skypilot-nightly 1.0.0.dev20250627__py3-none-any.whl → 1.0.0.dev20250630__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 (173) hide show
  1. sky/__init__.py +2 -2
  2. sky/adaptors/kubernetes.py +14 -0
  3. sky/adaptors/nebius.py +2 -2
  4. sky/authentication.py +12 -5
  5. sky/backends/backend_utils.py +92 -26
  6. sky/check.py +5 -2
  7. sky/client/cli/command.py +39 -8
  8. sky/client/sdk.py +217 -167
  9. sky/client/service_account_auth.py +47 -0
  10. sky/clouds/aws.py +10 -4
  11. sky/clouds/azure.py +5 -2
  12. sky/clouds/cloud.py +5 -2
  13. sky/clouds/gcp.py +31 -18
  14. sky/clouds/kubernetes.py +54 -34
  15. sky/clouds/nebius.py +8 -2
  16. sky/clouds/ssh.py +5 -2
  17. sky/clouds/utils/aws_utils.py +10 -4
  18. sky/clouds/utils/gcp_utils.py +22 -7
  19. sky/clouds/utils/oci_utils.py +62 -14
  20. sky/dashboard/out/404.html +1 -1
  21. sky/dashboard/out/_next/static/NdypbqMxaYucRGfopkKXa/_buildManifest.js +1 -0
  22. sky/dashboard/out/_next/static/chunks/1043-1b39779691bb4030.js +1 -0
  23. sky/dashboard/out/_next/static/chunks/{141-fa5a20cbf401b351.js → 1141-726e5a3f00b67185.js} +2 -2
  24. sky/dashboard/out/_next/static/chunks/1272-1ef0bf0237faccdb.js +1 -0
  25. sky/dashboard/out/_next/static/chunks/1664-d65361e92b85e786.js +1 -0
  26. sky/dashboard/out/_next/static/chunks/1691.44e378727a41f3b5.js +21 -0
  27. sky/dashboard/out/_next/static/chunks/1871-80dea41717729fa5.js +6 -0
  28. sky/dashboard/out/_next/static/chunks/2544.27f70672535675ed.js +1 -0
  29. sky/dashboard/out/_next/static/chunks/{875.52c962183328b3f2.js → 2875.c24c6d57dc82e436.js} +1 -1
  30. sky/dashboard/out/_next/static/chunks/3256.7257acd01b481bed.js +11 -0
  31. sky/dashboard/out/_next/static/chunks/3698-52ad1ca228faa776.js +1 -0
  32. sky/dashboard/out/_next/static/chunks/3785.b3cc2bc1d49d2c3c.js +1 -0
  33. sky/dashboard/out/_next/static/chunks/3937.d7f1c55d1916c7f2.js +1 -0
  34. sky/dashboard/out/_next/static/chunks/{947-6620842ef80ae879.js → 3947-b059261d6fa88a1f.js} +1 -1
  35. sky/dashboard/out/_next/static/chunks/{697.6460bf72e760addd.js → 4697.f5421144224da9fc.js} +1 -1
  36. sky/dashboard/out/_next/static/chunks/4725.4c849b1e05c8e9ad.js +1 -0
  37. sky/dashboard/out/_next/static/chunks/5230-df791914b54d91d9.js +1 -0
  38. sky/dashboard/out/_next/static/chunks/{491.b3d264269613fe09.js → 5491.918ffed0ba7a5294.js} +1 -1
  39. sky/dashboard/out/_next/static/chunks/5739-5ea3ffa10fc884f2.js +8 -0
  40. sky/dashboard/out/_next/static/chunks/616-162f3033ffcd3d31.js +39 -0
  41. sky/dashboard/out/_next/static/chunks/6601-fcfad0ddf92ec7ab.js +1 -0
  42. sky/dashboard/out/_next/static/chunks/6989-6ff4e45dfb49d11d.js +1 -0
  43. sky/dashboard/out/_next/static/chunks/6990-d0dc765474fa0eca.js +1 -0
  44. sky/dashboard/out/_next/static/chunks/8969-909d53833da080cb.js +1 -0
  45. sky/dashboard/out/_next/static/chunks/8982.a2e214068f30a857.js +1 -0
  46. sky/dashboard/out/_next/static/chunks/{25.76c246239df93d50.js → 9025.a7c44babfe56ce09.js} +2 -2
  47. sky/dashboard/out/_next/static/chunks/938-044ad21de8b4626b.js +1 -0
  48. sky/dashboard/out/_next/static/chunks/9470-21d059a1dfa03f61.js +1 -0
  49. sky/dashboard/out/_next/static/chunks/9984.739ae958a066298d.js +1 -0
  50. sky/dashboard/out/_next/static/chunks/fd9d1056-61f2257a9cd8b32b.js +1 -0
  51. sky/dashboard/out/_next/static/chunks/{framework-87d061ee6ed71b28.js → framework-efc06c2733009cd3.js} +1 -1
  52. sky/dashboard/out/_next/static/chunks/main-app-68c028b1bc5e1b72.js +1 -0
  53. sky/dashboard/out/_next/static/chunks/{main-e0e2335212e72357.js → main-c0a4f1ea606d48d2.js} +1 -1
  54. sky/dashboard/out/_next/static/chunks/pages/{_app-9a3ce3170d2edcec.js → _app-a37b06ddb64521fd.js} +2 -2
  55. sky/dashboard/out/_next/static/chunks/pages/_error-c72a1f77a3c0be1b.js +1 -0
  56. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-8135aba0712bda37.js +6 -0
  57. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-b8e1114e6d38218c.js +6 -0
  58. sky/dashboard/out/_next/static/chunks/pages/clusters-9744c271a1642f76.js +1 -0
  59. sky/dashboard/out/_next/static/chunks/pages/config-a2673b256b6d416f.js +1 -0
  60. sky/dashboard/out/_next/static/chunks/pages/index-927ddeebe57a8ac3.js +1 -0
  61. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-8b0809f59034d509.js +1 -0
  62. sky/dashboard/out/_next/static/chunks/pages/infra-ae9d2f705ce582c9.js +1 -0
  63. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-c4d5cfac7fbc0668.js +16 -0
  64. sky/dashboard/out/_next/static/chunks/pages/jobs-5bbdc71878f0a068.js +1 -0
  65. sky/dashboard/out/_next/static/chunks/pages/users-cd43fb3c122eedde.js +1 -0
  66. sky/dashboard/out/_next/static/chunks/pages/volumes-4ebf6484f7216387.js +1 -0
  67. sky/dashboard/out/_next/static/chunks/pages/workspace/new-5629d4e551dba1ee.js +1 -0
  68. sky/dashboard/out/_next/static/chunks/pages/workspaces/[name]-7c0187f43757a548.js +1 -0
  69. sky/dashboard/out/_next/static/chunks/pages/workspaces-06bde99155fa6292.js +1 -0
  70. sky/dashboard/out/_next/static/chunks/webpack-d427db53e54de9ce.js +1 -0
  71. sky/dashboard/out/_next/static/css/0da6afe66176678a.css +3 -0
  72. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  73. sky/dashboard/out/clusters/[cluster].html +1 -1
  74. sky/dashboard/out/clusters.html +1 -1
  75. sky/dashboard/out/config.html +1 -1
  76. sky/dashboard/out/index.html +1 -1
  77. sky/dashboard/out/infra/[context].html +1 -1
  78. sky/dashboard/out/infra.html +1 -1
  79. sky/dashboard/out/jobs/[job].html +1 -1
  80. sky/dashboard/out/jobs.html +1 -1
  81. sky/dashboard/out/users.html +1 -1
  82. sky/dashboard/out/volumes.html +1 -1
  83. sky/dashboard/out/workspace/new.html +1 -1
  84. sky/dashboard/out/workspaces/[name].html +1 -1
  85. sky/dashboard/out/workspaces.html +1 -1
  86. sky/data/storage.py +8 -3
  87. sky/global_user_state.py +257 -9
  88. sky/jobs/client/sdk.py +20 -25
  89. sky/models.py +16 -0
  90. sky/optimizer.py +46 -0
  91. sky/provision/__init__.py +14 -6
  92. sky/provision/kubernetes/config.py +1 -1
  93. sky/provision/kubernetes/constants.py +9 -0
  94. sky/provision/kubernetes/instance.py +24 -18
  95. sky/provision/kubernetes/network.py +15 -9
  96. sky/provision/kubernetes/network_utils.py +42 -23
  97. sky/provision/kubernetes/utils.py +73 -35
  98. sky/provision/kubernetes/volume.py +77 -15
  99. sky/provision/nebius/utils.py +10 -4
  100. sky/resources.py +10 -4
  101. sky/serve/client/sdk.py +28 -34
  102. sky/server/common.py +51 -3
  103. sky/server/constants.py +3 -0
  104. sky/server/requests/executor.py +4 -0
  105. sky/server/requests/payloads.py +33 -0
  106. sky/server/requests/requests.py +19 -0
  107. sky/server/rest.py +6 -15
  108. sky/server/server.py +121 -6
  109. sky/skylet/constants.py +7 -0
  110. sky/skypilot_config.py +32 -4
  111. sky/task.py +12 -0
  112. sky/users/permission.py +29 -0
  113. sky/users/server.py +384 -5
  114. sky/users/token_service.py +196 -0
  115. sky/utils/common_utils.py +4 -5
  116. sky/utils/config_utils.py +41 -0
  117. sky/utils/controller_utils.py +5 -1
  118. sky/utils/log_utils.py +68 -0
  119. sky/utils/resource_checker.py +153 -0
  120. sky/utils/resources_utils.py +12 -4
  121. sky/utils/schemas.py +87 -60
  122. sky/utils/subprocess_utils.py +2 -6
  123. sky/volumes/server/core.py +103 -78
  124. sky/volumes/utils.py +22 -5
  125. sky/workspaces/core.py +9 -117
  126. {skypilot_nightly-1.0.0.dev20250627.dist-info → skypilot_nightly-1.0.0.dev20250630.dist-info}/METADATA +1 -1
  127. {skypilot_nightly-1.0.0.dev20250627.dist-info → skypilot_nightly-1.0.0.dev20250630.dist-info}/RECORD +133 -128
  128. sky/dashboard/out/_next/static/HudU4f4Xsy-cP51JvXSZ-/_buildManifest.js +0 -1
  129. sky/dashboard/out/_next/static/chunks/230-d6e363362017ff3a.js +0 -1
  130. sky/dashboard/out/_next/static/chunks/43-36177d00f6956ab2.js +0 -1
  131. sky/dashboard/out/_next/static/chunks/470-92dd1614396389be.js +0 -1
  132. sky/dashboard/out/_next/static/chunks/544.110e53813fb98e2e.js +0 -1
  133. sky/dashboard/out/_next/static/chunks/616-d6128fa9e7cae6e6.js +0 -39
  134. sky/dashboard/out/_next/static/chunks/645.961f08e39b8ce447.js +0 -1
  135. sky/dashboard/out/_next/static/chunks/664-047bc03493fda379.js +0 -1
  136. sky/dashboard/out/_next/static/chunks/690.55f9eed3be903f56.js +0 -16
  137. sky/dashboard/out/_next/static/chunks/785.dc2686c3c1235554.js +0 -1
  138. sky/dashboard/out/_next/static/chunks/798-c0525dc3f21e488d.js +0 -1
  139. sky/dashboard/out/_next/static/chunks/799-3625946b2ec2eb30.js +0 -8
  140. sky/dashboard/out/_next/static/chunks/871-3db673be3ee3750b.js +0 -6
  141. sky/dashboard/out/_next/static/chunks/937.3759f538f11a0953.js +0 -1
  142. sky/dashboard/out/_next/static/chunks/938-068520cc11738deb.js +0 -1
  143. sky/dashboard/out/_next/static/chunks/969-d3a0b53f728d280a.js +0 -1
  144. sky/dashboard/out/_next/static/chunks/973-81b2d057178adb76.js +0 -1
  145. sky/dashboard/out/_next/static/chunks/982.1b61658204416b0f.js +0 -1
  146. sky/dashboard/out/_next/static/chunks/984.e8bac186a24e5178.js +0 -1
  147. sky/dashboard/out/_next/static/chunks/989-db34c16ad7ea6155.js +0 -1
  148. sky/dashboard/out/_next/static/chunks/990-0ad5ea1699e03ee8.js +0 -1
  149. sky/dashboard/out/_next/static/chunks/fd9d1056-2821b0f0cabcd8bd.js +0 -1
  150. sky/dashboard/out/_next/static/chunks/main-app-241eb28595532291.js +0 -1
  151. sky/dashboard/out/_next/static/chunks/pages/_error-1be831200e60c5c0.js +0 -1
  152. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-aff040d7bc5d0086.js +0 -6
  153. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-8040f2483897ed0c.js +0 -6
  154. sky/dashboard/out/_next/static/chunks/pages/clusters-f119a5630a1efd61.js +0 -1
  155. sky/dashboard/out/_next/static/chunks/pages/config-6b255eae088da6a3.js +0 -1
  156. sky/dashboard/out/_next/static/chunks/pages/index-6b0d9e5031b70c58.js +0 -1
  157. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-b302aea4d65766bf.js +0 -1
  158. sky/dashboard/out/_next/static/chunks/pages/infra-ee8cc4d449945d19.js +0 -1
  159. sky/dashboard/out/_next/static/chunks/pages/jobs/[job]-e4b23128db0774cd.js +0 -16
  160. sky/dashboard/out/_next/static/chunks/pages/jobs-0a5695ff3075d94a.js +0 -1
  161. sky/dashboard/out/_next/static/chunks/pages/users-4978cbb093e141e7.js +0 -1
  162. sky/dashboard/out/_next/static/chunks/pages/volumes-476b670ef33d1ecd.js +0 -1
  163. sky/dashboard/out/_next/static/chunks/pages/workspace/new-5b59bce9eb208d84.js +0 -1
  164. sky/dashboard/out/_next/static/chunks/pages/workspaces/[name]-cb7e720b739de53a.js +0 -1
  165. sky/dashboard/out/_next/static/chunks/pages/workspaces-50e230828730cfb3.js +0 -1
  166. sky/dashboard/out/_next/static/chunks/webpack-08fdb9e6070127fc.js +0 -1
  167. sky/dashboard/out/_next/static/css/52082cf558ec9705.css +0 -3
  168. /sky/dashboard/out/_next/static/{HudU4f4Xsy-cP51JvXSZ- → NdypbqMxaYucRGfopkKXa}/_ssgManifest.js +0 -0
  169. /sky/dashboard/out/_next/static/chunks/{804-4c9fc53aa74bc191.js → 804-9f5e98ce84d46bdd.js} +0 -0
  170. {skypilot_nightly-1.0.0.dev20250627.dist-info → skypilot_nightly-1.0.0.dev20250630.dist-info}/WHEEL +0 -0
  171. {skypilot_nightly-1.0.0.dev20250627.dist-info → skypilot_nightly-1.0.0.dev20250630.dist-info}/entry_points.txt +0 -0
  172. {skypilot_nightly-1.0.0.dev20250627.dist-info → skypilot_nightly-1.0.0.dev20250630.dist-info}/licenses/LICENSE +0 -0
  173. {skypilot_nightly-1.0.0.dev20250627.dist-info → skypilot_nightly-1.0.0.dev20250630.dist-info}/top_level.txt +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6990],{803:function(e,r,t){t.d(r,{z:function(){return i}});var o=t(5893),a=t(7294),n=t(8426),s=t(2003),c=t(2350);let l=(0,s.j)("inline-flex items-center justify-center whitespace-nowrap 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",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),i=a.forwardRef((e,r)=>{let{className:t,variant:a,size:s,asChild:i=!1,...u}=e,d=i?n.g7:"button";return(0,o.jsx)(d,{className:(0,c.cn)(l({variant:a,size:s,className:t})),ref:r,...u})});i.displayName="Button"},7673:function(e,r,t){t.d(r,{Ol:function(){return i},Zb:function(){return l},aY:function(){return f},eW:function(){return p},ll:function(){return u}});var o=t(5893),a=t(7294),n=t(5697),s=t.n(n),c=t(2350);let l=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",t),...n,children:a})});l.displayName="Card",l.propTypes={className:s().string,children:s().node};let i=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("flex flex-col space-y-1.5 p-6",t),...n,children:a})});i.displayName="CardHeader",i.propTypes={className:s().string,children:s().node};let u=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("h3",{ref:r,className:(0,c.cn)("text-2xl font-semibold leading-none tracking-tight",t),...n,children:a})});u.displayName="CardTitle",u.propTypes={className:s().string,children:s().node};let d=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("p",{ref:r,className:(0,c.cn)("text-sm text-muted-foreground",t),...n,children:a})});d.displayName="CardDescription",d.propTypes={className:s().string,children:s().node};let f=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("p-6 pt-0",t),...n,children:a})});f.displayName="CardContent",f.propTypes={className:s().string,children:s().node};let p=a.forwardRef((e,r)=>{let{className:t,children:a,...n}=e;return(0,o.jsx)("div",{ref:r,className:(0,c.cn)("flex items-center p-6 pt-0",t),...n,children:a})});p.displayName="CardFooter",p.propTypes={className:s().string,children:s().node}},7145:function(e,r,t){t.d(r,{x:function(){return a}});var o=t(3225);let a={fetch:async function(e,r){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST",a=window.location.origin,n="".concat(a).concat(o.f4).concat(e),s=await fetch(n,{method:t,headers:"POST"===t?{"Content-Type":"application/json"}:{},body:"POST"===t?JSON.stringify(r):void 0}),c=s.headers.get("X-Skypilot-Request-ID")||s.headers.get("X-Request-ID"),l=await fetch("".concat(a).concat(o.f4,"/api/get?request_id=").concat(c)),i=await l.json();return i.return_value?JSON.parse(i.return_value):[]},post:async(e,r)=>{let t=window.location.origin,a="".concat(t).concat(o.f4).concat(e);return await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})},stream:async(e,r,t)=>{let o=(await a.post(e,r)).body.getReader();try{for(;;){let{done:e,value:r}=await o.read();if(e)break;let a=new TextDecoder().decode(r);t(a)}}catch(e){throw console.error("Error in stream:",e),e}},get:async e=>{let r=window.location.origin,t="".concat(r).concat(o.f4).concat(e);return await fetch(t)}}},7324:function(e,r,t){t.d(r,{MB:function(){return l},eA:function(){return c},fX:function(){return a},iE:function(){return u},rF:function(){return d},yz:function(){return n},zl:function(){return i}});var o=t(7145);async function a(){try{let e=await o.x.get("/workspaces");if(!e.ok)throw Error("Error scheduling getWorkspaces: ".concat(e.statusText," (status ").concat(e.status,")"));let r=e.headers.get("X-Skypilot-Request-ID");if(!r){console.warn("X-Skypilot-Request-ID header not found in /workspaces response. Attempting to find request_id in response body as a fallback.");try{let t=await e.json();if(t&&t.request_id)r=t.request_id,console.log("Found request_id in /workspaces response body (fallback):",r);else throw Error("X-Skypilot-Request-ID header not found AND request_id not found in parsed response body from /workspaces.")}catch(r){let e=r.message||"Error processing fallback for request_id from /workspaces response body.";throw console.error("Error in /workspaces request_id fallback logic:",e),Error("X-Skypilot-Request-ID header not found, and fallback to read request_id from body failed: ".concat(e))}}if(!r)throw Error("Failed to obtain X-Skypilot-Request-ID from /workspaces response (checked header and attempted body fallback, but ID is still missing).");console.log("Fetching workspace data with request_id: ".concat(r));let t=await o.x.get("/api/get?request_id=".concat(r));if(!t.ok){let e="Error fetching workspace data for request ID ".concat(r,": ").concat(t.statusText," (status ").concat(t.status,")");try{let o=await t.json();if(o&&o.detail){let t=o.detail;try{let e=JSON.parse(t);e&&e.error?t=e.error:e&&e.result&&e.result.error&&(t=e.result.error)}catch(e){}e="Error fetching workspace data for request ID ".concat(r,": ").concat(t)}}catch(e){}throw Error(e)}let a=await t.json();if(console.log("[Connector Debug] Full resultData from /api/get:",a),"FAILED"===a.status){let e="Unknown error during task execution";if(a.error)"string"==typeof a.error?e=a.error:"object"==typeof a.error&&(e=a.error.message||a.error.detail||JSON.stringify(a.error));else if(a.result&&a.result.error)"string"==typeof a.result.error?e=a.result.error:"object"==typeof a.result.error&&(e=a.result.error.message||a.result.error.detail||JSON.stringify(a.result.error));else if(a.return_value)try{let r=JSON.parse(a.return_value);r.error&&(e="string"==typeof r.error?r.error:r.error.message||r.error.detail||JSON.stringify(r.error))}catch(r){(a.return_value.includes("Error")||a.return_value.includes("Cannot"))&&(e=a.return_value)}throw Error(e)}let n={};if("SUCCEEDED"===a.status&&a.return_value)try{n=JSON.parse(a.return_value),console.log("Successfully parsed workspace data from return_value:",n)}catch(e){throw console.error("Failed to parse workspace data from return_value:",e,"Raw return_value:",a.return_value),Error("Failed to parse workspace data for request ID ".concat(r,": ").concat(e.message))}else a.result&&(console.warn("Using resultData.result as fallback for status ".concat(a.status)),n=a.result);return console.log("Effectively fetched workspace data (to be returned):",n),n||{}}catch(e){throw console.error("Failed to fetch workspaces (in getWorkspaces function):",e.message,e.stack),e}}async function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{let t="/enabled_clouds",a=new URLSearchParams;e&&a.append("workspace",e),r&&a.append("expand","true"),a.toString()&&(t+="?".concat(a.toString()));let n=await o.x.get(t);if(!n.ok)throw Error("Error scheduling getEnabledClouds: ".concat(n.statusText," (status ").concat(n.status,")"));let s=n.headers.get("X-Skypilot-Request-ID");if(!s){console.warn("X-Skypilot-Request-ID header not found in /enabled_clouds response. Attempting to find request_id in response body as a fallback.");try{let e=await n.json();if(e&&e.request_id)s=e.request_id,console.log("Found request_id in /enabled_clouds response body (fallback):",s);else throw Error("X-Skypilot-Request-ID header not found AND request_id not found in parsed response body from /enabled_clouds.")}catch(r){let e=r.message||"Error processing fallback for request_id from /enabled_clouds response body.";throw console.error("Error in /enabled_clouds request_id fallback logic:",e),Error("X-Skypilot-Request-ID header not found, and fallback to read request_id from body failed: ".concat(e))}}if(!s)throw Error("Failed to obtain X-Skypilot-Request-ID from /enabled_clouds response (checked header and attempted body fallback, but ID is still missing).");console.log("Fetching enabled_clouds data with request_id: ".concat(s));let c=await o.x.get("/api/get?request_id=".concat(s));if(!c.ok){let e="Error fetching enabled_clouds data for request ID ".concat(s,": ").concat(c.statusText," (status ").concat(c.status,")");try{let r=await c.json();if(r&&r.detail){let t=r.detail;try{let e=JSON.parse(t);e&&e.error?t=e.error:e&&e.result&&e.result.error&&(t=e.result.error)}catch(e){}e="Error fetching enabled_clouds data for request ID ".concat(s,": ").concat(t)}}catch(e){}throw Error(e)}let l=await c.json();if(console.log("[Connector Debug] Full resultData from /api/get for enabled_clouds:",l),"FAILED"===l.status){let e=l.error||l.result&&l.result.error||"Unknown error during task execution for enabled_clouds";throw Error("Fetching enabled_clouds data failed for request ID ".concat(s,": ").concat(e))}let i=[];if("SUCCEEDED"===l.status&&l.return_value)try{i=JSON.parse(l.return_value),console.log("Successfully parsed enabled_clouds data from return_value:",i)}catch(e){throw console.error("Failed to parse enabled_clouds data from return_value:",e,"Raw return_value:",l.return_value),Error("Failed to parse enabled_clouds data for request ID ".concat(s,": ").concat(e.message))}else l.result&&(console.warn("Using resultData.result as fallback for enabled_clouds status ".concat(l.status)),i=l.result);return Array.isArray(i)?i:[]}catch(e){throw console.error("Failed to fetch enabled_clouds (in getEnabledClouds function):",e.message,e.stack),e}}async function s(e,r){console.log("Polling for ".concat(r," task completion with request_id: ").concat(e));let t=await o.x.get("/api/get?request_id=".concat(e));if(!t.ok){let o="Error fetching ".concat(r," data for request ID ").concat(e,": ").concat(t.statusText," (status ").concat(t.status,")");try{let e=await t.json();if(console.error("[Error Debug] ".concat(r," HTTP error response:"),JSON.stringify(e,null,2)),e&&e.detail){if("object"==typeof e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);if(t&&t.message)o="".concat(r," failed: ").concat(t.message);else if(t&&"object"==typeof t){let e=t.type||JSON.stringify(t);o="".concat(r," failed: ").concat(e)}}catch(t){o="".concat(r," failed: ").concat(e.detail.error)}else if("string"==typeof e.detail)o="".concat(r," failed: ").concat(e.detail);else{let t=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("string"==typeof e&&(e.includes("Cannot")||e.includes("Error")||e.includes("Failed")))return e;if("object"==typeof e&&null!==e)for(let[o,a]of Object.entries(e)){let e=t(a,r?"".concat(r,".").concat(o):o);if(e)return e}return null},a=t(e.detail);a&&(o="".concat(r," failed: ").concat(a))}}}catch(e){console.error("[Error Debug] Failed to parse error response:",e)}throw Error(o)}let a=await t.json();if(console.log("[Connector Debug] ".concat(r," resultData:"),a),"FAILED"===a.status){console.error("[Error Debug] ".concat(r," failed. Full resultData:"),JSON.stringify(a,null,2)),console.error("[Error Debug] resultData.error:",a.error),console.error("[Error Debug] resultData.result:",a.result),console.error("[Error Debug] resultData.return_value:",a.return_value);let e="Unknown error during ".concat(r," task execution");if(a.error)"string"==typeof a.error?e=a.error:"object"==typeof a.error&&(e=a.error.message||a.error.detail||JSON.stringify(a.error));else if(a.result&&a.result.error)"string"==typeof a.result.error?e=a.result.error:"object"==typeof a.result.error&&(e=a.result.error.message||a.result.error.detail||JSON.stringify(a.result.error));else if(a.return_value)try{let r=JSON.parse(a.return_value);r.error&&(e="string"==typeof r.error?r.error:r.error.message||r.error.detail||JSON.stringify(r.error))}catch(r){a.return_value&&(a.return_value.includes("Error")||a.return_value.includes("Cannot"))&&(e=a.return_value)}if(e==="Unknown error during ".concat(r," task execution")){let r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("string"==typeof e&&(e.includes("Cannot")||e.includes("Error")||e.includes("Failed")))return e;if("object"==typeof e&&null!==e)for(let[o,a]of Object.entries(e)){let e=r(a,t?"".concat(t,".").concat(o):o);if(e)return e}return null},t=r(a);t&&(e=t)}throw Error(e)}let n={};if("SUCCEEDED"===a.status&&a.return_value)try{n=JSON.parse(a.return_value),console.log("Successfully parsed ".concat(r," data:"),n)}catch(t){throw console.error("Failed to parse ".concat(r," data from return_value:"),t,"Raw return_value:",a.return_value),Error("Failed to parse ".concat(r," data for request ID ").concat(e,": ").concat(t.message))}else a.result&&(console.warn("Using resultData.result as fallback for ".concat(r," status ").concat(a.status)),n=a.result);return n}async function c(e,r){try{console.log("Updating workspace ".concat(e," with config:"),r);let t=await o.x.post("/workspaces/update",{workspace_name:e,config:r});if(!t.ok)throw Error("Error scheduling updateWorkspace: ".concat(t.statusText," (status ").concat(t.status,")"));let a=t.headers.get("X-Skypilot-Request-ID");if(!a)throw Error("Failed to obtain request ID for updateWorkspace");return await s(a,"updateWorkspace")}catch(e){throw console.error("Failed to update workspace:",e),e}}let l=async(e,r)=>{try{let t=await o.x.post("/workspaces/create",{workspace_name:e,config:r});if(!t.ok)throw await t.text(),Error("Error scheduling createWorkspace: ".concat(t.statusText," (status ").concat(t.status,")"));let a=t.headers.get("X-Skypilot-Request-ID");if(!a)throw Error("Failed to obtain request ID for createWorkspace");return await s(a,"createWorkspace")}catch(e){throw console.error("Failed to create workspace:",e),e}};async function i(e){try{console.log("Deleting workspace ".concat(e));let r=await o.x.post("/workspaces/delete",{workspace_name:e});if(!r.ok)throw Error("Error scheduling deleteWorkspace: ".concat(r.statusText," (status ").concat(r.status,")"));let t=r.headers.get("X-Skypilot-Request-ID");if(!t)throw Error("Failed to obtain request ID for deleteWorkspace");console.log("[Delete Debug] Got request ID for deleteWorkspace: ".concat(t));try{let e=await s(t,"deleteWorkspace");return console.log("[Delete Debug] deleteWorkspace completed successfully:",e),e}catch(e){throw console.error("[Delete Debug] deleteWorkspace failed with error:",e),console.error("[Delete Debug] Error message:",e.message),e}}catch(e){throw console.error("Failed to delete workspace:",e),e}}async function u(){try{console.log("Getting entire SkyPilot configuration");let e=await o.x.get("/workspaces/config");if(!e.ok)throw Error("Error scheduling getConfig: ".concat(e.statusText," (status ").concat(e.status,")"));let r=e.headers.get("X-Skypilot-Request-ID");if(!r)throw Error("Failed to obtain request ID for getConfig");return await s(r,"getConfig")}catch(e){throw console.error("Failed to get config:",e),e}}async function d(e){try{console.log("Updating entire SkyPilot configuration with config:",e);let r=await o.x.post("/workspaces/config",{config:e});if(!r.ok)throw Error("Error scheduling updateConfig: ".concat(r.statusText," (status ").concat(r.status,")"));let t=r.headers.get("X-Skypilot-Request-ID");if(!t)throw Error("Failed to obtain request ID for updateConfig");return await s(t,"updateConfig")}catch(e){throw console.error("Failed to update config:",e),e}}},2350:function(e,r,t){t.d(r,{cn:function(){return n}});var o=t(512),a=t(8388);function n(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return(0,a.m6)((0,o.W)(r))}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8969],{8969:function(e,t,r){r.d(t,{Ce:function(){return u},NJ:function(){return d},UA:function(){return l},getManagedJobs:function(){return i}});var o=r(7294),a=r(5821),n=r(3225),c=r(6378),s=r(7145);async function i(){let{allUsers:e=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let t=(await s.x.post("/jobs/queue",{all_users:e})).headers.get("X-Skypilot-Request-ID"),r=await s.x.get("/api/get?request_id=".concat(t));if(500===r.status){try{let e=await r.json();if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);if(t.type&&t.type===n.iW)return{jobs:[],controllerStopped:!0}}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{jobs:[],controllerStopped:!1}}let o=await r.json();return{jobs:(o.return_value?JSON.parse(o.return_value):[]).map(e=>{let t=[];e.submitted_at&&t.push({time:new Date(1e3*e.submitted_at),event:"Job submitted."}),e.start_at&&t.push({time:new Date(1e3*e.start_at),event:"Job started."}),e.end_at&&("CANCELLING"==e.status||"CANCELLED"==e.status?t.push({time:new Date(1e3*e.end_at),event:"Job cancelled."}):t.push({time:new Date(1e3*e.end_at),event:"Job completed."})),e.last_recovered_at&&e.last_recovered_at!=e.start_at&&t.push({time:new Date(1e3*e.last_recovered_at),event:"Job recovered."});let r=(e.end_at?e.end_at:Date.now()/1e3)-e.submitted_at,o=e.cloud,a=e.cluster_resources;if(!o){if(e.cluster_resources&&"-"!==e.cluster_resources)try{o=e.cluster_resources.split("(")[0].split("x").pop().trim(),a=e.cluster_resources.replace("".concat(o,"("),"(").replace("x ","x")}catch(e){o="Unknown"}else o="Unknown"}let n="",c=n=e.zone?e.zone:e.region;n&&n.length>15&&(n=n.substring(0,15)+"...");let s=o+" ("+n+")";"-"===n&&(s=o);let i=o+" ("+c+")";return"-"===c&&(i=o),{id:e.job_id,task:e.task_name,name:e.job_name,job_duration:e.job_duration,total_duration:r,workspace:e.workspace,status:e.status,requested_resources:e.resources,resources_str:a,resources_str_full:e.cluster_resources_full||a,cloud:o,region:e.region,infra:s,full_infra:i,recoveries:e.recovery_count,details:e.details||e.failure_reason,user:e.user_name,user_hash:e.user_hash,submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,events:t,dag_yaml:e.user_yaml,entrypoint:e.entrypoint}}),controllerStopped:!1}}catch(e){return console.error("Error fetching managed job data:",e),{jobs:[],controllerStopped:!1}}}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,[r,a]=(0,o.useState)(null),[n,s]=(0,o.useState)(!0);return(0,o.useEffect)(()=>{(async function(){if(e)try{var t;s(!0);let r=await c.default.get(i,[{allUsers:!0}]),o=null==r?void 0:null===(t=r.jobs)||void 0===t?void 0:t.find(t=>String(t.id)===String(e));o?a({jobs:[o],controllerStopped:r.controllerStopped||!1}):a({jobs:[],controllerStopped:r.controllerStopped||!1})}catch(e){console.error("Error fetching single managed job data:",e),a({jobs:[],controllerStopped:!1})}finally{s(!1)}})()},[e,t]),{jobData:r,loading:n}}async function d(e){let t,{jobId:r,controller:o=!1,signal:c,onNewLog:s}=e,i=Date.now(),l=new Promise(e=>{let r=()=>{let o=Date.now()-i;o>=3e4?e({timeout:!0}):t=setTimeout(r,3e4-o)};t=setTimeout(r,3e4)}),d=window.location.origin,u="".concat(d).concat(n.f4),h=(async()=>{try{let e=(await fetch("".concat(u,"/jobs/logs"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({controller:o,follow:!1,job_id:r,tail:1e3}),...c?{signal:c}:{}})).body.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)break;i=Date.now();let o=new TextDecoder().decode(r);s(o)}}finally{if(!c||!c.aborted)try{e.cancel()}catch(e){"AbortError"!==e.name&&console.warn("Error canceling reader:",e)}t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),b=await Promise.race([h,l]);if(t&&clearTimeout(t),b.timeout){(0,a.C)("Log request for job ".concat(r," timed out after ").concat(30,"s of inactivity"),"warning");return}}async function u(e,t,r){let o="",c="",s="",i={};if("restartcontroller"===e)o="Restarting",c="restarted",s="jobs/queue",i={all_users:!0,refresh:!0},t="controller";else throw Error("Invalid action: ".concat(e));(0,a.C)("".concat(o," job ").concat(t,"..."),"info");let l=window.location.origin,d="".concat(l).concat(n.f4);try{try{let e=(await fetch("".concat(d,"/").concat(s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})).headers.get("X-Skypilot-Request-ID"),l=await fetch("".concat(d,"/api/get?request_id=").concat(e));if(200===l.status)(0,a.C)("Job ".concat(t," ").concat(c," successfully."),"success");else if(500===l.status)try{let e=await l.json();if(e.detail&&e.detail.error)try{let c=JSON.parse(e.detail.error);c.type&&c.type===n.Bo?(0,a.C)("".concat(o," job ").concat(t," is not supported!"),"error",1e4):c.type&&c.type===n.mF?(0,a.C)("Cluster ".concat(r," does not exist."),"error"):c.type&&c.type===n.iW?(0,a.C)("Cluster ".concat(r," is not up."),"error"):(0,a.C)("".concat(o," job ").concat(t," failed: ").concat(c.type),"error")}catch(r){(0,a.C)("".concat(o," job ").concat(t," failed: ").concat(e.detail.error),"error")}else(0,a.C)("".concat(o," job ").concat(t," failed with no details."),"error")}catch(e){(0,a.C)("".concat(o," job ").concat(t," failed with parse error."),"error")}else(0,a.C)("".concat(o," job ").concat(t," failed with status ").concat(l.status,"."),"error")}catch(e){console.error("Fetch error:",e),(0,a.C)("Network error ".concat(o," job ").concat(t,": ").concat(e.message),"error")}}catch(e){console.error("Error in handleStop:",e),(0,a.C)("Critical error ".concat(o," job ").concat(t,": ").concat(e.message),"error")}}},5821:function(e,t,r){r.d(t,{C:function(){return o}});function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,o=document.getElementById("toast-container");o||((o=document.createElement("div")).id="toast-container",o.className="fixed top-0 right-0 p-4 z-[9999] flex flex-col items-end space-y-2",document.body.appendChild(o));let a=document.createElement("div");switch(a.className="rounded-md border-l-4 p-4 shadow-md flex items-center justify-between max-w-md w-full mb-2 pointer-events-auto",t){case"success":a.className+=" bg-green-100 border-green-500 text-green-800";break;case"error":a.className+=" bg-red-100 border-red-500 text-red-800";break;case"warning":a.className+=" bg-yellow-100 border-yellow-500 text-yellow-800";break;default:a.className+=" bg-blue-100 border-blue-500 text-blue-800"}return a.innerHTML='\n <div class="flex-1 mr-2">\n <p class="text-sm font-medium">'.concat(e,'</p>\n </div>\n <button class="text-gray-500 hover:text-gray-700 focus:outline-none" aria-label="Close toast">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n '),o.appendChild(a),a.querySelector("button").addEventListener("click",()=>{o.removeChild(a)}),setTimeout(()=>{o.contains(a)&&o.removeChild(a)},r),a}},6378:function(e,t,r){r.r(t),r.d(t,{DashboardCache:function(){return a},dashboardCache:function(){return n}});let o=r(1214).ej.DEFAULT_TTL;class a{async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.ttl||o,n=!1!==r.refreshOnAccess,c=this._generateKey(e,t),s=e.name||"anonymous",i=this.cache.get(c),l=Date.now();if(i&&l-i.lastUpdated<a){let r=Math.round((l-i.lastUpdated)/1e3);return this._debug("Cache HIT for ".concat(s," (age: ").concat(r,"s, TTL: ").concat(Math.round(a/1e3),"s)")),n&&(this.cache.set(c,{data:i.data,lastUpdated:l}),this._debug("Cache TTL refreshed for ".concat(s))),this.backgroundJobs.has(c)||this._refreshInBackground(e,t,c),i.data}try{let r=await e(...t);return this.cache.set(c,{data:r,lastUpdated:l}),r}catch(e){if(i)return console.warn("Failed to fetch fresh data for ".concat(c,", returning stale data:"),e),i.data;throw e}}invalidate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this._generateKey(e,t);this.cache.delete(r),this.backgroundJobs.delete(r)}invalidateFunction(e){let t=e.name||"anonymous",r=[];for(let e of this.cache.keys())e.startsWith("".concat(t,"_"))&&r.push(e);r.forEach(e=>{this.cache.delete(e),this.backgroundJobs.delete(e)})}clear(){this.cache.clear(),this.backgroundJobs.clear()}getStats(){return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,keys:Array.from(this.cache.keys())}}getDetailedStats(){let e=Date.now(),t=[];for(let[r,o]of this.cache.entries()){let a=e-o.lastUpdated;t.push({key:r,age:Math.round(a/1e3),lastUpdated:new Date(o.lastUpdated).toISOString(),hasBackgroundJob:this.backgroundJobs.has(r)})}return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,entries:t.sort((e,t)=>e.age-t.age)}}setDebugMode(e){this.debugMode=e}_debug(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];this.debugMode&&console.log("[DashboardCache] ".concat(e),...r)}_refreshInBackground(e,t,r){this.backgroundJobs.set(r,!0),e(...t).then(e=>{this.cache.set(r,{data:e,lastUpdated:Date.now()})}).catch(e=>{console.warn("Background refresh failed for ".concat(r,":"),e)}).finally(()=>{this.backgroundJobs.delete(r)})}_generateKey(e,t){let r=function(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r);return t>>>0}(e.toString()),o=t.length>0?JSON.stringify(t):"";return"".concat(r,"_").concat(o)}constructor(){this.cache=new Map,this.backgroundJobs=new Map,this.debugMode=!1}}let n=new a;t.default=n}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8982,430],{1812:function(e,s,l){"use strict";l.d(s,{X:function(){return a}});var t=l(5893),r=l(7294);let n=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},a=e=>{let{error:s,title:l="Error",onDismiss:a}=e,[i,c]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{s&&c(!1)},[s]),!s||i)return null;let o="string"==typeof s?s:n(s);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[l,":"]})," ",o]})})]}),(0,t.jsx)("button",{onClick:()=>{c(!0),a&&a()},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,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})})]})})}},5443:function(e,s,l){"use strict";l.r(s),l.d(s,{Workspaces:function(){return D}});var t=l(5893),r=l(7294),n=l(1163),a=l(3266),i=l(8969),c=l(7324),o=l(7673),d=l(803),u=l(5739),m=l(1272),x=l(326),h=l(3850),p=l(1812),f=l(3626),j=l(3001),g=l(938),v=l(6378),N=l(1214),b=l(6856),w=l(7145);let k=e=>{let{isPrivate:s}=e;return s?(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-amber-100 text-amber-800 border border-amber-300",children:"Private"}):(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 border border-green-300",children:"Public"})},y=e=>{let{workspace:s,onDelete:l,onEdit:r,router:n,rawWorkspacesData:a,checkPermissionAndAct:i,roleLoading:c}=e,m=!0===((null==a?void 0:a[s.name])||{}).private;return(0,t.jsxs)(o.Zb,{children:[(0,t.jsx)(o.Ol,{children:(0,t.jsx)(o.ll,{className:"text-base font-normal",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-semibold",children:"Workspace:"})," ",s.name]}),(0,t.jsx)(k,{isPrivate:m})]})})}),(0,t.jsxs)(o.aY,{className:"text-sm pb-2",children:[(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(h.QT,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Clusters (Running / Total)"})]}),(0,t.jsxs)("button",{onClick:()=>{n.push({pathname:"/clusters",query:{workspace:s.name}})},className:"font-normal text-blue-600 hover:text-blue-800 hover:underline cursor-pointer",children:[s.runningClusterCount," / ",s.totalClusterCount]})]}),(0,t.jsxs)("div",{className:"py-2 flex items-center justify-between border-t border-gray-100",children:[(0,t.jsxs)("div",{className:"flex items-center text-gray-600",children:[(0,t.jsx)(h.Vp,{className:"w-4 h-4 mr-2 text-gray-500"}),(0,t.jsx)("span",{children:"Managed Jobs"})]}),(0,t.jsx)("button",{onClick:()=>{n.push({pathname:"/jobs",query:{workspace:s.name}})},className:"font-normal text-blue-600 hover:text-blue-800 hover:underline cursor-pointer",children:s.managedJobsCount})]})]}),(0,t.jsxs)("div",{className:"px-6 pb-3 text-sm pt-3",children:[(0,t.jsx)("h4",{className:"mb-2 text-xs text-gray-500 tracking-wider",children:"Enabled Infra"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:s.clouds.map(e=>(0,t.jsxs)("div",{className:"flex items-center text-gray-700",children:[(0,t.jsx)(h.Ye,{className:"w-3.5 h-3.5 mr-1.5 text-green-500"}),(0,t.jsx)("span",{children:e})]},e))})]}),(0,t.jsxs)(o.eW,{className:"flex justify-end pt-3 gap-2",children:[(0,t.jsx)(d.z,{variant:"outline",size:"sm",onClick:()=>l(s.name),disabled:"default"===s.name||c,title:"default"===s.name?"Cannot delete default workspace":"Delete workspace",className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:c?(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(u.Z,{size:12,className:"mr-1"}),(0,t.jsx)("span",{children:"Delete"})]}):"Delete"}),(0,t.jsx)(d.z,{variant:"outline",size:"sm",onClick:()=>{i("cannot edit workspace",()=>{r(s.name)})},disabled:c,children:c?(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(u.Z,{size:12,className:"mr-1"}),(0,t.jsx)("span",{children:"Edit"})]}):"Edit"})]})]},s.name)},C=e=>{let{onClick:s,checkPermissionAndAct:l,roleLoading:r}=e;return(0,t.jsx)(o.Zb,{className:"border-2 border-dashed border-sky-300 hover:border-sky-400 cursor-pointer transition-colors flex flex-col",onClick:()=>{l("cannot create workspace",s)},children:(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-full bg-sky-100 flex items-center justify-center mb-4 mx-auto",children:(0,t.jsx)("span",{className:"text-3xl text-sky-600",children:"+"})}),(0,t.jsx)("h3",{className:"text-lg font-medium text-sky-700 mb-2",children:"Create New Workspace"}),(0,t.jsx)("p",{className:"text-sm text-gray-500",children:"Set up a new workspace with custom infrastructure configurations"})]})})},"create-new")},E=e=>{let{workspaceCount:s,runningClusters:l,totalClusters:r,managedJobs:n,router:a}=e;return(0,t.jsx)("div",{className:"bg-sky-50 p-4 rounded-lg shadow mb-6",children:(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-around items-center",children:[(0,t.jsx)("div",{className:"p-2",children:(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(h.E9,{className:"w-5 h-5 mr-2 text-sky-600"}),(0,t.jsx)("span",{className:"text-sm text-gray-600",children:"Workspaces:"}),(0,t.jsx)("span",{className:"ml-1 text-xl font-semibold text-sky-700",children:s})]})}),(0,t.jsx)("div",{className:"p-2",children:(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(h.QT,{className:"w-5 h-5 mr-2 text-sky-600"}),(0,t.jsx)("span",{className:"text-sm text-gray-600",children:"Clusters (Running / Total):"}),(0,t.jsxs)("button",{onClick:()=>a.push("/clusters"),className:"ml-1 text-xl font-semibold text-blue-600 hover:text-blue-800 hover:underline cursor-pointer",children:[l," / ",r]})]})}),(0,t.jsx)("div",{className:"p-2",children:(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(h.Vp,{className:"w-5 h-5 mr-2 text-sky-600"}),(0,t.jsx)("span",{className:"text-sm text-gray-600",children:"Managed Jobs:"}),(0,t.jsx)("button",{onClick:()=>a.push("/jobs"),className:"ml-1 text-xl font-semibold text-blue-600 hover:text-blue-800 hover:underline cursor-pointer",children:n})]})})]})})},z=N.nb.REFRESH_INTERVAL;function D(){let[e,s]=(0,r.useState)([]),[l,o]=(0,r.useState)({runningClusters:0,totalClusters:0,managedJobs:0}),[h,N]=(0,r.useState)(!0),[k,D]=(0,r.useState)(null),[L,O]=(0,r.useState)(!1),[R,S]=(0,r.useState)({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),[A,T]=(0,r.useState)({open:!1,message:"",userName:""}),[Z,J]=(0,r.useState)(null),[P,W]=(0,r.useState)(!1),[M,B]=(0,r.useState)(null),[F,V]=(0,r.useState)(null),X=(0,n.useRouter)(),_=(0,j.X)(),I=async()=>{if(Z&&Date.now()-Z.timestamp<3e5)return Z;W(!0);try{let e=await w.x.get("/users/role");if(!e.ok){let s=await e.json();throw Error(s.detail||"Failed to get user role")}let s=await e.json(),l={role:s.role,name:s.name,timestamp:Date.now()};return J(l),W(!1),l}catch(e){throw W(!1),e}},q=async(e,s)=>{try{let l=await I();if("admin"!==l.role)return T({open:!0,message:e,userName:l.name.toLowerCase()}),!1;return s(),!0}catch(e){return console.error("Failed to check user role:",e),T({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},K=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&N(!0);try{let[e,l,t]=await Promise.all([v.default.get(c.fX),v.default.get(a.getClusters),v.default.get(i.getManagedJobs,[{allUsers:!0}])]);D(e);let r=Object.keys(e),n=await Promise.all(r.map(e=>v.default.get(c.yz,[e]))),d=Object.fromEntries(r.map((e,s)=>[e,n[s]])),u=Object.fromEntries(l.map(e=>[e.cluster,e.workspace||"default"])),m={};r.forEach(e=>{m[e]={name:e,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}});let x=0;l.forEach(e=>{let s=e.workspace||"default";m[s]||(m[s]={name:s,totalClusterCount:0,runningClusterCount:0,managedJobsCount:0,clouds:new Set}),m[s].totalClusterCount++,("RUNNING"===e.status||"LAUNCHING"===e.status)&&(m[s].runningClusterCount++,x++),e.cloud&&m[s].clouds.add(e.cloud)});let h=t.jobs||[],p=new Set(g.statusGroups.active),f=0;h.forEach(e=>{let s=e.cluster_name||e.resources&&e.resources.cluster_name;if(s){let l=u[s];l&&m[l]&&p.has(e.status)&&m[l].managedJobsCount++}p.has(e.status)&&f++});let j=Object.values(m).filter(e=>r.includes(e.name)).map(e=>({...e,clouds:Array.isArray(d[e.name])?d[e.name]:[]})).sort((e,s)=>e.name.localeCompare(s.name));s(j),o({runningClusters:x,totalClusters:l.length,managedJobs:f})}catch(e){console.error("Error fetching workspace data:",e),s([]),o({runningClusters:0,totalClusters:0,managedJobs:0})}e&&N(!1)};(0,r.useEffect)(()=>{(async()=>{await b.ZP.preloadForPage("workspaces"),K(!0)})();let e=setInterval(()=>{K(!1)},z);return()=>clearInterval(e)},[]);let U=e=>{q("cannot delete workspace",()=>{S({confirmOpen:!0,workspaceToDelete:e,deleting:!1,error:null})})},$=async()=>{if(R.workspaceToDelete){S(e=>({...e,deleting:!0,error:null}));try{await (0,c.zl)(R.workspaceToDelete),V('Workspace "'.concat(R.workspaceToDelete,'" deleted successfully!')),S({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null}),v.default.invalidate(c.fX),await K(!0)}catch(e){console.error("Error deleting workspace:",e),S(e=>({...e,deleting:!1,error:null})),B(e)}}},G=()=>{S({confirmOpen:!1,workspaceToDelete:null,deleting:!1,error:null})};return h&&0===e.length?(0,t.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,t.jsx)(u.Z,{}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading workspaces..."})]}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[F&&(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:F})})]}),(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsxs)("button",{type:"button",onClick:()=>V(null),className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100",children:[(0,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})]})})]})}),(0,t.jsx)(p.X,{error:M,title:"Error",onDismiss:()=>B(null)})]}),(0,t.jsxs)("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)("span",{className:"text-sky-blue leading-none",children:"Workspaces"}),(0,t.jsx)(d.z,{variant:"outline",size:"sm",onClick:()=>{q("cannot edit config",()=>{X.push("/config")})},className:"ml-4 px-2 py-1 text-xs",disabled:h||P||!k||0===Object.keys(k).length,children:P?(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(u.Z,{size:12,className:"mr-1"}),(0,t.jsx)("span",{children:"Edit All Configs"})]}):"Edit All Configs"})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[h&&(0,t.jsxs)("div",{className:"flex items-center mr-2",children:[(0,t.jsx)(u.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500 text-xs",children:"Refreshing..."})]}),(0,t.jsxs)("button",{onClick:()=>{v.default.invalidate(c.fX),v.default.invalidate(a.getClusters),v.default.invalidate(i.getManagedJobs,[{allUsers:!0}]),v.default.invalidateFunction(c.yz),K(!0)},disabled:h,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,t.jsx)(f.Z,{className:"h-4 w-4 mr-1.5"}),!_&&(0,t.jsx)("span",{children:"Refresh"})]})]})]}),(0,t.jsx)(E,{workspaceCount:e.length,runningClusters:l.runningClusters,totalClusters:l.totalClusters,managedJobs:l.managedJobs,router:X}),0!==e.length||h?(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.map(e=>(0,t.jsx)(y,{workspace:e,onDelete:U,onEdit:e=>X.push("/workspaces/".concat(e)),router:X,rawWorkspacesData:k,checkPermissionAndAct:q,roleLoading:P},e.name)),(0,t.jsx)(C,{onClick:()=>X.push("/workspace/new"),checkPermissionAndAct:q,roleLoading:P})]}):(0,t.jsxs)("div",{className:"text-center py-10",children:[(0,t.jsx)("p",{className:"text-lg text-gray-600",children:"No workspaces found."}),(0,t.jsx)("p",{className:"text-sm text-gray-500 mt-2",children:"Create a cluster to see its workspace here."})]}),k&&(0,t.jsx)(x.Vq,{open:L,onOpenChange:O,children:(0,t.jsxs)(x.cZ,{className:"sm:max-w-md md:max-w-lg lg:max-w-xl xl:max-w-2xl w-full max-h-[90vh] flex flex-col",children:[(0,t.jsx)(x.fK,{children:(0,t.jsx)(x.$N,{className:"pr-10",children:"All Workspaces Configuration"})}),(0,t.jsx)("div",{className:"flex-grow overflow-y-auto py-4",children:(0,t.jsx)("pre",{style:{backgroundColor:"#f5f5f5",padding:"16px",borderRadius:"8px",overflowX:"auto",whiteSpace:"pre",wordBreak:"normal"},children:m.ZP.dump(k,{indent:2})})})]})}),(0,t.jsx)(x.Vq,{open:A.open,onOpenChange:e=>{T(s=>({...s,open:e})),e||B(null)},children:(0,t.jsxs)(x.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,t.jsxs)(x.fK,{children:[(0,t.jsx)(x.$N,{children:"Permission Denied"}),(0,t.jsx)(x.Be,{children:P?(0,t.jsxs)("div",{className:"flex items-center py-2",children:[(0,t.jsx)(u.Z,{size:16,className:"mr-2"}),(0,t.jsx)("span",{children:"Checking permissions..."})]}):(0,t.jsx)(t.Fragment,{children:A.userName?(0,t.jsxs)(t.Fragment,{children:[A.userName," is logged in as non-admin and ",A.message,"."]}):A.message})})]}),(0,t.jsx)(x.cN,{children:(0,t.jsx)(d.z,{variant:"outline",onClick:()=>T(e=>({...e,open:!1})),disabled:P,children:"OK"})})]})}),(0,t.jsx)(x.Vq,{open:R.confirmOpen,onOpenChange:e=>{e||(G(),B(null))},children:(0,t.jsxs)(x.cZ,{className:"sm:max-w-md",children:[(0,t.jsxs)(x.fK,{children:[(0,t.jsx)(x.$N,{children:"Delete Workspace"}),(0,t.jsxs)(x.Be,{children:['Are you sure you want to delete workspace "',R.workspaceToDelete,'"? This action cannot be undone.']})]}),(0,t.jsxs)(x.cN,{children:[(0,t.jsx)(d.z,{variant:"outline",onClick:G,disabled:R.deleting,children:"Cancel"}),(0,t.jsx)(d.z,{variant:"destructive",onClick:$,disabled:R.deleting,children:R.deleting?"Deleting...":"Delete"})]})]})})]})}},1163:function(e,s,l){e.exports=l(6036)},2003:function(e,s,l){"use strict";l.d(s,{j:function(){return a}});var t=l(512);let r=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=t.W,a=(e,s)=>l=>{var t;if((null==s?void 0:s.variants)==null)return n(e,null==l?void 0:l.class,null==l?void 0:l.className);let{variants:a,defaultVariants:i}=s,c=Object.keys(a).map(e=>{let s=null==l?void 0:l[e],t=null==i?void 0:i[e];if(null===s)return null;let n=r(s)||r(t);return a[e][n]}),o=l&&Object.entries(l).reduce((e,s)=>{let[l,t]=s;return void 0===t||(e[l]=t),e},{});return n(e,c,null==s?void 0:null===(t=s.compoundVariants)||void 0===t?void 0:t.reduce((e,s)=>{let{class:l,className:t,...r}=s;return Object.entries(r).every(e=>{let[s,l]=e;return Array.isArray(l)?l.includes({...i,...o}[s]):({...i,...o})[s]===l})?[...e,l,t]:e},[]),null==l?void 0:l.class,null==l?void 0:l.className)}}}]);
@@ -1,6 +1,6 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[25,430],{9333:function(e,n,r){"use strict";r.d(n,{Z:function(){return t}});/**
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9025,430],{9333:function(e,n,r){"use strict";r.d(n,{Z:function(){return t}});/**
2
2
  * @license lucide-react v0.407.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */let t=(0,r(998).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"}]])},4042:function(e,n,r){"use strict";r.r(n),r.d(n,{Config:function(){return g}});var t=r(5893),s=r(7294),l=r(1163),a=r(803),i=r(7673),o=r(7324),c=r(1812),u=r(8799),d=r(9333),m=r(1272),f=r(6989),x=r(7145);function h(){let[e,n]=(0,s.useState)(null),[r,l]=(0,s.useState)(null),a=async()=>{let e=await x.x.get("/api/health"),r=await e.json();r.version&&n(r.version),r.commit&&l(r.commit)};return((0,s.useEffect)(()=>{a()},[]),e)?(0,t.jsx)(f.Md,{content:r?"Commit: ".concat(r):"Commit information not available",className:"text-sm text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-sm text-gray-500 cursor-help border-b border-dotted border-gray-400 inline-block",children:["Version: ",e]})}):null}var v=r(7853);function g(){let e=(0,l.useRouter)(),[n,r]=(0,s.useState)(""),[f,g]=(0,s.useState)(!0),[p,j]=(0,s.useState)(!1),[b,y]=(0,s.useState)(null),[w,N]=(0,s.useState)(!1),[k,C]=(0,s.useState)(!1),L=(0,s.useRef)(null);(0,s.useEffect)(()=>{A(),(async()=>{C(await (0,v.TO)())})()},[]),(0,s.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let A=async()=>{g(!0),y(null);try{let e=await (0,o.iE)();0===Object.keys(e).length?r(""):r(m.ZP.dump(e,{indent:2}))}catch(e){console.error("Error loading config:",e),y(e)}finally{g(!1)}},S=async()=>{j(!0),y(null),L.current&&(clearTimeout(L.current),L.current=null);try{let e=await x.x.get("/users/role");if(!e.ok){let n=await e.json();throw Error(n.detail||"Failed to get user role")}let r=await e.json(),t=r.role;if("admin"!=t){y(Error("".concat(r.name," is logged in as non-admin and cannot edit config"))),j(!1);return}let s=m.ZP.load(n);if(null==s&&(s={}),"object"!=typeof s||Array.isArray(s)){let e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.";Array.isArray(s),e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.",y(Error(e)),j(!1);return}await (0,o.rF)(s),N(!0),L.current=setTimeout(()=>{N(!1),L.current=null},5e3)}catch(e){console.error("Error saving config:",e),y(e)}finally{j(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsx)("div",{className:"text-base flex items-center",children:(0,t.jsx)("span",{className:"text-sky-blue",children:"SkyPilot API Server"})}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"text-sm flex items-center",children:(f||p)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(u.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:p?"Applying...":"Loading..."})]})}),k&&(0,t.jsxs)("button",{onClick:()=>{let e=(0,v.ki)(),n=window.location.hostname;window.open("".concat(e,"/d/skypilot-apiserver-overview/skypilot-api-server?orgId=1&from=now-1h&to=now&timezone=browser&var-app=").concat(n),"_blank")},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-white bg-sky-blue-bright border border-transparent rounded-md shadow-sm hover:bg-sky-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-sky-blue mr-4",children:[(0,t.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"View API Server Metrics"]}),(0,t.jsx)(h,{})]})]}),(0,t.jsxs)(i.Zb,{className:"w-full",children:[(0,t.jsx)(i.Ol,{children:(0,t.jsx)(i.ll,{className:"text-base font-normal flex items-center justify-between",children:(0,t.jsx)("span",{children:"Edit SkyPilot API Server Configuration"})})}),(0,t.jsxs)(i.aY,{className:"space-y-4",children:[(0,t.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Refer to the"," ",(0,t.jsx)("a",{href:"https://docs.skypilot.co/en/latest/reference/config.html",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"SkyPilot Docs"})," ","for details. The configuration should be in YAML format."]}),w&&(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:"Configuration saved successfully!"})})]}),(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,t.jsxs)("button",{type:"button",onClick:()=>{N(!1),L.current&&(clearTimeout(L.current),L.current=null)},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,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})]})})})]})}),b&&(0,t.jsx)("div",{className:"mb-6",children:(0,t.jsx)(c.X,{error:b,title:"Failed to apply new configuration",onDismiss:()=>y(null)})}),(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("textarea",{value:n,onChange:e=>r(e.target.value),className:"w-full h-96 p-3 border border-gray-300 rounded font-mono text-sm resize-vertical focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:f?"Loading configuration...":"# Enter SkyPilot configuration in YAML format\n# Example:\n# kubernetes:\n# allowed_contexts: [default, my-context]",disabled:f||p})}),(0,t.jsxs)("div",{className:"flex justify-end space-x-3 pt-3",children:[(0,t.jsx)(a.z,{variant:"outline",onClick:()=>{e.push("/workspaces")},disabled:p,children:"Cancel"}),(0,t.jsx)(a.z,{onClick:S,disabled:f||p,className:"inline-flex items-center bg-blue-600 hover:bg-blue-700 text-white",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Z,{size:16,className:"mr-2"}),"Applying..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(d.Z,{className:"w-4 h-4 mr-1.5"}),"Apply"]})})]})]})]})]})}},1812:function(e,n,r){"use strict";r.d(n,{X:function(){return a}});var t=r(5893),s=r(7294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let n=e.message;return n.includes("failed:")&&(n=n.split("failed:")[1].trim()),n},a=e=>{let{error:n,title:r="Error",onDismiss:a}=e,[i,o]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{n&&o(!1)},[n]),!n||i)return null;let c="string"==typeof n?n:l(n);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",c]})})]}),(0,t.jsx)("button",{onClick:()=>{o(!0),a&&a()},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,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})})]})})}},7853:function(e,n,r){"use strict";r.d(n,{TO:function(){return l},ki:function(){return a}});let t=null,s=null,l=async()=>null!==t?t:s||(s=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),n=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==n.status}catch(e){return console.debug("Grafana availability check failed:",e),t=!1,!1}finally{s=null}})()),a=()=>"".concat(window.location.origin,"/grafana")},1163:function(e,n,r){e.exports=r(6036)},2003:function(e,n,r){"use strict";r.d(n,{j:function(){return a}});var t=r(512);let s=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,l=t.W,a=(e,n)=>r=>{var t;if((null==n?void 0:n.variants)==null)return l(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:a,defaultVariants:i}=n,o=Object.keys(a).map(e=>{let n=null==r?void 0:r[e],t=null==i?void 0:i[e];if(null===n)return null;let l=s(n)||s(t);return a[e][l]}),c=r&&Object.entries(r).reduce((e,n)=>{let[r,t]=n;return void 0===t||(e[r]=t),e},{});return l(e,o,null==n?void 0:null===(t=n.compoundVariants)||void 0===t?void 0:t.reduce((e,n)=>{let{class:r,className:t,...s}=n;return Object.entries(s).every(e=>{let[n,r]=e;return Array.isArray(r)?r.includes({...i,...c}[n]):({...i,...c})[n]===r})?[...e,r,t]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}}]);
6
+ */let t=(0,r(998).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"}]])},4042:function(e,n,r){"use strict";r.r(n),r.d(n,{Config:function(){return g}});var t=r(5893),s=r(7294),l=r(1163),a=r(803),i=r(7673),o=r(7324),c=r(1812),u=r(5739),d=r(9333),m=r(1272),f=r(6989),x=r(7145);function h(){let[e,n]=(0,s.useState)(null),[r,l]=(0,s.useState)(null),a=async()=>{let e=await x.x.get("/api/health"),r=await e.json();r.version&&n(r.version),r.commit&&l(r.commit)};return((0,s.useEffect)(()=>{a()},[]),e)?(0,t.jsx)(f.Md,{content:r?"Commit: ".concat(r):"Commit information not available",className:"text-sm text-muted-foreground",children:(0,t.jsxs)("div",{className:"text-sm text-gray-500 cursor-help border-b border-dotted border-gray-400 inline-block",children:["Version: ",e]})}):null}var v=r(7853);function g(){let e=(0,l.useRouter)(),[n,r]=(0,s.useState)(""),[f,g]=(0,s.useState)(!0),[p,j]=(0,s.useState)(!1),[b,y]=(0,s.useState)(null),[w,N]=(0,s.useState)(!1),[k,C]=(0,s.useState)(!1),L=(0,s.useRef)(null);(0,s.useEffect)(()=>{A(),(async()=>{C(await (0,v.TO)())})()},[]),(0,s.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let A=async()=>{g(!0),y(null);try{let e=await (0,o.iE)();0===Object.keys(e).length?r(""):r(m.ZP.dump(e,{indent:2}))}catch(e){console.error("Error loading config:",e),y(e)}finally{g(!1)}},S=async()=>{j(!0),y(null),L.current&&(clearTimeout(L.current),L.current=null);try{let e=await x.x.get("/users/role");if(!e.ok){let n=await e.json();throw Error(n.detail||"Failed to get user role")}let r=await e.json(),t=r.role;if("admin"!=t){y(Error("".concat(r.name," is logged in as non-admin and cannot edit config"))),j(!1);return}let s=m.ZP.load(n);if(null==s&&(s={}),"object"!=typeof s||Array.isArray(s)){let e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.";Array.isArray(s),e="Invalid config structure: Configuration must be a mapping (key-value pairs) in YAML format.",y(Error(e)),j(!1);return}await (0,o.rF)(s),N(!0),L.current=setTimeout(()=>{N(!1),L.current=null},5e3)}catch(e){console.error("Error saving config:",e),y(e)}finally{j(!1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,t.jsx)("div",{className:"text-base flex items-center",children:(0,t.jsx)("span",{className:"text-sky-blue",children:"SkyPilot API Server"})}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"text-sm flex items-center",children:(f||p)&&(0,t.jsxs)("div",{className:"flex items-center mr-4",children:[(0,t.jsx)(u.Z,{size:15,className:"mt-0"}),(0,t.jsx)("span",{className:"ml-2 text-gray-500",children:p?"Applying...":"Loading..."})]})}),k&&(0,t.jsxs)("button",{onClick:()=>{let e=(0,v.ki)(),n=window.location.hostname;window.open("".concat(e,"/d/skypilot-apiserver-overview/skypilot-api-server?orgId=1&from=now-1h&to=now&timezone=browser&var-app=").concat(n),"_blank")},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-white bg-sky-blue-bright border border-transparent rounded-md shadow-sm hover:bg-sky-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-sky-blue mr-4",children:[(0,t.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),"View API Server Metrics"]}),(0,t.jsx)(h,{})]})]}),(0,t.jsxs)(i.Zb,{className:"w-full",children:[(0,t.jsx)(i.Ol,{children:(0,t.jsx)(i.ll,{className:"text-base font-normal flex items-center justify-between",children:(0,t.jsx)("span",{children:"Edit SkyPilot API Server Configuration"})})}),(0,t.jsxs)(i.aY,{className:"space-y-4",children:[(0,t.jsxs)("p",{className:"text-sm text-gray-600 mb-3",children:["Refer to the"," ",(0,t.jsx)("a",{href:"https://docs.skypilot.co/en/latest/reference/config.html",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"SkyPilot Docs"})," ","for details. The configuration should be in YAML format."]}),w&&(0,t.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsx)("p",{className:"text-sm font-medium text-green-800",children:"Configuration saved successfully!"})})]}),(0,t.jsx)("div",{className:"ml-auto pl-3",children:(0,t.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,t.jsxs)("button",{type:"button",onClick:()=>{N(!1),L.current&&(clearTimeout(L.current),L.current=null)},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,t.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,t.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})]})})})]})}),b&&(0,t.jsx)("div",{className:"mb-6",children:(0,t.jsx)(c.X,{error:b,title:"Failed to apply new configuration",onDismiss:()=>y(null)})}),(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("textarea",{value:n,onChange:e=>r(e.target.value),className:"w-full h-96 p-3 border border-gray-300 rounded font-mono text-sm resize-vertical focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:f?"Loading configuration...":"# Enter SkyPilot configuration in YAML format\n# Example:\n# kubernetes:\n# allowed_contexts: [default, my-context]",disabled:f||p})}),(0,t.jsxs)("div",{className:"flex justify-end space-x-3 pt-3",children:[(0,t.jsx)(a.z,{variant:"outline",onClick:()=>{e.push("/workspaces")},disabled:p,children:"Cancel"}),(0,t.jsx)(a.z,{onClick:S,disabled:f||p,className:"inline-flex items-center bg-blue-600 hover:bg-blue-700 text-white",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Z,{size:16,className:"mr-2"}),"Applying..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(d.Z,{className:"w-4 h-4 mr-1.5"}),"Apply"]})})]})]})]})]})}},1812:function(e,n,r){"use strict";r.d(n,{X:function(){return a}});var t=r(5893),s=r(7294);let l=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let n=e.message;return n.includes("failed:")&&(n=n.split("failed:")[1].trim()),n},a=e=>{let{error:n,title:r="Error",onDismiss:a}=e,[i,o]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{n&&o(!1)},[n]),!n||i)return null;let c="string"==typeof n?n:l(n);return(0,t.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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,t.jsx)("div",{className:"ml-3",children:(0,t.jsxs)("div",{className:"text-sm text-red-800",children:[(0,t.jsxs)("strong",{children:[r,":"]})," ",c]})})]}),(0,t.jsx)("button",{onClick:()=>{o(!0),a&&a()},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,t.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.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"})})})]})})}},7853:function(e,n,r){"use strict";r.d(n,{TO:function(){return l},ki:function(){return a}});let t=null,s=null,l=async()=>null!==t?t:s||(s=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),n=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==n.status}catch(e){return console.debug("Grafana availability check failed:",e),t=!1,!1}finally{s=null}})()),a=()=>"".concat(window.location.origin,"/grafana")},1163:function(e,n,r){e.exports=r(6036)},2003:function(e,n,r){"use strict";r.d(n,{j:function(){return a}});var t=r(512);let s=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,l=t.W,a=(e,n)=>r=>{var t;if((null==n?void 0:n.variants)==null)return l(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:a,defaultVariants:i}=n,o=Object.keys(a).map(e=>{let n=null==r?void 0:r[e],t=null==i?void 0:i[e];if(null===n)return null;let l=s(n)||s(t);return a[e][l]}),c=r&&Object.entries(r).reduce((e,n)=>{let[r,t]=n;return void 0===t||(e[r]=t),e},{});return l(e,o,null==n?void 0:null===(t=n.compoundVariants)||void 0===t?void 0:t.reduce((e,n)=>{let{class:r,className:t,...s}=n;return Object.entries(s).every(e=>{let[n,r]=e;return Array.isArray(r)?r.includes({...i,...c}[n]):({...i,...c})[n]===r})?[...e,r,t]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[938],{938:function(e,s,t){t.r(s),t.d(s,{ClusterJobs:function(){return W},ManagedJobs:function(){return U},ManagedJobsTable:function(){return q},Status2Actions:function(){return z},filterJobsByName:function(){return M},filterJobsByUser:function(){return D},filterJobsByWorkspace:function(){return A},statusGroups:function(){return _}});var r=t(5893),n=t(7294),a=t(1163),l=t(1664),i=t.n(l),c=t(5739),o=t(803),d=t(7673),u=t(8764),h=t(6989),x=t(8969),m=t(3266),j=t(7324),p=t(3081);t(9470);var f=t(3626),g=t(3293),b=t(6521),w=t(3610),N=t(9284),y=t(4545),v=t(9307),k=t(546),C=t(3001),S=t(8950),L=t(6378),E=t(6856);let _={active:["PENDING","RUNNING","RECOVERING","SUBMITTED","STARTING","CANCELLING"],finished:["SUCCEEDED","FAILED","CANCELLED","FAILED_SETUP","FAILED_PRECHECKS","FAILED_NO_RESOURCE","FAILED_CONTROLLER"]},I="__ALL_WORKSPACES__",R="__ALL_USERS__";function M(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.name||"").toLowerCase().includes(t))}function A(e,s){return s&&s!==I?e.filter(e=>(e.workspace||"default").toLowerCase()===s.toLowerCase()):e}function D(e,s){return s&&s!==R?e.filter(e=>(e.user_hash||e.user)===s):e}let O=(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},F=e=>{if(!e)return"-";let s=e instanceof Date?e:new Date(1e3*e);return(0,r.jsx)(h.Zg,{date:s})};function U(){var e;let s=(0,a.useRouter)(),[t,l]=(0,n.useState)(!1),o=n.useRef(null),[d,u]=(0,n.useState)({isOpen:!1,title:"",message:"",onConfirm:null}),m=(0,C.X)(),[g,b]=(0,n.useState)(I),[w,y]=(0,n.useState)(R),[v,k]=(0,n.useState)(""),[_,M]=(0,n.useState)([]),[A,D]=(0,n.useState)([]);(0,n.useEffect)(()=>{s.isReady&&(s.query.workspace&&b(Array.isArray(s.query.workspace)?s.query.workspace[0]:s.query.workspace),s.query.user&&y(Array.isArray(s.query.user)?s.query.user[0]:s.query.user),s.query.name&&k(Array.isArray(s.query.name)?s.query.name[0]:s.query.name))},[s.isReady,s.query.workspace,s.query.user,s.query.name]);let F=(e,t,r)=>{let n={...s.query};e&&e!==I?n.workspace=e:delete n.workspace,t&&t!==R?n.user=t:delete n.user,r&&""!==r.trim()?n.name=r.trim():delete n.name,s.replace({pathname:s.pathname,query:n},void 0,{shallow:!0})},U=e=>{k(e),F(g,w,e)};return(0,n.useEffect)(()=>{(async()=>{try{await E.ZP.preloadForPage("jobs");let e=await L.default.get(j.fX),s=Object.keys(e),t=(await L.default.get(x.getManagedJobs,[{allUsers:!0}])).jobs||[],r=[...new Set(t.map(e=>e.workspace||"default").filter(e=>e))],n=new Set(s);r.forEach(e=>n.add(e)),M(Array.from(n).sort());let a=await L.default.get(p.R),l=[...new Set(t.map(e=>({userId:e.user_hash||e.user,username:e.user})).filter(e=>e.userId)).values()],i=new Map;a.forEach(e=>{i.set(e.userId,{userId:e.userId,username:e.username,display:O(e.username,e.userId)})}),l.forEach(e=>{i.has(e.userId)||i.set(e.userId,{userId:e.userId,username:e.username,display:O(e.username,e.userId)})}),D(Array.from(i.values()).sort((e,s)=>e.display.localeCompare(s.display)))}catch(e){console.error("Error fetching data for filters:",e),M(["default"]),D([])}})()},[]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(i(),{href:"/jobs",className:"text-sky-blue hover:underline leading-none",children:"Managed Jobs"}),(0,r.jsxs)("div",{className:"relative ml-4 mr-2",children:[(0,r.jsx)("input",{type:"text",placeholder:"Filter by job name",value:v,onChange:e=>U(e.target.value),className:"h-8 w-48 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"}),v&&(0,r.jsx)("button",{onClick:()=>U(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",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"})})})]}),(0,r.jsxs)(S.Ph,{value:g,onValueChange:e=>{b(e),F(e,w,v)},children:[(0,r.jsx)(S.i4,{className:"h-8 w-48 ml-2 mr-2 text-sm border-none focus:ring-0 focus:outline-none",children:(0,r.jsx)(S.ki,{placeholder:"Filter by workspace...",children:g===I?"All Workspaces":g})}),(0,r.jsxs)(S.Bw,{children:[(0,r.jsx)(S.Ql,{value:I,children:"All Workspaces"}),_.map(e=>(0,r.jsx)(S.Ql,{value:e,children:e},e))]})]}),(0,r.jsxs)(S.Ph,{value:w,onValueChange:e=>{y(e),F(g,e,v)},children:[(0,r.jsx)(S.i4,{className:"h-8 w-48 ml-2 mr-2 text-sm border-none focus:ring-0 focus:outline-none",children:(0,r.jsx)(S.ki,{placeholder:"Filter by user...",children:w===R?"All Users":(null===(e=A.find(e=>e.userId===w))||void 0===e?void 0:e.display)||w})}),(0,r.jsxs)(S.Bw,{children:[(0,r.jsx)(S.Ql,{value:R,children:"All Users"}),A.map(e=>(0,r.jsx)(S.Ql,{value:e.userId,children:e.display},e.userId))]})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[t&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(c.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:()=>{L.default.invalidate(x.getManagedJobs,[{allUsers:!0}]),L.default.invalidate(j.fX),L.default.invalidate(p.R),o.current&&o.current()},disabled:t,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",title:"Refresh",children:[(0,r.jsx)(f.Z,{className:"h-4 w-4 mr-1.5"}),!m&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsx)(q,{refreshInterval:h.yc,setLoading:l,refreshDataRef:o,workspaceFilter:g,userFilter:w,nameFilter:v}),(0,r.jsx)(N.cV,{isOpen:d.isOpen,onClose:()=>u({...d,isOpen:!1}),onConfirm:d.onConfirm,title:d.title,message:d.message})]})}function q(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,workspaceFilter:l,userFilter:j,nameFilter:p}=e,[f,b]=(0,n.useState)([]),[w,C]=(0,n.useState)({key:null,direction:"ascending"}),[S,E]=(0,n.useState)(!1),[I,R]=(0,n.useState)(!0),[O,U]=(0,n.useState)(1),[q,W]=(0,n.useState)(10),[Z,B]=(0,n.useState)(null),T=(0,n.useRef)(null),[H,G]=(0,n.useState)([]),[V,Q]=(0,n.useState)({}),[X,K]=(0,n.useState)(!1),[Y,$]=(0,n.useState)(!1),[ee,es]=(0,n.useState)(!1),[et,er]=(0,n.useState)("all"),[en,ea]=(0,n.useState)(!0),[el,ei]=(0,n.useState)({isOpen:!1,title:"",message:"",onConfirm:null}),ec=async()=>{ei({isOpen:!0,title:"Restart Controller",message:"Are you sure you want to restart the controller?",onConfirm:async()=>{try{es(!0),E(!0),await (0,x.Ce)("restartcontroller"),await eo()}catch(e){console.error("Error restarting controller:",e)}finally{es(!1),E(!1)}}})},eo=n.useCallback(async()=>{E(!0),t(!0);try{let[e,s]=await Promise.all([L.default.get(x.getManagedJobs,[{allUsers:!0}]),L.default.get(m.getClusters)]),{jobs:t=[],controllerStopped:r=!1}=e||{},n=null==s?void 0:s.find(e=>(0,y.Ym)(e.cluster)),a=n?n.status:"NOT_FOUND",l=!1;"STOPPED"==a&&r&&(l=!0),"LAUNCHING"==a?$(!0):$(!1),b(t),K(l),R(!1)}catch(e){console.error("Error fetching data:",e),b([]),K(!1),R(!1)}finally{E(!1),t(!1)}},[t]);n.useEffect(()=>{a&&(a.current=eo)},[a,eo]),(0,n.useEffect)(()=>{b([]);let e=!0;eo();let t=setInterval(()=>{e&&eo()},s);return()=>{e=!1,clearInterval(t)}},[s,eo]),(0,n.useEffect)(()=>{U(1)},[et,null==f?void 0:f.length]),(0,n.useEffect)(()=>{G([]),ea(!0)},[et]);let ed=e=>{let s="ascending";w.key===e&&"ascending"===w.direction&&(s="descending"),C({key:e,direction:s})},eu=e=>w.key===e?"ascending"===w.direction?" ↑":" ↓":"";n.useMemo(()=>{let e=f||[];return{active:e.filter(e=>_.active.includes(e.status)).length,finished:e.filter(e=>_.finished.includes(e.status)).length}},[f]);let eh=e=>H.length>0?H.includes(e):"all"===et||_[et].includes(e),ex=n.useMemo(()=>{let e=A(f,l);return(e=M(e=D(e,j),p),H.length>0)?e.filter(e=>H.includes(e.status)):en?"all"===et?e:e.filter(e=>_[et].includes(e.status)):[]},[f,et,H,en,l,j,p]),em=n.useMemo(()=>w.key?[...ex].sort((e,s)=>e[w.key]<s[w.key]?"ascending"===w.direction?-1:1:e[w.key]>s[w.key]?"ascending"===w.direction?1:-1:0):ex,[ex,w]),ej=Math.ceil(em.length/q),ep=(O-1)*q,ef=ep+q,eg=em.slice(ep,ef),eb=e=>{if(H.includes(e)){let s=H.filter(s=>s!==e);0===s.length?(ea(!0),G([])):(G(s),ea(!1))}else G([...H,e]),ea(!1)};return(0,n.useEffect)(()=>{Q((f||[]).reduce((e,s)=>(e[s.status]=(e[s.status]||0)+1,e),{}))},[f]),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"flex flex-col space-y-1 mb-1",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center text-sm mb-1",children:[(0,r.jsx)("span",{className:"mr-2 text-sm font-medium",children:"Statuses:"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[!S&&(!f||0===f.length)&&!I&&(0,r.jsx)("span",{className:"text-gray-500 mr-2",children:"No jobs found"}),Object.entries(V).map(e=>{let[s,t]=e;return(0,r.jsxs)("button",{onClick:()=>eb(s),className:"px-3 py-1 rounded-full flex items-center space-x-2 ".concat(eh(s)||H.includes(s)?(0,v.Cl)(s):"bg-gray-50 text-gray-600 hover:bg-gray-100"),children:[(0,r.jsx)("span",{children:s}),(0,r.jsx)("span",{className:"text-xs ".concat(eh(s)||H.includes(s)?"bg-white/50":"bg-gray-200"," px-1.5 py-0.5 rounded"),children:t})]},s)}),f&&f.length>0&&(0,r.jsxs)("div",{className:"flex items-center ml-2 gap-2",children:[(0,r.jsx)("span",{className:"text-gray-500",children:"("}),(0,r.jsx)("button",{onClick:()=>{er("all"),G([]),ea(!0)},className:"text-sm font-medium ".concat("all"===et&&en?"text-purple-700 underline":"text-gray-600 hover:text-purple-700 hover:underline"),children:"show all jobs"}),(0,r.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,r.jsx)("button",{onClick:()=>{er("active"),G([]),ea(!0)},className:"text-sm font-medium ".concat("active"===et&&en?"text-green-700 underline":"text-gray-600 hover:text-green-700 hover:underline"),children:"show all active jobs"}),(0,r.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,r.jsx)("button",{onClick:()=>{er("finished"),G([]),ea(!0)},className:"text-sm font-medium ".concat("finished"===et&&en?"text-blue-700 underline":"text-gray-600 hover:text-blue-700 hover:underline"),children:"show all finished jobs"}),(0,r.jsx)("span",{className:"text-gray-500",children:")"})]})]})]})}),(0,r.jsx)(d.Zb,{children:(0,r.jsxs)(u.iA,{children:[(0,r.jsx)(u.xD,{children:(0,r.jsxs)(u.SC,{children:[(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("id"),children:["ID",eu("id")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("name"),children:["Name",eu("name")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("user"),children:["User",eu("user")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("workspace"),children:["Workspace",eu("workspace")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("submitted_at"),children:["Submitted",eu("submitted_at")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("job_duration"),children:["Duration",eu("job_duration")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("status"),children:["Status",eu("status")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("resources_str"),children:["Requested",eu("resources_str")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("infra"),children:["Infra",eu("infra")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("cluster"),children:["Resources",eu("cluster")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ed("recoveries"),children:["Recoveries",eu("recoveries")]}),(0,r.jsx)(u.ss,{children:"Details"}),(0,r.jsx)(u.ss,{children:"Logs"})]})}),(0,r.jsx)(u.RM,{children:S||I?(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:12,className:"text-center py-6 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(c.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]})})}):eg.length>0?(0,r.jsx)(r.Fragment,{children:eg.map(e=>(0,r.jsxs)(n.Fragment,{children:[(0,r.jsxs)(u.SC,{children:[(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.id})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.name})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(k.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/workspaces",className:"text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(u.pj,{children:F(e.submitted_at)}),(0,r.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(v.OE,{status:e.status})}),(0,r.jsx)(u.pj,{children:e.requested_resources}),(0,r.jsx)(u.pj,{children:e.infra&&"-"!==e.infra?(0,r.jsx)(h.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(i(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud||e.infra.split("(")[0].trim()}),e.infra.includes("(")&&(0,r.jsx)("span",{children:" "+e.infra.substring(e.infra.indexOf("("))})]})}):(0,r.jsx)("span",{children:e.infra||"-"})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(h.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)(u.pj,{children:e.recoveries}),(0,r.jsx)(u.pj,{children:e.details?(0,r.jsx)(P,{text:e.details,rowId:e.id,expandedRowId:Z,setExpandedRowId:B}):"-"}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(z,{jobParent:"/jobs",jobId:e.id,managed:!0})})]}),Z===e.id&&(0,r.jsx)(J,{text:e.details,colSpan:12,innerRef:T})]},e.id))}):(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:12,className:"text-center py-6",children:(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[Y&&(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,r.jsx)("p",{className:"text-gray-700",children:"The managed job controller is launching. It will be ready shortly."}),(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(c.Z,{size:12,className:"mr-2"}),(0,r.jsx)("span",{className:"text-gray-500",children:"Launching..."})]})]}),!X&&!Y&&(0,r.jsx)("p",{className:"text-gray-500",children:"No active jobs"}),X&&(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,r.jsx)("p",{className:"text-gray-700",children:"The managed job controller has been stopped. Restart to check the latest job status."}),(0,r.jsx)(o.z,{variant:"outline",size:"sm",onClick:ec,className:"text-sky-blue hover:text-sky-blue-bright",disabled:S||ee,children:ee?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.Z,{className:"h-4 w-4 mr-2"}),"Restart Controller"]})})]})]})})})})]})}),em&&em.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:q,onChange:e=>{W(parseInt(e.target.value,10)),U(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.jsxs)("div",{children:[ep+1," – ",Math.min(ef,em.length)," of"," ",em.length]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{U(e=>Math.max(e-1,1))},disabled:1===O,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)(o.z,{variant:"ghost",size:"icon",onClick:()=>{U(e=>Math.min(e+1,ej))},disabled:O===ej||0===ej,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"})})})]})]})}),(0,r.jsx)(N.cV,{isOpen:el.isOpen,onClose:()=>ei({...el,isOpen:!1}),onConfirm:el.onConfirm,title:el.title,message:el.message,confirmClassName:"bg-blue-600 hover:bg-blue-700 text-white"})]})}function z(e){let{withLabel:s=!1,jobParent:t,jobId:n,managed:l}=e,i=(0,a.useRouter)(),c=(e,s)=>{e.preventDefault(),e.stopPropagation(),i.push({pathname:"".concat(t,"/").concat(n),query:{tab:s}})};return(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsx)(h.WH,{content:"View Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("button",{onClick:e=>c(e,"logs"),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,r.jsx)(b.Z,{className:"w-4 h-4"}),s&&(0,r.jsx)("span",{className:"ml-1.5",children:"Logs"})]})},"logs"),l&&(0,r.jsx)(h.WH,{content:"View Controller Logs",className:"capitalize text-sm text-muted-foreground",children:(0,r.jsxs)("button",{onClick:e=>c(e,"controllerlogs"),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,r.jsx)(w.Z,{className:"w-4 h-4"}),s&&(0,r.jsx)("span",{className:"ml-2",children:"Controller Logs"})]})},"controllerlogs")]})}function W(e){let{clusterName:s,clusterJobData:t,loading:a,refreshClusterJobsOnly:l,userFilter:x=null,nameFilter:m=null}=e,[j,p]=(0,n.useState)(null),[g,b]=(0,n.useState)({key:null,direction:"ascending"}),[w,N]=(0,n.useState)(1),[y,C]=(0,n.useState)(10),S=(0,n.useRef)(null),[L,E]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=e=>{j&&S.current&&!S.current.contains(e.target)&&p(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[j]);let _=n.useMemo(()=>{let e=t||[];return x&&x!==R&&(e=D(e,x)),m&&(e=M(e,m)),e},[t,x,m]);(0,n.useEffect)(()=>{JSON.stringify(t)!==JSON.stringify(L)&&E(t)},[t,L]);let I=n.useMemo(()=>g.key?[..._].sort((e,s)=>e[g.key]<s[g.key]?"ascending"===g.direction?-1:1:e[g.key]>s[g.key]?"ascending"===g.direction?1:-1:0):_,[_,g]),A=e=>{let s="ascending";g.key===e&&"ascending"===g.direction&&(s="descending"),b({key:e,direction:s})},O=e=>g.key===e?"ascending"===g.direction?" ↑":" ↓":"",U=Math.ceil(I.length/y),q=(w-1)*y,W=q+y,Z=I.slice(q,W);return(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)(d.Zb,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Cluster Jobs"}),(0,r.jsx)("div",{className:"flex items-center",children:l&&(0,r.jsxs)("button",{onClick:l,disabled:a,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center text-sm ml-2",children:[(0,r.jsx)(f.Z,{className:"w-4 h-4 mr-1"}),"Refresh Jobs"]})})]}),(0,r.jsxs)(u.iA,{children:[(0,r.jsx)(u.xD,{children:(0,r.jsxs)(u.SC,{children:[(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("id"),children:["ID",O("id")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("job"),children:["Name",O("job")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("user"),children:["User",O("user")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("workspace"),children:["Workspace",O("workspace")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("submitted_at"),children:["Submitted",O("submitted_at")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("job_duration"),children:["Duration",O("job_duration")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("status"),children:["Status",O("status")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>A("resources"),children:["Resources",O("resources")]}),(0,r.jsx)(u.ss,{className:"whitespace-nowrap",children:"Logs"})]})}),(0,r.jsx)(u.RM,{children:a?(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:9,className:"text-center py-12 text-gray-500",children:(0,r.jsxs)("div",{className:"flex justify-center items-center",children:[(0,r.jsx)(c.Z,{size:24,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading cluster jobs..."})]})})}):Z.length>0?Z.map(e=>(0,r.jsxs)(n.Fragment,{children:[(0,r.jsxs)(u.SC,{className:j===e.id?"selected-row":"",children:[(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:e.id})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:(0,r.jsx)(P,{text:e.job||"Unnamed job",rowId:e.id,expandedRowId:j,setExpandedRowId:p})})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(k.H,{username:e.user,userHash:e.user_hash})}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(i(),{href:"/workspaces",className:"text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,r.jsx)(u.pj,{children:F(e.submitted_at)}),(0,r.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(v.OE,{status:e.status})}),(0,r.jsx)(u.pj,{children:e.resources}),(0,r.jsx)(u.pj,{className:"flex content-center items-center",children:(0,r.jsx)(z,{jobParent:"/clusters/".concat(s),jobId:e.id,managed:!1})})]}),j===e.id&&(0,r.jsx)(J,{text:e.job||"Unnamed job",colSpan:9,innerRef:S})]},e.id)):(0,r.jsx)(u.SC,{children:(0,r.jsx)(u.pj,{colSpan:8,className:"text-center py-6 text-gray-500",children:"No jobs found"})})})]})]}),I&&I.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:y,onChange:e=>{C(parseInt(e.target.value,10)),N(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:5,children:"5"}),(0,r.jsx)("option",{value:10,children:"10"}),(0,r.jsx)("option",{value:20,children:"20"}),(0,r.jsx)("option",{value:50,children:"50"})]}),(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.jsxs)("div",{children:[q+1," – ",Math.min(W,I.length)," of"," ",I.length]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{N(e=>Math.max(e-1,1))},disabled:1===w,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)(o.z,{variant:"ghost",size:"icon",onClick:()=>{N(e=>Math.min(e+1,U))},disabled:w===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"})})})]})]})})]})}function J(e){let{text:s,colSpan:t,innerRef:n}=e;return(0,r.jsx)(u.SC,{className:"expanded-details",children:(0,r.jsx)(u.pj,{colSpan:t,children:(0,r.jsx)("div",{className:"p-4 bg-gray-50 rounded-md border border-gray-200",ref:n,children:(0,r.jsx)("div",{className:"flex justify-between items-start",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Full Details"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-700",style:{whiteSpace:"pre-wrap"},children:s})]})})})})})}function P(e){let{text:s,rowId:t,expandedRowId:a,setExpandedRowId:l}=e,i=s||"",c=i.length>50,o=a===t,d=c?"".concat(i.substring(0,50)):i,u=(0,n.useRef)(null);return(0,r.jsxs)("div",{className:"truncated-details relative max-w-full flex items-center",children:[(0,r.jsx)("span",{className:"truncate",children:d}),c&&(0,r.jsx)("button",{ref:u,type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(o?null:t)},className:"text-blue-600 hover:text-blue-800 font-medium ml-1 flex-shrink-0","data-button-type":"show-more-less",children:o?"... show less":"... show more"})]})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9470],{9470:function(e,s,t){t.r(s),t.d(s,{Layout:function(){return N}});var r=t(5893),n=t(7294),a=t(5675),c=t.n(a),l=t(1163),i=t(1664),o=t.n(i),h=t(3850),d=t(355),x=t(6021),u=t(3225),m=t(6989),f=t(3001);let p=(0,n.createContext)(null);function j(e){let{children:s}=e,[t,a]=(0,n.useState)(!0),[c,l]=(0,n.useState)(null),[i,o]=(0,n.useState)(null),h=window.location.origin,d="".concat(h).concat(u.f4);return(0,n.useEffect)(()=>{fetch("".concat(d,"/api/health")).then(e=>e.json()).then(e=>{e.user&&e.user.name&&(l(e.user.name),(async()=>{try{let e=await fetch("".concat(d,"/users/role"));if(e.ok){let s=await e.json();s.role&&o(s.role)}}catch(e){console.log("Could not fetch user role:",e)}})())}).catch(e=>{console.error("Error fetching user data:",e)})},[d]),(0,r.jsx)(p.Provider,{value:{isSidebarOpen:t,toggleSidebar:()=>{a(e=>!e)},userEmail:c,userRole:i},children:s})}function g(){let e,s;let t=(0,l.useRouter)(),a=(0,f.X)(),{userEmail:i,userRole:j}=function(){let e=(0,n.useContext)(p);if(!e)throw Error("useSidebar must be used within a SidebarProvider");return e}(),[g,b]=(0,n.useState)(!1),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{function e(e){N.current&&!N.current.contains(e.target)&&b(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[N]);let y=e=>"/workspaces"===e?t.pathname.startsWith("/workspaces")||t.pathname.startsWith("/workspace"):t.pathname.startsWith(e),w=e=>{let s=y(e);return"inline-flex items-center border-b-2 ".concat(s?"border-transparent text-blue-600":"border-transparent hover:text-blue-600"," ").concat(a?"px-2 py-1":"px-1 pt-1 space-x-2")};return(0,r.jsx)("div",{className:"fixed top-0 left-0 right-0 bg-white z-30 h-14 px-4 border-b border-gray-200 shadow-sm",children:(0,r.jsxs)("div",{className:"flex items-center h-full",children:[(0,r.jsx)("div",{className:"flex items-center ".concat(a?"space-x-2 mr-2":"space-x-4 mr-6"),children:(0,r.jsx)(o(),{href:"/",className:"flex items-center px-1 pt-1 h-full",prefetch:!1,children:(0,r.jsx)("div",{className:"h-20 w-20 flex items-center justify-center",children:(0,r.jsx)(c(),{src:"".concat(u.GW,"/skypilot.svg"),alt:"SkyPilot Logo",width:80,height:80,priority:!0,className:"w-full h-full object-contain"})})})}),(0,r.jsxs)("div",{className:"flex items-center ".concat(a?"space-x-1":"space-x-2 md:space-x-4"," ").concat(a?"mr-2":"mr-6"),children:[(0,r.jsxs)(o(),{href:"/clusters",className:w("/clusters"),prefetch:!1,children:[(0,r.jsx)(h.QT,{className:"w-4 h-4"}),!a&&(0,r.jsx)("span",{children:"Clusters"})]}),(0,r.jsxs)(o(),{href:"/jobs",className:w("/jobs"),prefetch:!1,children:[(0,r.jsx)(h.Vp,{className:"w-4 h-4"}),!a&&(0,r.jsx)("span",{children:"Jobs"})]}),(0,r.jsxs)(o(),{href:"/volumes",className:w("/volumes"),prefetch:!1,children:[(0,r.jsx)(h.eU,{className:"w-4 h-4"}),!a&&(0,r.jsx)("span",{children:"Volumes"})]}),(0,r.jsx)("div",{className:"border-l border-gray-200 h-6 mx-1"}),(0,r.jsxs)(o(),{href:"/infra",className:w("/infra"),prefetch:!1,children:[(0,r.jsx)(h.PC,{className:"w-4 h-4"}),!a&&(0,r.jsx)("span",{children:"Infra"})]}),(0,r.jsxs)(o(),{href:"/workspaces",className:w("/workspaces"),prefetch:!1,children:[(0,r.jsx)(h.E9,{className:"w-4 h-4"}),!a&&(0,r.jsx)("span",{children:"Workspaces"})]}),(0,r.jsxs)(o(),{href:"/users",className:w("/users"),prefetch:!1,children:[(0,r.jsx)(h.oy,{className:"w-4 h-4"}),!a&&(0,r.jsx)("span",{children:"Users"})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-1 ".concat(a?"ml-0":"ml-auto"),children:[(0,r.jsx)(m.WH,{content:"Documentation",className:"text-sm text-muted-foreground",children:(0,r.jsxs)("a",{href:"https://skypilot.readthedocs.io/en/latest/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-2 py-1 text-gray-600 hover:text-blue-600 transition-colors duration-150 cursor-pointer",title:"Docs",children:[!a&&(0,r.jsx)("span",{className:"mr-1",children:"Docs"}),(0,r.jsx)(h.h0,{className:"".concat(a?"w-4 h-4":"w-3.5 h-3.5")})]})}),(0,r.jsx)(m.WH,{content:"GitHub Repository",className:"text-sm text-muted-foreground",children:(0,r.jsx)("a",{href:"https://github.com/skypilot-org/skypilot",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center p-2 rounded-full text-gray-600 hover:bg-gray-100 transition-colors duration-150 cursor-pointer",title:"GitHub",children:(0,r.jsx)(h.fy,{className:"".concat(a?"w-4 h-4":"w-5 h-5")})})}),(0,r.jsx)(m.WH,{content:"Join Slack",className:"text-sm text-muted-foreground",children:(0,r.jsx)("a",{href:"https://slack.skypilot.co/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center p-2 rounded-full text-gray-600 hover:bg-gray-100 transition-colors duration-150 cursor-pointer",title:"Slack",children:(0,r.jsx)(h.mU,{className:"".concat(a?"w-4 h-4":"w-5 h-5")})})}),(0,r.jsx)(m.WH,{content:"Leave Feedback",className:"text-sm text-muted-foreground",children:(0,r.jsx)("a",{href:"https://github.com/skypilot-org/skypilot/issues/new",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center p-2 rounded-full text-gray-600 hover:bg-gray-100 transition-colors duration-150 cursor-pointer",title:"Leave Feedback",children:(0,r.jsx)(h.aD,{className:"".concat(a?"w-4 h-4":"w-5 h-5")})})}),(0,r.jsx)("div",{className:"border-l border-gray-200 h-6"}),(0,r.jsx)(m.WH,{content:"Configuration",className:"text-sm text-muted-foreground",children:(0,r.jsx)(o(),{href:"/config",className:"inline-flex items-center justify-center p-2 rounded-full transition-colors duration-150 cursor-pointer ".concat(y("/config")?"text-blue-600 hover:bg-gray-100":"text-gray-600 hover:bg-gray-100"),title:"Configuration",prefetch:!1,children:(0,r.jsx)(d.Z,{className:"".concat(a?"w-4 h-4":"w-5 h-5")})})}),i&&(0,r.jsxs)("div",{className:"relative",ref:N,children:[(0,r.jsx)("button",{onClick:()=>b(!g),className:"inline-flex items-center justify-center rounded-full transition-colors duration-150 cursor-pointer hover:ring-2 hover:ring-blue-200",title:"User Profile",children:(0,r.jsx)("div",{className:"".concat(a?"w-6 h-6":"w-7 h-7"," bg-blue-600 text-white rounded-full flex items-center justify-center font-medium ").concat(a?"text-xs":"text-sm"," hover:bg-blue-700 transition-colors"),children:i?i.includes("@")?i.split("@")[0].charAt(0).toUpperCase():i.charAt(0).toUpperCase():"?"})}),g&&(0,r.jsxs)("div",{className:"absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg z-50 border border-gray-200",children:[(e=i,s=null,i&&i.includes("@")&&(e=i.split("@")[0],s=i),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"px-4 pt-2 pb-1 text-sm font-medium text-gray-900",children:e}),s&&(0,r.jsx)("div",{className:"px-4 pt-0 pb-1 text-xs text-gray-500",children:s}),j&&(0,r.jsx)("div",{className:"px-4 pt-0 pb-2 text-xs",children:"admin"===j?(0,r.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,r.jsx)(h.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,r.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,r.jsx)(x.Z,{className:"w-3 h-3 mr-1"}),"User"]})})]})),(0,r.jsx)("div",{className:"border-t border-gray-200 mx-1 my-1"}),(0,r.jsx)(o(),{href:"/users",className:"block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-blue-600",onClick:()=>b(!1),prefetch:!1,children:"See all users"})]})]})]})]})})}function b(e){let{children:s,highlighted:t}=e;return(0,f.X)(),(0,r.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,r.jsx)("div",{className:"fixed top-0 left-0 right-0 z-50 shadow-sm",children:(0,r.jsx)(g,{})}),(0,r.jsx)("div",{className:"transition-all duration-200 ease-in-out min-h-screen",style:{paddingTop:"56px"},children:(0,r.jsx)("main",{className:"p-6",children:s})})]})}function N(e){return(0,r.jsx)(j,{children:(0,r.jsx)(b,{...e})})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9984],{9984:function(e,t,s){s.r(t),s.d(t,{ContextDetails:function(){return L},GPUs:function(){return Z},InfrastructureSection:function(){return G}});var a=s(5893),l=s(7294),r=s(5739);s(9470);var o=s(6409),n=s(8418),c=s(3626),i=s(3001),d=s(7853),m=s(2045),u=s(3266),h=s(8969),x=s(3225),p=s(5821);async function g(){try{let e=await fetch("".concat(x.f4,"/ssh_node_pools"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return await e.json()}catch(e){return console.error("Error fetching SSH Node Pools:",e),{}}}async function f(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error updating SSH Node Pools:",e),e}}async function y(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e),{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deleting SSH Node Pool:",e),e}}async function j(e,t){try{let s=new FormData;s.append("key_name",e),s.append("key_file",t);let a=await fetch("".concat(x.f4,"/ssh_node_pools/keys"),{method:"POST",body:s});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));return await a.json()}catch(e){throw console.error("Error uploading SSH key:",e),e}}async function N(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/deploy"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deploying SSH Node Pool:",e),e}}async function b(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/down"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error tearing down SSH Node Pool:",e),e}}async function w(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/status"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error fetching SSH Node Pool status:",e),e}}async function v(e){let t,{requestId:s,signal:a,onNewLog:l}=e,r=Date.now(),o=new Promise(e=>{let s=()=>{let a=Date.now()-r;a>=3e5?e({timeout:!0}):t=setTimeout(s,3e5-a)};t=setTimeout(s,3e5)}),n=(async()=>{try{let e=await fetch("".concat(x.f4,"/api/stream?request_id=").concat(s,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...a?{signal:a}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let o=e.body.getReader();try{for(;;){let{done:e,value:t}=await o.read();if(e)break;r=Date.now();let s=new TextDecoder().decode(t);l(s)}}finally{o.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),c=await Promise.race([n,o]);if(t&&clearTimeout(t),c.timeout){(0,p.C)("SSH deployment log stream timed out after ".concat(300,"s of inactivity"),"warning");return}}async function S(e){let t,{requestId:s,signal:a,onNewLog:l,operationType:r="operation"}=e,o=Date.now(),n=new Promise(e=>{let s=()=>{let a=Date.now()-o;a>=3e5?e({timeout:!0}):t=setTimeout(s,3e5-a)};t=setTimeout(s,3e5)}),c=(async()=>{try{let e=await fetch("".concat(x.f4,"/api/stream?request_id=").concat(s,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...a?{signal:a}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let r=e.body.getReader();try{for(;;){let{done:e,value:t}=await r.read();if(e)break;o=Date.now();let s=new TextDecoder().decode(t);l(s)}}finally{r.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),i=await Promise.race([c,n]);if(t&&clearTimeout(t),i.timeout){(0,p.C)("SSH ".concat(r," log stream timed out after ").concat(300,"s of inactivity"),"warning");return}}var _=s(326),C=s(803),P=s(2557),k=s(6185),T=s(9123);function E(e){let{isOpen:t,onClose:s,onSave:o,poolData:n=null,isLoading:c=!1}=e,[i,d]=(0,l.useState)(""),[m,u]=(0,l.useState)(""),[h,x]=(0,l.useState)("ubuntu"),[p,g]=(0,l.useState)(null),[f,y]=(0,l.useState)(""),[N,b]=(0,l.useState)({}),w=null!==n;(0,l.useEffect)(()=>{if(w&&n){var e,t,s;d(n.name||""),u(((null===(e=n.config)||void 0===e?void 0:e.hosts)||[]).join("\n")),x((null===(t=n.config)||void 0===t?void 0:t.user)||"ubuntu"),y((null===(s=n.config)||void 0===s?void 0:s.password)||"")}else d(""),u(""),x("ubuntu"),g(null),y("");b({})},[w,n]);let v=()=>{let e={};return i.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"),p||f||(e.auth="Either SSH key file or password is required"),b(e),0===Object.keys(e).length},S=async()=>{if(!v())return;let e={hosts:m.split("\n").map(e=>e.trim()).filter(e=>e.length>0),user:h};try{if(p){let t=p.name;await j(t,p),e.identity_file="~/.sky/ssh_keys/".concat(t)}f&&(e.password=f),o(i,e)}catch(e){console.error("Failed to upload SSH key:",e),b({...N,keyUpload:"Failed to upload SSH key"})}},E=()=>{c||s()};return(0,a.jsx)(_.Vq,{open:t,onOpenChange:E,children:(0,a.jsxs)(_.cZ,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,a.jsx)(_.fK,{children:(0,a.jsx)(_.$N,{children:w?"Edit SSH Node Pool: ".concat(null==n?void 0:n.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)(k._,{htmlFor:"poolName",children:"Pool Name"}),(0,a.jsx)(P.I,{id:"poolName",placeholder:"my-ssh-cluster",value:i,onChange:e=>d(e.target.value),disabled:w,className:"placeholder:text-gray-500 ".concat(N.poolName?"border-red-500":"")}),N.poolName&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.poolName})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"hosts",children:"Hosts (one per line)"}),(0,a.jsx)(T.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(N.hosts?"border-red-500":"")}),N.hosts&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.hosts})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"sshUser",children:"SSH User"}),(0,a.jsx)(P.I,{id:"sshUser",placeholder:"ubuntu",value:h,onChange:e=>x(e.target.value),className:"placeholder:text-gray-500 ".concat(N.sshUser?"border-red-500":"")}),N.sshUser&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.sshUser})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"keyFile",children:"SSH Private Key File"}),(0,a.jsx)(P.I,{id:"keyFile",type:"file",accept:".pem,.key,id_rsa,id_ed25519",onChange:e=>{var t;return g((null===(t=e.target.files)||void 0===t?void 0:t[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"}),N.keyUpload&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.keyUpload})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"password",children:"Password (optional, if sudo requires a password)"}),(0,a.jsx)(P.I,{id:"password",type:"password",placeholder:"Leave empty if using passwordless sudo",value:f,onChange:e=>y(e.target.value),className:"placeholder:text-gray-500"})]}),N.auth&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.auth})]}),(0,a.jsxs)(_.cN,{children:[(0,a.jsx)(C.z,{variant:"outline",onClick:E,disabled:c,children:"Cancel"}),(0,a.jsx)(C.z,{onClick:S,disabled:c,className:"bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"Saving..."]}):w?"Update Pool":"Create Pool"})]})]})})}var H=s(6378),D=s(6856),U=s(1214),I=s(1163),F=s(1664),q=s.n(F),O=s(6989);s(7673);let R=U.nb.REFRESH_INTERVAL,A=U.MO.NAME_TRUNCATE_LENGTH;function G(e){let{title:t,isLoading:s,isDataLoaded:l,contexts:o,gpus:n,groupedPerContextGPUs:c,groupedPerNodeGPUs:i,handleContextClick:d,contextStats:m={},isSSH:u=!1,actionButton:h=null}=e,x=o||[];return s||!l?(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:t}),(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 ",t,"..."]})]})]})}):l&&0===x.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:t}),h]}),(0,a.jsxs)("p",{className:"text-sm text-gray-500",children:["No ",t," found or ",t," is not configured."]})]})}):l&&x.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:t}),(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:[x.length," ",1===x.length?u?"pool":"context":u?"pools":"contexts"]})]}),h]}),(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:u?"Node Pool":"Context"}),(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(x.length>5?"max-h-[250px] overflow-y-auto block":""),children:x.map(e=>{let t=c[e]||[],s=i[e]||[],l=t.reduce((e,t)=>e+(t.gpu_total||0),0),r=m[u?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e)]||{clusters:0,jobs:0},o=Object.keys(t.reduce((e,t)=>(e[t.gpu_name]=(e[t.gpu_name]||0)+(t.gpu_total||0),e),{})).join(", "),n=u?e.replace(/^ssh-/,""):e;return(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3",children:(0,a.jsx)(O.Md,{content:n,className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{className:"text-blue-600 hover:underline cursor-pointer",onClick:()=>d(e),children:n.length>A?"".concat(n.substring(0,Math.floor((A-3)/2)),"...").concat(n.substring(n.length-Math.ceil((A-3)/2))):n})})}),(0,a.jsx)("td",{className:"p-3",children:r.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:r.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)("td",{className:"p-3",children:r.jobs>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:r.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:s.length}),(0,a.jsx)("td",{className:"p-3",children:o||"-"}),(0,a.jsx)("td",{className:"p-3",children:l})]},e)})})]})})}),n&&n.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:[n.reduce((e,t)=>e+t.gpu_free,0)," ","of"," ",n.reduce((e,t)=>e+t.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(n.length>5?"max-h-[250px] overflow-y-auto block":""),children:n.map(e=>{let t=e.gpu_total-e.gpu_free,s=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,l=e.gpu_total>0?t/e.gpu_total*100:0,r=c?Object.values(c).flat().filter(t=>t.gpu_name===e.gpu_name&&(u?t.context.startsWith("ssh-"):!t.context.startsWith("ssh-"))).map(e=>e.gpu_requestable_qty_per_node).filter((e,t,s)=>s.indexOf(e)===t).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:[r||"-"," / 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.jsxs)("div",{className:"flex-1 bg-gray-100 rounded-md h-5 flex overflow-hidden shadow-sm min-w-[100px] w-full",children:[l>0&&(0,a.jsx)("div",{style:{width:"".concat(l,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs font-medium",children:l>15&&"".concat(t," used")}),s>0&&(0,a.jsx)("div",{style:{width:"".concat(s,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs font-medium",children:s>15&&"".concat(e.gpu_free," free")})]})})})]},e.gpu_name)})})]})})})]})]})}):null}function L(e){let{contextName:t,gpusInContext:s,nodesInContext:o}=e;t.startsWith("ssh-");let[n,c]=(0,l.useState)([]),[i,m]=(0,l.useState)("$__all"),[u,h]=(0,l.useState)({from:"now-1h",to:"now"}),[x,p]=(0,l.useState)(!1),[g,f]=(0,l.useState)(!1);(0,l.useEffect)(()=>{(async()=>{f(await (0,d.TO)())})()},[]);let y=(0,l.useCallback)(async()=>{if(g){p(!0);try{let e=(0,d.ki)();for(let t of["/api/datasources/proxy/1/api/v1/label/node/values"])try{let s=await fetch("".concat(e).concat(t),{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(s.ok){let e=await s.json();if(e.data&&e.data.length>0){c(e.data.sort()),console.log("Successfully fetched hosts from ".concat(t,":"),e.data);break}}else console.log("HTTP ".concat(s.status," from ").concat(t,": ").concat(s.statusText))}catch(e){console.log("Failed to fetch from ".concat(t,":"),e);continue}}catch(e){console.error("Error fetching available hosts:",e)}finally{p(!1)}}},[g]);(0,l.useEffect)(()=>{g&&o&&o.length>0&&y()},[o,g,y]);let j=e=>{let t=(0,d.ki)(),s="$__all"===i?"$__all":i;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(s),"&var-gpu=$__all&refresh=5s&theme=light&from=").concat(encodeURIComponent(u.from),"&to=").concat(encodeURIComponent(u.to),"&panelId=").concat(e,"&__feature.dashboardSceneSolo")},N=e=>{h({"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:s.map(e=>{let t=e.gpu_total-e.gpu_free,s=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,l=e.gpu_total>0?t/e.gpu_total*100:0;return(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.jsxs)("div",{className:"w-full bg-gray-100 rounded-md h-4 flex overflow-hidden shadow-sm",children:[l>0&&(0,a.jsx)("div",{style:{width:"".concat(l,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs",children:l>15&&"".concat(t," used")}),s>0&&(0,a.jsx)("div",{style:{width:"".concat(s,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs",children:s>15&&"".concat(e.gpu_free," free")})]})]},e.gpu_name)})}),o&&o.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:o.map((e,t)=>(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:"".concat(e.gpu_free," of ").concat(e.gpu_total," free")})]},"".concat(e.node_name,"-").concat(t)))})]})})]}),g&&o&&o.length>0&&(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:[(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:i,onChange:e=>{m(e.target.value)},disabled:x,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"}),n.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]}),x&&(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(u.from==="now-".concat(e.value)&&"now"===u.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.jsxs)("div",{className:"mt-2 text-xs text-gray-500",children:["Showing:"," ","$__all"===i?"All nodes":i," • Time: ",u.from," to ",u.to,n.length>0&&(0,a.jsxs)("span",{children:[" • ",n.length," nodes available"]})]})]}),(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",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:j("6"),width:"100%",height:"400",frameBorder:"0",title:"GPU Utilization",className:"rounded"},"gpu-util-".concat(i,"-").concat(u.from,"-").concat(u.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:j("18"),width:"100%",height:"400",frameBorder:"0",title:"GPU Memory",className:"rounded"},"gpu-memory-".concat(i,"-").concat(u.from,"-").concat(u.to))})}),(0,a.jsx)("div",{className:"bg-white rounded-md",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:j("10"),width:"100%",height:"400",frameBorder:"0",title:"GPU Power Consumption",className:"rounded"},"gpu-power-".concat(i,"-").concat(u.from,"-").concat(u.to))})})]})]})]})})})}function z(e){var t;let{poolName:s,gpusInContext:c,nodesInContext:i,handleDeploySSHPool:d,handleEditSSHPool:m,handleDeleteSSHPool:u,poolConfig:h}=e,[x,p]=(0,l.useState)(null),[g,f]=(0,l.useState)(!0),[y,j]=(0,l.useState)({isOpen:!1,action:null,loading:!1}),[N,P]=(0,l.useState)({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});(0,l.useEffect)(()=>{(async()=>{try{f(!0);let e=await w(s);p(e)}catch(e){console.error("Failed to fetch SSH Node Pool status:",e),p({pool_name:s,status:"Error",reason:"Failed to fetch status"})}finally{f(!1)}})()},[s]);let{deployDisabled:k}=(()=>{if(!x)return{deployDisabled:!0};let e=x.status;return"Ready"===e?{deployDisabled:!0}:"Error"===e?{deployDisabled:!0}:{deployDisabled:!1}})(),T=async()=>{j({...y,loading:!0});try{if("deploy"===y.action){j({isOpen:!1,action:null,loading:!1}),P({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await d(s)).request_id;P(t=>({...t,requestId:e}));let t=new AbortController;await v({requestId:e,signal:t.signal,onNewLog:e=>{P(t=>({...t,logs:t.logs+e}))}}),P(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0})),setTimeout(async()=>{(async()=>{try{let e=await w(s);p(e)}catch(e){console.error("Failed to fetch SSH Node Pool status after deployment:",e)}})()},1e3)}catch(e){console.error("Deployment failed:",e),P(t=>({...t,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:t.logs+"\nDeployment failed: ".concat(e.message)}))}}else if("delete"===y.action){j({isOpen:!1,action:null,loading:!1}),P({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await b(s)).request_id;P(t=>({...t,requestId:e})),e&&await S({requestId:e,signal:null,onNewLog:e=>{P(t=>({...t,logs:t.logs+e}))},operationType:"down"}),await u(s),P(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),P(t=>({...t,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:t.logs+"\nTeardown failed: ".concat(e.message)}))}}}catch(e){console.error("Action failed:",e),j({...y,loading:!1})}},E=()=>{j({isOpen:!1,action:null,loading:!1})},H=()=>{P({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null}),N.deploymentComplete&&setTimeout(()=>{(async()=>{try{let e=await w(s);p(e)}catch(e){console.error("Failed to refresh status:",e)}})()},1e3)},D="deploy"===y.action?{title:"Deploy SSH Node Pool",description:'Are you sure you want to deploy SSH Node Pool "'.concat(s,'"?'),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(s,'"?'),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(k?"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:k?void 0:()=>{j({isOpen:!0,action:"deploy",loading:!1})},disabled:k,children:[(0,a.jsx)(o.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:()=>{j({isOpen:!0,action:"delete",loading:!1})},children:[(0,a.jsx)(n.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:s})]}),(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:i?i.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:g?(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..."})]}):x?(0,a.jsx)(e=>{let{status:t,reason:s}=e,l="Ready"===t,r="Not Ready"===t?"Click Deploy to set up this node pool":s;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:t}),!l&&r&&(0,a.jsxs)("span",{className:"text-sm text-gray-600",children:["(",r,")"]})]})},{status:x.status,reason:x.reason}):(0,a.jsx)("span",{className:"text-gray-500",children:"Unknown"})})]})]})})]})}),(0,a.jsx)(L,{contextName:"ssh-".concat(s),gpusInContext:c,nodesInContext:i}),(0,a.jsx)(_.Vq,{open:y.isOpen,onOpenChange:E,children:(0,a.jsxs)(_.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(_.fK,{className:"",children:[(0,a.jsx)(_.$N,{className:"",children:D.title}),(0,a.jsx)(_.Be,{className:"",children:D.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:"}),D.details.map((e,t)=>(0,a.jsx)("p",{className:""===e?"pt-2":"",children:e},t))]})}),(0,a.jsxs)(_.cN,{className:"",children:[(0,a.jsx)(C.z,{variant:"outline",onClick:E,disabled:y.loading,className:"",children:"Cancel"}),(0,a.jsx)(C.z,{onClick:T,disabled:y.loading,className:"deploy"===y.action?"bg-green-600 hover:bg-green-700 text-white":"bg-red-600 hover:bg-red-700 text-white",children:y.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"deploy"===y.action?"Deploying...":"Deleting..."]}):"deploy"===y.action?"Deploy":"Delete"})]})]})}),(0,a.jsx)(_.Vq,{open:N.isOpen,onOpenChange:N.isStreaming?void 0:H,children:(0,a.jsxs)(_.cZ,{className:"sm:max-w-4xl max-h-[80vh]",children:[(0,a.jsxs)(_.fK,{className:"",children:[(0,a.jsxs)(_.$N,{className:"",children:["Deploying SSH Node Pool: ",s]}),(0,a.jsx)(_.Be,{className:"",children:N.isStreaming?"Deployment in progress. Do not close this dialog.":N.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:(t=N.logs)?t.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"):""}),N.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)(_.cN,{className:"",children:(0,a.jsx)(C.z,{onClick:H,disabled:N.isStreaming,className:N.deploymentSuccess?"bg-green-600 hover:bg-green-700 text-white":N.deploymentComplete&&!N.deploymentSuccess?"bg-red-600 hover:bg-red-700 text-white":"bg-gray-600 hover:bg-gray-700 text-white",children:N.isStreaming?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{size:16,className:"mr-2"}),"Deploying..."]}):"Close"})})]})})]})}function Z(){let[e,t]=(0,l.useState)(!0),[s,o]=(0,l.useState)(!0),[n,d]=(0,l.useState)(!0),x=l.useRef(null),p=(0,i.X)(),[j,b]=(0,l.useState)(!1),[w,v]=(0,l.useState)(!1),S=(0,I.useRouter)(),[_,C]=(0,l.useState)([]),[P,k]=(0,l.useState)([]),[T,U]=(0,l.useState)([]),[F,O]=(0,l.useState)([]),[A,Z]=(0,l.useState)([]),[M,W]=(0,l.useState)(0),[$,B]=(0,l.useState)(0),[K,J]=(0,l.useState)({}),[V,X]=(0,l.useState)({}),[Q,Y]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(null),[es,ea]=(0,l.useState)(!1),[el,er]=(0,l.useState)(null),eo=l.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{showLoadingIndicators:!0};e.showLoadingIndicators&&(t(!0),o(!0));try{let e=await H.default.get(m.l4),{gpuData:t,cloudData:s}=e||{};if(t){let{allContextNames:e,allGPUs:s,perContextGPUs:a,perNodeGPUs:l,contextStats:r}=t;C(e||[]),k(s||[]),U(a||[]),O(l||[]),J(r||{}),b(!0)}else e&&null===e.gpuData?(C([]),k([]),U([]),O([]),J({}),b(!0)):e||console.log("No infra data received from cache");s?(Z(s.clouds||[]),W(s.totalClouds||0),B(s.enabledClouds||0),v(!0)):e&&null===e.cloudData?(Z([]),W(0),B(0),v(!0)):e||console.log("No cloud data received from cache"),await en()}catch(e){console.error("Error in fetchData:",e),C([]),k([]),U([]),O([]),J({}),Z([]),W(0),B(0),b(!0),v(!0)}finally{e.showLoadingIndicators&&(t(!1),o(!1)),n&&e.showLoadingIndicators&&d(!1)}},[n]),en=async()=>{try{let e=await g();X(e)}catch(e){console.error("Failed to fetch SSH Node Pools:",e),X({})}},ec=(e,t)=>{et({name:e,config:t}),Y(!0)},ei=async e=>{try{await y(e),await en(),er(null),S.push("/infra")}catch(e){throw console.error("Failed to delete SSH Node Pool:",e),e}},ed=async e=>{try{await N(e)}catch(e){throw console.error("Failed to deploy SSH Node Pool:",e),e}},em=async(e,t)=>{ea(!0);try{let s={...V};s[e]=t,await f(s),await en(),Y(!1)}catch(e){console.error("Failed to save SSH Node Pool:",e),alert("Failed to save SSH Node Pool. Please try again.")}finally{ea(!1)}};(0,l.useEffect)(()=>{x.current=eo},[eo]),(0,l.useEffect)(()=>{(async()=>{await D.ZP.preloadForPage("infra"),eo({showLoadingIndicators:!0})})()},[eo]),(0,l.useEffect)(()=>{let e=!0,t=setInterval(()=>{e&&x.current&&x.current({showLoadingIndicators:!1})},R);return()=>{e=!1,clearInterval(t)}},[]),(0,l.useEffect)(()=>()=>{b(!1),v(!1),d(!0)},[]),(P||[]).length,(P||[]).reduce((e,t)=>e+t.gpu_total,0),(P||[]).reduce((e,t)=>e+t.gpu_free,0);let eu=l.useMemo(()=>T?T.reduce((e,t)=>{let{context:s}=t;return e[s]||(e[s]=[]),e[s].push(t),e},{}):{},[T]),eh=l.useMemo(()=>_&&Array.isArray(_)?_.filter(e=>e.startsWith("ssh-")):[],[_]),ex=l.useMemo(()=>_&&Array.isArray(_)?_.filter(e=>!e.startsWith("ssh-")):[],[_]),ep=l.useMemo(()=>{if(!T||!P)return[];let e=new Set;return T.forEach(t=>{t.context.startsWith("ssh-")&&e.add(t.gpu_name)}),P.filter(t=>e.has(t.gpu_name))},[P,T]),eg=l.useMemo(()=>{if(!T||!P)return[];let e=new Set;return T.forEach(t=>{t.context.startsWith("ssh-")||e.add(t.gpu_name)}),P.filter(t=>e.has(t.gpu_name))},[P,T]),ef=l.useMemo(()=>F?F.reduce((e,t)=>{let{context:s}=t;return e[s]||(e[s]=[]),e[s].push(t),e},{}):{},[F]);(0,l.useEffect)(()=>{S.isReady&&S.query.context&&er(decodeURIComponent(Array.isArray(S.query.context)?S.query.context[0]:S.query.context))},[S.isReady,S.query.context]);let ey=e=>{er(e),S.push("/infra/".concat(encodeURIComponent(e)))},ej=e||s,eN=j&&w&&!n;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)(q(),{href:"/infra",className:"text-sky-blue hover:underline ".concat(el?"":"cursor-default"),children:"Infrastructure"}),el&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),el.startsWith("ssh-")?(0,a.jsx)(q(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"SSH Node Pool"}):(0,a.jsx)(q(),{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:el.startsWith("ssh-")?el.replace(/^ssh-/,""):el})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[ej&&(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:()=>{H.default.invalidate(u.getClusters),H.default.invalidate(h.getManagedJobs,[{allUsers:!0}]),H.default.invalidate(m.l4),x.current&&x.current({showLoadingIndicators:!0})},disabled:ej,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(c.Z,{className:"h-4 w-4 mr-1.5"}),!p&&"Refresh"]})]})]}),eN?el?e&&!j?(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..."})]}):(t=>{let s=eu[t]||[],l=ef[t]||[];if(e&&!j)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(t.startsWith("ssh-")){let e=t.replace(/^ssh-/,"");return(0,a.jsx)(z,{poolName:e,gpusInContext:s,nodesInContext:l,handleDeploySSHPool:ed,handleEditSSHPool:ec,handleDeleteSSHPool:ei,poolConfig:V[e]})}return(0,a.jsx)(L,{contextName:t,gpusInContext:s,nodesInContext:l})})(el):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(G,{title:"SSH Node Pool",isLoading:e,isDataLoaded:j,contexts:eh,gpus:ep,groupedPerContextGPUs:eu,groupedPerNodeGPUs:ef,handleContextClick:ey,contextStats:K,isSSH:!0,actionButton:null}),(0,a.jsx)(G,{title:"Kubernetes",isLoading:e,isDataLoaded:j,contexts:ex,gpus:eg,groupedPerContextGPUs:eu,groupedPerNodeGPUs:ef,handleContextClick:ey,contextStats:K,isSSH:!1}),s||!w?(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:[$," of ",M," enabled"]})]}),A&&0!==A.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:A.map(e=>(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: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)("td",{className:"p-3",children: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"})})]},e.name))})]})}):(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"No enabled clouds available."})]})})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-32",children:[(0,a.jsx)(r.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading infrastructure data..."})]}),(0,a.jsx)(E,{isOpen:Q,onClose:()=>Y(!1),onSave:em,poolData:ee,isLoading:es})]})}},2557:function(e,t,s){s.d(t,{I:function(){return o}});var a=s(5893),l=s(7294),r=s(2350);let o=l.forwardRef((e,t)=>{let{className:s,type:l,...o}=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",s),ref:t,...o})});o.displayName="Input"},6185:function(e,t,s){s.d(t,{_:function(){return i}});var a=s(5893),l=s(7294),r=s(9102),o=s(2003),n=s(2350);let c=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),i=l.forwardRef((e,t)=>{let{className:s,...l}=e;return(0,a.jsx)(r.f,{ref:t,className:(0,n.cn)(c(),s),...l})});i.displayName=r.f.displayName},9123:function(e,t,s){s.d(t,{g:function(){return o}});var a=s(5893),l=s(7294),r=s(2350);let o=l.forwardRef((e,t)=>{let{className:s,...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",s),ref:t,...l})});o.displayName="Textarea"},7853:function(e,t,s){s.d(t,{TO:function(){return r},ki:function(){return o}});let a=null,l=null,r=async()=>null!==a?a:l||(l=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),t=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==t.status}catch(e){return console.debug("Grafana availability check failed:",e),a=!1,!1}finally{l=null}})()),o=()=>"".concat(window.location.origin,"/grafana")}}]);