skypilot-nightly 1.0.0.dev20251210__py3-none-any.whl → 1.0.0.dev20260112__py3-none-any.whl

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 (207) hide show
  1. sky/__init__.py +4 -2
  2. sky/adaptors/slurm.py +159 -72
  3. sky/backends/backend_utils.py +52 -10
  4. sky/backends/cloud_vm_ray_backend.py +192 -32
  5. sky/backends/task_codegen.py +40 -2
  6. sky/catalog/data_fetchers/fetch_gcp.py +9 -1
  7. sky/catalog/data_fetchers/fetch_nebius.py +1 -1
  8. sky/catalog/data_fetchers/fetch_vast.py +4 -2
  9. sky/catalog/seeweb_catalog.py +30 -15
  10. sky/catalog/shadeform_catalog.py +5 -2
  11. sky/catalog/slurm_catalog.py +0 -7
  12. sky/catalog/vast_catalog.py +30 -6
  13. sky/check.py +11 -8
  14. sky/client/cli/command.py +106 -54
  15. sky/client/interactive_utils.py +190 -0
  16. sky/client/sdk.py +8 -0
  17. sky/client/sdk_async.py +9 -0
  18. sky/clouds/aws.py +60 -2
  19. sky/clouds/azure.py +2 -0
  20. sky/clouds/kubernetes.py +2 -0
  21. sky/clouds/runpod.py +38 -7
  22. sky/clouds/slurm.py +44 -12
  23. sky/clouds/ssh.py +1 -1
  24. sky/clouds/vast.py +30 -17
  25. sky/core.py +69 -1
  26. sky/dashboard/out/404.html +1 -1
  27. sky/dashboard/out/_next/static/3nu-b8raeKRNABZ2d4GAG/_buildManifest.js +1 -0
  28. sky/dashboard/out/_next/static/chunks/1871-0565f8975a7dcd10.js +6 -0
  29. sky/dashboard/out/_next/static/chunks/2109-55a1546d793574a7.js +11 -0
  30. sky/dashboard/out/_next/static/chunks/2521-099b07cd9e4745bf.js +26 -0
  31. sky/dashboard/out/_next/static/chunks/2755.a636e04a928a700e.js +31 -0
  32. sky/dashboard/out/_next/static/chunks/3495.05eab4862217c1a5.js +6 -0
  33. sky/dashboard/out/_next/static/chunks/3785.cfc5dcc9434fd98c.js +1 -0
  34. sky/dashboard/out/_next/static/chunks/3981.645d01bf9c8cad0c.js +21 -0
  35. sky/dashboard/out/_next/static/chunks/4083-0115d67c1fb57d6c.js +21 -0
  36. sky/dashboard/out/_next/static/chunks/{8640.5b9475a2d18c5416.js → 429.a58e9ba9742309ed.js} +2 -2
  37. sky/dashboard/out/_next/static/chunks/4555.8e221537181b5dc1.js +6 -0
  38. sky/dashboard/out/_next/static/chunks/4725.937865b81fdaaebb.js +6 -0
  39. sky/dashboard/out/_next/static/chunks/6082-edabd8f6092300ce.js +25 -0
  40. sky/dashboard/out/_next/static/chunks/6989-49cb7dca83a7a62d.js +1 -0
  41. sky/dashboard/out/_next/static/chunks/6990-630bd2a2257275f8.js +1 -0
  42. sky/dashboard/out/_next/static/chunks/7248-a99800d4db8edabd.js +1 -0
  43. sky/dashboard/out/_next/static/chunks/754-cfc5d4ad1b843d29.js +18 -0
  44. sky/dashboard/out/_next/static/chunks/8050-dd8aa107b17dce00.js +16 -0
  45. sky/dashboard/out/_next/static/chunks/8056-d4ae1e0cb81e7368.js +1 -0
  46. sky/dashboard/out/_next/static/chunks/8555.011023e296c127b3.js +6 -0
  47. sky/dashboard/out/_next/static/chunks/8821-93c25df904a8362b.js +1 -0
  48. sky/dashboard/out/_next/static/chunks/8969-0662594b69432ade.js +1 -0
  49. sky/dashboard/out/_next/static/chunks/9025.f15c91c97d124a5f.js +6 -0
  50. sky/dashboard/out/_next/static/chunks/{9353-8369df1cf105221c.js → 9353-7ad6bd01858556f1.js} +1 -1
  51. sky/dashboard/out/_next/static/chunks/pages/_app-5a86569acad99764.js +34 -0
  52. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-8297476714acb4ac.js +6 -0
  53. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-337c3ba1085f1210.js +1 -0
  54. sky/dashboard/out/_next/static/chunks/pages/{clusters-9e5d47818b9bdadd.js → clusters-57632ff3684a8b5c.js} +1 -1
  55. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-5fd3a453c079c2ea.js +1 -0
  56. sky/dashboard/out/_next/static/chunks/pages/infra-9f85c02c9c6cae9e.js +1 -0
  57. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-90f16972cbecf354.js +1 -0
  58. sky/dashboard/out/_next/static/chunks/pages/jobs/pools/[pool]-2dd42fc37aad427a.js +16 -0
  59. sky/dashboard/out/_next/static/chunks/pages/jobs-ed806aeace26b972.js +1 -0
  60. sky/dashboard/out/_next/static/chunks/pages/users-bec34706b36f3524.js +1 -0
  61. sky/dashboard/out/_next/static/chunks/pages/{volumes-ef19d49c6d0e8500.js → volumes-a83ba9b38dff7ea9.js} +1 -1
  62. sky/dashboard/out/_next/static/chunks/pages/workspaces/{[name]-96e0f298308da7e2.js → [name]-c781e9c3e52ef9fc.js} +1 -1
  63. sky/dashboard/out/_next/static/chunks/pages/workspaces-91e0942f47310aae.js +1 -0
  64. sky/dashboard/out/_next/static/chunks/webpack-cfe59cf684ee13b9.js +1 -0
  65. sky/dashboard/out/_next/static/css/b0dbca28f027cc19.css +3 -0
  66. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  67. sky/dashboard/out/clusters/[cluster].html +1 -1
  68. sky/dashboard/out/clusters.html +1 -1
  69. sky/dashboard/out/config.html +1 -1
  70. sky/dashboard/out/index.html +1 -1
  71. sky/dashboard/out/infra/[context].html +1 -1
  72. sky/dashboard/out/infra.html +1 -1
  73. sky/dashboard/out/jobs/[job].html +1 -1
  74. sky/dashboard/out/jobs/pools/[pool].html +1 -1
  75. sky/dashboard/out/jobs.html +1 -1
  76. sky/dashboard/out/plugins/[...slug].html +1 -1
  77. sky/dashboard/out/users.html +1 -1
  78. sky/dashboard/out/volumes.html +1 -1
  79. sky/dashboard/out/workspace/new.html +1 -1
  80. sky/dashboard/out/workspaces/[name].html +1 -1
  81. sky/dashboard/out/workspaces.html +1 -1
  82. sky/data/data_utils.py +26 -12
  83. sky/data/mounting_utils.py +29 -4
  84. sky/global_user_state.py +108 -16
  85. sky/jobs/client/sdk.py +8 -3
  86. sky/jobs/controller.py +191 -31
  87. sky/jobs/recovery_strategy.py +109 -11
  88. sky/jobs/server/core.py +81 -4
  89. sky/jobs/server/server.py +14 -0
  90. sky/jobs/state.py +417 -19
  91. sky/jobs/utils.py +73 -80
  92. sky/models.py +9 -0
  93. sky/optimizer.py +2 -1
  94. sky/provision/__init__.py +11 -9
  95. sky/provision/kubernetes/utils.py +122 -15
  96. sky/provision/kubernetes/volume.py +52 -17
  97. sky/provision/provisioner.py +2 -1
  98. sky/provision/runpod/instance.py +3 -1
  99. sky/provision/runpod/utils.py +13 -1
  100. sky/provision/runpod/volume.py +25 -9
  101. sky/provision/slurm/instance.py +75 -29
  102. sky/provision/slurm/utils.py +213 -107
  103. sky/provision/vast/utils.py +1 -0
  104. sky/resources.py +135 -13
  105. sky/schemas/api/responses.py +4 -0
  106. sky/schemas/db/global_user_state/010_save_ssh_key.py +1 -1
  107. sky/schemas/db/spot_jobs/008_add_full_resources.py +34 -0
  108. sky/schemas/db/spot_jobs/009_job_events.py +32 -0
  109. sky/schemas/db/spot_jobs/010_job_events_timestamp_with_timezone.py +43 -0
  110. sky/schemas/db/spot_jobs/011_add_links.py +34 -0
  111. sky/schemas/generated/jobsv1_pb2.py +9 -5
  112. sky/schemas/generated/jobsv1_pb2.pyi +12 -0
  113. sky/schemas/generated/jobsv1_pb2_grpc.py +44 -0
  114. sky/schemas/generated/managed_jobsv1_pb2.py +32 -28
  115. sky/schemas/generated/managed_jobsv1_pb2.pyi +11 -2
  116. sky/serve/serve_utils.py +232 -40
  117. sky/server/common.py +17 -0
  118. sky/server/constants.py +1 -1
  119. sky/server/metrics.py +6 -3
  120. sky/server/plugins.py +16 -0
  121. sky/server/requests/payloads.py +18 -0
  122. sky/server/requests/request_names.py +2 -0
  123. sky/server/requests/requests.py +28 -10
  124. sky/server/requests/serializers/encoders.py +5 -0
  125. sky/server/requests/serializers/return_value_serializers.py +14 -4
  126. sky/server/server.py +434 -107
  127. sky/server/uvicorn.py +5 -0
  128. sky/setup_files/MANIFEST.in +1 -0
  129. sky/setup_files/dependencies.py +21 -10
  130. sky/sky_logging.py +2 -1
  131. sky/skylet/constants.py +22 -5
  132. sky/skylet/executor/slurm.py +4 -6
  133. sky/skylet/job_lib.py +89 -4
  134. sky/skylet/services.py +18 -3
  135. sky/ssh_node_pools/deploy/tunnel/cleanup-tunnel.sh +62 -0
  136. sky/ssh_node_pools/deploy/tunnel/ssh-tunnel.sh +379 -0
  137. sky/templates/kubernetes-ray.yml.j2 +4 -6
  138. sky/templates/slurm-ray.yml.j2 +32 -2
  139. sky/templates/websocket_proxy.py +18 -41
  140. sky/users/permission.py +61 -51
  141. sky/utils/auth_utils.py +42 -0
  142. sky/utils/cli_utils/status_utils.py +19 -5
  143. sky/utils/cluster_utils.py +10 -3
  144. sky/utils/command_runner.py +256 -94
  145. sky/utils/command_runner.pyi +16 -0
  146. sky/utils/common_utils.py +30 -29
  147. sky/utils/context.py +32 -0
  148. sky/utils/db/db_utils.py +36 -6
  149. sky/utils/db/migration_utils.py +41 -21
  150. sky/utils/infra_utils.py +5 -1
  151. sky/utils/instance_links.py +139 -0
  152. sky/utils/interactive_utils.py +49 -0
  153. sky/utils/kubernetes/generate_kubeconfig.sh +42 -33
  154. sky/utils/kubernetes/rsync_helper.sh +5 -1
  155. sky/utils/plugin_extensions/__init__.py +14 -0
  156. sky/utils/plugin_extensions/external_failure_source.py +176 -0
  157. sky/utils/resources_utils.py +10 -8
  158. sky/utils/rich_utils.py +9 -11
  159. sky/utils/schemas.py +63 -20
  160. sky/utils/status_lib.py +7 -0
  161. sky/utils/subprocess_utils.py +17 -0
  162. sky/volumes/client/sdk.py +6 -3
  163. sky/volumes/server/core.py +65 -27
  164. sky_templates/ray/start_cluster +8 -4
  165. {skypilot_nightly-1.0.0.dev20251210.dist-info → skypilot_nightly-1.0.0.dev20260112.dist-info}/METADATA +53 -57
  166. {skypilot_nightly-1.0.0.dev20251210.dist-info → skypilot_nightly-1.0.0.dev20260112.dist-info}/RECORD +172 -162
  167. sky/dashboard/out/_next/static/KYAhEFa3FTfq4JyKVgo-s/_buildManifest.js +0 -1
  168. sky/dashboard/out/_next/static/chunks/1141-9c810f01ff4f398a.js +0 -11
  169. sky/dashboard/out/_next/static/chunks/1871-7e202677c42f43fe.js +0 -6
  170. sky/dashboard/out/_next/static/chunks/2260-7703229c33c5ebd5.js +0 -1
  171. sky/dashboard/out/_next/static/chunks/2350.fab69e61bac57b23.js +0 -1
  172. sky/dashboard/out/_next/static/chunks/2369.fc20f0c2c8ed9fe7.js +0 -15
  173. sky/dashboard/out/_next/static/chunks/2755.edd818326d489a1d.js +0 -26
  174. sky/dashboard/out/_next/static/chunks/3294.ddda8c6c6f9f24dc.js +0 -1
  175. sky/dashboard/out/_next/static/chunks/3785.7e245f318f9d1121.js +0 -1
  176. sky/dashboard/out/_next/static/chunks/3800-b589397dc09c5b4e.js +0 -1
  177. sky/dashboard/out/_next/static/chunks/4725.172ede95d1b21022.js +0 -1
  178. sky/dashboard/out/_next/static/chunks/4937.a2baa2df5572a276.js +0 -15
  179. sky/dashboard/out/_next/static/chunks/6212-7bd06f60ba693125.js +0 -13
  180. sky/dashboard/out/_next/static/chunks/6856-da20c5fd999f319c.js +0 -1
  181. sky/dashboard/out/_next/static/chunks/6989-01359c57e018caa4.js +0 -1
  182. sky/dashboard/out/_next/static/chunks/6990-09cbf02d3cd518c3.js +0 -1
  183. sky/dashboard/out/_next/static/chunks/7359-c8d04e06886000b3.js +0 -30
  184. sky/dashboard/out/_next/static/chunks/7411-b15471acd2cba716.js +0 -41
  185. sky/dashboard/out/_next/static/chunks/7615-019513abc55b3b47.js +0 -1
  186. sky/dashboard/out/_next/static/chunks/8969-452f9d5cbdd2dc73.js +0 -1
  187. sky/dashboard/out/_next/static/chunks/9025.fa408f3242e9028d.js +0 -6
  188. sky/dashboard/out/_next/static/chunks/9360.a536cf6b1fa42355.js +0 -31
  189. sky/dashboard/out/_next/static/chunks/9847.3aaca6bb33455140.js +0 -30
  190. sky/dashboard/out/_next/static/chunks/pages/_app-68b647e26f9d2793.js +0 -34
  191. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-33f525539665fdfd.js +0 -16
  192. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-a7565f586ef86467.js +0 -1
  193. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-12c559ec4d81fdbd.js +0 -1
  194. sky/dashboard/out/_next/static/chunks/pages/infra-d187cd0413d72475.js +0 -1
  195. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-895847b6cf200b04.js +0 -16
  196. sky/dashboard/out/_next/static/chunks/pages/jobs/pools/[pool]-8d0f4655400b4eb9.js +0 -21
  197. sky/dashboard/out/_next/static/chunks/pages/jobs-e5a98f17f8513a96.js +0 -1
  198. sky/dashboard/out/_next/static/chunks/pages/users-2f7646eb77785a2c.js +0 -1
  199. sky/dashboard/out/_next/static/chunks/pages/workspaces-cb4da3abe08ebf19.js +0 -1
  200. sky/dashboard/out/_next/static/chunks/webpack-fba3de387ff6bb08.js +0 -1
  201. sky/dashboard/out/_next/static/css/c5a4cfd2600fc715.css +0 -3
  202. /sky/dashboard/out/_next/static/{KYAhEFa3FTfq4JyKVgo-s → 3nu-b8raeKRNABZ2d4GAG}/_ssgManifest.js +0 -0
  203. /sky/dashboard/out/_next/static/chunks/pages/plugins/{[...slug]-4f46050ca065d8f8.js → [...slug]-449a9f5a3bb20fb3.js} +0 -0
  204. {skypilot_nightly-1.0.0.dev20251210.dist-info → skypilot_nightly-1.0.0.dev20260112.dist-info}/WHEEL +0 -0
  205. {skypilot_nightly-1.0.0.dev20251210.dist-info → skypilot_nightly-1.0.0.dev20260112.dist-info}/entry_points.txt +0 -0
  206. {skypilot_nightly-1.0.0.dev20251210.dist-info → skypilot_nightly-1.0.0.dev20260112.dist-info}/licenses/LICENSE +0 -0
  207. {skypilot_nightly-1.0.0.dev20251210.dist-info → skypilot_nightly-1.0.0.dev20260112.dist-info}/top_level.txt +0 -0
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST=function(s,c,a,e,t,u,f,n,i,o,j,b,r,k,d){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static/chunks/pages/index-444f1804401f04ea.js"],"/_error":["static/chunks/pages/_error-c66a4e8afc46f17b.js"],"/clusters":["static/chunks/pages/clusters-9e5d47818b9bdadd.js"],"/clusters/[cluster]":[c,s,a,u,f,j,o,e,t,n,b,i,r,k,d,"static/chunks/6856-da20c5fd999f319c.js","static/chunks/1871-7e202677c42f43fe.js","static/chunks/pages/clusters/[cluster]-a7565f586ef86467.js"],"/clusters/[cluster]/[job]":[c,s,a,u,e,t,i,"static/chunks/pages/clusters/[cluster]/[job]-33f525539665fdfd.js"],"/config":["static/chunks/pages/config-718cdc365de82689.js"],"/infra":["static/chunks/pages/infra-d187cd0413d72475.js"],"/infra/[context]":["static/chunks/pages/infra/[context]-12c559ec4d81fdbd.js"],"/jobs":["static/chunks/pages/jobs-e5a98f17f8513a96.js"],"/jobs/pools/[pool]":[c,s,a,f,o,e,t,n,"static/chunks/pages/jobs/pools/[pool]-8d0f4655400b4eb9.js"],"/jobs/[job]":[c,s,a,u,f,o,e,t,n,i,"static/chunks/pages/jobs/[job]-895847b6cf200b04.js"],"/plugins/[...slug]":[s,"static/chunks/pages/plugins/[...slug]-4f46050ca065d8f8.js"],"/users":["static/chunks/pages/users-2f7646eb77785a2c.js"],"/volumes":["static/chunks/pages/volumes-ef19d49c6d0e8500.js"],"/workspace/new":["static/chunks/pages/workspace/new-3f88a1c7e86a3f86.js"],"/workspaces":["static/chunks/pages/workspaces-cb4da3abe08ebf19.js"],"/workspaces/[name]":[c,s,a,u,f,j,e,t,n,b,i,r,k,d,"static/chunks/1141-9c810f01ff4f398a.js","static/chunks/pages/workspaces/[name]-96e0f298308da7e2.js"],sortedPages:["/","/_app","/_error","/clusters","/clusters/[cluster]","/clusters/[cluster]/[job]","/config","/infra","/infra/[context]","/jobs","/jobs/pools/[pool]","/jobs/[job]","/plugins/[...slug]","/users","/volumes","/workspace/new","/workspaces","/workspaces/[name]"]}}("static/chunks/5739-d67458fcb1386c92.js","static/chunks/616-3d59f75e2ccf9321.js","static/chunks/6130-2be46d70a38f1e82.js","static/chunks/6989-01359c57e018caa4.js","static/chunks/3850-fd5696f3bbbaddae.js","static/chunks/7411-b15471acd2cba716.js","static/chunks/1272-1ef0bf0237faccdb.js","static/chunks/8969-452f9d5cbdd2dc73.js","static/chunks/9353-8369df1cf105221c.js","static/chunks/6212-7bd06f60ba693125.js","static/chunks/7359-c8d04e06886000b3.js","static/chunks/6990-09cbf02d3cd518c3.js","static/chunks/2260-7703229c33c5ebd5.js","static/chunks/3800-b589397dc09c5b4e.js","static/chunks/7615-019513abc55b3b47.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1,11 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1141],{99333:function(e,s,t){t.d(s,{Z:function(){return a}});/**
2
- * @license lucide-react v0.407.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */let a=(0,t(60998).Z)("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"}]])},98418:function(e,s,t){t.d(s,{Z:function(){return a}});/**
7
- * @license lucide-react v0.407.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */let a=(0,t(60998).Z)("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]])},1812:function(e,s,t){t.d(s,{X:function(){return n}});var a=t(85893),r=t(67294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let s=e.message;return s.includes("failed:")&&(s=s.split("failed:")[1].trim()),s},n=e=>{let{error:s,title:t="Error",onDismiss:n}=e,[c,i]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{s&&i(!1)},[s]),!s||c)return null;let o="string"==typeof s?s:l(s);return(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,a.jsx)("div",{className:"ml-3",children:(0,a.jsxs)("div",{className:"text-sm text-red-800",children:[(0,a.jsxs)("strong",{children:[t,":"]})," ",o]})})]}),(0,a.jsx)("button",{onClick:()=>{i(!0),n&&n()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,a.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},69123:function(e,s,t){t.d(s,{g:function(){return n}});var a=t(85893),r=t(67294),l=t(32350);let n=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...r})});n.displayName="Textarea"},11141:function(e,s,t){t.r(s),t.d(s,{WorkspaceEditor:function(){return _}});var a=t(85893),r=t(67294),l=t(11163),n=t(17324),c=t(23266),i=t(68969);t(9353);var o=t(41664),d=t.n(o),u=t(9008),x=t.n(u),m=t(37673),h=t(30803),f=t(69123),g=t(55739),p=t(70282),b=t(6021),j=t(13626),y=t(98418),N=t(99333),w=t(50326);let k=e=>{let{className:s="",variant:t="default",children:r,...l}=e;return(0,a.jsx)("div",{role:"alert",className:"".concat("relative w-full rounded-lg border p-4 flex items-start space-x-2"," ").concat({default:"bg-blue-50 border-blue-200 text-blue-800",destructive:"bg-red-50 border-red-200 text-red-800"}[t]," ").concat(s),...l,children:r})},v=e=>{let{className:s="",children:t,...r}=e;return(0,a.jsx)("div",{className:"text-sm leading-relaxed ".concat(s),...r,children:t})};var C=t(53850),L=t(1812),E=t(47615),S=t(1272),W=t(93225),A=t(53081),M=t(6378);let Z=e=>{let{message:s}=e;return s?(0,a.jsxs)(k,{className:"border-green-200 bg-green-50",children:[(0,a.jsx)(p.Z,{className:"h-4 w-4 text-green-600"}),(0,a.jsx)(v,{className:"text-green-800",children:s})]}):null},D=e=>{let{workspaceName:s,config:t,enabledClouds:r=[]}=e;if(!t)return null;let l="default"===s,n=0===Object.keys(t).length;if(l&&n)return(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"Workspace 'default' can use all accessible infrastructure."});let c=[],i=[],o=[],d=new Set(r.map(e=>e.toLowerCase()));Object.entries(t).forEach(e=>{let[s,t]=e;if("private"===s||"allowed_users"===s)return;let r=W.Z2[s.toLowerCase()]||s.toUpperCase(),l=null==r?void 0:r.toLowerCase(),n=d.has(l)||Array.from(d).some(e=>e.startsWith(l+"/")),u=()=>"kubernetes"===s.toLowerCase()?Array.from(d).filter(e=>e.startsWith(l+"/")).map(e=>e.split("/")[1]):[];if((null==t?void 0:t.disabled)===!0)i.push(r);else if(t&&Object.keys(t).length>0){let e="";if("gcp"===s.toLowerCase()&&t.project_id)e=" (Project ID: ".concat(t.project_id,")");else if("aws"===s.toLowerCase()&&t.region)e=" (Region: ".concat(t.region,")");else if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}n?c.push((0,a.jsxs)("span",{className:"block",children:[r,e," is enabled."]},"".concat(s,"-enabled"))):o.push((0,a.jsxs)("span",{className:"block text-amber-700",children:[r,e," is configured but not currently available."]},"".concat(s,"-configured-not-enabled")))}else if(n){let e="";if("kubernetes"===s.toLowerCase()){let s=u();s.length>0&&(e=" (Contexts: ".concat(s.join(", "),")"))}c.push((0,a.jsxs)("span",{className:"block",children:[r,e," is enabled (using default settings)."]},"".concat(s,"-default-enabled")))}else o.push((0,a.jsxs)("span",{className:"block text-amber-700",children:[r," is configured but not currently available."]},"".concat(s,"-default-not-enabled")))});let u=[];if(i.length>0){let e=i.join(" and ");u.push((0,a.jsxs)("span",{className:"block",children:[e," ",1===i.length?"is":"are"," explicitly disabled."]},"disabled-clouds"))}return(u.push(...c),u.push(...o),u.length>0)?(0,a.jsx)("div",{className:"text-sm text-gray-700 mb-3 p-3 bg-sky-50 rounded border border-sky-200",children:u}):!l&&n?(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-3 italic p-3 bg-sky-50 rounded border border-sky-200",children:"This workspace has no specific cloud resource configurations and can use all accessible infrastructure."}):null},R=e=>{let{isPrivate:s}=e;return s?(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700 border border-gray-300",children:"Private"}):(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-300",children:"Public"})},P=e=>{let{workspaceConfig:s,allUsers:t}=e;if(!s.private)return null;let r=s.allowed_users||[],l=(t||[]).filter(e=>"admin"===e.role).map(e=>e.username),n=[...new Set([...r,...l])];return 0===n.length?(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Allowed Users (0)"}),(0,a.jsx)("div",{className:"text-amber-600 text-xs italic p-2 bg-amber-50 rounded border border-amber-200",children:"No users configured (workspace may be inaccessible)"})]}):(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsxs)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:["Allowed Users (",n.length,")"]}),(0,a.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded",children:n.map(e=>{let s=l.includes(e);return(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs p-2 bg-gray-50 hover:bg-gray-100 border-b border-gray-100 last:border-b-0",children:[(0,a.jsx)("span",{className:"font-medium text-gray-700",children:e}),s?(0,a.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,a.jsx)(C.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,a.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,a.jsx)(b.Z,{className:"w-3 h-3 mr-1"}),"User"]})]},e)})})]})};function _(e){let{workspaceName:s,isNewWorkspace:t=!1}=e,o=(0,l.useRouter)(),[u,p]=(0,r.useState)({}),[b,k]=(0,r.useState)({}),[v,W]=(0,r.useState)(""),[_,z]=(0,r.useState)(!0),[O,U]=(0,r.useState)(!1),[F,T]=(0,r.useState)(!1),[Y,I]=(0,r.useState)(null),[J,V]=(0,r.useState)(null),[H,B]=(0,r.useState)(null),[X,G]=(0,r.useState)([]),[q,K]=(0,r.useState)({showDialog:!1,deleting:!1,error:null}),[Q,$]=(0,r.useState)({totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:[]}),[ee,es]=(0,r.useState)(!1),et=(0,r.useCallback)(async()=>{z(!0),I(null);try{let e;let[t,a]=await Promise.all([(0,n.getWorkspaces)(),(0,A.R)()]),r=t[s]||{};p(r),k(r),G(a||[]),e=0===Object.keys(r).length?"".concat(s,":\n # Empty workspace configuration - uses all accessible infrastructure\n"):S.ZP.dump({[s]:r},{indent:2,lineWidth:-1,noRefs:!0,skipInvalid:!0,flowLevel:-1}),W(e)}catch(e){console.error("Error fetching workspace config:",e),I(e)}finally{z(!1)}},[s]),ea=(0,r.useCallback)(async()=>{if(!t){es(!0);try{let[e,t,a]=await Promise.all([M.dashboardCache.get(c.getClusters),M.dashboardCache.get(i.getManagedJobs,[{allUsers:!0,skipFinished:!0,workspaceMatch:s,fields:["workspace","status"]}]),M.dashboardCache.get(n.getEnabledClouds,[s,!0])]),r=e.filter(e=>(e.workspace||"default")===s),l=r.filter(e=>"RUNNING"===e.status||"LAUNCHING"===e.status),o={};e.forEach(e=>{o[e.cluster]=e.workspace||"default"});let d=t.jobs||[],u=new Set(E.statusGroups.active),x=0;d.forEach(e=>{e.workspace===s&&u.has(e.status)&&x++}),$({totalClusterCount:r.length,runningClusterCount:l.length,managedJobsCount:x,clouds:Array.isArray(a)?a:[]})}catch(e){console.error("Failed to fetch workspace stats:",e)}finally{es(!1)}}},[s,t]);(0,r.useEffect)(()=>{t?(z(!1),W("".concat(s,":\n # New workspace configuration\n # Leave empty to use all accessible infrastructure\n"))):(et(),ea())},[s,t,et,ea]),(0,r.useEffect)(()=>{T(JSON.stringify(u)!==JSON.stringify(b))},[u,b]);let er=e=>{W(e),B(null);try{let t=S.ZP.load(e)||{},a=Object.keys(t);if(0===a.length)p({});else if(1===a.length){let e=a[0];if(e!==s){B('Workspace name cannot be changed. Expected "'.concat(s,'" but found "').concat(e,'".'));return}let r=t[s]||{};p(r)}else B("Configuration must contain only one workspace. Found: ".concat(a.join(", ")))}catch(e){B("Invalid YAML: ".concat(e.message))}},el=async()=>{U(!0),I(null),V(null);try{if(H)throw Error("Please fix YAML errors before saving");let e=S.ZP.load(v)||{},a=Object.keys(e);if(a.length>0&&a[0]!==s)throw Error('Workspace name cannot be changed. Expected "'.concat(s,'".'));t?(await (0,n.MB)(s,u),V("Workspace created successfully!"),setTimeout(()=>{o.push("/workspaces/".concat(s))},1500)):(await (0,n.eA)(s,u),V("Workspace updated successfully!"),k(u),ea())}catch(e){console.error("Error saving workspace:",e),I(e)}finally{U(!1)}},en=async()=>{K(e=>({...e,deleting:!0,error:null}));try{await (0,n.zl)(s),V("Workspace deleted successfully!"),setTimeout(()=>{o.push("/workspaces")},1500)}catch(e){console.error("Error deleting workspace:",e),K(s=>({...s,deleting:!1,error:e}))}},ec=()=>{K({showDialog:!1,deleting:!1,error:null})},ei=async()=>{await Promise.all([et(),ea()])};if(!o.isReady)return(0,a.jsx)("div",{children:"Loading..."});let eo=t?"Create New Workspace | SkyPilot Dashboard":"Workspace: ".concat(s," | SkyPilot Dashboard");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x(),{children:(0,a.jsx)("title",{children:eo})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)(d(),{href:t?"/workspace/new":"/workspaces/".concat(s),className:"text-sky-blue hover:underline",children:t?"New Workspace":s}),F&&(0,a.jsx)("span",{className:"ml-3 px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded",children:"Unsaved changes"})]}),(0,a.jsxs)("div",{className:"text-sm flex items-center",children:[(_||O||ee)&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)(g.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:O?"Saving...":"Loading..."})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[!t&&(0,a.jsxs)("button",{onClick:ei,disabled:_||O||ee,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,a.jsx)(j.Z,{className:"w-4 h-4 mr-1.5"}),"Refresh"]}),!t&&"default"!==s&&(0,a.jsxs)("button",{onClick:()=>K({...q,showDialog:!0}),disabled:q.deleting||O,className:"text-red-600 hover:text-red-700 font-medium inline-flex items-center",children:[(0,a.jsx)(y.Z,{className:"w-4 h-4 mr-1.5"}),"Delete"]})]})]})]}),_?(0,a.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,a.jsx)(g.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading workspace configuration..."})]}):(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)(L.X,{error:Y,title:"Error",onDismiss:()=>I(null)}),(0,a.jsx)(Z,{message:J}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[!t&&(0,a.jsx)("div",{className:"lg:col-span-1",children:(0,a.jsxs)(m.Zb,{className:"h-full",children:[(0,a.jsx)(m.Ol,{children:(0,a.jsx)(m.ll,{className:"text-base font-normal",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s]}),(0,a.jsx)(R,{isPrivate:!0===b.private})]})})}),(0,a.jsxs)(m.aY,{className:"text-sm pb-2 flex-1",children:[(0,a.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,a.jsx)(C.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,a.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,a.jsx)("span",{className:"font-normal text-gray-800",children:ee?"...":"".concat(Q.runningClusterCount," / ").concat(Q.totalClusterCount)})]}),(0,a.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,a.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,a.jsx)(C.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,a.jsx)("span",{children:"Managed Jobs"})]}),(0,a.jsx)("span",{className:"font-normal text-gray-800",children:ee?"...":Q.managedJobsCount})]})]}),(0,a.jsxs)("div",{className:"px-6 pb-6 text-sm pt-3",children:[(0,a.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:ee?(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."}):Q.clouds.length>0?Q.clouds.map(e=>(0,a.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,a.jsx)(C.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,a.jsx)("span",{children:e})]},e)):(0,a.jsx)("span",{className:"text-gray-500 italic",children:"No enabled infrastructure"})}),(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(D,{workspaceName:s,config:b,enabledClouds:Q.clouds})}),(0,a.jsx)(P,{workspaceConfig:b,allUsers:X})]})]})}),(0,a.jsx)("div",{className:t?"lg:col-span-3":"lg:col-span-2",children:(0,a.jsxs)(m.Zb,{className:"h-full flex flex-col",children:[(0,a.jsx)(m.Ol,{children:(0,a.jsx)(m.ll,{className:"text-base font-normal",children:t?"New Workspace YAML":"Edit Workspace YAML"})}),(0,a.jsx)(m.aY,{className:"flex-1 flex flex-col",children:(0,a.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col",children:[H&&(0,a.jsx)(L.X,{error:H,onDismiss:()=>B(null)}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,a.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Configure infra-specific settings for this workspace. Leave empty to use all accessible infrastructure. Refer to"," ",(0,a.jsx)("a",{href:"https://docs.skypilot.co/en/latest/admin/workspaces.html#configuration",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600",children:"SkyPilot Docs"})," ","for more details."]}),(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Example configuration:"}),(0,a.jsx)("div",{className:"p-3 bg-gray-50 border rounded-lg",children:(0,a.jsx)("pre",{className:"text-xs font-mono text-gray-600 whitespace-pre-wrap",children:"".concat(s||"my-workspace",":\n private: true\n allowed_users:\n - user1@mydomain.com\n - user2@mydomain.com\n gcp:\n project_id: xxx\n disabled: false\n kubernetes:\n allowed_contexts:\n - context-1")})})]}),(0,a.jsx)(f.g,{value:v,onChange:e=>er(e.target.value),className:"font-mono text-sm flex-1 resize-none",style:{minHeight:"350px"},spellCheck:!1,placeholder:"# Enter workspace configuration in YAML format"}),(0,a.jsx)("div",{className:"flex justify-end space-x-3 pt-3 border-gray-200",children:(0,a.jsxs)(h.z,{onClick:el,disabled:O||H||_,className:"inline-flex items-center bg-sky-600 hover:bg-sky-700 text-white",children:[(0,a.jsx)(N.Z,{className:"w-4 h-4 mr-1.5"}),O?"Applying...":"Apply"]})})]})]})})]})})]})]}),(0,a.jsx)(w.Vq,{open:q.showDialog,onOpenChange:ec,children:(0,a.jsxs)(w.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(w.fK,{className:"",children:[(0,a.jsx)(w.$N,{children:"Delete Workspace"}),(0,a.jsxs)(w.Be,{children:['Are you sure you want to delete workspace "',s,'"? This action cannot be undone.']})]}),q.error&&(0,a.jsx)(L.X,{error:q.error,title:"Deletion Failed",onDismiss:()=>K(e=>({...e,error:null}))}),(0,a.jsxs)(w.cN,{className:"",children:[(0,a.jsx)(h.z,{variant:"outline",onClick:ec,disabled:q.deleting,children:"Cancel"}),(0,a.jsx)(h.z,{variant:"destructive",onClick:en,disabled:q.deleting,children:q.deleting?"Deleting...":"Delete"})]})]})})]})]})}},53081:function(e,s,t){t.d(s,{R:function(){return r}});var a=t(47145);async function r(){try{let e=await a.x.get("/users");if(!e.ok)throw Error("Failed to fetch users with status ".concat(e.status));return(await e.json()).map(e=>({userId:e.id,username:e.name,role:e.role,created_at:e.created_at}))||[]}catch(e){throw console.error("Failed to fetch users:",e),e}}}}]);
@@ -1,6 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1871],{39037:function(e,s,t){t.r(s),t.d(s,{ClusterTable:function(){return _},Clusters:function(){return I},Status2Actions:function(){return F},enabledActions:function(){return H},handleVSCodeConnection:function(){return O}});var r=t(85893),l=t(67294),a=t(11163),n=t(55739),i=t(36989),c=t(41664),o=t.n(c),u=t(30803),d=t(37673),h=t(68764),x=t(23266),p=t(17324),m=t(94545),f=t(13626),j=t(60998);/**
2
- * @license lucide-react v0.407.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */let v=(0,j.Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),g=(0,j.Z)("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);t(9353);var y=t(92128),w=t(99307),b=t(23001),k=t(88950),N=t(6378),C=t(36856);t(1272);var S=t(20546);let L=[{label:"Status",value:"status"},{label:"Cluster",value:"cluster"},{label:"User",value:"user"},{label:"Workspace",value:"workspace"},{label:"Infra",value:"infra"}],M=(e,s)=>{let t="",r="";return e>=0&&(t=e+"m",r=" "),s&&(t+="".concat(r,"(down)")),""===t&&(t="-"),t},R=(e,s)=>{if(e&&e.includes("@")){let t=e.split("@")[0];return s&&s!==t?"".concat(t," (").concat(s,")"):t}let t=e||s||"N/A";return s&&s!==t?"".concat(t," (").concat(s,")"):t},E=e=>{if(!e||0===e)return"-";let s=e=Math.floor(e),t="",r=0;for(let e of[{value:31536e3,label:"y"},{value:2592e3,label:"mo"},{value:86400,label:"d"},{value:3600,label:"h"},{value:60,label:"m"},{value:1,label:"s"}])if(s>=e.value&&r<2){let l=Math.floor(s/e.value);t+="".concat(l).concat(e.label," "),s%=e.value,r++}return t.trim()||"0s"};function I(){let e=(0,a.useRouter)(),[s,t]=(0,l.useState)(!1),c=l.useRef(null),[u,d]=(0,l.useState)(!1),[h,m]=(0,l.useState)(!1),[j,v]=(0,l.useState)(null),[g,w]=(0,l.useState)(()=>!!e.isReady&&"true"===e.query.history),[S,M]=(0,l.useState)(!0),[E,I]=(0,l.useState)(()=>{if(e.isReady){let s=e.query.historyDays;if(s&&"string"==typeof s&&["1","5","10","30"].includes(s))return parseInt(s)}return 1}),O=(0,b.X)(),[q,H]=(0,l.useState)([]),[W,F]=(0,l.useState)({status:[],cluster:[],user:[],workspace:[],infra:[]}),[A,D]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(e.isReady){U();let s="true"===e.query.history;g!==s&&(M(!1),w(s),setTimeout(()=>M(!0),50));let t=e.query.historyDays;if(t&&"string"==typeof t&&["1","5","10","30"].includes(t)){let e=parseInt(t);E!==e&&I(e)}}},[e.isReady,e.query.history,e.query.historyDays]),(0,l.useEffect)(()=>{(async()=>{try{await C.ZP.preloadForPage("clusters");let e=await N.default.get(p.getWorkspaces),s=Object.keys(e),t=await N.default.get(x.getClusters),r=[...new Set(t.map(e=>e.workspace||"default").filter(e=>e))],l=new Set(s);r.includes("default")&&l.has("default"),r.forEach(e=>l.add(e));let a=[...new Set(t.map(e=>({userId:e.user_hash||e.user,username:e.user})).filter(e=>e.userId)).values()],n=new Map;a.forEach(e=>{n.set(e.userId,{userId:e.userId,username:e.username,display:R(e.username,e.userId)})}),D(!0)}catch(e){console.error("Error fetching data for filters:",e),D(!0)}})()},[]);let P=s=>{let t={...e.query},r=[],l=[],a=[];s.map((e,s)=>{var t;r.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),l.push(e.operator),a.push(e.value)}),t.property=r,t.operator=l,t.value=a,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},Z=s=>{let t={...e.query};t.history=s.toString(),e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},B=s=>{let t={...e.query};t.historyDays=s.toString(),e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},U=()=>{let s={...e.query},t=s.property,r=s.operator,l=s.value;if(void 0===t)return;let a=[],n=Array.isArray(t)?t.length:1,i=new Map;if(i.set("",""),i.set("status","Status"),i.set("cluster","Cluster"),i.set("user","User"),i.set("workspace","Workspace"),i.set("infra","Infra"),1===n)a.push({property:i.get(t),operator:r,value:l});else for(let e=0;e<n;e++)a.push({property:i.get(t[e]),operator:r[e],value:l[e]});H(a)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1 min-h-[20px]",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(o(),{href:"/clusters",className:"text-sky-blue hover:underline leading-none text-base",children:"Sky Clusters"})}),(0,r.jsx)("div",{className:"w-full sm:w-auto",children:(0,r.jsx)(V,{propertyList:L,valueList:W,setFilters:H,updateURLParams:P,placeholder:"Filter clusters",filters:q})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{let s=e.target.checked;w(s),Z(s)},className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full ".concat(S?"transition-colors":""," ").concat(g?"bg-sky-600":"bg-gray-300"),children:(0,r.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white ".concat(S?"transition-transform":""," ").concat(g?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Show history"})]}),g&&(0,r.jsxs)(k.Ph,{value:E.toString(),onValueChange:e=>{let s=parseInt(e);I(s),B(s)},children:[(0,r.jsx)(k.i4,{className:"w-24 h-8 text-xs",children:(0,r.jsx)(k.ki,{})}),(0,r.jsxs)(k.Bw,{children:[(0,r.jsx)(k.Ql,{value:"1",children:"1 day"}),(0,r.jsx)(k.Ql,{value:"5",children:"5 days"}),(0,r.jsx)(k.Ql,{value:"10",children:"10 days"}),(0,r.jsx)(k.Ql,{value:"30",children:"30 days"})]})]})]}),s&&(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(n.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,r.jsxs)("button",{onClick:()=>{N.default.invalidate(x.getClusters),N.default.invalidate(p.getWorkspaces),g&&N.default.invalidate(x.uR),D(!1),C.ZP.preloadForPage("clusters",{force:!0}).then(()=>{D(!0),c.current&&c.current()})},disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(f.Z,{className:"h-4 w-4 mr-1.5"}),!O&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsx)(z,{filters:q,setFilters:H,updateURLParams:P}),(0,r.jsx)(_,{refreshInterval:i.yc,setLoading:t,refreshDataRef:c,filters:q,showHistory:g,historyDays:E,onOpenSSHModal:e=>{v(e),d(!0)},onOpenVSCodeModal:e=>{v(e),m(!0)},setOptionValues:F,preloadingComplete:A}),(0,r.jsx)(y.Oh,{isOpen:u,onClose:()=>d(!1),cluster:j}),(0,r.jsx)(y._R,{isOpen:h,onClose:()=>m(!1),cluster:j})]})}function _(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,filters:c,showHistory:p,historyDays:f,onOpenSSHModal:j,onOpenVSCodeModal:v,setOptionValues:g,preloadingComplete:y}=e,[b,k]=(0,l.useState)([]),[C,L]=(0,l.useState)({key:null,direction:"ascending"}),[R,I]=(0,l.useState)(!1),[_,O]=(0,l.useState)(!0),[q,H]=(0,l.useState)(1),[W,V]=(0,l.useState)(10),z=e=>{let s={status:[],cluster:[],user:[],workspace:[],infra:[]},t=(e,s)=>{e.includes(s)||e.push(s)};return e.map(e=>{t(s.status,e.status),t(s.cluster,e.cluster),t(s.user,e.user),t(s.workspace,e.workspace),t(s.infra,e.infra)}),s},A=l.useCallback(async()=>{t(!0),I(!0);try{let e=await N.default.get(x.getClusters);if(p){let s=[];try{s=await N.default.get(x.uR,[null,f])}catch(e){console.error("Error fetching cluster history:",e)}let t=e.map(e=>({...e,isHistorical:!1})),r=s.map(e=>({...e,isHistorical:!0})),l=[...t];r.forEach(s=>{e.some(e=>e.cluster_hash===s.cluster_hash)||l.push(s)}),g(z(l)),k(l)}else{let s=e.map(e=>({...e,isHistorical:!1}));g(z(s)),k(s)}}catch(e){console.error("Error fetching cluster data:",e),g(z([])),k([])}t(!1),I(!1),O(!1)},[t,p,f,g]),D=(e,s)=>{var t;let{property:r,operator:l,value:a}=s;if(!a)return!0;if(!r){let s=a.toLowerCase();return Object.values(e).some(e=>null==e?void 0:e.toString().toLowerCase().includes(s))}let n=null===(t=e[r.toLowerCase()])||void 0===t?void 0:t.toString().toLowerCase(),i=a.toString().toLowerCase();switch(l){case"=":return n===i;case":":return null==n?void 0:n.includes(i);default:return!0}},P=l.useMemo(()=>{let e=0===c.length?b:b.filter(e=>{let s=null;for(let t=0;t<c.length;t++){let r=D(e,c[t]);s=null===s?r:s&&r}return s});return(0,m.R0)(e,C.key,C.direction)},[b,C,c]);l.useEffect(()=>{a&&(a.current=A)},[a,A]),(0,l.useEffect)(()=>{k([]);let e=!0;if(y){A();let t=setInterval(()=>{e&&"visible"===window.document.visibilityState&&A()},s);return()=>{e=!1,clearInterval(t)}}return()=>{e=!1}},[s,A,y]),(0,l.useEffect)(()=>{H(1)},[b.length]);let Z=e=>{let s="ascending";C.key===e&&"ascending"===C.direction&&(s="descending"),L({key:e,direction:s})},B=e=>C.key===e?"ascending"===C.direction?" ↑":" ↓":"",U=Math.ceil(P.length/W),Q=(q-1)*W,T=Q+W,X=P.slice(Q,T);return(0,r.jsxs)("div",{children:[(0,r.jsx)(d.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(h.iA,{className:"min-w-full",children:[(0,r.jsx)(h.xD,{children:(0,r.jsxs)(h.SC,{children:[(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("status"),children:["Status",B("status")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("cluster"),children:["Cluster",B("cluster")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("user"),children:["User",B("user")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("workspace"),children:["Workspace",B("workspace")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("infra"),children:["Infra",B("infra")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("resources_str"),children:["Resources",B("resources_str")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("time"),children:["Started",B("time")]}),p&&(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("duration"),children:["Duration",B("duration")]}),(0,r.jsxs)(h.ss,{className:"sortable whitespace-nowrap",onClick:()=>Z("autostop"),children:["Autostop",B("autostop")]}),(0,r.jsx)(h.ss,{className:"md:sticky md:right-0 md:bg-white",children:"Actions"})]})}),(0,r.jsx)(h.RM,{children:R||!y?(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(n.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):X.length>0?X.map((e,s)=>(0,r.jsxs)(h.SC,{children:[(0,r.jsx)(h.pj,{children:(0,r.jsx)(w.OE,{status:e.status})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/clusters/".concat(e.isHistorical?e.cluster_hash:e.cluster||e.name),className:"text-blue-600",children:e.cluster||e.name})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(S.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(o(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(o(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud}),e.infra.includes("(")&&(0,r.jsx)("span",{children:" "+e.infra.substring(e.infra.indexOf("("))})]})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,r.jsx)("span",{children:e.resources_str})})}),(0,r.jsx)(h.pj,{children:(0,r.jsx)(i.Zg,{date:e.time})}),p&&(0,r.jsx)(h.pj,{children:E(e.duration)}),(0,r.jsx)(h.pj,{children:e.isHistorical?"-":M(e.autostop,e.to_down)}),(0,r.jsx)(h.pj,{className:"text-left md:sticky md:right-0 md:bg-white",children:!e.isHistorical&&(0,r.jsx)(F,{cluster:e.cluster,status:e.status,onOpenSSHModal:j,onOpenVSCodeModal:v})})]},s)):(0,r.jsx)(h.SC,{children:(0,r.jsx)(h.pj,{colSpan:9,className:"text-center py-6 text-gray-500",children:p?"No clusters found":"No active clusters"})})})]})})}),b.length>0&&(0,r.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,r.jsxs)("div",{className:"relative inline-block",children:[(0,r.jsxs)("select",{value:W,onChange:e=>{V(parseInt(e.target.value,10)),H(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:30,children:"30"}),(0,r.jsx)("option",{value:50,children:"50"}),(0,r.jsx)("option",{value:100,children:"100"}),(0,r.jsx)("option",{value:200,children:"200"})]}),(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,r.jsx)("div",{children:"".concat(Q+1," - ").concat(Math.min(T,P.length)," of ").concat(P.length)}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.max(e-1,1))},disabled:1===q,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,r.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,r.jsx)(u.z,{variant:"ghost",size:"icon",onClick:()=>{H(e=>Math.min(e+1,U))},disabled:q===U||0===U,className:"text-gray-500 h-8 w-8 p-0",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,r.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}let O=(e,s)=>{s&&s(e)},q=(e,s)=>{s?s(e):window.open("ssh://".concat(e))},H=e=>"RUNNING"===e?["connect","VSCode"]:[],W={connect:(0,r.jsx)(v,{className:"w-4 h-4 text-gray-500 inline-block"}),VSCode:(0,r.jsx)(g,{className:"w-4 h-4 text-gray-500 inline-block"})};function F(e){let{withLabel:s=!1,cluster:t,status:l,onOpenSSHModal:a,onOpenVSCodeModal:n}=e,c=H(l),o=(0,b.X)(),u=e=>{switch(e){case"connect":q(t,a);break;case"VSCode":O(t,n);break;default:return}};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center space-x-4",children:Object.entries(W).map(e=>{let t,l,[a,n]=e;switch(a){case"connect":t="Connect",l="Connect with SSH";break;case"VSCode":t="VSCode",l="Open in VS Code"}return(s||(t=""),c.includes(a))?(0,r.jsx)(i.WH,{content:l,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("button",{onClick:()=>u(a),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},a):(0,r.jsx)(i.WH,{content:l,className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("span",{className:"opacity-30 flex items-center cursor-not-allowed text-sm",title:a,children:[n,!o&&(0,r.jsx)("span",{className:"ml-1.5",children:t})]})},a)})})})}let V=e=>{let{propertyList:s=[],valueList:t,setFilters:a,updateURLParams:n,placeholder:i="Filter clusters",filters:c=[]}=e,o=(0,l.useRef)(null),u=(0,l.useRef)(null),[d,h]=(0,l.useState)(!1),[x,p]=(0,l.useState)(""),[m,f]=(0,l.useState)("status"),[j,v]=(0,l.useState)([]);(0,l.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&o.current&&!o.current.contains(e.target)&&h(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,l.useEffect)(()=>{let e=[],s=m||"";if(s.length>1){s=m[0].toUpperCase();for(let e=1;e<m.length;e++)s+=m[e]}let r=c.filter(e=>e.property===s).map(e=>e.value);if(t&&"object"==typeof t)switch(m){case"status":e=t.status.filter(e=>!r.find(s=>s===e))||[];break;case"user":e=t.user.filter(e=>!r.find(s=>s===e))||[];break;case"cluster":e=t.cluster.filter(e=>!r.find(s=>s===e))||[];break;case"workspace":e=t.workspace.filter(e=>!r.find(s=>s===e))||[];break;case"infra":e=t.infra.filter(e=>!r.find(s=>s===e))||[]}""!==x.trim()&&(e=e.filter(e=>e&&e.toString().toLowerCase().includes(x.toLowerCase()))),v(e)},[m,t,x,c]);let g=e=>{let t=s.find(s=>s.value===e);return t?t.label:e},y=e=>{a(s=>{let t=[...s,{property:g(m),operator:":",value:e}];return n(t),t}),h(!1),p(""),o.current.focus()};return(0,r.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,r.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,r.jsxs)(k.Ph,{onValueChange:f,value:m,children:[(0,r.jsx)(k.i4,{"aria-label":"Filter Property",className:"focus:ring-0 focus:ring-offset-0 border-none rounded-l-md rounded-r-none w-20 sm:w-24 md:w-32 h-8 text-xs sm:text-sm",children:(0,r.jsx)(k.ki,{placeholder:"Status"})}),(0,r.jsx)(k.Bw,{children:s.map((e,s)=>(0,r.jsx)(k.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:"text",ref:o,placeholder:i,value:x,onChange:e=>{p(e.target.value),d||h(!0)},onFocus:()=>{h(!0)},onKeyDown:e=>{"Enter"===e.key&&""!==x.trim()?(a(e=>{let s=[...e,{property:g(m),operator:":",value:x}];return n(s),s}),p(""),h(!1)):"Escape"===e.key&&(h(!1),o.current.blur())},className:"h-8 w-full sm:w-96 px-3 pr-8 text-sm border-none rounded-l-none rounded-r-md focus:ring-0 focus:outline-none",autoComplete:"off"}),x&&(0,r.jsx)("button",{onClick:()=>{p(""),h(!1)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",tabIndex:-1,children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),d&&j.length>0&&(0,r.jsx)("div",{ref:u,className:"absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-60 overflow-y-auto",style:{zIndex:9999},children:j.map((e,s)=>(0,r.jsx)("div",{className:"px-3 py-2 cursor-pointer hover:bg-gray-50 text-sm ".concat(s!==j.length-1?"border-b border-gray-100":""),onClick:()=>y(e),children:(0,r.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},z=e=>{let{filters:s=[],setFilters:t,updateURLParams:l}=e,a=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return l(t),t})};return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,r.jsx)(A,{filter:e,onRemove:()=>a(s)},"filteritem-".concat(s))),s.length>0&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("button",{onClick:()=>{l([]),t([])},className:"rounded-full px-4 py-1 text-sm text-gray-700 bg-gray-200 hover:bg-gray-300",children:"Clear filters"})})]})})})},A=e=>{let{filter:s,onRemove:t}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,r.jsx)("span",{children:"".concat(s.property," ")}),(0,r.jsx)("span",{children:"".concat(s.operator," ")}),(0,r.jsx)("span",{children:" ".concat(s.value)})]}),(0,r.jsx)("button",{onClick:()=>t(),className:"p-0.5 ml-1 transform text-gray-400 hover:text-gray-600 bg-blue-500 hover:bg-blue-600 rounded-full flex flex-col items-center",title:"Clear filter",children:(0,r.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:5,d:"M6 18L18 6M6 6l12 12"})})})]})})}},12003:function(e,s,t){t.d(s,{j:function(){return n}});var r=t(90512);let l=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=r.W,n=(e,s)=>t=>{var r;if((null==s?void 0:s.variants)==null)return a(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:n,defaultVariants:i}=s,c=Object.keys(n).map(e=>{let s=null==t?void 0:t[e],r=null==i?void 0:i[e];if(null===s)return null;let a=l(s)||l(r);return n[e][a]}),o=t&&Object.entries(t).reduce((e,s)=>{let[t,r]=s;return void 0===r||(e[t]=r),e},{});return a(e,c,null==s?void 0:null===(r=s.compoundVariants)||void 0===r?void 0:r.reduce((e,s)=>{let{class:t,className:r,...l}=s;return Object.entries(l).every(e=>{let[s,t]=e;return Array.isArray(t)?t.includes({...i,...o}[s]):({...i,...o})[s]===t})?[...e,t,r]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2260],{50326:function(e,t,a){a.d(t,{$N:function(){return m},Be:function(){return h},Vq:function(){return c},cN:function(){return _},cZ:function(){return d},fK:function(){return f}});var s=a(85893),r=a(67294),o=a(6327),n=a(32350),l=a(43767);let c=o.fC;o.xz;let u=o.h_;o.x8;let i=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(o.aV,{ref:t,className:(0,n.cn)("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...r})});i.displayName=o.aV.displayName;let d=r.forwardRef((e,t)=>{let{className:a,children:r,...c}=e;return(0,s.jsxs)(u,{children:[(0,s.jsx)(i,{}),(0,s.jsxs)(o.VY,{ref:t,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...c,children:[r,(0,s.jsxs)(o.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100 data-[state=open]:text-gray-500",children:[(0,s.jsx)(l.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});d.displayName=o.VY.displayName;let f=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...a})};f.displayName="DialogHeader";let _=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a})};_.displayName="DialogFooter";let m=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(o.Dx,{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",a),...r})});m.displayName=o.Dx.displayName;let h=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(o.dk,{ref:t,className:(0,n.cn)("text-sm text-gray-500",a),...r})});h.displayName=o.dk.displayName},23266:function(e,t,a){a.d(t,{GH:function(){return f},QL:function(){return m},Sl:function(){return d},getClusters:function(){return u},uR:function(){return i}});var s=a(67294),r=a(15821),o=a(47145),n=a(93225),l=a(6378);let c={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function u(){let{clusterNames:e=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await o.x.fetch("/status",{cluster_names:e,all_users:!0,include_credentials:!1,include_handle:!1,summary_response:null==e})).map(e=>{let t="",a=t=e.zone?e.zone:e.region;return t&&t.length>25&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e||e.length<=t)return e;if(t<=3)return"...";let a=Math.floor((t-3)/2),s=a+(t-3)%2;return 0===a?e.substring(0,s)+"...":e.substring(0,s)+"..."+e.substring(e.length-a)}(t,25)),{status:c[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra:a?"".concat(e.cloud," (").concat(a,")"):e.cloud,cpus:e.cpus,mem:e.memory,gpus:e.accelerators,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:new Date(1e3*e.launched_at),num_nodes:e.nodes,workspace:e.workspace,autostop:e.autostop,last_event:e.last_event,to_down:e.to_down,cluster_name_on_cloud:e.cluster_name_on_cloud,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){throw console.error("Error fetching clusters:",e),e}}async function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;try{let a={days:t,dashboard_summary_response:!0};e&&(a.cluster_hashes=[e]);let s=await o.x.fetch("/cost_report",a);console.log("Raw cluster history data:",s);let r=s.map(e=>{let t="Unknown";e.cloud?t=e.cloud:e.resources&&e.resources.cloud&&(t=e.resources.cloud);let a=e.user_name||"-";return{status:e.status?c[e.status]:"TERMINATED",cluster:e.name,user:a,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,last_event:e.last_event,to_down:!1,cluster_name_on_cloud:null,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",r),r}catch(e){throw console.error("Error fetching cluster history:",e),e}}async function d(e){let{clusterName:t,jobId:a,onNewLog:s,workspace:n}=e;try{await o.x.stream("/logs",{follow:!1,cluster_name:t,job_id:a,tail:1e4,override_skypilot_config:{active_workspace:n||"default"}},s)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,r.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function f(e){let{clusterName:t,jobIds:a=null,workspace:s}=e;try{let e=await o.x.fetch("/download_logs",{cluster_name:t,job_ids:a?a.map(String):null,override_skypilot_config:{active_workspace:s||"default"}}),l=Object.values(e||{});if(!l.length){(0,r.C)("No logs found to download.","warning");return}let c=window.location.origin,u="".concat(c).concat(n.f4,"/download"),i=await fetch("".concat(u,"?relative=items"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder_paths:l})});if(!i.ok){let e=await i.text();throw Error("Download failed: ".concat(i.status," ").concat(e))}let d=await i.blob(),f=window.URL.createObjectURL(d),_=document.createElement("a"),m=new Date().toISOString().replace(/[:.]/g,"-"),h=a&&1===a.length?"job-".concat(a[0]):"jobs";_.href=f,_.download="".concat(t,"-").concat(h,"-logs-").concat(m,".zip"),document.body.appendChild(_),_.click(),_.remove(),window.URL.revokeObjectURL(f)}catch(e){console.error("Error downloading logs:",e),(0,r.C)("Error downloading logs: ".concat(e.message),"error")}}async function _(e){let{clusterName:t,workspace:a}=e;try{return(await o.x.fetch("/queue",{cluster_name:t,all_users:!0,override_skypilot_config:{active_workspace:a}})).map(e=>{var s;let r=e.end_at?e.end_at:Date.now()/1e3,o=0,n=0;return e.submitted_at&&(o=r-e.submitted_at),e.start_at&&(n=r-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,user_hash:e.user_hash,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:o,job_duration:n,infra:"",logs:"",workspace:a||"default",git_commit:(null===(s=e.metadata)||void 0===s?void 0:s.git_commit)||"-"}})}catch(e){throw console.error("Error fetching cluster jobs:",e),e}}function m(e){let{cluster:t,job:a=null}=e,[r,o]=(0,s.useState)(null),[n,c]=(0,s.useState)(null),[i,d]=(0,s.useState)(!0),[f,m]=(0,s.useState)(!0),h=(0,s.useCallback)(async()=>{if(t)try{d(!0);let e=await l.default.get(u,[{clusterNames:[t]}]);if(e.length>0)return o(e[0]),e[0];return console.error("No cluster data found for cluster:",t),null}catch(e){console.error("Error fetching cluster data:",e)}finally{d(!1)}return null},[t]),g=(0,s.useCallback)(async e=>{if(t)try{m(!0);let a=await l.default.get(_,[{clusterName:t,workspace:e||"default"}]);c(a)}catch(e){console.error("Error fetching cluster job data:",e)}finally{m(!1)}},[t]),p=(0,s.useCallback)(async()=>{l.default.invalidate(u,[{clusterNames:[t]}]);let e=await h();e&&(l.default.invalidate(_,[{clusterName:t,workspace:e.workspace||"default"}]),await g(e.workspace))},[h,g,t]),w=(0,s.useCallback)(async()=>{r&&(l.default.invalidate(_,[{clusterName:t,workspace:r.workspace||"default"}]),await g(r.workspace))},[g,r,t]);return(0,s.useEffect)(()=>{(async()=>{let e=await h();e&&g(e.workspace)})()},[t,a,h,g]),{clusterData:r,clusterJobData:n,loading:i,clusterDetailsLoading:i,clusterJobsLoading:f,refreshData:p,refreshClusterJobsOnly:w}}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2350],{32350:function(n,r,u){u.d(r,{cn:function(){return c}});var e=u(90512),t=u(98388);function c(){for(var n=arguments.length,r=Array(n),u=0;u<n;u++)r[u]=arguments[u];return(0,t.m6)((0,e.W)(r))}}}]);
@@ -1,15 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2369],{27325:function(e,t,n){n.d(t,{Z:function(){return r}});/**
2
- * @license lucide-react v0.407.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */let r=(0,n(60998).Z)("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"}]])},13626:function(e,t,n){n.d(t,{Z:function(){return r}});/**
7
- * @license lucide-react v0.407.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */let r=(0,n(60998).Z)("RotateCw",[["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"}]])},6327:function(e,t,n){n.d(t,{x8:function(){return eu},VY:function(){return eo},dk:function(){return ea},aV:function(){return er},h_:function(){return en},fC:function(){return ee},Dx:function(){return ei},xz:function(){return et}});var r=n(67294),o=n(36206),i=n(28771),a=n(25360),u=n(91276),l=n(77342),s=n(46063),c=n(95420),d=n(42651),f=n(9981),p=e=>{let t,n;let{present:o,children:a}=e,u=function(e){var t,n;let[o,i]=r.useState(),a=r.useRef(null),u=r.useRef(e),l=r.useRef("none"),[s,c]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},r.useReducer((e,t)=>n[e][t]??e,t));return r.useEffect(()=>{let e=m(a.current);l.current="mounted"===s?e:"none"},[s]),(0,f.b)(()=>{let t=a.current,n=u.current;if(n!==e){let r=l.current,o=m(t);e?c("MOUNT"):"none"===o||t?.display==="none"?c("UNMOUNT"):n&&r!==o?c("ANIMATION_OUT"):c("UNMOUNT"),u.current=e}},[e,c]),(0,f.b)(()=>{if(o){let e;let t=o.ownerDocument.defaultView??window,n=n=>{let r=m(a.current).includes(n.animationName);if(n.target===o&&r&&(c("ANIMATION_END"),!u.current)){let n=o.style.animationFillMode;o.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===o.style.animationFillMode&&(o.style.animationFillMode=n)})}},r=e=>{e.target===o&&(l.current=m(a.current))};return o.addEventListener("animationstart",r),o.addEventListener("animationcancel",n),o.addEventListener("animationend",n),()=>{t.clearTimeout(e),o.removeEventListener("animationstart",r),o.removeEventListener("animationcancel",n),o.removeEventListener("animationend",n)}}c("ANIMATION_END")},[o,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:r.useCallback(e=>{a.current=e?getComputedStyle(e):null,i(e)},[])}}(o),l="function"==typeof a?a({present:u.isPresent}):r.Children.only(a),s=(0,i.e)(u.ref,(t=Object.getOwnPropertyDescriptor(l.props,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning?l.ref:(t=Object.getOwnPropertyDescriptor(l,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning?l.props.ref:l.props.ref||l.ref);return"function"==typeof a||u.isPresent?r.cloneElement(l,{ref:s}):null};function m(e){return e?.animationName||"none"}p.displayName="Presence";var g=n(75320),y=n(27552),v=n(6223),N=n(23541),h=n(88426),D=n(85893),R="Dialog",[M,O]=(0,a.b)(R),[x,w]=M(R),b=e=>{let{__scopeDialog:t,children:n,open:o,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,c=r.useRef(null),d=r.useRef(null),[f,p]=(0,l.T)({prop:o,defaultProp:i??!1,onChange:a,caller:R});return(0,D.jsx)(x,{scope:t,triggerRef:c,contentRef:d,contentId:(0,u.M)(),titleId:(0,u.M)(),descriptionId:(0,u.M)(),open:f,onOpenChange:p,onOpenToggle:r.useCallback(()=>p(e=>!e),[p]),modal:s,children:n})};b.displayName=R;var I="DialogTrigger",j=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=w(I,n),u=(0,i.e)(t,a.triggerRef);return(0,D.jsx)(g.WV.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":K(a.open),...r,ref:u,onClick:(0,o.M)(e.onClick,a.onOpenToggle)})});j.displayName=I;var C="DialogPortal",[E,_]=M(C,{forceMount:void 0}),T=e=>{let{__scopeDialog:t,forceMount:n,children:o,container:i}=e,a=w(C,t);return(0,D.jsx)(E,{scope:t,forceMount:n,children:r.Children.map(o,e=>(0,D.jsx)(p,{present:n||a.open,children:(0,D.jsx)(d.h,{asChild:!0,container:i,children:e})}))})};T.displayName=C;var A="DialogOverlay",F=r.forwardRef((e,t)=>{let n=_(A,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=w(A,e.__scopeDialog);return i.modal?(0,D.jsx)(p,{present:r||i.open,children:(0,D.jsx)(P,{...o,ref:t})}):null});F.displayName=A;var k=(0,h.Z8)("DialogOverlay.RemoveScroll"),P=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(A,n);return(0,D.jsx)(v.Z,{as:k,allowPinchZoom:!0,shards:[o.contentRef],children:(0,D.jsx)(g.WV.div,{"data-state":K(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),W="DialogContent",U=r.forwardRef((e,t)=>{let n=_(W,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=w(W,e.__scopeDialog);return(0,D.jsx)(p,{present:r||i.open,children:i.modal?(0,D.jsx)(V,{...o,ref:t}):(0,D.jsx)(S,{...o,ref:t})})});U.displayName=W;var V=r.forwardRef((e,t)=>{let n=w(W,e.__scopeDialog),a=r.useRef(null),u=(0,i.e)(t,n.contentRef,a);return r.useEffect(()=>{let e=a.current;if(e)return(0,N.Ry)(e)},[]),(0,D.jsx)(L,{...e,ref:u,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,o.M)(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:(0,o.M)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:(0,o.M)(e.onFocusOutside,e=>e.preventDefault())})}),S=r.forwardRef((e,t)=>{let n=w(W,e.__scopeDialog),o=r.useRef(!1),i=r.useRef(!1);return(0,D.jsx)(L,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(o.current||n.triggerRef.current?.focus(),t.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(o.current=!0,"pointerdown"!==t.detail.originalEvent.type||(i.current=!0));let r=t.target;n.triggerRef.current?.contains(r)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&i.current&&t.preventDefault()}})}),L=r.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:u,...l}=e,d=w(W,n),f=r.useRef(null),p=(0,i.e)(t,f);return(0,y.EW)(),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(c.M,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:a,onUnmountAutoFocus:u,children:(0,D.jsx)(s.XB,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":K(d.open),...l,ref:p,onDismiss:()=>d.onOpenChange(!1)})}),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(J,{titleId:d.titleId}),(0,D.jsx)(Q,{contentRef:f,descriptionId:d.descriptionId})]})]})}),Z="DialogTitle",$=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(Z,n);return(0,D.jsx)(g.WV.h2,{id:o.titleId,...r,ref:t})});$.displayName=Z;var B="DialogDescription",q=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,o=w(B,n);return(0,D.jsx)(g.WV.p,{id:o.descriptionId,...r,ref:t})});q.displayName=B;var z="DialogClose",H=r.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=w(z,n);return(0,D.jsx)(g.WV.button,{type:"button",...r,ref:t,onClick:(0,o.M)(e.onClick,()=>i.onOpenChange(!1))})});function K(e){return e?"open":"closed"}H.displayName=z;var X="DialogTitleWarning",[Y,G]=(0,a.k)(X,{contentName:W,titleName:Z,docsSlug:"dialog"}),J=({titleId:e})=>{let t=G(X),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
12
-
13
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
14
-
15
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return r.useEffect(()=>{e&&!document.getElementById(e)&&console.error(n)},[n,e]),null},Q=({contentRef:e,descriptionId:t})=>{let n=G("DialogDescriptionWarning"),o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${n.contentName}}.`;return r.useEffect(()=>{let n=e.current?.getAttribute("aria-describedby");t&&n&&!document.getElementById(t)&&console.warn(o)},[o,e,t]),null},ee=b,et=j,en=T,er=F,eo=U,ei=$,ea=q,eu=H}}]);
@@ -1,26 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2755],{81260:function(e,t,s){s.d(t,{Z:function(){return r}});/**
2
- * @license lucide-react v0.407.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */let r=(0,s(60998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},47603:function(e,t,s){s.d(t,{Z:function(){return r}});/**
7
- * @license lucide-react v0.407.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */let r=(0,s(60998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1812:function(e,t,s){s.d(t,{X:function(){return l}});var r=s(85893),n=s(67294);let a=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let t=e.message;return t.includes("failed:")&&(t=t.split("failed:")[1].trim()),t},l=e=>{let{error:t,title:s="Error",onDismiss:l}=e,[o,i]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{t&&i(!1)},[t]),!t||o)return null;let c="string"==typeof t?t:a(t);return(0,r.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsxs)("div",{className:"text-sm text-red-800",children:[(0,r.jsxs)("strong",{children:[s,":"]})," ",c]})})]}),(0,r.jsx)("button",{onClick:()=>{i(!0),l&&l()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,r.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},27669:function(e,t,s){s.r(t),s.d(t,{Users:function(){return H}});var r=s(85893),n=s(67294),a=s(45697),l=s.n(a),o=s(55739),i=s(41664),c=s.n(i),u=s(11163),d=s(30803),m=s(68764),x=s(53081),h=s(23266),p=s(68969),f=s(6378),g=s(36856),b=s(51214),j=s(94545),y=s(36989),v=s(60998);/**
12
- * @license lucide-react v0.407.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */let w=(0,v.Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);var N=s(13626),k=s(81260);/**
17
- * @license lucide-react v0.407.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */let C=(0,v.Z)("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]),_=(0,v.Z)("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var S=s(16826),E=s(70282),R=s(43767);/**
22
- * @license lucide-react v0.407.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */let D=(0,v.Z)("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),I=(0,v.Z)("KeyRound",[["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"}]]);var T=s(47603),L=s(27325);s(9353);var U=s(23001),A=s(66235),F=s(37673),Z=s(47145),P=s(50326),O=s(1812),M=s(47615),z=s(10546);let q=new Set(M.statusGroups.active),V=[{label:"Name",value:"name"},{label:"GPU",value:"gpu type"},{label:"Infra",value:"infra"},{label:"User ID",value:"user id"},{label:"Role",value:"role"}],B=(e,t)=>{if(!e)return 0;let s=e;if("string"==typeof e)try{let t=e.replace(/'/g,'"').replace(/None/g,"null");s=JSON.parse(t)}catch(t){return console.error("Failed to parse accelerators string:",e,t),0}if("object"==typeof s&&null!==s){let e=Object.entries(s);return 0===e.length?0:(e.length>1&&console.warn("".concat(t," has ").concat(e.length," accelerator entries:"),s),Number(e[0][1])||0)}return 0},G=(e,t)=>e&&e.includes("@")?e.split("@")[0]:e||"N/A",J=(e,t)=>e&&e.includes("@")?e:t||"-",K=b.nb.REFRESH_INTERVAL,$=e=>{let{message:t,onDismiss:s}=e;return t?(0,r.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsx)("p",{className:"text-sm font-medium text-green-800",children:t})})]}),s&&(0,r.jsx)("div",{className:"ml-auto pl-3",children:(0,r.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,r.jsxs)("button",{type:"button",onClick:s,className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50",children:[(0,r.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,r.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})})]})}):null};function H(){let e=(0,u.useRouter)(),{userEmail:t}=(0,A.Ap)(),[s,a]=(0,n.useState)(!1),l=(0,n.useRef)(null),i=(0,U.X)(),[c,m]=(0,n.useState)(!1),[g,b]=(0,n.useState)({username:"",password:"",role:"user"}),[j,y]=(0,n.useState)(!1),[v,E]=(0,n.useState)({open:!1,message:"",userName:""}),[R,D]=(0,n.useState)(null),[I,T]=(0,n.useState)(!1),[L,F]=(0,n.useState)(!1),[M,q]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),[J,H]=(0,n.useState)(!1),[Q,Y]=(0,n.useState)(null),[ee,et]=(0,n.useState)("import"),[es,er]=(0,n.useState)(!1),[en,ea]=(0,n.useState)(null),[el,eo]=(0,n.useState)(""),[ei,ec]=(0,n.useState)(!1),[eu,ed]=(0,n.useState)(null),[em,ex]=(0,n.useState)(!1),[eh,ep]=(0,n.useState)(null),[ef,eg]=(0,n.useState)(null),[eb,ej]=(0,n.useState)(!1),[ey,ev]=(0,n.useState)(null),[ew,eN]=(0,n.useState)(null),[ek,eC]=(0,n.useState)(void 0),[e_,eS]=(0,n.useState)(void 0),[eE,eR]=(0,n.useState)(void 0),[eD,eI]=(0,n.useState)(!0),[eT,eL]=(0,n.useState)("users"),[eU,eA]=(0,n.useState)(!1),[eF,eZ]=(0,n.useState)(!1),[eP,eO]=(0,n.useState)(null),[eM,ez]=(0,n.useState)(!1),[eq,eV]=(0,n.useState)(""),[eB,eG]=(0,n.useState)(""),[eJ,eK]=(0,n.useState)([]),[e$,eH]=(0,n.useState)({name:[],"user id":[],role:[],"gpu type":[],infra:[]}),[eW,eX]=(0,n.useState)(()=>{if(e.isReady){let t=e.query.deduplicate;if(void 0!==t)return"true"===t}return!0});(0,n.useEffect)(()=>{if(e.isReady){let s=e.query.deduplicate;if(void 0===s)eQ(!t);else{let e="true"===s;eW!==e&&eX(e)}}},[e.isReady,e.query.deduplicate,t]);let eQ=t=>{let s={...e.query};s.deduplicate=t.toString(),e.replace({pathname:e.pathname,query:s},void 0,{shallow:!0})},eY=t=>{(0,z.eG)(e,t)},e0=new Map([["name","Name"],["user id","User ID"],["role","Role"],["gpu type","GPU"],["infra","Infra"]]);(0,n.useEffect)(()=>{if(e.isReady&&"users"===eT){let t=(0,z.Fu)(e,e0);t.length>0&&eK(t)}},[e.isReady,eT]),(0,n.useEffect)(()=>{e.isReady&&("service-accounts"===e.query.tab&&e_?eL("service-accounts"):eL("users"))},[e.isReady,e.query.tab,e_]),(0,n.useEffect)(()=>{(async function(){eI(!0);try{let e=await Z.x.get("/api/health");if(e.ok){let t=await e.json();eC(!!t.basic_auth_enabled),eS(!!t.service_account_token_enabled),eR(!!t.ingress_basic_auth_enabled)}else eC(!1),eS(!1),eR(!1)}catch(e){eC(!1),eS(!1),eR(!1)}finally{eI(!1)}})()},[]);let e1=(0,n.useCallback)(async()=>{if(R&&Date.now()-R.timestamp<3e5)return R;T(!0);try{let e=await Z.x.get("/users/role");if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to get user role")}let t=await e.json(),s={role:t.role,name:t.name,id:t.id,timestamp:Date.now()};return D(s),T(!1),s}catch(e){throw T(!1),e}},[R]);(0,n.useEffect)(()=>{e1().catch(()=>{console.error("Failed to get user role")})},[e1]);let e2=async(e,t)=>{try{let s=await e1();if("admin"!==s.role)return E({open:!0,message:e,userName:s.name.toLowerCase()}),!1;return t(),!0}catch(e){return console.error("Failed to check user role:",e),E({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},e4=()=>{f.default.invalidate(x.R),f.default.invalidate(h.getClusters),f.default.invalidate(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status"]}]),l.current&&l.current()},e3=async()=>{if(!g.username||!g.password){eN(Error("Username and password are required.")),m(!1);return}y(!0),eN(null),ev(null);try{let e=await Z.x.post("/users/create",g);if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to create user")}ev('User "'.concat(g.username,'" created successfully!')),m(!1),b({username:"",password:"",role:"user"}),e4()}catch(e){eN(e),m(!1),b({username:"",password:"",role:"user"})}finally{y(!1)}},e5=async e=>{let t=e.target.files[0];t&&(G(t),Y(null))},e6=async()=>{if(!B){alert("Please select a CSV file first.");return}H(!0);try{let e=new FileReader;e.onload=async e=>{try{let t=e.target.result,s=await Z.x.post("/users/import",{csv_content:t});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to import users")}let r=await s.json(),n="Import completed. ".concat(r.success_count," users created successfully.");r.error_count>0&&(n+="\n".concat(r.error_count," failed."),r.creation_errors.length>0&&(n+="\nErrors: ".concat(r.creation_errors.slice(0,3).join(", ")),r.creation_errors.length>3&&(n+=" and ".concat(r.creation_errors.length-3," more...")))),Y({message:n}),r.success_count>0&&e4()}catch(e){alert("Error importing users: ".concat(e.message))}finally{H(!1)}},e.readAsText(B)}catch(e){alert("Error reading file: ".concat(e.message)),H(!1)}},e7=async e=>{ea(e),eo(""),er(!0)},e8=async()=>{if(!el){eN(Error("Please enter a new password."));return}ec(!0),ed(null);try{let e=await Z.x.post("/users/update",{user_id:en.userId,password:el});if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to reset password")}ev('Password reset successfully for user "'.concat(en.usernameDisplay,'"!')),er(!1),ea(null),eo("")}catch(e){er(!1),ea(null),eo(""),ed(null),eN(e)}finally{ec(!1)}},e9=async()=>{if(eh){ej(!0),eg(null);try{let e=await Z.x.post("/users/delete",{user_id:eh.userId});if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to delete user")}ev('User "'.concat(eh.usernameDisplay,'" deleted successfully!')),ex(!1),ep(null),e4()}catch(e){ex(!1),ep(null),eg(null),eN(e)}finally{ej(!1)}}},te=()=>{ex(!1),ep(null)},tt=()=>{er(!1),ea(null),eo("")};return eD?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)("button",{className:e_?"leading-none mr-6 pb-2 px-2 border-b-2 ".concat("users"===eT?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"):"leading-none mr-6 pb-2 px-2",onClick:()=>{eL("users"),e.push("/users",void 0,{shallow:!0})},children:"Users"}),e_&&(0,r.jsx)("button",{className:"leading-none pb-2 px-2 border-b-2 ".concat("service-accounts"===eT?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"),onClick:()=>{eL("service-accounts"),e.push("/users?tab=service-accounts",void 0,{shallow:!0})},children:"Service Accounts"})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[s&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(o.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),"users"===eT&&ek&&(null==R?void 0:R.role)==="admin"&&(0,r.jsx)("button",{onClick:async()=>{await e2("cannot create users",()=>{m(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Create New User",children:"+ New User"}),"users"===eT&&ek&&(null==R?void 0:R.role)==="admin"&&(0,r.jsxs)("button",{onClick:async()=>{await e2("cannot import users",()=>{q(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Import/Export Users",children:[(0,r.jsx)(w,{className:"h-4 w-4 mr-1"}),"Import/Export"]}),(0,r.jsxs)("button",{onClick:e4,disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(N.Z,{className:"h-4 w-4 mr-1.5"}),!i&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:["users"===eT?(0,r.jsx)("div",{className:"w-full sm:w-auto max-w-md",children:(0,r.jsx)(z.ML,{propertyList:V,valueList:e$,setFilters:eK,updateURLParams:eY,placeholder:"Filter users"})}):(0,r.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,r.jsx)("input",{type:"text",placeholder:"Search by service account name, or created by",value:eB,onChange:e=>{eG(e.target.value)},className:"h-8 w-full px-3 pr-8 text-sm border border-gray-300 rounded-md focus:ring-1 focus:ring-sky-500 focus:border-sky-500 outline-none"}),eB&&(0,r.jsx)("button",{onClick:()=>{eG("")},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),"users"===eT&&!t&&(0,r.jsxs)("label",{className:"flex items-center cursor-pointer ml-4",children:[(0,r.jsx)("input",{type:"checkbox",checked:eW,onChange:e=>{let t=e.target.checked;eX(t),eQ(t)},className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors ".concat(eW?"bg-sky-600":"bg-gray-300"),children:(0,r.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white transition-transform ".concat(eW?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Deduplicate users"})]}),"service-accounts"===eT&&e_&&(0,r.jsxs)("button",{onClick:()=>{e2("cannot create service account tokens",()=>{eA(!0)})},className:"ml-4 bg-sky-600 hover:bg-sky-700 text-white flex items-center rounded-md px-3 py-1 text-sm font-medium transition-colors duration-200",title:"Create Service Account",children:[(0,r.jsx)(k.Z,{className:"h-4 w-4 mr-2"}),"Create Service Account"]})]}),"users"===eT&&(0,r.jsx)(z.x$,{filters:eJ,setFilters:eK,updateURLParams:eY}),(0,r.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[(0,r.jsx)($,{message:ey,onDismiss:()=>ev(null)}),(0,r.jsx)(O.X,{error:ew,title:"Error",onDismiss:()=>eN(null)})]}),"users"===eT?(0,r.jsx)(W,{refreshInterval:K,setLoading:a,refreshDataRef:l,checkPermissionAndAct:e2,roleLoading:I,onResetPassword:e7,onDeleteUser:e=>{e2("cannot delete users",()=>{ep(e),ex(!0)})},basicAuthEnabled:ek,ingressBasicAuthEnabled:eE,currentUserRole:null==R?void 0:R.role,currentUserId:null==R?void 0:R.id,filters:eJ,setValueList:eH,deduplicateUsers:eW}):e_&&(0,r.jsx)(X,{checkPermissionAndAct:e2,userRoleCache:R,setCreateSuccess:ev,setCreateError:eN,showCreateDialog:eU,setShowCreateDialog:eA,showRotateDialog:eF,setShowRotateDialog:eZ,tokenToRotate:eP,setTokenToRotate:eO,rotating:eM,setRotating:ez,searchQuery:eB,setSearchQuery:eG}),(0,r.jsx)(P.Vq,{open:c,onOpenChange:e=>{m(e),e||eN(null)},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsx)(P.fK,{children:(0,r.jsx)(P.$N,{children:"Create User"})}),(0,r.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Username"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"Username",value:g.username,onChange:e=>b({...g,username:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Password"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full pr-10",placeholder:"Password",type:L?"text":"password",value:g.password,onChange:e=>b({...g,password:e.target.value})}),(0,r.jsx)("button",{type:"button",className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600",onClick:()=>F(!L),children:L?(0,r.jsx)(C,{className:"h-4 w-4"}):(0,r.jsx)(_,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Role"}),(0,r.jsxs)("select",{className:"border rounded px-3 py-2 w-full",value:g.role,onChange:e=>b({...g,role:e.target.value}),children:[(0,r.jsx)("option",{value:"user",children:"User"}),(0,r.jsx)("option",{value:"admin",children:"Admin"})]})]})]}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>m(!1),disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:e3,disabled:j,children:j?"Creating...":"Create"})]})]})}),(0,r.jsx)(P.Vq,{open:v.open,onOpenChange:e=>{E(t=>({...t,open:e})),e||eN(null)},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Permission Denied"}),(0,r.jsx)(P.Be,{children:I?(0,r.jsxs)("div",{className:"flex items-center py-2",children:[(0,r.jsx)(o.Z,{size:16,className:"mr-2"}),(0,r.jsx)("span",{children:"Checking permissions..."})]}):(0,r.jsx)(r.Fragment,{children:v.userName?(0,r.jsxs)(r.Fragment,{children:[v.userName," is logged in as non-admin and ",v.message,"."]}):v.message})})]}),(0,r.jsx)(P.cN,{children:(0,r.jsx)(d.z,{variant:"outline",onClick:()=>E(e=>({...e,open:!1})),disabled:I,children:"OK"})})]})}),(0,r.jsx)(P.Vq,{open:M,onOpenChange:e=>{q(e),e||eN(null)},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-lg",children:[(0,r.jsx)(P.fK,{children:(0,r.jsx)(P.$N,{children:"Import/Export Users"})}),(0,r.jsxs)("div",{className:"flex border-b border-gray-200 mb-4",children:[(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("import"===ee?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>et("import"),children:"Import"}),(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("export"===ee?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>et("export"),children:"Export"})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:"import"===ee?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"CSV File"}),(0,r.jsx)("input",{type:"file",accept:".csv",onChange:e5,className:"border rounded px-3 py-2 w-full"}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["CSV should have columns: username, password, role",(0,r.jsx)("br",{}),"Supports both plain text passwords and exported password hashes."]})]}),Q&&(0,r.jsx)("div",{className:"p-3 bg-green-50 border border-green-200 rounded text-green-700 text-sm",children:Q.message})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Export Users to CSV"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Download all users as a CSV file with password hashes."}),(0,r.jsxs)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ This will export all users with columns: username, password (hashed), role"}),(0,r.jsx)("p",{className:"text-xs text-amber-600 mt-1",children:"Password hashes can be imported directly for system backups."})]})]})})}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>q(!1),disabled:J,children:"Cancel"}),"import"===ee?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:e6,disabled:J||!B,children:J?"Importing...":"Import"}):(0,r.jsxs)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:async()=>{try{let e=await Z.x.get("/users/export");if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to export users")}let t=await e.json(),s=t.csv_content,r=new Blob([s],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(r),a=document.createElement("a");a.href=n;let l=new Date,o=e=>String(e).padStart(2,"0"),i=l.getFullYear(),c=o(l.getMonth()+1),u=o(l.getDate()),d=o(l.getHours()),m=o(l.getMinutes()),x=o(l.getSeconds());a.download="users_export_".concat(i,"-").concat(c,"-").concat(u,"-").concat(d,"-").concat(m,"-").concat(x,".csv"),a.click(),URL.revokeObjectURL(n),alert("Successfully exported ".concat(t.user_count," users to CSV file."))}catch(e){alert("Error exporting users: ".concat(e.message))}},children:[(0,r.jsx)(S.Z,{className:"h-4 w-4 mr-1"}),"Export"]})]})]})}),(0,r.jsx)(P.Vq,{open:es,onOpenChange:e=>{e||(tt(),eN(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Reset Password"}),(0,r.jsxs)(P.Be,{children:["Enter a new password for"," ",(null==en?void 0:en.usernameDisplay)||"this user","."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Password"}),(0,r.jsx)("input",{type:"password",className:"border rounded px-3 py-2 w-full",placeholder:"Enter new password",value:el,onChange:e=>eo(e.target.value),autoFocus:!0})]})}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)(d.z,{variant:"outline",onClick:tt,disabled:ei,children:"Cancel"}),(0,r.jsx)(d.z,{variant:"default",onClick:e8,disabled:ei||!el,className:"bg-sky-600 text-white hover:bg-sky-700",children:ei?"Resetting...":"Reset Password"})]})]})}),(0,r.jsx)(P.Vq,{open:em,onOpenChange:e=>{e||(te(),eN(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Delete User"}),(0,r.jsxs)(P.Be,{children:['Are you sure you want to delete user "',(null==eh?void 0:eh.usernameDisplay)||"this user",'"? This action cannot be undone.']})]}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)(d.z,{variant:"outline",onClick:te,disabled:eb,children:"Cancel"}),(0,r.jsx)(d.z,{variant:"destructive",onClick:e9,disabled:eb,children:eb?"Deleting...":"Delete"})]})]})})]})}function W(e){let{refreshInterval:t,setLoading:s,refreshDataRef:a,checkPermissionAndAct:l,roleLoading:i,onResetPassword:u,onDeleteUser:d,basicAuthEnabled:b,ingressBasicAuthEnabled:v,currentUserRole:w,currentUserId:N,filters:k,setValueList:C,deduplicateUsers:_}=e,[S,L]=(0,n.useState)([]),[U,A]=(0,n.useState)(!0),[P,O]=(0,n.useState)(!1),[M,V]=(0,n.useState)({key:"username",direction:"ascending"}),[K,$]=(0,n.useState)(null),[H,W]=(0,n.useState)(""),[X,Q]=(0,n.useState)({}),[Y,ee]=(0,n.useState)(!1),et=(0,n.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];s&&e&&s(!0),e&&A(!0),ee(!1);try{let t=await f.default.get(x.R),r=(t||[]).map(e=>({...e,usernameDisplay:G(e.username,e.userId),fullEmailID:J(e.username,e.userId),clusterCount:-1,jobCount:-1,gpuCount:-1}));L(r),O(!0),s&&e&&s(!1),e&&A(!1);let n=[],a={jobs:[]};try{[n,a]=await Promise.all([f.default.get(h.getClusters),f.default.get(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status","accelerators","job_name","job_id","infra"]}])])}catch(e){console.error("Error fetching clusters and managed jobs:",e)}let l=a.jobs||[],o={},i=e=>{if(!e)return null;let t=e;if("string"==typeof e)try{let s=e.replace(/'/g,'"').replace(/None/g,"null");t=JSON.parse(s)}catch(e){return null}if("object"==typeof t&&null!==t){let e=Object.entries(t);if(e.length>0)return e[0][0]}return null},c=(e,t,s,r,n,a)=>{e&&t&&(o[e]||(o[e]={}),o[e][t]||(o[e][t]={}),o[e].Total||(o[e].Total={}),o[e][t].Total||(o[e][t].Total={clusterCount:0,jobCount:0,gpuCount:0}),o[e][t].Total.clusterCount+=r,o[e][t].Total.jobCount+=n,o[e][t].Total.gpuCount+=a,s&&(o[e][t][s]||(o[e][t][s]={clusterCount:0,jobCount:0,gpuCount:0}),o[e][t][s].clusterCount+=r,o[e][t][s].jobCount+=n,o[e][t][s].gpuCount+=a,o[e].Total[s]||(o[e].Total[s]={clusterCount:0,jobCount:0,gpuCount:0}),o[e].Total[s].clusterCount+=r,o[e].Total[s].jobCount+=n,o[e].Total[s].gpuCount+=a))};for(let e of n||[]){let t=e.user_hash;if(!t)continue;let s=i(e.gpus),r=e.infra,n=0;if("STOPPED"!==e.status&&"TERMINATED"!==e.status){let t=B(e.gpus,"Cluster ".concat(e.cluster)),s=e.num_nodes||1;n=t*s}c(t,r,s,1,0,n)}let u=e=>{if(!e||"string"!=typeof e)return 1;let t=e.match(/^(\d+)x/);return t?parseInt(t[1],10):1};for(let e of l||[]){if(!q.has(e.status))continue;let t=e.user_hash;if(!t)continue;let s=i(e.accelerators),r=e.infra,n=B(e.accelerators,"Job ".concat(e.job_id)),a=u(e.resources_str_full),l=n*a;c(t,r,s,0,1,l)}Q(o),ee(!0);let d=(t||[]).map(e=>{let t=0,s=0,r=0,a=0;for(let r of n||[])if(r.user_hash===e.userId&&(t++,"STOPPED"!==r.status&&"TERMINATED"!==r.status)){let e=B(r.gpus,"Cluster ".concat(r.cluster)),t=r.num_nodes||1;s+=e*t}for(let t of l||[])if(t.user_hash===e.userId&&q.has(t.status)){r++;let e=B(t.accelerators,"Job ".concat(t.job_id)),s=u(t.resources_str_full);a+=e*s}return{...e,usernameDisplay:G(e.username,e.userId),fullEmailID:J(e.username,e.userId),clusterCount:t,jobCount:r,gpuCount:s+a}}),m=new Set,g=new Set;for(let e of Object.values(o)){for(let t of Object.keys(e))"Total"!==t&&m.add(t);if(e.Total)for(let t of Object.keys(e.Total))g.add(t)}let b=new Set,j=new Set,y=new Set;d.forEach(e=>{e.usernameDisplay&&b.add(e.usernameDisplay),e.userId&&j.add(e.userId),e.role&&y.add(e.role)}),C({name:Array.from(b).sort(),"user id":Array.from(j).sort(),role:Array.from(y).sort(),"gpu type":Array.from(g).sort(),infra:Array.from(m).sort()}),L(d)}catch(t){console.error("Failed to fetch or process user data:",t),L([]),O(!0),s&&e&&s(!1),e&&A(!1)}},[s]);(0,n.useEffect)(()=>{a&&(a.current=()=>et(!0))},[a,et]),(0,n.useEffect)(()=>{(async()=>{O(!1),A(!0),await g.ZP.preloadForPage("users"),et(!0)})();let e=setInterval(()=>{"visible"===window.document.visibilityState&&et(!1)},t);return()=>clearInterval(e)},[et,t]);let es=(0,n.useMemo)(()=>{let e=S,t=k.filter(e=>"GPU"!==e.property&&"Infra"!==e.property),s=k.filter(e=>"GPU"===e.property),r=k.filter(e=>"Infra"===e.property);t.length>0&&(e=(0,z.cm)(S.map(e=>({...e,name:e.usernameDisplay,"user id":e.userId})),t));let n=(e,t,s)=>{let r=0,n=0,a=0,l=X[e];if(!l)return{clusterCount:0,jobCount:0,gpuCount:0};let o=t.map(e=>e.toLowerCase()),i=s.map(e=>e.toLowerCase()),c=o.length>0,u=i.length>0;if(c&&u){for(let e of i)for(let[t,s]of Object.entries(l))if("Total"!==t&&t.toLowerCase()===e)for(let e of o)for(let[t,l]of Object.entries(s))"Total"!==t&&t.toLowerCase()===e&&(r+=l.clusterCount,n+=l.jobCount,a+=l.gpuCount)}else if(u){for(let e of i)for(let[t,s]of Object.entries(l))if("Total"!==t&&t.toLowerCase()===e&&s.Total){let e=s.Total;r+=e.clusterCount,n+=e.jobCount,a+=e.gpuCount}}else if(c&&l.Total)for(let e of o)for(let[t,s]of Object.entries(l.Total))t.toLowerCase()===e&&(r+=s.clusterCount,n+=s.jobCount,a+=s.gpuCount);return{clusterCount:r,jobCount:n,gpuCount:a}},a=s.length>0,l=r.length>0;if(a||l){let t=s.map(e=>e.value).filter(Boolean),o=r.map(e=>e.value).filter(Boolean),i=t.map(e=>e.toLowerCase()),c=o.map(e=>e.toLowerCase());e=(e=e.filter(e=>{let t=X[e.userId];if(!t)return!1;if(a&&l){for(let e of c)for(let[s,r]of Object.entries(t))if("Total"!==s&&s.toLowerCase()===e){for(let e of i)for(let t of Object.keys(r))if("Total"!==t&&t.toLowerCase()===e)return!0}}else if(l){for(let e of c)for(let s of Object.keys(t))if("Total"!==s&&s.toLowerCase()===e)return!0}else if(a&&t.Total){for(let e of i)for(let s of Object.keys(t.Total))if(s.toLowerCase()===e)return!0}return!1})).map(e=>{let s=n(e.userId,t,o);return{...e,clusterCount:s.clusterCount,jobCount:s.jobCount,gpuCount:s.gpuCount}})}if(_){let t={};e.forEach(e=>{let s=e.usernameDisplay;t[s]?(t[s].userIds.push(e.userId),-1!==e.clusterCount&&(-1===t[s].clusterCount?t[s].clusterCount=e.clusterCount:t[s].clusterCount+=e.clusterCount),-1!==e.jobCount&&(-1===t[s].jobCount?t[s].jobCount=e.jobCount:t[s].jobCount+=e.jobCount),-1!==e.gpuCount&&(-1===t[s].gpuCount?t[s].gpuCount=e.gpuCount:t[s].gpuCount+=e.gpuCount),e.created_at&&(!t[s].created_at||e.created_at<t[s].created_at)&&(t[s].created_at=e.created_at)):t[s]={...e,userIds:[e.userId],clusterCount:e.clusterCount,jobCount:e.jobCount,gpuCount:e.gpuCount,created_at:e.created_at}}),e=Object.values(t)}return(0,j.R0)(e,M.key,M.direction)},[S,M,k,_,X]),er=e=>{let t="ascending";M.key===e&&"ascending"===M.direction&&(t="descending"),V({key:e,direction:t})},en=e=>M.key===e?"ascending"===M.direction?" ↑":" ↓":"",ea=async(e,t)=>{await l("cannot edit user role",()=>{$(e),W(t)})},el=()=>{$(null),W("")},eo=async e=>{if(!e||!H){console.error("User ID or role is missing."),alert("Error: User ID or role is missing.");return}A(!0);try{let t=await Z.x.post("/users/update",{user_id:e,role:H});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to update role")}f.default.invalidate(x.R),await et(!0),el()}catch(e){console.error("Failed to update user role:",e),alert("Error updating role: ".concat(e.message))}finally{A(!1)}};return U&&0===S.length&&!P?(0,r.jsx)("div",{className:"flex justify-center items-center h-64",children:(0,r.jsx)(o.Z,{})}):P?k.some(e=>"GPU"===e.property||"Infra"===e.property)&&!Y?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading filtered data..."})]}):es&&0!==es.length?(0,r.jsx)(F.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(m.iA,{className:"min-w-full",children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsxs)(m.ss,{onClick:()=>er("usernameDisplay"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Name",en("usernameDisplay")]}),!_&&(0,r.jsxs)(m.ss,{onClick:()=>er("fullEmailID"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["User ID",en("fullEmailID")]}),!_&&!v&&(0,r.jsxs)(m.ss,{onClick:()=>er("role"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Role",en("role")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("created_at"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Joined",en("created_at")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("gpuCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["GPUs",en("gpuCount")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("clusterCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Clusters",en("clusterCount")]}),(0,r.jsxs)(m.ss,{onClick:()=>er("jobCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Jobs",en("jobCount")]}),!_&&(b||"admin"===w)&&(0,r.jsx)(m.ss,{className:"whitespace-nowrap w-1/7",children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:es.map(e=>(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.username,children:e.usernameDisplay}),!_&&(0,r.jsx)(m.pj,{className:"truncate",title:e.fullEmailID,children:e.fullEmailID}),!_&&!v&&(0,r.jsx)(m.pj,{className:"truncate",title:e.role,children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:K===e.userId?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:H,onChange:e=>W(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>eo(e.userId),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:el,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.role}),"admin"===w&&(0,r.jsx)("button",{onClick:()=>ea(e.userId,e.role),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.created_at)}):"-"}),(0,r.jsx)(m.pj,{children:-1===e.gpuCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(o.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(e.gpuCount>0?"bg-purple-100 text-purple-600":"bg-gray-100 text-gray-500"),title:"Total GPUs: ".concat(e.gpuCount),children:e.gpuCount})}),(0,r.jsx)(m.pj,{children:-1===e.clusterCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(o.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/clusters?property=user&operator=%3A&value=".concat(encodeURIComponent(e.username)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.usernameDisplay),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:-1===e.jobCount?(0,r.jsxs)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-400 rounded text-xs font-medium flex items-center",children:[(0,r.jsx)(o.Z,{size:10,className:"mr-1"}),"Loading..."]}):(0,r.jsx)(c(),{href:"/jobs?property=user&operator=%3A&value=".concat(encodeURIComponent(e.username)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.usernameDisplay),children:e.jobCount})}),!_&&(b||"admin"===w)&&(0,r.jsx)(m.pj,{className:"relative",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[b&&(0,r.jsx)("button",{onClick:"admin"===w||e.userId===N?async()=>{u(e)}:void 0,className:"admin"===w||e.userId===N?"text-blue-600 hover:text-blue-700 p-1":"text-gray-300 cursor-not-allowed p-1",title:"admin"===w||e.userId===N?"Reset Password":"You can only reset your own password",disabled:"admin"!==w&&e.userId!==N,children:(0,r.jsx)(I,{className:"h-4 w-4"})}),"admin"===w&&(0,r.jsx)("button",{onClick:()=>d(e),className:"text-red-600 hover:text-red-700 p-1",title:"Delete User",children:(0,r.jsx)(T.Z,{className:"h-4 w-4"})})]})})]},e.userId))})]})})}):(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-500",children:k.length>0?"No users match your filters.":"No users found."}),(0,r.jsx)("p",{className:"text-sm text-gray-400 mt-1",children:k.length>0?"Try adjusting your filter criteria.":"There are currently no users to display."})]}):(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading users..."})]})}function X(e){let{checkPermissionAndAct:t,userRoleCache:s,setCreateSuccess:a,setCreateError:l,showCreateDialog:i,setShowCreateDialog:u,showRotateDialog:d,setShowRotateDialog:x,tokenToRotate:g,setTokenToRotate:b,rotating:j,setRotating:v,searchQuery:w,setSearchQuery:k}=e,[C,_]=(0,n.useState)([]),[S,U]=(0,n.useState)(!0),[A,O]=(0,n.useState)(!1),[M,z]=(0,n.useState)(null),[V,G]=(0,n.useState)(null),[J,K]=(0,n.useState)({token_name:"",expires_in_days:30}),[$,H]=(0,n.useState)(""),[W,X]=(0,n.useState)(!1),[Q,Y]=(0,n.useState)(!1),[ee,et]=(0,n.useState)(""),[es,er]=(0,n.useState)(null),[en,ea]=(0,n.useState)(null),[el,eo]=(0,n.useState)(null),[ei,ec]=(0,n.useState)(""),[eu,ed]=(0,n.useState)([]),em=async()=>{try{U(!0);let e=await Z.x.get("/users/service-account-tokens");if(!e.ok){console.error("Failed to fetch tokens"),_([]),ed([]);return}let t=await e.json();_(t||[]);let s=[],r={jobs:[]};try{[s,r]=await Promise.all([f.default.get(h.getClusters),f.default.get(p.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["user_hash","status","accelerators","job_id","infra"]}])])}catch(e){console.error("Error fetching clusters and managed jobs:",e)}let n=s||[],a=(null==r?void 0:r.jobs)||[],l=(t||[]).map(e=>{let t=e.service_account_user_id,s=0,r=0,l=0,o=0;for(let e of n)e.user_hash===t&&(s++,"STOPPED"!==e.status&&"TERMINATED"!==e.status&&(r+=B(e.gpus,"Cluster ".concat(e.cluster))));for(let e of a)e.user_hash===t&&q.has(e.status)&&(l++,o+=B(e.accelerators,"Job ".concat(e.job_name||e.job_id)));return{...e,clusterCount:s,jobCount:l,gpuCount:r+o,primaryRole:e.service_account_roles&&e.service_account_roles.length>0?e.service_account_roles[0]:"user"}});ed(l)}catch(e){console.error("Error fetching tokens and counts:",e),_([]),ed([])}finally{U(!1)}};(0,n.useEffect)(()=>{em()},[]);let ex=async(e,s)=>{await t("cannot edit service account role",()=>{eo(e),ec(s)})},eh=()=>{eo(null),ec("")},ep=async e=>{if(!e||!ei){console.error("Token ID or role is missing."),l(Error("Token ID or role is missing."));return}U(!0);try{let t=await Z.x.post("/users/service-account-tokens/update-role",{token_id:e,role:ei});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to update role")}a("Service account role updated successfully!"),await em(),eh()}catch(e){console.error("Failed to update service account role:",e),l(e)}finally{U(!1)}},ef=async e=>{try{await navigator.clipboard.writeText(e),et("Copied!"),setTimeout(()=>et(""),2e3)}catch(e){console.error("Failed to copy:",e)}},eg=async()=>{if(!J.token_name.trim()){l(Error("Token name is required"));return}X(!0);try{let e={token_name:J.token_name.trim(),expires_in_days:""===J.expires_in_days?null:J.expires_in_days},t=await Z.x.post("/users/service-account-tokens",e);if(t.ok){let e=await t.json();er(e.token),K({token_name:"",expires_in_days:30}),await em()}else{let e=await t.json();throw Error(e.detail||"Failed to create token")}}catch(e){l(e)}finally{X(!1)}},eb=async()=>{if(M){Y(!0),G(null);try{let e=await Z.x.post("/users/service-account-tokens/delete",{token_id:M.token_id});if(e.ok)a('Service account "'.concat(M.token_name,'" deleted successfully!')),O(!1),z(null),G(null),await em();else{let t=await e.json();throw Error(t.detail||"Failed to delete service account")}}catch(e){O(!1),z(null),G(null),l(e)}finally{Y(!1)}}},ej=async()=>{if(g){v(!0);try{let e={token_id:g.token_id,expires_in_days:""===$?null:parseInt($)},t=await Z.x.post("/users/service-account-tokens/rotate",e);if(t.ok){let e=await t.json();ea(e.token),await em()}else{let e=await t.json();throw Error(e.detail||"Failed to rotate token")}}catch(e){l(e)}finally{v(!1)}}},ey=eu.filter(e=>{var t,s,r,n;if(!(null==w?void 0:w.trim()))return!0;let a=w.toLowerCase();return(null===(t=e.token_name)||void 0===t?void 0:t.toLowerCase().includes(a))||(null===(s=e.creator_name)||void 0===s?void 0:s.toLowerCase().includes(a))||(null===(r=e.service_account_name)||void 0===r?void 0:r.toLowerCase().includes(a))||(null===(n=e.primaryRole)||void 0===n?void 0:n.toLowerCase().includes(a))});return S&&0===eu.length?(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,r.jsx)(o.Z,{size:32}),(0,r.jsx)("span",{className:"ml-3",children:"Loading tokens..."})]}):(0,r.jsxs)(r.Fragment,{children:[0===ey.length?(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)(I,{className:"mx-auto h-12 w-12 text-gray-400"}),(0,r.jsx)("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:(null==w?void 0:w.trim())?"No tokens match your search":"No service accounts"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:(null==w?void 0:w.trim())?"Try adjusting your search terms.":"No service accounts have been created yet."})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(F.Zb,{children:(0,r.jsxs)(m.iA,{children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.ss,{children:"Name"}),(0,r.jsx)(m.ss,{children:"Created by"}),(0,r.jsx)(m.ss,{children:"Role"}),(0,r.jsx)(m.ss,{children:"Clusters"}),(0,r.jsx)(m.ss,{children:"Jobs"}),(0,r.jsx)(m.ss,{children:"GPUs"}),(0,r.jsx)(m.ss,{children:"Created"}),(0,r.jsx)(m.ss,{children:"Last used"}),(0,r.jsx)(m.ss,{children:"Expires"}),(0,r.jsx)(m.ss,{children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:ey.map(e=>(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.token_name,children:e.token_name}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{children:e.creator_name||"Unknown"}),e.creator_user_hash!==(null==s?void 0:s.id)&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded",children:"Other"})]})}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:el===e.token_id?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:ei,onChange:e=>ec(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>ep(e.token_id),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:eh,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.primaryRole}),((null==s?void 0:s.role)==="admin"||e.creator_user_hash===(null==s?void 0:s.id))&&(0,r.jsx)("button",{onClick:()=>ex(e.token_id,e.primaryRole),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/clusters?property=user&operator=%3A&value=".concat(encodeURIComponent(e.service_account_name)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.token_name),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/jobs?property=user&operator=%3A&value=".concat(encodeURIComponent(e.service_account_name)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.token_name),children:e.jobCount})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(e.gpuCount>0?"bg-purple-100 text-purple-600":"bg-gray-100 text-gray-500"),title:"Total GPUs: ".concat(e.gpuCount),children:e.gpuCount})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.created_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.last_used_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.last_used_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.expires_at?new Date(1e3*e.expires_at)<new Date?(0,r.jsx)("span",{className:"text-red-600",children:"Expired"}):(0,r.jsx)(y.Zg,{date:new Date(1e3*e.expires_at)}):"Never"}),(0,r.jsx)(m.pj,{children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[((null==s?void 0:s.role)==="admin"||e.creator_user_hash===(null==s?void 0:s.id))&&(0,r.jsx)(y.WH,{content:"Rotate token",className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{t("cannot rotate service account tokens",()=>{b(e),x(!0)})},className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:(0,r.jsx)(N.Z,{className:"h-4 w-4"})})}),((null==s?void 0:s.role)==="admin"||e.creator_user_hash===(null==s?void 0:s.id))&&(0,r.jsx)(y.WH,{content:"Delete ".concat(e.token_name),className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{t("cannot delete service account tokens",()=>{z(e),O(!0)})},className:"text-red-600 hover:text-red-800 font-medium inline-flex items-center",children:(0,r.jsx)(T.Z,{className:"h-4 w-4"})})})]})})]},e.token_id))})]})})}),(0,r.jsx)(P.Vq,{open:i,onOpenChange:e=>{u(e),e||(er(null),l(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Create Service Account"}),(0,r.jsx)(P.Be,{children:"Create a new service account with an API token for programmatic access to SkyPilot."})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:es?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"⚠️ Service account created successfully - save this token now!"}),(0,r.jsx)(y.WH,{content:ee?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>ef(es),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:ee?(0,r.jsx)(E.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This service account token will not be shown again. Please copy and store it securely."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:es})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Service Account Name"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"e.g., ci-pipeline, monitoring-system",value:J.token_name,onChange:e=>K({...J,token_name:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"e.g., 30",min:"0",max:"365",value:J.expires_in_days||"",onChange:e=>K({...J,expires_in_days:e.target.value?parseInt(e.target.value):null})}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty or enter 0 to never expire. Maximum 365 days."})]})]})}),(0,r.jsx)(P.cN,{children:es?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:()=>{u(!1),er(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{u(!1),er(null)},disabled:W,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eg,disabled:W||!J.token_name.trim(),children:W?"Creating...":"Create Token"})]})})]})}),(0,r.jsx)(P.Vq,{open:A,onOpenChange:e=>{O(e),e||(z(null),l(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Delete Service Account Token"}),(0,r.jsxs)(P.Be,{children:['Are you sure you want to delete the service account "',null==M?void 0:M.token_name,'"',(null==M?void 0:M.creator_user_hash)!==(null==s?void 0:s.id)&&(null==s?void 0:s.role)==="admin"?" owned by ".concat(null==M?void 0:M.creator_name):"","? This action cannot be undone and will immediately revoke access for any systems using this token."]})]}),(0,r.jsxs)(P.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{O(!1),z(null)},disabled:Q,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-red-600 text-white hover:bg-red-700 h-10 px-4 py-2",onClick:eb,disabled:Q,children:Q?"Deleting...":"Delete Token"})]})]})}),(0,r.jsx)(P.Vq,{open:d,onOpenChange:e=>{x(e),e||(b(null),H(""),ea(null),l(null))},children:(0,r.jsxs)(P.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(P.fK,{children:[(0,r.jsx)(P.$N,{children:"Rotate Service Account Token"}),(0,r.jsxs)(P.Be,{children:['Rotate the service account token "',null==g?void 0:g.token_name,'"',(null==g?void 0:g.creator_user_hash)!==(null==s?void 0:s.id)&&(null==s?void 0:s.role)==="admin"?" owned by ".concat(null==g?void 0:g.creator_name):"",". This will generate a new token value and invalidate the current one."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:en?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"\uD83D\uDD04 Service account token rotated successfully - save this new token now!"}),(0,r.jsx)(y.WH,{content:ee?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>ef(en),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:ee?(0,r.jsx)(E.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This new token replaces the old one. Please copy and store it securely. The old token is now invalid."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:en})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"Leave empty to preserve current expiration",min:"0",max:"365",value:$,onChange:e=>H(e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty to preserve current expiration. Enter number of days for new expiration, or enter 0 to set to never expire. Maximum 365 days."})]}),(0,r.jsx)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ Any systems using the current token will need to be updated with the new token."})})]})}),(0,r.jsx)(P.cN,{children:en?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-green-600 text-white hover:bg-green-700 h-10 px-4 py-2",onClick:()=>{x(!1),b(null),H(""),ea(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{x(!1),b(null),H(""),ea(null)},disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:ej,disabled:j,children:j?"Rotating...":"Rotate Token"})]})})]})})]})}W.propTypes={refreshInterval:l().number.isRequired,setLoading:l().func.isRequired,refreshDataRef:l().shape({current:l().func}).isRequired,checkPermissionAndAct:l().func.isRequired,roleLoading:l().bool.isRequired,onResetPassword:l().func.isRequired,onDeleteUser:l().func.isRequired,basicAuthEnabled:l().bool,ingressBasicAuthEnabled:l().bool,currentUserRole:l().string,currentUserId:l().string}},12003:function(e,t,s){s.d(t,{j:function(){return l}});var r=s(90512);let n=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=r.W,l=(e,t)=>s=>{var r;if((null==t?void 0:t.variants)==null)return a(e,null==s?void 0:s.class,null==s?void 0:s.className);let{variants:l,defaultVariants:o}=t,i=Object.keys(l).map(e=>{let t=null==s?void 0:s[e],r=null==o?void 0:o[e];if(null===t)return null;let a=n(t)||n(r);return l[e][a]}),c=s&&Object.entries(s).reduce((e,t)=>{let[s,r]=t;return void 0===r||(e[s]=r),e},{});return a(e,i,null==t?void 0:null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:s,className:r,...n}=t;return Object.entries(n).every(e=>{let[t,s]=e;return Array.isArray(s)?s.includes({...o,...c}[t]):({...o,...c})[t]===s})?[...e,s,r]:e},[]),null==s?void 0:s.class,null==s?void 0:s.className)}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3294],{53294:function(e,s,t){t.r(s),t.d(s,{ContextDetails:function(){return A},GPUs:function(){return H},InfrastructureSection:function(){return E}});var a=t(85893),l=t(67294),r=t(55739);t(9353);var n=t(26409),o=t(98418),i=t(13626),c=t(23001),d=t(17853),m=t(32045),u=t(23266),h=t(68969),x=t(29326),g=t(50326),p=t(30803),f=t(42557),y=t(36185),j=t(69123);function b(e){let{isOpen:s,onClose:t,onSave:n,poolData:o=null,isLoading:i=!1}=e,[c,d]=(0,l.useState)(""),[m,u]=(0,l.useState)(""),[h,b]=(0,l.useState)("ubuntu"),[N,v]=(0,l.useState)(null),[w,S]=(0,l.useState)(""),[C,k]=(0,l.useState)({}),_=null!==o;(0,l.useEffect)(()=>{if(_&&o){var e,s,t;d(o.name||""),u(((null===(e=o.config)||void 0===e?void 0:e.hosts)||[]).join("\n")),b((null===(s=o.config)||void 0===s?void 0:s.user)||"ubuntu"),S((null===(t=o.config)||void 0===t?void 0:t.password)||"")}else d(""),u(""),b("ubuntu"),v(null),S("");k({})},[_,o]);let P=()=>{let e={};return c.trim()||(e.poolName="Pool name is required"),m.trim()||(e.hosts="At least one host is required"),h.trim()||(e.sshUser="SSH user is required"),N||w||(e.auth="Either SSH key file or password is required"),k(e),0===Object.keys(e).length},U=async()=>{if(!P())return;let e={hosts:m.split("\n").map(e=>e.trim()).filter(e=>e.length>0),user:h};try{if(N){let s=N.name;await (0,x.hY)(s,N),e.identity_file="~/.sky/ssh_keys/".concat(s)}w&&(e.password=w),n(c,e)}catch(e){console.error("Failed to upload SSH key:",e),k({...C,keyUpload:"Failed to upload SSH key"})}},D=()=>{i||t()};return(0,a.jsx)(g.Vq,{open:s,onOpenChange:D,children:(0,a.jsxs)(g.cZ,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,a.jsx)(g.fK,{children:(0,a.jsx)(g.$N,{children:_?"Edit SSH Node Pool: ".concat(null==o?void 0:o.name):"Add SSH Node Pool"})}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"poolName",children:"Pool Name"}),(0,a.jsx)(f.I,{id:"poolName",placeholder:"my-ssh-cluster",value:c,onChange:e=>d(e.target.value),disabled:_,className:"placeholder:text-gray-500 ".concat(C.poolName?"border-red-500":"")}),C.poolName&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:C.poolName})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"hosts",children:"Hosts (one per line)"}),(0,a.jsx)(j.g,{id:"hosts",placeholder:"192.168.1.10\n192.168.1.11\nhostname.example.com",value:m,onChange:e=>u(e.target.value),rows:6,className:"placeholder:text-gray-500 ".concat(C.hosts?"border-red-500":"")}),C.hosts&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:C.hosts})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"sshUser",children:"SSH User"}),(0,a.jsx)(f.I,{id:"sshUser",placeholder:"ubuntu",value:h,onChange:e=>b(e.target.value),className:"placeholder:text-gray-500 ".concat(C.sshUser?"border-red-500":"")}),C.sshUser&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:C.sshUser})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"keyFile",children:"SSH Private Key File"}),(0,a.jsx)(f.I,{id:"keyFile",type:"file",accept:".pem,.key,id_rsa,id_ed25519",onChange:e=>{var s;return v((null===(s=e.target.files)||void 0===s?void 0:s[0])||null)},className:"border-0 bg-transparent p-0 shadow-none focus:ring-0 file:mr-2 file:text-sm file:py-1 file:px-3 file:border file:border-gray-300 file:rounded file:bg-gray-50 hover:file:bg-gray-100 file:cursor-pointer"}),C.keyUpload&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:C.keyUpload})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y._,{htmlFor:"password",children:"Password (optional, if sudo requires a password)"}),(0,a.jsx)(f.I,{id:"password",type:"password",placeholder:"Leave empty if using passwordless sudo",value:w,onChange:e=>S(e.target.value),className:"placeholder:text-gray-500"})]}),C.auth&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:C.auth})]}),(0,a.jsxs)(g.cN,{children:[(0,a.jsx)(p.z,{variant:"outline",onClick:D,disabled:i,children:"Cancel"}),(0,a.jsx)(p.z,{onClick:U,disabled:i,className:"bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:i?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"Saving..."]}):_?"Update Pool":"Create Pool"})]})]})})}var N=t(6378),v=t(36856),w=t(51214),S=t(11163),C=t(41664),k=t.n(C),_=t(36989);t(37673);var P=t(88950);let U=w.nb.REFRESH_INTERVAL,D=w.MO.NAME_TRUNCATE_LENGTH,I=e=>{let{gpu:s,heightClass:t="h-4",wrapperClassName:l=""}=e,r=(null==s?void 0:s.gpu_total)||0,n=(null==s?void 0:s.gpu_not_ready)||0,o=(null==s?void 0:s.gpu_free)||0,i=Math.max(0,r-o-n),c="".concat(n," not ready"),d="".concat(i," used"),m="".concat(o," free"),u=r>0?e=>e/r*100:()=>0,h=u(n),x=u(i),g=u(o);return(0,a.jsxs)("div",{className:"bg-gray-100 rounded-md flex overflow-hidden shadow-sm ".concat(t," ").concat(l).trim(),children:[h>0&&(0,a.jsx)("div",{style:{width:"".concat(h,"%"),fontSize:"clamp(8px, 1.2vw, 12px)"},title:c,className:"bg-gray-400 h-full flex items-center justify-center text-white font-medium overflow-hidden whitespace-nowrap px-1",children:h>15&&c}),x>0&&(0,a.jsx)("div",{style:{width:"".concat(x,"%"),fontSize:"clamp(8px, 1.2vw, 12px)"},title:d,className:"bg-yellow-500 h-full flex items-center justify-center text-white font-medium overflow-hidden whitespace-nowrap px-1",children:x>15&&d}),g>0&&(0,a.jsx)("div",{style:{width:"".concat(g,"%"),fontSize:"clamp(8px, 1.2vw, 12px)"},title:m,className:"bg-green-700 h-full flex items-center justify-center text-white font-medium overflow-hidden whitespace-nowrap px-1",children:g>15&&m})]})};function E(e){let{title:s,isLoading:t,isDataLoaded:l,contexts:n,gpus:o,groupedPerContextGPUs:i,groupedPerNodeGPUs:c,handleContextClick:d,contextStats:m={},jobsData:u={},isJobsDataLoading:h=!0,isSSH:x=!1,isSlurm:g=!1,actionButton:p=null,contextWorkspaceMap:f={},contextErrors:y={}}=e,j=n||[];return t&&0===j.length?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:s}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(r.Z,{size:24,className:"mr-3"}),(0,a.jsxs)("span",{className:"text-gray-500",children:["Loading ",s,"..."]})]})]})}):l&&0===j.length?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:s}),p]}),(0,a.jsxs)("p",{className:"text-sm text-gray-500",children:["No ",s," found or ",s," is not configured."]})]})}):j.length>0?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:s}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[j.length," ",1===j.length?x?"pool":g?"cluster":"context":x?"pools":g?"clusters":"contexts"]})]}),p]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"Name"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Jobs"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Nodes"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"GPU Types"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"#GPUs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(j.length>5?"max-h-[250px] overflow-y-auto block":""),children:j.map(e=>{var s,t;let n=i[e]||[],o=c[e]||[],g=n.reduce((e,s)=>e+(s.gpu_total||0),0),p=x?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e),j=m[p]||{clusters:0,jobs:0},b=Object.keys(m).length>0&&m[p]||l,N=i&&Object.keys(i).length>0||l,v=c&&Object.keys(c).length>0||l,w=N?Object.keys(n.reduce((e,s)=>(e[s.gpu_name]=(e[s.gpu_name]||0)+(s.gpu_total||0),e),{})).join(", "):null,S=x?e.replace(/^ssh-/,""):e,C=f[e]||[],k=C.length>1?" (workspaces: ".concat(C.join(", "),")"):"";return(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3",children:(0,a.jsx)(_.Md,{content:"".concat(S).concat(k),className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{className:"text-blue-600 hover:underline cursor-pointer",onClick:()=>d(e),children:[S.length>D?"".concat(S.substring(0,Math.floor((D-3)/2)),"...").concat(S.substring(S.length-Math.ceil((D-3)/2))):S,k&&(0,a.jsx)("span",{className:"text-xs text-gray-500 ml-1",children:k})]})})}),(0,a.jsx)("td",{className:"p-3",children:b?j.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:j.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:12})})}),(0,a.jsx)("td",{className:"p-3",children:h?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:(0,a.jsx)(r.Z,{size:12})}):(null===(s=u[p])||void 0===s?void 0:s.jobs)?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:null===(t=u[p])||void 0===t?void 0:t.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:v?(0,a.jsx)("span",{className:0===o.length&&y[e]?"text-gray-400":"",title:0===o.length&&y[e]?y[e]:"",children:0===o.length&&y[e]?"0*":o.length}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})}),(0,a.jsx)("td",{className:"p-3",children:N?w||"-":(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})}),(0,a.jsx)("td",{className:"p-3",children:N?g:(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})})]},e)})})]})})}),o&&o.length>0&&(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsxs)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4 whitespace-nowrap",children:["GPU",(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-green-100 text-green-800 rounded-full text-xs font-medium whitespace-nowrap",children:[o.reduce((e,s)=>e+s.gpu_free,0)," ","of"," ",o.reduce((e,s)=>e+s.gpu_total,0)," ","free"]})]}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"Requestable"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/2",children:(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)("span",{children:"Utilization"})})})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(o.length>5?"max-h-[250px] overflow-y-auto block":""),children:o.map(e=>{let s=i?Object.values(i).flat().filter(s=>{if(s.gpu_name!==e.gpu_name)return!1;if(g)return!0;let t=s.context||s.cluster;return!!t&&(x?t.startsWith("ssh-"):!t.startsWith("ssh-"))}).map(e=>e.gpu_requestable_qty_per_node).filter((e,s,t)=>t.indexOf(e)===s).join(", "):"-";return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"p-3 font-medium w-24 whitespace-nowrap",children:e.gpu_name}),(0,a.jsxs)("td",{className:"p-3 text-xs text-gray-600",children:[s||"-"," / node"]}),(0,a.jsx)("td",{className:"p-3 w-2/3",children:(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsx)(I,{gpu:e,heightClass:"h-5",wrapperClassName:"flex-1 min-w-[100px] w-full"})})})]},e.gpu_name)})})]})})})]})]})}):null}function A(e){let{contextName:s,gpusInContext:t,nodesInContext:n}=e,o=s.startsWith("ssh-"),[i,c]=(0,l.useState)([]),[m,u]=(0,l.useState)("$__all"),[h,x]=(0,l.useState)({from:"now-1h",to:"now"}),[g,p]=(0,l.useState)(!1),[f,y]=(0,l.useState)(!1);(0,l.useEffect)(()=>{(async()=>{y(await (0,d.TO)())})()},[]);let j=(0,l.useCallback)(async()=>{if(f){p(!0);try{let e=(0,d.ki)(),t="in-cluster"===s?"^$":s,a="query="+encodeURIComponent('group by (node) (DCGM_FI_DEV_GPU_TEMP{cluster=~"'.concat(t,'"} or label_replace(amd_gpu_gfx_activity{cluster=~"').concat(t,'"}, "node", "$1", "hostname", "(.*)"))')),l="/api/datasources/proxy/1/api/v1/query?".concat(a);try{let s=await fetch("".concat(e).concat(l),{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(s.ok){let e=await s.json();if(e.data&&e.data.result&&e.data.result.length>0){let s=e.data.result.map(e=>e.metric.node).filter(Boolean).sort();c(s),console.log("Successfully fetched hosts for cluster ".concat(t||"in-cluster",":"),s)}else console.log("No nodes found for this cluster"),c([])}else console.log("HTTP ".concat(s.status," from ").concat(l,": ").concat(s.statusText)),c([])}catch(e){console.log("Failed to fetch from ".concat(l,":"),e),c([])}}catch(e){console.error("Error fetching available hosts:",e),c([])}finally{p(!1)}}},[f,s]);(0,l.useEffect)(()=>{f&&n&&n.length>0&&j()},[n,f,j]);let b=e=>{let t=(0,d.ki)(),a="in-cluster"===s?"^$":s;return"".concat(t,"/d-solo/skypilot-dcgm-cluster-dashboard/skypilot-dcgm-kubernetes-cluster-dashboard?orgId=1&timezone=browser&var-datasource=prometheus&var-host=").concat(encodeURIComponent(m),"&var-gpu=$__all&var-cluster=").concat(encodeURIComponent(a),"&refresh=5s&theme=light&from=").concat(encodeURIComponent(h.from),"&to=").concat(encodeURIComponent(h.to),"&panelId=").concat(e,"&__feature.dashboardSceneSolo")},N=e=>{x({"15m":{from:"now-15m",to:"now"},"1h":{from:"now-1h",to:"now"},"6h":{from:"now-6h",to:"now"},"24h":{from:"now-24h",to:"now"},"7d":{from:"now-7d",to:"now"}}[e])};return(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm h-full",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsx)("h4",{className:"text-lg font-semibold",children:"Available GPUs"})}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-6",children:t.map(e=>(0,a.jsxs)("div",{className:"p-3 bg-gray-50 rounded-md border border-gray-200 shadow-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-1.5 flex-wrap",children:[(0,a.jsxs)("div",{className:"font-medium text-gray-800 text-sm",children:[e.gpu_name,(0,a.jsxs)("span",{className:"text-xs text-gray-500 ml-2",children:["(Requestable: ",e.gpu_requestable_qty_per_node," / node)"]})]}),(0,a.jsxs)("span",{className:"text-xs font-medium",children:[e.gpu_free," free / ",e.gpu_total," total"]})]}),(0,a.jsx)("div",{className:"w-full",children:(0,a.jsx)(I,{gpu:e,heightClass:"h-4",wrapperClassName:"w-full"})})]},e.gpu_name))}),n&&n.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4",children:"Nodes"}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-100",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"Node"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"IP Address"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"GPU"}),(0,a.jsx)("th",{className:"p-3 text-right font-medium text-gray-600",children:"Availability"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:n.map((e,s)=>(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.node_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.ip_address||"-"}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.gpu_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-right text-gray-700",children:!1===e.is_ready?"0 of ".concat(e.gpu_total," free (Node NotReady)"):"".concat(e.gpu_free," of ").concat(e.gpu_total," free")})]},"".concat(e.node_name,"-").concat(s)))})]})})]}),f&&t&&t.length>0&&!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4 mt-6",children:"GPU Metrics"}),(0,a.jsxs)("div",{className:"mb-4 p-4 bg-gray-50 rounded-md border border-gray-200",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:[n&&n.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{htmlFor:"host-select",className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Node:"}),(0,a.jsxs)("select",{id:"host-select",value:m,onChange:e=>{u(e.target.value)},disabled:g,className:"px-3 py-1 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-sky-blue focus:border-transparent",children:[(0,a.jsx)("option",{value:"$__all",children:"All Nodes"}),i.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]}),g&&(0,a.jsx)("div",{className:"ml-2",children:(0,a.jsx)(r.Z,{size:16})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Time Range:"}),(0,a.jsx)("div",{className:"flex gap-1",children:[{label:"15m",value:"15m"},{label:"1h",value:"1h"},{label:"6h",value:"6h"},{label:"24h",value:"24h"},{label:"7d",value:"7d"}].map(e=>(0,a.jsx)("button",{onClick:()=>N(e.value),className:"px-2 py-1 text-xs font-medium rounded border transition-colors ".concat(h.from==="now-".concat(e.value)&&"now"===h.to?"bg-sky-blue text-white border-sky-blue":"bg-white text-gray-600 border-gray-300 hover:bg-gray-50"),children:e.label},e.value))})]})]}),(0,a.jsx)("div",{className:"mt-2 text-xs text-gray-500",children:n&&n.length>0?(0,a.jsxs)(a.Fragment,{children:["Showing:"," ","$__all"===m?"All nodes":m," ","• Time: ",h.from," to ",h.to,i.length>0&&(0,a.jsxs)("span",{children:[" ","• ",i.length," nodes available"]})]}):(0,a.jsxs)(a.Fragment,{children:["Cluster:"," ",o?s.replace(/^ssh-/,""):s," ","• Time: ",h.from," to ",h.to," • Showing metrics for all nodes in cluster"]})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("6"),width:"100%",height:"400",frameBorder:"0",title:"GPU Utilization",className:"rounded"},"gpu-util-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("18"),width:"100%",height:"400",frameBorder:"0",title:"GPU Memory",className:"rounded"},"gpu-memory-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("10"),width:"100%",height:"400",frameBorder:"0",title:"GPU Power Consumption",className:"rounded"},"gpu-power-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("12"),width:"100%",height:"400",frameBorder:"0",title:"GPU Temperature",className:"rounded"},"gpu-temp-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("22"),width:"100%",height:"400",frameBorder:"0",title:"CPU Utilization",className:"rounded"},"cpu-util-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:b("21"),width:"100%",height:"400",frameBorder:"0",title:"Memory Utilization",className:"rounded"},"memory-util-".concat(m,"-").concat(h.from,"-").concat(h.to))})})]})]})]})})})}function F(e){var s;let{poolName:t,gpusInContext:i,nodesInContext:c,handleDeploySSHPool:d,handleEditSSHPool:m,handleDeleteSSHPool:u,poolConfig:h}=e,[f,y]=(0,l.useState)(null),[j,b]=(0,l.useState)(!0),[N,v]=(0,l.useState)({isOpen:!1,action:null,loading:!1}),[w,S]=(0,l.useState)({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});(0,l.useEffect)(()=>{(async()=>{try{b(!0);let e=await (0,x.IS)(t);y(e)}catch(e){console.error("Failed to fetch SSH Node Pool status:",e),y({pool_name:t,status:"Error",reason:"Failed to fetch status"})}finally{b(!1)}})()},[t]);let{deployDisabled:C}=(()=>{if(!f)return{deployDisabled:!0};let e=f.status;return"Ready"===e?{deployDisabled:!0}:"Error"===e?{deployDisabled:!0}:{deployDisabled:!1}})(),k=async()=>{v({...N,loading:!0});try{if("deploy"===N.action){v({isOpen:!1,action:null,loading:!1}),S({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await d(t)).request_id;S(s=>({...s,requestId:e}));let s=new AbortController;await (0,x.wJ)({requestId:e,signal:s.signal,onNewLog:e=>{S(s=>({...s,logs:s.logs+e}))}}),S(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0})),setTimeout(async()=>{(async()=>{try{let e=await (0,x.IS)(t);y(e)}catch(e){console.error("Failed to fetch SSH Node Pool status after deployment:",e)}})()},1e3)}catch(e){console.error("Deployment failed:",e),S(s=>({...s,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:s.logs+"\nDeployment failed: ".concat(e.message)}))}}else if("delete"===N.action){v({isOpen:!1,action:null,loading:!1}),S({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await (0,x.ez)(t)).request_id;S(s=>({...s,requestId:e})),e&&await (0,x.mF)({requestId:e,signal:null,onNewLog:e=>{S(s=>({...s,logs:s.logs+e}))},operationType:"down"}),await u(t),S(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0,logs:e.logs+"\nSSH Node Pool teardown completed successfully."}))}catch(e){console.error("Down operation failed:",e),S(s=>({...s,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:s.logs+"\nTeardown failed: ".concat(e.message)}))}}}catch(e){console.error("Action failed:",e),v({...N,loading:!1})}},_=()=>{v({isOpen:!1,action:null,loading:!1})},P=()=>{S({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null}),w.deploymentComplete&&setTimeout(()=>{(async()=>{try{let e=await (0,x.IS)(t);y(e)}catch(e){console.error("Failed to refresh status:",e)}})()},1e3)},U="deploy"===N.action?{title:"Deploy SSH Node Pool",description:'Are you sure you want to deploy SSH Node Pool "'.concat(t,'"?'),details:["• Set up SkyPilot runtime on the configured SSH hosts","• Install required components and dependencies","• Make the node pool available for workloads","","This process may take a few minutes to complete."]}:{title:"Delete SSH Node Pool",description:'Are you sure you want to delete SSH Node Pool "'.concat(t,'"?'),details:["• Clean up any deployed resources","• Remove the SSH Node Pool configuration"]};return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsxs)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"SSH Node Pool Details"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border rounded flex items-center ".concat(C?"border-gray-300 bg-gray-100 text-gray-400 cursor-not-allowed":"border-green-300 bg-green-50 text-green-700 hover:bg-green-100"),onClick:C?void 0:()=>{v({isOpen:!0,action:"deploy",loading:!1})},disabled:C,children:[(0,a.jsx)(n.Z,{className:"w-4 h-4 mr-2"}),"Deploy"]}),(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border border-gray-300 rounded hover:bg-gray-50 flex items-center text-red-600 hover:text-red-700",onClick:()=>{v({isOpen:!0,action:"delete",loading:!1})},children:[(0,a.jsx)(o.Z,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]}),(0,a.jsx)("div",{className:"p-4",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Pool Name"}),(0,a.jsx)("div",{className:"text-base mt-1",children:t})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Nodes"}),(0,a.jsx)("div",{className:"text-base mt-1",children:c?c.length:0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,a.jsx)("div",{className:"text-base mt-1",children:j?(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."})]}):f?(0,a.jsx)(e=>{let{status:s,reason:t}=e,l="Ready"===s,r="Not Ready"===s?"Click Deploy to set up this node pool":t;return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(l?"bg-green-100":"bg-red-100"," ").concat(l?"text-green-800":"text-red-800"),children:s}),!l&&r&&(0,a.jsxs)("span",{className:"text-sm text-gray-600",children:["(",r,")"]})]})},{status:f.status,reason:f.reason}):(0,a.jsx)("span",{className:"text-gray-500",children:"Unknown"})})]})]})})]})}),(0,a.jsx)(A,{contextName:"ssh-".concat(t),gpusInContext:i,nodesInContext:c}),(0,a.jsx)(g.Vq,{open:N.isOpen,onOpenChange:_,children:(0,a.jsxs)(g.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(g.fK,{className:"",children:[(0,a.jsx)(g.$N,{className:"",children:U.title}),(0,a.jsx)(g.Be,{className:"",children:U.description})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"text-sm text-gray-600 space-y-1",children:[(0,a.jsx)("p",{className:"font-medium mb-2",children:"This will:"}),U.details.map((e,s)=>(0,a.jsx)("p",{className:""===e?"pt-2":"",children:e},s))]})}),(0,a.jsxs)(g.cN,{className:"",children:[(0,a.jsx)(p.z,{variant:"outline",onClick:_,disabled:N.loading,className:"",children:"Cancel"}),(0,a.jsx)(p.z,{onClick:k,disabled:N.loading,className:"deploy"===N.action?"bg-green-600 hover:bg-green-700 text-white":"bg-red-600 hover:bg-red-700 text-white",children:N.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"deploy"===N.action?"Deploying...":"Deleting..."]}):"deploy"===N.action?"Deploy":"Delete"})]})]})}),(0,a.jsx)(g.Vq,{open:w.isOpen,onOpenChange:w.isStreaming?void 0:P,children:(0,a.jsxs)(g.cZ,{className:"sm:max-w-4xl max-h-[80vh]",children:[(0,a.jsxs)(g.fK,{className:"",children:[(0,a.jsxs)(g.$N,{className:"",children:["Deploying SSH Node Pool: ",t]}),(0,a.jsx)(g.Be,{className:"",children:w.isStreaming?"Deployment in progress. Do not close this dialog.":w.deploymentSuccess?"Deployment completed successfully!":"Deployment completed with errors."})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm max-h-96 overflow-y-auto",children:[(0,a.jsx)("pre",{className:"whitespace-pre-wrap",children:(s=w.logs)?s.split("\n").map(e=>(e=e.replace(/\x1b\[[0-9;]*m/g,"")).match(/^D \d{2}-\d{2} \d{2}:\d{2}:\d{2}/)?null:e=(e=e.replace(/├──/g,"├─")).replace(/└──/g,"└─")).filter(e=>null!==e&&""!==e.trim()).join("\n"):""}),w.isStreaming&&(0,a.jsxs)("div",{className:"flex items-center mt-2",children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2 text-green-400"}),(0,a.jsx)("span",{className:"text-green-400",children:"Streaming logs..."})]})]})}),(0,a.jsx)(g.cN,{className:"",children:(0,a.jsx)(p.z,{onClick:P,disabled:w.isStreaming,className:w.deploymentSuccess?"bg-green-600 hover:bg-green-700 text-white":w.deploymentComplete&&!w.deploymentSuccess?"bg-red-600 hover:bg-red-700 text-white":"bg-gray-600 hover:bg-gray-700 text-white",children:w.isStreaming?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"Deploying..."]}):"Close"})})]})})]})}function H(){let[e,s]=(0,l.useState)(!0),[t,n]=(0,l.useState)(!0),[o,d]=(0,l.useState)(!0),g=l.useRef(null),p=(0,c.X)(),[f,y]=(0,l.useState)(!1),[j,w]=(0,l.useState)(!1),C=(0,S.useRouter)(),[_,D]=(0,l.useState)([]),[I,H]=(0,l.useState)([]),[M,z]=(0,l.useState)([]),[L,R]=(0,l.useState)([]),[G,q]=(0,l.useState)([]),[O,Z]=(0,l.useState)([]),[T,W]=(0,l.useState)([]),[B,J]=(0,l.useState)([]),[K,$]=(0,l.useState)(0),[V,X]=(0,l.useState)(0),[Q,Y]=(0,l.useState)({}),[ee,es]=(0,l.useState)({}),[et,ea]=(0,l.useState)({}),[el,er]=(0,l.useState)({}),[en,eo]=(0,l.useState)("all"),[ei,ec]=(0,l.useState)([]),[ed,em]=(0,l.useState)({}),[eu,eh]=(0,l.useState)(!1),[ex,eg]=(0,l.useState)(null),[ep,ef]=(0,l.useState)(!1),[ey,ej]=(0,l.useState)(!0),[eb,eN]=(0,l.useState)({}),[ev,ew]=(0,l.useState)(null),eS=l.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{showLoadingIndicators:!0},{showLoadingIndicators:t=!0,forceRefresh:a=!1}=e;t&&(s(!0),n(!0),ef(!0),ej(!0));try{async function l(e){await eC(e),await eP(e)}await Promise.all([l(a),e_(a),ek(a)])}catch(e){console.error("Error in fetchData:",e),er({}),D([]),H([]),z([]),R([]),Y({}),es({}),ea({}),ec([]),y(!0),s(!1),J([]),$(0),X(0),w(!0),em({}),ef(!1),eN({}),ej(!1)}finally{t&&(s(!1),n(!1),ef(!1),ej(!1)),o&&t&&d(!1)}},[o]),eC=async e=>{try{let t=e?await (0,m.Xg)():await N.default.get(m.Xg);if(t){let{workspaces:e,allContextNames:a,allGPUs:l,perContextGPUs:r,perNodeGPUs:n,allSlurmGPUs:o,perClusterSlurmGPUs:i,perNodeSlurmGPUs:c,contextStats:d,contextWorkspaceMap:m,contextErrors:u}=t;er(e||{}),D(a||[]),H(l||[]),z(r||[]),R(n||[]),q(o||[]),Z(i||[]),W(c||[]),Y(d||{}),es(m||{}),ea(u||{});let h=Object.keys(e||{});ec(h.sort()),y(!0),s(!1)}else null===t&&(er({}),D([]),H([]),z([]),R([]),q([]),Z([]),W([]),Y({}),es({}),ea({}),ec([]),y(!0),s(!1))}catch(e){console.error("Error in fetchKubernetesData:",e),er({}),D([]),H([]),z([]),R([]),q([]),Z([]),W([]),Y({}),es({}),ea({}),ec([]),y(!0),s(!1)}},ek=async e=>{try{let s=e?await (0,h.getManagedJobs)({allUsers:!0,skipFinished:!0,fields:["cloud","region"]}):await N.default.get(h.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["cloud","region"]}]),t=(null==s?void 0:s.jobs)||[];eN(await (0,m.R8)(t)),ej(!1)}catch(e){console.error("Error in fetchManagedJobsData:",e),eN({}),ej(!1)}},e_=async e=>{try{let s=e?await (0,m.ef)():await N.default.get(m.ef,[e]);s?(J(s.clouds||[]),$(s.totalClouds||0),X(s.enabledClouds||0),w(!0)):null===s&&(J([]),$(0),X(0),w(!0))}catch(e){console.error("Error in fetchCloudData:",e),J([]),$(0),X(0),w(!0)}},eP=async e=>{try{let s=e?await (0,x.It)():await N.default.get(x.It);em(s),ef(!1)}catch(e){console.error("Failed to fetch SSH Node Pools:",e),em({}),ef(!1)}},eU=(e,s)=>{eg({name:e,config:s}),eh(!0)},eD=async e=>{try{await (0,x.MV)(e),await eP(),ew(null),C.push("/infra")}catch(e){throw console.error("Failed to delete SSH Node Pool:",e),e}},eI=async e=>{try{await (0,x._x)(e)}catch(e){throw console.error("Failed to deploy SSH Node Pool:",e),e}},eE=async(e,s)=>{ef(!0);try{let t={...ed};t[e]=s,await (0,x.Ri)(t),await eP(),eh(!1)}catch(e){console.error("Failed to save SSH Node Pool:",e),alert("Failed to save SSH Node Pool. Please try again.")}finally{ef(!1)}};(0,l.useEffect)(()=>{g.current=eS},[eS]),(0,l.useEffect)(()=>{(async()=>{await v.ZP.preloadForPage("infra"),eS({showLoadingIndicators:!0})})()},[]),(0,l.useEffect)(()=>{let e=!0,s=setInterval(()=>{e&&g.current&&"visible"===window.document.visibilityState&&g.current({showLoadingIndicators:!1})},U);return()=>{e=!1,clearInterval(s)}},[]),(0,l.useEffect)(()=>()=>{y(!1),w(!1),ef(!1),d(!0),ej(!1)},[]);let eA=()=>{N.default.invalidate(u.getClusters),N.default.invalidate(h.getManagedJobs,[{allUsers:!0,skipFinished:!0,fields:["cloud","region"]}]),N.default.invalidate(m.Xg),N.default.invalidate(m.ef,[!1]),N.default.invalidate(x.It),g.current&&g.current({showLoadingIndicators:!0,forceRefresh:!0})};(0,l.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"r"===e.key&&(e.preventDefault(),eA())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[]),(I||[]).length,(I||[]).reduce((e,s)=>e+s.gpu_total,0),(I||[]).reduce((e,s)=>e+s.gpu_free,0);let eF=l.useMemo(()=>M?M.reduce((e,s)=>{let{context:t}=s;return e[t]||(e[t]=[]),e[t].push(s),e},{}):{},[M]),eH=l.useCallback(e=>"all"===en?e:e.filter(e=>(ee[e]||[]).includes(en)),[en,ee]),eM=l.useMemo(()=>{if("all"===en){let e=new Set;return Object.values(el).forEach(s=>{s.clouds&&Array.isArray(s.clouds)&&s.clouds.forEach(s=>{let t=s.toLowerCase().split("/")[0];e.add(t)})}),Array.from(e)}{let e=el[en];if(!e||!e.clouds||!Array.isArray(e.clouds))return[];let s=new Set;return e.clouds.forEach(e=>{let t=e.toLowerCase().split("/")[0];s.add(t)}),Array.from(s)}},[en,el]),ez=l.useMemo(()=>B&&0!==B.length?B.filter(e=>eM.includes(e.name.toLowerCase())):[],[B,eM]),eL=l.useMemo(()=>ez.length,[ez]),eR=l.useMemo(()=>_&&Array.isArray(_)?eH(_.filter(e=>e.startsWith("ssh-"))):[],[_,eH]),eG=l.useMemo(()=>_&&Array.isArray(_)?eH(_.filter(e=>!e.startsWith("ssh-"))):[],[_,eH]),eq=l.useMemo(()=>{if(!M||!I)return[];let e=new Set;return M.forEach(s=>{s.context.startsWith("ssh-")&&e.add(s.gpu_name)}),I.filter(s=>e.has(s.gpu_name))},[I,M]),eO=l.useMemo(()=>{if(!M||!I)return[];let e=new Set;return M.forEach(s=>{s.context.startsWith("ssh-")||e.add(s.gpu_name)}),I.filter(s=>e.has(s.gpu_name))},[I,M]),eZ=l.useMemo(()=>O&&Array.isArray(O)?[...new Set(O.map(e=>e.cluster))].sort():[],[O]),eT=l.useMemo(()=>O?O.reduce((e,s)=>{let{cluster:t}=s;return e[t]||(e[t]=[]),e[t].push(s),e},{}):{},[O]),eW=l.useMemo(()=>T?T.reduce((e,s)=>{let{cluster:t}=s;return e[t]||(e[t]=[]),e[t].push(s),e},{}):{},[T]),eB=l.useMemo(()=>L?L.reduce((e,s)=>{let{context:t}=s;return e[t]||(e[t]=[]),e[t].push(s),e},{}):{},[L]);(0,l.useEffect)(()=>{C.isReady&&C.query.context&&ew(decodeURIComponent(Array.isArray(C.query.context)?C.query.context[0]:C.query.context))},[C.isReady,C.query.context]);let eJ=e=>{ew(e);let s="/infra/".concat(encodeURIComponent(e));C.asPath!==s&&C.push(s)},eK=s=>{let t=eF[s]||[],l=eB[s]||[];if(e&&!f)return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(r.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]});if(s.startsWith("ssh-")){let e=s.replace(/^ssh-/,"");return(0,a.jsx)(F,{poolName:e,gpusInContext:t,nodesInContext:l,handleDeploySSHPool:eI,handleEditSSHPool:eU,handleDeleteSSHPool:eD,poolConfig:ed[e]})}return(0,a.jsx)(A,{contextName:s,gpusInContext:t,nodesInContext:l})},e$=()=>t&&(!B||0===B.length)?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Cloud"}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(r.Z,{size:24,className:"mr-3"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading Cloud..."})]})]})}):(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Cloud"}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[eL," of ",K," enabled"]})]}),ez&&0!==ez.length?(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-32",children:"Cloud"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Jobs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:ez.map(e=>{let s=j&&void 0!==e.clusters&&void 0!==e.jobs;return(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 font-medium text-gray-700",children:e.name}),(0,a.jsx)("td",{className:"p-3",children:s?e.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:e.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})}),(0,a.jsx)("td",{className:"p-3",children:s?e.jobs>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:e.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"}):(0,a.jsx)("div",{className:"flex items-center justify-center",children:(0,a.jsx)(r.Z,{size:16})})})]},e.name)})})]})}):(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"all"===en?"No enabled clouds available.":'No enabled clouds for workspace "'.concat(en,'".')})]})}),eV=()=>(0,a.jsx)(E,{title:"SSH Node Pool",isLoading:e,isDataLoaded:f,contexts:eR,gpus:eq,groupedPerContextGPUs:eF,groupedPerNodeGPUs:eB,handleContextClick:eJ,contextStats:Q,jobsData:eb,isJobsDataLoading:ey,isSSH:!0,contextWorkspaceMap:ee,contextErrors:et,actionButton:null}),eX=()=>(0,a.jsx)(E,{title:"Kubernetes",isLoading:e,isDataLoaded:f,contexts:eG,gpus:eO,groupedPerContextGPUs:eF,groupedPerNodeGPUs:eB,handleContextClick:eJ,contextStats:Q,jobsData:eb,isJobsDataLoading:ey,isSSH:!1,contextWorkspaceMap:ee,contextErrors:et}),eQ=()=>(0,a.jsx)(E,{title:"Slurm",isLoading:e,isDataLoaded:f,contexts:eZ,gpus:G,groupedPerContextGPUs:eT,groupedPerNodeGPUs:eW,handleContextClick:eJ,contextStats:{},jobsData:{},isJobsDataLoading:!1,isSSH:!1,isSlurm:!0,contextWorkspaceMap:{}}),eY=e||t;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(k(),{href:"/infra",className:"text-sky-blue hover:underline ".concat(ev?"":"cursor-default"),children:"Infrastructure"}),ev&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),ev.startsWith("ssh-")?(0,a.jsx)(k(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"SSH Node Pool"}):(0,a.jsx)(k(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"Kubernetes"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)("span",{className:"text-sky-blue",children:ev.startsWith("ssh-")?ev.replace(/^ssh-/,""):ev})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[ei.length>0&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700 mr-2",children:"Workspace:"}),(0,a.jsxs)(P.Ph,{value:en,onValueChange:eo,children:[(0,a.jsx)(P.i4,{className:"w-40 h-8 text-sm",children:(0,a.jsx)(P.ki,{})}),(0,a.jsxs)(P.Bw,{children:[(0,a.jsx)(P.Ql,{value:"all",children:"All Workspaces"}),ei.map(e=>(0,a.jsx)(P.Ql,{value:e,children:e},e))]})]})]}),eY&&(0,a.jsxs)("div",{className:"flex items-center mr-2",children:[(0,a.jsx)(r.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,a.jsxs)("button",{onClick:eA,disabled:eY,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(i.Z,{className:"h-4 w-4 mr-1.5"}),!p&&"Refresh"]})]})]}),(()=>{if(ev)return e&&!f?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(r.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]}):eK(ev);let s=[];s.push({name:"Slurm",render:eQ,hasActivity:eZ.length>0,priority:1}),s.push({name:"Kubernetes",render:eX,hasActivity:eG.length>0,priority:2}),s.push({name:"Cloud",render:e$,hasActivity:V>0,priority:3}),s.push({name:"SSH Node Pool",render:eV,hasActivity:eR.length>0&&function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.some(e=>{let t=Q[s?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e)]||{clusters:0,jobs:0};return t.clusters>0||t.jobs>0})}(eR,!0),priority:4});let t=s.sort((e,s)=>e.hasActivity!==s.hasActivity?e.hasActivity?-1:1:e.priority-s.priority);return(0,a.jsx)(a.Fragment,{children:t.map((e,s)=>(0,a.jsx)(l.Fragment,{children:e.render()},s))})})(),(0,a.jsx)(b,{isOpen:eu,onClose:()=>eh(!1),onSave:eE,poolData:ex,isLoading:ep})]})}},42557:function(e,s,t){t.d(s,{I:function(){return n}});var a=t(85893),l=t(67294),r=t(32350);let n=l.forwardRef((e,s)=>{let{className:t,type:l,...n}=e;return(0,a.jsx)("input",{type:l,className:(0,r.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...n})});n.displayName="Input"},36185:function(e,s,t){t.d(s,{_:function(){return c}});var a=t(85893),l=t(67294),r=t(49102),n=t(12003),o=t(32350);let i=(0,n.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)(r.f,{ref:s,className:(0,o.cn)(i(),t),...l})});c.displayName=r.f.displayName},69123:function(e,s,t){t.d(s,{g:function(){return n}});var a=t(85893),l=t(67294),r=t(32350);let n=l.forwardRef((e,s)=>{let{className:t,...l}=e;return(0,a.jsx)("textarea",{className:(0,r.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:s,...l})});n.displayName="Textarea"},17853:function(e,s,t){t.d(s,{TO:function(){return r},ki:function(){return n}});let a=null,l=null,r=async()=>null!==a?a:l||(l=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),s=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==s.status}catch(e){return console.debug("Grafana availability check failed:",e),a=!1,!1}finally{l=null}})()),n=()=>"".concat(window.location.origin,"/grafana")}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3785],{42557:function(e,s,r){r.d(s,{I:function(){return l}});var t=r(85893),a=r(67294),n=r(32350);let l=a.forwardRef((e,s)=>{let{className:r,type:a,...l}=e;return(0,t.jsx)("input",{type:a,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),ref:s,...l})});l.displayName="Input"},36185:function(e,s,r){r.d(s,{_:function(){return c}});var t=r(85893),a=r(67294),n=r(49102),l=r(12003),o=r(32350);let i=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=a.forwardRef((e,s)=>{let{className:r,...a}=e;return(0,t.jsx)(n.f,{ref:s,className:(0,o.cn)(i(),r),...a})});c.displayName=n.f.displayName},33785:function(e,s,r){r.r(s),r.d(s,{NewWorkspace:function(){return b}});var t=r(85893),a=r(67294),n=r(11163),l=r(41664),o=r.n(l),i=r(5152),c=r.n(i),u=r(17324),d=r(30803),f=r(42557),m=r(36185),p=r(37673);let x=c()(()=>Promise.all([r.e(616),r.e(5739),r.e(7411),r.e(1272),r.e(7359),r.e(6989),r.e(3850),r.e(8969),r.e(9353),r.e(2260),r.e(3800),r.e(7615),r.e(1141)]).then(r.bind(r,11141)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[11141]},ssr:!1});function b(){(0,n.useRouter)();let[e,s]=(0,a.useState)(""),[r,l]=(0,a.useState)(!1),[i,c]=(0,a.useState)({}),[b,h]=(0,a.useState)(!0);(0,a.useEffect)(()=>{v()},[]);let v=async()=>{try{let e=await (0,u.getWorkspaces)();c(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{h(!1)}},k=()=>{e.trim()&&!y&&l(!0)},y=e.trim()&&i.hasOwnProperty(e.trim()),w=e.trim()&&!y;return r?(0,t.jsx)(x,{workspaceName:e,isNewWorkspace:!0}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,t.jsxs)("div",{className:"text-base flex items-center",children:[(0,t.jsx)(o(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,t.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,t.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,t.jsxs)(p.Zb,{className:"max-w-md",children:[(0,t.jsx)(p.Ol,{children:(0,t.jsx)(p.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,t.jsxs)(p.aY,{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(m._,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,t.jsx)(f.I,{id:"workspace-name",value:e,onChange:e=>s(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&w&&k()}}),y?(0,t.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,t.jsx)(o(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,t.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,t.jsx)(d.z,{onClick:k,disabled:!w||b,className:"w-full bg-sky-600 hover:bg-sky-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:b?"Loading...":"Next: Configure Workspace"})]})]})]})}},49102:function(e,s,r){r.d(s,{f:function(){return o}});var t=r(67294),a=r(75320),n=r(85893),l=t.forwardRef((e,s)=>(0,n.jsx)(a.WV.label,{...e,ref:s,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));l.displayName="Label";var o=l},12003:function(e,s,r){r.d(s,{j:function(){return l}});var t=r(90512);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=t.W,l=(e,s)=>r=>{var t;if((null==s?void 0:s.variants)==null)return n(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:l,defaultVariants:o}=s,i=Object.keys(l).map(e=>{let s=null==r?void 0:r[e],t=null==o?void 0:o[e];if(null===s)return null;let n=a(s)||a(t);return l[e][n]}),c=r&&Object.entries(r).reduce((e,s)=>{let[r,t]=s;return void 0===t||(e[r]=t),e},{});return n(e,i,null==s?void 0:null===(t=s.compoundVariants)||void 0===t?void 0:t.reduce((e,s)=>{let{class:r,className:t,...a}=s;return Object.entries(a).every(e=>{let[s,r]=e;return Array.isArray(r)?r.includes({...o,...c}[s]):({...o,...c})[s]===r})?[...e,r,t]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3800],{99307:function(e,s,t){t.d(s,{Cl:function(){return l},OE:function(){return d}});var a=t(85893);t(67294);var r=t(55739),c=t(36989),n=t(53850);let l=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":case"IN_USE":case"READY":return"bg-green-50 text-green-700";case"STOPPED":return"bg-yellow-100 text-yellow-800";case"TERMINATED":case"PENDING":case"UNKNOWN":default:return"bg-gray-100 text-gray-800";case"SUCCEEDED":case"PROVISIONING":case"CONTROLLER_INIT":case"REPLICA_INIT":return"bg-blue-50 text-blue-700";case"FAILED":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":case"FAILED_INITIAL_DELAY":case"FAILED_PROBING":case"FAILED_PROVISION":case"FAILED_CLEANUP":case"CONTROLLER_FAILED":return"bg-red-50 text-red-700";case"CANCELLED":case"CANCELLING":case"NOT_READY":return"bg-yellow-50 text-yellow-700";case"RECOVERING":case"SHUTTING_DOWN":return"bg-orange-50 text-orange-700";case"SUBMITTED":return"bg-indigo-50 text-indigo-700";case"STARTING":return"bg-cyan-50 text-cyan-700";case"FAILED_SETUP":return"bg-pink-50 text-pink-700";case"PREEMPTED":case"NO_REPLICA":return"bg-purple-50 text-purple-700"}},i=e=>{switch(e){case"LAUNCHING":case"STARTING":case"PROVISIONING":case"SHUTTING_DOWN":return(0,a.jsx)(r.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":case"IN_USE":default:return(0,a.jsx)(n.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":case"PREEMPTED":return(0,a.jsx)(n.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":case"FAILED_INITIAL_DELAY":case"FAILED_PROBING":case"FAILED_PROVISION":case"FAILED_CLEANUP":case"CONTROLLER_FAILED":case"UNKNOWN":return(0,a.jsx)(n.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,a.jsx)(n.Ye,{className:"w-3 h-3 mr-1"});case"PENDING":case"RECOVERING":case"SUBMITTED":case"CANCELLING":case"FAILED_SETUP":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":case"READY":case"NOT_READY":case"CONTROLLER_INIT":case"REPLICA_INIT":case"NO_REPLICA":return(0,a.jsx)(n.J$,{className:"w-3 h-3 mr-1"})}},o=e=>{let s=l(e),t=i(e);return(0,a.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(s),children:[t,e]})},d=e=>{let{status:s}=e;return(0,a.jsx)(c.WH,{content:s,className:"text-muted-foreground text-sm",children:(0,a.jsx)("span",{children:o(s)})})}},20546:function(e,s,t){t.d(s,{H:function(){return d}});var a=t(85893);t(67294);var r=t(41664),c=t.n(r),n=t(45697),l=t.n(n);function i(e){return!!e&&"string"==typeof e&&e.toLowerCase().startsWith("sa-")}let o=()=>(0,a.jsx)("span",{className:"px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded font-medium ml-1",children:"SA"}),d=e=>{let{username:s,userHash:t,className:r="flex items-center gap-1",linkClassName:n="text-gray-700 hover:text-blue-600 hover:underline",showBadge:l=!0}=e,d=i(t),m=i(t)?"/users?tab=service-accounts":"/users";return(0,a.jsxs)("div",{className:r,children:[(0,a.jsx)(c(),{href:m,className:n,children:s}),l&&d&&(0,a.jsx)(o,{})]})};d.propTypes={username:l().string.isRequired,userHash:l().string,className:l().string,linkClassName:l().string,showBadge:l().bool}},92128:function(e,s,t){t.d(s,{Oh:function(){return u},_R:function(){return x},cV:function(){return N}});var a=t(85893),r=t(67294),c=t(50326),n=t(30803),l=t(37673),i=t(27325),o=t(36989),d=t(93225),m=t(23001);function u(e){let{isOpen:s,onClose:t,cluster:d}=e,[m,u]=r.useState(!1),x=e=>{navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)},N=["sky status ".concat(d),"ssh ".concat(d)],h=N.join("\n");return(0,a.jsx)(c.Vq,{open:s,onOpenChange:t,children:(0,a.jsxs)(c.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(c.fK,{children:[(0,a.jsxs)(c.$N,{children:["Connect to: ",(0,a.jsx)("span",{className:"font-light",children:d})]}),(0,a.jsx)(c.Be,{children:"Use these instructions to connect to your cluster via SSH."})]}),(0,a.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-medium mb-2",children:"SSH Command"}),(0,a.jsx)(l.Zb,{className:"p-3 bg-gray-50",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("pre",{className:"text-sm w-full whitespace-pre-wrap",children:N.map((e,s)=>(0,a.jsx)("code",{className:"block",children:e},s))}),(0,a.jsx)(o.WH,{content:m?"Copied!":"Copy command",children:(0,a.jsx)(n.z,{variant:"ghost",size:"icon",onClick:()=>x(h),className:"h-8 w-8 rounded-full",children:(0,a.jsx)(i.Z,{className:"h-4 w-4"})})})]})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-medium mb-2",children:"Additional Information"}),(0,a.jsxs)("p",{className:"text-sm text-secondary-foreground",children:["Make sure to run"," ",(0,a.jsxs)("code",{className:"text-sm",children:["sky status ",d]})," first to have SkyPilot set up the SSH access."]})]})]})]})})}function x(e){let{isOpen:s,onClose:t,cluster:r}=e,u=(0,m.X)();return(0,a.jsx)(c.Vq,{open:s,onOpenChange:t,children:(0,a.jsx)(c.cZ,{className:"sm:max-w-3xl",children:(0,a.jsxs)(c.fK,{children:[(0,a.jsxs)(c.$N,{children:["Connect to: ",(0,a.jsx)("span",{className:"font-light",children:r})]}),(0,a.jsx)(c.Be,{children:(0,a.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-medium mb-2 my-2",children:"Setup SSH access"}),(0,a.jsx)(l.Zb,{className:"p-3 bg-gray-50",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("pre",{className:"text-sm",children:(0,a.jsxs)("code",{children:["sky status ",r]})}),(0,a.jsx)(o.WH,{content:"Copy command",children:(0,a.jsx)(n.z,{variant:"ghost",size:"icon",onClick:()=>navigator.clipboard.writeText("sky status ".concat(r)),className:"h-8 w-8 rounded-full",children:(0,a.jsx)(i.Z,{className:"h-4 w-4"})})})]})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-medium mb-2 my-2",children:"Connect with VSCode/Cursor"}),(0,a.jsx)(l.Zb,{className:"p-3 bg-gray-50",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("pre",{className:"text-sm",children:(0,a.jsxs)("code",{children:["code --remote ssh-remote+",r,' "/home"']})}),(0,a.jsx)(o.WH,{content:"Copy command",children:(0,a.jsx)(n.z,{variant:"ghost",size:"icon",onClick:()=>navigator.clipboard.writeText("code --remote ssh-remote+".concat(r,' "/home"')),className:"h-8 w-8 rounded-full",children:(0,a.jsx)(i.Z,{className:"h-4 w-4"})})})]})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:"Or use the GUI to connect"}),(0,a.jsx)("div",{className:"relative ".concat(u?"-mt-5":"-mt-10"),style:{paddingBottom:"70%"},children:(0,a.jsxs)("video",{className:"absolute top-0 left-0 w-full h-full rounded-lg",controls:!0,autoPlay:!0,muted:!0,preload:"metadata",children:[(0,a.jsx)("source",{src:"".concat(d.GW,"/videos/cursor-small.mp4"),type:"video/mp4"}),"Your browser does not support the video tag."]})})]})]})})]})})})}function N(e){let{isOpen:s,onClose:t,onConfirm:r,title:l,message:i,confirmText:o="Confirm",confirmVariant:d="destructive",confirmClassName:m=null}=e;return(0,a.jsx)(c.Vq,{open:s,onOpenChange:t,children:(0,a.jsxs)(c.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(c.fK,{children:[(0,a.jsx)(c.$N,{children:l}),(0,a.jsx)(c.Be,{children:i})]}),(0,a.jsxs)(c.cN,{className:"flex justify-end gap-2 pt-4",children:[(0,a.jsx)(n.z,{variant:"outline",onClick:t,children:"Cancel"}),(0,a.jsx)(n.z,{variant:m?void 0:d,className:m,onClick:()=>{r(),t()},children:o})]})]})})}},68764:function(e,s,t){t.d(s,{RM:function(){return i},SC:function(){return o},iA:function(){return n},pj:function(){return m},ss:function(){return d},xD:function(){return l}});var a=t(85893),r=t(67294),c=t(32350);let n=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("div",{className:"relative w-full overflow-auto",children:(0,a.jsx)("table",{ref:s,className:(0,c.cn)("w-full caption-bottom text-base",t),...r})})});n.displayName="Table";let l=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("thead",{ref:s,className:(0,c.cn)("[&_tr]:border-b",t),...r})});l.displayName="TableHeader";let i=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("tbody",{ref:s,className:(0,c.cn)("[&_tr:last-child]:border-0",t),...r})});i.displayName="TableBody",r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("tfoot",{ref:s,className:(0,c.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...r})}).displayName="TableFooter";let o=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("tr",{ref:s,className:(0,c.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...r})});o.displayName="TableRow";let d=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("th",{ref:s,className:(0,c.cn)("h-12 px-4 text-left align-middle font-medium text-[hsl(var(--text-strong))] [&:has([role=checkbox])]:pr-0",t),...r})});d.displayName="TableHead";let m=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("td",{ref:s,className:(0,c.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...r})});m.displayName="TableCell",r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)("caption",{ref:s,className:(0,c.cn)("mt-4 text-base text-muted-foreground",t),...r})}).displayName="TableCaption"}}]);