@harperfast/harper 5.2.0-beta.4 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/bin/backup.ts +169 -0
  2. package/bin/cliOperations.ts +92 -73
  3. package/bin/harper.ts +25 -6
  4. package/components/Scope.ts +52 -6
  5. package/components/componentLoader.ts +107 -9
  6. package/components/mcp/toolRegistry.ts +10 -0
  7. package/components/mcp/tools/application.ts +12 -5
  8. package/components/mcp/tools/operations.ts +3 -0
  9. package/components/mcp/tools/schemas/operationDescriptions.ts +3 -0
  10. package/components/mcp/tools/schemas/operations.ts +9 -0
  11. package/components/operations.js +1 -0
  12. package/components/operationsValidation.js +32 -2
  13. package/components/scopeMount.ts +150 -0
  14. package/config-root.schema.json +4 -0
  15. package/dataLayer/backupManifest.ts +102 -0
  16. package/dataLayer/blobBackup.ts +286 -0
  17. package/dataLayer/harperBridge/ResourceBridge.ts +43 -0
  18. package/dataLayer/restoreMarker.ts +276 -0
  19. package/dataLayer/rocksdbBackup.ts +1100 -0
  20. package/dist/bin/backup.d.ts +9 -0
  21. package/dist/bin/backup.js +192 -0
  22. package/dist/bin/backup.js.map +1 -0
  23. package/dist/bin/cliOperations.d.ts +13 -0
  24. package/dist/bin/cliOperations.js +89 -70
  25. package/dist/bin/cliOperations.js.map +1 -1
  26. package/dist/bin/harper.d.ts +7 -0
  27. package/dist/bin/harper.js +27 -6
  28. package/dist/bin/harper.js.map +1 -1
  29. package/dist/components/Scope.d.ts +37 -1
  30. package/dist/components/Scope.js +48 -6
  31. package/dist/components/Scope.js.map +1 -1
  32. package/dist/components/componentLoader.d.ts +2 -6
  33. package/dist/components/componentLoader.js +91 -8
  34. package/dist/components/componentLoader.js.map +1 -1
  35. package/dist/components/mcp/toolRegistry.d.ts +7 -0
  36. package/dist/components/mcp/toolRegistry.js +10 -0
  37. package/dist/components/mcp/toolRegistry.js.map +1 -1
  38. package/dist/components/mcp/tools/application.js +11 -5
  39. package/dist/components/mcp/tools/application.js.map +1 -1
  40. package/dist/components/mcp/tools/operations.js +3 -0
  41. package/dist/components/mcp/tools/operations.js.map +1 -1
  42. package/dist/components/mcp/tools/schemas/operationDescriptions.js +2 -0
  43. package/dist/components/mcp/tools/schemas/operationDescriptions.js.map +1 -1
  44. package/dist/components/mcp/tools/schemas/operations.js +9 -0
  45. package/dist/components/mcp/tools/schemas/operations.js.map +1 -1
  46. package/dist/components/operations.js +2 -0
  47. package/dist/components/operations.js.map +1 -1
  48. package/dist/components/operationsValidation.js +34 -2
  49. package/dist/components/operationsValidation.js.map +1 -1
  50. package/dist/components/scopeMount.d.ts +86 -0
  51. package/dist/components/scopeMount.js +131 -0
  52. package/dist/components/scopeMount.js.map +1 -0
  53. package/dist/dataLayer/backupManifest.d.ts +26 -0
  54. package/dist/dataLayer/backupManifest.js +97 -0
  55. package/dist/dataLayer/backupManifest.js.map +1 -0
  56. package/dist/dataLayer/blobBackup.d.ts +87 -0
  57. package/dist/dataLayer/blobBackup.js +282 -0
  58. package/dist/dataLayer/blobBackup.js.map +1 -0
  59. package/dist/dataLayer/harperBridge/ResourceBridge.d.ts +3 -0
  60. package/dist/dataLayer/harperBridge/ResourceBridge.js +33 -0
  61. package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
  62. package/dist/dataLayer/restoreMarker.d.ts +122 -0
  63. package/dist/dataLayer/restoreMarker.js +261 -0
  64. package/dist/dataLayer/restoreMarker.js.map +1 -0
  65. package/dist/dataLayer/rocksdbBackup.d.ts +127 -0
  66. package/dist/dataLayer/rocksdbBackup.js +1039 -0
  67. package/dist/dataLayer/rocksdbBackup.js.map +1 -0
  68. package/dist/resources/DatabaseTransaction.js +0 -6
  69. package/dist/resources/DatabaseTransaction.js.map +1 -1
  70. package/dist/resources/ResourceInterface.d.ts +0 -3
  71. package/dist/resources/ResourceInterface.js.map +1 -1
  72. package/dist/resources/Table.js +22 -22
  73. package/dist/resources/Table.js.map +1 -1
  74. package/dist/resources/blob.d.ts +8 -0
  75. package/dist/resources/blob.js +16 -7
  76. package/dist/resources/blob.js.map +1 -1
  77. package/dist/resources/databases.d.ts +42 -1
  78. package/dist/resources/databases.js +276 -40
  79. package/dist/resources/databases.js.map +1 -1
  80. package/dist/resources/transaction.js +0 -3
  81. package/dist/resources/transaction.js.map +1 -1
  82. package/dist/server/REST.js +25 -9
  83. package/dist/server/REST.js.map +1 -1
  84. package/dist/server/fastifyRoutes.js +15 -1
  85. package/dist/server/fastifyRoutes.js.map +1 -1
  86. package/dist/server/itc/serverHandlers.js +7 -1
  87. package/dist/server/itc/serverHandlers.js.map +1 -1
  88. package/dist/server/jobs/jobProcess.js +20 -1
  89. package/dist/server/jobs/jobProcess.js.map +1 -1
  90. package/dist/server/jobs/jobRunner.js +10 -0
  91. package/dist/server/jobs/jobRunner.js.map +1 -1
  92. package/dist/server/jobs/jobs.js +11 -0
  93. package/dist/server/jobs/jobs.js.map +1 -1
  94. package/dist/server/middlewareChain.d.ts +10 -1
  95. package/dist/server/middlewareChain.js +81 -21
  96. package/dist/server/middlewareChain.js.map +1 -1
  97. package/dist/server/serverHelpers/serverHandlers.js +8 -4
  98. package/dist/server/serverHelpers/serverHandlers.js.map +1 -1
  99. package/dist/server/serverHelpers/serverUtilities.js +11 -0
  100. package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
  101. package/dist/server/static.js +11 -3
  102. package/dist/server/static.js.map +1 -1
  103. package/dist/utility/OperationFunctionCaller.js +25 -6
  104. package/dist/utility/OperationFunctionCaller.js.map +1 -1
  105. package/dist/utility/hdbTerms.d.ts +11 -1
  106. package/dist/utility/hdbTerms.js +11 -1
  107. package/dist/utility/hdbTerms.js.map +1 -1
  108. package/dist/utility/logging/harper_logger.d.ts +40 -0
  109. package/dist/utility/logging/harper_logger.js +746 -14
  110. package/dist/utility/logging/harper_logger.js.map +1 -1
  111. package/dist/utility/operation_authorization.js +13 -3
  112. package/dist/utility/operation_authorization.js.map +1 -1
  113. package/npm-shrinkwrap.json +3 -2
  114. package/package.json +4 -1
  115. package/resources/DESIGN.md +2 -0
  116. package/resources/DatabaseTransaction.ts +0 -3
  117. package/resources/ResourceInterface.ts +0 -3
  118. package/resources/Table.ts +20 -20
  119. package/resources/blob.ts +16 -6
  120. package/resources/databases.ts +272 -42
  121. package/resources/transaction.ts +0 -3
  122. package/server/DESIGN.md +16 -0
  123. package/server/REST.ts +25 -9
  124. package/server/fastifyRoutes.ts +20 -1
  125. package/server/itc/serverHandlers.js +7 -1
  126. package/server/jobs/jobProcess.ts +18 -1
  127. package/server/jobs/jobRunner.ts +10 -0
  128. package/server/jobs/jobs.ts +11 -0
  129. package/server/middlewareChain.ts +79 -20
  130. package/server/serverHelpers/serverHandlers.js +8 -4
  131. package/server/serverHelpers/serverUtilities.ts +19 -0
  132. package/server/static.ts +12 -3
  133. package/static/defaultConfig.yaml +1 -0
  134. package/studio/web/assets/{Chat-DK3GlWEb.js → Chat-DoVWScmq.js} +2 -2
  135. package/studio/web/assets/{Chat-DK3GlWEb.js.map → Chat-DoVWScmq.js.map} +1 -1
  136. package/studio/web/assets/{FloatingChat-fBcC1Ew_.js → FloatingChat-UZ2NsUOZ.js} +4 -4
  137. package/studio/web/assets/{FloatingChat-fBcC1Ew_.js.map → FloatingChat-UZ2NsUOZ.js.map} +1 -1
  138. package/studio/web/assets/{apiToken-DJo1nakA.js → apiToken-BUI_04o7.js} +2 -2
  139. package/studio/web/assets/{apiToken-DJo1nakA.js.map → apiToken-BUI_04o7.js.map} +1 -1
  140. package/studio/web/assets/{applications-BDfH8urd.js → applications-D03NA7wW.js} +2 -2
  141. package/studio/web/assets/{applications-BDfH8urd.js.map → applications-D03NA7wW.js.map} +1 -1
  142. package/studio/web/assets/{index-BHo3c2Gk.js → index-Bh_CNAHr.js} +6 -6
  143. package/studio/web/assets/index-Bh_CNAHr.js.map +1 -0
  144. package/studio/web/assets/{index.lazy-BTo0y6UM.js → index.lazy-Dx3MpyDC.js} +4 -4
  145. package/studio/web/assets/{index.lazy-BTo0y6UM.js.map → index.lazy-Dx3MpyDC.js.map} +1 -1
  146. package/studio/web/assets/{notifications-CMxvWNnz.js → notifications-0edoFTsb.js} +2 -2
  147. package/studio/web/assets/{notifications-CMxvWNnz.js.map → notifications-0edoFTsb.js.map} +1 -1
  148. package/studio/web/assets/{notifications-D3GoB26g.js → notifications-CwKhipK7.js} +2 -2
  149. package/studio/web/assets/{notifications-D3GoB26g.js.map → notifications-CwKhipK7.js.map} +1 -1
  150. package/studio/web/assets/{profile-Doj5FVDE.js → profile-DUfEPQtx.js} +2 -2
  151. package/studio/web/assets/{profile-Doj5FVDE.js.map → profile-DUfEPQtx.js.map} +1 -1
  152. package/studio/web/assets/{setComponentFile-yinsqJy0.js → setComponentFile-DMPo4UjC.js} +2 -2
  153. package/studio/web/assets/{setComponentFile-yinsqJy0.js.map → setComponentFile-DMPo4UjC.js.map} +1 -1
  154. package/studio/web/assets/{setup-DJwR0BHd.js → setup-B56Oz1_u.js} +2 -2
  155. package/studio/web/assets/{setup-DJwR0BHd.js.map → setup-B56Oz1_u.js.map} +1 -1
  156. package/studio/web/assets/{status-Br_AbsJs.js → status-BAod7p3o.js} +2 -2
  157. package/studio/web/assets/{status-Br_AbsJs.js.map → status-BAod7p3o.js.map} +1 -1
  158. package/studio/web/assets/{swagger-ui-react-02XH5sVf.js → swagger-ui-react-lQrBxfwM.js} +2 -2
  159. package/studio/web/assets/{swagger-ui-react-02XH5sVf.js.map → swagger-ui-react-lQrBxfwM.js.map} +1 -1
  160. package/studio/web/assets/{tsMode-D1DMKY7h.js → tsMode-CrHCRjTK.js} +2 -2
  161. package/studio/web/assets/{tsMode-D1DMKY7h.js.map → tsMode-CrHCRjTK.js.map} +1 -1
  162. package/studio/web/assets/{useEntityRestURL-DtRblRgw.js → useEntityRestURL-DoaBMEvU.js} +2 -2
  163. package/studio/web/assets/{useEntityRestURL-DtRblRgw.js.map → useEntityRestURL-DoaBMEvU.js.map} +1 -1
  164. package/studio/web/index.html +1 -1
  165. package/utility/OperationFunctionCaller.ts +24 -3
  166. package/utility/hdbTerms.ts +11 -1
  167. package/utility/logging/harper_logger.ts +729 -15
  168. package/utility/operation_authorization.ts +31 -3
  169. package/studio/web/assets/index-BHo3c2Gk.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/apiToken-DJo1nakA.js","assets/rolldown-runtime-CNC7AqOf.js","assets/button-oQgW4t1x.js","assets/vendor-core-xUefYpUO.js","assets/vendor-datadog-DyjkTkvg.js","assets/vendor-react-DeL8Gtgl.js","assets/vendor-ui-Bj22lHGK.js","assets/vendor-tanstack-0SjDjtT0.js","assets/card-BHplR9Xd.js","assets/notifications-D3GoB26g.js","assets/select-y6NKMkG_.js","assets/createLucideIcon-BDx8noBh.js","assets/x-C3uc0qMD.js","assets/setLocalStorage-CD_L8p_D.js","assets/useLocalStorage-hkNSGGg8.js","assets/textarea-DhLMZ3PA.js","assets/alertDialog-DSs2KlnR.js","assets/setup-DJwR0BHd.js","assets/editor.api-OBQnf1nL.js","assets/editor-jjEx9u7D.css","assets/dist-3T7cRma3.js","assets/toggleHighContrast-el2uNoWb.js","assets/toggleHighContrast--ixms01u.css","assets/editor-DK9rdQRE.js","assets/index.lazy-BTo0y6UM.js","assets/getRegistrationInfo-BOLlgqXr.js","assets/pollUnlessForbidden-HHdQZW1N.js","assets/authStore-CNoNfv0F.js","assets/useEntityRestURL-DtRblRgw.js","assets/index-BFYFtDGD.css","assets/applications-BDfH8urd.js","assets/useAuth-DvlnspkA.js","assets/tabs-CxZ4MxTw.js","assets/setComponentFile-yinsqJy0.js","assets/queryClient-CbA8wM7J.js","assets/errorText-NpBmvk9I.js","assets/applications-DNZhsH95.css","assets/jsonMode-Cjj7dtlr.js","assets/tokenization-uOBOyHAS.js","assets/workers-Bhsi-paP.js","assets/lspLanguageFeatures-DxCM7LI8.js","assets/tsMode-D1DMKY7h.js","assets/FloatingChat-fBcC1Ew_.js","assets/react-CjDfh48f.js","assets/status-Br_AbsJs.js","assets/linear-Clj7BvYC.js","assets/string-f6JzSHaO.js","assets/defaultLocale-C8Fc0cco.js","assets/init-Cs1-1e_z.js","assets/ordinal-BeZAVUpG.js","assets/time-V48BpMN7.js","assets/band-CcbG6rPL.js","assets/path-BWPyau1x.js","assets/math-Bi_r_ZWc.js","assets/array-BifhSqXX.js","assets/step-D4Q0arzR.js","assets/line-BMvOdiSv.js","assets/react-redux-Co6ou4E8.js","assets/getAnalytics-ChWFgfXd.js","assets/notifications-CMxvWNnz.js","assets/profile-Doj5FVDE.js"])))=>i.map(i=>d[i]);
2
- import{a as e,r as t,t as n}from"./rolldown-runtime-CNC7AqOf.js";import{a as r,c as i,d as a,f as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./authStore-CNoNfv0F.js";import{A as _,M as v,N as y,_ as b,a as x,b as S,c as C,f as w,k as T,l as E,m as D,n as O,o as k,r as A,v as j,x as ee,y as te}from"./vendor-core-xUefYpUO.js";import{i as M,n as N,t as P}from"./button-oQgW4t1x.js";import{A as F,C as I,D as ne,E as re,F as ie,I as ae,M as oe,N as L,O as se,P as ce,S as le,V as ue,_ as R,a as de,b as fe,c as pe,d as me,f as he,g as ge,i as _e,j as z,k as ve,l as ye,m as be,n as xe,o as Se,p as Ce,r as we,s as Te,t as Ee,u as De,v as B,w as Oe,x as ke,y as Ae}from"./vendor-tanstack-0SjDjtT0.js";import{a as je,i as Me,t as Ne}from"./vendor-datadog-DyjkTkvg.js";import{r as Pe,t as Fe}from"./vendor-react-DeL8Gtgl.js";import{a as Ie,i as Le,n as Re,o as ze,r as Be,s as Ve,t as He}from"./useAuth-DvlnspkA.js";import{$ as V,At as Ue,B as We,C as Ge,Ct as Ke,Dt as qe,Et as Je,H as Ye,Lt as Xe,Mt as Ze,Nt as Qe,Ot as $e,Pt as et,R as tt,Rt as H,S as nt,St as rt,Tt as it,U as at,V as ot,W as st,_t as ct,at as lt,b as ut,bt as dt,ct as ft,dt as pt,et as mt,ft as ht,gt,ht as _t,it as vt,jt as yt,kt as bt,lt as xt,mt as St,nt as Ct,ot as wt,pt as Tt,rt as Et,st as Dt,tt as Ot,ut as kt,v as At,vt as jt,wt as Mt,x as Nt,xt as Pt,y as Ft,yt as It,z as Lt,zt as Rt}from"./vendor-ui-Bj22lHGK.js";import{a as zt,i as Bt,n as Vt,r as Ht,t as Ut}from"./card-BHplR9Xd.js";import{t as U}from"./createLucideIcon-BDx8noBh.js";import{a as Wt,c as Gt,d as Kt,f as qt,g as Jt,i as Yt,l as Xt,m as Zt,n as Qt,o as $t,p as en,r as tn,s as nn,t as rn,u as an}from"./select-y6NKMkG_.js";import{a as on,i as sn,n as cn,r as ln,t as un}from"./getRegistrationInfo-BOLlgqXr.js";import{a as dn,c as fn,i as pn,l as mn,n as hn,o as gn,r as _n,s as vn,t as yn,u as bn}from"./textarea-DhLMZ3PA.js";import{i as xn,r as Sn,t as Cn}from"./x-C3uc0qMD.js";import{t as wn}from"./errorText-NpBmvk9I.js";import{n as Tn,t as En}from"./queryClient-CbA8wM7J.js";import{i as Dn,n as On,r as kn,t as An}from"./setLocalStorage-CD_L8p_D.js";import{t as jn}from"./useLocalStorage-hkNSGGg8.js";import{a as Mn,i as Nn,n as Pn,o as W,r as Fn,s as In,t as Ln}from"./pollUnlessForbidden-HHdQZW1N.js";import{m as Rn,n as zn}from"./editor.api-OBQnf1nL.js";import{t as Bn}from"./tokenization-uOBOyHAS.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function Vn(e){return e!==null&&!!e.username}function Hn(e){if(e&&!Vn(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var Un=U(`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`}]]),Wn=U(`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`}]]),Gn=U(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Kn=U(`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`}]]),qn=U(`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`}]]),Jn=U(`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`}]]),Yn=U(`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`}]]),Xn=U(`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`}]]),Zn=U(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),Qn=U(`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`}]]),$n=U(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),er=U(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),tr=U(`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`}]]),nr=U(`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`}]]),rr=U(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ir=U(`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`}]]),ar=U(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),or=U(`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`}]]),sr=U(`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`}]]),cr=U(`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`}]]),lr=U(`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`}]]),ur=U(`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`}]]),dr=U(`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`}]]),fr=U(`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`}]]),pr=U(`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`}]]),mr=U(`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`}]]),hr=U(`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`}]]),gr=U(`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`}]]),_r=U(`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`}]]),vr=U(`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`}]]),yr=U(`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`}]]),br=U(`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`}]]),xr=U(`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`}]]),Sr=U(`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`}]]),Cr=U(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),wr=U(`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`}]]),Tr=U(`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`}]]),Er=U(`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`}]]),Dr=U(`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`}]]),Or=U(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),kr=U(`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`}]]),Ar=U(`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`}]]),jr=U(`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`}]]),Mr=U(`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`}]]),Nr=U(`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`}]]),Pr=U(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Fr=U(`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`}]]),Ir=U(`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`}]]),Lr=U(`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`}]]),Rr=U(`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`}]]),zr=U(`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`}]]),Br=U(`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`}]]),Vr=U(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Hr=U(`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`}]]),Ur=U(`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`}]]),Wr=U(`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`}]]),Gr=U(`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`}]]),Kr=U(`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`}]]),qr=U(`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`}]]),Jr=U(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Yr=U(`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`}]]),Xr=U(`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`}]]),Zr=U(`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=U(`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`}]]),$r=U(`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`}]]),ei=U(`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`}]]),ti=U(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),ni=U(`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`}]]),ri=U(`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`}]]),ii=U(`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`}]]);U(`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 ai=U(`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`}]]),oi=U(`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`}]]),si=U(`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`}]]),ci=U(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),li=U(`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`}]]),ui=U(`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`}]]),di=U(`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`}]]),fi=U(`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`}]]),pi=U(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),mi=U(`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`}]]),hi=U(`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`}]]),gi=U(`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`}]]),_i=U(`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`}]]),vi=U(`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`}]]),yi=U(`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`}]]),bi=U(`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`}]]),xi=U(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),G=Pe();function Si({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=ze();return Hn(a),(0,G.jsxs)(Ut,{className:N(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,G.jsxs)(Bt,{children:[(0,G.jsx)(zt,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:n??`Component Error`})}),(0,G.jsx)(Ht,{children:t.message})]}),(0,G.jsxs)(Vt,{children:[i,r!==!1&&(a&&!o?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Go to Sign In Page`]})}))]})]})}function Ci(){let{user:e,isLoading:t}=ze();return Hn(e),(0,G.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,G.jsxs)(Ut,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,G.jsx)(Bt,{children:(0,G.jsx)(zt,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,G.jsx)(Vt,{children:e&&!t?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Go Sign In Page`]})})})]})})}function wi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var K=e(je(),1);function Ti({...e}){return(0,G.jsx)(Ke,{"data-slot":`dropdown-menu`,...e})}function Ei({...e}){return(0,G.jsx)(et,{"data-slot":`dropdown-menu-trigger`,...e})}function Di({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(bt,{children:(0,G.jsx)(it,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:N(`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 Oi({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(Je,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:N(`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 ki({className:e,children:t,checked:n,...r}){return(0,G.jsxs)(Mt,{"data-slot":`dropdown-menu-checkbox-item`,className:N(`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,G.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,G.jsx)(qe,{children:(0,G.jsx)(xn,{className:`size-4`})})}),t]})}function Ai({className:e,inset:t,...n}){return(0,G.jsx)($e,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:N(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function ji({className:e,...t}){return(0,G.jsx)(Ue,{"data-slot":`dropdown-menu-separator`,className:N(`bg-border -mx-1 my-1 h-px`,e),...t})}function Mi({className:e,...t}){return(0,G.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:N(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ni({...e}){return(0,G.jsx)(yt,{"data-slot":`dropdown-menu-sub`,...e})}function Pi({className:e,inset:t,children:n,...r}){return(0,G.jsxs)(Qe,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:N(`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,G.jsx)(er,{className:`ml-auto size-4`})]})}function Fi({className:e,...t}){return(0,G.jsx)(Ze,{"data-slot":`dropdown-menu-sub-content`,className:N(`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 Ii=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Li=`block p-2 rounded-lg text-sm transition-colors`,Ri={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},zi={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Bi({items:e,ariaLabel:t}){let{pathname:n}=De(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(B,{to:e.to,className:Ii,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:[(0,G.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,G.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,G.jsx)(B,{to:e.to,className:Li,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:e.label},e.to))})]},e.to)})}),(0,G.jsx)(`div`,{className:`md:hidden`,children:(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full justify-between`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(a,{className:`size-4`}),i.label]}),(0,G.jsx)(Sn,{className:`size-4`})]})}),(0,G.jsx)(Di,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,G.jsx)(Oi,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,className:`flex items-center gap-2`,children:[(0,G.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,G.jsx)(Oi,{asChild:!0,children:(0,G.jsx)(B,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Vi=[{to:`/admin`,label:`API Token`,icon:kr,exact:!0},{to:`/admin/notifications`,label:`Notifications`,icon:qn}];function Hi(){let{isLoading:e,user:t}=Le();return e?null:Re(t)?(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(Bi,{items:Vi,ariaLabel:`Admin sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,G.jsx)(Ce,{})})]})}):(0,G.jsx)(fe,{to:`/`,replace:!0})}function Ui({className:e,text:t,centered:n,...r}){return(0,G.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,G.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Wi(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,G.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 Gi(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var Ki=T(`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 qi({className:e,variant:t,asChild:n=!1,...r}){return(0,G.jsx)(n?Rt:`span`,{"data-slot":`badge`,className:N(Ki({variant:t}),e),...r})}function Ji({className:e,children:t,...n}){return(0,G.jsxs)(jt,{"data-slot":`scroll-area`,className:N(`relative`,e),...n,children:[(0,G.jsx)(rt,{"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,G.jsx)(Yi,{}),(0,G.jsx)(It,{})]})}function Yi({className:e,orientation:t=`vertical`,...n}){return(0,G.jsx)(dt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:N(`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,G.jsx)(Pt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var Xi=[`notification-acks`];function Zi(){let e=kn(On.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Qi(e){Tn.setQueryData(Xi,e);try{An(On.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function $i(){return z({queryKey:Xi,queryFn:Zi,staleTime:1/0,gcTime:1/0,initialData:Zi})}function ea(e){Qi(Array.from(new Set([...Zi(),e])))}function ta(e){Qi(Zi().filter(t=>t!==e))}function na(){let{data:e}=L($i());return(0,K.useMemo)(()=>new Set(e??[]),[e])}var ra={critical:{severity:`critical`,label:`Critical`,Icon:Gr,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:_i,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:Or,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},ia=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),aa=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),oa=new Set([`info`,`information`,`informational`,`success`,`ok`]);function sa(e){let t=(e??``).trim().toLowerCase();return aa.has(t)?`warning`:oa.has(t)?`info`:(ia.has(t),`critical`)}function ca(e){return ra[sa(e)]}var la={critical:0,warning:1,info:2};function ua(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 da(e){let t=ua(e);return t.kind===`valid`?t.ms:null}function fa(e){return new Date(e).toLocaleString()}function pa(e,t){let n=ua(e.startAt),r=ua(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${fa(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${fa(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${fa(r.ms)}`}:{state:`active`,label:`Active`}}var ma=new Set([`http`,`https`,`mailto`]);function ha(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?ma.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function ga({url:e,className:t,children:n,onNavigate:r}){let i=ha(e);return i?i.kind===`external`?(0,G.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,G.jsx)(gr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,G.jsx)(B,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var _a=[`system-status`];async function va(){let{data:e}=await M.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function ya(){return z({queryKey:_a,queryFn:va,refetchInterval:6e4,staleTime:3e4})}var ba=3e4,xa=new Set,Sa=Date.now(),Ca=null;function wa(e){return xa.add(e),Ca||=(Sa=Date.now(),setInterval(()=>{Sa=Date.now(),xa.forEach(e=>e())},ba)),()=>{xa.delete(e),xa.size===0&&Ca&&(clearInterval(Ca),Ca=null)}}function Ta(){return(0,K.useSyncExternalStore)(wa,()=>Sa,()=>Sa)}function Ea(){return L(ya())}function Da(){let[e,t]=(0,K.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,K.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 Oa=(0,K.createContext)([`system`,()=>{}]);function ka({children:e}){let[t,n]=jn(On.Theme,`system`),r=Da();return(0,K.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,G.jsx)(Oa.Provider,{value:[t,n],children:e})}function Aa(){return(0,K.useContext)(Oa)}var ja=[{value:`light`,icon:(0,G.jsx)(li,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,G.jsx)(Hr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,G.jsx)(Ur,{className:`size-4`}),label:`Dark`}];function Ma(){let[e,t]=Aa();return(0,G.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:ja.map(({value:n,icon:r,label:i})=>(0,G.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 Na({className:e,...t}){return(0,G.jsx)(`div`,{className:N(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,G.jsx)(ct,{"data-slot":`navigation-menu-viewport`,className:N(`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 Pa({className:e,children:t,viewport:n=!0,...r}){return(0,G.jsxs)(Tt,{"data-slot":`navigation-menu`,"data-viewport":n,className:N(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,G.jsx)(Na,{})]})}function Fa({className:e,...t}){return(0,G.jsx)(St,{"data-slot":`navigation-menu-item`,className:N(`relative`,e),...t})}function Ia({className:e,...t}){return(0,G.jsx)(_t,{"data-slot":`navigation-menu-link`,className:N(`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 La({className:e,...t}){return(0,G.jsx)(gt,{"data-slot":`navigation-menu-list`,className:N(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function Ra({delayDuration:e=0,...t}){return(0,G.jsx)(pt,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function za({...e}){return(0,G.jsx)(Ra,{children:(0,G.jsx)(Dt,{"data-slot":`tooltip`,...e})})}function Ba({...e}){return(0,G.jsx)(ht,{"data-slot":`tooltip-trigger`,...e})}function Va({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,G.jsx)(kt,{children:(0,G.jsxs)(xt,{"data-slot":`tooltip-content`,sideOffset:t,className:N(`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,G.jsx)(ft,{className:N(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Ha(){let e=`v5.2.0-beta.4`;return(0,G.jsx)(`a`,{href:e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,G.jsxs)(`span`,{className:N(Ki({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ua(){localStorage.clear()}function Wa(){sessionStorage.clear()}async function Ga(){u.setUserForEntity(h,null),Tn.getQueryCache().clear(),Ua(),Wa(),await Tn.invalidateQueries({refetchType:`none`})}async function Ka(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:h})}function qa(){let e=Mn();return F({mutationFn:()=>Ka({instanceClient:e}),onSuccess:Ga})}var Ja={className:`text-foreground dark:text-white font-semibold`};function Ya(){let{mutate:e}=qa(),t=ke(),{user:n}=ze(),r=Re(n),i=re(),a=(0,K.useCallback)(()=>{e(void 0,{onSuccess:async()=>{H.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,K.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,G.jsx)(Jn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,G.jsx)(Xn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,G.jsx)(Wi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,G.jsx)(Lr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Fn),[a,r]);return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(eo,{menuItems:o}),(0,G.jsx)(Qa,{menuItems:o})]}):(0,G.jsx)(Za,{})}function Xa(e){return e.items!==void 0}function Za(){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsx)(Gi,{})}),(0,G.jsx)(Ha,{})]}),(0,G.jsx)(Pa,{children:(0,G.jsxs)(La,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,G.jsx)(Fa,{children:(0,G.jsx)(Ia,{asChild:!0,children:(0,G.jsxs)(B,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,G.jsx)(Jn,{}),` `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,G.jsx)(Fa,{children:(0,G.jsx)(Ma,{})}),(0,G.jsx)(Fa,{children:(0,G.jsx)(Ia,{asChild:!0,children:(0,G.jsxs)(B,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Ja,children:[(0,G.jsx)(Fr,{}),` Sign In`]})})})]})})]})}function Qa({menuItems:e}){let{user:t}=ze();return Hn(t),(0,G.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Gi,{})}),(0,G.jsx)(Ha,{})]}),(0,G.jsx)(Pa,{children:(0,G.jsxs)(La,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>Xa(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,G.jsx)($a,{menuItem:e},e.text))},e.text):(0,G.jsx)($a,{menuItem:e},e.text)),!1,(0,G.jsx)(Fa,{children:(0,G.jsx)(Ma,{})})]})})]})})}function $a({menuItem:e}){return(0,G.jsx)(Fa,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(Ia,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?Ja:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,G.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,G.jsx)(Va,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function eo({menuItems:e}){let{user:t}=ze();Hn(t);let[n,r]=(0,K.useState)(!1),i=(0,K.useCallback)(()=>r(e=>!e),[]),a=(0,K.useCallback)(()=>r(!1),[]);return(0,G.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Gi,{})}),(0,G.jsx)(Ha,{}),(0,G.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,G.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,G.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,G.jsx)(Cn,{}):(0,G.jsx)(Vr,{})]})]})]}),(0,G.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,G.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,G.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,G.jsx)(Ma,{})}),e.map(e=>Xa(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,G.jsx)(to,{menuItem:e,onClick:a},e.text))},e.text):(0,G.jsx)(to,{menuItem:e,onClick:a},e.text))]})]})}function to({menuItem:e,onClick:t}){let n=(0,K.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,G.jsxs)(B,{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?Ja:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function no(){let{isLoading:e}=ze(),{createCluster:t}=le({strict:!1}),[,n]=jn(On.SavedClusterState,null);return(0,K.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,G.jsx)(Ui,{className:`fixed z-50 translate-1/2`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Ya,{})}),(0,G.jsx)(`main`,{children:(0,G.jsx)(Ce,{})})]})}function ro(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var io=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function ao(){let e=ro();return!io.includes(e)&&{redirect:e}}var oo=!1;function so(){(0,K.useEffect)(()=>{oo||=!0},[])}function co(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ye,{}),(0,G.jsx)(Ce,{})]})}var lo=ge()({component:co}),uo=R({getParentRoute:()=>lo,id:`_dashboardLayout`,component:no,beforeLoad:({context:e})=>{let t=e.authentication[h];if(t&&!t.isLoading&&!t.user)throw ve({to:`/sign-in`,search:ao()})}}),fo=R({getParentRoute:()=>uo,path:`admin`,component:Hi});R({getParentRoute:()=>fo,path:`/`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./apiToken-DJo1nakA.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),`ApiTokenIndex`)}),R({getParentRoute:()=>fo,path:`/notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./notifications-D3GoB26g.js`),__vite__mapDeps([9,1,2,3,4,5,6,7,10,11,12,13,14,15,16])),`NotificationsAdminIndex`)});function po(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Ya,{})}),(0,G.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,G.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,G.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,G.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,G.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,G.jsx)(Ce,{})})})]})]})}var mo;function ho(){(0,K.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=ke(),t=re(),n=ae(),{redirect:r}=le({strict:!1});return(0,K.useEffect)(()=>{xo||=(async function(){let a=await i().catch(()=>null);if(!a)H.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{u.setUserForEntity(h,a),bo();let i=Hn(a),o=_o(a.email);mo?.identify?.({username:a.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:m,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:i})}xo=null})()},[]),(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,G.jsx)(`div`,{className:`underline flex gap-4`,children:(0,G.jsx)(B,{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=De(),{organization:n,instance:r,cluster:i}=Ae({strict:!1});return(0,G.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...(0,K.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,G.jsxs)(B,{to:`/`,children:[(0,G.jsx)(Dr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,G.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,G.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,G.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,G.jsx)(B,{to:s,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:c},s))}return a},[t.pathname,i?.name,r?.name,n?.name]),e&&(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,G.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,G.jsxs)(Va,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,G.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var q=Ct,Do=(0,K.createContext)({}),Oo=(0,K.createContext)({});function ko(){let e=(0,K.useContext)(Do),t=(0,K.useContext)(Oo),{getFieldState:n}=lt(),r=wt({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}=ko();return(0,G.jsx)(Rt,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,G.jsx)(Do,{value:{name:e.name},children:(0,G.jsx)(Ot,{...e})})}function X({className:e,...t}){return(0,G.jsx)(Oo,{value:{id:(0,K.useId)()},children:(0,G.jsx)(`div`,{"data-slot":`form-item`,className:N(`grid gap-2`,e),...t})})}function Ao({className:e,...t}){return(0,G.jsx)(mt,{"data-slot":`label`,className:N(`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}=ko();return(0,G.jsx)(Ao,{"data-slot":`form-label`,"data-error":!!n,className:N(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=ko(),i=n?String(n?.message):t.children;return i?(0,G.jsx)(`p`,{"data-slot":`form-message`,id:r,className:N(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,G.jsx)(`input`,{type:t,"data-slot":`input`,className:N(`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/apiToken-BUI_04o7.js","assets/rolldown-runtime-CNC7AqOf.js","assets/button-oQgW4t1x.js","assets/vendor-core-xUefYpUO.js","assets/vendor-datadog-DyjkTkvg.js","assets/vendor-react-DeL8Gtgl.js","assets/vendor-ui-Bj22lHGK.js","assets/vendor-tanstack-0SjDjtT0.js","assets/card-BHplR9Xd.js","assets/notifications-CwKhipK7.js","assets/select-y6NKMkG_.js","assets/createLucideIcon-BDx8noBh.js","assets/x-C3uc0qMD.js","assets/setLocalStorage-CD_L8p_D.js","assets/useLocalStorage-hkNSGGg8.js","assets/textarea-DhLMZ3PA.js","assets/alertDialog-DSs2KlnR.js","assets/setup-B56Oz1_u.js","assets/editor.api-OBQnf1nL.js","assets/editor-jjEx9u7D.css","assets/dist-3T7cRma3.js","assets/toggleHighContrast-el2uNoWb.js","assets/toggleHighContrast--ixms01u.css","assets/editor-DK9rdQRE.js","assets/index.lazy-Dx3MpyDC.js","assets/getRegistrationInfo-BOLlgqXr.js","assets/pollUnlessForbidden-HHdQZW1N.js","assets/authStore-CNoNfv0F.js","assets/useEntityRestURL-DoaBMEvU.js","assets/index-BFYFtDGD.css","assets/applications-D03NA7wW.js","assets/useAuth-DvlnspkA.js","assets/tabs-CxZ4MxTw.js","assets/setComponentFile-DMPo4UjC.js","assets/queryClient-CbA8wM7J.js","assets/errorText-NpBmvk9I.js","assets/applications-DNZhsH95.css","assets/jsonMode-Cjj7dtlr.js","assets/tokenization-uOBOyHAS.js","assets/workers-Bhsi-paP.js","assets/lspLanguageFeatures-DxCM7LI8.js","assets/tsMode-CrHCRjTK.js","assets/FloatingChat-UZ2NsUOZ.js","assets/react-CjDfh48f.js","assets/status-BAod7p3o.js","assets/linear-Clj7BvYC.js","assets/string-f6JzSHaO.js","assets/defaultLocale-C8Fc0cco.js","assets/init-Cs1-1e_z.js","assets/ordinal-BeZAVUpG.js","assets/time-V48BpMN7.js","assets/band-CcbG6rPL.js","assets/path-BWPyau1x.js","assets/math-Bi_r_ZWc.js","assets/array-BifhSqXX.js","assets/step-D4Q0arzR.js","assets/line-BMvOdiSv.js","assets/react-redux-Co6ou4E8.js","assets/getAnalytics-ChWFgfXd.js","assets/notifications-0edoFTsb.js","assets/profile-DUfEPQtx.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,r as t,t as n}from"./rolldown-runtime-CNC7AqOf.js";import{a as r,c as i,d as a,f as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./authStore-CNoNfv0F.js";import{A as _,M as v,N as y,_ as b,a as x,b as S,c as C,f as w,k as T,l as E,m as D,n as O,o as k,r as A,v as j,x as ee,y as te}from"./vendor-core-xUefYpUO.js";import{i as M,n as N,t as P}from"./button-oQgW4t1x.js";import{A as F,C as I,D as ne,E as re,F as ie,I as ae,M as oe,N as L,O as se,P as ce,S as le,V as ue,_ as R,a as de,b as fe,c as pe,d as me,f as he,g as ge,i as _e,j as z,k as ve,l as ye,m as be,n as xe,o as Se,p as Ce,r as we,s as Te,t as Ee,u as De,v as B,w as Oe,x as ke,y as Ae}from"./vendor-tanstack-0SjDjtT0.js";import{a as je,i as Me,t as Ne}from"./vendor-datadog-DyjkTkvg.js";import{r as Pe,t as Fe}from"./vendor-react-DeL8Gtgl.js";import{a as Ie,i as Le,n as Re,o as ze,r as Be,s as Ve,t as He}from"./useAuth-DvlnspkA.js";import{$ as V,At as Ue,B as We,C as Ge,Ct as Ke,Dt as qe,Et as Je,H as Ye,Lt as Xe,Mt as Ze,Nt as Qe,Ot as $e,Pt as et,R as tt,Rt as H,S as nt,St as rt,Tt as it,U as at,V as ot,W as st,_t as ct,at as lt,b as ut,bt as dt,ct as ft,dt as pt,et as mt,ft as ht,gt,ht as _t,it as vt,jt as yt,kt as bt,lt as xt,mt as St,nt as Ct,ot as wt,pt as Tt,rt as Et,st as Dt,tt as Ot,ut as kt,v as At,vt as jt,wt as Mt,x as Nt,xt as Pt,y as Ft,yt as It,z as Lt,zt as Rt}from"./vendor-ui-Bj22lHGK.js";import{a as zt,i as Bt,n as Vt,r as Ht,t as Ut}from"./card-BHplR9Xd.js";import{t as U}from"./createLucideIcon-BDx8noBh.js";import{a as Wt,c as Gt,d as Kt,f as qt,g as Jt,i as Yt,l as Xt,m as Zt,n as Qt,o as $t,p as en,r as tn,s as nn,t as rn,u as an}from"./select-y6NKMkG_.js";import{a as on,i as sn,n as cn,r as ln,t as un}from"./getRegistrationInfo-BOLlgqXr.js";import{a as dn,c as fn,i as pn,l as mn,n as hn,o as gn,r as _n,s as vn,t as yn,u as bn}from"./textarea-DhLMZ3PA.js";import{i as xn,r as Sn,t as Cn}from"./x-C3uc0qMD.js";import{t as wn}from"./errorText-NpBmvk9I.js";import{n as Tn,t as En}from"./queryClient-CbA8wM7J.js";import{i as Dn,n as On,r as kn,t as An}from"./setLocalStorage-CD_L8p_D.js";import{t as jn}from"./useLocalStorage-hkNSGGg8.js";import{a as Mn,i as Nn,n as Pn,o as W,r as Fn,s as In,t as Ln}from"./pollUnlessForbidden-HHdQZW1N.js";import{m as Rn,n as zn}from"./editor.api-OBQnf1nL.js";import{t as Bn}from"./tokenization-uOBOyHAS.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function Vn(e){return e!==null&&!!e.username}function Hn(e){if(e&&!Vn(e)){let t=Object.keys(e.roles);if(t.length===1)return`/${t[0]}`}return`/`}var Un=U(`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`}]]),Wn=U(`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`}]]),Gn=U(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Kn=U(`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`}]]),qn=U(`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`}]]),Jn=U(`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`}]]),Yn=U(`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`}]]),Xn=U(`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`}]]),Zn=U(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),Qn=U(`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`}]]),$n=U(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),er=U(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),tr=U(`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`}]]),nr=U(`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`}]]),rr=U(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ir=U(`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`}]]),ar=U(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),or=U(`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`}]]),sr=U(`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`}]]),cr=U(`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`}]]),lr=U(`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`}]]),ur=U(`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`}]]),dr=U(`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`}]]),fr=U(`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`}]]),pr=U(`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`}]]),mr=U(`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`}]]),hr=U(`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`}]]),gr=U(`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`}]]),_r=U(`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`}]]),vr=U(`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`}]]),yr=U(`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`}]]),br=U(`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`}]]),xr=U(`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`}]]),Sr=U(`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`}]]),Cr=U(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),wr=U(`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`}]]),Tr=U(`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`}]]),Er=U(`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`}]]),Dr=U(`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`}]]),Or=U(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),kr=U(`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`}]]),Ar=U(`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`}]]),jr=U(`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`}]]),Mr=U(`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`}]]),Nr=U(`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`}]]),Pr=U(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Fr=U(`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`}]]),Ir=U(`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`}]]),Lr=U(`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`}]]),Rr=U(`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`}]]),zr=U(`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`}]]),Br=U(`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`}]]),Vr=U(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Hr=U(`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`}]]),Ur=U(`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`}]]),Wr=U(`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`}]]),Gr=U(`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`}]]),Kr=U(`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`}]]),qr=U(`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`}]]),Jr=U(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Yr=U(`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`}]]),Xr=U(`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`}]]),Zr=U(`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=U(`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`}]]),$r=U(`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`}]]),ei=U(`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`}]]),ti=U(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),ni=U(`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`}]]),ri=U(`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`}]]),ii=U(`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`}]]);U(`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 ai=U(`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`}]]),oi=U(`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`}]]),si=U(`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`}]]),ci=U(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),li=U(`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`}]]),ui=U(`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`}]]),di=U(`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`}]]),fi=U(`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`}]]),pi=U(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),mi=U(`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`}]]),hi=U(`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`}]]),gi=U(`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`}]]),_i=U(`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`}]]),vi=U(`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`}]]),yi=U(`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`}]]),bi=U(`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`}]]),xi=U(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),G=Pe();function Si({className:e,error:t,title:n,showReturnToHome:r,children:i}){let{user:a,isLoading:o}=ze();return Hn(a),(0,G.jsxs)(Ut,{className:N(`text-red p-5 border border-red rounded-md m-12 mt-36`,e),children:[(0,G.jsxs)(Bt,{children:[(0,G.jsx)(zt,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:n??`Component Error`})}),(0,G.jsx)(Ht,{children:t.message})]}),(0,G.jsxs)(Vt,{children:[i,r!==!1&&(a&&!o?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Go to Sign In Page`]})}))]})]})}function Ci(){let{user:e,isLoading:t}=ze();return Hn(e),(0,G.jsx)(`div`,{className:`flex items-center justify-center h-screen px-3`,children:(0,G.jsxs)(Ut,{className:`text-red p-5 border border-red rounded-md w-full max-w-md`,children:[(0,G.jsx)(Bt,{children:(0,G.jsx)(zt,{className:`text-2xl`,children:(0,G.jsx)(`h2`,{children:`Sorry, Page Not Found`})})}),(0,G.jsx)(Vt,{children:e&&!t?(0,G.jsx)(B,{to:`/`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Return to Home`]})}):(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsxs)(P,{children:[` `,(0,G.jsx)(on,{}),` Go Sign In Page`]})})})]})})}function wi(){return`ontouchstart`in window||navigator.maxTouchPoints>0}var K=e(je(),1);function Ti({...e}){return(0,G.jsx)(Ke,{"data-slot":`dropdown-menu`,...e})}function Ei({...e}){return(0,G.jsx)(et,{"data-slot":`dropdown-menu-trigger`,...e})}function Di({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(bt,{children:(0,G.jsx)(it,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:N(`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 Oi({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(Je,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:N(`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 ki({className:e,children:t,checked:n,...r}){return(0,G.jsxs)(Mt,{"data-slot":`dropdown-menu-checkbox-item`,className:N(`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,G.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,G.jsx)(qe,{children:(0,G.jsx)(xn,{className:`size-4`})})}),t]})}function Ai({className:e,inset:t,...n}){return(0,G.jsx)($e,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:N(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function ji({className:e,...t}){return(0,G.jsx)(Ue,{"data-slot":`dropdown-menu-separator`,className:N(`bg-border -mx-1 my-1 h-px`,e),...t})}function Mi({className:e,...t}){return(0,G.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:N(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ni({...e}){return(0,G.jsx)(yt,{"data-slot":`dropdown-menu-sub`,...e})}function Pi({className:e,inset:t,children:n,...r}){return(0,G.jsxs)(Qe,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:N(`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,G.jsx)(er,{className:`ml-auto size-4`})]})}function Fi({className:e,...t}){return(0,G.jsx)(Ze,{"data-slot":`dropdown-menu-sub-content`,className:N(`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 Ii=`flex items-center gap-3 p-2 rounded-lg text-sm transition-colors`,Li=`block p-2 rounded-lg text-sm transition-colors`,Ri={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-grey-700`},zi={className:`font-medium text-primary bg-primary/10 dark:text-white dark:bg-white/10`};function Bi({items:e,ariaLabel:t}){let{pathname:n}=De(),r=e=>e.exact?n===e.to:n.startsWith(e.to),i=e.find(r)??e[0],a=i.icon;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`hidden md:flex flex-col gap-1`,"aria-label":t,children:e.map(e=>{let t=e.icon;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(B,{to:e.to,className:Ii,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:[(0,G.jsx)(t,{className:`size-4 shrink-0`}),e.label]}),e.children&&r(e)&&(0,G.jsx)(`div`,{className:`mt-1 ml-4 flex flex-col gap-1 border-l border-border pl-3`,children:e.children.map(e=>(0,G.jsx)(B,{to:e.to,className:Li,activeOptions:{exact:!!e.exact},activeProps:zi,inactiveProps:Ri,children:e.label},e.to))})]},e.to)})}),(0,G.jsx)(`div`,{className:`md:hidden`,children:(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full justify-between`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(a,{className:`size-4`}),i.label]}),(0,G.jsx)(Sn,{className:`size-4`})]})}),(0,G.jsx)(Di,{align:`start`,className:`w-(--radix-dropdown-menu-trigger-width)`,children:e.map(e=>{let t=e.icon;return[(0,G.jsx)(Oi,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,className:`flex items-center gap-2`,children:[(0,G.jsx)(t,{className:`size-4`}),e.label]})},e.to),...e.children&&r(e)?e.children.map(e=>(0,G.jsx)(Oi,{asChild:!0,children:(0,G.jsx)(B,{to:e.to,className:`flex items-center gap-2 pl-8`,children:e.label})},e.to)):[]]})})]})})]})}var Vi=[{to:`/admin`,label:`API Token`,icon:kr,exact:!0},{to:`/admin/notifications`,label:`Notifications`,icon:qn}];function Hi(){let{isLoading:e,user:t}=Le();return e?null:Re(t)?(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(Bi,{items:Vi,ariaLabel:`Admin sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:(0,G.jsx)(Ce,{})})]})}):(0,G.jsx)(fe,{to:`/`,replace:!0})}function Ui({className:e,text:t,centered:n,...r}){return(0,G.jsxs)(`div`,{className:`text-foreground h-full w-full ${e||``} ${n?`flex flex-col items-center justify-center`:``}`,...r,children:[(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`100px`,height:`100px`,alt:`HDB Dog Logo Loading`,className:`inline-block`}),(0,G.jsx)(`p`,{className:`pt-4`,children:t||`Loading...`})]})}function Wi(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 126.644 96`,width:24,height:24,children:(0,G.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 Gi(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`img`,{src:`/harper-studio_white.png`,alt:`Harper Studio`,className:`w-64 hidden md:inline-block`}),(0,G.jsx)(`img`,{src:`/HDBDogOnly.svg`,width:`50px`,height:`44px`,alt:`Harper`,className:`inline-block md:hidden`})]})}var Ki=T(`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 qi({className:e,variant:t,asChild:n=!1,...r}){return(0,G.jsx)(n?Rt:`span`,{"data-slot":`badge`,className:N(Ki({variant:t}),e),...r})}function Ji({className:e,children:t,...n}){return(0,G.jsxs)(jt,{"data-slot":`scroll-area`,className:N(`relative`,e),...n,children:[(0,G.jsx)(rt,{"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,G.jsx)(Yi,{}),(0,G.jsx)(It,{})]})}function Yi({className:e,orientation:t=`vertical`,...n}){return(0,G.jsx)(dt,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:N(`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,G.jsx)(Pt,{"data-slot":`scroll-area-thumb`,className:`bg-border relative flex-1 rounded-full`})})}var Xi=[`notification-acks`];function Zi(){let e=kn(On.AckedNotificationIds,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Qi(e){Tn.setQueryData(Xi,e);try{An(On.AckedNotificationIds,e)}catch(e){console.warn(`[notifications] could not persist acknowledgements`,e)}}function $i(){return z({queryKey:Xi,queryFn:Zi,staleTime:1/0,gcTime:1/0,initialData:Zi})}function ea(e){Qi(Array.from(new Set([...Zi(),e])))}function ta(e){Qi(Zi().filter(t=>t!==e))}function na(){let{data:e}=L($i());return(0,K.useMemo)(()=>new Set(e??[]),[e])}var ra={critical:{severity:`critical`,label:`Critical`,Icon:Gr,badgeVariant:`destructive`,bannerClass:`bg-destructive/10 border-destructive/40 text-foreground`,iconClass:`text-destructive`},warning:{severity:`warning`,label:`Warning`,Icon:_i,badgeVariant:`warning`,bannerClass:`bg-yellow/10 border-yellow/40 text-foreground`,iconClass:`text-yellow`},info:{severity:`info`,label:`Info`,Icon:Or,badgeVariant:`secondary`,bannerClass:`bg-secondary/20 border-secondary/50 text-foreground`,iconClass:`text-secondary-foreground`}},ia=new Set([`critical`,`error`,`outage`,`incident`,`down`,`danger`]),aa=new Set([`warning`,`warn`,`maintenance`,`degraded`,`notice`]),oa=new Set([`info`,`information`,`informational`,`success`,`ok`]);function sa(e){let t=(e??``).trim().toLowerCase();return aa.has(t)?`warning`:oa.has(t)?`info`:(ia.has(t),`critical`)}function ca(e){return ra[sa(e)]}var la={critical:0,warning:1,info:2};function ua(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 da(e){let t=ua(e);return t.kind===`valid`?t.ms:null}function fa(e){return new Date(e).toLocaleString()}function pa(e,t){let n=ua(e.startAt),r=ua(e.endAt);return n.kind===`invalid`||r.kind===`invalid`?{state:`expired`,label:`Schedule unavailable`}:n.kind===`valid`&&t<n.ms?{state:`upcoming`,label:`Starts ${fa(n.ms)}`}:r.kind===`valid`&&t>r.ms?{state:`expired`,label:`Ended ${fa(r.ms)}`}:r.kind===`valid`?{state:`active`,label:`Active until ${fa(r.ms)}`}:{state:`active`,label:`Active`}}var ma=new Set([`http`,`https`,`mailto`]);function ha(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?ma.has(n)?{kind:`external`,href:t}:null:{kind:`internal`,href:t.startsWith(`/`)?t:`/${t}`}}function ga({url:e,className:t,children:n,onNavigate:r}){let i=ha(e);return i?i.kind===`external`?(0,G.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer noopener`,className:t,children:[n??`Learn more`,(0,G.jsx)(gr,{className:`inline size-3 ml-1 align-[-1px]`})]}):(0,G.jsx)(B,{to:i.href,className:t,onClick:r,children:n??`View details`}):null}var _a=[`system-status`];async function va(){let{data:e}=await M.get(`/SystemStatus/`);return Array.isArray(e)?e:[]}function ya(){return z({queryKey:_a,queryFn:va,refetchInterval:6e4,staleTime:3e4})}var ba=3e4,xa=new Set,Sa=Date.now(),Ca=null;function wa(e){return xa.add(e),Ca||=(Sa=Date.now(),setInterval(()=>{Sa=Date.now(),xa.forEach(e=>e())},ba)),()=>{xa.delete(e),xa.size===0&&Ca&&(clearInterval(Ca),Ca=null)}}function Ta(){return(0,K.useSyncExternalStore)(wa,()=>Sa,()=>Sa)}function Ea(){return L(ya())}function Da(){let[e,t]=(0,K.useState)(()=>window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);return(0,K.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 Oa=(0,K.createContext)([`system`,()=>{}]);function ka({children:e}){let[t,n]=jn(On.Theme,`system`),r=Da();return(0,K.useEffect)(()=>{let e=t===`dark`||t===`system`&&r===`dark`;document.documentElement.classList.toggle(`dark`,e)},[t,r]),(0,G.jsx)(Oa.Provider,{value:[t,n],children:e})}function Aa(){return(0,K.useContext)(Oa)}var ja=[{value:`light`,icon:(0,G.jsx)(li,{className:`size-4`}),label:`Light`},{value:`system`,icon:(0,G.jsx)(Hr,{className:`size-4`}),label:`System`},{value:`dark`,icon:(0,G.jsx)(Ur,{className:`size-4`}),label:`Dark`}];function Ma(){let[e,t]=Aa();return(0,G.jsx)(`div`,{className:`flex items-center bg-muted dark:bg-black rounded-xl p-0.5 gap-0.5`,children:ja.map(({value:n,icon:r,label:i})=>(0,G.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 Na({className:e,...t}){return(0,G.jsx)(`div`,{className:N(`absolute top-full left-0 isolate z-50 flex justify-center`),children:(0,G.jsx)(ct,{"data-slot":`navigation-menu-viewport`,className:N(`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 Pa({className:e,children:t,viewport:n=!0,...r}){return(0,G.jsxs)(Tt,{"data-slot":`navigation-menu`,"data-viewport":n,className:N(`group/navigation-menu relative flex max-w-max flex-1 items-center justify-center`,e),...r,children:[t,n&&(0,G.jsx)(Na,{})]})}function Fa({className:e,...t}){return(0,G.jsx)(St,{"data-slot":`navigation-menu-item`,className:N(`relative`,e),...t})}function Ia({className:e,...t}){return(0,G.jsx)(_t,{"data-slot":`navigation-menu-link`,className:N(`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 La({className:e,...t}){return(0,G.jsx)(gt,{"data-slot":`navigation-menu-list`,className:N(`group flex flex-1 list-none items-center justify-center gap-1`,e),...t})}function Ra({delayDuration:e=0,...t}){return(0,G.jsx)(pt,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function za({...e}){return(0,G.jsx)(Ra,{children:(0,G.jsx)(Dt,{"data-slot":`tooltip`,...e})})}function Ba({...e}){return(0,G.jsx)(ht,{"data-slot":`tooltip-trigger`,...e})}function Va({className:e,sideOffset:t=0,arrowClassName:n,children:r,...i}){return(0,G.jsx)(kt,{children:(0,G.jsxs)(xt,{"data-slot":`tooltip-content`,sideOffset:t,className:N(`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,G.jsx)(ft,{className:N(`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`,n)})]})})}function Ha(){let e=`v5.2.0`;return(0,G.jsx)(`a`,{href:e.startsWith(`v`)?`https://github.com/HarperFast/studio/releases/tag/${e}`:`https://github.com/HarperFast/studio/releases`,target:`_blank`,rel:`noopener noreferrer`,children:(0,G.jsxs)(`span`,{className:N(Ki({variant:`default`}),`text-xs inline-block ml-2 align-text-top`),children:[e,` BETA`]})})}function Ua(){localStorage.clear()}function Wa(){sessionStorage.clear()}async function Ga(){u.setUserForEntity(h,null),Tn.getQueryCache().clear(),Ua(),Wa(),await Tn.invalidateQueries({refetchType:`none`})}async function Ka(e){await u.signOutFromPotentiallyAuthenticatedInstances(),await d({...e,entityId:h})}function qa(){let e=Mn();return F({mutationFn:()=>Ka({instanceClient:e}),onSuccess:Ga})}var Ja={className:`text-foreground dark:text-white font-semibold`};function Ya(){let{mutate:e}=qa(),t=ke(),{user:n}=ze(),r=Re(n),i=re(),a=(0,K.useCallback)(()=>{e(void 0,{onSuccess:async()=>{H.success(`Success`,{description:`You have been signed out successfully.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`}),i.invalidate()}})},[e,i,t]),o=(0,K.useMemo)(()=>[!1,!1,{to:`https://docs.harperdb.io/docs`,target:`_blank`,icon:(0,G.jsx)(Jn,{}),text:`Docs`,textBreakpoint:`md`},{to:`https://github.com/HarperFast/studio/issues`,target:`_blank`,icon:(0,G.jsx)(Xn,{}),text:`Report an Issue`,textBreakpoint:`lg`},{to:`https://discord.gg/VzZuaw3Xay`,target:`_blank`,icon:(0,G.jsx)(Wi,{}),text:`Discord`,textBreakpoint:`lg`},{onClick:a,icon:(0,G.jsx)(Lr,{}),text:`Sign Out`,textBreakpoint:`md`}].filter(Fn),[a,r]);return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(eo,{menuItems:o}),(0,G.jsx)(Qa,{menuItems:o})]}):(0,G.jsx)(Za,{})}function Xa(e){return e.items!==void 0}function Za(){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/sign-in`,children:(0,G.jsx)(Gi,{})}),(0,G.jsx)(Ha,{})]}),(0,G.jsx)(Pa,{children:(0,G.jsxs)(La,{className:`text-muted-foreground dark:text-grey-400`,children:[(0,G.jsx)(Fa,{children:(0,G.jsx)(Ia,{asChild:!0,children:(0,G.jsxs)(B,{to:`https://docs.harperdb.io/docs`,target:`_blank`,rel:`noreferrer noopener`,className:`flex-row items-center`,children:[(0,G.jsx)(Jn,{}),` `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Docs`})]})})}),(0,G.jsx)(Fa,{children:(0,G.jsx)(Ma,{})}),(0,G.jsx)(Fa,{children:(0,G.jsx)(Ia,{asChild:!0,children:(0,G.jsxs)(B,{to:`/sign-in`,className:`flex-row items-center`,activeProps:Ja,children:[(0,G.jsx)(Fr,{}),` Sign In`]})})})]})})]})}function Qa({menuItems:e}){let{user:t}=ze();return Hn(t),(0,G.jsx)(`div`,{className:`hidden md:[@media(hover:hover)]:block xl:block`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`inline-block`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Gi,{})}),(0,G.jsx)(Ha,{})]}),(0,G.jsx)(Pa,{children:(0,G.jsxs)(La,{className:`text-muted-foreground dark:text-grey-400`,children:[e.map(e=>Xa(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black rounded-2xl flex`,children:e.items.map(e=>(0,G.jsx)($a,{menuItem:e},e.text))},e.text):(0,G.jsx)($a,{menuItem:e},e.text)),!1,(0,G.jsx)(Fa,{children:(0,G.jsx)(Ma,{})})]})})]})})}function $a({menuItem:e}){return(0,G.jsx)(Fa,{className:`text-muted-foreground dark:text-gray-400 hover:text-foreground dark:hover:text-white`,children:(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(Ia,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,onClick:e.onClick,"aria-label":e.text,className:`flex-row items-center`,target:e.target,activeProps:e.to?Ja:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`hidden ${e.textBreakpoint}:inline-block`,children:e.text}),(0,G.jsx)(`span`,{className:`${e.textBreakpoint}:hidden`,children:`\xA0`})]})})}),(0,G.jsx)(Va,{side:`bottom`,className:`${e.textBreakpoint}:hidden`,children:e.text})]})})}function eo({menuItems:e}){let{user:t}=ze();Hn(t);let[n,r]=(0,K.useState)(!1),i=(0,K.useCallback)(()=>r(e=>!e),[]),a=(0,K.useCallback)(()=>r(!1),[]);return(0,G.jsxs)(`div`,{className:`md:[@media(hover:hover)]:hidden xl:hidden`,id:`mobile-menu`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(B,{to:`/`,children:(0,G.jsx)(Gi,{})}),(0,G.jsx)(Ha,{}),(0,G.jsxs)(`div`,{className:`flex items-center`,children:[!1,(0,G.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,G.jsx)(`span`,{className:`sr-only`,children:n?`Close menu`:`Open menu`}),n?(0,G.jsx)(Cn,{}):(0,G.jsx)(Vr,{})]})]})]}),(0,G.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,G.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,G.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,G.jsx)(Ma,{})}),e.map(e=>Xa(e)?!!e.items.length&&(0,G.jsx)(`div`,{className:`bg-muted dark:bg-black pl-10 pr-2 py-2`,children:e.items.map(e=>(0,G.jsx)(to,{menuItem:e,onClick:a},e.text))},e.text):(0,G.jsx)(to,{menuItem:e,onClick:a},e.text))]})]})}function to({menuItem:e,onClick:t}){let n=(0,K.useCallback)(()=>{e.onClick?.(),t()},[e,t]);return(0,G.jsxs)(B,{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?Ja:void 0,children:[e.icon,(0,G.jsx)(`span`,{className:`ml-4`,children:e.text})]})}function no(){let{isLoading:e}=ze(),{createCluster:t}=le({strict:!1}),[,n]=jn(On.SavedClusterState,null);return(0,K.useEffect)(()=>{t&&n(t)},[t,n]),e?(0,G.jsx)(Ui,{className:`fixed z-50 translate-1/2`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Ya,{})}),(0,G.jsx)(`main`,{children:(0,G.jsx)(Ce,{})})]})}function ro(){let e=location.hash;return e?e.startsWith(`#/`)?e.slice(1):e:`/`}var io=[`/`,`/forgot-password`,`/reset-password`,`/sign-in`,`/sign-up`,`/verify-email`];function ao(){let e=ro();return!io.includes(e)&&{redirect:e}}var oo=!1;function so(){(0,K.useEffect)(()=>{oo||=!0},[])}function co(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ye,{}),(0,G.jsx)(Ce,{})]})}var lo=ge()({component:co}),uo=R({getParentRoute:()=>lo,id:`_dashboardLayout`,component:no,beforeLoad:({context:e})=>{let t=e.authentication[h];if(t&&!t.isLoading&&!t.user)throw ve({to:`/sign-in`,search:ao()})}}),fo=R({getParentRoute:()=>uo,path:`admin`,component:Hi});R({getParentRoute:()=>fo,path:`/`,head:()=>({meta:[{title:`API Token — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./apiToken-BUI_04o7.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),`ApiTokenIndex`)}),R({getParentRoute:()=>fo,path:`/notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./notifications-CwKhipK7.js`),__vite__mapDeps([9,1,2,3,4,5,6,7,10,11,12,13,14,15,16])),`NotificationsAdminIndex`)});function po(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Ya,{})}),(0,G.jsxs)(`div`,{className:`pt-20 h-screen grid grid-cols-1 md:grid-cols-2`,children:[(0,G.jsx)(`section`,{"aria-label":`Harper Fabric overview`,className:`items-center justify-center hidden text-white md:flex px-6 fabricSignupTextContainer`,children:(0,G.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,G.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,G.jsx)(`div`,{className:`min-h-full flex items-start justify-center py-12`,children:(0,G.jsx)(Ce,{})})})]})]})}var mo;function ho(){(0,K.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=ke(),t=re(),n=ae(),{redirect:r}=le({strict:!1});return(0,K.useEffect)(()=>{xo||=(async function(){let a=await i().catch(()=>null);if(!a)H.error(`We were not able to verify your sign-in. Please try signing in again.`,{duration:1e4}),await e({to:`/sign-in`});else{u.setUserForEntity(h,a),bo();let i=Hn(a),o=_o(a.email);mo?.identify?.({username:a.email,type:`email`,...o?{company:o}:{}}),await n.invalidateQueries({queryKey:m,refetchType:`none`}),await t.invalidate(),await e({to:r?.startsWith(`/`)?r:i})}xo=null})()},[]),(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Checking...`]}),(0,G.jsx)(`div`,{className:`underline flex gap-4`,children:(0,G.jsx)(B,{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=De(),{organization:n,instance:r,cluster:i}=Ae({strict:!1});return(0,G.jsxs)(`div`,{role:`list`,className:`flex items-center space-x-2 xl:space-x-4 sm:max-w-9/10 max-w-[calc(100%-56px)]`,children:[...(0,K.useMemo)(()=>{let e=t.pathname.split(`/`).filter(e=>e&&e.length>0),a=[(0,G.jsxs)(B,{to:`/`,children:[(0,G.jsx)(Dr,{"aria-hidden":`true`,className:`size-5 shrink-0`}),(0,G.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,G.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`size-5 shrink-0 text-grey`,children:(0,G.jsx)(`path`,{d:`M5.555 17.776l8-16 .894.448-8 16-.894-.448z`})},a.length+`-dash`),(0,G.jsx)(B,{to:s,className:`text-xs md:text-sm font-medium hover:text-grey truncate max-w-48`,children:c},s))}return a},[t.pathname,i?.name,r?.name,n?.name]),e&&(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(`div`,{className:`text-xs italic text-muted-foreground`,children:[`* Restart `,(0,G.jsx)(`span`,{className:`hidden lg:inline-block`,children:`Requested`})]})}),(0,G.jsxs)(Va,{side:`bottom`,children:[`This `,`Instance`,` is requesting a restart, when convenient, to apply your latest changes.`,(0,G.jsx)(`br`,{}),`You can do this from the Apps or Config pages.`]})]})]})}var q=Ct,Do=(0,K.createContext)({}),Oo=(0,K.createContext)({});function ko(){let e=(0,K.useContext)(Do),t=(0,K.useContext)(Oo),{getFieldState:n}=lt(),r=wt({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}=ko();return(0,G.jsx)(Rt,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${i}`:`${r}`,"aria-invalid":!!t,...e})}function Y({...e}){return(0,G.jsx)(Do,{value:{name:e.name},children:(0,G.jsx)(Ot,{...e})})}function X({className:e,...t}){return(0,G.jsx)(Oo,{value:{id:(0,K.useId)()},children:(0,G.jsx)(`div`,{"data-slot":`form-item`,className:N(`grid gap-2`,e),...t})})}function Ao({className:e,...t}){return(0,G.jsx)(mt,{"data-slot":`label`,className:N(`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}=ko();return(0,G.jsx)(Ao,{"data-slot":`form-label`,"data-error":!!n,className:N(`data-[error=true]:text-destructive`,e),htmlFor:r,...t})}function Q({className:e,...t}){let{error:n,formMessageId:r}=ko(),i=n?String(n?.message):t.children;return i?(0,G.jsx)(`p`,{"data-slot":`form-message`,id:r,className:N(`text-destructive text-sm`,e),...t,children:i}):null}function $({className:e,type:t,...n}){return(0,G.jsx)(`input`,{type:t,"data-slot":`input`,className:N(`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,14 +9,14 @@ import{a as e,r as t,t as n}from"./rolldown-runtime-CNC7AqOf.js";import{a as r,c
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 jo=[`RUNNING`],Mo=[`TERMINATING`,`TERMINATED`,`REMOVED`];function No(){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 Po({username:e,password:t,instanceClient:n,entityId:i}){let a={username:e,password:t};u.checkForBasicAuth(i)&&(n.defaults.auth=a,n.defaults.withCredentials=!1);let{data:{message:o}}=await n.post(`/`,{operation:`login`,username:e,password:t});if(!u.checkForBasicAuth(i))try{let e=await r({instanceClient:n});return u.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){console.error(`Failed to get user after login, trying basic auth`,e)}try{n.defaults.auth=a,n.defaults.withCredentials=!1;let e=await r({instanceClient:n,auth:a});return u.flagForBasicAuth(i,a),u.setLastConnectMode(i,`direct`),{message:o,user:e}}catch(e){throw n.defaults.auth=void 0,n.defaults.withCredentials=!0,e}return{message:o,user:await u.establishFabricConnectAuth({id:i,operationsUrl:n.defaults.baseURL}),instanceClient:g({id:i,operationsUrl:n.defaults.baseURL})}}function Fo(){return F({mutationFn:Po})}function Io({cluster:e,instance:t,instanceParams:n}){let r=ke(),i=re(),{redirect:a}=le({strict:!1}),{mutate:o,isPending:s}=Fo();return{isPending:s,submitForm:(0,K.useCallback)(async s=>{o({...s,...n},{onSuccess:async({message:n,user:o})=>{if(H.success(n),e?.instances?.length&&!t)for(let t of e.instances)u.setUserForEntity(t,o);let s=h;if(!s)throw Error(`Sign in failed due to missing cluster or instance.`);u.setUserForEntity(s,o),i.invalidate(),await r({to:a?.startsWith(`/`)?a:`/`})}})},[e,t,n,r,a,i,o])}}function Lo(e){if(Ho(e)||Uo(e))return`warning`;if(zo(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 Ro(e){switch(e){case`STOPPED`:case`STOPPING`:case`STARTING`:case`RESTARTING`:return!0;default:return!1}}function zo(e){switch(e){case`RUNNING`:case`UPDATED`:return!0;default:return!1}}function Bo(e){switch(e){case`FAILED`:return!0;default:return!1}}function Vo(e){switch(e){case`TERMINATED`:return!0;default:return!1}}function Ho(e){switch(e){case`CLONE_PENDING`:case`PENDING_UPGRADE`:return!0;default:return!1}}function Uo(e){switch(e){case`PROVISIONING`:case`CLONING`:case`CLONE_READY`:case`UPDATING_HDB_NODES`:case`DRAINING`:case`UPDATING`:return!0;default:return!1}}function Wo(e){let t=(e?.instances??[]).filter(e=>!(e.status&&Mo.includes(e.status)));return t.length>0&&t.every(e=>zo(e.status))}async function Go(e){let{data:t}=await M.get(`/Cluster/${e}`);return t}function Ko(e,t){return z({queryKey:[e],queryFn:()=>Go(e),retry:!1,staleTime:1900,enabled:!!e,refetchInterval:Ln(t?t===!0?1e4:t:void 0)})}var qo=w({error:`Please enter a valid email address.`}).toLowerCase().trim(),Jo=S().nonempty({error:`Please enter your password.`}),Yo=S().nonempty({error:`Please enter a username.`}),Xo=j({username:Yo,password:Jo}),Zo=j({email:qo,password:Jo});function Qo({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 $o=[`localhost`,`127.0.0.1`],es=function(e){return e.MixedLoopback=`MixedLoopback`,e.InsecureCookieOutsideChromeAndFirefox=`InsecureCookieOutsideChromeAndFirefox`,e}({});function ts(e,t,n){if(!n||!t||!e)return null;let r=new URL(n).hostname,i=$o.includes(t),a=$o.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 ns(){let{clusterId:e,instanceId:t}=I({strict:!1}),{data:n}=L(Ko(e,!0)),r=(0,K.useMemo)(()=>t&&n&&n?.instances?.find(e=>e.id===t)||void 0,[n,t]),i=(0,K.useMemo)(()=>n?.status&&jo.includes(n.status),[n?.status]),a=`instance`,o=(0,K.useMemo)(()=>n?r?(u.flagForFabricConnect(r.id,!1),p(r)):(u.flagForFabricConnect(n.id,!1),s(n)):null,[n,r]);(0,K.useEffect)(()=>{r?u.setUserForEntity(r,null):n&&u.setUserForEntity(n,null)},[r?.id??n?.id]);let c=W({operationsUrl:o}),l=(0,K.useMemo)(()=>o?.includes(`localhost`)||o?.includes(`127.0.0.1`),[o]),d=(0,K.useMemo)(()=>ts(navigator.userAgent,location.hostname,o),[o]),{data:f}=L(Qo(c)),m=vt({resolver:V(Xo),defaultValues:{username:``,password:``}}),{control:h,handleSubmit:g}=m,{submitForm:v,isPending:y}=Io({cluster:n,instance:r,instanceParams:c});if(!t&&n&&!n?.fqdn)return(0,G.jsx)(fe,{to:`../instances`,replace:!0});if(n?.resetPassword){let e=i&&Wo(n);return(0,G.jsx)(fe,{to:`/${n.organizationId}/${n.id}/${e?`finish-setup`:`starting-up`}`,replace:!0})}return(0,G.jsxs)(G.Fragment,{children:[!1,(0,G.jsx)(`div`,{className:_(`min-h-screen`,`items-center justify-center flex`),children:(0,G.jsxs)(`div`,{className:`text-foreground w-xs py-8`,children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-light`,children:[`Sign in to Harper `,`Local`]}),(0,G.jsx)(q,{...m,children:(0,G.jsxs)(`form`,{id:`auth-${a}-signin-form`,name:`auth-${a}-signin-form`,onSubmit:g(v),className:`my-4`,children:[(0,G.jsx)(Y,{control:h,name:`username`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Username`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoComplete:`username`,autoFocus:!0,type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:h,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{disabled:y,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Sign In`}),f===!1&&(0,G.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,G.jsx)(`span`,{className:`font-medium`,children:`Warning!`}),` This `,a,` is not responding to GET`,` `,(0,G.jsxs)(`a`,{href:`${o}health`,className:`underline`,target:`_blank`,children:[o,`health`]}),` `,`checks.`,(0,G.jsxs)(`ol`,{className:`list-decimal ml-8 mt-2`,children:[(0,G.jsx)(`li`,{children:`Is the server running?`}),(0,G.jsxs)(`li`,{children:[`Have you`,` `,(0,G.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?`]}),l&&(0,G.jsxs)(`li`,{children:[`Have you allowed`,` `,(0,G.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?`]})]})]}),d===es.MixedLoopback&&(0,G.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,G.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.`]}),d===es.InsecureCookieOutsideChromeAndFirefox&&(0,G.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,G.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,G.jsxs)(`div`,{className:`p-4 mt-4 text-sm rounded-lg bg-purple-950`,role:`alert`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Did you know?`}),` `,`You can add this instance to your Harper account to manage it remotely.`,(0,G.jsx)(`div`,{className:`text-center pt-2`,children:(0,G.jsx)(B,{to:No(),target:`_blank`,children:(0,G.jsx)(P,{type:`button`,variant:`positive`,children:`Connect to Harper Fabric`})})})]})]})})]})})]})}async function rs({email:e}){let{data:t}=await M.post(`/ForgotPassword/`,{email:e});if(t)return t;throw Error(`Something went wrong`)}function is(){return F({mutationFn:e=>rs(e)})}var as=j({email:qo});function os(){let e=ke(),{me:t}=le({strict:!1}),n=vt({resolver:V(as),defaultValues:{email:t||``}}),r=n.watch(`email`),{setFocus:i,control:a,handleSubmit:o}=n;(0,K.useEffect)(()=>{i(`email`)},[i]);let{mutate:s,isPending:c}=is(),l=async t=>{s(t,{onSuccess:t=>{H.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e({to:`/sign-in`,search:{me:r}})}})};return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Enter your account email`}),(0,G.jsx)(`p`,{className:`text-sm pt-1`,children:`If a matching account exists, we'll send you a password reset link.`}),(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`auth-forgot-password-form`,name:`auth-forgot-password-form`,onSubmit:o(l),className:`my-4`,children:[(0,G.jsx)(Y,{control:a,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:c,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{type:`submit`,variant:`submit`,disabled:c,className:`w-full my-2`,children:`Send Password Reset Email`})]})}),(0,G.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,G.jsx)(B,{className:`text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:r},children:`Sign in to your account`}),(0,G.jsx)(B,{className:`text-sm hover:text-blue-300`,to:`/sign-up`,search:{me:r},children:`Sign up for free`})]})]})}var ss=async({token:e,password:t})=>{let{data:n}=await M.put(`/ResetPassword/`,{token:e,newPassword:t});return n};function cs(){return F({mutationFn:e=>ss(e)})}var ls=j({password:Jo.min(8,{error:`Password must be at least 8 characters long.`}).max(50,{error:`Password cannot be longer than 50 characters.`}),confirmPassword:S()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});function us(){let{token:e}=le({strict:!1}),t=ke();(0,K.useEffect)(()=>{e||t({to:`/sign-in`})},[e,t]);let n=vt({resolver:V(ls),defaultValues:{password:``,confirmPassword:``}}),{setFocus:r,control:i,handleSubmit:a}=n;(0,K.useEffect)(()=>{r(`password`)},[r]);let{mutate:o,isPending:s}=cs(),c=(0,K.useCallback)(async n=>{o({token:e,password:n.password},{onSuccess:()=>{H.success(`Success`,{description:`Your password has been reset successfully.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`})}})},[t,o,e]);return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Reset Password`}),(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`auth-reset-password-form`,name:`auth-reset-password-form`,className:`my-4`,onSubmit:a(c),children:[(0,G.jsx)(Y,{control:i,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`New Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:i,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:s,type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{variant:`submit`,type:`submit`,disabled:s,className:`w-full my-2`,children:`Submit New Password`})]})})]})}function ds(){return(0,G.jsx)(qi,{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 fs({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,G.jsxs)(`a`,{href:`/oauth/github/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:_(`github-signin-btn`,t&&`opacity-50 cursor-default`),children:[(0,G.jsx)(`img`,{src:`/github/GitHub_Invertocat_White.svg`,alt:``,className:`github-icon`}),e]});return r?(0,G.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,G.jsx)(ds,{})]}):i}function ps({text:e,disabled:t,onClick:n,lastUsed:r=!1}){let i=(0,G.jsxs)(`a`,{href:`/oauth/google/login?redirect=%2F%23%2Fcheck-oauth`,onClick:n,"aria-disabled":t||void 0,className:_(`gsi-material-button`,t&&`opacity-50 cursor-default`),children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-state`}),(0,G.jsxs)(`div`,{className:`gsi-material-button-content-wrapper`,children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`gsi-material-button-icon`,children:(0,G.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,G.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,G.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,G.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,G.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,G.jsx)(`path`,{fill:`none`,d:`M0 0h48v48H0z`})]})}),(0,G.jsx)(`span`,{className:`gsi-material-button-contents`,children:e}),(0,G.jsx)(`span`,{className:`hidden`,children:e})]})]});return r?(0,G.jsxs)(`div`,{className:`relative flex flex-col`,children:[i,(0,G.jsx)(ds,{})]}):i}function ms(e){if(!y(e)||e.response?.status!==403)return!1;let t=e.response.data,n=typeof t==`string`?t:wn(t?.error)??wn(t?.message)??``;return/verif/i.test(n)}var hs=async({email:e})=>{let{data:t}=await M.post(`/ResendVerificationEmail/`,{email:e});return t};function gs(){return F({mutationFn:e=>hs(e)})}function _s(){let e=ke(),t=ae(),n=re(),{redirect:r}=le({strict:!1}),{mutate:i,isPending:a}=vs(),{mutate:o}=gs();return{isPending:a,submitForm:(0,K.useCallback)(a=>{i(a,{onSuccess:async i=>{u.setUserForEntity(h,i),bo();let a=Hn(i),o=_o(i.email);mo?.identify?.({username:i.email,type:`email`,...o?{company:o}:{}}),await t.invalidateQueries({queryKey:m,refetchType:`none`}),n.invalidate(),await e({to:r?.startsWith(`/`)?r:a})},onError:t=>{if(ms(t)){o({email:a.email},{onSuccess:()=>H.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}En(t)}})},[e,t,r,o,n,i])}}function vs(){return F({mutationFn:e=>ys(e),meta:{skipGlobalErrorToast:!0}})}async function ys({email:e,password:t}){let{data:n}=await M.post(`/Login/`,{email:e,password:t});if(n)return n;throw Error(`Something went wrong`)}function bs(){let[e,t]=jn(On.RememberSignInMethod,!0),[n,r]=jn(On.LastUsedSignInMethod,null),i=(0,K.useCallback)(t=>{e&&(An(On.LastUsedSignInMethod,t),r(t))},[e,r]),a=(0,K.useCallback)(()=>{r(null),t(!1)},[r,t]),o=(0,K.useCallback)(()=>{t(!0)},[t]);return{lastUsed:e?n:null,remember:e,recordMethod:i,disable:a,enable:o}}var xs=`mx-auto mt-3 block text-xs text-muted-foreground underline hover:text-foreground dark:text-inherit dark:hover:text-blue-300`;function Ss(){let{me:e}=le({strict:!1}),t=vt({resolver:V(Zo),defaultValues:{email:e||``,password:``}}),{handleSubmit:n,control:r}=t,i=t.watch(`email`),{submitForm:a,isPending:o}=_s(),{lastUsed:s,remember:c,recordMethod:l,disable:u,enable:d}=bs();return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign in to Harper Fabric`}),(0,G.jsx)(q,{...t,children:(0,G.jsxs)(`form`,{id:`auth-signin-form`,name:`auth-signin-form`,onSubmit:n(a),className:`my-4`,children:[(0,G.jsx)(Y,{control:r,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,autoFocus:!0,autoComplete:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`current-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{type:`submit`,variant:`submit`,className:`w-full my-2`,disabled:o,children:`Sign In`}),(0,G.jsxs)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:[(0,G.jsx)(B,{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,G.jsx)(B,{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,G.jsx)(`hr`,{"aria-hidden":`true`,className:`border-border dark:border-gray-600 my-6`}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(ps,{text:`Sign in with Google`,lastUsed:s===`google`,onClick:()=>l(`google`)}),(0,G.jsx)(fs,{text:`Sign in with GitHub`,lastUsed:s===`github`,onClick:()=>l(`github`)})]}),c?s&&(0,G.jsx)(`button`,{type:`button`,onClick:u,className:xs,children:`On a shared device? Forget my sign-in method.`}):(0,G.jsx)(`button`,{type:`button`,onClick:d,className:xs,children:`Remember my last sign-in method on this device.`})]})}var Cs=/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžæÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,'-]+$/u;async function ws(e){let{data:t}=await M.post(`/User/`,e);if(t)return t;throw Error(`Something went wrong`)}function Ts(){return F({mutationFn:e=>ws(e)})}var Es=j({email:qo.max(80,{error:`Email cannot be longer than 80 characters.`}),firstname:S().trim().min(2,{error:`Please enter your first name.`}).regex(Cs,{error:`First name can only contain letters, spaces, and hyphens.`}).max(40,{error:`First name cannot be longer than 40 characters.`}),lastname:S().trim().min(2,{error:`Please enter your last name.`}).regex(Cs,{error:`Last name can only contain letters, spaces, and hyphens.`}).max(80,{error:`Last name cannot be longer than 80 characters.`}),password:Jo.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:S(),acceptTerms:E().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 Ds(){let e=ke(),{email:t,me:n}=le({strict:!1}),[r,i]=(0,K.useState)(!1),a=vt({resolver:V(Es),defaultValues:{firstname:``,lastname:``,email:n||t||``,password:``,confirmPassword:``,acceptTerms:!1}}),o=a.watch(`email`),s=a.watch(`acceptTerms`),{setFocus:c,control:l,handleSubmit:u}=a;(0,K.useEffect)(()=>{c(`firstname`)},[c]);let{mutate:d}=Ts(),f=(0,K.useCallback)(async t=>{let{confirmPassword:n,acceptTerms:r,...i}=t;d(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)})}})},[e,d]),p=(0,K.useCallback)(e=>{if(!s)return i(!0),setTimeout(()=>i(!1),1e3),e.preventDefault(),!1},[s]),m=(0,G.jsx)(Y,{control:l,name:`acceptTerms`,render:({field:e})=>(0,G.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,G.jsx)(J,{children:(0,G.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,G.jsxs)(`div`,{className:`space-y-1 leading-none`,children:[(0,G.jsxs)(Z,{className:`text-xs font-normal`,children:[`I accept the`,` `,(0,G.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,G.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,G.jsx)(Q,{})]})]})});return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-center`,children:`Sign up for Harper Fabric`}),(0,G.jsxs)(q,{...a,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 my-6`,children:[m,(0,G.jsx)(ps,{text:`Sign up with Google`,disabled:!s,onClick:p}),(0,G.jsx)(fs,{text:`Sign up with GitHub`,disabled:!s,onClick:p})]}),(0,G.jsx)(`hr`,{className:`border-gray-600`}),(0,G.jsxs)(`form`,{id:`auth-signup-form`,name:`auth-signup-form`,onSubmit:u(f),className:`grid gap-4 my-4`,children:[(0,G.jsx)(Y,{control:l,name:`firstname`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`First Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:l,name:`lastname`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Last Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:`dark:bg-black dark:border-black`,autoCapitalize:`words`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:l,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,readOnly:!!t,disabled:!!t,className:`dark:bg-black dark:border-black`,autoComplete:`email`,autoCapitalize:`none`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:l,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:l,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),m,(0,G.jsx)(P,{type:`submit`,variant:`submit`,className:`w-full my-4`,children:`Sign Up For Free`})]})]}),(0,G.jsx)(`div`,{className:`flex px-4 mt-4 underline place-content-between`,children:(0,G.jsx)(B,{className:`m-auto text-sm hover:text-blue-300`,to:`/sign-in`,search:{me:o},children:`Already have an account? Sign in instead.`})})]})}var Os=async e=>{let{data:t}=await M.put(`/VerifyEmail/`,{token:e.toString()});return t};function ks(){return F({mutationFn:e=>Os(e)})}var As=j({email:qo});function js(){let e=ke(),{mutate:t,isPending:n}=gs(),r=vt({resolver:V(As),defaultValues:{email:``}}),i=r.watch(`email`),{setFocus:a,control:o,handleSubmit:s}=r;(0,K.useEffect)(()=>{a(`email`)},[a]);let c=(0,K.useCallback)(async n=>{t(n,{onSuccess:t=>{H.success(`Success`,{description:`${t}`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e({to:`/sign-in`,search:{me:i}})}})},[i,e,t]);return(0,G.jsxs)(q,{...r,children:[(0,G.jsx)(`p`,{className:`text-sm py-2`,children:`Please Enter an Email`}),(0,G.jsxs)(`form`,{id:`auth-verify-email-form`,name:`auth-verify-email-form`,onSubmit:s(c),className:`my-4`,children:[(0,G.jsx)(Y,{control:o,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-2`,children:[(0,G.jsx)(Z,{children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{disabled:n,type:`email`,className:`dark:bg-black dark:border-black`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{type:`submit`,variant:`submit`,disabled:n,className:`w-full my-2`,children:`Send Verification Email`})]})]})}function Ms(){let{token:e}=le({strict:!1}),t=ke(),{mutate:n,isPending:r}=ks(),i=(0,K.useCallback)(e=>{n(e,{onSuccess:()=>{H.success(`Success`,{description:`Email verified successfully`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t({to:`/sign-in`})}})},[n,t]);return(0,K.useEffect)(()=>{e&&i(e)},[i,e]),(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-3xl font-light`,children:`Verify Email`}),r?(0,G.jsx)(`p`,{className:`text-sm pt-1`,children:`Verifying email...`}):(0,G.jsx)(js,{})]})}function Ns(){let{email:e}=le({strict:!1}),{mutate:t,isPending:n}=gs(),r=(0,K.useCallback)(n=>(n.preventDefault(),e&&t({email:e},{onSuccess:e=>{H.success(`Code Sent`,{description:`${e}`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}}),!1),[e,t]);return(0,G.jsxs)(`div`,{className:`text-foreground dark:text-white w-lg flex flex-col gap-4`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-light`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl animate-flower-dance mr-4`,title:`Loading`,children:`🌼`}),`Check your email!`]}),(0,G.jsxs)(`p`,{children:[`Your account has been created! You should receive an email with a link to `,(0,G.jsx)(`strong`,{children:`[Verify My Email]`}),`!`]}),(0,G.jsxs)(`p`,{children:[`From: `,(0,G.jsx)(`strong`,{children:`harper@notifications.harperfabric.com`})]}),(0,G.jsxs)(`p`,{children:[`To: `,(0,G.jsx)(`strong`,{children:e||`your email`})]}),(0,G.jsx)(`p`,{children:`Can you click it? Then we can carry on to more fun things!`}),(0,G.jsxs)(`div`,{className:`underline flex gap-4`,children:[(0,G.jsx)(B,{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,G.jsx)(B,{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 Ps=R({getParentRoute:()=>lo,id:`_authLayout`,component:po}),Fs=R({getParentRoute:()=>Ps,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:Ss,beforeLoad:({context:e,location:t})=>{let n=e.authentication[h]?.user;if(n){let e=t?.search,r=Hn(n);throw ve({to:e?.redirect?.startsWith(`/`)?e.redirect:r})}}}),Is=R({getParentRoute:()=>lo,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:ns,beforeLoad:({context:e,location:t})=>{if(e.authentication.OverallAppSignIn?.user){let e=t?.search;throw ve({to:e?.redirect?.startsWith(`/`)?e.redirect:`/`})}}}),Ls=R({getParentRoute:()=>Ps,path:`sign-up`,head:()=>({meta:[{title:`Sign Up — Harper Fabric`}]}),component:Ds}),Rs=R({getParentRoute:()=>Ps,path:`forgot-password`,head:()=>({meta:[{title:`Forgot Password — Harper Fabric`}]}),component:os}),zs=R({getParentRoute:()=>Ps,path:`verify-email`,head:()=>({meta:[{title:`Verify Email — Harper Fabric`}]}),component:Ms}),Bs=R({getParentRoute:()=>Ps,path:`verifying`,head:()=>({meta:[{title:`Check Your Email — Harper Fabric`}]}),component:Ns}),Vs=R({getParentRoute:()=>Ps,path:`check-oauth`,head:()=>({meta:[{title:`Signing In — Harper Fabric`}]}),component:So}),Hs=R({getParentRoute:()=>Ps,path:`reset-password`,head:()=>({meta:[{title:`Reset Password — Harper Fabric`}]}),component:us});Ps.addChildren([Fs,Ls,Vs,Rs,zs,Bs,Hs]);var Us=[Is];function Ws({children:e}){return(0,G.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,G.jsxs)(`div`,{className:`flex items-center h-full space-x-2`,children:[(0,G.jsx)(Eo,{}),e]})})}function Gs({typeOfThingBeingDeleted:e,nameOfThingBeingDeleted:t,isModalOpen:n,hideDataLossWarning:r,setIsModalOpen:i,deletionConfirmed:a,deletionPending:o,trigger:s,presentParticiple:c=`Deleting`,transitiveVerb:l=`Delete`}){return(0,G.jsxs)(Gt,{open:n,onOpenChange:i,children:[s&&(0,G.jsx)(Zt,{asChild:!0,children:s}),(0,G.jsxs)(Xt,{className:`sm:max-w-[750px]`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsxs)(en,{children:[`Are you sure you want to `,l.toLowerCase(),` this `,e,`?`]}),(0,G.jsx)(an,{children:`This action cannot be undone.`})]}),!r&&(0,G.jsxs)(`div`,{className:`p-3 my-5 text-white rounded-md bg-amber-600`,children:[(0,G.jsxs)(`p`,{className:`flex space-x-1 font-semibold align-baseline`,children:[(0,G.jsx)(_i,{className:`inline-block size-5`}),` `,(0,G.jsx)(`span`,{children:`Warning`})]}),(0,G.jsxs)(`p`,{className:`pt-2 text-base`,children:[`By `,c.toLowerCase(),` `,e,` `,(0,G.jsx)(`span`,{className:`font-semibold`,children:t}),` `,`you will lose the data stored in it permanently.`]})]}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-center space-x-5`,children:[(0,G.jsxs)(P,{type:`button`,onClick:()=>i(!1),children:[(0,G.jsx)(on,{}),` Cancel`]}),(0,G.jsxs)(P,{variant:`destructive`,onClick:a,disabled:o,children:[(0,G.jsx)(gi,{}),` `,l]})]})})]})]})}function Ks({...e}){return(0,G.jsx)(tt,{"data-slot":`context-menu`,...e})}function qs({...e}){return(0,G.jsx)(st,{"data-slot":`context-menu-trigger`,...e})}function Js({className:e,...t}){return(0,G.jsx)(Ye,{children:(0,G.jsx)(Lt,{"data-slot":`context-menu-content`,className:N(`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 Ys({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(We,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:N(`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 Xs({className:e,inset:t,...n}){return(0,G.jsx)(ot,{"data-slot":`context-menu-label`,"data-inset":t,className:N(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Zs({className:e,...t}){return(0,G.jsx)(at,{"data-slot":`context-menu-separator`,className:N(`bg-border -mx-1 my-1 h-px`,e),...t})}function Qs({className:e,...t}){return(0,G.jsx)(`span`,{"data-slot":`context-menu-shortcut`,className:N(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}var $s={dropdown:{Item:Oi,Label:Ai,Separator:ji},context:{Item:Ys,Label:Xs,Separator:Zs}};function ec(e,t){let{Item:n,Label:r,Separator:i}=$s[t];return e.map(e=>{if(e.type===`separator`)return(0,G.jsx)(i,{},e.key);if(e.type===`label`)return(0,G.jsx)(r,{className:e.className,children:e.label},e.key);let t=(0,G.jsxs)(n,{className:e.className,onClick:e.onClick,disabled:e.disabled,variant:e.variant,children:[e.icon,e.label]});return e.to?(0,G.jsx)(B,{to:e.to,disabled:e.disabled,children:t},e.key):(0,G.jsx)(K.Fragment,{children:t},e.key)})}function tc({items:e,children:t}){return e.length?(0,G.jsxs)(Ks,{children:[(0,G.jsx)(qs,{asChild:!0,children:t}),(0,G.jsx)(Js,{children:ec(e,`context`)})]}):(0,G.jsx)(G.Fragment,{children:t})}function nc(e,t,n,r){return e?e.super_user===!0||e.structure_user===!0||e[t]?.tables?.[n]?.[r]===!0:!1}function rc(e){let{user:t}=Le(),{organizationId:n}=I({strict:!1});if(He(t))return{update:!0,remove:!0};let r=t?.roles?.[e??n];return!r||`oauthProviders`in r||!r.permission&&!r.organization?{update:!1,remove:!1}:r.permission?.super_user?{update:!0,remove:!0}:{update:r.organization.update,remove:r.organization.delete}}function ic(e){let{user:t}=Le(),{organizationId:n}=I({strict:!1});if(He(t))return{create:!0,remove:!0,update:!0,view:!0};let r=t?.roles?.[e??n];if(!r||`oauthProviders`in r||!r.permission&&!r.organization?.roles)return{create:!1,remove:!1,update:!1,view:!1};if(r.permission?.super_user)return{create:!0,remove:!0,update:!0,view:!0};let i=r.organization.roles;return{create:i.create,remove:i.delete,update:i.update,view:i.view}}function ac(e,t){let{user:n}=Le(),{organizationId:r,clusterId:i}=I({strict:!1});return oc(n,e??r,t??i)}function oc(e,t,n){if(He(e))return{create:!0,remove:!0,update:!0,view:!0};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 sc(e,t){let{user:n}=Le(),{organizationId:r,clusterId:i}=I({strict:!1});return cc(n,e??r,t??i)}function cc(e,t,n){if(He(e))return{create:!0,remove:!0,update:!0,view:!0};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 lc(e){let{clusterId:t,instanceId:n}=I({strict:!1}),{user:r}=Ie(e??n??t),i=r?.role?.permission;return i?i.super_user===!0:!1}function uc(e){let{clusterId:t,instanceId:n}=I({strict:!1}),{user:r}=Ie(e??n??t),i=r?.role?.permission;return i?i.super_user===!0||i.structure_user===!0:!1}function dc(e,t,n,r){let{clusterId:i,instanceId:a}=I({strict:!1}),{user:o}=Ie(e??a??i);return nc(o?.role?.permission,t,n,r)}function fc(e){return!!e?.plans?.[0]?.planId?.startsWith(`self-hosted`)}function pc({cluster:e,hasCardLink:t=!1}){let{view:n,update:r}=ac(e.organizationId,e.id),i=`/${e.organizationId}/${e.id}`;if(n)return fc(e)?(0,G.jsx)(mc,{cluster:e,hasCardLink:t}):e.fqdn?e.resetPassword?r?(0,G.jsx)(B,{to:`${i}/finish-setup`,className:`text-sm text-nowrap`,"aria-label":`Set Password on ${e.name}`,title:`Set Password on ${e.name}`,children:(0,G.jsxs)(P,{variant:`positive`,className:`py-2 hover:border-b-2 animate-glow-pulse`,children:[`Finish Setup `,(0,G.jsx)(Gn,{className:`inline-block`})]})}):(0,G.jsx)(`span`,{className:`py-2 text-nowrap`,children:`Pending Owner Setup`}):(0,G.jsx)(mc,{cluster:e,hasCardLink:t}):t?(0,G.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Instances `,(0,G.jsx)(Gn,{className:`inline-block`})]}):(0,G.jsx)(B,{to:`${i}/instances`,className:`text-sm text-nowrap`,"aria-label":`View ${e.name}`,title:`View ${e.name}`,children:(0,G.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Instances `,(0,G.jsx)(Gn,{className:`inline-block`})]})})}function mc({cluster:e,hasCardLink:t}){return t?(0,G.jsxs)(`span`,{className:`text-sm text-nowrap py-2 ml-auto`,children:[`Open `,(0,G.jsx)(Gn,{className:`inline-block`})]}):(0,G.jsx)(B,{to:`/${e.organizationId}/${e.id}`,className:`text-sm text-nowrap`,"aria-label":`Open ${e.name}`,title:`Open ${e.name}`,children:(0,G.jsxs)(`span`,{className:`py-2 hover:border-b-2`,children:[`Open `,(0,G.jsx)(Gn,{className:`inline-block`})]})})}function hc({clusterName:e,isPending:t,stopOpen:n,setStopOpen:r,onConfirmStop:i,restartOpen:a,setRestartOpen:o,onConfirmRestart:s}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Gt,{open:n,onOpenChange:r,children:(0,G.jsxs)(Xt,{className:`sm:max-w-[560px]`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsxs)(en,{children:[`Stop cluster `,e,`?`]}),(0,G.jsx)(an,{children:`This stops every instance in the cluster. It will be offline and stop serving traffic until you start it again.`})]}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>r(!1),children:`Cancel`}),(0,G.jsx)(P,{type:`button`,variant:`destructive`,onClick:i,disabled:t,children:`Stop cluster`})]})})]})}),(0,G.jsx)(Gt,{open:a,onOpenChange:o,children:(0,G.jsxs)(Xt,{className:`sm:max-w-[560px]`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsxs)(en,{children:[`Restart cluster `,e]}),(0,G.jsx)(an,{children:`Choose how to restart the cluster's instances.`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 py-2`,children:[(0,G.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,G.jsxs)(`div`,{className:`font-medium`,children:[`Rolling `,(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(recommended)`})]}),(0,G.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,G.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,G.jsx)(`div`,{className:`font-medium`,children:`Parallel`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`All instances at once. Faster, but the whole cluster is briefly offline.`})]})]}),(0,G.jsx)(Kt,{children:(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>o(!1),children:`Cancel`})})]})})]})}function gc(e,t){let n=[];if(e)for(let r of e)n.push(r[t]);return n}function _c({cluster:e,forceProgressBarVisible:t}){let[n,r]=(0,K.useState)(t||!1),{data:i}=L(Ko(n&&e.id,2e3));(0,K.useEffect)(function(){(Ho(e.status)||Uo(e.status))&&r(!0)},[n,e.status,i?.instances]);let a=(0,K.useMemo)(()=>{let e=gc(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||Vo(t)||(Ho(t)?(n+=1,r[t]=`${n} ${wo(t)}`):Uo(t)?(a+=1,o[t]=`${a} ${wo(t)}`):Bo(t)?(l+=1,u[t]=`${l} ${wo(t)}`):!i.planId||!e.includes(i.planId)?(a+=1,o.DRAINING_TRAFFIC=`${a} ${wo(`Draining Traffic`)}`):zo(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,G.jsxs)(`div`,{className:`w-full text-center`,children:[(0,G.jsxs)(`div`,{className:`w-full h-2.5 rounded-full overflow-clip flex shadow`,children:[(0,G.jsx)(`div`,{style:{width:a.runningWidth},className:`grow bg-green/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,G.jsx)(`div`,{style:{width:a.failedWidth},className:`grow bg-red/80 transition-[width] duration-1000 ease-in-out motion-reduce:transition-none`}),(0,G.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,G.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,G.jsx)(`div`,{className:`text-xs text-muted-foreground font-light mt-2`,children:a.text})]}):null}function vc({open:e,setOpen:t,action:n,targetName:r,scope:i,isPending:a,onConfirm:o}){let s=n===`start`?`Start`:`Restart`;return(0,G.jsx)(Gt,{open:e,onOpenChange:t,children:(0,G.jsxs)(Xt,{className:`sm:max-w-[560px]`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsxs)(en,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Mr,{className:`size-5 text-yellow`}),s,` `,r,` in safe mode?`]}),(0,G.jsxs)(an,{children:[`Safe mode boots Harper`,` `,(0,G.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,G.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,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsxs)(P,{type:`button`,variant:`warning`,onClick:o,disabled:a,children:[(0,G.jsx)(Mr,{}),` `,s,` in safe mode`]})]})})]})})}async function yc(e){let{data:t}=await M.delete(`/Cluster/${e}`,{timeout:0});return t}function bc(){return F({mutationFn:e=>yc(e)})}async function xc({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 M.post(`/Cluster/${e}/container/${t}`,i);return a}function Sc(){return F({mutationFn:xc})}var Cc={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function wc(e){let{mutateAsync:t,isPending:n}=Sc(),r=ae();return{run:(0,K.useCallback)(async(n,i)=>{let a=i?.label??Cc[n],o=H.loading(a,{description:`${a} cluster ${e.name}. Status will update automatically.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>H.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]}),H.dismiss(o),H.success(`Request accepted`,{description:`${e.name} is ${a.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}catch{H.dismiss(o)}},[e.id,e.name,e.organizationId,t,r]),isPending:n}}async function Tc(e){if(!navigator.clipboard)return H.error(`Clipboard access is not available in this environment.`),!1;try{return await navigator.clipboard.writeText(e),!0}catch{return H.error(`Failed to copy to clipboard.`),!1}}function Ec(e){Tc(e).then(e=>{e&&H.info(`Copied to clipboard!`,{icon:(0,G.jsx)(or,{}),duration:1e3})})}function Dc(...e){return(0,K.useMemo)(()=>e.map(e=>()=>Ec(e)),e)}function Oc(){return Ec}function kc({cluster:e}){let t=re(),n=ae(),r=(0,K.useMemo)(()=>s(e),[e]),i=Mn({operationsUrl:r}),a=Ie(e.id),[,o]=jn(On.SavedClusterState,null),{view:c,update:l,remove:f,create:p}=ac(e.organizationId,e.id),{mutate:m,isPending:h}=bc(),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(null),{run:E,isPending:D}=wc(e),O=e.status===`RUNNING`,k=e.status===`STOPPED`,A=e.status===`PARTIAL`,j=e.status===`STOPPING`||e.status===`STARTING`||e.status===`RESTARTING`,ee=j||k||A,te=(0,K.useMemo)(()=>!!(e.status&&jo.includes(e.status)),[e.status]),M=fc(e),N=l&&!M,P=u.checkForFabricConnect(e.id),F=!P&&!!a.user,I=(0,K.useMemo)(()=>!!(e.status&&Mo.includes(e.status)),[e.status]),ne=(0,K.useMemo)(()=>!!(e.status&&Bo(e.status)),[e.status]),ie=l&&!M&&!I&&!Uo(e.status)&&!Ho(e.status),oe=(0,K.useCallback)(async()=>{_(!0);let t=await Go(e.id).catch(e=>(console.error(`Failed to lookup cluster details, proceeding without checking instances.`,e),null));if(await d({entityId:e.id,instanceClient:i}),t?.instances?.length)for(let e of t.instances)u.setUserForEntity(e,null);u.setUserForEntity(e,null)},[e,i]),L=(0,K.useCallback)(()=>{o(e),t.navigate({to:`/${e.organizationId}/new-cluster`})},[e,t,o]),se=(0,K.useCallback)(()=>y(!0),[]),ce=(0,K.useCallback)(()=>{let r=e.organizationId;m(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[r],refetchType:`active`}),await t.invalidate(),H.success(`Success`,{description:M?`Cluster successfully removed.`:`Cluster successfully terminated.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),y(!1)},onError:()=>{H.error(`Error`,{description:M?`Failed to remove cluster: ${e.name}`:`Failed to terminate cluster: ${e.name}.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),y(!1)}})},[t,e.organizationId,e.id,e.name,m,M,n]),le=!c||I?void 0:e.status===`STOPPED`?`/${e.organizationId}/${e.id}/instances`:e.status===`PARTIAL`?`/${e.organizationId}/${e.id}`:te?M?`/${e.organizationId}/${e.id}`:e.fqdn?e.resetPassword?void 0:`/${e.organizationId}/${e.id}`:`/${e.organizationId}/${e.id}/instances`:void 0,ue=e.domains?.[0]?.domain||e.fqdn,[R,de]=Dc(`${ue}`,`https://${ue}`),fe=[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-separator`},te&&l&&!a.isLoading&&(!F||P)&&{key:`sign-in`,to:`${e.id}/sign-in`,disabled:g,icon:(0,G.jsx)(Ar,{className:`text-green`}),label:`Direct Sign In`},te&&c&&!!r&&!a.isLoading&&F&&{key:`direct-sign-out`,onClick:oe,disabled:g,label:`Direct Sign Out`},te&&l&&{key:`edit`,to:`${e.id}/edit`,disabled:g,icon:(0,G.jsx)(ei,{className:`text-purple-600`}),label:M?`Edit`:`Edit Scaling`},ie&&{key:`edit-version`,to:`${e.id}/edit/version`,disabled:g,icon:(0,G.jsx)(wr,{className:`text-fuchsia-300`}),label:`Edit Version`},te&&l&&!1,te&&c&&{key:`instances`,to:`${e.id}/instances`,disabled:g,icon:(0,G.jsx)(ni,{className:`text-orange-300`}),label:`Instances`},te&&c&&!!a.user&&{key:`deployments`,to:`${e.id}/config/deployments`,disabled:g,icon:(0,G.jsx)(Xr,{className:`text-sky-400`}),label:`Deployments`},N&&(O||k||A)&&{type:`separator`,key:`container-separator`},N&&(O||k||A)&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},N&&(k||A)&&{key:`container-start`,disabled:D,onClick:()=>void E(`start`,{safeMode:!1,strategy:`parallel`}),icon:(0,G.jsx)(qr,{}),label:`Start`},N&&k&&{key:`container-start-safe`,disabled:D,onClick:()=>T(`start`),icon:(0,G.jsx)(Mr,{}),label:`Start in safe mode`},N&&(O||A)&&{key:`container-restart`,disabled:D,onClick:()=>C(!0),icon:(0,G.jsx)(Qr,{}),label:`Restart`},N&&O&&{key:`container-restart-safe`,disabled:D,onClick:()=>T(`restart`),icon:(0,G.jsx)(Mr,{}),label:`Restart in safe mode`},N&&(O||A)&&{key:`container-stop`,variant:`destructive`,disabled:D,onClick:()=>x(!0),icon:(0,G.jsx)(ci,{}),label:`Stop`},te&&c&&!!e.fqdn&&{type:`separator`,key:`copy-separator`},te&&c&&!!e.fqdn&&{key:`copy-host-name`,onClick:R,disabled:g,icon:(0,G.jsx)(sr,{}),label:`Copy Host Name`},te&&c&&!!e.fqdn&&{key:`copy-api-url`,onClick:de,disabled:g,icon:(0,G.jsx)(sr,{}),label:`Copy API URL`},ne&&p&&{key:`try-again`,onClick:L,className:`focus:bg-green/70 focus:text-white`,label:`Try Again`},!I&&f&&te&&{type:`separator`,key:`remove-separator`},!I&&f&&{key:`remove`,onClick:se,className:`focus:bg-red/70 focus:text-white`,icon:(0,G.jsx)(gi,{className:`text-red-300`}),label:M?`Remove`:`Terminate`}].filter(Fn);return(0,G.jsx)(tc,{items:I?[]:fe,children:(0,G.jsxs)(Ut,{className:`relative h-full justify-between transition-[transform,box-shadow] duration-200 ${le?`hover:scale-[1.02] hover:shadow-lg hover:ring-2 hover:ring-primary/60 dark:hover:ring-violet-400/70`:`hover:shadow-lg`}`,children:[le&&(0,G.jsx)(B,{to:le,"aria-label":`${M||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,G.jsxs)(Bt,{children:[(0,G.jsxs)(Ht,{className:`flex items-center justify-between`,children:[ue?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`truncate max-w-48`,children:ue}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`Copy host name`,onClick:e=>{e.stopPropagation(),R()},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,G.jsx)(fr,{size:16})}),(0,G.jsx)(`span`,{className:`grow`})]}):(0,G.jsx)(`span`,{children:`Self-Hosted`}),!I&&(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{"aria-label":`Cluster options`,onClick:e=>e.stopPropagation(),className:`relative z-10 -m-2 p-2 rounded-md hover:bg-accent/60`,children:(0,G.jsx)(hr,{})}),(0,G.jsx)(Di,{children:ec(fe,`dropdown`)})]})]}),(0,G.jsx)(zt,{children:(0,G.jsx)(`h2`,{children:e.name})})]}),(0,G.jsxs)(Vt,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(_c,{cluster:e}),te&&c&&(0,G.jsx)(pc,{cluster:e,hasCardLink:!!le}),ee&&e.status&&(0,G.jsxs)(qi,{variant:k?`destructive`:`warning`,children:[j&&(0,G.jsx)(Pr,{className:`animate-spin`}),wo(e.status)]}),ne&&e.status&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qi,{variant:Lo(e.status),children:wo(e.status)}),(0,G.jsx)(`span`,{className:`text-xs`,children:`Click "..." to choose how to proceed.`})]})]}),(0,G.jsx)(Gs,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:M?`Remove`:`Terminate`,presentParticiple:M?`Removing`:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:v,hideDataLossWarning:M,setIsModalOpen:e=>y(e),deletionConfirmed:ce,deletionPending:h}),(0,G.jsx)(hc,{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,G.jsx)(vc,{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 Ac({overEmail:e}){return(0,G.jsx)(`a`,{href:e?`mailto:support@harperdb.io`:`https://discord.com/channels/1415002037439041710/1415002038286286994`,target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Contact us`})}function jc({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] relative ${t??``}`,children:e})]})}function Mc({children:e}){let{organizationId:t,clusterId:n}=I({strict:!1}),{view:r,update:i}=ac(t,n),{data:a}=L(Ko(n,!1)),o=a?fc(a):!1,s=`/${t}/${n}`;return(0,G.jsx)(`div`,{className:`relative mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(Bi,{items:[{to:s,label:`Overview`,icon:jr,exact:!0},i&&{to:`${s}/edit`,label:o?`Configuration`:`Scaling`,icon:Cr,exact:!0},i&&!o&&{to:`${s}/edit/version`,label:`Version`,icon:fi,exact:!0},i&&!o&&{to:`${s}/domains`,label:`Domains`,icon:Tr},r&&{to:`${s}/instances`,label:`Instances`,icon:ni}].filter(Boolean),ariaLabel:`Cluster sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}async function Nc(e){let{data:t}=await M.get(`/Plan/`,{params:{organizationId:e}});return t}function Pc(e){return z({queryKey:[e,`instancePlan`],queryFn:()=>Nc(e),retry:!1})}var Fc=[`stable`,`next`,`beta`,`alpha`];function Ic(e){let t=Fc.indexOf(e);return t===-1?Fc.length:t}function Lc(e){let t=new Map;for(let n of e){let e=t.get(n.version);(!e||Ic(n.name)<Ic(e.name))&&t.set(n.version,n)}return[...t.values()]}async function Rc(e){let{data:t}=await M.get(`/HarperVersions/`,{params:{organizationId:e}}),n=t;return{...n,value:Lc(n.value)}}function zc(e){return z({queryKey:[e,`HarperVersions`],queryFn:()=>Rc(e),staleTime:6e4,retry:!1})}async function Bc({organizationId:e,availableHosts:t}={}){let{data:n}=await M.get(`/Region/`,{params:{availableHosts:t,organizationId:e}});return n}function Vc({organizationId:e,availableHosts:t}={}){return z({queryKey:[e,`regionLocations`,t],queryFn:()=>Bc({organizationId:e,availableHosts:t}),retry:!1})}function Hc(e){return(t,n)=>t[e]===n[e]?0:t[e]>n[e]?1:-1}function Uc(e){let t=e.split(`.`).map(Number);return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0}function Wc(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 Gc(e,t){return e.instanceFqdn===t.instanceFqdn?e.operationsApiPort-t.operationsApiPort:Wc(e.instanceFqdn)&&Wc(t.instanceFqdn)?Uc(e.instanceFqdn)-Uc(t.instanceFqdn):e.instanceFqdn>t.instanceFqdn?1:-1}function Kc(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 qc(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 Jc(e,t,n){let r=Kc(e,t),i={};for(let e in r)i[e]=qc(r[e],n);return i}function Yc({duration:e,message:t,lateMessage:n}){let r=(0,K.useRef)(0),i=(0,K.useRef)(0),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(`5%`),l=(0,K.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,K.useEffect)(()=>(r.current=requestAnimationFrame(l),()=>cancelAnimationFrame(r.current)),[l]),(0,G.jsxs)(G.Fragment,{children:[a?n:t,(0,G.jsx)(cn,{width:s,animated:!1})]})}async function Xc(e){let{data:t}=await M.post(`/Cluster/`,e,{timeout:0});return t}function Zc(){return F({mutationFn:e=>Xc(e)})}async function Qc(e){let{id:t,...n}=e,{data:r}=await M.put(`/Cluster/${t}`,n,{timeout:0});return r}function $c(){return F({mutationFn:e=>Qc(e)})}function el(e){return!!e&&e!==`undefined`&&e!==`null`}async function tl(e){if(!el(e))throw Error(`getOrganization called without a valid organization id (got: ${e})`);let{data:t}=await M.get(`/Organization/${e}`);return t}function nl(e){return z({queryKey:[e],queryFn:()=>tl(e),retry:!1,enabled:el(e),refetchInterval:Ln(1e4)})}var rl=`ENTERPRISE`;function il(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 al(e,t,n=`-`){let r=t.split(n)[0];return e.findIndex(e=>e.startsWith(r))!==-1}function ol(e){return e.replace(/[^a-zA-Z0-9]/g,`-`).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase().replace(/-+/g,`-`).replace(/^-+|-+$/g,``)}function sl(e){return e!==void 0&&e>0}function cl(e,t,n){return t===void 0?Promise.resolve():e.invalidateQueries({predicate:e=>e.queryKey[0]===t||e.queryKey[1]===t,...n})}async function ll(e){await M.put(`/Payment/`,e)}function ul(){return F({mutationFn:e=>ll(e)})}function dl(e){let{mutate:t}=ul();return(0,K.useCallback)((n,r)=>{t({paymentMethodId:typeof n==`string`?n:n.id,organizationId:e},{onSuccess:()=>{H.success(`Success! Your payment method has been saved.`),r(!0)},onError:()=>{H.error(`Failed to process payment method details. Please try another payment method.`),r(!1)}})},[t,e])}var fl=(0,K.createContext)(null);function pl(){return(0,K.useContext)(fl)}var ml=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),hl=n(((e,t)=>{var n=ml();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}})),gl=n(((e,t)=>{t.exports=hl()()})),_l=e(gl(),1);function vl(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 yl(e){if(Array.isArray(e))return e}function bl(e,t,n){return(t=kl(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xl(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 Sl(){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 Cl(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 wl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Cl(Object(n),!0).forEach(function(t){bl(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tl(e,t){if(e==null)return{};var n,r,i=El(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 El(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 Dl(e,t){return yl(e)||xl(e,t)||jl(e,t)||Sl()}function Ol(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 kl(e){var t=Ol(e,`string`);return typeof t==`symbol`?t:t+``}function Al(e){"@babel/helpers - typeof";return Al=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},Al(e)}function jl(e,t){if(e){if(typeof e==`string`)return vl(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)?vl(e,t):void 0}}var Ml=function(e,t,n){var r=!!n,i=K.useRef(n);K.useEffect(function(){i.current=n},[n]),K.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])},Nl=function(e){var t=K.useRef(e);return K.useEffect(function(){t.current=e},[e]),t.current},Pl=function(e){return e!==null&&Al(e)===`object`},Fl=function(e){return Pl(e)&&typeof e.then==`function`},Il=function(e){return Pl(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Ll=`[object Object]`,Rl=function e(t,n){if(!Pl(t)||!Pl(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Ll;if(i!==(Object.prototype.toString.call(n)===Ll))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])})},zl=function(e,t,n){return Pl(e)?Object.keys(e).reduce(function(r,i){var a=!Pl(t)||!Rl(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?wl(wl({},r||{}),{},bl({},i,e[i])):r},null):null},Bl="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",Vl=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bl;if(e===null||Il(e))return e;throw Error(t)},Hl=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bl;if(Fl(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return Vl(e,t)})};var n=Vl(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Ul=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.8.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.8.0`,url:`https://stripe.com/docs/stripe-js/react`}))},Wl=K.createContext(null);Wl.displayName=`ElementsContext`;var Gl=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},Kl=function(e){var t=e.stripe,n=e.options,r=e.children,i=K.useMemo(function(){return Hl(t)},[t]),a=Dl(K.useState(function(){return{stripe:i.tag===`sync`?i.stripe:null,elements:i.tag===`sync`?i.stripe.elements(n):null}}),2),o=a[0],s=a[1];K.useEffect(function(){var e=!0,t=function(e){s(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return i.tag===`async`&&!o.stripe?i.stripePromise.then(function(n){n&&e&&t(n)}):i.tag===`sync`&&!o.stripe&&t(i.stripe),function(){e=!1}},[i,o,n]);var c=Nl(t);K.useEffect(function(){c!==null&&c!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[c,t]);var l=Nl(n);return K.useEffect(function(){if(o.elements){var e=zl(n,l,[`clientSecret`,`fonts`]);e&&o.elements.update(e)}},[n,l,o.elements]),K.useEffect(function(){Ul(o.stripe)},[o.stripe]),K.createElement(Wl.Provider,{value:o},r)};Kl.propTypes={stripe:_l.default.any,options:_l.default.object};var ql=function(e){return Gl(K.useContext(Wl),e)},Jl=function(){return ql(`calls useElements()`).elements},Yl=function(e){var t=e.children;return t(ql(`mounts <ElementsConsumer>`))};Yl.propTypes={children:_l.default.func.isRequired};var Xl=K.createContext(null);Xl.displayName=`CheckoutContext`;var Zl=function(e){var t=K.useContext(Xl),n=K.useContext(Wl);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}else return Gl(n,e)},Ql=[`mode`],$l=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},eu=function(e,t,n){var r=`${$l(e)}Element`,i=t?function(e){Zl(`mounts <${r}>`);var t=e.id,n=e.className;return K.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=Zl(`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=Dl(K.useState(null),2),O=D[0],k=D[1],A=K.useRef(null),j=K.useRef(null);Ml(O,`blur`,s),Ml(O,`focus`,c),Ml(O,`escape`,d),Ml(O,`click`,f),Ml(O,`loaderror`,p),Ml(O,`loaderstart`,m),Ml(O,`networkschange`,h),Ml(O,`confirm`,g),Ml(O,`cancel`,_),Ml(O,`shippingaddresschange`,v),Ml(O,`shippingratechange`,y),Ml(O,`savedpaymentmethodremove`,b),Ml(O,`savedpaymentmethodupdate`,x),Ml(O,`availablepaymentmethodschange`,S),Ml(O,`change`,u);var ee;l&&(ee=e===`expressCheckout`?l:function(){l(O)}),Ml(O,`ready`,ee),K.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=Tl(o,Ql);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 te=Nl(o);return K.useEffect(function(){if(A.current){var e=zl(o,te,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,te]),K.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),K.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:_l.default.string,className:_l.default.string,onChange:_l.default.func,onBlur:_l.default.func,onFocus:_l.default.func,onReady:_l.default.func,onEscape:_l.default.func,onClick:_l.default.func,onLoadError:_l.default.func,onLoaderStart:_l.default.func,onNetworksChange:_l.default.func,onConfirm:_l.default.func,onCancel:_l.default.func,onShippingAddressChange:_l.default.func,onShippingRateChange:_l.default.func,onSavedPaymentMethodRemove:_l.default.func,onSavedPaymentMethodUpdate:_l.default.func,onAvailablePaymentMethodsChange:_l.default.func,options:_l.default.object},i.displayName=r,i.__elementType=e,i},tu=typeof window>`u`,nu=K.createContext(null);nu.displayName=`EmbeddedCheckoutProviderContext`;var ru=function(){return Zl(`calls useStripe()`).stripe};eu(`auBankAccount`,tu),eu(`card`,tu),eu(`cardNumber`,tu),eu(`cardExpiry`,tu),eu(`cardCvc`,tu),eu(`currencySelector`,tu),eu(`iban`,tu);var iu=eu(`payment`,tu);eu(`expressCheckout`,tu),eu(`paymentRequestButton`,tu),eu(`linkAuthentication`,tu),eu(`contactDetails`,tu);var au=eu(`address`,tu);eu(`shippingAddress`,tu),eu(`paymentMethodMessaging`,tu),eu(`taxId`,tu),eu(`issuingCardNumberDisplay`,tu),eu(`issuingCardCvcDisplay`,tu),eu(`issuingCardExpiryDisplay`,tu),eu(`issuingCardPinDisplay`,tu),eu(`issuingCardCopyButton`,tu),eu(`terms`,tu);function ou({hasExistingBilling:e,onPaymentAdded:t,onSaveStateForBillingRedirect:n}){let{organizationId:r}=I({strict:!1}),i=ru(),a=pl(),o=Jl(),[s,c]=(0,K.useState)(!1),l=dl(r),u=(0,K.useCallback)(()=>{t(!1)},[t]);return(0,G.jsxs)(`form`,{id:`billing-add-payment-method-form`,name:`billing-add-payment-method-form`,onSubmit:(0,K.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),H.error(s.error.message),c(!1),n?.(!1)):s.setupIntent.payment_method&&(l(s.setupIntent.payment_method,t),n?.(!1))},[o,t,n,r,l,i,a.clientSecret]),className:`max-w-xl`,children:[(0,G.jsx)(iu,{}),(0,G.jsx)(au,{options:{mode:`billing`}}),(0,G.jsxs)(`div`,{className:`mt-4 flex gap-8 items-center`,children:[(0,G.jsxs)(P,{disabled:!i||!o||s,variant:`submit`,children:[(0,G.jsx)($r,{}),` Add Payment Method`]}),e&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`text-xs text-gray-600`,children:`Your existing payment method will be overwritten.`}),(0,G.jsx)(P,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Cancel`})]})]})]})}var su=`dahlia`,cu=`https://js.stripe.com`,lu=`${cu}/${su}/stripe.js`,uu=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,du=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,fu=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,pu=function(e){return uu.test(e)||du.test(e)},mu=function(){for(var e=document.querySelectorAll(`script[src^="${cu}"]`),t=0;t<e.length;t++){var n=e[t];if(pu(n.src))return n}return null},hu=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${lu}${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},gu=null,_u=null,vu=null,yu=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},bu=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},xu=function(e){return gu===null?(gu=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(fu),window.Stripe){t(window.Stripe);return}try{var r=mu();if(r&&e)console.warn(fu);else if(!r)r=hu(e);else if(r&&vu!==null&&_u!==null){var i;r.removeEventListener(`load`,vu),r.removeEventListener(`error`,_u),(i=r.parentNode)==null||i.removeChild(r),r=hu(e)}vu=bu(t,n),_u=yu(n),r.addEventListener(`load`,vu),r.addEventListener(`error`,_u)}catch(e){n(e);return}}),gu.catch(function(e){return gu=null,Promise.reject(e)})):gu},Su,Cu=function(){return Su||(Su=xu(null).catch(function(e){return Su=null,Promise.reject(e)}),Su)};Promise.resolve().then(function(){return Cu()}).catch(function(e){console.warn(e)});async function wu(e){let{data:t}=await M.post(`/StripeAccount/`,e);return t}function Tu(){return F({mutationFn:e=>wu(e)})}async function Eu(e){let{data:t}=await M.post(`/Payment/`,{organizationId:e.organizationId});return t}function Du(){return F({mutationFn:e=>Eu(e)})}function Ou(e){let{enabled:t,existingStripeId:n,organizationId:r}=e,{mutate:i}=Tu(),{mutate:a}=Du(),[o,s]=(0,K.useState)(void 0);return(0,K.useEffect)(()=>{},[i,t,n,a,(0,K.useCallback)(e=>{s(e.clientSecret)},[]),r]),o}function ku({children:e}){let{organizationId:t}=I({strict:!1}),{data:n}=L(nl(t)),r=Ou({organizationId:t,enabled:!!n,existingStripeId:n?.stripeId}),i=Da();return(0,K.useMemo)(()=>({clientSecret:r||``,appearance:{theme:i===`dark`?`night`:`stripe`}}),[r,i]),console.error(`No VITE_PUBLIC_STRIPE_KEY is configured for this environment.`),(0,G.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 Au({onPaymentAdded:e,onSaveStateForBillingRedirect:t}){let{organizationId:n}=I({strict:!1}),{data:r}=L(nl(n)),i=r?.billing,a=i?.paymentMethod;return(0,G.jsxs)(ku,{children:[(0,G.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,G.jsx)(ou,{hasExistingBilling:!!i,onSaveStateForBillingRedirect:t,onPaymentAdded:e})]})}var ju=function(e){return e.PASS=`pass`,e.FAIL=`fail`,e.PENDING=`pending`,e.ERROR=`error`,e}({});function Mu(e){switch(e){case ju.PASS:return`success`;case ju.FAIL:case ju.ERROR:return`destructive`;case ju.PENDING:default:return`default`}}function Nu(e){switch(e){case ju.PASS:return`READY`;case ju.FAIL:case ju.ERROR:case ju.PENDING:default:return e.toUpperCase()}}function Pu(e,t){return`${String(e).padStart(2,`0`)}/${String(t%100).padStart(2,`0`)}`}function Fu(e){let{onSaveStateForBillingRedirect:t,onReplacingPaymentMethod:n}=e??{},{organizationId:r}=I({strict:!1}),{update:i}=rc(r),{data:a,refetch:o}=L(nl(r)),s=a?.billing?.paymentMethod,[c,l]=(0,K.useState)(!1),u=(0,K.useCallback)(()=>{l(!c),n?.(!c)},[n,c]),d=(0,K.useCallback)(e=>{l(!1),n?.(!1),e&&o()},[n,o]);return a?.type===`ENTERPRISE`?(0,G.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,G.jsx)(Ac,{}),`, we would love to talk!`]}):s&&!c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-2`,children:[s.brand?.toUpperCase()??`Card`,` ending in `,s.last4??`••••`,s.expMonth&&s.expYear?(0,G.jsxs)(G.Fragment,{children:[`(exp `,Pu(s.expMonth,s.expYear),`)`]}):null,s.status?(0,G.jsxs)(G.Fragment,{children:[`—`,` `,(0,G.jsx)(qi,{variant:Mu(s.status),children:Nu(s.status)})]}):null]}),i&&(0,G.jsx)(`div`,{className:`mt-2 mb-6`,children:(0,G.jsx)(P,{variant:`defaultOutline`,type:`button`,onClick:u,children:`Replace Payment Method`})})]}):i?(0,G.jsx)(Au,{onSaveStateForBillingRedirect:t,onPaymentAdded:d}):(0,G.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 Iu({clusterId:e,isPending:t,onGoBackToDetails:n,onSaveStateForBillingRedirect:r,onSubmit:i,organizationId:a,selectedPlan:s}){let{data:c}=L(nl(a)),l=c?.billing,u=c?.type===rl,d=u||l?.paymentMethod?.status===ju.PASS,[f,p]=(0,K.useState)(!1),m=sl(s?.planLimits?.expirationMonths)&&s.planLimits.expirationMonths<1e3&&s.planLimits.expirationMonths,h=(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end mt-3 max-w-xl`,children:[(0,G.jsxs)(P,{type:`button`,variant:`defaultOutline`,disabled:t,onClick:n,children:[(0,G.jsx)(on,{}),` Back to Details`]}),(0,G.jsxs)(P,{disabled:t||!d||f,type:`submit`,variant:`submit`,onClick:i,children:[e?`Edit Cluster`:`Create New Cluster`,` `,(0,G.jsx)(Gn,{})]})]})});if(u)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`ul`,{className:`list-disc ml-6 max-w-lg`,children:[(0,G.jsx)(`li`,{children:`Reminder: you will be billed at your contracted rate for any additional infrastructure.`}),(0,G.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,G.jsx)(Ac,{overEmail:!0}),`, we are here to help.`]})]}),h]});let g=m&&`, or ${o(m,`month`,`months`)} elapse`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`ul`,{className:`list-disc ml-6 mb-6`,children:[(0,G.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,G.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,G.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,G.jsxs)(`li`,{children:[`When that block is used up`,g,`, you will be automatically renewed.`]}),(0,G.jsx)(`li`,{children:`While refunds are not available, we’d be happy to assist you with troubleshooting.`}),(0,G.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,G.jsx)(Ac,{overEmail:!0}),`, we are here to help.`]})]}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:`Payment method:`}),(0,G.jsx)(Fu,{onSaveStateForBillingRedirect:r,onReplacingPaymentMethod:p}),h]})}var Lu=/(^$|^(?: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,Ru=65535,zu=S().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.`),Bu=j({clusterName:S().nonempty(`Please enter a cluster name.`).max(255,`Cluster name cannot be longer than 255 characters long.`),abbreviatedName:ee([D(``),k(),zu]).optional(),fqdn:S().regex(Lu,`Please enter a valid host name without the port or any path.`).optional(),version:S().optional(),deploymentDescription:S().nonempty(`Please select a deployment tier.`),performanceDescription:S().nonempty(`Please select a performance tier.`),regionPlans:C(j({regionName:S().nonempty(`Please select a region.`),latencyDescription:S().nonempty(`Please select a latency tier.`)})).max(50,{error:`A maximum of 50 regions can be selected for each cluster. `}),instances:C(j({secure:A([`true`,`false`]),fqdn:S().nonempty(`Please enter the host name of your instance.`).regex(Lu,`Please enter a valid host name without the port or any path.`),port:b().min(0,`Positive thinking only, please.`).max(Ru,`That port number is too high.`).optional()})).max(100,{error:`A maximum of 100 instances can be added to each cluster.`}),skipToBilling:E().optional(),skipGtmWait:E().optional(),sourceClusterId:S().optional()});function Vu({calculatedNames:e,disabled:t,form:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{control:n.control,name:`abbreviatedName`,render:({field:n})=>(0,G.jsxs)(X,{className:`col-span-3`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...n,type:`text`,maxLength:zu.maxLength,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:e.suggestedAbbreviatedName,disabled:t})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(X,{className:`col-span-3 `,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)(`span`,{children:e.fullHostName})}),(0,G.jsx)(Q,{})]})]})}function Hu({className:e}={}){return(0,G.jsx)(`div`,{className:(0,K.useMemo)(()=>_(`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])})}var Uu={Colocated:`Shared infrastructure for optimized value`,Dedicated:`Dedicated infrastructure for consistent performance`,"Self-Hosted":`Your own infrastructure`};function Wu({availableDeploymentTypes:e,disabled:t,form:n}){return(0,G.jsx)(Y,{control:n.control,name:`deploymentDescription`,render:({field:r})=>(0,G.jsxs)(X,{className:`col-span-3`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Harper Deployment`}),(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(Hu,{}),children:(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{...r,disabled:t,onValueChange:e=>{r.onChange(e),n.trigger()},children:[(0,G.jsx)($t,{className:`w-full h-auto`,children:(0,G.jsx)(nn,{placeholder:`Choose Tier`})}),(0,G.jsx)(Qt,{children:(0,G.jsx)(tn,{children:e.map(e=>(0,G.jsxs)(Yt,{value:e,children:[(0,G.jsx)(`dt`,{className:`text-left font-bold text-sm/6`,children:e}),Uu[e]&&(0,G.jsx)(`dd`,{className:`font-light`,children:Uu[e]})]},e))})})]})})}),(0,G.jsx)(Q,{})]})})}function Gu({disabled:e,form:t}){return(0,G.jsx)(Y,{control:t.control,name:`fqdn`,render:({field:t})=>(0,G.jsxs)(X,{className:`md:col-span-6 col-span-3`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Optional Cluster Load Balancer Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...t,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:`example.your-company.com`,disabled:e})}),(0,G.jsx)(Q,{})]})})}function Ku({className:e,disabled:t,form:n}){return(0,G.jsx)(Y,{control:n.control,name:`clusterName`,render:({field:n})=>(0,G.jsxs)(X,{className:e,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Cluster Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoFocus:!0,type:`text`,maxLength:Bu.shape.clusterName.maxLength,autoCapitalize:`words`,disabled:t,...n})}),(0,G.jsx)(Q,{})]})})}function qu({availablePerformanceDescriptions:e,form:t,selectedDeployment:n}){return(0,G.jsx)(Y,{control:t.control,name:`performanceDescription`,render:({field:r})=>(0,G.jsxs)(X,{className:`col-span-3`,children:[(0,G.jsxs)(Z,{className:`pb-1`,children:[n.startsWith(`Self`)?`Support`:`Performance`,` & Usage`]}),(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(Hu,{}),children:(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{...r,onValueChange:e=>{r.onChange(e),t.trigger()},disabled:!e?.length,children:[(0,G.jsx)($t,{className:`w-full h-auto`,children:(0,G.jsx)(nn,{placeholder:`Choose Tier`})}),(0,G.jsx)(Qt,{children:(0,G.jsx)(tn,{children:e.map(e=>(0,G.jsxs)(Yt,{value:e.performanceTier,children:[(0,G.jsxs)(`dt`,{className:`text-left font-bold text-sm/6 flex items-center gap-2`,children:[e.name,e.isPremium&&(0,G.jsx)(qi,{children:`Premium`})]}),e.description&&(0,G.jsx)(`dd`,{className:`text-left font-light`,children:e.description})]},e.name))})})]})})}),(0,G.jsx)(Q,{})]})})}function Ju({className:e,...t}){let{formDescriptionId:n}=ko();return(0,G.jsx)(`p`,{"data-slot":`form-description`,id:n,className:N(`text-muted-foreground text-sm`,e),...t})}function Yu({className:e,form:t}){return(0,G.jsx)(Y,{control:t.control,name:`skipGtmWait`,render:({field:t})=>(0,G.jsxs)(X,{className:e,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(J,{children:(0,G.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,G.jsx)(Z,{className:`cursor-pointer`,children:`Immediate upgrade and restart`})]}),(0,G.jsx)(Ju,{children:`Apply changes immediately without waiting for each instance to be taken out of the load balancer (faster, but potentially less safe).`})]})})}function Xu({className:e,disabled:t,form:n,harperVersions:r}){return r?.value?.length?(0,G.jsx)(Y,{control:n.control,name:`version`,render:({field:i})=>(0,G.jsxs)(X,{className:e,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Harper Version`}),(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(Hu,{}),children:(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{...i,disabled:t,onValueChange:e=>{i.onChange(e),n.trigger()},children:[(0,G.jsx)($t,{className:`w-full h-auto`,children:(0,G.jsx)(nn,{placeholder:`Choose Version`})}),(0,G.jsx)(Qt,{children:(0,G.jsx)(tn,{children:r?.value.map(e=>(0,G.jsxs)(Yt,{value:e.version,children:[e.version,` `,(0,G.jsx)(`span`,{className:`font-light opacity-50`,children:e.name})]},e.version))})})]})})}),(0,G.jsx)(Q,{})]})}):null}var Zu=new RegExp(/^\d+/);function Qu(e,t){let n=parseInt(e.match(Zu)?.[0]||`0`,10),r=parseInt(t.match(Zu)?.[0]||`0`,10);return n===r?0:n>r?1:-1}var $u=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],ed=[`secs`,`mins`,`hrs`],td={bytes:1e3,secs:60};function nd(e,t,n){let r,i;switch(t){case`bytes`:r=$u,i=td.bytes;break;case`secs`:r=ed,i=td.secs;break;default:return e}let a=r.indexOf(n);return a===-1?e:e/i**a}function rd(e,t){let n,r;switch(e){case`bytes`:n=$u,r=td.bytes;break;case`secs`:n=ed,r=td.secs;break;default:return e}let i=0;for(;t>=r&&i<n.length-1;)t/=r,i++;return n[i]}function id(e,t=1){let n=e*t,r=rd(`bytes`,n),i=nd(n,`bytes`,r);return`${new Intl.NumberFormat().format(Math.round(i))} ${r}`}function ad(e){return new Intl.NumberFormat().format(e)}var od=[`K`,`M`,`B`,`T`,`Qa`,`Qi`,`Sx`,`Sp`,`Oc`,`No`,`Dc`];function sd(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<od.length-1);return`${ad(Math.round(n))} ${od[r]}`}function cd(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 ld(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 ud({selectedPlan:e,selectedRegion:t,usageScale:n,isEnterprise:r,cloudProvider:i}){let[a,s]=(0,K.useState)(!1),c=(0,K.useCallback)(()=>{s(!a)},[a,s]),l=e?.planLimits,u=e?.resourcesPerInstance,d=i&&e?.cloudInstanceTypes?.[i],f=sl(l?.expirationMonths)&&l.expirationMonths<1e3&&l.expirationMonths,p=t?.purchasedBlockMultiplier??1,m=(0,K.useMemo)(()=>l?[sl(l.totalReadCount)&&{label:`Total Reads`,value:sd(l.totalReadCount*p)},sl(l.totalReadsBytes)&&{label:`Total Read Transfer`,value:`${id(l.totalReadsBytes*p)}`},sl(l.readsPerMinuteCount)&&{label:`Read Rate`,value:`${sd(l.readsPerMinuteCount*60*p)}/hr`},sl(l.readsPerMinuteBytes)&&{label:`Read Bandwidth`,value:`${id(l.readsPerMinuteBytes*60*p)}/hr`},sl(l.totalWriteCount)&&{label:`Total Writes`,value:sd(l.totalWriteCount)},sl(l.totalWritesBytes)&&{label:`Total Write Transfer`,value:`${id(l.totalWritesBytes)}`},sl(l.writesPerMinuteCount)&&{label:`Write Rate`,value:`${sd(l.writesPerMinuteCount*60)}/hr`},sl(l.writesPerMinuteBytes)&&{label:`Write Bandwidth`,value:`${id(l.writesPerMinuteBytes*60)}/hr`},sl(l.totalRealTimeMessageDeliveries)&&{label:`Total Real-Time Messages`,value:`${sd(l.totalRealTimeMessageDeliveries*p)} messages`},sl(l.totalRealTimeMessageDeliveryBytes)&&{label:`Total Real-Time Message Transfer`,value:`${id(l.totalRealTimeMessageDeliveryBytes*p)}`},sl(l.realTimeMessageDeliveriesPerMinute)&&{label:`Real-Time Message Rate`,value:`${sd(l.realTimeMessageDeliveriesPerMinute*60*p)}/hr`},sl(l.realTimeMessageDeliveryBytesPerMinute)&&{label:`Real-Time Message Bandwidth`,value:`${id(l.realTimeMessageDeliveryBytesPerMinute*60*p)}/hr`},sl(l.tlsHandshakes)&&{label:`TLS Handshakes`,value:`${sd(l.tlsHandshakes*60*p)}`},sl(l.applicationComputeHours)&&{label:`Application Compute Hours`,value:`${sd(l.applicationComputeHours*p)}`},!!u&&sl(u.storageGb)&&{label:`Storage`,value:`${id(u.storageGb*1e9)}`},!!u&&sl(u.cpuCores)&&{label:`Maximum CPU Cores`,value:`${sd(u.cpuCores)}`},!!u&&sl(u.memoryMb)&&{label:`Memory`,value:`${u.memoryMb/1024} GB`},!!d&&{label:`Cloud Instance Type`,value:d},!!f&&{label:`Expiration`,value:o(f,`month`,`months`)},!!t?.id&&{label:`Region ID`,value:t.id},!!e?.id&&{label:`Plan ID`,value:e.id}].filter(Fn):[],[f,t,e,p]);if(!l)return``;if(!sl(l.totalReadCount))return`This plan has no usage limits.`;let h=r?`for the contracted rate`:`for the price listed above`,g=f?` in ${o(f,`month`,`months`)} or`:``,_=sl(l.readsPerMinuteCount)?l.readsPerMinuteCount*p:0,v=sl(l.writesPerMinuteCount)?l.writesPerMinuteCount:0,y=l.totalReadCount*p,b=sl(l.totalWriteCount)?l.totalWriteCount:0,x=[_>0&&{icon:Cr,label:`Read Rate`,value:`${sd(_)}/min`,fill:ld(_,n.readRate)},y>0&&{icon:Kn,label:`Total Reads`,value:sd(y),fill:ld(y,n.totalReads)},v>0&&{icon:Cr,label:`Write Rate`,value:`${sd(v)}/min`,fill:ld(v,n.writeRate)},b>0&&{icon:Wn,label:`Total Writes`,value:sd(b),fill:ld(b,n.totalWrites)},!!f&&{icon:Zn,label:`License Term`,value:o(f,`month`,`months`)}].filter(Fn);return(0,G.jsxs)(X,{className:`basis-full`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-2`,children:[(0,G.jsx)(Z,{onClick:c,className:`cursor-pointer`,children:`Usage block included with this plan`}),(0,G.jsxs)(P,{type:`button`,variant:`link`,className:`text-foreground`,onClick:c,children:[`Learn More `,a?(0,G.jsx)(Jt,{}):(0,G.jsx)(Gn,{})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:x.map(e=>(0,G.jsx)(dd,{icon:e.icon,label:e.label,value:e.value,fill:e.fill},e.label))}),(0,G.jsx)(J,{children:(0,G.jsxs)(`dl`,{className:N(`divide-y divide-border rounded-md overflow-hidden transition-[max-height] duration-200 ease-in`,a?`max-h-fit border border-border`:`max-h-0`),children:[(0,G.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,G.jsxs)(`div`,{className:N(`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,G.jsx)(`dt`,{className:`text-sm/6 font-medium text-foreground`,children:e.label}),(0,G.jsx)(`dd`,{className:`mt-1 text-sm/6 text-muted-foreground sm:col-span-2 sm:mt-0`,children:e.value})]},e.label))]})}),(0,G.jsx)(Q,{})]})}function dd({icon:e,label:t,value:n,fill:r}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-background/50 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,G.jsx)(e,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs font-medium`,children:t})]}),(0,G.jsx)(`span`,{className:`text-lg font-bold text-foreground tabular-nums`,children:n}),r!==void 0&&(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-sky-500/15`,children:(0,G.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 fd({control:e,fieldArray:t,form:n,index:r,regionNameToLatencyToRegion:i,premiumOnlyRegions:a,usageScale:o,selectedPlan:s,isEnterprise:c,cloudProvider:l}){let u=(0,K.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,K.useMemo)(()=>Object.keys(i[f]||{}).sort(Qu).reverse(),[i,f]),h=s?.allowedRegionIds,g=(0,K.useCallback)(e=>!h?.length||Object.values(i[e]||{}).some(e=>h.includes(e.id)),[h,i]),_=(0,K.useCallback)(e=>{if(!h?.length)return!0;let t=i[f]?.[e]?.id;return!t||h.includes(t)},[h,i,f]);(0,K.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,K.useCallback)(()=>{t?.remove(r),n.trigger()},[t,n,r]);return(0,G.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,G.jsx)(Y,{control:e,name:`regionPlans.${r}.regionName`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsxs)(Z,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Br,{className:`size-4 shrink-0`}),`Region `,t.fields.length>1?r+1:``]}),(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,children:[(0,G.jsx)($t,{className:`w-full`,children:(0,G.jsx)(nn,{placeholder:`Choose Region`})}),(0,G.jsx)(Qt,{children:(0,G.jsx)(tn,{children:u.map(e=>(0,G.jsx)(Yt,{value:e,disabled:!g(e),children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,a.regionNames.has(e)&&(0,G.jsx)(qi,{children:`Premium`})]})},e))})})]})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e,name:`regionPlans.${r}.latencyDescription`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsxs)(Z,{children:[`Estimated `,d?`P95`:`P90`,` Latency, Distribution`]}),(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{onValueChange:t=>{e.onChange(t),n.trigger()},...e,disabled:!m?.length,children:[(0,G.jsx)($t,{className:`w-full`,children:(0,G.jsx)(nn,{placeholder:`Choose Latency Tier`})}),(0,G.jsx)(Qt,{children:(0,G.jsx)(tn,{children:m.map(e=>(0,G.jsx)(Yt,{value:e,disabled:!_(e),children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e,(()=>{let t=i[f]?.[e]?.id;return t&&a.regionIds.has(t)&&(0,G.jsx)(qi,{children:`Premium`})})()]})},e))})})]})}),(0,G.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,G.jsx)(`div`,{className:`flex-none mt-6`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:v,children:[(0,G.jsx)(gi,{}),` `,(0,G.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})}),(0,G.jsx)(ud,{selectedPlan:s,selectedRegion:i[f]?.[p],usageScale:o,isEnterprise:c,cloudProvider:l})]})}function pd({form:e,regionLocations:t,regionNameToLatencyToRegion:n,premiumOnlyRegions:r,usageScale:i,selectedPlan:a,totalPrice:o,isEnterprise:s,cloudProvider:c}){let l=e.watch(`regionPlans`),u=Et({control:e.control,name:`regionPlans`}),d=(0,K.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,K.useCallback)(()=>{d&&(u.append({regionName:d.region,latencyDescription:d.latencyDescription}),e.trigger())},[e,d,u]);return t?.length?(0,G.jsxs)(G.Fragment,{children:[u.fields.map((t,o)=>(0,G.jsx)(fd,{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,G.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,G.jsxs)(P,{type:`button`,variant:`positiveOutline`,onClick:f,children:[(0,G.jsx)(Jr,{}),`Add Additional Region Usage`]})})]}):(0,G.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,G.jsx)(Si,{className:`mt-0 m-0`,title:`No Regions Available`,showReturnToHome:!1,error:{message:(0,G.jsxs)(G.Fragment,{children:[`The deployment type you selected currently has no available regions. Please try a different deployment type, try again later, or `,(0,G.jsx)(Ac,{}),`.`]})}})})}function md({control:e,fieldArray:t,form:n,index:r}){let i=(0,K.useCallback)(()=>{t?.remove(r)},[t,r]);return(0,G.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,G.jsx)(Y,{control:e,name:`instances.${r}.secure`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsxs)(Z,{children:[`Instance `,t.fields.length>1?r+1:``]}),(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{...e,onValueChange:t=>{e.onChange(t),n.trigger()},children:[(0,G.jsx)($t,{className:`w-full`,children:(0,G.jsx)(nn,{placeholder:`https://`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Yt,{value:`true`,children:`https://`}),(0,G.jsx)(Yt,{value:`false`,children:`http://`})]})})]})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e,name:`instances.${r}.fqdn`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-3`,children:[(0,G.jsx)(Z,{children:`Host Name`}),(0,G.jsx)(J,{children:(0,G.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,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e,name:`instances.${r}.port`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Operations API Port`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...e,type:`number`,min:0,max:Ru,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,placeholder:String(l),onChange:t=>{e.onChange(t.target.value?parseInt(t.target.value,10):void 0),n.trigger()}})}),(0,G.jsx)(Q,{})]})}),t?.fields?.length&&t?.fields?.length>1&&(0,G.jsx)(`div`,{className:`flex-none mt-6`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,size:`sm`,onClick:i,children:[(0,G.jsx)(gi,{}),` `,(0,G.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})})]})}function hd({form:e}){let t=Et({control:e.control,name:`instances`}),n=(0,K.useCallback)(()=>{t.append({secure:`true`,fqdn:``,port:l})},[t]);return(0,G.jsxs)(G.Fragment,{children:[t.fields.map((n,r)=>(0,G.jsx)(md,{control:e.control,fieldArray:t,form:e,index:r},n.id)),(0,G.jsx)(`div`,{className:`md:col-span-6 col-span-3`,children:(0,G.jsxs)(P,{type:`button`,variant:`positiveOutline`,onClick:n,children:[(0,G.jsx)(Jr,{}),`Add Instance`]})})]})}function gd(e,t){return!e.allowedRegionIds?.length||e.allowedRegionIds.includes(t)}function _d(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=>gd(t,e.id)),i=o.some(t=>gd(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 vd({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:_}=wt(),v=(0,K.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,K.useMemo)(()=>Object.keys(n).sort(),[n]),b=(0,K.useMemo)(()=>_d(Object.values(n[f]||{}),d),[n,d,f]),x=(0,K.useMemo)(()=>cd(Object.values(n).flatMap(e=>Object.values(e)),d),[n,d]);(0,K.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,G.jsx)(Kt,{className:`mt-3 mb-12`,children:(0,G.jsxs)(P,{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,G.jsx)(Gn,{})]})});return c===`version`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,G.jsx)(Ku,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!0,form:r}),(0,G.jsx)(Xu,{className:`col-span-3`,form:r,harperVersions:i}),(0,G.jsx)(Yu,{className:`col-span-3 md:col-span-6`,form:r}),l&&(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-3 items-start gap-6 text-foreground md:grid-cols-6`,children:[(0,G.jsx)(Ku,{className:i?.value?.length?`col-span-3`:`md:col-span-6 col-span-3`,disabled:!!t,form:r}),(0,G.jsx)(Xu,{className:`col-span-3`,disabled:!!t,form:r,harperVersions:i}),S?(0,G.jsx)(Gu,{form:r,disabled:!!t}):(0,G.jsx)(Vu,{form:r,calculatedNames:e,disabled:!!t}),(0,G.jsx)(Wu,{form:r,availableDeploymentTypes:y}),(0,G.jsx)(qu,{availablePerformanceDescriptions:v,form:r,selectedDeployment:f}),S?(0,G.jsx)(hd,{form:r}):(0,G.jsx)(pd,{form:r,regionLocations:u,regionNameToLatencyToRegion:d,premiumOnlyRegions:b,usageScale:x,selectedPlan:m,totalPrice:h,isEnterprise:a,cloudProvider:o}),t&&!S&&(0,G.jsx)(Yu,{className:`col-span-3 md:col-span-6`,form:r})]}),C]})}function yd(e){let{fqdn:t}=e,{secure:n,port:r}=e;return r||=l,r===443&&n===`false`&&(n=`true`),r===80&&n===`true`&&(n=`false`),`${n===`true`?`https`:`http`}://${t}${r===443||r===80?``:`:`+r}`.toLowerCase()}function bd(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 xd(e,t,n){if(t&&n){let r=e.getValues();if(!r.deploymentDescription||!r.performanceDescription||!r.regionPlans.length){let i=bd(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 Sd({price:e}){return(0,G.jsx)(`span`,{className:`text-4xl`,children:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).formatToParts(e||0).map((e,t)=>(0,G.jsx)(Cd,{type:e.type,value:e.value},t))})}function Cd({type:e,value:t}){switch(e){case`currency`:case`decimal`:case`fraction`:return(0,G.jsx)(`sup`,{className:`font-light text-xl`,children:t});default:return t}}function wd({alreadyUsingFree:e,clusterId:t,defaultValues:n,deploymentToPerformanceToPlan:r,harperVersions:i,mode:a,organization:s,organizationId:c,partialUpgrade:u,planTypes:d,regionLocationsColocated:f,regionLocationsDedicated:p,setSavedClusterState:m,startOffOnBilling:h}){let g=ke(),v=re(),y=s?.type===rl,b=s?.channel===`Akamai`?`linode`:void 0,x=ae(),{mutate:S,isPending:C}=Zc(),{mutate:w,isPending:T}=$c(),[E,D]=(0,K.useState)(h),O=(0,K.useMemo)(()=>Jc(f?.sort(Hc(`latencyDescription`))||[],`region`,`latencyDescription`),[f]),k=(0,K.useMemo)(()=>Jc(p?.sort(Hc(`latencyDescription`))||[],`region`,`latencyDescription`),[p]),A=(0,K.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=yd(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!`}):al(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=vt({mode:`onChange`,resolver:V(Bu.superRefine(A)),defaultValues:n}),[ee,te]=(0,K.useState)(!0);(0,K.useEffect)(()=>{ee&&n&&(m(null),te(!1))},[n,ee,m]);let M=j.watch(`clusterName`),N=j.watch(`abbreviatedName`),P=j.watch(`deploymentDescription`),F=j.watch(`performanceDescription`),I=j.watch(`regionPlans`),ne=j.watch(`instances`),ie=P===`Dedicated`?k:O,oe=P===`Dedicated`?p:f;(0,K.useEffect)(function(){let e=j.getValues();P&&(P===`Self-Hosted`?(e.abbreviatedName&&j.setValue(`abbreviatedName`,``),e.regionPlans.length&&j.setValue(`regionPlans`,[]),e.instances.length||j.setValue(`instances`,[{secure:`true`,fqdn:``,port:l}])):(e.fqdn&&j.setValue(`fqdn`,``),e.instances.length&&j.setValue(`instances`,[]),e.regionPlans.length||xd(j,d,oe)))},[j,d,oe,P]);let L=(0,K.useMemo)(()=>{let e=il(ol(M),zu.maxLength);return{suggestedAbbreviatedName:e,fullHostName:`${N||e}.${s.subdomain||`your-org`}.harperfabric.com`}},[M,N,s]),se=(0,K.useMemo)(()=>r?.[P]?.[F],[r,P,F]);(0,K.useEffect)(function(){let e=se?.allowedRegionIds;if(e?.length&&I?.length===1){let t=I[0],n=ie?.[t.regionName]?.[t.latencyDescription];if(!e.includes(n?.id)){let t=oe?.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())}}},[se,I,j,ie,oe]),(0,K.useEffect)(function(){if(P!==`Self-Hosted`&&Object.keys(ie).length&&I.length)for(let e=0;e<I.length;e++){let t=I[e];ie[t.regionName]||j.setValue(`regionPlans.${e}.regionName`,``)}},[j,ie,P,I]);let ce=se?.priceUsd?P===`Self-Hosted`?ne.length*se.priceUsd:I.reduce((e,t)=>{let n=ie?.[t.regionName]?.[t.latencyDescription];return e+(n?se.priceUsd*n.instanceCount/2:0)},0):0,le=se?.planLimits?.expirationMonths,ue=sl(le)&&le<1e3?le:void 0,R=ue?ce/ue:ce,de=(0,K.useCallback)(({creating:e,deploymentDescription:t})=>H.message(e?`Creating Cluster`:`Updating Cluster`,{description:(0,G.jsx)(Yc,{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,K.useCallback)(async({clusterId:e,sourceClusterId:t,creating:n,toastId:r,isSelfManaged:i,skipGtmWait:a})=>{if(t){let e=(await tl(c)).clusters?.find(e=>e.id===t);Bo(e?.status)&&await yc(t)}x.invalidateQueries({queryKey:[c],refetchType:`active`}),n||cl(x,e,{refetchType:`active`}),v.invalidate(),g(i?{to:`/${c}/${e}/instances`}:n?{to:`/${c}/${e}/starting-up`}:{to:`/${c}/${e}/scaling`,search:a?{immediate:!0}:void 0}),j.reset(),H.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,g,c,j]),pe=(0,K.useCallback)(async()=>{let e=j.getValues(),n=[],i=r[e.deploymentDescription][e.performanceDescription],o=e.deploymentDescription===`Self-Hosted`;if(o)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=ie[t.regionName][t.latencyDescription];n.push({autoRenew:!0,planId:i.id,regionId:e.id})}m(null);let s=de({creating:!t,deploymentDescription:e.deploymentDescription}),l=()=>H.dismiss(s);t?w(a===`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:o,creating:!1,toastId:s,skipGtmWait:e.skipGtmWait}),onError:l}):S({abbreviatedName:o?void 0:e.abbreviatedName||L.suggestedAbbreviatedName,autoRenew:!0,fqdn:o&&e.fqdn||void 0,name:e.clusterName,version:e.version,organizationId:c,regionPlans:n},{onSuccess:t=>fe({clusterId:t.id,sourceClusterId:e.sourceClusterId,isSelfManaged:o,creating:!0,toastId:s}),onError:l})},[L.suggestedAbbreviatedName,t,r,j,fe,de,c,ie,m,w,S]),me=(0,K.useCallback)(()=>{if(a!==`version`&&ce>0){D(!0);return}return pe()},[a,pe,ce]),he=(0,K.useCallback)(e=>{m(e?{clusterId:t,...j.getValues(),skipToBilling:!0}:null)},[t,j,m]),ge=(0,K.useCallback)(()=>{D(!1)},[]),_e=!y&&`mr-37.5`;return(0,G.jsxs)(G.Fragment,{children:[!y&&a!==`version`&&(0,G.jsxs)(`div`,{className:`absolute top-3 right-4 md:right-12 flex flex-col items-end text-right`,children:[(0,G.jsx)(`dt`,{className:`font-light`,children:ue?`Monthly Price`:`Total Price`}),(0,G.jsx)(`dd`,{className:`font-bold`,children:ce>0?(0,G.jsxs)(`span`,{className:`inline-flex items-baseline`,children:[(0,G.jsx)(Sd,{price:R}),!!ue&&(0,G.jsxs)(`span`,{className:`font-light text-base text-muted-foreground`,children:[`/mo`,ue>1&&(0,G.jsx)(`sup`,{children:`*`})]})]}):(0,G.jsx)(`span`,{className:`text-4xl text-green`,children:`Free`})})]}),(0,G.jsx)(q,{...j,children:E?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h1`,{className:_(`text-lg leading-none text-foreground font-semibold mb-4`,_e),children:`Cluster Billing`}),(0,G.jsx)(`p`,{className:_(`text-muted-foreground text-sm mb-2`,_e),children:`Please confirm the following billing details:`}),(0,G.jsx)(Iu,{clusterId:t,isPending:C||T,onGoBackToDetails:ge,onSaveStateForBillingRedirect:he,onSubmit:pe,organizationId:c,selectedPlan:se})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h1`,{className:_(`text-lg leading-none text-foreground font-semibold mb-4`,_e),children:`Cluster Configuration`}),(0,G.jsxs)(`div`,{className:_(`mb-6 flex flex-col items-start gap-2`,_e),children:[(0,G.jsx)(`p`,{className:`sr-only`,children:`Configure your Harper cluster and define deployment plans.`}),!y&&a!==`version`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(qi,{variant:`warning`,children:`Beta pricing subject to change.`}),!!ue&&ue>1&&ce>0&&(0,G.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(ce),` `,`every`,` `,o(ue,`month`,`months`),`, or sooner if you reach a usage limit — then a new license is issued.`]})]})]}),(0,G.jsx)(`form`,{id:`cluster-upsert-form`,name:`cluster-upsert-form`,onSubmit:j.handleSubmit(me),children:(0,G.jsx)(vd,{calculatedNames:L,clusterId:t,deploymentToPerformanceToPlan:r,form:j,isPending:C||T,harperVersions:i,mode:a,partialUpgrade:u,regionLocations:oe,regionNameToLatencyToRegion:ie,selectedDeployment:P,selectedPerformance:F,selectedPlan:se,totalPrice:ce,isEnterprise:y,cloudProvider:b})})]})})]})}function Td(e){return e?.clusterName!==void 0}function Ed(e){let t=e.filter(e=>!!e&&!(e.status!=null&&Mo.includes(e.status))).map(e=>e.version).filter(e=>!!e);if(t.length<2)return null;let n=t.reduce((e,t)=>ln(t,e)>0?t:e),r=t.filter(e=>e!==n).length;return r>0?{latest:n,behindCount:r,total:t.length}:null}function Dd({isEdit:e,className:t,children:n}){return e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(Mc,{children:(0,G.jsx)(`div`,{className:t,children:n})})]}):(0,G.jsx)(jc,{className:t,children:n})}function Od(){let{organizationId:e,clusterId:t,mode:n}=I({strict:!1}),{create:r,update:i}=ac(e),{organization:a,cluster:o}=Ae({strict:!1}),[s,c]=jn(On.SavedClusterState,null),{data:l}=L(Pc(e)),{data:u}=L(Vc({availableHosts:!0,organizationId:e})),{data:d}=L(Vc({organizationId:e})),{data:f}=L(zc(e)),p=(0,K.useMemo)(()=>{if(o){let e=o.instances?.map(e=>e.version).filter(Fn);if(f&&e){let t=[...e].sort(ln).pop(),n=new Set(e);return{...f,value:[!!t&&{name:`current`,version:t},...(f?.value||[]).filter(e=>!n.has(e.version)&&(!t||sn(t,e.version)))].filter(Fn)}}}return f},[f,o]),m=(0,K.useMemo)(()=>Ed(o?.instances??[]),[o]),h=(0,K.useMemo)(()=>{for(let e of a?.clusters??[])if(e.id!==o?.id&&l&&!Vo(e.status)&&!Bo(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,K.useMemo)(()=>Jc(l?.sort(Hc(`priceUsd`))||[],`deploymentDescription`,`performanceDescription`),[l]),_=(0,K.useMemo)(()=>{if(!l||!p||!u||!d||t&&!o)return null;let e=o;if(s){if(Td(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=bd(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&&!Mo.includes(e.status)).sort(Gc);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,G.jsx)(Dd,{isEdit:!!t,children:(0,G.jsx)(Ui,{centered:!0,text:`Loading...`})}):(o?.id?!i:!r)?(0,G.jsx)(Dd,{isEdit:!!t,children:(0,G.jsx)(Si,{title:`Not Allowed`,error:{message:(0,G.jsxs)(G.Fragment,{children:[`You do not have permission to `,o?.id?`update`:`create`,` clusters in this org.`]})}})}):l.length===0?(0,G.jsx)(Dd,{isEdit:!!t,children:(0,G.jsx)(Si,{title:`Cluster ${t?`Modification`:`Creation`} Not Currently Allowed`,error:{message:(0,G.jsxs)(G.Fragment,{children:[`There are no available deployment types right now! Please try again later, or `,(0,G.jsx)(Ac,{}),`.`]})}})}):(0,G.jsx)(Dd,{isEdit:!!t,className:`max-w-4xl mx-auto`,children:(0,G.jsx)(wd,{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:Td(s)&&s.skipToBilling===!0})})}function kd({children:e}){let{organizationId:t}=I({strict:!1}),{view:n}=ic(t),{update:r}=rc(t),i=`/${t}`;return(0,G.jsx)(`div`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`md:grid gap-6 md:grid-cols-12`,children:[(0,G.jsx)(`aside`,{className:`md:col-span-3 lg:col-span-2 mb-4 md:mb-0`,children:(0,G.jsx)(Bi,{items:[{to:i,label:`Clusters`,icon:ni,exact:!0},n&&{to:`${i}/users`,label:`Users`,icon:bi},n&&{to:`${i}/roles`,label:`Roles`,icon:ii},r&&{to:`${i}/billing`,label:`Billing`,icon:pr,children:[{to:`${i}/billing`,label:`Payment Method`,exact:!0},{to:`${i}/billing/invoices`,label:`Invoices`}]},r&&{to:`${i}/settings`,label:`Settings`,icon:ri}].filter(Boolean),ariaLabel:`Organization sections`})}),(0,G.jsx)(`section`,{className:`md:col-span-9 lg:col-span-10 min-w-0`,children:e})]})})}var Ad={FAILED:0,UPDATING:1,PROVISIONING:2,RUNNING:3,TERMINATED:4},jd=Ad.RUNNING;function Md(e,t){return e.status===t.status?e.name.localeCompare(t.name):(e.status?Ad[e.status]??jd:jd)-(t.status?Ad[t.status]??jd:jd)}function Nd(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 Pd(){let{organizationId:e}=I({strict:!1}),{create:t}=ac(e),{data:n,isSuccess:r}=oe(nl(e)),[i]=jn(On.SavedClusterState,null),[a,o]=(0,K.useState)(``),s=(0,K.useCallback)(()=>o(``),[]),c=(0,K.useCallback)(e=>{o(e.currentTarget.value?.toLowerCase()||``)},[]),l=(0,K.useMemo)(()=>n?.clusters?.slice().filter(e=>!Vo(e.status)).sort(Md)||[],[n?.clusters]),u=(0,K.useMemo)(()=>l.filter(Nd([`id`,`name`],a))||[],[a,l]);return n&&l.length===0&&t?(0,G.jsx)(Od,{}):i?(0,G.jsx)(fe,{to:`/${e}/new-cluster`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{children:r&&t&&(0,G.jsx)(`div`,{className:`flex w-full justify-end`,children:(0,G.jsx)(B,{to:`new-cluster`,children:(0,G.jsxs)(P,{variant:`positive`,accessKey:`n`,children:[(0,G.jsx)(Jr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,G.jsx)(`u`,{children:`N`}),`ew `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Cluster`})]})]})})})}),(0,G.jsxs)(kd,{children:[(0,G.jsxs)(`div`,{className:`relative mb-6 w-full`,children:[(0,G.jsx)(ti,{className:`pointer-events-none absolute left-0 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.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,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-9 mb-4`,children:[u.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-3 xl:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(kc,{cluster:e})},e.id)),!u.length&&(0,G.jsxs)(`div`,{className:`col-span-1 md:col-span-9 text-center`,children:[(0,G.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:s,children:`Clear Filters`})]})]})]})]})}function Fd(){return`/#`+ro()}function Id(){let{organizationId:e}=I({strict:!1}),t=ke(),n=new URLSearchParams(window.location.search).get(`setup_intent_client_secret`),{setup_intent_client_secret:r}=le({strict:!1}),[i]=jn(On.SavedClusterState,null),a=n||r,o=ru(),s=dl(e),c=(0,K.useCallback)(()=>{let e=i?i.clusterId?`../../${i.clusterId}/edit`:`../../new-cluster`:`../`;window.history.replaceState(null,``,Fd()),t({search:void 0,to:e})},[t,i]);return(0,K.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?(H.error(`Failed to process payment method details. Please try another payment method.`),c()):s(e.payment_method,c);break;case`processing`:H.warning(`Processing payment method. Please check back later.`),c();break;case`requires_payment_method`:H.error(`Failed to process payment method details. Please try another payment method.`),c();break;default:H.error(`Failed to process payment method details. Please try another payment method.`),c();break}}catch(e){console.error(e),H.error(`Failed to process payment method details. Please try another payment method.`),c()}})()},[a,c,e,s,o]),(0,G.jsx)(Ui,{centered:!0})}function Ld(){return(0,G.jsx)(ku,{children:(0,G.jsx)(Id,{})})}function Rd(){let{organizationId:e}=I({strict:!1}),{update:t}=rc(e);return t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(kd,{children:(0,G.jsx)(Ce,{})})]}):(0,G.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 zd({columns:e,data:t,isFetching:n,onRowClick:r,onColumnClick:i,sortingState:a,children:o}){let s=_e({data:t,columns:e,getCoreRowModel:Se(),getSortedRowModel:pe(),initialState:{sorting:a}});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-end space-x-2 pb-4`,children:[(0,G.jsx)(`div`,{className:`grow lg:hidden`}),o,(0,G.jsx)(`div`,{className:`grow hidden lg:visible`})]}),(0,G.jsxs)(hn,{containerClassName:`rounded-md bg-card dark:bg-black-dark`,children:[(0,G.jsx)(vn,{children:s.getHeaderGroups().map(e=>(0,G.jsx)(fn,{className:`border-none`,children:e.headers.map(e=>(0,G.jsx)(gn,{header:e,onColumnClick:i},e.id))},e.id))}),(0,G.jsx)(_n,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:s.getRowModel().rows?.length?s.getRowModel().rows.map(e=>(0,G.jsx)(fn,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>r?.(e),className:N(`hover:bg-muted/10 data-[state=selected]:bg-muted`,r&&`cursor-pointer`),children:e.getVisibleCells().map(e=>(0,G.jsx)(pn,{className:`py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,style:{width:`${e.column.getSize()}px`},children:we(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,G.jsx)(fn,{children:(0,G.jsx)(pn,{colSpan:e.length,className:`h-24 text-center`,children:n?(0,G.jsx)(`div`,{children:(0,G.jsx)(Ui,{className:`p-12`})}):(0,G.jsx)(`span`,{children:`No results.`})})})})]})]})}function Bd(e){switch(e){case`paid`:return`success`;case`void`:case`uncollectible`:return`destructive`;default:return`default`}}function Vd(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e)}function Hd(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 Ud=[{header:`Invoice Id`,accessorKey:`id`,enableSorting:!1},{header:`Status`,accessorKey:`status`,enableSorting:!1,cell:({cell:e})=>(0,G.jsx)(qi,{variant:Bd(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?Hd(r,t):[t?Hd(r,t):`-`,n?Hd(i,n):`-`].join(` to `)}},{header:`Amount Due`,accessorKey:`amountDue`,enableSorting:!1,cell:({cell:e})=>Vd(e.getValue()?e.getValue()/100:0)},{header:`Amount Paid`,accessorKey:`amountPaid`,enableSorting:!1,cell:({cell:e})=>Vd(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} @ ${Vd(e.amount/100)}`);return n.join(`
12
- `)}}];function Wd(e){return(0,K.useCallback)(async()=>{H.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await a(500),H.success(`Refreshed!`,{id:`refreshing`})},[e])}async function Gd(e){let{data:t}=await M.get(`/Invoice/${e}`);return t}function Kd(e,t){return z({queryKey:[e,`invoices`],queryFn:()=>Gd(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function qd(){let{organizationId:e}=I({strict:!1}),{data:t}=L(nl(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(Kd(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Wd(r);return t?.type===`ENTERPRISE`?(0,G.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,G.jsx)(Ac,{}),`, we would love to talk!`]}):i?(0,G.jsx)(Ui,{centered:!0}):!n||!n.length?(0,G.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,G.jsx)(Ac,{overEmail:!0}),`, we would love to talk!`]}):(0,G.jsx)(zd,{data:n,columns:Ud,children:(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,G.jsx)(Yr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Jd(e){let t=R({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Rd}),n=R({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Fu}),r=R({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:qd}),i=R({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Ld});return t.addChildren([n,r,i])}async function Yd(e){let{data:t}=await M.get(`/OrganizationRole/${e}`);return t}function Xd(e){return z({queryKey:[e,`roles`],queryFn:()=>Yd(e),retry:!1,refetchInterval:Ln(10*1e3)})}var Zd=de(),Qd=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},Zd.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),Zd.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 $d(e){let{data:t}=await M.post(`/Role/`,e);return t}function ef(){return F({mutationFn:$d})}var tf=j({name:S().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:E(),delete:E()});j({roles:j({create:E(),delete:E(),update:E(),view:E()}),clusters:j({create:E(),delete:E(),update:E(),view:E(),resources:C(j({id:S(),delete:E(),update:E(),view:E(),instances:j({create:E(),delete:E(),update:E(),view:E()})}))})});function nf(){let[e]=Aa(),t=Da();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var rf=(0,K.lazy)(async()=>(await Me(()=>import(`./setup-DJwR0BHd.js`),__vite__mapDeps([17,4,1,18,19,20,21,22,23])),{default:(await Me(()=>import(`./dist-3T7cRma3.js`),__vite__mapDeps([20,1,4]))).default}));function af(e){return(0,G.jsx)(K.Suspense,{fallback:e.loading??null,children:(0,G.jsx)(rf,{...e})})}var of={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function sf({isModalOpen:e,setIsModalOpen:t}){let n=nf(),r=ae(),{organizationId:i}=I({strict:!1}),[a,o]=(0,K.useState)(!0),[s,c]=(0,K.useState)(JSON.stringify(of,null,2)),{mutate:l,isPending:u}=ef(),d=vt({resolver:V(tf),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,K.useCallback)(e=>{o(e.length===0)},[o]),p=(0,K.useCallback)(async e=>{let n=Dn(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{H.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{H.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,G.jsx)(Gt,{onOpenChange:t,open:e,children:(0,G.jsxs)(Xt,{resizable:!0,children:[(0,G.jsx)(en,{children:`Add New Organization Role`}),(0,G.jsx)(an,{children:`Set the new organization role permissions.`}),(0,G.jsx)(q,{...d,children:(0,G.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,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(af,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(of,null,2)})}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,G.jsx)(P,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function cf({roleId:e}){let{data:t}=await M.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function lf(){return F({mutationFn:({roleId:e})=>cf({roleId:e})})}async function uf({roleId:e,updatedRoleInfo:t}){let{data:n}=await M.put(`/Role/${e}`,t);return n}function df(){return F({mutationFn:({roleId:e,updatedRoleInfo:t})=>uf({roleId:e,updatedRoleInfo:t})})}function ff({organizationId:e,roleId:t}){return z({queryKey:[e,`roles`,t],queryFn:()=>pf(t),refetchInterval:Ln(10*1e3),retry:Pn()})}async function pf(e){let{data:t}=await M.get(`/Role/${e}`);return t}function mf({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(en,{children:`Confirm Role Deletion`}),(0,G.jsx)(an,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,G.jsxs)(Kt,{children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsx)(P,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function hf({data:e,isModalOpen:t,closeModal:n}){return(0,G.jsx)(Gt,{onOpenChange:(0,K.useCallback)(()=>n(!1),[n]),open:t,children:(0,G.jsx)(Xt,{resizable:!0,children:(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(gf,{roleName:e.roleName}),children:(0,G.jsx)(_f,{data:e,closeModal:n})})})})}function gf({roleName:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(en,{children:[`Organization Role "`,e,`"`]}),(0,G.jsx)(Ui,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function _f({data:e,closeModal:t}){let n=ae(),{data:r}=oe(ff({roleId:e.id,organizationId:e.organizationId})),i=Le().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=ic(e.organizationId),{mutate:s,isPending:c}=df(),{mutate:l,isPending:u}=lf(),d=nf(),[f,p]=(0,K.useState)(!1),m=vt({resolver:V(tf),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,K.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{H.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,K.useState)(!0),v=(0,K.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,K.useState)(v),x=y!==v,S=(0,K.useCallback)(e=>{_(e.length===0)},[_]),C=(0,K.useCallback)(async r=>{if(!a)return;let i=Dn(y);if(!i)return;let o={...r,...i,organizationId:e.organizationId};y&&g&&s({roleId:e.id,updatedRoleInfo:o},{onSuccess:async()=>{H.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,G.jsx)(mf,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(en,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,G.jsx)(q,{...m,children:(0,G.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,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.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,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.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,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(af,{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,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,G.jsx)(P,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function vf(){let e=ke(),t=ae(),{organizationId:n,orgRoleId:r}=I({strict:!1}),{create:i}=ic(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=oe(Xd(n)),l=(0,K.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,K.useState)(!1),p=(0,K.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,K.useCallback)(()=>{f(!0)},[f]),h=(0,K.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,K.useCallback)(e=>p(void 0,e),[p]),_=Wd(o);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(kd,{children:(0,G.jsxs)(K.Suspense,{fallback:(0,G.jsx)(Ui,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(zd,{data:a,columns:Qd,onRowClick:h,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,G.jsx)(Yr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,G.jsx)(sf,{isModalOpen:d,setIsModalOpen:f}),u&&(0,G.jsx)(hf,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function yf({className:e,...t}){return(0,G.jsx)(nt,{"data-slot":`switch`,className:N(`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,G.jsx)(Ge,{"data-slot":`switch-thumb`,className:N(`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 bf(e){return`//oauth/${e}/login`}async function xf(e,t){let{data:n}=await M.patch(`/Organization/${e}/settings/oauth`,t);return n}var Sf=j({domain:S().min(1,`Domain is required`),clientId:S().min(1,`Client ID is required`),clientSecret:S().min(1,`Client secret is required`),scope:S().optional()}),Cf=j({domain:S().min(1,`Domain is required`),clientId:S().optional(),clientSecret:S().optional(),scope:S().optional()});function wf(){let{organizationId:e}=I({strict:!1}),{user:t}=Le(),{update:n}=rc(e),{data:r}=oe(nl(e)),i=ae(),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=F({mutationFn:t=>xf(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>H.error(`Failed to update OAuth settings.`)}),f=vt({resolver:V(Sf),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{H.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=vt({resolver:V(Cf)}),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:()=>{H.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 Tc(e)&&H.success(`Sign-in URL copied.`)},b=async e=>{await Tc(e)&&H.success(`Redirect URI copied.`)};return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(kd,{children:(0,G.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,G.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,G.jsxs)(P,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,G.jsx)(Jr,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,G.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,G.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(Cn,{className:`size-4`})})]}),(0,G.jsx)(q,{...m,children:(0,G.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,G.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,G.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,G.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,G.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,G.jsx)(fr,{className:`size-3.5`})})]})]}),(0,G.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`a`,{href:bf(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:bf(e.id)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(bf(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,G.jsx)(fr,{className:`size-3.5`})}),(0,G.jsx)(`a`,{href:bf(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,G.jsx)(gr,{className:`size-3.5`})})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,G.jsx)(yf,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,G.jsx)(yf,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,G.jsxs)(Va,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,G.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,G.jsx)(mn,{className:`size-4`})})]})]})},e.id)}),a&&(0,G.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(Cn,{className:`size-4`})})]}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,G.jsx)(q,{...f,children:(0,G.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,G.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.`})}O.object({email:qo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:O.string().nonempty({error:`Please select a role.`})});async function Tf(e){let{data:t}=await M.post(`/UserInvite/`,e);return t}function Ef(){return F({mutationFn:e=>Tf(e)})}function Df({user:e}){let{update:t}=ic(),{mutate:n,isPending:r}=Ef(),i=e.roles?.[0]?.id,a=(0,K.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){H.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>H.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,G.jsxs)(P,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,G.jsx)(zr,{}),` Resend invite`]}):null}var Of=de(),kf=[{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},Of.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},Of.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,G.jsx)(Df,{user:e.row.original}):null})];function Af({name:e,id:t}){return(0,G.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:e}),(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var jf=O.object({email:qo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:O.string().nonempty({error:`Please select a role.`})});async function Mf(e){let{data:t}=await M.post(`/OrganizationRole/`,e);return t}function Nf(){return F({mutationFn:e=>Mf(e)})}function Pf({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=I({strict:!1}),{data:i,isLoading:a}=L({...Xd(r),throwOnError:!0}),[o,s]=(0,K.useState)(!1),c=vt({resolver:V(jf),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=Nf(),{mutate:d,isPending:f}=Ef(),p=(0,K.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),H.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,G.jsx)(Gt,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,G.jsx)(Xt,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...c,children:(0,G.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,G.jsx)(qt,{children:(0,G.jsx)(en,{children:o?`Invite User`:`Add User`})}),(0,G.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,G.jsx)(Hu,{}):(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{...e,onValueChange:t=>e.onChange(t),children:[(0,G.jsx)($t,{className:`w-full`,children:(0,G.jsx)(nn,{placeholder:`Choose Role`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Wt,{children:`Role`}),i?.map(e=>(0,G.jsx)(Yt,{value:e.id,children:(0,G.jsx)(Af,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,G.jsx)(Q,{})]})}),o&&(0,G.jsxs)(an,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,G.jsx)(Rr,{className:`inline-block size-12 pr-2`}),(0,G.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,G.jsx)(Kt,{children:(0,G.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,G.jsx)($r,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function Ff({roleId:e,userId:t}){let{data:n}=await M.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function If(){return F({mutationFn:({roleId:e,userId:t})=>Ff({roleId:e,userId:t})})}function Lf(e){let[t,n]=(0,K.useState)(e||!1);return[t,(0,K.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Rf({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Nf(),{mutate:c,isPending:l}=If(),u=!!i[r.id],[d,f]=(0,K.useState)(u),[p,m]=Lf(u);return(0,K.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,G.jsxs)(Ao,{className:`flex`,children:[(0,G.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,G.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function zf({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,K.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?Lr:vi;return r?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.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,G.jsx)(_i,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.jsx)(`span`,{children:a.warning})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(P,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,G.jsxs)(P,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,G.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,G.jsx)(`div`,{className:`flex justify-start`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,G.jsx)(o,{}),` `,a.idle]})})}function Bf(e){return e?.trim().toLowerCase()===`admin`}function Vf({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 Hf({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=I({strict:!1}),s=Le(),{update:c,remove:l}=ic(o),u=s.user?.email===t.email,[d,f]=(0,K.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=Vf({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>Bf(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=If(),[_,v]=(0,K.useState)(!1),y=(0,K.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)?H.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):H.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,G.jsx)(Gt,{onOpenChange:d?r:e,open:n,children:(0,G.jsxs)(Xt,{resizable:!0,children:[(0,G.jsx)(qt,{children:(0,G.jsxs)(en,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,G.jsxs)(an,{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,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(Ui,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,G.jsx)(Uf,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(Df,{user:t})}),m&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(zf,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,G.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,G.jsx)(_i,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.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 Uf({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=oe(Xd(t)),o=(0,K.useMemo)(()=>e.roles?qc(e.roles,`id`):{},[e]);return(0,G.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,G.jsx)(Rf,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function Wf(e,t){return e.email>t.email?1:-1}function Gf(e){return(e.users??[]).filter(e=>e!=null)}function Kf(e){let t={};for(let n of e)for(let e of Gf(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(Wf)}function qf(e){let t=new Set;for(let n of e)if(Bf(n.roleName))for(let e of Gf(n))t.add(e.id);return t.size}function Jf(){let e=ke(),{organizationId:t,orgUserId:n}=I({strict:!1}),{update:r}=ic(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=oe(Xd(t)),c=(0,K.useMemo)(()=>Kf(i),[i]),l=(0,K.useMemo)(()=>qf(i),[i]),u=(0,K.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,K.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,K.useState)(!1),[h]=(0,K.useState)({attribute:`email`,descending:!1}),g=(0,K.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,K.useCallback)(()=>{m(!0)},[m]),v=(0,K.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,K.useCallback)(e=>{d(e.original.id)},[d]),b=(0,K.useCallback)(()=>{d(void 0)},[d]),x=(0,K.useCallback)(()=>{a(),d(void 0)},[d,a]),S=Wd(a);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(kd,{children:(0,G.jsxs)(K.Suspense,{fallback:(0,G.jsx)(Ui,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(zd,{data:c,isFetching:o||s,columns:kf,onRowClick:y,sortingState:g,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,G.jsx)(Yr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,G.jsx)(Jr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,G.jsx)(Pf,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,G.jsx)(Hf,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function Yf({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`skeleton`,className:N(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function Xf({organizationId:e,organizationName:t,providers:n}){return(0,G.jsxs)(Ut,{className:`relative h-full justify-between opacity-90`,children:[(0,G.jsxs)(Bt,{children:[(0,G.jsx)(Ht,{className:`truncate`,children:e}),(0,G.jsx)(zt,{children:(0,G.jsx)(`h2`,{children:t})})]}),(0,G.jsxs)(Vt,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,G.jsx)(kr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,G.jsx)(`a`,{href:bf(e.oauthConfigId),children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var Zf=j({couponId:S().nonempty({message:`Please enter a coupon ID.`}).trim()});async function Qf({organizationId:e,couponId:t}){let{data:n}=await M.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function $f(){return F({mutationFn:Qf})}function ep({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=$f(),o=vt({resolver:V(Zf),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,K.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,K.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?H.error(`Error`,{description:i||`Failed to add coupon.`}):(H.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,G.jsx)(Gt,{open:n,onOpenChange:e=>!e&&r(),children:(0,G.jsxs)(Xt,{children:[(0,G.jsxs)(qt,{children:[(0,G.jsx)(en,{children:`Add Coupon`}),(0,G.jsxs)(an,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,G.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,G.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,G.jsx)(q,{...o,children:(0,G.jsxs)(`form`,{onSubmit:s(u),children:[(0,G.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,G.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,G.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,G.jsx)(Z,{children:`Coupon ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,G.jsx)(Q,{})]})})}),(0,G.jsxs)(Kt,{children:[(0,G.jsx)(P,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,G.jsx)(P,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function tp({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=rc(n),s=o,{view:c}=ic(n),l=Be(),[u,d]=(0,K.useState)(!1),f=(0,K.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,G.jsx)(ni,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,G.jsx)(ii,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,G.jsx)(bi,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,G.jsx)(pr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,G.jsx)(kr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,G.jsx)(mi,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},{type:`separator`,key:`sep-bottom`},{key:`delete`,onClick:f,className:`focus:bg-red/70 focus:text-white`,icon:(0,G.jsx)(hi,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(Fn);return(0,G.jsx)(tc,{items:a?p:[],children:(0,G.jsxs)(Ut,{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,G.jsx)(B,{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,G.jsxs)(Bt,{children:[(0,G.jsxs)(Ht,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{"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,G.jsx)(hr,{})}),(0,G.jsx)(Di,{children:ec(p,`dropdown`)})]})]}),(0,G.jsx)(zt,{children:(0,G.jsx)(`h2`,{children:r})})]}),(0,G.jsxs)(Vt,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(qi,{className:`min-w-0 shrink`,title:wo(i),children:(0,G.jsx)(`span`,{className:`truncate`,children:wo(i)})}),(0,G.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,G.jsx)(Gn,{className:`inline-block`})]})]}),(0,G.jsx)(ep,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function np(e){let{data:t}=await M.delete(`/Organization/${e}`);return t}function rp(){return F({mutationFn:e=>np(e)})}async function ip(e){let{data:t}=await M.post(`/Organization/`,{...e});return t}function ap(){return F({mutationFn:e=>ip(e)})}var op=S().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.`}),sp=j({name:S().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:ee([D(``),k(),op]).optional()});function cp(){let{user:e}=Le(),t=ke(),n=vt({resolver:V(sp),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,K.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,K.useMemo)(()=>{let e=il(ol(o),op.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=ap(),f=ae(),p=(0,K.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{f.invalidateQueries({queryKey:m,refetchType:`active`}),u.reloadUser(h),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,f,l,a,t]);return(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(p),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,G.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:sp.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:op.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)(`span`,{children:c.fullHostName})}),(0,G.jsx)(Q,{})]}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,G.jsx)(Gn,{})]})})]})})})}function lp(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,G.jsx)(cp,{})})]})}var up={org:`organization`,clu:`cluster`,ins:`instance`},dp=/^(org|clu|ins)-[a-z0-9]+$/;function fp(e){if(typeof e!=`string`)return null;let t=e.trim(),n=dp.exec(t);return n?{kind:up[n[1]],id:t}:null}function pp(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 mp(e,t){let{data:n}=await M.get(pp(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var hp={organizations:[],hasNextPage:!1};function gp(e){return e instanceof v&&(e.response?.status===404||e.status===404)}async function _p(e){try{let{data:t}=await M.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:hp}catch(e){if(gp(e))return hp;throw e}}async function vp(e){try{let{data:t}=await M.get(`/Cluster/${e}`),n=t?.organizationId;return n?await _p(n):hp}catch(e){if(gp(e))return hp;throw e}}function yp(e,t){let n=fp(t);return z({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?_p(n.id):n?.kind===`cluster`?vp(n.id):mp(e,t),placeholderData:ue,retry:!1})}function bp(e,t=300,n){let[r,i]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[n?n(e):e,t]),r}function xp(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 Sp(e,t){let[n,r]=(0,K.useState)(t),[i,a]=(0,K.useState)(e);return(0,K.useEffect)(()=>{xp(n,t)||(r(t),a(e))},[n,t,e]),xp(n,t)?[i,a]:[e,a]}var Cp={};function wp(e,t,n){let r=(0,K.useCallback)((e,n)=>t(e,n),[n]);(0,K.useEffect)(()=>(Cp[e]||(Cp[e]=[]),Cp[e].push(r),function(){let t=Cp[e].indexOf(r);t>=0&&Cp[e].splice(t,1)}),[e,t,r])}function Tp(e,t,n){let r=Cp[e];if(r)for(let e of r)e(t,n)}function Ep(e,t,n){return r=>Tp(e,t,n??r)}function Dp(e,t,n){return(0,K.useCallback)(r=>Tp(e,t,n??r),[e,t,n])}function Op(e,t){return Dn(sessionStorage.getItem(String(e)))??t}function kp(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function Ap(e,t){let n=Sp(Op(e,t),[e]),[r,i]=n;return(0,K.useEffect)(()=>{kp(e,r),Tp(`Session:${e}`,r)},[e,r]),wp(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,K.useEffect)(function(){let n=n=>{n.key===e&&i(Op(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function jp(){let e=ae(),{data:t}=oe(c()),{mutate:n,isPending:r}=rp(),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),[l,u]=(0,K.useState)(``),d=(0,K.useCallback)(()=>u(``),[]),f=Be(),[p,m]=Ap(`ShowAllOrganizations`,!1),[h,g]=(0,K.useState)(0),_=f&&p,v=(0,K.useCallback)(e=>{m(e),g(0)},[m]),y=bp(l,300),b=(0,K.useMemo)(()=>{if(!f)return null;let e=fp(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=L({...yp(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,K.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 admin`});return{organizationRoles:n.filter(Nd([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,K.useMemo)(()=>{let e=t?.roles||{};return(S?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric admin`}))},[S?.organizations,t?.roles]),D=x?E:w,O=(0,K.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,K.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{H.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,K.useCallback)(e=>{s(e),a(!0)},[]),{createCluster:j}=le({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,G.jsx)(fe,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,G.jsx)(lp,{}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{children:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,G.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,G.jsx)(yf,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,G.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,G.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,G.jsx)(B,{to:`/new-org`,children:(0,G.jsxs)(P,{variant:`positive`,accessKey:`n`,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,G.jsx)(`u`,{children:`N`}),`ew `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,G.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(Xf,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,G.jsx)(Yf,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(tp,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,G.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,G.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,G.jsx)(P,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,G.jsx)(on,{}),`Previous`]}),(0,G.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,G.jsx)(Gn,{})]})]})]}),o&&(0,G.jsx)(Gs,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var Mp=R({getParentRoute:()=>uo,id:`_orgsLayout`});R({getParentRoute:()=>Mp,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:jp}),R({getParentRoute:()=>Mp,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:lp});var Np=R({getParentRoute:()=>Mp,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!el(t))throw ve({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(nl(t))}}});R({getParentRoute:()=>Np,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:vf}),R({getParentRoute:()=>Np,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:vf}),R({getParentRoute:()=>Np,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Jf}),R({getParentRoute:()=>Np,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Jf}),R({getParentRoute:()=>Np,path:`/settings`,component:wf}),Jd(Np);var Pp=R({getParentRoute:()=>Np,id:`_clusterLayout`});R({getParentRoute:()=>Pp,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:Pd}),R({getParentRoute:()=>Np,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Od}),R({getParentRoute:()=>Ip,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Od}),R({getParentRoute:()=>Ip,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Od});function Fp(){return(0,G.jsx)(Ce,{})}var Ip=R({getParentRoute:()=>Pp,path:`$clusterId`,component:Fp,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(Ko(t.clusterId))})});function Lp({cluster:e}){let t=re(),n=ae(),{update:r,remove:i}=ac(e.organizationId,e.id),{run:a,isPending:o}=wc(e),{mutate:s,isPending:c}=bc(),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,K.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),H.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,K.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 fc(e)||!r&&!i?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,G.jsx)(Sn,{className:`size-4 transition-transform`})]})}),(0,G.jsxs)(Di,{align:`end`,className:`w-56`,children:[(0,G.jsx)(Ai,{className:`text-gray-600 text-xs`,children:`Container`}),(0,G.jsxs)(Oi,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,G.jsx)(qr,{}),` Start`]}),(0,G.jsxs)(Oi,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,G.jsx)(Mr,{}),` Start in safe mode`]}),(0,G.jsxs)(Oi,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,G.jsx)(Qr,{}),` Restart`]}),(0,G.jsxs)(Oi,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,G.jsx)(Mr,{}),` Restart in safe mode`]}),(0,G.jsxs)(Oi,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,G.jsx)(ci,{}),` Stop`]}),(0,G.jsx)(ji,{}),(0,G.jsxs)(Oi,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,G.jsx)(gi,{}),` Terminate`]})]})]}),(0,G.jsx)(hc,{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,G.jsx)(vc,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,G.jsx)(Gs,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function Rp(){let{clusterId:e}=I({strict:!1}),t=re(),n=ke(),{data:r}=L(Ko(e,!0)),{user:i,isLoading:a}=Ie(e),{view:o,update:c}=ac(r?.organizationId,r?.id),[l,f]=(0,K.useState)(!1),p=r?.domains?.[0]?.domain||r?.fqdn||``,[m,h]=Dc(p,p?`https://${p}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,K.useCallback)(async()=>{if(r){f(!0);try{await u.establishFabricConnectAuth({id:r.id,operationsUrl:s(r)}),await t.invalidate()}catch{H.error(`Could not connect to this cluster through Fabric Connect.`)}finally{f(!1)}}},[r,t]),y=(0,K.useCallback)(()=>{r&&(u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,K.useCallback)(async()=>{if(r){try{await d({instanceClient:g({id:r.id}),entityId:r.id})}catch{}u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1),u.flagForBasicAuth(r.id,null),await t.invalidate()}},[r,t]);if(!r)return(0,G.jsx)(Bp,{children:(0,G.jsx)(Vp,{})});if(!o)return(0,G.jsx)(fe,{to:`/${r.organizationId}`,replace:!0});if(fc(r))return(0,G.jsx)(zp,{cluster:r});if(!r.fqdn)return(0,G.jsx)(fe,{to:`${_}/instances`,replace:!0});if(r.resetPassword)return c?(0,G.jsx)(fe,{to:`${_}/${r.status&&jo.includes(r.status)&&Wo(r)?`finish-setup`:`starting-up`}`,replace:!0}):(0,G.jsx)(Bp,{children:(0,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)(ni,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,G.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,G.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 x=u.checkForFabricConnect(r.id),S=!!i,C=u.getLastConnectMode(r.id),w=(r.instances??[]).filter(e=>e.status&&!Mo.includes(e.status)).length,T=r.instances??[],E=!!r.status&&jo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,G.jsxs)(Bp,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)(ni,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,G.jsx)(Hp,{status:r.status}),E&&(0,G.jsx)(Up,{})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,G.jsxs)(`a`,{href:`https://${p}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[p,(0,G.jsx)(gr,{className:`size-3`})]}),(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,G.jsx)(fr,{className:`size-3.5`})}),(0,G.jsxs)(Di,{align:`start`,children:[(0,G.jsx)(Oi,{onClick:m,children:`Copy host name`}),(0,G.jsx)(Oi,{onClick:h,children:`Copy API URL`})]})]})]})]}),(0,G.jsx)(Lp,{cluster:r})]}),a?(0,G.jsx)(Vp,{}):S?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(rr,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,G.jsxs)(B,{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,G.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,G.jsx)(Xr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Gn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,G.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[c&&!fc(r)&&(0,G.jsx)(Wp,{icon:xi,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,G.jsx)(P,{className:`w-full`,disabled:l,onClick:()=>void v(),children:l?(0,G.jsx)(Pr,{className:`animate-spin`}):`Fabric Connect`})}),(0,G.jsx)(Wp,{icon:kr,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]})]})}function zp({cluster:e}){let t=re(),n=ke(),r=`/${e.organizationId}/${e.id}`,i=(0,K.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Mo.includes(e.status)).sort(Gc),[e.instances]),a=i.at(0),{user:o,isLoading:s}=Ie(a?.id),c=!!a&&!!o,l=(0,K.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),f=(0,K.useCallback)(async()=>{if(a){try{await d({instanceClient:g({id:a.id,operationsUrl:p(a)}),entityId:a.id})}catch{}u.setUserForEntity(a,null),u.flagForBasicAuth(a.id,null),await t.invalidate()}},[a,t]);return(0,G.jsxs)(Bp,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)(ni,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,G.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,G.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,G.jsxs)(B,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?s?(0,G.jsx)(Vp,{}):c?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(rr,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,G.jsxs)(B,{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,G.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,G.jsx)(Xr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Gn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>void f(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,G.jsx)(Wp,{icon:kr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:l,children:`Direct sign-in`})})})]}):(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,G.jsx)(B,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function Bp({children:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(Mc,{children:(0,G.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function Vp(){return(0,G.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,G.jsx)(Pr,{className:`size-6 animate-spin`})})}function Hp({status:e}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${e&&jo.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`}`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function Up(){return(0,G.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,G.jsx)(Mr,{className:`size-3`}),`Safe mode`]})}function Wp({icon:e,title:t,description:n,pill:r,children:i}){return(0,G.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,G.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,G.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,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,G.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,G.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function Gp({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(Mc,{children:(0,G.jsx)(`div`,{className:t,children:e})})]})}var Kp=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function qp(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&&Kp.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Jp({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=qp(t),[i,a,o]=Dc(r,e||``,n);return(0,G.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]})}),(0,G.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 Yp({certificate:e,domain:t,cluster:n}){let r=qp(t.domain),[i,a,o]=Dc(r,n.fqdn||``,t.id),s=(0,K.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,G.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,G.jsxs)(`div`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,G.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,G.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,G.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,G.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]}),(0,G.jsx)(Xp,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]})]}),(0,G.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,G.jsx)(fr,{className:`w-2.5 h-2.5`})})]})})]})]})}function Xp(){return(0,G.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,G.jsx)(`path`,{d:`M5 12h14`}),(0,G.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Zp(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:()=>Qp(e)})}async function Qp({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 $p(e){return z({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Qp({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:g({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:Ln(5e3),retry:Pn()})}function em(e){return L($p(e))}function tm({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=qp(n),[o,s,c,l,u]=Dc(t,e,a,i||``,r);return(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]})}),(0,G.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 nm({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await M.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function rm(){return F({mutationFn:e=>nm(e)})}O.object({domainId:O.string()});async function im(e){let{data:t}=await M.delete(`/Domain/${e.domainId}`);return t}function am(){return F({mutationFn:e=>im(e)})}function om(e){return[...new Set(e)]}var sm=de();function cm(e,t,n){let{data:r}=em(e.id),i=(0,K.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=rm(),{mutate:s,isPending:c}=am(),l=o||c,u=(0,K.useCallback)((t,n)=>{if(!zo(e.status)){H.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:om((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,K.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),H.success(`Domain removed!`)}})},[s]),f=(0,K.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain unbound!`)}})},[s]);return(0,K.useMemo)(()=>[sm.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!fc(e)?(0,G.jsx)(`label`,{className:`p-10 -m-10`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),sm.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:t.domain}),(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,G.jsx)(Va,{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!`})]})}}),sm.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,G.jsx)(`div`,{className:`py-2`,children:(0,G.jsx)(Yp,{certificate:i,domain:n,cluster:e})}),(0,G.jsx)(P,{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,G.jsx)(tm,{domain:n,cluster:e}):fc(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,G.jsx)(Jp,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var lm=O.object({domain:O.string(),organizationId:O.string()});async function um(e){let{data:t}=await M.post(`/Domain/`,e);return t}function dm(){return F({mutationFn:e=>um(e)})}async function fm(e){let{data:t}=await M.post(`/Domain/${e}/validate`);return t}async function pm(e){let{data:t}=await M.get(`/Domain/?organizationId=${e}`);return t}function mm(e){return z({queryKey:[e,`domains`],queryFn:()=>pm(e)})}function hm(){let{organizationId:e,clusterId:t}=I({strict:!1}),{data:n}=oe(Ko(t,!0)),{update:r}=ic(e),{data:i,refetch:a,isFetching:s,isRefetching:c}=L(mm(e)),l=(0,K.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[u]=(0,K.useState)({attribute:`domain`,descending:!1}),d=(0,K.useMemo)(()=>[{desc:u.descending,id:u.attribute}],[u]),f=Wd(a),[p,m]=(0,K.useState)([]),h=(0,K.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=rm(),v=(0,K.useCallback)(()=>{if(!zo(n.status)){H.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:om((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),H.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,g]),{mutateAsync:y,isPending:b}=dm(),x=vt({resolver:V(lm),defaultValues:{domain:``,organizationId:e}}),S=(0,K.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 a(),H.success(`${o(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),C=(0,K.useCallback)(async()=>{let e=`Validating ${o(l.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of l)try{H.loading(e,{description:`${n++} of ${l.length} checked`,id:t}),await fm(i.id)}catch{r+=1}r>0?H.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),H.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[l]),w=cm(n,p,h),T=x.watch(`domain`),E=(0,K.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,K.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,G.jsx)(zd,{data:i||[],isFetching:s||c,columns:w,sortingState:d,children:(0,G.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,G.jsx)(q,{...x,children:(0,G.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,G.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,G.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,G.jsx)(P,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,G.jsx)(Q,{children:(0,G.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,G.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:b,children:[(0,G.jsx)(Jr,{}),` Add`]}),l.length>0&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,G.jsx)(Nr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,G.jsx)(Yr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,G.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,G.jsxs)(P,{variant:`submit`,onClick:v,disabled:_,children:[(0,G.jsx)($r,{}),` Bind `,o(p.length,`Domain`,`Domains`)]})})]})})}function gm(){return(0,G.jsx)(Gp,{className:`flex flex-col justify-start max-w-4xl`,children:(0,G.jsx)(hm,{})})}var _m=j({username:Yo,role:S().nonempty({error:`Please select a role.`}),password:Jo.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:S()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function vm(e){await M.patch(`/ResetPasswordUpdater/${e}`)}async function ym(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function bm(){return F({mutationFn:ym})}async function xm({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 Sm(){return F({mutationFn:xm})}async function Cm({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function wm(){return F({mutationFn:Cm})}async function Tm({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 Po({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await xm({username:n,password:r,instanceClient:o}):(await ym({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Po({username:n,password:r,instanceClient:o,entityId:e}),await Cm({username:f,instanceClient:o})),await vm(e),a}catch(t){throw await d({entityId:e,instanceClient:o}),t}}function Em(){return F({mutationFn:Tm})}function Dm(){let{user:e}=Le(),{clusterId:t}=I({strict:!1}),{data:n}=L(Ko(t,!0)),r=ke(),i=(0,K.useMemo)(()=>s(n),[n]),a=Mn({operationsUrl:i}),{redirect:o}=le({strict:!1}),c=re(),l=vt({resolver:V(_m),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:p,handleSubmit:m}=l;(0,K.useEffect)(()=>{d(`password`)},[d]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,g=Wo(n),{mutate:_,isPending:v}=Em(),y=(0,K.useCallback)(async e=>{if(!i){H.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!g){H.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}_({instanceClient:a,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:f,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{H.success(e),u.setUserForEntity(n,t),c.invalidate(),await r({to:o?.startsWith(`/`)?o:`../`})}})},[n,t,a,g,r,i,o,c,_,h]);return n&&!n.resetPassword?(0,G.jsx)(fe,{to:`../sign-in`,replace:!0}):n&&!g?(0,G.jsx)(fe,{to:`../starting-up`,replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Eo,{})}),(0,G.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,G.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,G.jsx)(q,{...l,children:(0,G.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(y),className:`my-4`,children:[(0,G.jsx)(Y,{control:p,name:`username`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Username`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,G.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,G.jsx)(Un,{size:36,className:`flex-none`}),(0,G.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 Om({columns:e,data:t,renderRowWrapper:n}){let r=_e({data:t,columns:e,getCoreRowModel:Se()});return(0,G.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,G.jsxs)(hn,{children:[(0,G.jsx)(vn,{children:r.getHeaderGroups().map(e=>(0,G.jsx)(fn,{className:`border-none`,children:e.headers.map(e=>(0,G.jsx)(dn,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:we(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(_n,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,G.jsx)(fn,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,G.jsx)(pn,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:we(e.column.columnDef.cell,e.getContext())},e.id))});return(0,G.jsx)(K.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,G.jsx)(fn,{children:(0,G.jsx)(pn,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function km(){return(0,G.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,G.jsx)(`p`,{children:`No instances found.`})})}async function Am({instance:e,instanceClient:t}){try{await d({instanceClient:t,entityId:e.id})}catch{}u.signOutLocally(e.id),e.clusterId&&u.signOutLocally(e.clusterId)}async function jm({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await M.post(`/HDBInstance/${e}/container/${t}`,r);return i}function Mm(){return F({mutationFn:jm})}var Nm={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function Pm(e){let{clusterId:t}=I({strict:!1}),{mutateAsync:n,isPending:r}=Mm(),i=ae();return{run:(0,K.useCallback)(async(r,a)=>{let o=a?.label??Nm[r],s=e.name??e.id,c=H.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),H.dismiss(c),H.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}catch{H.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function Fm({entityId:e,instanceClient:t},n){return z({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:Ln(1e4),retry:Pn(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function Im(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function Lm({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function Rm(){return F({mutationFn:Lm,onSuccess:(e,t)=>Tn.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var zm=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function Bm(e,t,n){let{user:r}=Ie(e.id),i=(0,K.useMemo)(()=>p(e),[e]),a=Mn({operationsUrl:i}),{update:o}=sc(),s=u.checkForFabricConnect(e.id),c=W({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:l}=L(Fm(c,n&&o&&!Ro(e.status))),d=Im(l,`availability`)||`Unknown`,f=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=Rm(),{run:_,isPending:v}=Pm(e),[y,b]=(0,K.useState)(null),x=e.instanceFqdn,S=yd({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=Dc(x??``,S),T=(0,K.useCallback)(async()=>{await Am({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&zm.includes(e.status),D=!!r&&!s,O=E,k=!!x,A=o&&E&&(f||m),j=e.status===`RUNNING`,ee=e.status===`STOPPED`,te=o&&!t&&(j||ee),M=[O&&D&&{key:`direct-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)(ni,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,G.jsx)(Lr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)(ni,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,G.jsx)(Fr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,G.jsx)(sr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,G.jsx)(sr,{}),label:`Copy API URL`},(O||k)&&A&&{type:`separator`,key:`rotation-sep`},A&&f&&{key:`out-of-rotation`,variant:`destructive`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Unavailable`}),icon:(0,G.jsx)(ai,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,G.jsx)(ii,{}),label:`Bring back into rotation`},(O||k||A)&&te&&{type:`separator`,key:`container-sep`},te&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},te&&ee&&{key:`container-start`,disabled:v,onClick:()=>void _(`start`,{safeMode:!1}),icon:(0,G.jsx)(qr,{}),label:`Start`},te&&ee&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,G.jsx)(Mr,{}),label:`Start in safe mode`},te&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,G.jsx)(Qr,{}),label:`Restart`},te&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,G.jsx)(Mr,{}),label:`Restart in safe mode`},te&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,G.jsx)(ci,{}),label:`Stop`}].filter(Fn),N=(0,G.jsx)(vc,{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 M.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...M],dialog:N}:{items:[],dialog:N}}function Vm({instance:e,isSelfManaged:t}){let[n,r]=(0,K.useState)(!1),{items:i,dialog:a}=Bm(e,t,n);return i.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ti,{open:n,onOpenChange:r,children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,G.jsx)(hr,{})})}),(0,G.jsx)(Di,{align:`end`,className:`min-w-48`,children:ec(i,`dropdown`)})]}),a]}):null}function Hm({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Ie(t.id),i=Mn({operationsUrl:(0,K.useMemo)(()=>p(t),[t])}),{update:a}=sc(),o=u.checkForFabricConnect(t.id),s=(0,K.useCallback)(async()=>{await Am({instance:t,instanceClient:i})},[t,i]);return Ro(t.status)?(0,G.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,G.jsx)(Pr,{className:`animate-spin`,color:`gray`}):!n||o?(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,G.jsx)(B,{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,G.jsx)(P,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,G.jsx)(P,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:s,children:`Direct Sign Out`})]})}function Um({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,K.useState)(!1),{items:a,dialog:o}=Bm(e,t,r);return a.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ks,{onOpenChange:i,children:[(0,G.jsx)(qs,{asChild:!0,children:n}),(0,G.jsx)(Js,{className:`min-w-48`,children:ec(a,`context`)})]}),o]}):(0,G.jsx)(G.Fragment,{children:n})}function Wm({instance:e,index:t}){let{update:n}=sc(),r=W({operationsUrl:(0,K.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=Rm(),[o,s]=(0,K.useState)(!1);(0,K.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let c=Ro(e.status),{data:l,isLoading:u,isFetching:d}=L(Fm(r,o&&n&&!c)),f=Im(l,`availability`)||`Unknown`,m=f===`Available`,h=f===`Unavailable`;return n?c?(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,G.jsx)(Va,{children:`Not running`})]})}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,G.jsx)(Pr,{className:`animate-spin size-5 text-muted-foreground`}):(0,G.jsx)(qi,{variant:m?`success`:h?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,G.jsx)(`span`,{className:`sr-only`,children:m?`Online`:`Offline`})})})}),(0,G.jsxs)(Va,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[m&&(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,G.jsx)(Pr,{className:`animate-spin size-4`}):(0,G.jsx)(ai,{className:`size-4`})})}),(0,G.jsx)(Va,{children:`Bring out of rotation`})]}),h&&(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,G.jsx)(Pr,{className:`animate-spin size-4`}):(0,G.jsx)(ii,{className:`size-4`})})}),(0,G.jsx)(Va,{children:`Bring back into rotation`})]})]})]}):null}function Gm(){let{clusterId:e}=I({strict:!1}),{data:t,isLoading:n}=L(Ko(e,!0)),r=fc(t),i=(0,K.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,G.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,G.jsx)(Hm,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>yd({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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Wm,{instance:e.row.original,index:e.row.index}),t?(0,G.jsx)(qi,{variant:Lo(t),children:wo(t)}):null,e.row.original.safeMode&&!Ro(e.row.original.status)?(0,G.jsxs)(qi,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,G.jsx)(Mr,{}),`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,G.jsxs)(G.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,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(Vm,{isSelfManaged:r,instance:e.row.original})})}].filter(Fn),[r]),a=(0,K.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Mo.includes(e.status)).sort(Gc):[],[t]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(Mc,{children:(0,G.jsx)(Ut,{className:`p-0 min-h-96`,children:(0,G.jsx)(Vt,{className:`p-0 min-h-96`,children:n?(0,G.jsx)(Hu,{}):a.length?(0,G.jsx)(Om,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,G.jsx)(Um,{instance:e,isSelfManaged:r,children:t})}):(0,G.jsx)(km,{})})})})]})}function Km(){let{clusterId:e}=I({strict:!1}),{immediate:t}=le({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=L(Ko(e,2e3)),a=r?.status,o=(0,K.useMemo)(()=>a&&jo.includes(a),[a]);return i||!r?(0,G.jsx)(Gp,{className:`flex justify-center`,children:(0,G.jsx)(Hu,{})}):o?(0,G.jsx)(Gp,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,G.jsx)(_c,{cluster:r,forceProgressBarVisible:!0}),(0,G.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(pc,{cluster:r})})]})}):(0,G.jsx)(Gp,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(_c,{cluster:r,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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 qm({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(`div`,{className:_(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function Jm(){let e=re(),{clusterId:t}=I({strict:!1}),{data:n,isLoading:r}=L(Ko(t,2e3)),i=n?.status,a=(0,K.useMemo)(()=>i&&jo.includes(i)&&Wo(n),[i,n]),o=Bo(i),[,s]=jn(On.SavedClusterState,null),c=(0,K.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsx)(Hu,{})}):o?(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,G.jsx)(cr,{className:`w-24 h-24`}),(0,G.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,G.jsx)(Ac,{}),` if you want more help.`]}),(0,G.jsx)(P,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,G.jsx)(_c,{cluster:n,forceProgressBarVisible:!0}),(0,G.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,G.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,G.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,G.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(pc,{cluster:n})})]})}):(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(_c,{cluster:n,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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.`]})]})]})})}R({getParentRoute:()=>Ip,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:Gm}),R({getParentRoute:()=>Ip,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:Jm}),R({getParentRoute:()=>Ip,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:Km}),R({getParentRoute:()=>Ip,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:gm});function Ym({location:e,params:t}){let n=u.checkForFabricConnect(t.clusterId);if(u.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw ve({to:t?.startsWith(`/`)?t:`../`})}}function Xm({location:e,params:t}){let n=u.checkForFabricConnect(t.instanceId);if(u.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw ve({to:t?.startsWith(`/`)?t:`../`})}}R({getParentRoute:()=>Ip,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:ns,beforeLoad:Ym}),R({getParentRoute:()=>Ip,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:ns,beforeLoad:Xm}),R({getParentRoute:()=>Ip,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:Dm}),R({getParentRoute:()=>Ip,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:Rp});function Zm(e){return R({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>Me(()=>import(`./index.lazy-BTo0y6UM.js`).then(e=>e.route),__vite__mapDeps([24,1,2,3,4,5,6,7,25,11,26,27,28,29])))}function Qm(e,t){return[R({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:be(()=>Me(()=>import(`./applications-BDfH8urd.js`),__vite__mapDeps([30,1,27,3,2,4,5,6,7,31,8,11,10,12,13,14,25,15,32,33,26,34,35,18,19,16,28,23,36])),`ApplicationsEditor`)})]}async function $m({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function eh(e){return z({queryKey:[e.entityId,`list_certificates`],queryFn:()=>$m(e)})}var th=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},de().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 nh({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`add_certificate`,...t});return n}var rh=j({name:S().min(1,`Name is required`),certificate:S().min(1,`Certificate is required`),private_key:S().optional(),is_authority:E().default(!1),hosts:S().optional(),uses:S().optional()});function ih(){return F({mutationFn:({instanceParams:e,certificateParams:t})=>nh(e,t)})}function ah({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=vt({resolver:V(rh),defaultValues:{name:``,certificate:``,private_key:``,is_authority:!1,hosts:``,uses:``}}),i=W(),{mutate:a,isPending:o}=ih(),s=(0,K.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(),H.success(`Certificate added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,K.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,G.jsx)(Gt,{onOpenChange:n,open:e,children:(0,G.jsx)(Xt,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...r,children:(0,G.jsxs)(`form`,{id:`instance-add-certificate-form`,name:`instance-add-certificate-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsx)(en,{children:`Add New Certificate`}),(0,G.jsx)(an,{children:`Enter the details of your Certificate below.`})]}),(0,G.jsx)(Y,{control:r.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`is_authority`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex flex-row items-center justify-between rounded-lg border border-gray-800 p-3 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`space-y-0.5`,children:(0,G.jsx)(Z,{children:`Is Authority`})}),(0,G.jsx)(J,{children:(0,G.jsx)(yf,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,G.jsx)(Y,{control:r.control,name:`certificate`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Certificate`}),(0,G.jsx)(J,{children:(0,G.jsx)(yn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`hosts`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Hosts (optional)`}),(0,G.jsx)(Ju,{children:`Comma-separated list of hostnames this certificate is valid for.`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. example.com, *.example.com`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`uses`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Uses (optional)`}),(0,G.jsx)(Ju,{children:`Comma-separated list of intended uses, e.g. "https, operations, wss".`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. https, operations, wss`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`private_key`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Private Key (optional)`}),(0,G.jsx)(Ju,{children:`PEM formatted private key string.`}),(0,G.jsx)(J,{children:(0,G.jsx)(yn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:o||!r.formState.isDirty||!r.formState.isValid,children:[(0,G.jsx)($r,{}),` Add Certificate`]})]})})]})})})})}async function oh({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`remove_certificate`,name:t});return n}function sh(){return F({mutationFn:({instanceParams:e,name:t})=>oh(e,t)})}function ch({data:e,isModalOpen:t,closeModal:n,onSelectCertificate:r,onChangesSaved:i}){let{name:a}=e,o=W(),{mutate:s,isPending:c}=sh(),[l,u]=(0,K.useState)(!1),d=(0,K.useCallback)(()=>{u(!0)},[]),f=(0,K.useCallback)(()=>{s({instanceParams:o,name:a},{onSuccess:()=>{H.success(`Certificate removed successfully!`),r(void 0),i()}})},[a,s,o,i,r]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Gt,{onOpenChange:n,open:t,children:(0,G.jsx)(Xt,{className:`sm:max-w-[800px] max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:(0,G.jsxs)(`div`,{className:`grid gap-4 my-4`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsxs)(en,{children:[`View Certificate: `,a]}),(0,G.jsx)(an,{children:`Details of the selected certificate.`})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm bg-muted p-4 rounded-lg border border-border`,children:[(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Issuer`}),(0,G.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.issuer||`N/A`})]}),(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Subject`}),(0,G.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject||`N/A`})]}),e.details.subject_alt_name&&(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Subject Alternative Name`}),(0,G.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject_alt_name})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Valid From`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_from?new Date(e.details.valid_from).toLocaleString():`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Valid To (Expires At)`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_to?new Date(e.details.valid_to).toLocaleString():`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Serial Number`}),(0,G.jsx)(`p`,{className:`text-muted-foreground font-mono text-xs break-all`,children:e.details.serial_number||`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Private Key Name`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.private_key_name||`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Is Authority`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_authority?`Yes`:`No`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Is Self-Signed`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_self_signed?`Yes`:`No`})]}),e.hosts&&e.hosts.length>0&&(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Hosts`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.hosts.join(`, `)})]}),(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Uses`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.uses?.join(`, `)||`N/A`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Ao,{children:`Certificate Content`}),(0,G.jsx)(yn,{autoComplete:`off`,autoCapitalize:`off`,rows:8,readOnly:!0,className:`font-mono text-xs`,value:e.certificate})]})]}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:d,disabled:c,children:`Remove Certificate`}),(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>n(),children:`Close`})]})})]})})}),(0,G.jsx)(Gs,{isModalOpen:l,setIsModalOpen:u,deletionConfirmed:f,deletionPending:c,typeOfThingBeingDeleted:`certificate`,presentParticiple:`Removing`,transitiveVerb:`Remove`,nameOfThingBeingDeleted:a,hideDataLossWarning:!0})]})}function lh(){let e=ke(),{certName:t}=I({strict:!1}),{data:n,refetch:r,isFetching:i,isRefetching:a}=L(eh(W())),o=(0,K.useMemo)(()=>n?.find(e=>e.name===t),[n,t]),s=(0,K.useCallback)(n=>{let r=n?.original?.name,i=[t?`..`:``,r].filter(Boolean);e({to:i.join(`/`)})},[t,e]),c=!!t&&!!o,[l,u]=(0,K.useState)(!1),d=(0,K.useCallback)(()=>{u(!0)},[u]),f=Wd(r);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(zd,{columns:th,data:n||[],isFetching:i,onRowClick:s,children:[(0,G.jsx)(B,{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,G.jsxs)(P,{variant:`defaultOutline`,onClick:f,accessKey:`r`,disabled:i||a,children:[(0,G.jsx)(Yr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:d,accessKey:`a`,disabled:l,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),l&&(0,G.jsx)(ah,{isModalOpen:l,onChangesSaved:r,setIsModalOpen:u}),c&&(0,G.jsx)(ch,{isModalOpen:c,closeModal:s,data:o,onSelectCertificate:s,onChangesSaved:r})]})}var uh=new Set([`success`,`failed`,`rolled_back`]);function dh(e){return!!e&&uh.has(e)}var fh=2e3,ph=1e4;async function mh({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 hh(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:()=>mh(e),retry:!1,enabled:e.enabled!==!1,refetchInterval:c?e=>(e.state.data?.deployments??[]).some(e=>!dh(e.status))?fh:ph:!1})}var gh={pending:`warning`,extracting:`warning`,installing:`warning`,loading:`warning`,replicating:`warning`,restarting:`warning`,success:`success`,failed:`destructive`,rolled_back:`destructive`},_h={pending:`Pending`,extracting:`Extracting`,installing:`Installing`,loading:`Loading`,replicating:`Replicating`,restarting:`Restarting`,success:`Success`,failed:`Failed`,rolled_back:`Rolled back`};function vh({status:e}){return(0,G.jsx)(qi,{variant:gh[e]??`secondary`,children:_h[e]??e})}var yh=de();function bh(e){return e?Hd((Date.now()-e)/1e3,e):`—`}var xh=[{header:`Project`,accessorKey:`project`,enableSorting:!1},yh.display({header:`Status`,id:`status`,enableSorting:!1,cell:e=>(0,G.jsx)(vh,{status:e.row.original.status})}),yh.display({header:`Started`,id:`started_at`,enableSorting:!1,cell:e=>bh(e.row.original.started_at)}),yh.display({header:`Completed`,id:`completed_at`,enableSorting:!1,cell:e=>bh(e.row.original.completed_at)}),{header:`User`,accessorKey:`user`,enableSorting:!1},{header:`Origin`,accessorKey:`origin_node`,enableSorting:!1}];function Sh({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,G.jsx)(Nt,{"data-slot":`separator-root`,decorative:n,orientation:t,className:N(`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*Ch(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=wh(i);e&&(yield e)}}finally{a||n.cancel().catch(()=>{}),n.releaseLock()}function*o(){for(;;){let e=i.indexOf(`
12
+ `)}}];function Wd(e){return(0,K.useCallback)(async()=>{H.loading(`Refreshing...`,{id:`refreshing`});let t=Date.now();await e(),Date.now()-t<500&&await a(500),H.success(`Refreshed!`,{id:`refreshing`})},[e])}async function Gd(e){let{data:t}=await M.get(`/Invoice/${e}`);return t}function Kd(e,t){return z({queryKey:[e,`invoices`],queryFn:()=>Gd(e),retry:!1,enabled:!!e,refetchInterval:t?1e4:void 0})}function qd(){let{organizationId:e}=I({strict:!1}),{data:t}=L(nl(e)),{data:n,refetch:r,isLoading:i,isFetching:a,isRefetching:o}=L(Kd(t?.type!==`ENTERPRISE`&&t?.id,!1)),s=Wd(r);return t?.type===`ENTERPRISE`?(0,G.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,G.jsx)(Ac,{}),`, we would love to talk!`]}):i?(0,G.jsx)(Ui,{centered:!0}):!n||!n.length?(0,G.jsxs)(`span`,{children:[`Your invoices will be shown here once one is available! Want to explore your solution with Harper more?`,` `,(0,G.jsx)(Ac,{overEmail:!0}),`, we would love to talk!`]}):(0,G.jsx)(zd,{data:n,columns:Ud,children:(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:s,accessKey:`r`,disabled:a||o,children:[(0,G.jsx)(Yr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})})}function Jd(e){let t=R({getParentRoute:()=>e,path:`billing`,head:()=>({meta:[{title:`Billing — Harper Fabric`}]}),component:Rd}),n=R({getParentRoute:()=>t,path:`/`,head:()=>({meta:[{title:`Payment Methods — Harper Fabric`}]}),component:Fu}),r=R({getParentRoute:()=>t,path:`invoices`,head:()=>({meta:[{title:`Invoices — Harper Fabric`}]}),component:qd}),i=R({getParentRoute:()=>t,path:`confirm`,head:()=>({meta:[{title:`Confirm Payment — Harper Fabric`}]}),component:Ld});return t.addChildren([n,r,i])}async function Yd(e){let{data:t}=await M.get(`/OrganizationRole/${e}`);return t}function Xd(e){return z({queryKey:[e,`roles`],queryFn:()=>Yd(e),retry:!1,refetchInterval:Ln(10*1e3)})}var Zd=de(),Qd=[{header:`Role Name`,accessorKey:`roleName`,enableSorting:!1},Zd.display({header:`ID`,id:`id`,enableSorting:!1,cell:e=>(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:e.row.original.id,children:e.row.original.id})}),Zd.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 $d(e){let{data:t}=await M.post(`/Role/`,e);return t}function ef(){return F({mutationFn:$d})}var tf=j({name:S().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:E(),delete:E()});j({roles:j({create:E(),delete:E(),update:E(),view:E()}),clusters:j({create:E(),delete:E(),update:E(),view:E(),resources:C(j({id:S(),delete:E(),update:E(),view:E(),instances:j({create:E(),delete:E(),update:E(),view:E()})}))})});function nf(){let[e]=Aa(),t=Da();return e===`dark`||e===`system`&&t===`dark`?`vs-dark`:`light`}var rf=(0,K.lazy)(async()=>(await Me(()=>import(`./setup-B56Oz1_u.js`),__vite__mapDeps([17,4,1,18,19,20,21,22,23])),{default:(await Me(()=>import(`./dist-3T7cRma3.js`),__vite__mapDeps([20,1,4]))).default}));function af(e){return(0,G.jsx)(K.Suspense,{fallback:e.loading??null,children:(0,G.jsx)(rf,{...e})})}var of={roles:{create:!0,view:!0,update:!0,delete:!0},clusters:{create:!0,view:!0,update:!0,delete:!0,resources:[]}};function sf({isModalOpen:e,setIsModalOpen:t}){let n=nf(),r=ae(),{organizationId:i}=I({strict:!1}),[a,o]=(0,K.useState)(!0),[s,c]=(0,K.useState)(JSON.stringify(of,null,2)),{mutate:l,isPending:u}=ef(),d=vt({resolver:V(tf),defaultValues:{name:``,update:!1,delete:!1}}),f=(0,K.useCallback)(e=>{o(e.length===0)},[o]),p=(0,K.useCallback)(async e=>{let n=Dn(s);if(!n)return;let o={...e,...n,organizationId:i};e&&a&&l(o,{onSuccess:()=>{H.success(`Organization role added successfully!`),t(!1),r.invalidateQueries({queryKey:[i,`roles`],refetchType:`active`}),d.reset()},onError:e=>{H.error(`Failed to add organization role: ${e.message}`)}})},[a,s,l,d,r,t,i]);return(0,G.jsx)(Gt,{onOpenChange:t,open:e,children:(0,G.jsxs)(Xt,{resizable:!0,children:[(0,G.jsx)(en,{children:`Add New Organization Role`}),(0,G.jsx)(an,{children:`Set the new organization role permissions.`}),(0,G.jsx)(q,{...d,children:(0,G.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,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:d.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:d.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`checkbox`,className:`w-6 ml-2`,checked:e.value,onChange:t=>e.onChange(t.target.checked)})}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(af,{className:`w-full h-full`,theme:n,defaultLanguage:`json`,onValidate:f,onChange:e=>{e&&c(e)},options:{automaticLayout:!0},defaultValue:JSON.stringify(of,null,2)})}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:()=>t(!1),disabled:u,children:`Cancel`}),(0,G.jsx)(P,{variant:`submit`,disabled:u||!a||!d.formState.isValid,children:`Save Changes`})]})})]})})]})})}async function cf({roleId:e}){let{data:t}=await M.delete(`/Role/${e}`,{id:e,deleted:!0});return t}function lf(){return F({mutationFn:({roleId:e})=>cf({roleId:e})})}async function uf({roleId:e,updatedRoleInfo:t}){let{data:n}=await M.put(`/Role/${e}`,t);return n}function df(){return F({mutationFn:({roleId:e,updatedRoleInfo:t})=>uf({roleId:e,updatedRoleInfo:t})})}function ff({organizationId:e,roleId:t}){return z({queryKey:[e,`roles`,t],queryFn:()=>pf(t),refetchInterval:Ln(10*1e3),retry:Pn()})}async function pf(e){let{data:t}=await M.get(`/Role/${e}`);return t}function mf({onRoleDeleteClick:e,setIsConfirmingRoleDeletion:t,isRoleDeletionPending:n}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(en,{children:`Confirm Role Deletion`}),(0,G.jsx)(an,{children:`Are you sure you want to delete this role? This action cannot be undone.`}),(0,G.jsxs)(Kt,{children:[(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>t(!1),children:`Cancel`}),(0,G.jsx)(P,{variant:`destructiveOutline`,onClick:e,disabled:n,children:n?`Deleting...`:`Delete Role`})]})]})}function hf({data:e,isModalOpen:t,closeModal:n}){return(0,G.jsx)(Gt,{onOpenChange:(0,K.useCallback)(()=>n(!1),[n]),open:t,children:(0,G.jsx)(Xt,{resizable:!0,children:(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(gf,{roleName:e.roleName}),children:(0,G.jsx)(_f,{data:e,closeModal:n})})})})}function gf({roleName:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(en,{children:[`Organization Role "`,e,`"`]}),(0,G.jsx)(Ui,{centered:!0,text:`Loading role…`,className:`flex-1 min-h-0`})]})}function _f({data:e,closeModal:t}){let n=ae(),{data:r}=oe(ff({roleId:e.id,organizationId:e.organizationId})),i=Le().user?.roles?.[e.organizationId]?.id===e.id,{update:a,remove:o}=ic(e.organizationId),{mutate:s,isPending:c}=df(),{mutate:l,isPending:u}=lf(),d=nf(),[f,p]=(0,K.useState)(!1),m=vt({resolver:V(tf),defaultValues:{name:e.roleName,update:r.organization.update||!1,delete:r.organization.delete||!1}}),h=(0,K.useCallback)(()=>{l({roleId:e.id},{onSuccess:()=>{H.success(`Role deleted successfully!`),t(!0),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to delete role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[e.id,l,m,t]),[g,_]=(0,K.useState)(!0),v=(0,K.useMemo)(()=>JSON.stringify({roles:{...r.organization.roles},clusters:{...r.organization.clusters}},null,2),[r]),[y,b]=(0,K.useState)(v),x=y!==v,S=(0,K.useCallback)(e=>{_(e.length===0)},[_]),C=(0,K.useCallback)(async r=>{if(!a)return;let i=Dn(y);if(!i)return;let o={...r,...i,organizationId:e.organizationId};y&&g&&s({roleId:e.id,updatedRoleInfo:o},{onSuccess:async()=>{H.success(`Role updated successfully!`),await n.invalidateQueries({queryKey:[e.organizationId,`roles`,e.id]}),t(!1),m.reset()},onError:e=>{H.error(`Error`,{description:`Failed to update role: ${e instanceof Error?e.message:String(e)}.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}})},[t,e.id,e.organizationId,m,g,n,r,a,y,s]);return f?(0,G.jsx)(mf,{onRoleDeleteClick:h,setIsConfirmingRoleDeletion:p,isRoleDeletionPending:u}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(en,{children:[i||!a?`View`:`Edit`,` Organization Role "`,e.roleName,`"`]}),(0,G.jsx)(q,{...m,children:(0,G.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,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{className:`col-span-2`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Role Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,className:``,...e,disabled:!0,readOnly:!0})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`update`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Update Organization`}),(0,G.jsx)(J,{children:(0,G.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,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`delete`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Can Delete Organization`}),(0,G.jsx)(J,{children:(0,G.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,G.jsx)(Q,{})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(af,{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,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[o&&(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:()=>p(!0),disabled:c,children:`Delete Role`}),a&&(0,G.jsx)(P,{variant:`submit`,disabled:!g||c||!m.formState.isValid||!m.formState.isDirty&&!x,children:`Save Changes`})]})})]})})]})}function vf(){let e=ke(),t=ae(),{organizationId:n,orgRoleId:r}=I({strict:!1}),{create:i}=ic(n),{data:a,refetch:o,isFetching:s,isRefetching:c}=oe(Xd(n)),l=(0,K.useMemo)(()=>a&&a?.find(e=>e.id===r),[a,r]),u=!!r&&!!l,[d,f]=(0,K.useState)(!1),p=(0,K.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,K.useCallback)(()=>{f(!0)},[f]),h=(0,K.useCallback)(e=>p(e.original.id,!1),[p]),g=(0,K.useCallback)(e=>p(void 0,e),[p]),_=Wd(o);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(kd,{children:(0,G.jsxs)(K.Suspense,{fallback:(0,G.jsx)(Ui,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(zd,{data:a,columns:Qd,onRowClick:h,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:_,accessKey:`r`,disabled:s||c,children:[(0,G.jsx)(Yr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),i&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:m,accessKey:`a`,disabled:d,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),i&&(0,G.jsx)(sf,{isModalOpen:d,setIsModalOpen:f}),u&&(0,G.jsx)(hf,{data:l,isModalOpen:u,closeModal:g},l.id)]})})]})}function yf({className:e,...t}){return(0,G.jsx)(nt,{"data-slot":`switch`,className:N(`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,G.jsx)(Ge,{"data-slot":`switch-thumb`,className:N(`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 bf(e){return`//oauth/${e}/login`}async function xf(e,t){let{data:n}=await M.patch(`/Organization/${e}/settings/oauth`,t);return n}var Sf=j({domain:S().min(1,`Domain is required`),clientId:S().min(1,`Client ID is required`),clientSecret:S().min(1,`Client secret is required`),scope:S().optional()}),Cf=j({domain:S().min(1,`Domain is required`),clientId:S().optional(),clientSecret:S().optional(),scope:S().optional()});function wf(){let{organizationId:e}=I({strict:!1}),{user:t}=Le(),{update:n}=rc(e),{data:r}=oe(nl(e)),i=ae(),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(null),l=r.settings?.oauthConfigs??[],{mutate:u,isPending:d}=F({mutationFn:t=>xf(e,t),onSuccess:()=>void i.invalidateQueries({queryKey:[e]}),onError:()=>H.error(`Failed to update OAuth settings.`)}),f=vt({resolver:V(Sf),defaultValues:{domain:``,clientId:``,clientSecret:``,scope:`openid email profile`}}),p=e=>{u({provider:`okta`,...e},{onSuccess:()=>{H.success(`OAuth provider added.`),f.reset(),o(!1)}})},m=vt({resolver:V(Cf)}),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:()=>{H.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 Tc(e)&&H.success(`Sign-in URL copied.`)},b=async e=>{await Tc(e)&&H.success(`Redirect URI copied.`)};return n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(kd,{children:(0,G.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,G.jsx)(`h2`,{className:`text-2xl text-foreground font-light mb-6`,children:`Authentication`}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h3`,{className:`text-lg text-foreground font-medium`,children:`OAuth Providers`}),!a&&(0,G.jsxs)(P,{variant:`positiveOutline`,size:`sm`,onClick:()=>o(!0),children:[(0,G.jsx)(Jr,{}),`Add Provider`]})]}),l.length===0&&!a&&(0,G.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,G.jsxs)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Edit Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(Cn,{className:`size-4`})})]}),(0,G.jsx)(q,{...m,children:(0,G.jsxs)(`form`,{onSubmit:m.handleSubmit(t=>g(e,t)),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:m.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Leave blank to keep existing`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:m.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Saving...`:`Save`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>c(null),children:`Cancel`})]})]})})]},e.id):(0,G.jsx)(`div`,{className:`border rounded-lg p-4 mb-3 text-foreground`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.domain}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase bg-muted px-2 py-0.5 rounded`,children:e.provider}),e.enabled===!1&&(0,G.jsx)(`span`,{className:`text-xs text-destructive bg-destructive/10 px-2 py-0.5 rounded`,children:`Disabled`})]}),(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:[`Client ID: `,(0,G.jsx)(`span`,{className:`text-foreground font-mono`,children:`****`})]}),e.id&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-3 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Okta redirect URI`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:[`Add to `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),` `,`in your Okta app settings.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground font-mono truncate`,children:v(e.id)}),(0,G.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,G.jsx)(fr,{className:`size-3.5`})})]})]}),(0,G.jsxs)(`div`,{className:`mt-2 rounded-md bg-muted px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`User login link`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`a`,{href:bf(e.id),target:`_blank`,rel:`noreferrer`,className:`text-sm text-foreground truncate hover:underline`,children:bf(e.id)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 text-muted-foreground`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(bf(e.id)),className:`hover:text-foreground`,title:`Copy login link`,children:(0,G.jsx)(fr,{className:`size-3.5`})}),(0,G.jsx)(`a`,{href:bf(e.id),target:`_blank`,rel:`noreferrer`,className:`hover:text-foreground`,title:`Open login link`,children:(0,G.jsx)(gr,{className:`size-3.5`})})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 sm:shrink-0`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-foreground cursor-pointer`,children:[(0,G.jsx)(yf,{checked:e.enabled!==!1,onCheckedChange:()=>_(e,`enabled`),disabled:d}),`Enabled`]}),(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-foreground ${n?`cursor-pointer`:`cursor-not-allowed opacity-50`}`,children:[(0,G.jsx)(yf,{checked:!!e.required,onCheckedChange:()=>_(e,`required`),disabled:d||!n}),`Required`]})}),!n&&(0,G.jsxs)(Va,{children:[`Sign in via `,e.provider,` first to enable Required`]})]}),(0,G.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:d,children:(0,G.jsx)(mn,{className:`size-4`})})]})]})},e.id)}),a&&(0,G.jsxs)(`div`,{className:`border rounded-lg p-4 text-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h4`,{className:`font-medium`,children:`Add Okta Provider`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),f.reset()},className:`text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(Cn,{className:`size-4`})})]}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:[`After saving, copy the `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Okta redirect URI`}),` `,`from the provider card and add it to your Okta app's`,` `,(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Login redirect URIs`}),`.`]}),(0,G.jsx)(q,{...f,children:(0,G.jsxs)(`form`,{onSubmit:f.handleSubmit(p),className:`space-y-4`,children:[(0,G.jsx)(Y,{control:f.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Domain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`company.okta.com`,autoFocus:!0,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`Okta Client ID`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`clientSecret`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Client Secret`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,placeholder:`Okta Client Secret`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:f.control,name:`scope`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Scope`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{placeholder:`openid email profile`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positive`,disabled:d,children:d?`Adding...`:`Add Provider`}),(0,G.jsx)(P,{type:`button`,variant:`outline`,onClick:()=>{o(!1),f.reset()},children:`Cancel`})]})]})})]})]})]})})]}):(0,G.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.`})}O.object({email:qo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:O.string().nonempty({error:`Please select a role.`})});async function Tf(e){let{data:t}=await M.post(`/UserInvite/`,e);return t}function Ef(){return F({mutationFn:e=>Tf(e)})}function Df({user:e}){let{update:t}=ic(),{mutate:n,isPending:r}=Ef(),i=e.roles?.[0]?.id,a=(0,K.useCallback)(t=>{if(t.stopPropagation(),!e.email||!i){H.error(`Cannot resend invite: this user has no email or role.`);return}n({email:e.email,roleId:i},{onSuccess:()=>H.success(`Invitation resent to ${e.email}.`)})},[n,i,e.email]);return t?(0,G.jsxs)(P,{variant:`ghost`,size:`sm`,className:`h-auto px-2 py-0 align-middle text-sm`,onClick:a,disabled:r||!i,children:[(0,G.jsx)(zr,{}),` Resend invite`]}):null}var Of=de(),kf=[{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},Of.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},Of.display({header:``,enableSorting:!1,id:`actions`,cell:e=>e.row.original.status===`PENDING`?(0,G.jsx)(Df,{user:e.row.original}):null})];function Af({name:e,id:t}){return(0,G.jsxs)(`span`,{className:`flex items-baseline gap-2 truncate`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:e}),(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}var jf=O.object({email:qo.max(80,{error:`Email cannot be longer than 80 characters.`}),roleId:O.string().nonempty({error:`Please select a role.`})});async function Mf(e){let{data:t}=await M.post(`/OrganizationRole/`,e);return t}function Nf(){return F({mutationFn:e=>Mf(e)})}function Pf({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let{organizationId:r}=I({strict:!1}),{data:i,isLoading:a}=L({...Xd(r),throwOnError:!0}),[o,s]=(0,K.useState)(!1),c=vt({resolver:V(jf),defaultValues:{email:``,roleId:``}}),{mutate:l,isPending:u}=Nf(),{mutate:d,isPending:f}=Ef(),p=(0,K.useCallback)(async e=>{e&&(o?d:l)(e,{onSuccess:()=>{let r=e.roleId;c.reset(),c.setValue(`roleId`,r),t(),H.success(`User invited successfully!`),n(!1),s(!1)},onError:e=>{e?.status===404&&s(!0)}})},[l,c,d,t,n,o]);return(0,G.jsx)(Gt,{onOpenChange:()=>{n(!1),s(!1),c.reset()},open:e,children:(0,G.jsx)(Xt,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...c,children:(0,G.jsxs)(`form`,{id:`org-add-user-form`,name:`org-add-user-form`,onSubmit:c.handleSubmit(p),className:`grid gap-4 my-4`,children:[(0,G.jsx)(qt,{children:(0,G.jsx)(en,{children:o?`Invite User`:`Add User`})}),(0,G.jsx)(Y,{control:c.control,name:`email`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Email`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`email`,enterKeyHint:`next`,autoComplete:`email`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:c.control,name:`roleId`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Roles`}),a?(0,G.jsx)(Hu,{}):(0,G.jsx)(J,{children:(0,G.jsxs)(rn,{...e,onValueChange:t=>e.onChange(t),children:[(0,G.jsx)($t,{className:`w-full`,children:(0,G.jsx)(nn,{placeholder:`Choose Role`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Wt,{children:`Role`}),i?.map(e=>(0,G.jsx)(Yt,{value:e.id,children:(0,G.jsx)(Af,{name:e.roleName,id:e.id})},e.id))]})})]})}),(0,G.jsx)(Q,{})]})}),o&&(0,G.jsxs)(an,{className:`p-3 my-5 text-white rounded-md bg-amber-600 flex`,children:[(0,G.jsx)(Rr,{className:`inline-block size-12 pr-2`}),(0,G.jsx)(`span`,{children:`This person doesn’t have a Fabric account. Do you want to invite them?`})]}),(0,G.jsx)(Kt,{children:(0,G.jsx)(`div`,{className:`flex justify-between w-full`,children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:u||f,children:[(0,G.jsx)($r,{}),` `,o?`Invite User`:`Add User`]})})})]})})})})}async function Ff({roleId:e,userId:t}){let{data:n}=await M.delete(`/OrganizationRole/role/${e}/user/${t}`);return n}function If(){return F({mutationFn:({roleId:e,userId:t})=>Ff({roleId:e,userId:t})})}function Lf(e){let[t,n]=(0,K.useState)(e||!1);return[t,(0,K.useCallback)(e=>{n(typeof e==`boolean`?e:e.target.checked)},[])]}function Rf({data:e,readOnly:t,canRemove:n,orgRole:r,selectedRoles:i,setChangesMade:a}){let{mutate:o,isPending:s}=Nf(),{mutate:c,isPending:l}=If(),u=!!i[r.id],[d,f]=(0,K.useState)(u),[p,m]=Lf(u);return(0,K.useEffect)(()=>{p!==d&&(p?o({email:e.email,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role added successfully`)}}):c({userId:e.id,roleId:r.id},{onSuccess:()=>{f(p),a(!0),H.success(`Role removed successfully`)}}))},[o,e.email,e.id,p,r.id,c,a,d]),(0,G.jsxs)(Ao,{className:`flex`,children:[(0,G.jsx)($,{type:`checkbox`,className:`w-6`,disabled:t||s||l||!n&&p,checked:p,onChange:m}),(0,G.jsx)(`span`,{className:`pl-4 pr-8 flex-1 py-2.5`,children:r.roleName})]},r.id)}function zf({isSelf:e,isPending:t,onConfirm:n}){let[r,i]=(0,K.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?Lr:vi;return r?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.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,G.jsx)(_i,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.jsx)(`span`,{children:a.warning})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(P,{type:`button`,variant:`ghostOutline`,disabled:t,onClick:()=>i(!1),children:`Cancel`}),(0,G.jsxs)(P,{type:`button`,variant:`destructive`,disabled:t,onClick:n,children:[(0,G.jsx)(o,{}),` `,t?a.busy:a.confirm]})]})]}):(0,G.jsx)(`div`,{className:`flex justify-start`,children:(0,G.jsxs)(P,{type:`button`,variant:`destructiveOutline`,disabled:t,onClick:()=>i(!0),children:[(0,G.jsx)(o,{}),` `,a.idle]})})}function Bf(e){return e?.trim().toLowerCase()===`admin`}function Vf({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 Hf({closeModal:e,data:t,isModalOpen:n,onUserUpdated:r,orgUserCount:i,orgAdminCount:a}){let{organizationId:o}=I({strict:!1}),s=Le(),{update:c,remove:l}=ic(o),u=s.user?.email===t.email,[d,f]=(0,K.useState)(!1),{canRemoveRoles:p,showRemovalAction:m,blockedReason:h}=Vf({canDelete:l,isSelf:u,orgUserCount:i,adminCount:a,isAdmin:(t.roles??[]).some(e=>Bf(e.roleName)),roleCount:t.roles?.length??0}),{mutateAsync:g}=If(),[_,v]=(0,K.useState)(!1),y=(0,K.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)?H.error(u?`Something went wrong leaving the organization. Please try again.`:`Couldn’t remove ${t.email} from the organization. Please try again.`):H.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,G.jsx)(Gt,{onOpenChange:d?r:e,open:n,children:(0,G.jsxs)(Xt,{resizable:!0,children:[(0,G.jsx)(qt,{children:(0,G.jsxs)(en,{children:[c?`Edit `:`View `,` `,t.email,` `,u?`(yourself)`:``]})}),c&&(0,G.jsxs)(an,{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,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(Ui,{centered:!0,text:`Loading roles…`,className:`flex-1 min-h-0`}),children:(0,G.jsx)(Uf,{data:t,organizationId:o,update:c,canRemove:p,setChangesMade:f})}),t.status===`PENDING`&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(Df,{user:t})}),m&&(0,G.jsx)(`div`,{className:`border-t border-border pt-4`,children:(0,G.jsx)(zf,{isSelf:u,isPending:_,onConfirm:y})}),h&&(0,G.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground border border-amber-500/50 rounded-md p-3`,children:[(0,G.jsx)(_i,{className:`size-4 text-amber-500 shrink-0 mt-0.5`}),(0,G.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 Uf({data:e,organizationId:t,update:n,canRemove:r,setChangesMade:i}){let{data:a}=oe(Xd(t)),o=(0,K.useMemo)(()=>e.roles?qc(e.roles,`id`):{},[e]);return(0,G.jsx)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto`,children:a.map(t=>(0,G.jsx)(Rf,{readOnly:!n,canRemove:r,data:e,orgRole:t,selectedRoles:o,setChangesMade:i},t.id))})}function Wf(e,t){return e.email>t.email?1:-1}function Gf(e){return(e.users??[]).filter(e=>e!=null)}function Kf(e){let t={};for(let n of e)for(let e of Gf(n))t[e.id]||(t[e.id]={...e,roles:[]}),t[e.id].roles.push(n);return Object.values(t).sort(Wf)}function qf(e){let t=new Set;for(let n of e)if(Bf(n.roleName))for(let e of Gf(n))t.add(e.id);return t.size}function Jf(){let e=ke(),{organizationId:t,orgUserId:n}=I({strict:!1}),{update:r}=ic(t),{data:i,refetch:a,isFetching:o,isRefetching:s}=oe(Xd(t)),c=(0,K.useMemo)(()=>Kf(i),[i]),l=(0,K.useMemo)(()=>qf(i),[i]),u=(0,K.useMemo)(()=>c?.find(e=>e.id===n),[c,n]),d=(0,K.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)})},[n,e]),f=!!n&&!!u,[p,m]=(0,K.useState)(!1),[h]=(0,K.useState)({attribute:`email`,descending:!1}),g=(0,K.useMemo)(()=>[{desc:h.descending,id:h.attribute}],[h]),_=(0,K.useCallback)(()=>{m(!0)},[m]),v=(0,K.useCallback)(()=>{a(),m(!1)},[a,m]),y=(0,K.useCallback)(e=>{d(e.original.id)},[d]),b=(0,K.useCallback)(()=>{d(void 0)},[d]),x=(0,K.useCallback)(()=>{a(),d(void 0)},[d,a]),S=Wd(a);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(kd,{children:(0,G.jsxs)(K.Suspense,{fallback:(0,G.jsx)(Ui,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:[(0,G.jsxs)(zd,{data:c,isFetching:o||s,columns:kf,onRowClick:y,sortingState:g,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:S,accessKey:`r`,disabled:o||s,children:[(0,G.jsx)(Yr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),r&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:_,accessKey:`a`,disabled:p,children:[(0,G.jsx)(Jr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),r&&(0,G.jsx)(Pf,{isModalOpen:p,onChangesSaved:v,setIsModalOpen:m}),f&&(0,G.jsx)(Hf,{closeModal:b,data:u,isModalOpen:f,onUserUpdated:x,orgUserCount:c.length,orgAdminCount:l})]})})]})}function Yf({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`skeleton`,className:N(`bg-primary/10 animate-pulse rounded-md`,e),...t})}function Xf({organizationId:e,organizationName:t,providers:n}){return(0,G.jsxs)(Ut,{className:`relative h-full justify-between opacity-90`,children:[(0,G.jsxs)(Bt,{children:[(0,G.jsx)(Ht,{className:`truncate`,children:e}),(0,G.jsx)(zt,{children:(0,G.jsx)(`h2`,{children:t})})]}),(0,G.jsxs)(Vt,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1.5 mb-1`,children:[(0,G.jsx)(kr,{className:`size-3 shrink-0`}),`Sign in with an OAuth provider to access this organization.`]}),n.map(e=>(0,G.jsx)(`a`,{href:bf(e.oauthConfigId),children:(0,G.jsxs)(P,{variant:`outline`,className:`w-full`,children:[`Sign in with `,e.name]})},e.oauthConfigId))]})]})}var Zf=j({couponId:S().nonempty({message:`Please enter a coupon ID.`}).trim()});async function Qf({organizationId:e,couponId:t}){let{data:n}=await M.post(`/Coupon`,{organizationId:e,couponId:t},{validateStatus:e=>e>=200&&e<400||e===400||e===409});return n}function $f(){return F({mutationFn:Qf})}function ep({organizationId:e,organizationName:t,isOpen:n,onClose:r}){let{mutate:i,isPending:a}=$f(),o=vt({resolver:V(Zf),defaultValues:{couponId:``}}),{handleSubmit:s,control:c,reset:l}=o;(0,K.useEffect)(()=>{n&&l({couponId:``})},[n,l]);let u=(0,K.useCallback)(n=>{i({organizationId:e,couponId:n.couponId},{onSuccess:i=>{i?H.error(`Error`,{description:i||`Failed to add coupon.`}):(H.success(`Success`,{description:`Coupon "${n.couponId}" added to ${t||e}.`}),r())}})},[i,e,t,r]);return(0,G.jsx)(Gt,{open:n,onOpenChange:e=>!e&&r(),children:(0,G.jsxs)(Xt,{children:[(0,G.jsxs)(qt,{children:[(0,G.jsx)(en,{children:`Add Coupon`}),(0,G.jsxs)(an,{children:[`Add a coupon code to`,` `,t||e,`. This coupon will be applied to the next billing cycle.`,(0,G.jsx)(`br`,{}),`Coupons can be created in our`,` `,(0,G.jsx)(`a`,{href:`https://dashboard.stripe.com/`,target:`_blank`,rel:`noreferrer`,className:`text-purple hover:underline`,children:`Stripe Dashboard`}),`.`]})]}),(0,G.jsx)(q,{...o,children:(0,G.jsxs)(`form`,{onSubmit:s(u),children:[(0,G.jsx)(`div`,{className:`grid gap-4 py-4`,children:(0,G.jsx)(Y,{control:c,name:`couponId`,render:({field:e})=>(0,G.jsxs)(X,{className:`grid items-center gap-4`,children:[(0,G.jsx)(Z,{children:`Coupon ID`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{...e,placeholder:`e.g. 100OFF`,disabled:a})}),(0,G.jsx)(Q,{})]})})}),(0,G.jsxs)(Kt,{children:[(0,G.jsx)(P,{type:`button`,variant:`ghost`,onClick:r,disabled:a,children:`Cancel`}),(0,G.jsx)(P,{type:`submit`,disabled:a,children:a?`Adding...`:`Add Coupon`})]})]})})]})})}function tp({organizationRole:e,onDeleteOrgModal:t}){let{organizationId:n,organizationName:r,roleName:i}=e,{remove:a,update:o}=rc(n),s=o,{view:c}=ic(n),l=Be(),[u,d]=(0,K.useState)(!1),f=(0,K.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,G.jsx)(ni,{className:`size-4 mr-2 text-blue-500`}),label:`Clusters`},c&&{key:`roles`,to:`${n}/roles`,icon:(0,G.jsx)(ii,{className:`size-4 mr-2 text-purple`}),label:`Roles`},c&&{key:`users`,to:`${n}/users`,icon:(0,G.jsx)(bi,{className:`size-4 mr-2 text-orange-500`}),label:`Users`},s&&{key:`billing`,to:`${n}/billing`,icon:(0,G.jsx)(pr,{className:`size-4 mr-2 text-green-500`}),label:`Billing`},o&&{key:`settings`,to:`${n}/settings`,icon:(0,G.jsx)(kr,{className:`size-4 mr-2 text-yellow-500`}),label:`Settings`},l&&{key:`add-coupon`,onClick:()=>d(!0),icon:(0,G.jsx)(mi,{className:`size-4 mr-2 text-pink-500`}),label:`Add Coupon`},{type:`separator`,key:`sep-bottom`},{key:`delete`,onClick:f,className:`focus:bg-red/70 focus:text-white`,icon:(0,G.jsx)(hi,{className:`size-4 mr-2 text-red-500`}),label:`Delete`}].filter(Fn);return(0,G.jsx)(tc,{items:a?p:[],children:(0,G.jsxs)(Ut,{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,G.jsx)(B,{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,G.jsxs)(Bt,{children:[(0,G.jsxs)(Ht,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:n}),a&&(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{"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,G.jsx)(hr,{})}),(0,G.jsx)(Di,{children:ec(p,`dropdown`)})]})]}),(0,G.jsx)(zt,{children:(0,G.jsx)(`h2`,{children:r})})]}),(0,G.jsxs)(Vt,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(qi,{className:`min-w-0 shrink`,title:wo(i),children:(0,G.jsx)(`span`,{className:`truncate`,children:wo(i)})}),(0,G.jsxs)(`span`,{className:`text-sm shrink-0 py-2 whitespace-nowrap ml-auto`,children:[`View `,(0,G.jsx)(Gn,{className:`inline-block`})]})]}),(0,G.jsx)(ep,{organizationId:n,organizationName:r,isOpen:u,onClose:()=>d(!1)})]})})}async function np(e){let{data:t}=await M.delete(`/Organization/${e}`);return t}function rp(){return F({mutationFn:e=>np(e)})}async function ip(e){let{data:t}=await M.post(`/Organization/`,{...e});return t}function ap(){return F({mutationFn:e=>ip(e)})}var op=S().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.`}),sp=j({name:S().max(255,{error:`Name cannot be longer than 255 characters.`}),subdomain:ee([D(``),k(),op]).optional()});function cp(){let{user:e}=Le(),t=ke(),n=vt({resolver:V(sp),defaultValues:{name:``,subdomain:``}}),{setFocus:r,watch:i}=n;(0,K.useEffect)(()=>{r(`name`)},[r]);let a=`${e?.firstname} ${e?.lastname} Org`,o=i(`name`)||a,s=i(`subdomain`),c=(0,K.useMemo)(()=>{let e=il(ol(o),op.maxLength);return{suggestedSubdomain:e,fullHostName:`future-cluster-names.${s||e}.harperfabric.com`}},[o,s]),{mutate:l,isPending:d}=ap(),f=ae(),p=(0,K.useCallback)(async e=>{l({name:e.name||a,subdomain:e.subdomain||c.suggestedSubdomain},{onSuccess:e=>{f.invalidateQueries({queryKey:m,refetchType:`active`}),u.reloadUser(h),t({to:`/${e.id}`})}})},[c.suggestedSubdomain,f,l,a,t]);return(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(q,{...n,children:(0,G.jsxs)(`form`,{id:`org-add-form`,name:`org-add-form`,onSubmit:n.handleSubmit(p),className:`grid gap-6 text-foreground max-w-xl`,children:[(0,G.jsx)(Y,{control:n.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:sp.shape.name.maxLength,autoCapitalize:`words`,placeholder:a,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:n.control,name:`subdomain`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Subdomain`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,maxLength:op.maxLength,autoCapitalize:`none`,placeholder:c.suggestedSubdomain,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Full Host Name`}),(0,G.jsx)(J,{children:(0,G.jsx)(`span`,{children:c.fullHostName})}),(0,G.jsx)(Q,{})]}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:d,children:[`Create New Organization `,(0,G.jsx)(Gn,{})]})})]})})})}function lp(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:(0,G.jsx)(cp,{})})]})}var up={org:`organization`,clu:`cluster`,ins:`instance`},dp=/^(org|clu|ins)-[a-z0-9]+$/;function fp(e){if(typeof e!=`string`)return null;let t=e.trim(),n=dp.exec(t);return n?{kind:up[n[1]],id:t}:null}function pp(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 mp(e,t){let{data:n}=await M.get(pp(e,t));return{organizations:n.slice(0,12),hasNextPage:n.length>12}}var hp={organizations:[],hasNextPage:!1};function gp(e){return e instanceof v&&(e.response?.status===404||e.status===404)}async function _p(e){try{let{data:t}=await M.get(`/Admin/Organization/${e}`);return t?{organizations:[t],hasNextPage:!1}:hp}catch(e){if(gp(e))return hp;throw e}}async function vp(e){try{let{data:t}=await M.get(`/Cluster/${e}`),n=t?.organizationId;return n?await _p(n):hp}catch(e){if(gp(e))return hp;throw e}}function yp(e,t){let n=fp(t);return z({queryKey:[`admin-all-organizations`,t,e],queryFn:()=>n?.kind===`organization`?_p(n.id):n?.kind===`cluster`?vp(n.id):mp(e,t),placeholderData:ue,retry:!1})}function bp(e,t=300,n){let[r,i]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[n?n(e):e,t]),r}function xp(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 Sp(e,t){let[n,r]=(0,K.useState)(t),[i,a]=(0,K.useState)(e);return(0,K.useEffect)(()=>{xp(n,t)||(r(t),a(e))},[n,t,e]),xp(n,t)?[i,a]:[e,a]}var Cp={};function wp(e,t,n){let r=(0,K.useCallback)((e,n)=>t(e,n),[n]);(0,K.useEffect)(()=>(Cp[e]||(Cp[e]=[]),Cp[e].push(r),function(){let t=Cp[e].indexOf(r);t>=0&&Cp[e].splice(t,1)}),[e,t,r])}function Tp(e,t,n){let r=Cp[e];if(r)for(let e of r)e(t,n)}function Ep(e,t,n){return r=>Tp(e,t,n??r)}function Dp(e,t,n){return(0,K.useCallback)(r=>Tp(e,t,n??r),[e,t,n])}function Op(e,t){return Dn(sessionStorage.getItem(String(e)))??t}function kp(e,t){t==null?sessionStorage.removeItem(String(e)):sessionStorage.setItem(String(e),JSON.stringify(t))}function Ap(e,t){let n=Sp(Op(e,t),[e]),[r,i]=n;return(0,K.useEffect)(()=>{kp(e,r),Tp(`Session:${e}`,r)},[e,r]),wp(`Session:${e}`,function(e){r!==e&&i(e)},[r,e,t]),(0,K.useEffect)(function(){let n=n=>{n.key===e&&i(Op(e,t))};return window.addEventListener(`storage`,n),()=>{window.removeEventListener(`storage`,n)}},[e,i,t]),n}function jp(){let e=ae(),{data:t}=oe(c()),{mutate:n,isPending:r}=rp(),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),[l,u]=(0,K.useState)(``),d=(0,K.useCallback)(()=>u(``),[]),f=Be(),[p,m]=Ap(`ShowAllOrganizations`,!1),[h,g]=(0,K.useState)(0),_=f&&p,v=(0,K.useCallback)(e=>{m(e),g(0)},[m]),y=bp(l,300),b=(0,K.useMemo)(()=>{if(!f)return null;let e=fp(y);return e?.kind===`organization`||e?.kind===`cluster`?e:null},[f,y]),x=_||!!b,{data:S,isPending:C}=L({...yp(h,y),enabled:x}),{organizationRoles:w,oauthLockedOrgs:T}=(0,K.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 admin`});return{organizationRoles:n.filter(Nd([`organizationId`,`organizationName`],l)).sort((e,t)=>(e.organizationName||``)>(t.organizationName||``)?1:-1),oauthLockedOrgs:r}},[l,t?.roles,f]),E=(0,K.useMemo)(()=>{let e=t?.roles||{};return(S?.organizations||[]).map(t=>({organizationId:t.id,organizationName:t.name,roleName:e[t.id]?.role||`fabric admin`}))},[S?.organizations,t?.roles]),D=x?E:w,O=(0,K.useCallback)(e=>{u(e.currentTarget.value||``),g(0)},[]),k=(0,K.useCallback)(t=>{t?.organizationId&&n(t.organizationId,{onSuccess:()=>{H.success(`Success`,{description:`Organization successfully deleted.`,duration:5e3,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),e.invalidateQueries({queryKey:[]}),a(!1)},onError:()=>a(!1)})},[n,e,a]),A=(0,K.useCallback)(e=>{s(e),a(!0)},[]),{createCluster:j}=le({strict:!1});return!_&&w.length===1&&!l.length&&j?(0,G.jsx)(fe,{to:`/${w[0].organizationId}/new-cluster`,replace:!0}):!_&&!w.length&&!T.length&&!l.length?(0,G.jsx)(lp,{}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{children:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-end gap-2`,children:[f&&(0,G.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 text-xs`,children:[(0,G.jsx)(yf,{checked:p,onCheckedChange:v,"aria-label":`Show all organizations`}),(0,G.jsx)(`span`,{className:`hidden sm:inline-block`,children:`All Orgs`})]}),(0,G.jsx)($,{placeholder:`Filter by name`,className:`inline-block w-full text-xs`,value:l,onChange:O}),(0,G.jsx)(B,{to:`/new-org`,children:(0,G.jsxs)(P,{variant:`positive`,accessKey:`n`,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{className:`hidden sm:inline-block`,children:[(0,G.jsx)(`u`,{children:`N`}),`ew `,(0,G.jsx)(`span`,{className:`hidden md:inline-block`,children:`Organization`})]})]})})]})}),(0,G.jsxs)(`section`,{className:`mt-32 px-4 pt-4 md:px-12 min-h-[calc(100vh-theme(spacing.32))]`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-12`,children:[!x&&T.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(Xf,{organizationId:e.organizationId,organizationName:e.organizationName,providers:e.providers})},e.organizationId)),x&&C?Array.from({length:12},(e,t)=>(0,G.jsx)(Yf,{className:`col-span-1 h-40 md:col-span-4 lg:col-span-3 2xl:col-span-2`},t)):D.map(e=>(0,G.jsx)(`div`,{className:`col-span-1 md:col-span-4 lg:col-span-3 2xl:col-span-2`,children:(0,G.jsx)(tp,{organizationRole:e,onDeleteOrgModal:A})},e.organizationId)),!D.length&&!(x&&C)&&(x||!T.length)&&(0,G.jsxs)(`div`,{className:`col-span-1 md:col-span-12 text-center`,children:[(0,G.jsx)(`h2`,{className:`my-4 text-xl`,children:`No matches found.`}),(0,G.jsx)(P,{variant:`outline`,onClick:d,children:`Clear Filters`})]})]}),x&&(h>0||S?.hasNextPage)&&(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-4 py-6`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:h===0,onClick:()=>g(e=>e-1),children:[(0,G.jsx)(on,{}),`Previous`]}),(0,G.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`Page `,h+1]}),(0,G.jsxs)(P,{variant:`defaultOutline`,size:`sm`,className:`select-none`,disabled:!S?.hasNextPage,onClick:()=>g(e=>e+1),children:[`Next`,(0,G.jsx)(Gn,{})]})]})]}),o&&(0,G.jsx)(Gs,{typeOfThingBeingDeleted:`organization`,nameOfThingBeingDeleted:o.organizationName,isModalOpen:i,setIsModalOpen:()=>a(!1),deletionConfirmed:()=>k(o),deletionPending:r})]})}var Mp=R({getParentRoute:()=>uo,id:`_orgsLayout`});R({getParentRoute:()=>Mp,path:`/`,head:()=>({meta:[{title:`Organizations — Harper Fabric`}]}),component:jp}),R({getParentRoute:()=>Mp,path:`/new-org`,head:()=>({meta:[{title:`New Organization — Harper Fabric`}]}),component:lp});var Np=R({getParentRoute:()=>Mp,path:`$organizationId`,beforeLoad:async e=>{let{organizationId:t}=e.params;if(!el(t))throw ve({to:`/`});return{organization:await e.context.queryClient.ensureQueryData(nl(t))}}});R({getParentRoute:()=>Np,path:`/roles`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:vf}),R({getParentRoute:()=>Np,path:`/roles/$orgRoleId`,head:()=>({meta:[{title:`Organization Roles — Harper Fabric`}]}),component:vf}),R({getParentRoute:()=>Np,path:`/users`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Jf}),R({getParentRoute:()=>Np,path:`/users/$orgUserId`,head:()=>({meta:[{title:`Organization Users — Harper Fabric`}]}),component:Jf}),R({getParentRoute:()=>Np,path:`/settings`,component:wf}),Jd(Np);var Pp=R({getParentRoute:()=>Np,id:`_clusterLayout`});R({getParentRoute:()=>Pp,path:`/`,head:()=>({meta:[{title:`Clusters — Harper Fabric`}]}),component:Pd}),R({getParentRoute:()=>Np,path:`/new-cluster`,head:()=>({meta:[{title:`New Cluster — Harper Fabric`}]}),component:Od}),R({getParentRoute:()=>Ip,path:`/edit`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Od}),R({getParentRoute:()=>Ip,path:`/edit/$mode`,head:()=>({meta:[{title:`Edit Cluster — Harper Fabric`}]}),component:Od});function Fp(){return(0,G.jsx)(Ce,{})}var Ip=R({getParentRoute:()=>Pp,path:`$clusterId`,component:Fp,beforeLoad:async({context:e,params:t})=>({cluster:await e.queryClient.ensureQueryData(Ko(t.clusterId))})});function Lp({cluster:e}){let t=re(),n=ae(),{update:r,remove:i}=ac(e.organizationId,e.id),{run:a,isPending:o}=wc(e),{mutate:s,isPending:c}=bc(),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(null),_=e.status===`RUNNING`,v=e.status===`STOPPED`,y=e.status===`PARTIAL`,b=!r||o,x=(0,K.useCallback)(()=>{s(e.id,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),m(!1),H.success(`Success`,{description:`Cluster successfully terminated.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),t.navigate({to:`/${e.organizationId}`})},onError:()=>{m(!1)}})},[e.id,e.organizationId,s,n,t]),S=(0,K.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 fc(e)||!r&&!i?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsxs)(P,{variant:`outline`,size:`sm`,disabled:o,className:`gap-1.5 hover:translate-y-0 data-[state=open]:[&>svg]:rotate-180`,children:[`Cluster actions`,(0,G.jsx)(Sn,{className:`size-4 transition-transform`})]})}),(0,G.jsxs)(Di,{align:`end`,className:`w-56`,children:[(0,G.jsx)(Ai,{className:`text-gray-600 text-xs`,children:`Container`}),(0,G.jsxs)(Oi,{disabled:b||!(v||y),onClick:()=>void a(`start`,{safeMode:!1,strategy:`parallel`}),children:[(0,G.jsx)(qr,{}),` Start`]}),(0,G.jsxs)(Oi,{disabled:b||!v,onClick:()=>g(`start`),children:[(0,G.jsx)(Mr,{}),` Start in safe mode`]}),(0,G.jsxs)(Oi,{disabled:b||!(_||y),onClick:()=>f(!0),children:[(0,G.jsx)(Qr,{}),` Restart`]}),(0,G.jsxs)(Oi,{disabled:b||!_,onClick:()=>g(`restart`),children:[(0,G.jsx)(Mr,{}),` Restart in safe mode`]}),(0,G.jsxs)(Oi,{variant:`destructive`,disabled:b||!(_||y),onClick:()=>u(!0),children:[(0,G.jsx)(ci,{}),` Stop`]}),(0,G.jsx)(ji,{}),(0,G.jsxs)(Oi,{variant:`destructive`,disabled:!i,onClick:()=>m(!0),children:[(0,G.jsx)(gi,{}),` Terminate`]})]})]}),(0,G.jsx)(hc,{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,G.jsx)(vc,{open:h!==null,setOpen:e=>{e||g(null)},action:h??`restart`,targetName:e.name,scope:`cluster`,isPending:o,onConfirm:S}),(0,G.jsx)(Gs,{typeOfThingBeingDeleted:`cluster`,transitiveVerb:`Terminate`,presentParticiple:`Terminating`,nameOfThingBeingDeleted:e.name,isModalOpen:p,setIsModalOpen:m,deletionConfirmed:x,deletionPending:c})]})}function Rp(){let{clusterId:e}=I({strict:!1}),t=re(),n=ke(),{data:r}=L(Ko(e,!0)),{user:i,isLoading:a}=Ie(e),{view:o,update:c}=ac(r?.organizationId,r?.id),[l,f]=(0,K.useState)(!1),p=r?.domains?.[0]?.domain||r?.fqdn||``,[m,h]=Dc(p,p?`https://${p}`:``),_=r?`/${r.organizationId}/${r.id}`:``,v=(0,K.useCallback)(async()=>{if(r){f(!0);try{await u.establishFabricConnectAuth({id:r.id,operationsUrl:s(r)}),await t.invalidate()}catch{H.error(`Could not connect to this cluster through Fabric Connect.`)}finally{f(!1)}}},[r,t]),y=(0,K.useCallback)(()=>{r&&(u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1)),n({to:`${_}/sign-in`})},[_,r,n]),b=(0,K.useCallback)(async()=>{if(r){try{await d({instanceClient:g({id:r.id}),entityId:r.id})}catch{}u.setUserForEntity(r,null),u.flagForFabricConnect(r.id,!1),u.flagForBasicAuth(r.id,null),await t.invalidate()}},[r,t]);if(!r)return(0,G.jsx)(Bp,{children:(0,G.jsx)(Vp,{})});if(!o)return(0,G.jsx)(fe,{to:`/${r.organizationId}`,replace:!0});if(fc(r))return(0,G.jsx)(zp,{cluster:r});if(!r.fqdn)return(0,G.jsx)(fe,{to:`${_}/instances`,replace:!0});if(r.resetPassword)return c?(0,G.jsx)(fe,{to:`${_}/${r.status&&jo.includes(r.status)&&Wo(r)?`finish-setup`:`starting-up`}`,replace:!0}):(0,G.jsx)(Bp,{children:(0,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)(ni,{className:`size-12 text-muted-foreground mx-auto mb-4`}),(0,G.jsx)(`h1`,{className:`text-xl font-medium mb-2 text-foreground`,children:`Pending Owner Setup`}),(0,G.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 x=u.checkForFabricConnect(r.id),S=!!i,C=u.getLastConnectMode(r.id),w=(r.instances??[]).filter(e=>e.status&&!Mo.includes(e.status)).length,T=r.instances??[],E=!!r.status&&jo.includes(r.status)&&T.length>0&&T.every(e=>e.safeMode);return(0,G.jsxs)(Bp,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)(ni,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:r.name}),(0,G.jsx)(Hp,{status:r.status}),E&&(0,G.jsx)(Up,{})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,G.jsxs)(`span`,{children:[w,` `,w===1?`instance`:`instances`]}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,G.jsxs)(`a`,{href:`https://${p}`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 hover:text-foreground hover:underline`,children:[p,(0,G.jsx)(gr,{className:`size-3`})]}),(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{"aria-label":`Copy cluster URLs`,className:`rounded-md p-1 -m-1 hover:bg-accent/60 hover:text-foreground`,children:(0,G.jsx)(fr,{className:`size-3.5`})}),(0,G.jsxs)(Di,{align:`start`,children:[(0,G.jsx)(Oi,{onClick:m,children:`Copy host name`}),(0,G.jsx)(Oi,{onClick:h,children:`Copy API URL`})]})]})]})]}),(0,G.jsx)(Lp,{cluster:r})]}),a?(0,G.jsx)(Vp,{}):S?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(rr,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:x?`Connected via Fabric Connect`:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,x?`through your Harper account`:`session cookie`]})]}),(0,G.jsxs)(B,{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,G.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,G.jsx)(Xr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Gn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:[x&&(0,G.jsx)(`button`,{type:`button`,onClick:y,className:`text-muted-foreground hover:text-foreground transition-colors`,children:`Switch to direct sign-in`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:x?`Disconnect`:`Direct sign out`})]})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:[c&&!fc(r)&&(0,G.jsx)(Wp,{icon:xi,title:`Fabric Connect`,description:`Connect through your Harper account. No cluster credentials needed.`,pill:C===`fabric`?`last`:C?void 0:`recommended`,children:(0,G.jsx)(P,{className:`w-full`,disabled:l,onClick:()=>void v(),children:l?(0,G.jsx)(Pr,{className:`animate-spin`}):`Fabric Connect`})}),(0,G.jsx)(Wp,{icon:kr,title:`Direct sign-in`,description:`Sign in with this cluster's Harper username and password.`,pill:C===`direct`?`last`:void 0,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:y,children:`Direct sign-in`})})]})]})]})}function zp({cluster:e}){let t=re(),n=ke(),r=`/${e.organizationId}/${e.id}`,i=(0,K.useMemo)(()=>(e.instances??[]).filter(e=>e.status&&!Mo.includes(e.status)).sort(Gc),[e.instances]),a=i.at(0),{user:o,isLoading:s}=Ie(a?.id),c=!!a&&!!o,l=(0,K.useCallback)(()=>{a&&n({to:`${r}/instance/${a.id}/sign-in`})},[r,a,n]),f=(0,K.useCallback)(async()=>{if(a){try{await d({instanceClient:g({id:a.id,operationsUrl:p(a)}),entityId:a.id})}catch{}u.setUserForEntity(a,null),u.flagForBasicAuth(a.id,null),await t.invalidate()}},[a,t]);return(0,G.jsxs)(Bp,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 mb-6`,children:[(0,G.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,G.jsx)(ni,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light text-foreground`,children:e.name}),(0,G.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,G.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:(0,G.jsxs)(B,{to:`${r}/instances`,className:`hover:text-foreground hover:underline`,children:[i.length,` `,i.length===1?`instance`:`instances`]})})]})]}),a?s?(0,G.jsx)(Vp,{}):c?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-sm`,children:[(0,G.jsx)(rr,{className:`size-4 text-green shrink-0`}),(0,G.jsx)(`span`,{className:`font-medium text-green`,children:`Signed in directly`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,a.name||a.instanceFqdn]})]}),(0,G.jsxs)(B,{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,G.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,G.jsx)(Xr,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-lg font-medium text-foreground`,children:`Enter cluster`}),(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Open the studio — apps, databases, APIs, logs, and config.`})]}),(0,G.jsx)(Gn,{className:`size-5 text-muted-foreground transition-transform group-hover:translate-x-1`})]}),(0,G.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-4 text-sm`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>void f(),className:`text-muted-foreground hover:text-destructive transition-colors`,children:`Direct sign out`})})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground mb-3`,children:`Connect to this cluster`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3.5`,children:(0,G.jsx)(Wp,{icon:kr,title:`Direct sign-in`,description:`Sign in with this instance's Harper username and password.`,children:(0,G.jsx)(P,{className:`w-full`,variant:`outline`,onClick:l,children:`Direct sign-in`})})})]}):(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This cluster has no instances yet. Register one from the`,` `,(0,G.jsx)(B,{to:`${r}/instances`,className:`underline hover:text-foreground`,children:`Instances`}),` page.`]})]})}function Bp({children:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(Mc,{children:(0,G.jsx)(`div`,{className:`max-w-3xl`,children:e})})]})}function Vp(){return(0,G.jsx)(`div`,{className:`flex justify-center py-10 text-muted-foreground`,children:(0,G.jsx)(Pr,{className:`size-6 animate-spin`})})}function Hp({status:e}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs px-2.5 py-0.5 rounded-full ${e&&jo.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`}`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e?e.charAt(0)+e.slice(1).toLowerCase():`Unknown`]})}function Up(){return(0,G.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,G.jsx)(Mr,{className:`size-3`}),`Safe mode`]})}function Wp({icon:e,title:t,description:n,pill:r,children:i}){return(0,G.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,G.jsx)(`span`,{className:`absolute -top-2.5 left-4 rounded-full bg-card`,children:(0,G.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,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),r===`last`?`Last used`:`Recommended`]})}),(0,G.jsx)(e,{className:`size-6 text-primary dark:text-violet-300 mb-2`}),(0,G.jsx)(`div`,{className:`text-[15px] font-medium text-foreground mb-1`,children:t}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-normal mb-4`,children:n}),i]})}function Gp({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(Mc,{children:(0,G.jsx)(`div`,{className:t,children:e})})]})}var Kp=new Set([`com`,`co`,`org`,`net`,`edu`,`gov`,`mil`,`me`,`biz`,`info`,`ac`,`or`,`ne`,`go`,`lg`,`asn`,`id`,`nom`,`sch`,`ltd`,`plc`]);function qp(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&&Kp.has(r)?3:2;return t.length<=i?`@`:t.slice(0,-i).join(`.`)}function Jp({cluster:{fqdn:e},domain:{domain:t,id:n}}){let r=qp(t),[i,a,o]=Dc(r,e||``,n);return(0,G.jsxs)(`div`,{className:`grid gap-4 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:i,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:a,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]})}),(0,G.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 Yp({certificate:e,domain:t,cluster:n}){let r=qp(t.domain),[i,a,o]=Dc(r,n.fqdn||``,t.id),s=(0,K.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,G.jsxs)(`div`,{className:`w-full max-w-2xl border border-border/50 rounded-md p-4 bg-gray-900/20`,children:[(0,G.jsxs)(`div`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`w-full h-1.5 rounded-full overflow-clip flex shadow-sm bg-gray-800`,children:(0,G.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,G.jsx)(`div`,{className:`text-[10px] text-muted-foreground font-light mt-1 italic`,children:s.text})]}),(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] text-sm`,children:[(0,G.jsx)(`div`,{className:`col-span-1 text-xs text-muted-foreground`,children:`CNAME:`}),(0,G.jsxs)(`div`,{className:`col-span-1 flex gap-2 items-center flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[150px]`,title:r,children:r}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:i,title:`Copy Name`,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]}),(0,G.jsx)(Xp,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-xs`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fqdn||``,children:n.fqdn}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-4 w-4 p-0`,onClick:a,title:`Copy Target`,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]})]}),(0,G.jsx)(`div`,{className:`col-span-1 text-[10px] text-muted-foreground`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted px-2 py-0.5 rounded text-[10px] text-muted-foreground italic`,children:[(0,G.jsx)(`span`,{className:`truncate max-w-[200px]`,children:t.id}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-3 w-3 p-0`,onClick:o,title:`Copy ID`,children:(0,G.jsx)(fr,{className:`w-2.5 h-2.5`})})]})})]})]})}function Xp(){return(0,G.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,G.jsx)(`path`,{d:`M5 12h14`}),(0,G.jsx)(`path`,{d:`m12 5 7 7-7 7`})]})}function Zp(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:()=>Qp(e)})}async function Qp({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 $p(e){return z({queryKey:[e,`ChallengeCertificate`],queryFn:async()=>{if(!e)return[];let{data:t}=await Qp({searchAttribute:`domain`,entityId:e,databaseName:`data`,tableName:`ChallengeCertificate`,sort:{attribute:`domain`,descending:!0},instanceClient:g({id:e,forceFabricConnect:!0}),onlyIfCached:!1,pageIndex:0,pageSize:100});return t},enabled:!!e,refetchInterval:Ln(5e3),retry:Pn()})}function em(e){return L($p(e))}function tm({domain:{challengeToken:e,challengeTxtRecord:t,domain:n,id:r},cluster:{fqdn:i}}){let a=qp(n),[o,s,c,l,u]=Dc(t,e,a,i||``,r);return(0,G.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 md:grid-cols-[80px_1fr] pb-6`,children:[(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TXT`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:o,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Content:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:s,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.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,G.jsx)(`div`,{className:`col-span-1`,children:`Type:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`CNAME`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Name:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:c,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`TTL:`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Auto`}),(0,G.jsx)(`div`,{className:`col-span-1`,children:`Target:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted rounded-md px-3 py-1 flex-1 overflow-hidden`,children:[(0,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:l,children:(0,G.jsx)(fr,{className:`w-3.5 h-3.5`})})]})}),(0,G.jsx)(`div`,{className:`col-span-1 text-xs`,children:`Domain ID:`}),(0,G.jsx)(`div`,{className:`col-span-1 flex gap-2 items-center`,children:(0,G.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,G.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,G.jsx)(P,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:u,children:(0,G.jsx)(fr,{className:`w-3 h-3`})})]})}),(0,G.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 nm({clusterId:e,domainIds:t,generateDomainCerts:n}){let{data:r}=await M.put(`/Cluster/${e}`,{domainIds:t,generateDomainCerts:n},{timeout:0});return r}function rm(){return F({mutationFn:e=>nm(e)})}O.object({domainId:O.string()});async function im(e){let{data:t}=await M.delete(`/Domain/${e.domainId}`);return t}function am(){return F({mutationFn:e=>im(e)})}function om(e){return[...new Set(e)]}var sm=de();function cm(e,t,n){let{data:r}=em(e.id),i=(0,K.useMemo)(()=>!!r?.some(e=>!e.issueDate||e.inProgress),[r]),{mutate:a,isPending:o}=rm(),{mutate:s,isPending:c}=am(),l=o||c,u=(0,K.useCallback)((t,n)=>{if(!zo(e.status)){H.error(`Cluster is currently `+e.status,{description:`To bind a domain, it must be running.`});return}a({clusterId:e.id,domainIds:om((e.domainIds?.slice()||[]).concat([t])),generateDomainCerts:n},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain bound!`+(n?` Certificates are being generated in the background now.`:``))}})},[a,e]),d=(0,K.useCallback)(t=>{s({domainId:t},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[e.organizationId,`domains`],refetchType:`active`}),H.success(`Domain removed!`)}})},[s]),f=(0,K.useCallback)(t=>{a({clusterId:e.id,domainIds:(e.domainIds?.slice()||[]).filter(e=>e!==t),generateDomainCerts:!1},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[e.organizationId],refetchType:`active`}),H.success(`Domain unbound!`)}})},[s]);return(0,K.useMemo)(()=>[sm.display({id:`select`,header:`Bind`,size:50,cell:r=>{let a=r.row.original;return a.status===`ACTIVE`&&!a.clusterId&&!fc(e)?(0,G.jsx)(`label`,{className:`p-10 -m-10`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:t.includes(a.id),onChange:()=>n(a.id),disabled:l||i})}):null}}),sm.display({header:`Domains`,id:`domain`,enableSorting:!1,size:150,cell:e=>{let t=e.row.original;return(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:t.domain}),(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,className:`text-muted-foreground text-xs`,disabled:l||!!t.clusterId,onClick:()=>d(t.id),children:`Remove Domain`})]})}),(0,G.jsx)(Va,{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!`})]})}}),sm.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{children:`Bound to this cluster`}),i&&(!i.issueDate||i.inProgress)&&(0,G.jsx)(`div`,{className:`py-2`,children:(0,G.jsx)(Yp,{certificate:i,domain:n,cluster:e})}),(0,G.jsx)(P,{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,G.jsx)(tm,{domain:n,cluster:e}):fc(e)?`Cannot be associated with this self-managed cluster.`:n.status===`ACTIVE`&&!n.clusterId?(0,G.jsx)(Jp,{cluster:e,domain:n}):n.status}})],[e,u,l,r,i,t,n])}var lm=O.object({domain:O.string(),organizationId:O.string()});async function um(e){let{data:t}=await M.post(`/Domain/`,e);return t}function dm(){return F({mutationFn:e=>um(e)})}async function fm(e){let{data:t}=await M.post(`/Domain/${e}/validate`);return t}async function pm(e){let{data:t}=await M.get(`/Domain/?organizationId=${e}`);return t}function mm(e){return z({queryKey:[e,`domains`],queryFn:()=>pm(e)})}function hm(){let{organizationId:e,clusterId:t}=I({strict:!1}),{data:n}=oe(Ko(t,!0)),{update:r}=ic(e),{data:i,refetch:a,isFetching:s,isRefetching:c}=L(mm(e)),l=(0,K.useMemo)(()=>i?.filter(e=>e.status===`PENDING_VALIDATION`)||[],[i]),[u]=(0,K.useState)({attribute:`domain`,descending:!1}),d=(0,K.useMemo)(()=>[{desc:u.descending,id:u.attribute}],[u]),f=Wd(a),[p,m]=(0,K.useState)([]),h=(0,K.useCallback)(e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{mutate:g,isPending:_}=rm(),v=(0,K.useCallback)(()=>{if(!zo(n.status)){H.error(`Cluster is currently `+n.status,{description:`To bind a domain, it must be running.`});return}g({clusterId:n.id,domainIds:om((n.domainIds?.slice()||[]).concat(p)),generateDomainCerts:!0},{onSuccess:()=>{Tn.invalidateQueries({queryKey:[n.organizationId],refetchType:`active`}),H.success(`Domain(s) bound! Certificates are being generated in the background now.`),m([])}})},[n,p,g]),{mutateAsync:y,isPending:b}=dm(),x=vt({resolver:V(lm),defaultValues:{domain:``,organizationId:e}}),S=(0,K.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 a(),H.success(`${o(t.length,`Domain`,`Domains`)} added! Please add the txt record above to your domain registrar.`)}},[y,x,a]),C=(0,K.useCallback)(async()=>{let e=`Validating ${o(l.length,`domain`,`domains`)}...`,t=`validatingDomains`,n=0,r=0;for(let i of l)try{H.loading(e,{description:`${n++} of ${l.length} checked`,id:t}),await fm(i.id)}catch{r+=1}r>0?H.error(`Validation failed!`,{description:`Please make sure the TXT record has been put in place. You may need to wait a bit for the DNS change to propagate.`,id:t}):(await a(),H.success(`Validation succeeded!`,{description:`Please take a look at the next steps for newly verified domains.`,id:t}))},[l]),w=cm(n,p,h),T=x.watch(`domain`),E=(0,K.useMemo)(()=>typeof T==`string`&&T.trim().split(`.`).length===2,[T]),D=(0,K.useCallback)(()=>{typeof T==`string`&&x.setValue(`domain`,`${T.trim()}, www.${T.trim()}`)},[T,x]);return(0,G.jsx)(zd,{data:i||[],isFetching:s||c,columns:w,sortingState:d,children:(0,G.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,G.jsx)(q,{...x,children:(0,G.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,G.jsx)(Y,{control:x.control,name:`domain`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex-1`,children:[(0,G.jsx)(Z,{className:`pb-1`,children:`New Domain Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,enterKeyHint:`done`,autoComplete:`off`,...e})}),E&&(0,G.jsxs)(`div`,{className:`mt-1 flex gap-4`,children:[`Adding an apex domain?`,(0,G.jsx)(P,{variant:`positiveOutline`,type:`button`,onClick:D,children:`Add www as well`})]}),(0,G.jsx)(Q,{children:(0,G.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,G.jsxs)(`div`,{className:`flex-0 self-start flex gap-1 md:pt-6.5`,children:[(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:b,children:[(0,G.jsx)(Jr,{}),` Add`]}),l.length>0&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:C,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,G.jsx)(Nr,{}),` `,(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`V`}),`alidate`]})]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:f,accessKey:`r`,type:`button`,disabled:s||c,children:[(0,G.jsx)(Yr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})]})]})}),p.length>0&&(0,G.jsx)(`div`,{className:`flex-0 self-start md:pt-6.5`,children:(0,G.jsxs)(P,{variant:`submit`,onClick:v,disabled:_,children:[(0,G.jsx)($r,{}),` Bind `,o(p.length,`Domain`,`Domains`)]})})]})})}function gm(){return(0,G.jsx)(Gp,{className:`flex flex-col justify-start max-w-4xl`,children:(0,G.jsx)(hm,{})})}var _m=j({username:Yo,role:S().nonempty({error:`Please select a role.`}),password:Jo.min(8,{error:`Password must be at least 8 characters long.`}),confirmPassword:S()}).refine(e=>e.password===e.confirmPassword,{error:`Passwords do not match.`,path:[`confirmPassword`]});async function vm(e){await M.patch(`/ResetPasswordUpdater/${e}`)}async function ym(e){let{instanceClient:t,...n}=e,{data:r}=await t.post(`/`,{operation:`add_user`,...n});return r}function bm(){return F({mutationFn:ym})}async function xm({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 Sm(){return F({mutationFn:xm})}async function Cm({username:e,instanceClient:t}){let{data:n}=await t.post(`/`,{operation:`drop_user`,username:e});return n}function wm(){return F({mutationFn:Cm})}async function Tm({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 Po({username:t,password:i,instanceClient:o,entityId:e});return a.instanceClient&&(o=a.instanceClient),n===`HDB_ADMIN`?await xm({username:n,password:r,instanceClient:o}):(await ym({username:n,password:r,role:`super_user`,active:!0,instanceClient:o}),await Po({username:n,password:r,instanceClient:o,entityId:e}),await Cm({username:f,instanceClient:o})),await vm(e),a}catch(t){throw await d({entityId:e,instanceClient:o}),t}}function Em(){return F({mutationFn:Tm})}function Dm(){let{user:e}=Le(),{clusterId:t}=I({strict:!1}),{data:n}=L(Ko(t,!0)),r=ke(),i=(0,K.useMemo)(()=>s(n),[n]),a=Mn({operationsUrl:i}),{redirect:o}=le({strict:!1}),c=re(),l=vt({resolver:V(_m),defaultValues:{confirmPassword:``,password:``,role:`super_user`,username:e?.email??``}}),{setFocus:d,control:p,handleSubmit:m}=l;(0,K.useEffect)(()=>{d(`password`)},[d]);let h=n?.instances?.find(e=>e.tempPassword)?.tempPassword,g=Wo(n),{mutate:_,isPending:v}=Em(),y=(0,K.useCallback)(async e=>{if(!i){H.error(`Cluster is not yet fully loaded, please wait a moment before trying to sign in.`);return}if(!g){H.error(`Some instances are still starting up. You can create your admin user once they are all running.`);return}_({instanceClient:a,clusterId:t,newPassword:e.password,tempPassword:h,initialUsername:f,desiredUsername:e.username},{onSuccess:async({message:e,user:t})=>{H.success(e),u.setUserForEntity(n,t),c.invalidate(),await r({to:o?.startsWith(`/`)?o:`../`})}})},[n,t,a,g,r,i,o,c,_,h]);return n&&!n.resetPassword?(0,G.jsx)(fe,{to:`../sign-in`,replace:!0}):n&&!g?(0,G.jsx)(fe,{to:`../starting-up`,replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Eo,{})}),(0,G.jsx)(`div`,{className:`items-center justify-center flex mt-32 py-4 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsxs)(`div`,{className:`text-foreground w-xs`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-light`,children:`Create Admin User`}),(0,G.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,G.jsx)(q,{...l,children:(0,G.jsxs)(`form`,{id:`cluster-create-admin-form`,name:`cluster-create-admin-form`,onSubmit:m(y),className:`my-4`,children:[(0,G.jsx)(Y,{control:p,name:`username`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Username`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{autoComplete:`username`,type:`text`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`password`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:p,name:`confirmPassword`,render:({field:e})=>(0,G.jsxs)(X,{className:`my-4`,children:[(0,G.jsx)(Z,{children:`Confirm Password`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`password`,autoComplete:`new-password`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(P,{disabled:v,type:`submit`,variant:`submit`,className:`w-full my-2`,children:`Create Admin User`})]})}),(0,G.jsxs)(`p`,{className:`text-muted-foreground flex gap-2 align-middle`,children:[(0,G.jsx)(Un,{size:36,className:`flex-none`}),(0,G.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 Om({columns:e,data:t,renderRowWrapper:n}){let r=_e({data:t,columns:e,getCoreRowModel:Se()});return(0,G.jsx)(`div`,{className:`bg-card dark:bg-black-dark rounded-md`,children:(0,G.jsxs)(hn,{children:[(0,G.jsx)(vn,{children:r.getHeaderGroups().map(e=>(0,G.jsx)(fn,{className:`border-none`,children:e.headers.map(e=>(0,G.jsx)(dn,{className:`p-4`,style:{width:`${e.getSize()}%`},children:e.isPlaceholder?null:we(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(_n,{className:`bg-background dark:bg-black`,children:r.getRowModel().rows?.length?r.getRowModel().rows.map(e=>{let t=(0,G.jsx)(fn,{"data-state":e.getIsSelected()&&`selected`,className:`hover:bg-muted/10 data-[state=selected]:bg-muted`,children:e.getVisibleCells().map(e=>(0,G.jsx)(pn,{className:`p-4`,style:{width:`${e.column.getSize()}%`},children:we(e.column.columnDef.cell,e.getContext())},e.id))});return(0,G.jsx)(K.Fragment,{children:n?n(e.original,t):t},e.id)}):(0,G.jsx)(fn,{children:(0,G.jsx)(pn,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})})}function km(){return(0,G.jsx)(`div`,{className:`flex-col items-center justify-center px-16 space-y-3 text-center pt-30`,children:(0,G.jsx)(`p`,{children:`No instances found.`})})}async function Am({instance:e,instanceClient:t}){try{await d({instanceClient:t,entityId:e.id})}catch{}u.signOutLocally(e.id),e.clusterId&&u.signOutLocally(e.clusterId)}async function jm({instanceId:e,action:t,safeMode:n}){let r=n===void 0?{}:{safeMode:n},{data:i}=await M.post(`/HDBInstance/${e}/container/${t}`,r);return i}function Mm(){return F({mutationFn:jm})}var Nm={stop:`Stopping`,start:`Starting`,restart:`Restarting`};function Pm(e){let{clusterId:t}=I({strict:!1}),{mutateAsync:n,isPending:r}=Mm(),i=ae();return{run:(0,K.useCallback)(async(r,a)=>{let o=a?.label??Nm[r],s=e.name??e.id,c=H.loading(o,{description:`${o} ${s}. Status will update shortly.`,duration:3e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});try{await n({instanceId:e.id,action:r,safeMode:a?.safeMode}),t&&i.invalidateQueries({queryKey:[t]}),i.invalidateQueries({queryKey:[e.id]}),H.dismiss(c),H.success(`Request accepted`,{description:`${s} is ${o.toLowerCase()}. The status will update automatically.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}catch{H.dismiss(c)}},[t,e.id,e.name,n,i]),isPending:r}}function Fm({entityId:e,instanceClient:t},n){return z({queryKey:[`get_status`,e],staleTime:9e3,refetchInterval:Ln(1e4),retry:Pn(),retryDelay:1e4,throwOnError:!1,enabled:n,queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_status`});return e}})}function Im(e,t){return e?.systemStatus?.find(e=>e.id===t)?.status}async function Lm({instanceClient:e,id:t,status:n}){let{data:r}=await e.post(`/`,{operation:`set_status`,id:t,status:n});return r}function Rm(){return F({mutationFn:Lm,onSuccess:(e,t)=>Tn.invalidateQueries({queryKey:[`get_status`,t.entityId]})})}var zm=[`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`];function Bm(e,t,n){let{user:r}=Ie(e.id),i=(0,K.useMemo)(()=>p(e),[e]),a=Mn({operationsUrl:i}),{update:o}=sc(),s=u.checkForFabricConnect(e.id),c=W({operationsUrl:i,instanceId:e.id,forceFabricConnect:!0}),{data:l}=L(Fm(c,n&&o&&!Ro(e.status))),d=Im(l,`availability`)||`Unknown`,f=d===`Available`,m=d===`Unavailable`,{mutate:h,isPending:g}=Rm(),{run:_,isPending:v}=Pm(e),[y,b]=(0,K.useState)(null),x=e.instanceFqdn,S=yd({secure:e.operationsApiSecure?`true`:`false`,port:e.operationsApiPort,fqdn:e.instanceFqdn}),[C,w]=Dc(x??``,S),T=(0,K.useCallback)(async()=>{await Am({instance:e,instanceClient:a})},[e,a]),E=!!e.status&&zm.includes(e.status),D=!!r&&!s,O=E,k=!!x,A=o&&E&&(f||m),j=e.status===`RUNNING`,ee=e.status===`STOPPED`,te=o&&!t&&(j||ee),M=[O&&D&&{key:`direct-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)(ni,{className:`text-green`}),label:`Direct Connect`},O&&D&&{key:`direct-sign-out`,onClick:T,variant:`destructive`,icon:(0,G.jsx)(Lr,{}),label:`Direct Sign Out`},O&&!D&&o&&!t&&{key:`fabric-connect`,to:`../instance/${e.id}/`,icon:(0,G.jsx)(ni,{className:`text-green`}),label:`Fabric Connect`},O&&!D&&{key:`direct-sign-in`,to:`../instance/${e.id}/sign-in`,icon:(0,G.jsx)(Fr,{}),label:`Direct Sign In`},O&&k&&{type:`separator`,key:`copy-sep`},k&&{key:`copy-fqdn`,onClick:C,icon:(0,G.jsx)(sr,{}),label:`Copy Instance FQDN`},k&&{key:`copy-api`,onClick:w,icon:(0,G.jsx)(sr,{}),label:`Copy API URL`},(O||k)&&A&&{type:`separator`,key:`rotation-sep`},A&&f&&{key:`out-of-rotation`,variant:`destructive`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Unavailable`}),icon:(0,G.jsx)(ai,{}),label:`Bring out of rotation`},A&&m&&{key:`into-rotation`,disabled:g,onClick:()=>h({...c,id:`availability`,status:`Available`}),icon:(0,G.jsx)(ii,{}),label:`Bring back into rotation`},(O||k||A)&&te&&{type:`separator`,key:`container-sep`},te&&{type:`label`,key:`container-label`,className:`text-gray-600 text-xs`,label:`Container`},te&&ee&&{key:`container-start`,disabled:v,onClick:()=>void _(`start`,{safeMode:!1}),icon:(0,G.jsx)(qr,{}),label:`Start`},te&&ee&&{key:`container-start-safe`,disabled:v,onClick:()=>b(`start`),icon:(0,G.jsx)(Mr,{}),label:`Start in safe mode`},te&&j&&{key:`container-restart`,disabled:v,onClick:()=>void _(`restart`,{safeMode:!1}),icon:(0,G.jsx)(Qr,{}),label:`Restart`},te&&j&&{key:`container-restart-safe`,disabled:v,onClick:()=>b(`restart`),icon:(0,G.jsx)(Mr,{}),label:`Restart in safe mode`},te&&j&&{key:`container-stop`,variant:`destructive`,disabled:v,onClick:()=>void _(`stop`),icon:(0,G.jsx)(ci,{}),label:`Stop`}].filter(Fn),N=(0,G.jsx)(vc,{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 M.length?{items:[{type:`label`,key:`label`,className:`text-gray-600 text-xs`,label:`Options`},{type:`separator`,key:`label-sep`},...M],dialog:N}:{items:[],dialog:N}}function Vm({instance:e,isSelfManaged:t}){let[n,r]=(0,K.useState)(!1),{items:i,dialog:a}=Bm(e,t,n);return i.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ti,{open:n,onOpenChange:r,children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Instance options`,children:(0,G.jsx)(hr,{})})}),(0,G.jsx)(Di,{align:`end`,className:`min-w-48`,children:ec(i,`dropdown`)})]}),a]}):null}function Hm({isSelfManaged:e,instance:t}){let{user:n,isLoading:r}=Ie(t.id),i=Mn({operationsUrl:(0,K.useMemo)(()=>p(t),[t])}),{update:a}=sc(),o=u.checkForFabricConnect(t.id),s=(0,K.useCallback)(async()=>{await Am({instance:t,instanceClient:i})},[t,i]);return Ro(t.status)?(0,G.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:`—`}):r||!t.status||![`CLONE_READY`,`RUNNING`,`UPDATED`,`PENDING_UPGRADE`].includes(t.status)?(0,G.jsx)(Pr,{className:`animate-spin`,color:`gray`}):!n||o?(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[a&&!e&&(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Connect to ${t.name} instance`,title:`Connect to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Fabric Connect`})}),(0,G.jsx)(B,{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,G.jsx)(P,{variant:a?`defaultOutline`:`positiveOutline`,children:`Direct Sign In`})})]}):(0,G.jsxs)(`span`,{className:`flex gap-4`,children:[(0,G.jsx)(B,{to:`../instance/${t.id}/`,className:`text-sm`,"aria-label":`Go to ${t.name} instance`,title:`Go to ${t.name} instance`,children:(0,G.jsx)(P,{variant:`positiveOutline`,children:`Direct Connect`})}),(0,G.jsx)(P,{variant:`destructiveOutline`,className:`text-sm`,"aria-label":`Sign out from ${t.name} instance`,title:`Sign out from ${t.name} instance`,onClick:s,children:`Direct Sign Out`})]})}function Um({instance:e,isSelfManaged:t,children:n}){let[r,i]=(0,K.useState)(!1),{items:a,dialog:o}=Bm(e,t,r);return a.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ks,{onOpenChange:i,children:[(0,G.jsx)(qs,{asChild:!0,children:n}),(0,G.jsx)(Js,{className:`min-w-48`,children:ec(a,`context`)})]}),o]}):(0,G.jsx)(G.Fragment,{children:n})}function Wm({instance:e,index:t}){let{update:n}=sc(),r=W({operationsUrl:(0,K.useMemo)(()=>p(e),[e]),instanceId:e.id,forceFabricConnect:!0}),{mutate:i,isPending:a}=Rm(),[o,s]=(0,K.useState)(!1);(0,K.useEffect)(()=>{let e=setTimeout(()=>s(!0),t*500);return()=>clearTimeout(e)},[t]);let c=Ro(e.status),{data:l,isLoading:u,isFetching:d}=L(Fm(r,o&&n&&!c)),f=Im(l,`availability`)||`Unknown`,m=f===`Available`,h=f===`Unavailable`;return n?c?(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(`span`,{className:`inline-block size-4 rounded-full bg-muted-foreground/40`,"aria-label":`Not running`})}),(0,G.jsx)(Va,{children:`Not running`})]})}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:u||!o||d&&!l?(0,G.jsx)(Pr,{className:`animate-spin size-5 text-muted-foreground`}):(0,G.jsx)(qi,{variant:m?`success`:h?`destructive`:`default`,className:`size-4 rounded-full p-0`,children:(0,G.jsx)(`span`,{className:`sr-only`,children:m?`Online`:`Offline`})})})}),(0,G.jsxs)(Va,{children:[d&&l?`Refreshing... `:``,f]})]}),n&&(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[m&&(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`destructiveGhost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Unavailable`}),disabled:a,children:a?(0,G.jsx)(Pr,{className:`animate-spin size-4`}):(0,G.jsx)(ai,{className:`size-4`})})}),(0,G.jsx)(Va,{children:`Bring out of rotation`})]}),h&&(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i({...r,id:`availability`,status:`Available`}),disabled:a,children:a?(0,G.jsx)(Pr,{className:`animate-spin size-4`}):(0,G.jsx)(ii,{className:`size-4`})})}),(0,G.jsx)(Va,{children:`Bring back into rotation`})]})]})]}):null}function Gm(){let{clusterId:e}=I({strict:!1}),{data:t,isLoading:n}=L(Ko(e,!0)),r=fc(t),i=(0,K.useMemo)(()=>[{id:`instanceActions`,size:1,minSize:1,cell:e=>(0,G.jsx)(`div`,{className:`flex justify-end gap-2 items-center`,children:(0,G.jsx)(Hm,{isSelfManaged:r,instance:e.row.original})})},r&&{accessorKey:`instanceFqdn`,size:90,header:`URL`,cell:e=>yd({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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Wm,{instance:e.row.original,index:e.row.index}),t?(0,G.jsx)(qi,{variant:Lo(t),children:wo(t)}):null,e.row.original.safeMode&&!Ro(e.row.original.status)?(0,G.jsxs)(qi,{variant:`warning`,title:`Running in safe mode — user apps/components are not loaded`,children:[(0,G.jsx)(Mr,{}),`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,G.jsxs)(G.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,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(Vm,{isSelfManaged:r,instance:e.row.original})})}].filter(Fn),[r]),a=(0,K.useMemo)(()=>t?.instances?t.instances.filter(e=>e.status&&!Mo.includes(e.status)).sort(Gc):[],[t]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(Mc,{children:(0,G.jsx)(Ut,{className:`p-0 min-h-96`,children:(0,G.jsx)(Vt,{className:`p-0 min-h-96`,children:n?(0,G.jsx)(Hu,{}):a.length?(0,G.jsx)(Om,{data:a,columns:i,renderRowWrapper:(e,t)=>(0,G.jsx)(Um,{instance:e,isSelfManaged:r,children:t})}):(0,G.jsx)(km,{})})})})]})}function Km(){let{clusterId:e}=I({strict:!1}),{immediate:t}=le({strict:!1}),n=t===!0||t===`true`,{data:r,isLoading:i}=L(Ko(e,2e3)),a=r?.status,o=(0,K.useMemo)(()=>a&&jo.includes(a),[a]);return i||!r?(0,G.jsx)(Gp,{className:`flex justify-center`,children:(0,G.jsx)(Hu,{})}):o?(0,G.jsx)(Gp,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`All done!`}),(0,G.jsx)(_c,{cluster:r,forceProgressBarVisible:!0}),(0,G.jsx)(`p`,{children:`Your cluster finished updating, and is ready for interaction.`}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(pc,{cluster:r})})]})}):(0,G.jsx)(Gp,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(_c,{cluster:r,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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 qm({children:e,className:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ws,{}),(0,G.jsx)(`div`,{className:_(`mt-32 px-4 py-4 md:px-12 min-h-[calc(100vh-(--spacing(32)))] flex justify-center`,t),children:e})]})}function Jm(){let e=re(),{clusterId:t}=I({strict:!1}),{data:n,isLoading:r}=L(Ko(t,2e3)),i=n?.status,a=(0,K.useMemo)(()=>i&&jo.includes(i)&&Wo(n),[i,n]),o=Bo(i),[,s]=jn(On.SavedClusterState,null),c=(0,K.useCallback)(()=>{s(n),e.navigate({to:`/${n.organizationId}/new-cluster`})},[n,e,s]);return r||!n?(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsx)(Hu,{})}):o?(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4 items-center`,children:[(0,G.jsx)(cr,{className:`w-24 h-24`}),(0,G.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,G.jsx)(Ac,{}),` if you want more help.`]}),(0,G.jsx)(P,{type:`button`,variant:`positiveOutline`,onClick:c,children:`Try Again`})]})}):a?(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`It's ready!`}),(0,G.jsx)(_c,{cluster:n,forceProgressBarVisible:!0}),(0,G.jsxs)(`p`,{children:[`Let's set up your secure, browser-to-cluster connection now.`,` `,(0,G.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,G.jsx)(`em`,{children:`Direct Connect`}),`! Once you create your user, you will have the option to`,` `,(0,G.jsx)(`em`,{children:`Fabric Connect`}),` from your Fabric account without having to sign in again.`]})]}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(pc,{cluster:n})})]})}):(0,G.jsx)(qm,{className:`flex justify-center`,children:(0,G.jsxs)(`div`,{className:`center max-w-2xl flex flex-col gap-4`,children:[(0,G.jsx)(`h1`,{className:`text-xl text-center`,children:`Here we go!`}),(0,G.jsx)(_c,{cluster:n,forceProgressBarVisible:!0}),(0,G.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,G.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,G.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.`]})]})]})})}R({getParentRoute:()=>Ip,path:`instances`,head:()=>({meta:[{title:`Instances — Harper Fabric`}]}),component:Gm}),R({getParentRoute:()=>Ip,path:`starting-up`,head:()=>({meta:[{title:`Starting Up — Harper Fabric`}]}),component:Jm}),R({getParentRoute:()=>Ip,path:`scaling`,head:()=>({meta:[{title:`Scaling — Harper Fabric`}]}),component:Km}),R({getParentRoute:()=>Ip,path:`domains`,head:()=>({meta:[{title:`Domains — Harper Fabric`}]}),component:gm});function Ym({location:e,params:t}){let n=u.checkForFabricConnect(t.clusterId);if(u.getConnectionById(t.clusterId).user&&!n){let t=e?.search?.redirect;throw ve({to:t?.startsWith(`/`)?t:`../`})}}function Xm({location:e,params:t}){let n=u.checkForFabricConnect(t.instanceId);if(u.getConnectionById(t.instanceId).user&&!n){let t=e?.search?.redirect;throw ve({to:t?.startsWith(`/`)?t:`../`})}}R({getParentRoute:()=>Ip,path:`sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:ns,beforeLoad:Ym}),R({getParentRoute:()=>Ip,path:`instance/$instanceId/sign-in`,head:()=>({meta:[{title:`Sign In — Harper Fabric`}]}),component:ns,beforeLoad:Xm}),R({getParentRoute:()=>Ip,path:`finish-setup`,head:()=>({meta:[{title:`Create Admin User — Harper Fabric`}]}),component:Dm}),R({getParentRoute:()=>Ip,path:`/`,head:()=>({meta:[{title:`Cluster — Harper Fabric`}]}),component:Rp});function Zm(e){return R({getParentRoute:()=>e,path:`apis`,head:()=>({meta:[{title:`APIs — Harper Fabric`}]})}).lazy(()=>Me(()=>import(`./index.lazy-Dx3MpyDC.js`).then(e=>e.route),__vite__mapDeps([24,1,2,3,4,5,6,7,25,11,26,27,28,29])))}function Qm(e,t){return[R({getParentRoute:()=>e,path:t===`cluster`?`apps`:`/`,head:()=>({meta:[{title:`Applications — Harper Fabric`}]}),component:be(()=>Me(()=>import(`./applications-D03NA7wW.js`),__vite__mapDeps([30,1,27,3,2,4,5,6,7,31,8,11,10,12,13,14,25,15,32,33,26,34,35,18,19,16,28,23,36])),`ApplicationsEditor`)})]}async function $m({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`list_certificates`});return t}function eh(e){return z({queryKey:[e.entityId,`list_certificates`],queryFn:()=>$m(e)})}var th=[{header:`Certificate Name`,accessorKey:`name`,enableSorting:!0},{header:`Issuer`,accessorKey:`details.issuer`,enableSorting:!0},de().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 nh({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`add_certificate`,...t});return n}var rh=j({name:S().min(1,`Name is required`),certificate:S().min(1,`Certificate is required`),private_key:S().optional(),is_authority:E().default(!1),hosts:S().optional(),uses:S().optional()});function ih(){return F({mutationFn:({instanceParams:e,certificateParams:t})=>nh(e,t)})}function ah({isModalOpen:e,onChangesSaved:t,setIsModalOpen:n}){let r=vt({resolver:V(rh),defaultValues:{name:``,certificate:``,private_key:``,is_authority:!1,hosts:``,uses:``}}),i=W(),{mutate:a,isPending:o}=ih(),s=(0,K.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(),H.success(`Certificate added successfully!`),n(!1)}})},[a,r,i,t,n]),c=(0,K.useCallback)(()=>{r.reset(),n(!1)},[r,n]);return(0,G.jsx)(Gt,{onOpenChange:n,open:e,children:(0,G.jsx)(Xt,{"aria-describedby":void 0,children:(0,G.jsx)(q,{...r,children:(0,G.jsxs)(`form`,{id:`instance-add-certificate-form`,name:`instance-add-certificate-form`,onSubmit:r.handleSubmit(s),className:`grid gap-4 my-4`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsx)(en,{children:`Add New Certificate`}),(0,G.jsx)(an,{children:`Enter the details of your Certificate below.`})]}),(0,G.jsx)(Y,{control:r.control,name:`name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Name`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoFocus:!0,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`is_authority`,render:({field:e})=>(0,G.jsxs)(X,{className:`flex flex-row items-center justify-between rounded-lg border border-gray-800 p-3 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`space-y-0.5`,children:(0,G.jsx)(Z,{children:`Is Authority`})}),(0,G.jsx)(J,{children:(0,G.jsx)(yf,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,G.jsx)(Y,{control:r.control,name:`certificate`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Certificate`}),(0,G.jsx)(J,{children:(0,G.jsx)(yn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`hosts`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Hosts (optional)`}),(0,G.jsx)(Ju,{children:`Comma-separated list of hostnames this certificate is valid for.`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. example.com, *.example.com`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`uses`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Uses (optional)`}),(0,G.jsx)(Ju,{children:`Comma-separated list of intended uses, e.g. "https, operations, wss".`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`text`,autoComplete:`off`,autoCapitalize:`off`,placeholder:`e.g. https, operations, wss`,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:r.control,name:`private_key`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{className:`pb-1`,children:`Private Key (optional)`}),(0,G.jsx)(Ju,{children:`PEM formatted private key string.`}),(0,G.jsx)(J,{children:(0,G.jsx)(yn,{autoComplete:`off`,autoCapitalize:`off`,rows:5,...e})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{variant:`destructiveOutline`,type:`button`,onClick:c,disabled:o,children:`Cancel`}),(0,G.jsxs)(P,{type:`submit`,variant:`submit`,disabled:o||!r.formState.isDirty||!r.formState.isValid,children:[(0,G.jsx)($r,{}),` Add Certificate`]})]})})]})})})})}async function oh({instanceClient:e},t){let{data:n}=await e.post(`/`,{operation:`remove_certificate`,name:t});return n}function sh(){return F({mutationFn:({instanceParams:e,name:t})=>oh(e,t)})}function ch({data:e,isModalOpen:t,closeModal:n,onSelectCertificate:r,onChangesSaved:i}){let{name:a}=e,o=W(),{mutate:s,isPending:c}=sh(),[l,u]=(0,K.useState)(!1),d=(0,K.useCallback)(()=>{u(!0)},[]),f=(0,K.useCallback)(()=>{s({instanceParams:o,name:a},{onSuccess:()=>{H.success(`Certificate removed successfully!`),r(void 0),i()}})},[a,s,o,i,r]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Gt,{onOpenChange:n,open:t,children:(0,G.jsx)(Xt,{className:`sm:max-w-[800px] max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:(0,G.jsxs)(`div`,{className:`grid gap-4 my-4`,children:[(0,G.jsxs)(qt,{children:[(0,G.jsxs)(en,{children:[`View Certificate: `,a]}),(0,G.jsx)(an,{children:`Details of the selected certificate.`})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm bg-muted p-4 rounded-lg border border-border`,children:[(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Issuer`}),(0,G.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.issuer||`N/A`})]}),(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Subject`}),(0,G.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject||`N/A`})]}),e.details.subject_alt_name&&(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Subject Alternative Name`}),(0,G.jsx)(`p`,{className:`text-muted-foreground break-all`,children:e.details.subject_alt_name})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Valid From`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_from?new Date(e.details.valid_from).toLocaleString():`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Valid To (Expires At)`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.details.valid_to?new Date(e.details.valid_to).toLocaleString():`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Serial Number`}),(0,G.jsx)(`p`,{className:`text-muted-foreground font-mono text-xs break-all`,children:e.details.serial_number||`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Private Key Name`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.private_key_name||`N/A`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Is Authority`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_authority?`Yes`:`No`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Is Self-Signed`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.is_self_signed?`Yes`:`No`})]}),e.hosts&&e.hosts.length>0&&(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Hosts`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.hosts.join(`, `)})]}),(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`p`,{className:`font-semibold`,children:`Uses`}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e.uses?.join(`, `)||`N/A`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Ao,{children:`Certificate Content`}),(0,G.jsx)(yn,{autoComplete:`off`,autoCapitalize:`off`,rows:8,readOnly:!0,className:`font-mono text-xs`,value:e.certificate})]})]}),(0,G.jsx)(Kt,{children:(0,G.jsxs)(`div`,{className:`flex justify-between w-full`,children:[(0,G.jsx)(P,{type:`button`,variant:`destructiveOutline`,onClick:d,disabled:c,children:`Remove Certificate`}),(0,G.jsx)(P,{type:`button`,variant:`defaultOutline`,onClick:()=>n(),children:`Close`})]})})]})})}),(0,G.jsx)(Gs,{isModalOpen:l,setIsModalOpen:u,deletionConfirmed:f,deletionPending:c,typeOfThingBeingDeleted:`certificate`,presentParticiple:`Removing`,transitiveVerb:`Remove`,nameOfThingBeingDeleted:a,hideDataLossWarning:!0})]})}function lh(){let e=ke(),{certName:t}=I({strict:!1}),{data:n,refetch:r,isFetching:i,isRefetching:a}=L(eh(W())),o=(0,K.useMemo)(()=>n?.find(e=>e.name===t),[n,t]),s=(0,K.useCallback)(n=>{let r=n?.original?.name,i=[t?`..`:``,r].filter(Boolean);e({to:i.join(`/`)})},[t,e]),c=!!t&&!!o,[l,u]=(0,K.useState)(!1),d=(0,K.useCallback)(()=>{u(!0)},[u]),f=Wd(r);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(zd,{columns:th,data:n||[],isFetching:i,onRowClick:s,children:[(0,G.jsx)(B,{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,G.jsxs)(P,{variant:`defaultOutline`,onClick:f,accessKey:`r`,disabled:i||a,children:[(0,G.jsx)(Yr,{}),(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:d,accessKey:`a`,disabled:l,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`A`}),`dd`]})]})]}),l&&(0,G.jsx)(ah,{isModalOpen:l,onChangesSaved:r,setIsModalOpen:u}),c&&(0,G.jsx)(ch,{isModalOpen:c,closeModal:s,data:o,onSelectCertificate:s,onChangesSaved:r})]})}var uh=new Set([`success`,`failed`,`rolled_back`]);function dh(e){return!!e&&uh.has(e)}var fh=2e3,ph=1e4;async function mh({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 hh(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:()=>mh(e),retry:!1,enabled:e.enabled!==!1,refetchInterval:c?e=>(e.state.data?.deployments??[]).some(e=>!dh(e.status))?fh:ph:!1})}var gh={pending:`warning`,extracting:`warning`,installing:`warning`,loading:`warning`,replicating:`warning`,restarting:`warning`,success:`success`,failed:`destructive`,rolled_back:`destructive`},_h={pending:`Pending`,extracting:`Extracting`,installing:`Installing`,loading:`Loading`,replicating:`Replicating`,restarting:`Restarting`,success:`Success`,failed:`Failed`,rolled_back:`Rolled back`};function vh({status:e}){return(0,G.jsx)(qi,{variant:gh[e]??`secondary`,children:_h[e]??e})}var yh=de();function bh(e){return e?Hd((Date.now()-e)/1e3,e):`—`}var xh=[{header:`Project`,accessorKey:`project`,enableSorting:!1},yh.display({header:`Status`,id:`status`,enableSorting:!1,cell:e=>(0,G.jsx)(vh,{status:e.row.original.status})}),yh.display({header:`Started`,id:`started_at`,enableSorting:!1,cell:e=>bh(e.row.original.started_at)}),yh.display({header:`Completed`,id:`completed_at`,enableSorting:!1,cell:e=>bh(e.row.original.completed_at)}),{header:`User`,accessorKey:`user`,enableSorting:!1},{header:`Origin`,accessorKey:`origin_node`,enableSorting:!1}];function Sh({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,G.jsx)(Nt,{"data-slot":`separator-root`,decorative:n,orientation:t,className:N(`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*Ch(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=wh(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
16
16
  `),n=-1,r=0;if(e!==-1&&(t===-1||e<t)?(n=e,r=2):t!==-1&&(n=t,r=4),n===-1)return;let a=i.slice(0,n);i=i.slice(n+r);let o=wh(a);o&&(yield o)}}}function wh(e){let t=e.split(/\r?\n/),n=`message`,r,i,a=[];for(let e of t){if(e===``||e.startsWith(`:`))continue;let t=e.indexOf(`:`),o=t===-1?e:e.slice(0,t),s=t===-1?``:e.slice(t+1);switch(s.startsWith(` `)&&(s=s.slice(1)),o){case`event`:n=s;break;case`data`:a.push(s);break;case`id`:r=s;break;case`retry`:{let e=Number(s);Number.isFinite(e)&&(i=e);break}}}return a.length===0&&n===`message`?null:{event:n,data:a.join(`
17
17
  `),id:r,retry:i}}function Th(e){try{return JSON.parse(e.data)}catch{return e.data}}var Eh=class extends Error{constructor(e,t){super(e,t),this.name=`SSEUnsupportedError`}},Dh=class extends Error{constructor(e,t){super(e,t),this.name=`SSEInconclusiveError`}},Oh=class extends Error{code;phase;deploymentId;constructor(e,t){super(e),this.name=`SSEOperationError`,this.code=t?.code,this.phase=t?.phase,this.deploymentId=t?.deploymentId}};function kh({id:e=h,operationsUrl:t,port:n,secure:r,forceFabricConnect:i,disableFabricConnect:a}={}){let o=t||u.getOperationsUrl(e);if(o&&(n||r!==void 0)){let e=new URL(o);n&&(e.port=String(n)),r!==void 0&&(e.protocol=r?`https:`:`http:`),o=e.toString()}let s=u.checkForBasicAuth(e),c=i||a||s?void 0:u.getOperationToken(e),l=!c&&!a&&(i||u.checkForFabricConnect(e));if(l&&(e.startsWith(`clu-`)?o=M.defaults.baseURL+`/Cluster/${e}/operation`:e.startsWith(`ins-`)&&(o=M.defaults.baseURL+`/HDBInstance/${e}/operation`)),!o)throw Error(`No operations URL is known for "${e}"; cannot open an SSE stream.`);let d={"Content-Type":`application/json`,Accept:`text/event-stream`};return c?d.Authorization=`Bearer ${c}`:s&&!l&&(d.Authorization=`Basic ${btoa(`${s.username}:${s.password}`)}`),{url:o.replace(/\/+$/,``)+`/`,headers:d,credentials:l||!s&&!c?`include`:`same-origin`,mode:l?`proxy`:`direct`}}async function Ah({connection:e,body:t,signal:n,idleTimeoutMs:r=12e4,onMessage:i}){let{url:a,headers:o,credentials:s}=kh(e),c=new AbortController,{signal:l,cleanup:u}=jh([n,c.signal]),d,f=()=>{d&&clearTimeout(d),d=setTimeout(()=>c.abort(),r)};try{let e;try{f(),e=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(t),signal:l})}catch(e){throw n?.aborted?e:new Eh(`Failed to open the SSE stream.`,{cause:e})}let r=e.headers.get(`content-type`)??``;if(!e.ok||!r.includes(`text/event-stream`)||!e.body)throw await e.body?.cancel().catch(()=>{}),new Eh(`Server did not return an event stream (status ${e.status}, content-type "${r}").`);let u=!1,d;try{for await(let t of Ch(e.body,l)){if(f(),i?.(t),t.event===`done`){u=!0;let e=Th(t);d=e?.result??e;break}if(t.event===`error`){u=!0;let e=Th(t);if(!e||typeof e!=`object`)throw new Oh(typeof e==`string`&&e?e:`The operation failed.`);let n=e;throw new Oh(wn(n.message)??`The operation failed.`,{code:n.code,phase:n.phase,deploymentId:n.deployment_id})}}}catch(e){throw c.signal.aborted&&!n?.aborted?new Dh(`The stream went idle before completing.`,{cause:e}):e}if(!u)throw new Dh(`The stream ended without a terminal event.`);return d}finally{clearTimeout(d),u()}}function jh(e){let t=()=>{},n=e.filter(e=>!!e);if(n.length===1)return{signal:n[0],cleanup:t};if(typeof AbortSignal.any==`function`)return{signal:AbortSignal.any(n),cleanup:t};let r=new AbortController;function i(){for(let e of n)e.removeEventListener(`abort`,a)}function a(e){r.abort(e.target.reason),i()}for(let e of n){if(e.aborted){r.abort(e.reason),i();break}e.addEventListener(`abort`,a)}return{signal:r.signal,cleanup:i}}var Mh=[`prepare`,`load`,`replicate`,`restart`,`success`];async function Nh({connection:e,package:t,project:n,replicated:r,install_command:i,restart:a,signal:o,onEvent:s}){return await Ah({connection:e,body:{operation:`deploy_component`,package:t,project:n,replicated:r,install_command:i||void 0,restart:a},signal:o,onMessage:e=>{if(s)switch(e.event){case`phase`:s({type:`phase`,data:Th(e)});break;case`install`:s({type:`install`,data:Th(e)});break;case`peer`:s({type:`peer`,data:Th(e)});break}}})??{}}var Ph={prepare:`Prepare`,load:`Load`,replicate:`Replicate`,restart:`Restart`,success:`Finish`};function Fh({status:e,isCurrent:t}){return e===`done`?(0,G.jsx)(xn,{className:`size-4 text-success`}):e===`error`?(0,G.jsx)(Cn,{className:`size-4 text-destructive`}):e===`start`||t?(0,G.jsx)(Pr,{className:`size-4 animate-spin text-primary`}):(0,G.jsx)(ir,{className:`size-4 text-muted-foreground`})}function Ih({state:e}){let t=(0,K.useRef)(null);(0,K.useEffect)(()=>{t.current?.scrollIntoView({block:`end`})},[e.installLog.length]);let n=e.lifecycle===`error`;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsx)(`ol`,{className:`flex flex-col gap-2`,children:Mh.map(t=>{let n=e.phases[t];return(0,G.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(Fh,{status:n,isCurrent:e.currentPhase===t&&n!==`done`}),(0,G.jsx)(`span`,{className:N(n?`text-foreground`:`text-muted-foreground`),children:Ph[t]??t})]},t)})}),e.installLog.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Sh,{className:`mb-2`}),(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Install output`}),(0,G.jsx)(Ji,{className:`h-40 rounded-md border bg-muted/40`,children:(0,G.jsxs)(`pre`,{className:`whitespace-pre-wrap break-words p-2 font-mono text-xs leading-relaxed`,children:[e.installLog.map(e=>(0,G.jsx)(`div`,{className:N(e.stream===`stderr`&&`text-destructive`),children:e.line},e.id)),(0,G.jsx)(`div`,{ref:t})]})})]}),e.peers.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Sh,{className:`mb-2`}),(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Replication`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:e.peers.map((e,t)=>{let n=e.status===`failed`,r=wn(e.error??e.reason);return(0,G.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[n?(0,G.jsx)(Cn,{className:`size-4 text-destructive`}):(0,G.jsx)(xn,{className:`size-4 text-success`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.node??`node ${t+1}`})]}),n&&r&&(0,G.jsx)(`span`,{className:`truncate text-xs text-destructive`,children:r})]},t)})})]}),n&&e.error&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2 text-sm text-destructive`,children:[(0,G.jsx)(ar,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:e.error})]}),e.lifecycle===`inconclusive`&&(0,G.jsx)(qi,{variant:`warning`,className:`self-start`,children:`Live updates ended early — verifying…`})]})}var Lh={lifecycle:`idle`,phases:{},installLog:[],peers:[]},Rh=1e3;function zh(e,t){switch(t.kind){case`reset`:return Lh;case`start`:return{...Lh,lifecycle:`streaming`};case`event`:{let{event:n}=t;if(n.type===`phase`){let{phase:t,status:r}=n.data;return{...e,lifecycle:`streaming`,phases:{...e.phases,[t]:r},currentPhase:r===`start`?t:e.currentPhase}}if(n.type===`install`){let t=(e.installLog[e.installLog.length-1]?.id??0)+1,r=e.installLog.concat({id:t,stream:n.data.stream,line:n.data.line});return{...e,installLog:r.length>Rh?r.slice(-1e3):r}}return{...e,peers:e.peers.concat(n.data)}}case`settled`:return{...e,lifecycle:t.lifecycle,error:t.error}}}function Bh(){let[e,t]=(0,K.useReducer)(zh,Lh),n=(0,K.useCallback)(e=>t({kind:`event`,event:e}),[]),r=(0,K.useCallback)(()=>t({kind:`start`}),[]),i=(0,K.useCallback)(()=>t({kind:`reset`}),[]),a=(0,K.useCallback)((e,n)=>t({kind:`settled`,lifecycle:e,error:n}),[]);return(0,K.useMemo)(()=>({state:e,onEvent:n,markStarted:r,markSettled:a,reset:i}),[e,n,r,a,i])}function Vh(){let{data:e}=L(un(W()));return!!e?.version&&sn(`5.1.0`,e.version)}function Hh(){let e=W();return Vh()&&u.isDirectConnection(e.entityId)}async function Uh({instanceClient:e,deploymentId:t}){let{data:n}=await e.post(`/`,{operation:`get_deployment`,deployment_id:t});return n}function Wh(e){return z({queryKey:[e.entityId,`get_deployment`,e.deploymentId],queryFn:()=>Uh(e),retry:!1,refetchInterval:t=>e.pollWhileActive&&!dh(t.state.data?.status)?2e3:!1})}async function Gh({connection:e,deploymentId:t,signal:n,onEvent:r}){return await Ah({connection:e,body:{operation:`get_deployment`,deployment_id:t},signal:n,onMessage:e=>{if(r)switch(e.event){case`phase`:r({type:`phase`,data:Th(e)});break;case`install`:r({type:`install`,data:Th(e)});break;case`peer`:r({type:`peer`,data:Th(e)});break}}})??{}}function Kh({label:e,value:t}){return t==null||t===``?null:(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,G.jsx)(`span`,{className:`break-words text-sm`,children:t})]})}function qh(e){return e?Hd((Date.now()-e)/1e3,e):void 0}function Jh({deploymentId:e}){let t=W(),n=Hh(),r=ae(),i=Bh(),{data:a,isLoading:o,error:s}=L(Wh({...t,deploymentId:e,pollWhileActive:!0})),c=!!a&&!dh(a.status);if((0,K.useEffect)(()=>{if(!n||!c)return;let a=new AbortController;return i.reset(),i.markStarted(),Gh({connection:{id:t.entityId},deploymentId:e,signal:a.signal,onEvent:i.onEvent}).then(()=>i.markSettled(`success`)).catch(()=>{a.signal.aborted||i.markSettled(`inconclusive`)}).finally(()=>{a.signal.aborted||r.invalidateQueries({queryKey:[t.entityId,`get_deployment`,e]})}),()=>a.abort()},[n,c,e,t.entityId]),o)return(0,G.jsx)(Ui,{className:`flex h-full flex-col items-center justify-center`,text:`Loading deployment...`});if(s||!a)return(0,G.jsx)(`div`,{className:`p-4 text-sm text-destructive`,children:`Could not load this deployment.`});let l=c&&(i.state.installLog.length>0||Object.keys(i.state.phases).length>0);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 p-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:a.project}),(0,G.jsx)(vh,{status:a.status}),a.phase&&(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:a.phase})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3`,children:[(0,G.jsx)(Kh,{label:`Deployment ID`,value:(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:a.deployment_id})}),(0,G.jsx)(Kh,{label:`User`,value:a.user}),(0,G.jsx)(Kh,{label:`Origin node`,value:a.origin_node}),(0,G.jsx)(Kh,{label:`Started`,value:qh(a.started_at)}),(0,G.jsx)(Kh,{label:`Completed`,value:qh(a.completed_at)}),(0,G.jsx)(Kh,{label:`Restart mode`,value:a.restart_mode??void 0}),(0,G.jsx)(Kh,{label:`Package`,value:a.package_identifier??void 0}),(0,G.jsx)(Kh,{label:`Payload size`,value:a.payload_size==null?void 0:id(a.payload_size)}),(0,G.jsx)(Kh,{label:`Payload hash`,value:a.payload_hash?(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:a.payload_hash}):void 0}),(0,G.jsx)(Kh,{label:`Restorable`,value:a.restorable===void 0?void 0:a.restorable?`Yes`:`No`}),(0,G.jsx)(Kh,{label:`Rollback of`,value:a.rollback_of?(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:a.rollback_of}):void 0})]}),l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sh,{}),(0,G.jsx)(Ih,{state:i.state})]}),a.error&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sh,{}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm`,children:[(0,G.jsxs)(`span`,{className:`font-medium text-destructive`,children:[`Error`,typeof a.error.phase==`string`&&a.error.phase?` during ${a.error.phase}`:``,typeof a.error.code==`string`||typeof a.error.code==`number`?` (${a.error.code})`:``]}),(0,G.jsx)(`span`,{className:`break-words`,children:wn(a.error)??`Unknown error`})]})]}),!!a.peer_results?.length&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sh,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Replication`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:a.peer_results.map((e,t)=>{let n=wn(e.error);return(0,G.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:e.node}),(0,G.jsxs)(`span`,{className:e.status===`failed`?`text-destructive`:`text-success`,children:[e.status??`ok`,n?`: ${n}`:``]})]},e.node??t)})})]})]}),!!a.event_log?.length&&(0,G.jsx)(Yh,{deployment:a})]})}function Yh({deployment:e}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sh,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Activity`}),(0,G.jsx)(`ol`,{className:`flex flex-col gap-1 text-xs`,children:e.event_log.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:new Date(e.t).toLocaleTimeString()}),(0,G.jsx)(`span`,{className:`font-medium`,children:e.event}),(0,G.jsx)(`span`,{className:`break-words text-muted-foreground`,children:typeof e.data==`string`?e.data:JSON.stringify(e.data)})]},t))})]})]})}function Xh({deploymentId:e,isModalOpen:t,closeModal:n}){return(0,G.jsx)(Gt,{onOpenChange:n,open:t,children:(0,G.jsxs)(Xt,{resizable:!0,"aria-describedby":void 0,children:[(0,G.jsx)(qt,{children:(0,G.jsx)(en,{children:`Deployment`})}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,G.jsx)(Jh,{deploymentId:e})})]})})}function Zh(){let e=ke(),t=lc(),{deploymentId:n}=I({strict:!1}),{data:r,isFetching:i,isRefetching:a,refetch:o,error:s}=L(hh({...W(),limit:100,enabled:t,pollWhileOpen:!0})),c=(0,K.useMemo)(()=>r?.deployments??[],[r]),l=(0,K.useCallback)(t=>{let r=[n?`..`:``,t].filter(Boolean);e({to:r.join(`/`)||`.`})},[n,e]),u=(0,K.useCallback)(e=>l(e.original.deployment_id),[l]),d=(0,K.useCallback)(()=>l(void 0),[l]),f=Wd(o);return t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(zd,{data:c,isFetching:i||a,columns:xh,onRowClick:u,children:(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:f,accessKey:`r`,disabled:i||a,children:[(0,G.jsx)(Yr,{}),` `,(0,G.jsxs)(`span`,{className:`hidden lg:inline-block`,children:[(0,G.jsx)(`u`,{children:`R`}),`efresh`]})]})}),s&&(0,G.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`Could not load deployments. This instance may not support deployment history.`}),!s&&!i&&c.length===0&&(0,G.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`No deployments yet.`}),!!n&&(0,G.jsx)(Xh,{deploymentId:n,isModalOpen:!0,closeModal:d})]}):(0,G.jsx)(`div`,{className:`p-2 text-sm text-muted-foreground`,children:`Viewing deployments requires super-user permissions on this instance.`})}function Qh(){return(0,G.jsx)(hm,{})}function $h({clusterId:e,instanceId:t,organizationId:n},r){return`/`+[n,e,t&&`instance`,t,r].filter(Fn).join(`/`)}var eg=`flex items-center p-2 rounded-lg group`,tg={className:`text-foreground hover:bg-accent dark:text-white dark:hover:bg-gray-700`},ng={className:`text-black bg-white pointer-events-none cursor-default`};function rg(){let e=I({strict:!1}),{version:t}=Oe({strict:!1}),n=sn(`4.6.0`,t),r=sn(`5.1.0`,t),i=sn(`5.2.0-alpha.1`,t),{clusterId:a}=e,o=lc(),{data:s}=L(Ko(a,!1));s===void 0||fc(s);let c=o&&(0,G.jsxs)(G.Fragment,{children:[n&&(0,G.jsx)(`li`,{children:(0,G.jsxs)(B,{to:$h(e,`config/certificates`),className:eg,inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(ii,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`Certificates`})]})}),r&&(0,G.jsx)(`li`,{children:(0,G.jsxs)(B,{to:$h(e,`config/deployments`),className:eg,inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(Xr,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`Deployments`})]})}),!1,(0,G.jsx)(`li`,{children:(0,G.jsxs)(B,{to:$h(e,`config/roles`),className:eg,inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(Er,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`Roles`})]})}),i&&(0,G.jsx)(`li`,{children:(0,G.jsxs)(B,{to:$h(e,`config/secrets`),className:eg,inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(Ir,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`Secrets`})]})}),n&&(0,G.jsx)(`li`,{children:(0,G.jsxs)(B,{to:$h(e,`config/ssh-keys`),className:eg,inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(Ar,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`SSH Keys`})]})}),(0,G.jsx)(`li`,{children:(0,G.jsxs)(B,{to:$h(e,`config/users`),className:eg,inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(bi,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`Users`})]})})]});return(0,G.jsxs)(`div`,{className:`md:grid gap-4 md:grid-cols-12 min-h-[calc(100vh-(--spacing(36)))]`,children:[(0,G.jsxs)(`section`,{className:`col-span-1 text-foreground md:col-span-4 lg:col-span-3 md:border-r border-b md:border-b-0 md:pr-4 border-gray-700`,children:[(0,G.jsx)(ig,{params:e,children:c}),(0,G.jsx)(ag,{params:e,children:c})]}),(0,G.jsx)(`section`,{className:`col-span-1 text-foreground md:col-span-8 lg:col-span-9 md:pt-4`,children:(0,G.jsx)(K.Suspense,{fallback:(0,G.jsx)(Ui,{className:`flex flex-col items-center justify-center h-full`,text:`Loading...`}),children:(0,G.jsx)(Ce,{})})})]})}function ig({params:e,children:t}){return(0,G.jsxs)(`div`,{className:`hidden md:block pl-4 pt-4`,children:[(0,G.jsxs)(B,{to:$h(e,`config`),className:eg,activeOptions:{exact:!0},inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(Qn,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`Overview`})]}),t&&(0,G.jsx)(`ul`,{className:`border-t border-gray-700 pt-4 mt-4 space-y-2`,children:t})]})}function ag({params:e,children:t}){return(0,G.jsxs)(`ul`,{className:`flex space-x-2 md:hidden py-2 px-4`,children:[(0,G.jsx)(`li`,{children:(0,G.jsxs)(B,{to:$h(e,`config`),className:eg,activeOptions:{exact:!0},inactiveProps:tg,activeProps:ng,children:[(0,G.jsx)(Qn,{className:`hidden md:inline-block`}),` `,(0,G.jsx)(`span`,{className:`ms-3`,children:`Overview`})]})}),t]})}async function og(e,t=3,n=1e3){let r=0;if(t<=0)throw Error(`retries must be greater than 0`);let i;for(;r<t;)try{return await e()}catch(e){if(r++,i=e,r===t)break;await a(n)}throw i}async function sg({operation:e,replicated:t,instanceClient:n}){let{data:i}=await n.post(`/`,{operation:e,service:e===`restart_service`?`http`:void 0,replicated:t});return await a(1e4),await og(()=>r({instanceClient:n,timeout:3e3}),12,15e3),i}function cg(){return F({mutationFn:sg})}function lg({onRestartedSuccessfully:e}={}){let{clusterId:t}=I({strict:!1}),n=ae(),[i,s]=(0,K.useState)(!1);return{onRestartClick:(0,K.useCallback)(async()=>{if(!t)throw Error(`clusterId must be set in the route to invoke useRestartClusterClick`);s(!0);let i=!1,c={duration:6e4,action:{label:`Cancel`,onClick:()=>{i=!0}}},l=H.loading(`Restarting`,{...c,description:(0,G.jsx)(cn,{animated:!0,width:`0%`})}),d=await Go(t),f=u.checkForFabricConnect(d.id),m=d?.instances??[],h=m.filter(e=>e.status===`RUNNING`).map(e=>g({id:e.id,forceFabricConnect:f,operationsUrl:p(e)})).reverse(),_=0;if(h.length)for(let e=0;e<h.length;e++){let t=h[e];if(!i){H.loading(`Restarting Instance ${e+1} of ${h.length}`,{...c,id:l,description:(0,G.jsx)(cn,{animated:!0,width:(e===0?0:e/h.length*100)+`%`})});try{await r({instanceClient:t}),await sg({operation:`restart`,replicated:!1,instanceClient:t}),_+=1}catch{e+1!==h.length&&(H.loading(`Failed Restarting Instance ${e+1} of ${h.length}`,{...c,id:l,description:`We will carry on momentarily.`}),await a(3e3))}}}if(s(!1),cl(n,t),i)H.error(`Cancelled`,{id:l,description:`The restart was partially cancelled.`,duration:1e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});else if(m.length===_)e?.(),H.success(`Success`,{id:l,description:`Cluster fully restarted!`,duration:1e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});else{let e=o(m.length,`instance`,`instances`),t=o(_,`"RUNNING" instance was`,`"RUNNING" instances were`);H.error(`Error`,{id:l,description:`Failed to fully restart cluster.
18
18
  `+([m.length===0&&`No instances were found within the cluster to restart.`,_===0&&`No instances were in a "RUNNING" state of ${e}.`,m.length!==_&&`Only ${t} restarted of ${e}.`].filter(Fn).shift()||``),duration:1e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}},[t,e,n]),isRestartPending:i}}function ug({operation:e,instanceClient:t,onRestartedSuccessfully:n}){let{clusterId:r,instanceId:i}=I({strict:!1}),a=`Instance`,{mutateAsync:o,isPending:s}=cg(),c=ae();return{onRestartClick:(0,K.useCallback)(async()=>{let s=H.loading(`Restarting`,{description:`Restarting instance. This may take up to 60 seconds.`,duration:18e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});try{await o({operation:e,replicated:e===`restart_service`&&!1,instanceClient:t}),cl(c,r),cl(c,i),H.dismiss(s),H.success(`Success`,{description:`${a} restarted!`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}}),n?.()}catch{H.dismiss(s),H.error(`Error`,{description:`Failed to restart instance.`,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}},[r,t,i,n,e,c,o,a]),isRestartPending:s}}function dg({className:e,disabled:t,hideText:n,instanceClient:r,operation:i,targetNoun:a,tooltip:o,variant:s}){let{onRestartClick:c,isRestartPending:l}=lg(),{onRestartClick:u,isRestartPending:d}=ug({operation:i,instanceClient:r});return(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(P,{type:`button`,variant:s||`positiveOutline`,className:_(`mx-0 md:mx-4`,e),onClick:a===`Cluster`&&i===`restart`?c:u,disabled:t||d||l,title:`Restart ${a}`,children:[(0,G.jsx)(Zr,{className:`pointer-events-none`}),n!==!0&&(0,G.jsxs)(`span`,{className:`hidden md:inline-block pointer-events-none`,children:[`Restart `,(0,G.jsx)(`span`,{className:`hidden 2xl:inline-block`,children:a})]})]})}),(0,G.jsx)(Va,{side:`bottom`,children:o||(i===`restart_service`?`Restarts all service threads to apply changes. No downtime expected. Performance may be briefly slower during restart.`:`This fully restarts the Harper service and causes downtime.`)})]})}var fg=T(`relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90`,warning:`border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-50/50 dark:bg-amber-950/20 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-400`}},defaultVariants:{variant:`default`}});function pg({className:e,variant:t,...n}){return(0,G.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:N(fg({variant:t}),e),...n})}function mg({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`alert-title`,className:N(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),...t})}function hg({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`alert-description`,className:N(`text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed`,e),...t})}async function gg({clusterId:e,instanceId:t}){return null}function _g(e){return z({queryKey:[e.clusterId,e.instanceId],queryFn:()=>gg(e),retry:!1})}var vg=({loadingRegistration:e,registrationInfo:t})=>{let n=!!t?.version&&parseInt(t.version[0],10)>=5&&`https://github.com/HarperFast/harper/releases/tag/v${t.version}`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`font-bold text-sm/6`,children:`Harper Version`}),(0,G.jsx)(`dd`,{className:`text-sm/6 sm:mt-2`,children:e?(0,G.jsx)(Hu,{className:`w-10`}):n?(0,G.jsx)(`a`,{href:n,target:`_blank`,className:`underline hover:text-blue-300`,rel:`noopener noreferrer`,children:t.version}):t?.version||`Unknown`})]})},yg=({loading:e,timestamp:t})=>{let n=t?new Date(t).toLocaleString():`Never`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`font-bold text-sm/6`,children:`Last Deployed`}),(0,G.jsx)(`dd`,{className:`text-sm/6 sm:mt-2`,children:e?(0,G.jsx)(Hu,{className:`w-24`}):n})]})};async function bg({instanceClient:e,...t}){let{data:n}=await e.post(`/`,{operation:`set_configuration`,...t});return n}function xg({onRestartedSuccessfully:e}={}){let t=W(),n=ae(),[i,s]=(0,K.useState)(!1);return{onConfigUpdate:(0,K.useCallback)(async i=>{s(!0);let c=!1,l={duration:6e4,action:{label:`Cancel`,onClick:()=>{c=!0}}},d=H.loading(`Restarting`,{...l,description:(0,G.jsx)(cn,{animated:!0,width:`0%`})}),f=t.entityType===`cluster`?await Go(t.entityId):null,m=t.entityType===`cluster`?f?.instances||[]:[{id:t.entityId,status:`RUNNING`}],h=!!f&&u.checkForFabricConnect(f.id),_=t.entityType===`cluster`?m.filter(e=>e.status===`RUNNING`).map(e=>g({id:e.id,forceFabricConnect:h,operationsUrl:p(e)})).reverse():[t.instanceClient],v=0;if(_.length)for(let e=0;e<_.length;e++){let t=_[e];if(!c){H.loading(`Updating Instance ${e+1} of ${_.length}`,{...l,id:d,description:(0,G.jsx)(cn,{animated:!0,width:(e===0?0:e/_.length*100)+`%`})});try{await r({instanceClient:t}),await bg({...i,instanceClient:t}),await sg({operation:`restart_service`,replicated:!1,instanceClient:t}),v+=1}catch{e+1!==_.length&&(H.loading(`Failed Restarting Instance ${e+1} of ${_.length}`,{...l,id:d,description:`We will carry on momentarily.`}),await a(3e3))}}}if(s(!1),n.invalidateQueries({queryKey:[`get_configuration`,t.entityId]}),c)H.error(`Cancelled`,{id:d,description:`The config update was partially cancelled.`,duration:1e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});else if(m.length===v)e?.(),H.success(`Success`,{id:d,description:`Your configuration has been updated successfully!`,duration:1e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}});else{let e=o(m.length,`instance`,`instances`),t=o(v,`"RUNNING" instance was`,`"RUNNING" instances were`);H.error(`Error`,{id:d,description:`Failed to fully update cluster.
19
- `+([m.length===0&&`No instances were found within the cluster to restart.`,v===0&&`No instances were in a "RUNNING" state of ${e}.`,m.length!==v&&`Only ${t} restarted of ${e}.`].filter(Fn).shift()||``),duration:1e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}},[t,e,n]),isPending:i}}async function Sg({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_components`});return t}function Cg(e){return z({queryKey:[e.entityId,`get_components`],queryFn:()=>Sg(e),retry:!1,enabled:e.enabled!==!1})}function wg({entityId:e,instanceClient:t}){return z({queryKey:[`get_configuration`,e],queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_configuration`});return e}})}function Tg({entityId:e,instanceClient:t},n){return z({queryKey:[`get_usage_licenses`,e],enabled:n,queryFn:async()=>{try{let{data:e}=await t.post(`/`,{operation:`get_usage_licenses`});return e}catch(e){return console.error(e),null}}})}var Eg={http:{port:`blocked`,securePort:`blocked`},threads:`blocked`,authentication:{enableSessions:`blocked`},logging:{auditLog:`blocked`,root:`blocked`,rotation:{path:`blocked`}},mqtt:{network:{port:`blocked`,securePort:`blocked`}},operationsApi:{network:{domainSocket:`blocked`,port:`blocked`,securePort:`blocked`}},rootPath:`blocked`,replication:`blocked_except_databases`,storage:`blocked`,tls:`blocked`,node:`blocked`,license:`blocked`,componentsRoot:`blocked`,analytics:`allowed`,applications:`allowed`,localStudio:`allowed`};function Dg(e,t,n){if(JSON.stringify(t)===JSON.stringify(n))return!1;let r=e.split(`.`),i=Eg;for(let e=0;e<r.length;e++){let t=r[e];if(i===`blocked`)return!0;if(i===`blocked_except_databases`)return t!==`databases`;if(typeof i==`object`&&i&&t in i)i=i[t];else return!1}return i===`blocked`}function Og(e,t=Eg){if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){let i=e[r],a=t?.[r];if(a!==`blocked`)if(a===`blocked_except_databases`){i&&typeof i==`object`&&`databases`in i&&(n.replication={databases:i.databases});continue}else if(typeof a==`object`&&a){let e=Og(i,a);e!==void 0&&(typeof e!=`object`||Object.keys(e).length>0)&&(n[r]=e)}else n[r]=i}return n}function kg(e,t){if(typeof e!=`object`||!e||typeof t!=`object`||!t)return JSON.stringify(e)===JSON.stringify(t)?void 0:t;let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of r){let r=e[i],a=t[i];if(typeof r==`object`&&r&&typeof a==`object`&&a&&!Array.isArray(r)&&!Array.isArray(a)){let e=kg(r,a);Object.keys(e).length>0&&(n[i]=e)}else JSON.stringify(r)!==JSON.stringify(a)&&(n[i]=a)}return n}function Ag(e,t=``){let n={};for(let r in e){let i=e[r],a=t?`${t}_${r}`:r;typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(n,Ag(i,a)):n[a]=i}return n}var jg=new class{constructor(e,t,n){this._onDidChange=new zn,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(n)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}}(`json`,{validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:`warning`,schemaValidation:`warning`,comments:`error`,trailingCommas:`error`},{documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0});function Mg(){return Me(()=>import(`./jsonMode-Cjj7dtlr.js`),__vite__mapDeps([37,18,4,1,19,38,39,21,22,40]))}Rn.register({id:`json`,extensions:[`.json`,`.bowerrc`,`.jshintrc`,`.jscsrc`,`.eslintrc`,`.babelrc`,`.har`],aliases:[`JSON`,`json`],mimetypes:[`application/json`]}),Rn.onLanguage(`json`,()=>{Mg().then(e=>e.setupMode(jg))});var Ng=`5.9.3`,Pg=t({JsxEmit:()=>Ig,ModuleKind:()=>Fg,ModuleResolutionKind:()=>zg,NewLineKind:()=>Lg,ScriptTarget:()=>Rg,getJavaScriptWorker:()=>Kg,getTypeScriptWorker:()=>Gg,javascriptDefaults:()=>Wg,typescriptDefaults:()=>Ug,typescriptVersion:()=>Vg}),Fg=(e=>(e[e.None=0]=`None`,e[e.CommonJS=1]=`CommonJS`,e[e.AMD=2]=`AMD`,e[e.UMD=3]=`UMD`,e[e.System=4]=`System`,e[e.ES2015=5]=`ES2015`,e[e.ESNext=99]=`ESNext`,e))(Fg||{}),Ig=(e=>(e[e.None=0]=`None`,e[e.Preserve=1]=`Preserve`,e[e.React=2]=`React`,e[e.ReactNative=3]=`ReactNative`,e[e.ReactJSX=4]=`ReactJSX`,e[e.ReactJSXDev=5]=`ReactJSXDev`,e))(Ig||{}),Lg=(e=>(e[e.CarriageReturnLineFeed=0]=`CarriageReturnLineFeed`,e[e.LineFeed=1]=`LineFeed`,e))(Lg||{}),Rg=(e=>(e[e.ES3=0]=`ES3`,e[e.ES5=1]=`ES5`,e[e.ES2015=2]=`ES2015`,e[e.ES2016=3]=`ES2016`,e[e.ES2017=4]=`ES2017`,e[e.ES2018=5]=`ES2018`,e[e.ES2019=6]=`ES2019`,e[e.ES2020=7]=`ES2020`,e[e.ESNext=99]=`ESNext`,e[e.JSON=100]=`JSON`,e[e.Latest=99]=`Latest`,e))(Rg||{}),zg=(e=>(e[e.Classic=1]=`Classic`,e[e.NodeJs=2]=`NodeJs`,e))(zg||{}),Bg=class{constructor(e,t,n,r,i){this._onDidChange=new zn,this._onDidExtraLibsChange=new zn,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(e),this.setDiagnosticsOptions(t),this.setWorkerOptions(n),this.setInlayHintsOptions(r),this.setModeConfiguration(i),this._onDidExtraLibsChangeTimeout=-1}get onDidChange(){return this._onDidChange.event}get onDidExtraLibsChange(){return this._onDidExtraLibsChange.event}get modeConfiguration(){return this._modeConfiguration}get workerOptions(){return this._workerOptions}get inlayHintsOptions(){return this._inlayHintsOptions}getExtraLibs(){return this._extraLibs}addExtraLib(e,t){let n;if(n=t===void 0?`ts:extralib-${Math.random().toString(36).substring(2,15)}`:t,this._extraLibs[n]&&this._extraLibs[n].content===e)return{dispose:()=>{}};let r=1;return this._removedExtraLibs[n]&&(r=this._removedExtraLibs[n]+1),this._extraLibs[n]&&(r=this._extraLibs[n].version+1),this._extraLibs[n]={content:e,version:r},this._fireOnDidExtraLibsChangeSoon(),{dispose:()=>{let e=this._extraLibs[n];e&&e.version===r&&(delete this._extraLibs[n],this._removedExtraLibs[n]=r,this._fireOnDidExtraLibsChangeSoon())}}}setExtraLibs(e){for(let e in this._extraLibs)this._removedExtraLibs[e]=this._extraLibs[e].version;if(this._extraLibs=Object.create(null),e&&e.length>0)for(let t of e){let e=t.filePath||`ts:extralib-${Math.random().toString(36).substring(2,15)}`,n=t.content,r=1;this._removedExtraLibs[e]&&(r=this._removedExtraLibs[e]+1),this._extraLibs[e]={content:n,version:r}}this._fireOnDidExtraLibsChangeSoon()}_fireOnDidExtraLibsChangeSoon(){this._onDidExtraLibsChangeTimeout===-1&&(this._onDidExtraLibsChangeTimeout=window.setTimeout(()=>{this._onDidExtraLibsChangeTimeout=-1,this._onDidExtraLibsChange.fire(void 0)},0))}getCompilerOptions(){return this._compilerOptions}setCompilerOptions(e){this._compilerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}getDiagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setWorkerOptions(e){this._workerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setInlayHintsOptions(e){this._inlayHintsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setMaximumWorkerIdleTime(e){}setEagerModelSync(e){this._eagerModelSync=e}getEagerModelSync(){return this._eagerModelSync}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(void 0)}},Vg=Ng,Hg={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,diagnostics:!0,documentRangeFormattingEdits:!0,signatureHelp:!0,onTypeFormattingEdits:!0,codeActions:!0,inlayHints:!0},Ug=new Bg({allowNonTsExtensions:!0,target:99},{noSemanticValidation:!1,noSyntaxValidation:!1,onlyVisible:!1},{},{},Hg),Wg=new Bg({allowNonTsExtensions:!0,allowJs:!0,target:99},{noSemanticValidation:!0,noSyntaxValidation:!1,onlyVisible:!1},{},{},Hg),Gg=()=>qg().then(e=>e.getTypeScriptWorker()),Kg=()=>qg().then(e=>e.getJavaScriptWorker());function qg(){return Me(()=>import(`./tsMode-D1DMKY7h.js`),__vite__mapDeps([41,18,4,1,19,39,21,22]))}Rn.onLanguage(`typescript`,()=>qg().then(e=>e.setupTypeScript(Ug))),Rn.onLanguage(`javascript`,()=>qg().then(e=>e.setupJavaScript(Wg)));var Jg=JSON.parse(`{
19
+ `+([m.length===0&&`No instances were found within the cluster to restart.`,v===0&&`No instances were in a "RUNNING" state of ${e}.`,m.length!==v&&`Only ${t} restarted of ${e}.`].filter(Fn).shift()||``),duration:1e4,action:{label:`Dismiss`,onClick:()=>H.dismiss()}})}},[t,e,n]),isPending:i}}async function Sg({instanceClient:e}){let{data:t}=await e.post(`/`,{operation:`get_components`});return t}function Cg(e){return z({queryKey:[e.entityId,`get_components`],queryFn:()=>Sg(e),retry:!1,enabled:e.enabled!==!1})}function wg({entityId:e,instanceClient:t}){return z({queryKey:[`get_configuration`,e],queryFn:async()=>{let{data:e}=await t.post(`/`,{operation:`get_configuration`});return e}})}function Tg({entityId:e,instanceClient:t},n){return z({queryKey:[`get_usage_licenses`,e],enabled:n,queryFn:async()=>{try{let{data:e}=await t.post(`/`,{operation:`get_usage_licenses`});return e}catch(e){return console.error(e),null}}})}var Eg={http:{port:`blocked`,securePort:`blocked`},threads:`blocked`,authentication:{enableSessions:`blocked`},logging:{auditLog:`blocked`,root:`blocked`,rotation:{path:`blocked`}},mqtt:{network:{port:`blocked`,securePort:`blocked`}},operationsApi:{network:{domainSocket:`blocked`,port:`blocked`,securePort:`blocked`}},rootPath:`blocked`,replication:`blocked_except_databases`,storage:`blocked`,tls:`blocked`,node:`blocked`,license:`blocked`,componentsRoot:`blocked`,analytics:`allowed`,applications:`allowed`,localStudio:`allowed`};function Dg(e,t,n){if(JSON.stringify(t)===JSON.stringify(n))return!1;let r=e.split(`.`),i=Eg;for(let e=0;e<r.length;e++){let t=r[e];if(i===`blocked`)return!0;if(i===`blocked_except_databases`)return t!==`databases`;if(typeof i==`object`&&i&&t in i)i=i[t];else return!1}return i===`blocked`}function Og(e,t=Eg){if(typeof e!=`object`||!e)return e;let n=Array.isArray(e)?[]:{};for(let r in e){let i=e[r],a=t?.[r];if(a!==`blocked`)if(a===`blocked_except_databases`){i&&typeof i==`object`&&`databases`in i&&(n.replication={databases:i.databases});continue}else if(typeof a==`object`&&a){let e=Og(i,a);e!==void 0&&(typeof e!=`object`||Object.keys(e).length>0)&&(n[r]=e)}else n[r]=i}return n}function kg(e,t){if(typeof e!=`object`||!e||typeof t!=`object`||!t)return JSON.stringify(e)===JSON.stringify(t)?void 0:t;let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of r){let r=e[i],a=t[i];if(typeof r==`object`&&r&&typeof a==`object`&&a&&!Array.isArray(r)&&!Array.isArray(a)){let e=kg(r,a);Object.keys(e).length>0&&(n[i]=e)}else JSON.stringify(r)!==JSON.stringify(a)&&(n[i]=a)}return n}function Ag(e,t=``){let n={};for(let r in e){let i=e[r],a=t?`${t}_${r}`:r;typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(n,Ag(i,a)):n[a]=i}return n}var jg=new class{constructor(e,t,n){this._onDidChange=new zn,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(n)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}}(`json`,{validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:`warning`,schemaValidation:`warning`,comments:`error`,trailingCommas:`error`},{documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0});function Mg(){return Me(()=>import(`./jsonMode-Cjj7dtlr.js`),__vite__mapDeps([37,18,4,1,19,38,39,21,22,40]))}Rn.register({id:`json`,extensions:[`.json`,`.bowerrc`,`.jshintrc`,`.jscsrc`,`.eslintrc`,`.babelrc`,`.har`],aliases:[`JSON`,`json`],mimetypes:[`application/json`]}),Rn.onLanguage(`json`,()=>{Mg().then(e=>e.setupMode(jg))});var Ng=`5.9.3`,Pg=t({JsxEmit:()=>Ig,ModuleKind:()=>Fg,ModuleResolutionKind:()=>zg,NewLineKind:()=>Lg,ScriptTarget:()=>Rg,getJavaScriptWorker:()=>Kg,getTypeScriptWorker:()=>Gg,javascriptDefaults:()=>Wg,typescriptDefaults:()=>Ug,typescriptVersion:()=>Vg}),Fg=(e=>(e[e.None=0]=`None`,e[e.CommonJS=1]=`CommonJS`,e[e.AMD=2]=`AMD`,e[e.UMD=3]=`UMD`,e[e.System=4]=`System`,e[e.ES2015=5]=`ES2015`,e[e.ESNext=99]=`ESNext`,e))(Fg||{}),Ig=(e=>(e[e.None=0]=`None`,e[e.Preserve=1]=`Preserve`,e[e.React=2]=`React`,e[e.ReactNative=3]=`ReactNative`,e[e.ReactJSX=4]=`ReactJSX`,e[e.ReactJSXDev=5]=`ReactJSXDev`,e))(Ig||{}),Lg=(e=>(e[e.CarriageReturnLineFeed=0]=`CarriageReturnLineFeed`,e[e.LineFeed=1]=`LineFeed`,e))(Lg||{}),Rg=(e=>(e[e.ES3=0]=`ES3`,e[e.ES5=1]=`ES5`,e[e.ES2015=2]=`ES2015`,e[e.ES2016=3]=`ES2016`,e[e.ES2017=4]=`ES2017`,e[e.ES2018=5]=`ES2018`,e[e.ES2019=6]=`ES2019`,e[e.ES2020=7]=`ES2020`,e[e.ESNext=99]=`ESNext`,e[e.JSON=100]=`JSON`,e[e.Latest=99]=`Latest`,e))(Rg||{}),zg=(e=>(e[e.Classic=1]=`Classic`,e[e.NodeJs=2]=`NodeJs`,e))(zg||{}),Bg=class{constructor(e,t,n,r,i){this._onDidChange=new zn,this._onDidExtraLibsChange=new zn,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(e),this.setDiagnosticsOptions(t),this.setWorkerOptions(n),this.setInlayHintsOptions(r),this.setModeConfiguration(i),this._onDidExtraLibsChangeTimeout=-1}get onDidChange(){return this._onDidChange.event}get onDidExtraLibsChange(){return this._onDidExtraLibsChange.event}get modeConfiguration(){return this._modeConfiguration}get workerOptions(){return this._workerOptions}get inlayHintsOptions(){return this._inlayHintsOptions}getExtraLibs(){return this._extraLibs}addExtraLib(e,t){let n;if(n=t===void 0?`ts:extralib-${Math.random().toString(36).substring(2,15)}`:t,this._extraLibs[n]&&this._extraLibs[n].content===e)return{dispose:()=>{}};let r=1;return this._removedExtraLibs[n]&&(r=this._removedExtraLibs[n]+1),this._extraLibs[n]&&(r=this._extraLibs[n].version+1),this._extraLibs[n]={content:e,version:r},this._fireOnDidExtraLibsChangeSoon(),{dispose:()=>{let e=this._extraLibs[n];e&&e.version===r&&(delete this._extraLibs[n],this._removedExtraLibs[n]=r,this._fireOnDidExtraLibsChangeSoon())}}}setExtraLibs(e){for(let e in this._extraLibs)this._removedExtraLibs[e]=this._extraLibs[e].version;if(this._extraLibs=Object.create(null),e&&e.length>0)for(let t of e){let e=t.filePath||`ts:extralib-${Math.random().toString(36).substring(2,15)}`,n=t.content,r=1;this._removedExtraLibs[e]&&(r=this._removedExtraLibs[e]+1),this._extraLibs[e]={content:n,version:r}}this._fireOnDidExtraLibsChangeSoon()}_fireOnDidExtraLibsChangeSoon(){this._onDidExtraLibsChangeTimeout===-1&&(this._onDidExtraLibsChangeTimeout=window.setTimeout(()=>{this._onDidExtraLibsChangeTimeout=-1,this._onDidExtraLibsChange.fire(void 0)},0))}getCompilerOptions(){return this._compilerOptions}setCompilerOptions(e){this._compilerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}getDiagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setWorkerOptions(e){this._workerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setInlayHintsOptions(e){this._inlayHintsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setMaximumWorkerIdleTime(e){}setEagerModelSync(e){this._eagerModelSync=e}getEagerModelSync(){return this._eagerModelSync}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(void 0)}},Vg=Ng,Hg={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,diagnostics:!0,documentRangeFormattingEdits:!0,signatureHelp:!0,onTypeFormattingEdits:!0,codeActions:!0,inlayHints:!0},Ug=new Bg({allowNonTsExtensions:!0,target:99},{noSemanticValidation:!1,noSyntaxValidation:!1,onlyVisible:!1},{},{},Hg),Wg=new Bg({allowNonTsExtensions:!0,allowJs:!0,target:99},{noSemanticValidation:!0,noSyntaxValidation:!1,onlyVisible:!1},{},{},Hg),Gg=()=>qg().then(e=>e.getTypeScriptWorker()),Kg=()=>qg().then(e=>e.getJavaScriptWorker());function qg(){return Me(()=>import(`./tsMode-CrHCRjTK.js`),__vite__mapDeps([41,18,4,1,19,39,21,22]))}Rn.onLanguage(`typescript`,()=>qg().then(e=>e.setupTypeScript(Ug))),Rn.onLanguage(`javascript`,()=>qg().then(e=>e.setupJavaScript(Wg)));var Jg=JSON.parse(`{
20
20
  "$schema": "https://json-schema.org/draft-06/schema",
21
21
  "$id": "https://harper.fast/schema/config-root.schema.json",
22
22
  "title": "HarperDB Root Configuration",
@@ -805,5 +805,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
805
805
  disabled:pointer-events-none disabled:opacity-40
806
806
  [&_svg]:size-4 [&_svg]:shrink-0`,e&&`bg-muted font-semibold text-foreground`,t),...n})}function Dw({pageCount:e,disabled:t,onGo:n}){let[r,i]=(0,K.useState)(``);return(0,G.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,G.jsx)(`label`,{htmlFor:`pagination-go-to`,className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Go to`}),(0,G.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
807
807
  placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-purple focus-visible:outline-none
808
- disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function Ow({pageSize:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,G.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,G.jsxs)(rn,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,G.jsx)($t,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,G.jsx)(nn,{})}),(0,G.jsx)(Qt,{side:`top`,children:Cw.map(e=>(0,G.jsx)(Yt,{value:String(e),children:ad(e)},e))})]})]})}function kw(e,t,n=1){if(t<=n*2+5)return Aw(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?[...Aw(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...Aw(t-s+1,t)]:[1,`ellipsis`,...Aw(r,i),`ellipsis`,t]}function Aw(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function jw({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=_e({data:o||[],columns:n,manualPagination:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,pageCount:g,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i},rowCount:_,getCoreRowModel:Se(),getPaginationRowModel:Te()}),w=C.getState().columnSizingInfo,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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative flex flex-col grow`,children:[(0,G.jsxs)(hn,{containerClassName:`rounded-md bg-card dark:bg-black-dark grow overflow-visible`,className:`table-fixed`,children:[(0,G.jsx)(vn,{children:C.getHeaderGroups().map(e=>(0,G.jsxs)(fn,{className:`border-none`,children:[e.headers.map(e=>(0,G.jsx)(gn,{header:e,onColumnClick:c,className:`sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,G.jsx)(dn,{"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,G.jsx)(vw,{applyFilters:e,columnFiltersForm:t,headerGroups:C.getHeaderGroups()}),(0,G.jsx)(_n,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:C.getRowModel().rows?.length?C.getRowModel().rows.map(e=>(0,G.jsx)(Mw,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,G.jsx)(fn,{children:(0,G.jsx)(pn,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,G.jsx)(Sw,{className:`opacity-50 inline-block`}):(0,G.jsx)(`span`,{children:`No results.`})})})})]}),E!==null&&(0,G.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,G.jsx)(ww,{pageIndex:u,pageSize:d,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S,setPageIndex:p,setPageSize:m})]})}function Mw({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,K.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,G.jsx)(Nw,{cell:r[0]},r[0].id),(0,G.jsx)(Pw,{colSpan:r.length-1},`expired`)]:[(0,G.jsx)(Pw,{colSpan:r.length},`expired`)]:r.map(e=>(0,G.jsx)(Nw,{cell:e},e.id))},[e,t,r]);return(0,G.jsxs)(fn,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:N(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,G.jsx)(pn,{"aria-hidden":!0,className:`p-0`})]})}function Nw({cell:e}){let t=e.column.getSize();return(0,G.jsx)(pn,{"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:we(e.column.columnDef.cell,e.getContext())})}function Pw({colSpan:e}){return(0,G.jsx)(pn,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function Fw({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=I({strict:!1}),i=W(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=sw(!0),l=Be(),u=dc(o??a,t,n,`insert`),d=dc(o??a,t,n,`update`),f=dc(o??a,t,n,`delete`),p=uc(),{data:m}=L(Xb({...i,databaseName:t,tableName:n})),h=e?.[t],g=h?.[n],_=m??g,v=(0,K.useMemo)(()=>qc(_?.attributes??[],`attribute`),[_]),{data:y}=L(rw(i)),b=y?.[t]?.[n],x=(0,K.useMemo)(()=>my(_,h,b),[_,h,b]),S=(0,K.useMemo)(()=>yy(_,h),[_,h]),C=(0,K.useMemo)(()=>gy(_?.attributes,h),[_,h]),[w,T]=Sp(null,r),[E,D]=(0,K.useState)(!1),[O,k]=Sp(null,r),A=(0,K.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:j,toggleOn:ee,toggleOff:te}=sw(!1),M=vt({resolver:V(_w)}),{reset:N}=M,F=M.watch(),[ne,re]=Sp(null,[r.clusterId,r.instanceId,t,n]),ie=(0,K.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...Bb(n,r,v[n],x[n]))}catch(e){H.error(String(e))}}return t},[v,x]),oe=(0,K.useCallback)(()=>{let e=ie(F);re(e.length?e:null),N({...F})},[ie,N,F]),se=(0,K.useCallback)(()=>{N({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),N(),re(null),te()},[te,N]);(0,K.useEffect)(function(){return se()},[r,se]);let{filters:ce}=le({strict:!1}),ue=JSON.stringify([t,n,ce??null]),R=(0,K.useRef)(null);(0,K.useEffect)(function(){if(!_||R.current===ue)return;let e=R.current===null;if(R.current=ue,ce){N({...ce});let e=ie(ce);re(e.length?e:null),ee()}else e||se()},[ce,ue,_,N,ie,re,ee,se]);let{dataTableColumns:de,primaryKey:fe}=Ob(_,x),[pe,me]=Sp({attribute:fe,descending:!1},r),[he,ge]=Sp(0,[t,n,ne]),[_e,z]=(0,K.useState)(20),ve=m?.record_count??g?.record_count,ye=m?.estimated_record_range??g?.estimated_record_range,[be,xe]=Sp(!1,[t,n]),{data:Se,isFetching:Ce,isError:we,refetch:Te}=L(mw({...i,enabled:be,databaseName:t,tableName:n})),Ee=(0,K.useCallback)(()=>{be?Te():xe(!0)},[be,Te,xe]),De=Se??ve,Oe=De?Math.ceil(De/_e):0,ke=Se===void 0&&ye!==void 0,Ae=j&&!!ne,{data:je,isFetching:Me}=L(Zp({...i,enabled:!Ae&&!!fe,databaseName:t,tableName:n,searchAttribute:fe,sort:pe,pageSize:_e,pageIndex:he,onlyIfCached:s,getAttributes:S})),{data:Ne,isFetching:Pe}=L(Rb({...i,enabled:Ae&&!!fe,databaseName:t,tableName:n,conditions:ne,sort:pe,pageSize:_e,pageIndex:he,onlyIfCached:s,getAttributes:S})),Fe=Ae?Ne:je,Ie=Me||Pe,{data:Le,isFetching:Re,isError:ze}=L(fw({...i,enabled:E,databaseName:t,tableName:n,ids:w})),Ve=E&&!!O&&(!fe||O[fe]==null),He=Le?.data,Ue=!Ve&&!!w?.length&&!Re&&(ze||Array.isArray(He)&&He.length===0),{mutate:We,isPending:Ge}=gw(),{mutate:Ke,isPending:qe}=dw(),{mutate:Je,isPending:Ye}=lw(),Xe=ae(),Ze=(0,K.useCallback)(()=>Xe.invalidateQueries({queryKey:[i.entityId,t,n]}),[Xe,i.entityId,t,n]),Qe=(0,K.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&Je({...i,databaseName:t},{onSuccess:e=>{H.success(e.message||`Orphan blobs cleanup started successfully`),Ze()},onError:e=>{H.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Je,t,i,Ze]),{exportCsv:$e,isExporting:et}=Kb(),tt=(0,K.useCallback)(()=>{$e({databaseName:t,tableName:n,primaryKey:fe,sort:pe,conditions:Ae?ne:null})},[$e,t,n,fe,pe,Ae,ne]),nt=(0,K.useCallback)(e=>{We({...i,databaseName:t,tableName:n,records:e},{onSuccess:()=>{Ze(),D(!1),H.success(`Record updated successfully`)}})},[We,i,t,n,Ze]),rt=(0,K.useCallback)(e=>{Ke({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{Ze(),D(!1),H.success(`Record deleted successfully`)}})},[Ke,i,t,n,Ze]),it=e=>{let t=fe?e.original[fe]:void 0;k(e.original),T(t==null?null:[t]),D(!0)},at=(e,t)=>{me({attribute:e,descending:!t})},ot=Wd(Ze),st=(0,K.useCallback)(()=>{Hy(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),ct=(0,K.useCallback)(()=>{Hy(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[lt,ut]=Ap(`ColumnDisplayed/${t}/${n}`,{}),dt=(0,K.useMemo)(()=>({...Object.fromEntries(vy(x).map(e=>[e,!1])),...lt}),[x,lt]),[ft,pt]=Ap(`ColumnSizing/${t}/${n}`,{});return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:st,accessKey:`n`,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{children:[`Add `,(0,G.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),u&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:ct,accessKey:`i`,children:[(0,G.jsx)(ur,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:tt,disabled:et,accessKey:`e`,children:[(0,G.jsx)(lr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,G.jsxs)(`div`,{className:`flex space-x-2`,children:[j&&ne&&(0,G.jsxs)(P,{type:`button`,variant:`ghost`,onClick:se,accessKey:`f`,children:[(0,G.jsx)(xr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Clear `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),j&&M.formState.isDirty&&(0,G.jsxs)(P,{variant:`default`,onClick:oe,children:[(0,G.jsx)(br,{className:`inline-block `}),`Apply Filters`]}),j&&!ne&&(0,G.jsxs)(P,{variant:`ghost`,onClick:te,accessKey:`f`,children:[(0,G.jsx)(xr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Hide `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),!j&&(0,G.jsxs)(P,{variant:`ghost`,onClick:ee,accessKey:`f`,children:[(0,G.jsx)(Sr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Show `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,G.jsx)(P,{variant:`defaultOutline`,onClick:ot,disabled:Ie,children:(0,G.jsx)(Yr,{})}),(0,G.jsx)(bw,{columns:de,columnVisibility:dt,setColumnVisibility:ut}),(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,disabled:!e,children:(0,G.jsx)(P,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,G.jsx)(hr,{"aria-label":`Table options`})})}),(0,G.jsxs)(Di,{side:`bottom`,align:`end`,children:[(0,G.jsxs)(Oi,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,G.jsx)(nr,{className:`text-green`}):(0,G.jsx)(ar,{}),`Only If Cached`,(0,G.jsx)(B,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:Cb,children:(0,G.jsx)(gr,{})})]}),p&&l&&!!o&&(0,G.jsxs)(Oi,{className:`focus:bg-yellow/70 focus:text-white`,onClick:Qe,disabled:Ye,children:[(0,G.jsx)(Yn,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),p&&!A&&(0,G.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>Hy(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,G.jsx)(gi,{className:`inline-block `}),`Drop Table`]}),p&&(0,G.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>Hy(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,G.jsx)(hi,{}),`Drop Database`]})]})]})]})]}),(0,G.jsx)(jw,{primaryKey:fe,data:Fe?.data,isFetching:Ie,filtersToggled:j,columns:de,columnVisibility:dt,columnSizing:ft,setColumnSizing:pt,onRowClick:it,onColumnClick:at,totalPages:Oe,totalRecords:De,isEstimatedCount:ke,estimatedRange:ye,isExactCountFetching:Ce,isExactCountError:we,onRequestExactCount:Ee,pageIndex:he,pageSize:_e,columnFiltersForm:M,applyFilters:oe,setPageIndex:ge,setPageSize:z}),(0,G.jsx)(ow,{canEditRecords:d,canDeleteRecords:f,setIsModalOpen:D,isModalOpen:E,primaryKey:fe,missingPrimaryKey:Ve,recordUnavailable:Ue,syntheticAttributes:C,data:Ve||Ue?O?[O]:void 0:Le?.data,onSaveChanges:nt,onDeleteRecord:rt,isUpdateTableRecordsPending:Ge,isDeleteTableRecordsPending:qe})]})}function Iw(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 Lw=10;function Rw(e){return Math.max(200,Math.floor(e/2))}function zw(e,t){return Math.round(Math.min(Math.max(e,200),Rw(t)))}function Bw(){let[e,t]=jn(On.DatabasesSidebarWidth,320),[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(()=>zw(e,window.innerWidth)),o=(0,K.useRef)(i);o.current=i;let s=(0,K.useRef)(null);(0,K.useEffect)(()=>{n||a(zw(e,window.innerWidth))},[e,n]),(0,K.useEffect)(()=>{let t=()=>{n||a(zw(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,K.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,K.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(zw(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,K.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>zw(e-Lw,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>zw(e+Lw,window.innerWidth)))},[t])}}function Vw(){let e=I({strict:!1}),{data:t}=L(g_({...W(),skipRecordCount:!0})),{width:n,isResizing:r,startResizing:i,handleKeyDown:a}=Bw(),o={"--db-sidebar-width":`${n}px`},s=Iw(t,e);return s?(0,G.jsx)(fe,{to:cy({...e,...s}),replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,G.jsxs)(`section`,{style:o,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,G.jsx)(tC,{instanceDatabaseMap:t}),(0,G.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":n,"aria-valuemin":200,"aria-valuemax":Rw(window.innerWidth),onMouseDown:i,onKeyDown:a,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,G.jsx)(`div`,{className:N(`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`,r&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,G.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,G.jsx)(Fw,{instanceDatabaseMap:t,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,G.jsx)(tx,{instanceDatabaseMap:t,databaseName:e.databaseName}):null})]}),t&&(0,G.jsx)(Sb,{instanceDatabaseMap:t})]})}function Hw(e){return R({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:Vw})}var Uw={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function Ww(){let e=lc(),t=I({strict:!1}),{version:n}=Oe({strict:!1}),r=sn(`4.6.0`,n)&&e,i=sn(`4.7.0-beta.7`,n),{data:a}=L(Fm(W(),r)),o=a?.restartRequired??!1,s=(0,K.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?$h(t,`apps`):$h(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,G.jsx)(Kr,{className:`inline-block`})},{to:$h(t,`databases`),icon:(0,G.jsx)(mr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:$h(t,`apis`),name:`APIs`,icon:(0,G.jsx)(ni,{className:`inline-block`})},e&&r&&{to:$h(t,`status`),icon:(0,G.jsx)(Cr,{className:`inline-block`}),name:`Status`},e&&{to:$h(t,`logs`),icon:(0,G.jsx)(Wr,{className:`inline-block`}),name:`Logs`},e&&{to:$h(t,`config`),icon:(0,G.jsx)(ri,{className:`inline-block`}),name:`Config`}].filter(Fn),[e,t,i,r]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Gw,{links:s,restartRequired:o}),(0,G.jsx)(Kw,{links:s,restartRequired:o})]})}function Gw({links:e,restartRequired:t}){return(0,G.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,G.jsx)(Eo,{restartRequired:t}),(0,G.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,G.jsxs)(B,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:Uw,...t,children:[t.icon,(0,G.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,G.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:n}),(0,G.jsx)(Va,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function Kw({links:e,restartRequired:t}){return(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,G.jsx)(Eo,{restartRequired:t}),(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsx)(P,{variant:`ghost`,className:`p-0`,children:(0,G.jsx)(Vr,{className:`h-8 w-8`})})}),(0,G.jsxs)(Di,{children:[(0,G.jsx)(Ai,{children:`Instance Menu`}),(0,G.jsx)(ji,{}),e.map(e=>(0,G.jsx)(Oi,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,activeProps:Uw,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,K.lazy)(()=>Me(()=>import(`./FloatingChat-fBcC1Ew_.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([42,1,4,5,43,11,13,14])));function qw(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Ww,{})}),(0,G.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsx)(Ce,{})}),!1]})}function Jw(e){switch(e){case`local`:return R({getParentRoute:()=>uo,id:`_instanceLayout`,component:qw,loader:oy});case`cluster`:return R({getParentRoute:()=>Ip,id:`_instanceLayout`,component:qw,beforeLoad:Yw,loader:oy});case`instance`:return R({getParentRoute:()=>Ip,path:`instance/$instanceId`,component:qw,beforeLoad:Yw,loader:oy})}}async function Yw({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await Xw(n,e.cluster,t.instanceId)))return;let i=u.getConnectionById(n);if(i.isLoading||i.user)return;let a=e.authentication[h];if(!a||a.isLoading)return;let{update:o}=t.instanceId?cc(a.user,t.organizationId,t.clusterId):oc(a.user,t.organizationId,t.clusterId);if(!(!r&&o&&await Xw(n,e.cluster,t.instanceId)))throw ve({to:`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`,search:ao()})}async function Xw(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:Zw(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function Zw(e,t){if(t){let n=e?.instances?.find(e=>e.id===t);return n?p(n):void 0}return s(e)??void 0}function Qw(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 $w=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],eT=0,tT=new Map,nT=e=>{if(tT.has(e))return tT.get(e);eT++;let t=$w[eT%$w.length];return tT.set(e,t),t};function rT(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 iT({columns:e,data:t,onRowClick:n,containerRef:r}){let i=_e({data:t,columns:e,getCoreRowModel:Se()});return(0,G.jsxs)(hn,{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,G.jsx)(vn,{children:i.getHeaderGroups().map(e=>(0,G.jsx)(fn,{className:`border-b border-border`,children:e.headers.map(e=>(0,G.jsx)(dn,{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:we(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(_n,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,G.jsx)(fn,{"data-state":e.getIsSelected()&&`selected`,className:N(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,rT(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,G.jsx)(pn,{className:`p-2`,children:we(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,G.jsx)(fn,{children:(0,G.jsx)(pn,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}function aT(e){try{JSON.parse(e)}catch{return!1}return!0}function oT(e){return!e||e.length>524288?`plaintext`:aT(e)?`json`:`plaintext`}function sT({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,G.jsx)(`span`,{className:`text-xs`,children:t})]})}function cT({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?nT(n.node):`default`,i=nf();return(0,G.jsx)(Gt,{onOpenChange:e,open:t,children:(0,G.jsxs)(Xt,{"aria-describedby":void 0,resizable:!0,children:[(0,G.jsx)(qt,{children:(0,G.jsx)(en,{children:`Log Entry`})}),n?(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,G.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,G.jsx)(sT,{label:`Level`,children:(0,G.jsx)(qi,{variant:Qw(n.level),children:wo(n.level)})}),(0,G.jsx)(sT,{label:`Timestamp`,children:(0,G.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,G.jsx)(sT,{label:`Thread`,children:(0,G.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,G.jsx)(sT,{label:`Node`,children:(0,G.jsx)(qi,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,G.jsx)(sT,{label:`Tags`,children:(0,G.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,G.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,G.jsx)(af,{className:`w-full h-full`,language:oT(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,G.jsx)(Ui,{})]})})}var lT=j({limit:S().or(k()).or(x()).optional(),level:A([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(k()).or(x()).optional(),from:S().or(k()).or(x()).optional(),until:S().or(k()).or(x()).optional(),log_name:A([`hdb.log`,`system.log`]).or(k()).or(x()).optional(),filter:S().or(k()).or(x()).optional()}),uT=`dark:bg-grey-600 dark:border-grey-500`;function dT({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,G.jsxs)(Ut,{className:N(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,G.jsx)(Bt,{className:`hidden md:block`,children:(0,G.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,G.jsxs)(zt,{className:`flex items-center gap-2 text-base`,children:[(0,G.jsx)(oi,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,G.jsx)(Vt,{id:`logs-filters-content`,children:(0,G.jsx)(q,{...e,children:(0,G.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,G.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(J,{children:(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(ti,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)($,{type:`search`,placeholder:`Search logs…`,className:N(`pl-9`,uT),value:e.value??``,onChange:e.onChange})]})}),(0,G.jsx)(Q,{})]})}),r&&(0,G.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Log file`}),(0,G.jsxs)(rn,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)($t,{className:N(`w-full bg-white`,uT),children:(0,G.jsx)(nn,{placeholder:`Select log file`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Yt,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,G.jsx)(Yt,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Limit`}),(0,G.jsxs)(rn,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)($t,{className:N(`w-full bg-white`,uT),children:(0,G.jsx)(nn,{placeholder:`Limit`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Yt,{value:`1000`,children:`1000`}),(0,G.jsx)(Yt,{value:`500`,children:`500`}),(0,G.jsx)(Yt,{value:`250`,children:`250`}),(0,G.jsx)(Yt,{value:`100`,children:`100`}),(0,G.jsx)(Yt,{value:`10`,children:`10`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Level`}),(0,G.jsxs)(rn,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)($t,{className:N(`w-full bg-white`,uT),children:(0,G.jsx)(nn,{placeholder:`Level`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Yt,{value:`undefined`,children:`All`}),(0,G.jsx)(Yt,{value:`notify`,children:`Notify`}),(0,G.jsx)(Yt,{value:`error`,children:`Error`}),(0,G.jsx)(Yt,{value:`warn`,children:`Warn`}),(0,G.jsx)(Yt,{value:`info`,children:`Info`}),(0,G.jsx)(Yt,{value:`debug`,children:`Debug`}),(0,G.jsx)(Yt,{value:`trace`,children:`Trace`})]})})]}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Start date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:uT,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`End date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:uT,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,G.jsx)(P,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var fT=1e4;function pT(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,fT)}function mT(e,t){return{operation:`read_log`,start:0,replicated:t,limit:pT(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 hT({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,mT(t,n));return r}function gT(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:()=>hT(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function _T({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=kh(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(mT(t,n)),signal:r})}catch(e){throw r?.aborted?e:new Eh(`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 Eh(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of Ch(c.body,r)){if(e.event===`error`){let t=Th(e);if(!t||typeof t!=`object`)throw new Oh(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new Oh(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of vT(Th(e)))i(t)}}function vT(e){return Array.isArray(e)?e.filter(yT):yT(e)?[e]:[]}function yT(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 bT(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function xT(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=bT(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 ST={entries:[],fellBack:!1};function CT(e,t){switch(t.kind){case`reset`:return ST;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 wT(){let e=W();return u.isDirectConnection(e.entityId)}var TT=1e3,ET=2e3,DT=250;function OT(e){return pT(e)??TT}function kT(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function AT({params:e,logFilters:t,replicated:n,live:r}){let i=wT(),[a,o]=(0,K.useReducer)(CT,ST),s=r&&i&&!a.fellBack,c=kT(t,n),l=OT(t.limit),u=Math.max(ET,l),d=L(gT({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,K.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,K.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,K.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,K.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,DT);return _T({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,K.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:xT(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 jT={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},MT={error:(0,G.jsx)(tr,{className:`size-3`}),stderr:(0,G.jsx)(tr,{className:`size-3`}),warn:(0,G.jsx)(_i,{className:`size-3`}),notify:(0,G.jsx)(qn,{className:`size-3`}),info:(0,G.jsx)(Or,{className:`size-3`}),debug:(0,G.jsx)(Xn,{className:`size-3`}),trace:(0,G.jsx)(Un,{className:`size-3`}),stdout:(0,G.jsx)(pi,{className:`size-3`})},NT=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,G.jsxs)(qi,{variant:Qw(t),children:[MT[t],wo(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t);return(0,G.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString(),` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,G.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,G.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=nT(t);return(0,G.jsx)(G.Fragment,{children:t?(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(qi,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,G.jsx)(Va,{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,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],PT=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function FT(){return(0,G.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,G.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,G.jsx)(Yf,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,G.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,G.jsx)(Yf,{className:`h-5 w-14`}),(0,G.jsx)(Yf,{className:`h-5 w-32`}),(0,G.jsx)(Yf,{className:`h-5 w-10`}),(0,G.jsx)(Yf,{className:`h-5 w-20`}),(0,G.jsx)(Yf,{className:`h-5 w-12`}),(0,G.jsx)(Yf,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function IT(){let[e,t]=(0,K.useState)(jT),[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(),[o,s]=(0,K.useState)(!1),[c,l]=jn(On.LogsOrderReversed,!1),[u,d]=(0,K.useState)(!1),f=W(),{data:p}=L(un(f)),m=p?.version,h=!!m&&sn(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=AT({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,K.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,K.useRef)(null);(0,K.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,K.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=vt({resolver:V(lT),defaultValues:jT,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!PT(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(jT)},D=Wd(y);return(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,G.jsx)(oi,{}),`Filters`]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,G.jsx)(Yr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,G.jsxs)(P,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,G.jsx)(bn,{}),`Reverse`]})]}),(0,G.jsx)(dT,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,G.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,G.jsx)(Yr,{}),`Refresh`]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(yf,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,G.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(Yr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(yf,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,G.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(bn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,G.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,G.jsx)(FT,{}):(0,G.jsx)(iT,{columns:NT,data:x,onRowClick:w,containerRef:S})}),(0,G.jsx)(cT,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function LT(e){return R({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:IT})}var RT=6e4,zT=60*RT,BT=24*zT,VT=[{id:`1h`,label:`Last 1 hour`,durationMs:zT,bucketMs:1*RT},{id:`6h`,label:`Last 6 hours`,durationMs:6*zT,bucketMs:1*RT},{id:`24h`,label:`Last 24 hours`,durationMs:BT,bucketMs:5*RT},{id:`7d`,label:`Last 7 days`,durationMs:7*BT,bucketMs:15*RT},{id:`30d`,label:`Last 30 days`,durationMs:30*BT,bucketMs:zT}];function HT(e){let t=VT.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}var UT=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],WT=6e4,GT=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],KT={tab:`health`,range:`1h`,refresh:WT};function qT(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:GT.find(t=>t===e.tab)??KT.tab,range:VT.find(t=>t.id===e.range)?.id??KT.range,refresh:UT.find(e=>e.value===t)?.value??KT.refresh}}function JT(e){return R({getParentRoute:()=>e,path:`status`,validateSearch:qT,search:{middlewares:[ne(KT)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./status-Br_AbsJs.js`),__vite__mapDeps([44,1,3,2,4,5,6,7,8,11,10,12,13,14,32,35,26,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58])),`StatusIndex`)})}function YT(e){let t=Jw(e),n=[LT(t),...Qm(t,e),Zm(t),JT(t),sy(t),Hw(t)];return t.addChildren(n)}R({getParentRoute:()=>uo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./notifications-CMxvWNnz.js`),__vite__mapDeps([59,1,2,3,4,5,6])),`NotificationsCenter`)}),R({getParentRoute:()=>uo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./profile-Doj5FVDE.js`),__vite__mapDeps([60,1,27,3,2,4,5,6,7,31])),`ProfileIndex`)});var XT=lo.addChildren([...Us,uo.addChildren([YT(`local`)])]);function ZT({routeTree:e=XT,authentication:t}){let[n]=(0,K.useState)(()=>he({routeTree:e,history:se(),defaultNotFoundComponent:Ci,defaultErrorComponent:Si,defaultPreload:!wi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Tn,authentication:t||{}}}));return n}function QT(){let e=Ve(),t=ZT({authentication:e}),n=(0,K.useRef)(e);return(0,K.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(me,{router:t,context:{authentication:e}}),(0,G.jsx)(xe,{router:t,position:`bottom-right`})]})}var $T=({...e})=>(0,G.jsx)(Xe,{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}),eE=!1;function tE(){(0,K.useEffect)(()=>{eE||=!0},[])}function nE(){return ho(),so(),tE(),(0,G.jsxs)(ka,{children:[(0,G.jsxs)(ie,{client:Tn,children:[(0,G.jsx)(QT,{}),(0,G.jsx)(Ee,{buttonPosition:`bottom-right`})]}),(0,G.jsx)($T,{richColors:!0})]})}function rE(){u.signOutAllLocally(),Tn.getMutationCache().clear(),Tn.getQueryCache().clear(),Ua(),Wa()}function iE(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var aE=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],oE=`authUserAtSend`;function sE(){let e=u.getConnectionById(h).user;return e&&`id`in e?e.id:null}var cE=!1;function lE(){cE||(cE=!0,M.interceptors.request.use(e=>(e[oE]=sE(),e)),M.interceptors.response.use(e=>e,iE(rE,e=>aE.some(t=>e.startsWith(t)),e=>e?.[oE]===sE())))}function uE(){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 dE=`Studio:StaleDeployReloadedAt`,fE=6e4,pE=`__harperStaleDeployReloadState__`;function mE(){if(!(typeof window>`u`))return window[pE]}function hE(){let e=mE();if(e){try{let e=Number(sessionStorage.getItem(dE)??0);if(Date.now()-e<fE)return;sessionStorage.setItem(dE,String(Date.now()))}catch{return}e.reload()}}function gE(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[pE];if(n){n.reload=e;return}t[pE]={reload:e},window.addEventListener(`vite:preloadError`,()=>hE())}var _E=Fe();uE(),gE(),lE(),(0,_E.createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Ne(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Ne(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Ne(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,G.jsx)(K.StrictMode,{children:(0,G.jsx)(nE,{})}));export{X_ as $,Jr as $n,Zs as $t,uC as A,Ti as An,Ap as At,Uy as B,yi as Bn,Hd as Bt,yC as C,ha as Cn,Dh as Ct,CC as D,na as Dn,Om as Dt,wC as E,ta as En,Fm as Et,nx as F,Ni as Fn,wp as Ft,Ey as G,di as Gn,ol as Gt,Wy as H,gi as Hn,id as Ht,Zb as I,Fi as In,Yf as It,Uv as J,ti as Jn,uc as Jt,Ty as K,ui as Kn,Oc as Kt,Yb as L,Pi as Ln,yf as Lt,LS as M,Oi as Mn,Ep as Mt,eS as N,ji as Nn,Tp as Nt,dC as O,qi as On,om as Ot,rx as P,Mi as Pn,Dp as Pt,uv as Q,Yr as Qn,Ys as Qt,zb as R,Ei as Rn,af as Rt,xC as S,pa as Sn,Nh as St,bC as T,ea as Tn,Sh as Tt,Vy as U,hi as Un,gl as Ut,Hy as V,_i as Vn,Fd as Vt,Dy as W,pi as Wn,cl as Wt,xv as X,Zr as Xn,Ks as Xt,Ev as Y,$r as Yn,lc as Yt,lv as Z,Xr as Zn,Js as Zt,_C as _,Ta as _n,sg as _t,HT as a,Z as an,mr as ar,y_ as at,OC as b,la as bn,Bh as bt,uw as c,Y as cn,tr as cr,Ug as ct,ew as d,ro as dn,Cg as dt,Qs as en,Kr as er,$_ as et,$C as f,Ga as fn,xg as ft,EC as g,Ea as gn,ug as gt,qC as h,Ba as hn,mg as ht,VT as i,Q as in,Or as ir,ov as it,lC as j,Di as jn,Op as jt,oC as k,Ui as kn,Qp as kt,sw as l,J as ln,er as lr,wg as lt,JC as m,Va as mn,hg as mt,qT as n,Ko as nn,Pr as nr,sv as nt,hT as o,Ao as on,fr as or,h_ as ot,XC as p,za as pn,pg as pt,by as q,ii as qn,Dc as qt,UT as r,$ as rn,kr as rr,tv as rt,hw as s,X as sn,rr as sr,Pg as st,hE as t,qs as tn,Ir as tr,ev as tt,QC as u,q as un,Gn as ur,Sg as ut,vC as v,_a as vn,$h as vt,TC as w,da as wn,Eh as wt,kC as x,ca as xn,Ih as xt,DC as y,ga as yn,Hh as yt,Cb as z,Si as zn,nf as zt};
809
- //# sourceMappingURL=index-BHo3c2Gk.js.map
808
+ disabled:pointer-events-none disabled:opacity-50 dark:bg-grey-700 dark:text-white`})]})}function Ow({pageSize:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`hidden items-center gap-2 @min-[960px]:flex`,children:[(0,G.jsx)(`span`,{className:`text-sm whitespace-nowrap text-muted-foreground`,children:`Rows`}),(0,G.jsxs)(rn,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,G.jsx)($t,{"aria-label":`Rows per page`,className:`h-9 w-20`,children:(0,G.jsx)(nn,{})}),(0,G.jsx)(Qt,{side:`top`,children:Cw.map(e=>(0,G.jsx)(Yt,{value:String(e),children:ad(e)},e))})]})]})}function kw(e,t,n=1){if(t<=n*2+5)return Aw(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?[...Aw(1,s),`ellipsis`,t]:a&&!o?[1,`ellipsis`,...Aw(t-s+1,t)]:[1,`ellipsis`,...Aw(r,i),`ellipsis`,t]}function Aw(e,t){return Array.from({length:t-e+1},(t,n)=>e+n)}function jw({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=_e({data:o||[],columns:n,manualPagination:!0,enableColumnResizing:!0,columnResizeMode:`onEnd`,onColumnSizingChange:a,pageCount:g,defaultColumn:{minSize:80},state:{columnVisibility:r,columnSizing:i},rowCount:_,getCoreRowModel:Se(),getPaginationRowModel:Te()}),w=C.getState().columnSizingInfo,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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative flex flex-col grow`,children:[(0,G.jsxs)(hn,{containerClassName:`rounded-md bg-card dark:bg-black-dark grow overflow-visible`,className:`table-fixed`,children:[(0,G.jsx)(vn,{children:C.getHeaderGroups().map(e=>(0,G.jsxs)(fn,{className:`border-none`,children:[e.headers.map(e=>(0,G.jsx)(gn,{header:e,onColumnClick:c,className:`sticky top-32 z-10 bg-card dark:bg-black-dark border-b border-border`},e.id)),(0,G.jsx)(dn,{"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,G.jsx)(vw,{applyFilters:e,columnFiltersForm:t,headerGroups:C.getHeaderGroups()}),(0,G.jsx)(_n,{className:`bg-background dark:bg-black border border-border dark:border-grey-700`,children:C.getRowModel().rows?.length?C.getRowModel().rows.map(e=>(0,G.jsx)(Mw,{row:e,onRowClick:l,primaryKey:f},e.id)):(0,G.jsx)(fn,{children:(0,G.jsx)(pn,{colSpan:n.length+1,className:`h-24 text-center`,children:s||o===void 0?(0,G.jsx)(Sw,{className:`opacity-50 inline-block`}):(0,G.jsx)(`span`,{children:`No results.`})})})})]}),E!==null&&(0,G.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,G.jsx)(ww,{pageIndex:u,pageSize:d,totalPages:g,totalRecords:_,isEstimatedCount:v,estimatedRange:y,isExactCountFetching:b,isExactCountError:x,onRequestExactCount:S,setPageIndex:p,setPageSize:m})]})}function Mw({row:e,primaryKey:t,onRowClick:n}){let r=e.getVisibleCells(),i=(0,K.useMemo)(()=>{let n=e.original;return n&&n.message===`This entry has expired`?r[0]?.column?.id===t?[(0,G.jsx)(Nw,{cell:r[0]},r[0].id),(0,G.jsx)(Pw,{colSpan:r.length-1},`expired`)]:[(0,G.jsx)(Pw,{colSpan:r.length},`expired`)]:r.map(e=>(0,G.jsx)(Nw,{cell:e},e.id))},[e,t,r]);return(0,G.jsxs)(fn,{"data-state":e.getIsSelected()&&`selected`,onClick:()=>n?.(e),className:N(`hover:bg-muted/10 data-[state=selected]:bg-muted`,n&&`cursor-pointer`),children:[i,(0,G.jsx)(pn,{"aria-hidden":!0,className:`p-0`})]})}function Nw({cell:e}){let t=e.column.getSize();return(0,G.jsx)(pn,{"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:we(e.column.columnDef.cell,e.getContext())})}function Pw({colSpan:e}){return(0,G.jsx)(pn,{colSpan:e,className:`px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap`,children:(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`This entry has expired`})})}function Fw({instanceDatabaseMap:e,databaseName:t,tableName:n}){let r=I({strict:!1}),i=W(),{clusterId:a,instanceId:o}=r,{toggled:s,toggle:c}=sw(!0),l=Be(),u=dc(o??a,t,n,`insert`),d=dc(o??a,t,n,`update`),f=dc(o??a,t,n,`delete`),p=uc(),{data:m}=L(Xb({...i,databaseName:t,tableName:n})),h=e?.[t],g=h?.[n],_=m??g,v=(0,K.useMemo)(()=>qc(_?.attributes??[],`attribute`),[_]),{data:y}=L(rw(i)),b=y?.[t]?.[n],x=(0,K.useMemo)(()=>my(_,h,b),[_,h,b]),S=(0,K.useMemo)(()=>yy(_,h),[_,h]),C=(0,K.useMemo)(()=>gy(_?.attributes,h),[_,h]),[w,T]=Sp(null,r),[E,D]=(0,K.useState)(!1),[O,k]=Sp(null,r),A=(0,K.useMemo)(()=>(t?Object.keys(e?.[t]||[]).sort():[]).length===1,[e,t]),{toggled:j,toggleOn:ee,toggleOff:te}=sw(!1),M=vt({resolver:V(_w)}),{reset:N}=M,F=M.watch(),[ne,re]=Sp(null,[r.clusterId,r.instanceId,t,n]),ie=(0,K.useCallback)(e=>{let t=[];for(let n in e){let r=e[n];if(r?.length)try{t.push(...Bb(n,r,v[n],x[n]))}catch(e){H.error(String(e))}}return t},[v,x]),oe=(0,K.useCallback)(()=>{let e=ie(F);re(e.length?e:null),N({...F})},[ie,N,F]),se=(0,K.useCallback)(()=>{N({},{keepValues:!1,keepDirtyValues:!1,keepDefaultValues:!1}),N(),re(null),te()},[te,N]);(0,K.useEffect)(function(){return se()},[r,se]);let{filters:ce}=le({strict:!1}),ue=JSON.stringify([t,n,ce??null]),R=(0,K.useRef)(null);(0,K.useEffect)(function(){if(!_||R.current===ue)return;let e=R.current===null;if(R.current=ue,ce){N({...ce});let e=ie(ce);re(e.length?e:null),ee()}else e||se()},[ce,ue,_,N,ie,re,ee,se]);let{dataTableColumns:de,primaryKey:fe}=Ob(_,x),[pe,me]=Sp({attribute:fe,descending:!1},r),[he,ge]=Sp(0,[t,n,ne]),[_e,z]=(0,K.useState)(20),ve=m?.record_count??g?.record_count,ye=m?.estimated_record_range??g?.estimated_record_range,[be,xe]=Sp(!1,[t,n]),{data:Se,isFetching:Ce,isError:we,refetch:Te}=L(mw({...i,enabled:be,databaseName:t,tableName:n})),Ee=(0,K.useCallback)(()=>{be?Te():xe(!0)},[be,Te,xe]),De=Se??ve,Oe=De?Math.ceil(De/_e):0,ke=Se===void 0&&ye!==void 0,Ae=j&&!!ne,{data:je,isFetching:Me}=L(Zp({...i,enabled:!Ae&&!!fe,databaseName:t,tableName:n,searchAttribute:fe,sort:pe,pageSize:_e,pageIndex:he,onlyIfCached:s,getAttributes:S})),{data:Ne,isFetching:Pe}=L(Rb({...i,enabled:Ae&&!!fe,databaseName:t,tableName:n,conditions:ne,sort:pe,pageSize:_e,pageIndex:he,onlyIfCached:s,getAttributes:S})),Fe=Ae?Ne:je,Ie=Me||Pe,{data:Le,isFetching:Re,isError:ze}=L(fw({...i,enabled:E,databaseName:t,tableName:n,ids:w})),Ve=E&&!!O&&(!fe||O[fe]==null),He=Le?.data,Ue=!Ve&&!!w?.length&&!Re&&(ze||Array.isArray(He)&&He.length===0),{mutate:We,isPending:Ge}=gw(),{mutate:Ke,isPending:qe}=dw(),{mutate:Je,isPending:Ye}=lw(),Xe=ae(),Ze=(0,K.useCallback)(()=>Xe.invalidateQueries({queryKey:[i.entityId,t,n]}),[Xe,i.entityId,t,n]),Qe=(0,K.useCallback)(async()=>{confirm(`Are you sure you want to cleanup orphan blobs for database "${t}"?`)&&Je({...i,databaseName:t},{onSuccess:e=>{H.success(e.message||`Orphan blobs cleanup started successfully`),Ze()},onError:e=>{H.error(e instanceof Error?e.message:`Failed to cleanup orphan blobs`)}})},[Je,t,i,Ze]),{exportCsv:$e,isExporting:et}=Kb(),tt=(0,K.useCallback)(()=>{$e({databaseName:t,tableName:n,primaryKey:fe,sort:pe,conditions:Ae?ne:null})},[$e,t,n,fe,pe,Ae,ne]),nt=(0,K.useCallback)(e=>{We({...i,databaseName:t,tableName:n,records:e},{onSuccess:()=>{Ze(),D(!1),H.success(`Record updated successfully`)}})},[We,i,t,n,Ze]),rt=(0,K.useCallback)(e=>{Ke({...i,databaseName:t,tableName:n,hashValues:e},{onSuccess:()=>{Ze(),D(!1),H.success(`Record deleted successfully`)}})},[Ke,i,t,n,Ze]),it=e=>{let t=fe?e.original[fe]:void 0;k(e.original),T(t==null?null:[t]),D(!0)},at=(e,t)=>{me({attribute:e,descending:!t})},ot=Wd(Ze),st=(0,K.useCallback)(()=>{Hy(`ShowAddTableRecords`,{databaseName:t,tableName:n})},[t,n]),ct=(0,K.useCallback)(()=>{Hy(`ShowImportData`,{databaseName:t,tableName:n})},[t,n]),[lt,ut]=Ap(`ColumnDisplayed/${t}/${n}`,{}),dt=(0,K.useMemo)(()=>({...Object.fromEntries(vy(x).map(e=>[e,!1])),...lt}),[x,lt]),[ft,pt]=Ap(`ColumnSizing/${t}/${n}`,{});return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`div`,{className:`flex space-x-2`,children:[u&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:st,accessKey:`n`,children:[(0,G.jsx)(Jr,{}),(0,G.jsxs)(`span`,{children:[`Add `,(0,G.jsx)(`u`,{children:`N`}),`ew Record(s)`]})]}),u&&(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:ct,accessKey:`i`,children:[(0,G.jsx)(ur,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`I`}),`mport Data`]})]}),(0,G.jsxs)(P,{variant:`positiveOutline`,onClick:tt,disabled:et,accessKey:`e`,children:[(0,G.jsx)(lr,{}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`u`,{children:`E`}),`xport CSV`]})]})]}),(0,G.jsxs)(`div`,{className:`flex space-x-2`,children:[j&&ne&&(0,G.jsxs)(P,{type:`button`,variant:`ghost`,onClick:se,accessKey:`f`,children:[(0,G.jsx)(xr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Clear `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),j&&M.formState.isDirty&&(0,G.jsxs)(P,{variant:`default`,onClick:oe,children:[(0,G.jsx)(br,{className:`inline-block `}),`Apply Filters`]}),j&&!ne&&(0,G.jsxs)(P,{variant:`ghost`,onClick:te,accessKey:`f`,children:[(0,G.jsx)(xr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Hide `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),!j&&(0,G.jsxs)(P,{variant:`ghost`,onClick:ee,accessKey:`f`,children:[(0,G.jsx)(Sr,{className:`inline-block `}),(0,G.jsxs)(`span`,{children:[`Show `,(0,G.jsx)(`u`,{children:`F`}),`ilters`]})]}),(0,G.jsx)(P,{variant:`defaultOutline`,onClick:ot,disabled:Ie,children:(0,G.jsx)(Yr,{})}),(0,G.jsx)(bw,{columns:de,columnVisibility:dt,setColumnVisibility:ut}),(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,disabled:!e,children:(0,G.jsx)(P,{variant:`ghost`,size:`icon`,disabled:!e,children:(0,G.jsx)(hr,{"aria-label":`Table options`})})}),(0,G.jsxs)(Di,{side:`bottom`,align:`end`,children:[(0,G.jsxs)(Oi,{className:`focus:bg-primary/70 focus:text-white`,onClick:c,children:[s?(0,G.jsx)(nr,{className:`text-green`}):(0,G.jsx)(ar,{}),`Only If Cached`,(0,G.jsx)(B,{to:`https://docs.harperdb.io/docs/developers/applications/caching#cache-control-header`,target:`_blank`,rel:`noopener noreferrer`,onClick:Cb,children:(0,G.jsx)(gr,{})})]}),p&&l&&!!o&&(0,G.jsxs)(Oi,{className:`focus:bg-yellow/70 focus:text-white`,onClick:Qe,disabled:Ye,children:[(0,G.jsx)(Yn,{className:`text-yellow `}),`Cleanup Orphan Blobs`]}),p&&!A&&(0,G.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>Hy(`ShowDeleteTable`,{databaseName:t,tableName:n}),children:[(0,G.jsx)(gi,{className:`inline-block `}),`Drop Table`]}),p&&(0,G.jsxs)(Oi,{className:`focus:bg-red/70 focus:text-white`,onClick:()=>Hy(`ShowDeleteDatabase`,{databaseName:t}),children:[(0,G.jsx)(hi,{}),`Drop Database`]})]})]})]})]}),(0,G.jsx)(jw,{primaryKey:fe,data:Fe?.data,isFetching:Ie,filtersToggled:j,columns:de,columnVisibility:dt,columnSizing:ft,setColumnSizing:pt,onRowClick:it,onColumnClick:at,totalPages:Oe,totalRecords:De,isEstimatedCount:ke,estimatedRange:ye,isExactCountFetching:Ce,isExactCountError:we,onRequestExactCount:Ee,pageIndex:he,pageSize:_e,columnFiltersForm:M,applyFilters:oe,setPageIndex:ge,setPageSize:z}),(0,G.jsx)(ow,{canEditRecords:d,canDeleteRecords:f,setIsModalOpen:D,isModalOpen:E,primaryKey:fe,missingPrimaryKey:Ve,recordUnavailable:Ue,syntheticAttributes:C,data:Ve||Ue?O?[O]:void 0:Le?.data,onSaveChanges:nt,onDeleteRecord:rt,isUpdateTableRecordsPending:Ge,isDeleteTableRecordsPending:qe})]})}function Iw(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 Lw=10;function Rw(e){return Math.max(200,Math.floor(e/2))}function zw(e,t){return Math.round(Math.min(Math.max(e,200),Rw(t)))}function Bw(){let[e,t]=jn(On.DatabasesSidebarWidth,320),[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(()=>zw(e,window.innerWidth)),o=(0,K.useRef)(i);o.current=i;let s=(0,K.useRef)(null);(0,K.useEffect)(()=>{n||a(zw(e,window.innerWidth))},[e,n]),(0,K.useEffect)(()=>{let t=()=>{n||a(zw(e,window.innerWidth))};return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,n]);let c=(0,K.useCallback)(e=>{e.preventDefault(),s.current={startX:e.clientX,startWidth:o.current},r(!0)},[]);return(0,K.useEffect)(()=>{if(!n)return;let e=e=>{let t=s.current;t&&a(zw(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,K.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(e=>zw(e-Lw,window.innerWidth))):e.key===`ArrowRight`&&(e.preventDefault(),t(e=>zw(e+Lw,window.innerWidth)))},[t])}}function Vw(){let e=I({strict:!1}),{data:t}=L(g_({...W(),skipRecordCount:!0})),{width:n,isResizing:r,startResizing:i,handleKeyDown:a}=Bw(),o={"--db-sidebar-width":`${n}px`},s=Iw(t,e);return s?(0,G.jsx)(fe,{to:cy({...e,...s}),replace:!0}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`main`,{className:`flex flex-col gap-4 md:flex-row md:items-start`,children:[(0,G.jsxs)(`section`,{style:o,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,G.jsx)(tC,{instanceDatabaseMap:t}),(0,G.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":n,"aria-valuemin":200,"aria-valuemax":Rw(window.innerWidth),onMouseDown:i,onKeyDown:a,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,G.jsx)(`div`,{className:N(`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`,r&&`bg-violet-400/60 dark:bg-violet-500/60`)})})]}),(0,G.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,G.jsx)(Fw,{instanceDatabaseMap:t,databaseName:e.databaseName,tableName:e.tableName}):e.databaseName?(0,G.jsx)(tx,{instanceDatabaseMap:t,databaseName:e.databaseName}):null})]}),t&&(0,G.jsx)(Sb,{instanceDatabaseMap:t})]})}function Hw(e){return R({getParentRoute:()=>e,path:`/databases/{-$databaseName}/{-$tableName}`,head:()=>({meta:[{title:`Databases — Harper Fabric`}]}),component:Vw})}var Uw={className:`text-primary font-semibold bg-primary/10 rounded-md dark:text-white dark:bg-white/10`};function Ww(){let e=lc(),t=I({strict:!1}),{version:n}=Oe({strict:!1}),r=sn(`4.6.0`,n)&&e,i=sn(`4.7.0-beta.7`,n),{data:a}=L(Fm(W(),r)),o=a?.restartRequired??!1,s=(0,K.useMemo)(()=>[e&&{to:t.clusterId&&!t.instanceId?$h(t,`apps`):$h(t),activeOptions:{exact:!0},name:`Applications`,shortName:`Apps`,icon:(0,G.jsx)(Kr,{className:`inline-block`})},{to:$h(t,`databases`),icon:(0,G.jsx)(mr,{className:`inline-block`}),name:`Databases`},e&&i&&{to:$h(t,`apis`),name:`APIs`,icon:(0,G.jsx)(ni,{className:`inline-block`})},e&&r&&{to:$h(t,`status`),icon:(0,G.jsx)(Cr,{className:`inline-block`}),name:`Status`},e&&{to:$h(t,`logs`),icon:(0,G.jsx)(Wr,{className:`inline-block`}),name:`Logs`},e&&{to:$h(t,`config`),icon:(0,G.jsx)(ri,{className:`inline-block`}),name:`Config`}].filter(Fn),[e,t,i,r]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Gw,{links:s,restartRequired:o}),(0,G.jsx)(Kw,{links:s,restartRequired:o})]})}function Gw({links:e,restartRequired:t}){return(0,G.jsxs)(`div`,{className:`hidden md:[@media(hover:hover)]:flex xl:flex items-center justify-between h-full text-sm text-foreground`,children:[(0,G.jsx)(Eo,{restartRequired:t}),(0,G.jsx)(`div`,{className:`flex space-x-2`,children:e.map(({shortName:e,...t})=>{let n=(0,G.jsxs)(B,{"aria-label":t.name,className:`p-2 text-center text-muted-foreground hover:text-foreground`,activeProps:Uw,...t,children:[t.icon,(0,G.jsx)(`span`,{className:`hidden xl:inline-block ml-1`,children:t.name}),e&&(0,G.jsx)(`span`,{className:`visible xl:hidden ml-1`,children:e})]},t.to);return e?n:(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:n}),(0,G.jsx)(Va,{side:`bottom`,className:`xl:hidden`,children:t.name})]},t.to)})})]})}function Kw({links:e,restartRequired:t}){return(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex md:[@media(hover:hover)]:hidden xl:hidden items-center justify-between h-full px-2 text-foreground`,children:[(0,G.jsx)(Eo,{restartRequired:t}),(0,G.jsxs)(Ti,{children:[(0,G.jsx)(Ei,{asChild:!0,children:(0,G.jsx)(P,{variant:`ghost`,className:`p-0`,children:(0,G.jsx)(Vr,{className:`h-8 w-8`})})}),(0,G.jsxs)(Di,{children:[(0,G.jsx)(Ai,{children:`Instance Menu`}),(0,G.jsx)(ji,{}),e.map(e=>(0,G.jsx)(Oi,{asChild:!0,children:(0,G.jsxs)(B,{to:e.to,activeProps:Uw,className:`flex items-center gap-2`,children:[e.icon,e.name]})},e.to))]})]})]})})}(0,K.lazy)(()=>Me(()=>import(`./FloatingChat-UZ2NsUOZ.js`).then(e=>({default:e.FloatingChat})),__vite__mapDeps([42,1,4,5,43,11,13,14])));function qw(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(Ww,{})}),(0,G.jsx)(`div`,{className:`mt-32 min-h-[calc(100vh-(--spacing(32)))]`,children:(0,G.jsx)(Ce,{})}),!1]})}function Jw(e){switch(e){case`local`:return R({getParentRoute:()=>uo,id:`_instanceLayout`,component:qw,loader:oy});case`cluster`:return R({getParentRoute:()=>Ip,id:`_instanceLayout`,component:qw,beforeLoad:Yw,loader:oy});case`instance`:return R({getParentRoute:()=>Ip,path:`instance/$instanceId`,component:qw,beforeLoad:Yw,loader:oy})}}async function Yw({context:e,params:t}){let n=t.instanceId||t.clusterId,r=!1;if(u.checkForFabricConnect(n)&&!u.hasResolvedFabricConnect(n)&&(r=!0,await Xw(n,e.cluster,t.instanceId)))return;let i=u.getConnectionById(n);if(i.isLoading||i.user)return;let a=e.authentication[h];if(!a||a.isLoading)return;let{update:o}=t.instanceId?cc(a.user,t.organizationId,t.clusterId):oc(a.user,t.organizationId,t.clusterId);if(!(!r&&o&&await Xw(n,e.cluster,t.instanceId)))throw ve({to:`/${t.organizationId}/${t.clusterId}/`+(t.instanceId?`instance/${t.instanceId}`:``)+`/sign-in`,search:ao()})}async function Xw(e,t,n){try{return await u.establishFabricConnectAuth({id:e,operationsUrl:Zw(t,n)}),!0}catch(e){return console.debug(`Fabric Connect not established`,e),!1}}function Zw(e,t){if(t){let n=e?.instances?.find(e=>e.id===t);return n?p(n):void 0}return s(e)??void 0}function Qw(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 $w=[`secondary`,`default`,`warning`,`outline`,`success`,`destructive`],eT=0,tT=new Map,nT=e=>{if(tT.has(e))return tT.get(e);eT++;let t=$w[eT%$w.length];return tT.set(e,t),t};function rT(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 iT({columns:e,data:t,onRowClick:n,containerRef:r}){let i=_e({data:t,columns:e,getCoreRowModel:Se()});return(0,G.jsxs)(hn,{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,G.jsx)(vn,{children:i.getHeaderGroups().map(e=>(0,G.jsx)(fn,{className:`border-b border-border`,children:e.headers.map(e=>(0,G.jsx)(dn,{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:we(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,G.jsx)(_n,{className:`bg-background dark:bg-black`,children:i.getRowModel().rows?.length?i.getRowModel().rows.map(e=>(0,G.jsx)(fn,{"data-state":e.getIsSelected()&&`selected`,className:N(`hover:bg-muted/20 data-[state=selected]:bg-muted max-w-full border-l-2`,rT(e.original.level),n&&`cursor-pointer`),onClick:()=>n?.(e),children:e.getVisibleCells().map(e=>(0,G.jsx)(pn,{className:`p-2`,children:we(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,G.jsx)(fn,{children:(0,G.jsx)(pn,{colSpan:e.length,className:`h-24 text-center`,children:`No results.`})})})]})}function aT(e){try{JSON.parse(e)}catch{return!1}return!0}function oT(e){return!e||e.length>524288?`plaintext`:aT(e)?`json`:`plaintext`}function sT({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 py-1.5 border-b border-border/50 last:border-0`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground w-20 shrink-0 pt-0.5`,children:e}),(0,G.jsx)(`span`,{className:`text-xs`,children:t})]})}function cT({setIsModalOpen:e,isModalOpen:t,data:n}){let r=n?nT(n.node):`default`,i=nf();return(0,G.jsx)(Gt,{onOpenChange:e,open:t,children:(0,G.jsxs)(Xt,{"aria-describedby":void 0,resizable:!0,children:[(0,G.jsx)(qt,{children:(0,G.jsx)(en,{children:`Log Entry`})}),n?(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 text-popover-foreground`,children:[(0,G.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/20 px-3 py-1`,children:[(0,G.jsx)(sT,{label:`Level`,children:(0,G.jsx)(qi,{variant:Qw(n.level),children:wo(n.level)})}),(0,G.jsx)(sT,{label:`Timestamp`,children:(0,G.jsx)(`span`,{className:`tabular-nums`,children:new Date(n.timestamp).toLocaleString()})}),(0,G.jsx)(sT,{label:`Thread`,children:(0,G.jsx)(`span`,{className:`tabular-nums font-mono`,children:n.thread})}),n.node&&(0,G.jsx)(sT,{label:`Node`,children:(0,G.jsx)(qi,{variant:r,children:n.node})}),n.tags&&n.tags.length>0&&(0,G.jsx)(sT,{label:`Tags`,children:(0,G.jsx)(`span`,{className:`font-mono`,children:n.tags})})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1.5`,children:`Message`}),(0,G.jsx)(`div`,{className:`rounded-md overflow-hidden border border-border/50 flex-1 min-h-0`,children:(0,G.jsx)(af,{className:`w-full h-full`,language:oT(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,G.jsx)(Ui,{})]})})}var lT=j({limit:S().or(k()).or(x()).optional(),level:A([`notify`,`error`,`warn`,`info`,`debug`,`trace`,`undefined`]).or(k()).or(x()).optional(),from:S().or(k()).or(x()).optional(),until:S().or(k()).or(x()).optional(),log_name:A([`hdb.log`,`system.log`]).or(k()).or(x()).optional(),filter:S().or(k()).or(x()).optional()}),uT=`dark:bg-grey-600 dark:border-grey-500`;function dT({form:e,resetFilters:t,submitFilters:n,showLogName:r,showFilter:i,isOpen:a,onOpenChange:o}){return(0,G.jsxs)(Ut,{className:N(a?`block`:`hidden`,`mt-3 md:mt-0 md:block`),children:[(0,G.jsx)(Bt,{className:`hidden md:block`,children:(0,G.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,G.jsxs)(zt,{className:`flex items-center gap-2 text-base`,children:[(0,G.jsx)(oi,{className:`size-4 text-muted-foreground`}),`Filters`]})})}),(0,G.jsx)(Vt,{id:`logs-filters-content`,children:(0,G.jsx)(q,{...e,children:(0,G.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,G.jsx)(Y,{control:e.control,name:`filter`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(J,{children:(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(ti,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)($,{type:`search`,placeholder:`Search logs…`,className:N(`pl-9`,uT),value:e.value??``,onChange:e.onChange})]})}),(0,G.jsx)(Q,{})]})}),r&&(0,G.jsx)(Y,{control:e.control,name:`log_name`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Log file`}),(0,G.jsxs)(rn,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)($t,{className:N(`w-full bg-white`,uT),children:(0,G.jsx)(nn,{placeholder:`Select log file`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Yt,{value:`hdb.log`,children:`Application (hdb.log)`}),(0,G.jsx)(Yt,{value:`system.log`,children:`System (system.log)`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsx)(Y,{control:e.control,name:`limit`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Limit`}),(0,G.jsxs)(rn,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)($t,{className:N(`w-full bg-white`,uT),children:(0,G.jsx)(nn,{placeholder:`Limit`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Yt,{value:`1000`,children:`1000`}),(0,G.jsx)(Yt,{value:`500`,children:`500`}),(0,G.jsx)(Yt,{value:`250`,children:`250`}),(0,G.jsx)(Yt,{value:`100`,children:`100`}),(0,G.jsx)(Yt,{value:`10`,children:`10`})]})})]}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`level`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Level`}),(0,G.jsxs)(rn,{onValueChange:e.onChange,value:e.value??void 0,children:[(0,G.jsx)($t,{className:N(`w-full bg-white`,uT),children:(0,G.jsx)(nn,{placeholder:`Level`})}),(0,G.jsx)(Qt,{children:(0,G.jsxs)(tn,{children:[(0,G.jsx)(Yt,{value:`undefined`,children:`All`}),(0,G.jsx)(Yt,{value:`notify`,children:`Notify`}),(0,G.jsx)(Yt,{value:`error`,children:`Error`}),(0,G.jsx)(Yt,{value:`warn`,children:`Warn`}),(0,G.jsx)(Yt,{value:`info`,children:`Info`}),(0,G.jsx)(Yt,{value:`debug`,children:`Debug`}),(0,G.jsx)(Yt,{value:`trace`,children:`Trace`})]})})]}),(0,G.jsx)(Q,{})]})})]}),(0,G.jsx)(Y,{control:e.control,name:`from`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`Start date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:uT,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsx)(Y,{control:e.control,name:`until`,render:({field:e})=>(0,G.jsxs)(X,{children:[(0,G.jsx)(Z,{children:`End date`}),(0,G.jsx)(J,{children:(0,G.jsx)($,{type:`datetime-local`,className:uT,value:e.value??void 0,onChange:e.onChange})}),(0,G.jsx)(Q,{})]})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(P,{type:`submit`,variant:`positiveOutline`,className:`grow`,children:`Apply Filters`}),(0,G.jsx)(P,{type:`reset`,variant:`destructiveOutline`,onClick:t,children:`Clear`})]})]})})})]})}var fT=1e4;function pT(e){if(!e)return;let t=parseInt(e,10);if(!(!Number.isFinite(t)||t<=0))return Math.min(t,fT)}function mT(e,t){return{operation:`read_log`,start:0,replicated:t,limit:pT(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 hT({instanceClient:e,logFilters:t,replicated:n}){let{data:r}=await e.post(`/`,mT(t,n));return r}function gT(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:()=>hT(e),retry:!1,refetchInterval:e.isAutoRefreshEnabled?5e3:!1})}async function _T({connection:e,logFilters:t,replicated:n,signal:r,onEntry:i}){let{url:a,headers:o,credentials:s}=kh(e),c;try{c=await fetch(a,{method:`POST`,headers:o,credentials:s,body:JSON.stringify(mT(t,n)),signal:r})}catch(e){throw r?.aborted?e:new Eh(`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 Eh(`read_log did not return an event stream (status ${c.status}, content-type "${l}").`);for await(let e of Ch(c.body,r)){if(e.event===`error`){let t=Th(e);if(!t||typeof t!=`object`)throw new Oh(typeof t==`string`&&t?t:`The log stream failed.`);let n=t;throw new Oh(n.message??`The log stream failed.`,{code:n.code})}if(e.event===`done`||e.event===`end`)return;for(let t of vT(Th(e)))i(t)}}function vT(e){return Array.isArray(e)?e.filter(yT):yT(e)?[e]:[]}function yT(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 bT(e){return[e.timestamp,e.node??``,e.thread??``,e.level,e.message].join(`|`)}function xT(e,t,n){let r=new Set,i=[];for(let n of[...t,...e]){let e=bT(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 ST={entries:[],fellBack:!1};function CT(e,t){switch(t.kind){case`reset`:return ST;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 wT(){let e=W();return u.isDirectConnection(e.entityId)}var TT=1e3,ET=2e3,DT=250;function OT(e){return pT(e)??TT}function kT(e,t){return JSON.stringify([e.limit,e.level,e.from,e.until,e.log_name,e.filter,t])}function AT({params:e,logFilters:t,replicated:n,live:r}){let i=wT(),[a,o]=(0,K.useReducer)(CT,ST),s=r&&i&&!a.fellBack,c=kT(t,n),l=OT(t.limit),u=Math.max(ET,l),d=L(gT({...e,logFilters:t,replicated:n,isAutoRefreshEnabled:r&&!s}));(0,K.useEffect)(()=>{o({kind:`reset`})},[e.entityId,c]),(0,K.useEffect)(()=>{r&&o({kind:`retry`})},[r]);let f=(0,K.useRef)({logFilters:t,replicated:n});f.current={logFilters:t,replicated:n},(0,K.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,DT);return _T({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,K.useMemo)(()=>{let e=d.data??[];return a.entries.length===0?e:xT(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 jT={log_name:`hdb.log`,limit:`100`,level:`undefined`,from:``,until:``,filter:``},MT={error:(0,G.jsx)(tr,{className:`size-3`}),stderr:(0,G.jsx)(tr,{className:`size-3`}),warn:(0,G.jsx)(_i,{className:`size-3`}),notify:(0,G.jsx)(qn,{className:`size-3`}),info:(0,G.jsx)(Or,{className:`size-3`}),debug:(0,G.jsx)(Xn,{className:`size-3`}),trace:(0,G.jsx)(Un,{className:`size-3`}),stdout:(0,G.jsx)(pi,{className:`size-3`})},NT=[{accessorKey:`level`,header:`Level`,cell:({row:e})=>{let{level:t}=e.original;return(0,G.jsxs)(qi,{variant:Qw(t),children:[MT[t],wo(t)]})}},{accessorKey:`timestamp`,header:`Timestamp`,cell:({row:e})=>{let{timestamp:t}=e.original,n=new Date(t);return(0,G.jsxs)(`span`,{className:`tabular-nums whitespace-nowrap text-muted-foreground`,children:[n.getFullYear()===new Date().getFullYear()?n.toLocaleDateString(void 0,{month:`numeric`,day:`2-digit`}):n.toLocaleDateString(),` `,n.toLocaleTimeString()]})}},{accessorKey:`message`,header:`Message`,cell:({row:e})=>{let{message:t}=e.original;return(0,G.jsx)(`span`,{className:`block max-w-xl truncate font-mono text-xs`,children:t})}},{accessorKey:`thread`,header:`Thread`,cell:({row:e})=>(0,G.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=nT(t);return(0,G.jsx)(G.Fragment,{children:t?(0,G.jsxs)(za,{children:[(0,G.jsx)(Ba,{asChild:!0,children:(0,G.jsxs)(qi,{variant:n,children:[t.split(`.`)[0],`...`]})}),(0,G.jsx)(Va,{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,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null}}],PT=(e,t)=>!e&&!t||!e||!t||new Date(e)<=new Date(t);function FT(){return(0,G.jsxs)(`div`,{className:`rounded-md bg-card dark:bg-black-dark overflow-hidden`,children:[(0,G.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,G.jsx)(Yf,{className:`h-4 ${e}`},t))}),Array.from({length:12}).map((e,t)=>(0,G.jsxs)(`div`,{className:`flex gap-4 p-3 border-b border-border/40 border-l-2 border-l-transparent`,children:[(0,G.jsx)(Yf,{className:`h-5 w-14`}),(0,G.jsx)(Yf,{className:`h-5 w-32`}),(0,G.jsx)(Yf,{className:`h-5 w-10`}),(0,G.jsx)(Yf,{className:`h-5 w-20`}),(0,G.jsx)(Yf,{className:`h-5 w-12`}),(0,G.jsx)(Yf,{className:`h-5 flex-1 max-w-xs`})]},t))]})}function IT(){let[e,t]=(0,K.useState)(jT),[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(),[o,s]=(0,K.useState)(!1),[c,l]=jn(On.LogsOrderReversed,!1),[u,d]=(0,K.useState)(!1),f=W(),{data:p}=L(un(f)),m=p?.version,h=!!m&&sn(`4.7.16`,m),{logs:g,isLoading:_,isFetching:v,refetch:y,transport:b}=AT({params:f,logFilters:e,replicated:f.entityType===`cluster`,live:o}),x=(0,K.useMemo)(()=>c?[...g??[]].reverse():g??[],[g,c]),S=(0,K.useRef)(null);(0,K.useEffect)(()=>{let e=S.current;_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[c,_]),(0,K.useEffect)(()=>{let e=S.current;!o||_||!e||e.scrollTo({top:c?e.scrollHeight:0})},[x,o,c,_]);let C=vt({resolver:V(lT),defaultValues:jT,mode:`onChange`}),w=e=>{a(e.original),r(!0)},T=async e=>{if(!PT(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(jT)},D=Wd(y);return(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 pt-2 text-foreground md:grid-cols-12 md:gap-4`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 md:hidden`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:()=>d(e=>!e),"aria-label":`Toggle filters`,"aria-expanded":u,className:`flex-1`,children:[(0,G.jsx)(oi,{}),`Filters`]}),(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,"aria-label":`Refresh logs`,className:`flex-1`,children:[(0,G.jsx)(Yr,{className:v?`animate-spin`:``}),`Refresh`]}),(0,G.jsxs)(P,{variant:c?`default`:`defaultOutline`,onClick:()=>l(e=>!e),"aria-label":`Reverse log order`,"aria-pressed":c,className:`flex-1`,children:[(0,G.jsx)(bn,{}),`Reverse`]})]}),(0,G.jsx)(dT,{form:C,resetFilters:E,submitFilters:T,showLogName:!1,showFilter:h,isOpen:u,onOpenChange:d}),(0,G.jsxs)(`div`,{className:`mt-3 space-y-3 hidden md:block`,children:[(0,G.jsxs)(P,{variant:`defaultOutline`,onClick:D,disabled:v||_||o,className:`w-full`,children:[(0,G.jsx)(Yr,{}),`Refresh`]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(yf,{id:`logs-live-switch`,"aria-label":`Toggle live logs`,checked:o,onCheckedChange:s}),(0,G.jsxs)(`label`,{htmlFor:`logs-live-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(Yr,{className:`size-4 ${o?`animate-spin [animation-duration:3s]`:``}`}),o?b===`streaming`?`Live (streaming)`:`Live (polling every 5s)`:`Live`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[(0,G.jsx)(yf,{id:`logs-reverse-order-switch`,"aria-label":`Reverse log order`,checked:c,onCheckedChange:l}),(0,G.jsxs)(`label`,{htmlFor:`logs-reverse-order-switch`,className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(bn,{className:`size-4`}),c?`Oldest first`:`Newest first`]})]})]})]})]}),(0,G.jsx)(`section`,{className:`col-span-1 md:col-span-8 lg:col-span-9`,children:_?(0,G.jsx)(FT,{}):(0,G.jsx)(iT,{columns:NT,data:x,onRowClick:w,containerRef:S})}),(0,G.jsx)(cT,{isModalOpen:n,setIsModalOpen:r,data:i})]})}function LT(e){return R({getParentRoute:()=>e,path:`logs`,head:()=>({meta:[{title:`Logs — Harper Fabric`}]}),component:IT})}var RT=6e4,zT=60*RT,BT=24*zT,VT=[{id:`1h`,label:`Last 1 hour`,durationMs:zT,bucketMs:1*RT},{id:`6h`,label:`Last 6 hours`,durationMs:6*zT,bucketMs:1*RT},{id:`24h`,label:`Last 24 hours`,durationMs:BT,bucketMs:5*RT},{id:`7d`,label:`Last 7 days`,durationMs:7*BT,bucketMs:15*RT},{id:`30d`,label:`Last 30 days`,durationMs:30*BT,bucketMs:zT}];function HT(e){let t=VT.find(t=>t.id===e);if(!t)throw Error(`Unknown preset: ${e}`);return t}var UT=[{label:`Off`,value:0},{label:`30s`,value:3e4},{label:`60s`,value:6e4},{label:`5m`,value:3e5}],WT=6e4,GT=[`health`,`traffic`,`requests`,`database`,`replication`,`storage`,`overview`],KT={tab:`health`,range:`1h`,refresh:WT};function qT(e){let t=e.refresh===``?NaN:Number(e.refresh);return{tab:GT.find(t=>t===e.tab)??KT.tab,range:VT.find(t=>t.id===e.range)?.id??KT.range,refresh:UT.find(e=>e.value===t)?.value??KT.refresh}}function JT(e){return R({getParentRoute:()=>e,path:`status`,validateSearch:qT,search:{middlewares:[ne(KT)]},head:()=>({meta:[{title:`Status — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./status-BAod7p3o.js`),__vite__mapDeps([44,1,3,2,4,5,6,7,8,11,10,12,13,14,32,35,26,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58])),`StatusIndex`)})}function YT(e){let t=Jw(e),n=[LT(t),...Qm(t,e),Zm(t),JT(t),sy(t),Hw(t)];return t.addChildren(n)}R({getParentRoute:()=>uo,path:`notifications`,head:()=>({meta:[{title:`Notifications — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./notifications-0edoFTsb.js`),__vite__mapDeps([59,1,2,3,4,5,6])),`NotificationsCenter`)}),R({getParentRoute:()=>uo,path:`profile`,head:()=>({meta:[{title:`Profile — Harper Fabric`}]}),component:be(async()=>Me(()=>import(`./profile-DUfEPQtx.js`),__vite__mapDeps([60,1,27,3,2,4,5,6,7,31])),`ProfileIndex`)});var XT=lo.addChildren([...Us,uo.addChildren([YT(`local`)])]);function ZT({routeTree:e=XT,authentication:t}){let[n]=(0,K.useState)(()=>he({routeTree:e,history:se(),defaultNotFoundComponent:Ci,defaultErrorComponent:Si,defaultPreload:!wi()&&`intent`,trailingSlash:`never`,defaultPreloadStaleTime:0,scrollRestoration:!0,context:{queryClient:Tn,authentication:t||{}}}));return n}function QT(){let e=Ve(),t=ZT({authentication:e}),n=(0,K.useRef)(e);return(0,K.useEffect)(()=>{n.current!==e&&(n.current=e,t.invalidate())},[t,e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(me,{router:t,context:{authentication:e}}),(0,G.jsx)(xe,{router:t,position:`bottom-right`})]})}var $T=({...e})=>(0,G.jsx)(Xe,{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}),eE=!1;function tE(){(0,K.useEffect)(()=>{eE||=!0},[])}function nE(){return ho(),so(),tE(),(0,G.jsxs)(ka,{children:[(0,G.jsxs)(ie,{client:Tn,children:[(0,G.jsx)(QT,{}),(0,G.jsx)(Ee,{buttonPosition:`bottom-right`})]}),(0,G.jsx)($T,{richColors:!0})]})}function rE(){u.signOutAllLocally(),Tn.getMutationCache().clear(),Tn.getQueryCache().clear(),Ua(),Wa()}function iE(e,t=()=>!1,n=()=>!0){return r=>(r?.response?.status===401&&!t(r.config?.url??``)&&n(r.config)&&e(),Promise.reject(r))}var aE=[`/Login/`,`/ForgotPassword/`,`/ResetPassword/`,`/VerifyEmail/`,`/ResendVerificationEmail/`],oE=`authUserAtSend`;function sE(){let e=u.getConnectionById(h).user;return e&&`id`in e?e.id:null}var cE=!1;function lE(){cE||(cE=!0,M.interceptors.request.use(e=>(e[oE]=sE(),e)),M.interceptors.response.use(e=>e,iE(rE,e=>aE.some(t=>e.startsWith(t)),e=>e?.[oE]===sE())))}function uE(){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 dE=`Studio:StaleDeployReloadedAt`,fE=6e4,pE=`__harperStaleDeployReloadState__`;function mE(){if(!(typeof window>`u`))return window[pE]}function hE(){let e=mE();if(e){try{let e=Number(sessionStorage.getItem(dE)??0);if(Date.now()-e<fE)return;sessionStorage.setItem(dE,String(Date.now()))}catch{return}e.reload()}}function gE(e=()=>window.location.reload()){if(typeof window>`u`)return;let t=window,n=t[pE];if(n){n.reload=e;return}t[pE]={reload:e},window.addEventListener(`vite:preloadError`,()=>hE())}var _E=Fe();uE(),gE(),lE(),(0,_E.createRoot)(document.getElementById(`root`),{onUncaughtError:(e,t)=>{Ne(e,t),console.error(`Uncaught error:`,e,t)},onCaughtError:(e,t)=>{Ne(e,t),console.error(`Caught error:`,e,t)},onRecoverableError:(e,t)=>{Ne(e,t),console.warn(`Recoverable error:`,e,t)}}).render((0,G.jsx)(K.StrictMode,{children:(0,G.jsx)(nE,{})}));export{X_ as $,Jr as $n,Zs as $t,uC as A,Ti as An,Ap as At,Uy as B,yi as Bn,Hd as Bt,yC as C,ha as Cn,Dh as Ct,CC as D,na as Dn,Om as Dt,wC as E,ta as En,Fm as Et,nx as F,Ni as Fn,wp as Ft,Ey as G,di as Gn,ol as Gt,Wy as H,gi as Hn,id as Ht,Zb as I,Fi as In,Yf as It,Uv as J,ti as Jn,uc as Jt,Ty as K,ui as Kn,Oc as Kt,Yb as L,Pi as Ln,yf as Lt,LS as M,Oi as Mn,Ep as Mt,eS as N,ji as Nn,Tp as Nt,dC as O,qi as On,om as Ot,rx as P,Mi as Pn,Dp as Pt,uv as Q,Yr as Qn,Ys as Qt,zb as R,Ei as Rn,af as Rt,xC as S,pa as Sn,Nh as St,bC as T,ea as Tn,Sh as Tt,Vy as U,hi as Un,gl as Ut,Hy as V,_i as Vn,Fd as Vt,Dy as W,pi as Wn,cl as Wt,xv as X,Zr as Xn,Ks as Xt,Ev as Y,$r as Yn,lc as Yt,lv as Z,Xr as Zn,Js as Zt,_C as _,Ta as _n,sg as _t,HT as a,Z as an,mr as ar,y_ as at,OC as b,la as bn,Bh as bt,uw as c,Y as cn,tr as cr,Ug as ct,ew as d,ro as dn,Cg as dt,Qs as en,Kr as er,$_ as et,$C as f,Ga as fn,xg as ft,EC as g,Ea as gn,ug as gt,qC as h,Ba as hn,mg as ht,VT as i,Q as in,Or as ir,ov as it,lC as j,Di as jn,Op as jt,oC as k,Ui as kn,Qp as kt,sw as l,J as ln,er as lr,wg as lt,JC as m,Va as mn,hg as mt,qT as n,Ko as nn,Pr as nr,sv as nt,hT as o,Ao as on,fr as or,h_ as ot,XC as p,za as pn,pg as pt,by as q,ii as qn,Dc as qt,UT as r,$ as rn,kr as rr,tv as rt,hw as s,X as sn,rr as sr,Pg as st,hE as t,qs as tn,Ir as tr,ev as tt,QC as u,q as un,Gn as ur,Sg as ut,vC as v,_a as vn,$h as vt,TC as w,da as wn,Eh as wt,kC as x,ca as xn,Ih as xt,DC as y,ga as yn,Hh as yt,Cb as z,Si as zn,nf as zt};
809
+ //# sourceMappingURL=index-Bh_CNAHr.js.map