skypilot-nightly 1.0.0.dev20250623__py3-none-any.whl → 1.0.0.dev20250624__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 (96) hide show
  1. sky/__init__.py +2 -2
  2. sky/admin_policy.py +16 -5
  3. sky/backends/__init__.py +2 -1
  4. sky/backends/backend_utils.py +12 -0
  5. sky/backends/cloud_vm_ray_backend.py +36 -13
  6. sky/client/cli/command.py +42 -21
  7. sky/client/sdk.py +12 -6
  8. sky/clouds/kubernetes.py +1 -0
  9. sky/core.py +88 -15
  10. sky/dashboard/out/404.html +1 -1
  11. sky/dashboard/out/_next/static/chunks/37-4650f214e2119168.js +6 -0
  12. sky/dashboard/out/_next/static/chunks/42.2273cc2415291ceb.js +6 -0
  13. sky/dashboard/out/_next/static/chunks/470-1494c899266cf5c9.js +1 -0
  14. sky/dashboard/out/_next/static/chunks/{513.211357a2914a34b2.js → 513.309df9e18a9ff005.js} +1 -1
  15. sky/dashboard/out/_next/static/chunks/856-bfddc18e16f3873c.js +1 -0
  16. sky/dashboard/out/_next/static/chunks/938-ce7991c156584b06.js +1 -0
  17. sky/dashboard/out/_next/static/chunks/969-d3a0b53f728d280a.js +1 -0
  18. sky/dashboard/out/_next/static/chunks/989-db34c16ad7ea6155.js +1 -0
  19. sky/dashboard/out/_next/static/chunks/pages/{_app-c416e87d5c2715cf.js → _app-ce31493da9747ef4.js} +1 -1
  20. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-4e065c812a52460b.js +6 -0
  21. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-520ec1ab65e2f2a4.js +6 -0
  22. sky/dashboard/out/_next/static/chunks/pages/clusters-7e9736af1c6345a6.js +1 -0
  23. sky/dashboard/out/_next/static/chunks/pages/config-e4f473661889e7cd.js +1 -0
  24. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-00fd23b9577492ca.js +1 -0
  25. sky/dashboard/out/_next/static/chunks/pages/infra-8a4bf7370d4d9bb7.js +1 -0
  26. sky/dashboard/out/_next/static/chunks/pages/jobs/{[job]-cf490d1fa38f3740.js → [job]-171c27f4ca94861c.js} +1 -1
  27. sky/dashboard/out/_next/static/chunks/pages/jobs-55e5bcb16d563231.js +1 -0
  28. sky/dashboard/out/_next/static/chunks/pages/users-c9f4d785cdaa52d8.js +1 -0
  29. sky/dashboard/out/_next/static/chunks/pages/workspaces/{[name]-c4ff1ec05e2f3daf.js → [name]-ecc5a7003776cfa7.js} +1 -1
  30. sky/dashboard/out/_next/static/chunks/pages/workspaces-f00cba35691483b1.js +1 -0
  31. sky/dashboard/out/_next/static/chunks/webpack-c85998e6a5722f21.js +1 -0
  32. sky/dashboard/out/_next/static/css/6ab927686b492a4a.css +3 -0
  33. sky/dashboard/out/_next/static/zsALxITkbP8J8NVwSDwMo/_buildManifest.js +1 -0
  34. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  35. sky/dashboard/out/clusters/[cluster].html +1 -1
  36. sky/dashboard/out/clusters.html +1 -1
  37. sky/dashboard/out/config.html +1 -1
  38. sky/dashboard/out/index.html +1 -1
  39. sky/dashboard/out/infra/[context].html +1 -1
  40. sky/dashboard/out/infra.html +1 -1
  41. sky/dashboard/out/jobs/[job].html +1 -1
  42. sky/dashboard/out/jobs.html +1 -1
  43. sky/dashboard/out/users.html +1 -1
  44. sky/dashboard/out/workspace/new.html +1 -1
  45. sky/dashboard/out/workspaces/[name].html +1 -1
  46. sky/dashboard/out/workspaces.html +1 -1
  47. sky/exceptions.py +11 -0
  48. sky/global_user_state.py +134 -20
  49. sky/jobs/client/sdk.py +0 -1
  50. sky/jobs/controller.py +5 -1
  51. sky/jobs/scheduler.py +4 -3
  52. sky/jobs/server/core.py +117 -51
  53. sky/jobs/state.py +15 -0
  54. sky/jobs/utils.py +114 -8
  55. sky/resources.py +1 -1
  56. sky/server/requests/payloads.py +6 -3
  57. sky/server/requests/requests.py +24 -1
  58. sky/server/server.py +4 -3
  59. sky/skylet/constants.py +5 -11
  60. sky/task.py +1 -26
  61. sky/templates/jobs-controller.yaml.j2 +12 -1
  62. sky/templates/kubernetes-ray.yml.j2 +1 -1
  63. sky/utils/admin_policy_utils.py +5 -1
  64. sky/utils/cli_utils/status_utils.py +25 -17
  65. sky/utils/command_runner.py +118 -12
  66. sky/utils/command_runner.pyi +57 -0
  67. sky/utils/common_utils.py +9 -1
  68. sky/utils/controller_utils.py +1 -2
  69. sky/utils/schemas.py +34 -35
  70. {skypilot_nightly-1.0.0.dev20250623.dist-info → skypilot_nightly-1.0.0.dev20250624.dist-info}/METADATA +1 -1
  71. {skypilot_nightly-1.0.0.dev20250623.dist-info → skypilot_nightly-1.0.0.dev20250624.dist-info}/RECORD +78 -77
  72. sky/dashboard/out/_next/static/F4kiZ6Zh72jA6HzZ3ncFo/_buildManifest.js +0 -1
  73. sky/dashboard/out/_next/static/chunks/37-3a4d77ad62932eaf.js +0 -6
  74. sky/dashboard/out/_next/static/chunks/42.d39e24467181b06b.js +0 -6
  75. sky/dashboard/out/_next/static/chunks/470-4d1a5dbe58a8a2b9.js +0 -1
  76. sky/dashboard/out/_next/static/chunks/856-c2c39c0912285e54.js +0 -1
  77. sky/dashboard/out/_next/static/chunks/938-1493ac755eadeb35.js +0 -1
  78. sky/dashboard/out/_next/static/chunks/969-20d54a9d998dc102.js +0 -1
  79. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-89216c616dbaa9c5.js +0 -6
  80. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]-36bc0962129f72df.js +0 -6
  81. sky/dashboard/out/_next/static/chunks/pages/clusters-82a651dbad53ec6e.js +0 -1
  82. sky/dashboard/out/_next/static/chunks/pages/config-497a35a7ed49734a.js +0 -1
  83. sky/dashboard/out/_next/static/chunks/pages/infra/[context]-d2910be98e9227cb.js +0 -1
  84. sky/dashboard/out/_next/static/chunks/pages/infra-780860bcc1103945.js +0 -1
  85. sky/dashboard/out/_next/static/chunks/pages/jobs-336ab80e270ce2ce.js +0 -1
  86. sky/dashboard/out/_next/static/chunks/pages/users-928edf039219e47b.js +0 -1
  87. sky/dashboard/out/_next/static/chunks/pages/workspaces-82e6601baa5dd280.js +0 -1
  88. sky/dashboard/out/_next/static/chunks/webpack-0263b00d6a10e64a.js +0 -1
  89. sky/dashboard/out/_next/static/css/6c12ecc3bd2239b6.css +0 -3
  90. /sky/dashboard/out/_next/static/chunks/{843-b3040e493f6e7947.js → 843-bde186946d353355.js} +0 -0
  91. /sky/dashboard/out/_next/static/chunks/{973-db3c97c2bfbceb65.js → 973-56412c7976b4655b.js} +0 -0
  92. /sky/dashboard/out/_next/static/{F4kiZ6Zh72jA6HzZ3ncFo → zsALxITkbP8J8NVwSDwMo}/_ssgManifest.js +0 -0
  93. {skypilot_nightly-1.0.0.dev20250623.dist-info → skypilot_nightly-1.0.0.dev20250624.dist-info}/WHEEL +0 -0
  94. {skypilot_nightly-1.0.0.dev20250623.dist-info → skypilot_nightly-1.0.0.dev20250624.dist-info}/entry_points.txt +0 -0
  95. {skypilot_nightly-1.0.0.dev20250623.dist-info → skypilot_nightly-1.0.0.dev20250624.dist-info}/licenses/LICENSE +0 -0
  96. {skypilot_nightly-1.0.0.dev20250623.dist-info → skypilot_nightly-1.0.0.dev20250624.dist-info}/top_level.txt +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[470],{3850:function(e,t,r){r.d(t,{E9:function(){return j},J$:function(){return l},PC:function(){return d},Ps:function(){return i},QT:function(){return x},Vp:function(){return u},W2:function(){return c},Ye:function(){return a},aD:function(){return g},fp:function(){return h},fy:function(){return m},h0:function(){return f},mU:function(){return p},oy:function(){return v},r7:function(){return w}});var n=r(5893);r(7294);var s=r(8507),o=r(8586);function i(e){return(0,n.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"0",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})})}function c(e){return(0,n.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("circle",{cx:"10",cy:"10",r:"8"})})}function l(e){return(0,n.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("circle",{cx:"10",cy:"10",r:"8"})})}function a(e){return(0,n.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M6 12l4 4 8-8"})})}function h(e){return(0,n.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"0",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),(0,n.jsx)("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]})}function x(e){return(0,n.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),(0,n.jsx)("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),(0,n.jsx)("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]})}function u(e){return(0,n.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"}),(0,n.jsx)("rect",{width:"20",height:"14",x:"2",y:"6",rx:"2"})]})}function d(e){return(0,n.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",ry:"2"}),(0,n.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,n.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,n.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,n.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,n.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,n.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,n.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,n.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,n.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]})}function f(e){return(0,n.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,n.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,n.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function m(e){return(0,n.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})})}function w(e){return(0,n.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}function p(e){return(0,n.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{transform:"scale(0.85) translate(1.8, 1.8)",d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"})})}function j(e){return(0,n.jsx)("svg",{...e,stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,n.jsxs)("g",{children:[(0,n.jsx)("path",{fill:"none",d:"M0 0h24v24H0z"}),(0,n.jsx)("path",{d:"M3 18.5V5a3 3 0 0 1 3-3h14a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5A3.5 3.5 0 0 1 3 18.5zM19 20v-3H6.5a1.5 1.5 0 0 0 0 3H19zM10 4H6a1 1 0 0 0-1 1v10.337A3.486 3.486 0 0 1 6.5 15H19V4h-2v8l-3.5-2-3.5 2V4z"})]})})}let g=s.Z,v=o.Z},9470:function(e,t,r){r.r(t),r.d(t,{Layout:function(){return v}});var n=r(5893),s=r(7294),o=r(5675),i=r.n(o),c=r(1163),l=r(1664),a=r.n(l),h=r(3850),x=r(355),u=r(6021),d=r(3225),f=r(6989),m=r(3001);let w=(0,s.createContext)(null);function p(e){let{children:t}=e,[r,o]=(0,s.useState)(!0),[i,c]=(0,s.useState)(null),[l,a]=(0,s.useState)(null),h=window.location.origin,x="".concat(h).concat(d.f4);return(0,s.useEffect)(()=>{fetch("".concat(x,"/api/health")).then(e=>e.json()).then(e=>{e.user&&e.user.name&&(c(e.user.name),(async()=>{try{let e=await fetch("".concat(x,"/users/role"));if(e.ok){let t=await e.json();t.role&&a(t.role)}}catch(e){console.log("Could not fetch user role:",e)}})())}).catch(e=>{console.error("Error fetching user data:",e)})},[x]),(0,n.jsx)(w.Provider,{value:{isSidebarOpen:r,toggleSidebar:()=>{o(e=>!e)},userEmail:i,userRole:l},children:t})}function j(){let e,t;let r=(0,c.useRouter)(),o=(0,m.X)(),{userEmail:l,userRole:p}=function(){let e=(0,s.useContext)(w);if(!e)throw Error("useSidebar must be used within a SidebarProvider");return e}(),[j,g]=(0,s.useState)(!1),v=(0,s.useRef)(null);(0,s.useEffect)(()=>{function e(e){v.current&&!v.current.contains(e.target)&&g(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[v]);let y=e=>"/workspaces"===e?r.pathname.startsWith("/workspaces")||r.pathname.startsWith("/workspace"):r.pathname.startsWith(e),k=e=>{let t=y(e);return"inline-flex items-center border-b-2 ".concat(t?"border-transparent text-blue-600":"border-transparent hover:text-blue-600"," ").concat(o?"px-2 py-1":"px-1 pt-1 space-x-2")};return(0,n.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,n.jsxs)("div",{className:"flex items-center h-full",children:[(0,n.jsx)("div",{className:"flex items-center ".concat(o?"space-x-2 mr-2":"space-x-4 mr-6"),children:(0,n.jsx)(a(),{href:"/",className:"flex items-center px-1 pt-1 h-full",prefetch:!1,children:(0,n.jsx)("div",{className:"h-20 w-20 flex items-center justify-center",children:(0,n.jsx)(i(),{src:"".concat(d.GW,"/skypilot.svg"),alt:"SkyPilot Logo",width:80,height:80,priority:!0,className:"w-full h-full object-contain"})})})}),(0,n.jsxs)("div",{className:"flex items-center ".concat(o?"space-x-1":"space-x-2 md:space-x-4"," ").concat(o?"mr-2":"mr-6"),children:[(0,n.jsxs)(a(),{href:"/clusters",className:k("/clusters"),prefetch:!1,children:[(0,n.jsx)(h.QT,{className:"w-4 h-4"}),!o&&(0,n.jsx)("span",{children:"Clusters"})]}),(0,n.jsxs)(a(),{href:"/jobs",className:k("/jobs"),prefetch:!1,children:[(0,n.jsx)(h.Vp,{className:"w-4 h-4"}),!o&&(0,n.jsx)("span",{children:"Jobs"})]}),(0,n.jsx)("div",{className:"border-l border-gray-200 h-6 mx-1"}),(0,n.jsxs)(a(),{href:"/infra",className:k("/infra"),prefetch:!1,children:[(0,n.jsx)(h.PC,{className:"w-4 h-4"}),!o&&(0,n.jsx)("span",{children:"Infra"})]}),(0,n.jsxs)(a(),{href:"/workspaces",className:k("/workspaces"),prefetch:!1,children:[(0,n.jsx)(h.E9,{className:"w-4 h-4"}),!o&&(0,n.jsx)("span",{children:"Workspaces"})]}),(0,n.jsxs)(a(),{href:"/users",className:k("/users"),prefetch:!1,children:[(0,n.jsx)(h.oy,{className:"w-4 h-4"}),!o&&(0,n.jsx)("span",{children:"Users"})]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-1 ".concat(o?"ml-0":"ml-auto"),children:[(0,n.jsx)(f.WH,{content:"Documentation",className:"text-sm text-muted-foreground",children:(0,n.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:[!o&&(0,n.jsx)("span",{className:"mr-1",children:"Docs"}),(0,n.jsx)(h.h0,{className:"".concat(o?"w-4 h-4":"w-3.5 h-3.5")})]})}),(0,n.jsx)(f.WH,{content:"GitHub Repository",className:"text-sm text-muted-foreground",children:(0,n.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,n.jsx)(h.fy,{className:"".concat(o?"w-4 h-4":"w-5 h-5")})})}),(0,n.jsx)(f.WH,{content:"Join Slack",className:"text-sm text-muted-foreground",children:(0,n.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,n.jsx)(h.mU,{className:"".concat(o?"w-4 h-4":"w-5 h-5")})})}),(0,n.jsx)(f.WH,{content:"Leave Feedback",className:"text-sm text-muted-foreground",children:(0,n.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,n.jsx)(h.aD,{className:"".concat(o?"w-4 h-4":"w-5 h-5")})})}),(0,n.jsx)("div",{className:"border-l border-gray-200 h-6"}),(0,n.jsx)(f.WH,{content:"Configuration",className:"text-sm text-muted-foreground",children:(0,n.jsx)(a(),{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,n.jsx)(x.Z,{className:"".concat(o?"w-4 h-4":"w-5 h-5")})})}),l&&(0,n.jsxs)("div",{className:"relative",ref:v,children:[(0,n.jsx)("button",{onClick:()=>g(!j),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,n.jsx)("div",{className:"".concat(o?"w-6 h-6":"w-7 h-7"," bg-blue-600 text-white rounded-full flex items-center justify-center font-medium ").concat(o?"text-xs":"text-sm"," hover:bg-blue-700 transition-colors"),children:l?l.includes("@")?l.split("@")[0].charAt(0).toUpperCase():l.charAt(0).toUpperCase():"?"})}),j&&(0,n.jsxs)("div",{className:"absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg z-50 border border-gray-200",children:[(e=l,t=null,l&&l.includes("@")&&(e=l.split("@")[0],t=l),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"px-4 pt-2 pb-1 text-sm font-medium text-gray-900",children:e}),t&&(0,n.jsx)("div",{className:"px-4 pt-0 pb-1 text-xs text-gray-500",children:t}),p&&(0,n.jsx)("div",{className:"px-4 pt-0 pb-2 text-xs",children:"admin"===p?(0,n.jsxs)("span",{className:"inline-flex items-center text-blue-600",children:[(0,n.jsx)(h.r7,{className:"w-3 h-3 mr-1"}),"Admin"]}):(0,n.jsxs)("span",{className:"inline-flex items-center text-gray-600",children:[(0,n.jsx)(u.Z,{className:"w-3 h-3 mr-1"}),"User"]})})]})),(0,n.jsx)("div",{className:"border-t border-gray-200 mx-1 my-1"}),(0,n.jsx)(a(),{href:"/users",className:"block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-blue-600",onClick:()=>g(!1),prefetch:!1,children:"See all users"})]})]})]})]})})}function g(e){let{children:t,highlighted:r}=e;return(0,m.X)(),(0,n.jsxs)("div",{className:"min-h-screen bg-gray-50",children:[(0,n.jsx)("div",{className:"fixed top-0 left-0 right-0 z-50 shadow-sm",children:(0,n.jsx)(j,{})}),(0,n.jsx)("div",{className:"transition-all duration-200 ease-in-out min-h-screen",style:{paddingTop:"56px"},children:(0,n.jsx)("main",{className:"p-6",children:t})})]})}function v(e){return(0,n.jsx)(p,{children:(0,n.jsx)(g,{...e})})}},3001:function(e,t,r){r.d(t,{X:function(){return s}});var n=r(7294);function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[t,r]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let t=()=>{r(window.innerWidth<e)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[e]),t}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[513,211],{803:function(e,r,t){t.d(r,{z:function(){return d}});var s=t(5893),n=t(7294),a=t(8426),l=t(2003),o=t(2350);let i=(0,l.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"}}),d=n.forwardRef((e,r)=>{let{className:t,variant:n,size:l,asChild:d=!1,...c}=e,u=d?a.g7:"button";return(0,s.jsx)(u,{className:(0,o.cn)(i({variant:n,size:l,className:t})),ref:r,...c})});d.displayName="Button"},7673:function(e,r,t){t.d(r,{Ol:function(){return d},Zb:function(){return i},aY:function(){return f},eW:function(){return m},ll:function(){return c}});var s=t(5893),n=t(7294),a=t(5697),l=t.n(a),o=t(2350);let i=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a,children:n})});i.displayName="Card",i.propTypes={className:l().string,children:l().node};let d=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("flex flex-col space-y-1.5 p-6",t),...a,children:n})});d.displayName="CardHeader",d.propTypes={className:l().string,children:l().node};let c=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("h3",{ref:r,className:(0,o.cn)("text-2xl font-semibold leading-none tracking-tight",t),...a,children:n})});c.displayName="CardTitle",c.propTypes={className:l().string,children:l().node};let u=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("p",{ref:r,className:(0,o.cn)("text-sm text-muted-foreground",t),...a,children:n})});u.displayName="CardDescription",u.propTypes={className:l().string,children:l().node};let f=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("p-6 pt-0",t),...a,children:n})});f.displayName="CardContent",f.propTypes={className:l().string,children:l().node};let m=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("flex items-center p-6 pt-0",t),...a,children:n})});m.displayName="CardFooter",m.propTypes={className:l().string,children:l().node}},4513:function(e,r,t){t.r(r),t.d(r,{NewWorkspace:function(){return y}});var s=t(5893),n=t(7294),a=t(1163),l=t(1664),o=t.n(l),i=t(5152),d=t.n(i),c=t(7324),u=t(803),f=t(2350);let m=n.forwardRef((e,r)=>{let{className:t,type:n,...a}=e;return(0,s.jsx)("input",{type:n,className:(0,f.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...a})});m.displayName="Input";var p=t(5320),x=n.forwardRef((e,r)=>(0,s.jsx)(p.WV.label,{...e,ref:r,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));x.displayName="Label";let b=(0,t(2003).j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),h=n.forwardRef((e,r)=>{let{className:t,...n}=e;return(0,s.jsx)(x,{ref:r,className:(0,f.cn)(b(),t),...n})});h.displayName=x.displayName;var g=t(7673);let v=d()(()=>Promise.all([t.e(616),t.e(799),t.e(804),t.e(798),t.e(947),t.e(470),t.e(969),t.e(856),t.e(973),t.e(938),t.e(843)]).then(t.bind(t,5843)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[5843]},ssr:!1});function y(){(0,a.useRouter)();let[e,r]=(0,n.useState)(""),[t,l]=(0,n.useState)(!1),[i,d]=(0,n.useState)({}),[f,p]=(0,n.useState)(!0);(0,n.useEffect)(()=>{x()},[]);let x=async()=>{try{let e=await (0,c.fX)();d(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{p(!1)}},b=()=>{e.trim()&&!y&&l(!0)},y=e.trim()&&i.hasOwnProperty(e.trim()),N=e.trim()&&!y;return t?(0,s.jsx)(v,{workspaceName:e,isNewWorkspace:!0}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,s.jsxs)("div",{className:"text-base flex items-center",children:[(0,s.jsx)(o(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,s.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,s.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,s.jsxs)(g.Zb,{className:"max-w-md",children:[(0,s.jsx)(g.Ol,{children:(0,s.jsx)(g.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,s.jsxs)(g.aY,{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(h,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,s.jsx)(m,{id:"workspace-name",value:e,onChange:e=>r(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&N&&b()}}),y?(0,s.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,s.jsx)(o(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,s.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,s.jsx)(u.z,{onClick:b,disabled:!N||f,className:"w-full bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:f?"Loading...":"Next: Configure Workspace"})]})]})]})}},2003:function(e,r,t){t.d(r,{j:function(){return l}});var s=t(512);let n=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=s.W,l=(e,r)=>t=>{var s;if((null==r?void 0:r.variants)==null)return a(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:l,defaultVariants:o}=r,i=Object.keys(l).map(e=>{let r=null==t?void 0:t[e],s=null==o?void 0:o[e];if(null===r)return null;let a=n(r)||n(s);return l[e][a]}),d=t&&Object.entries(t).reduce((e,r)=>{let[t,s]=r;return void 0===s||(e[t]=s),e},{});return a(e,i,null==r?void 0:null===(s=r.compoundVariants)||void 0===s?void 0:s.reduce((e,r)=>{let{class:t,className:s,...n}=r;return Object.entries(n).every(e=>{let[r,t]=e;return Array.isArray(t)?t.includes({...o,...d}[r]):({...o,...d})[r]===t})?[...e,t,s]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[513,211],{803:function(e,r,t){t.d(r,{z:function(){return d}});var s=t(5893),n=t(7294),a=t(8426),l=t(2003),o=t(2350);let i=(0,l.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"}}),d=n.forwardRef((e,r)=>{let{className:t,variant:n,size:l,asChild:d=!1,...c}=e,u=d?a.g7:"button";return(0,s.jsx)(u,{className:(0,o.cn)(i({variant:n,size:l,className:t})),ref:r,...c})});d.displayName="Button"},7673:function(e,r,t){t.d(r,{Ol:function(){return d},Zb:function(){return i},aY:function(){return f},eW:function(){return m},ll:function(){return c}});var s=t(5893),n=t(7294),a=t(5697),l=t.n(a),o=t(2350);let i=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",t),...a,children:n})});i.displayName="Card",i.propTypes={className:l().string,children:l().node};let d=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("flex flex-col space-y-1.5 p-6",t),...a,children:n})});d.displayName="CardHeader",d.propTypes={className:l().string,children:l().node};let c=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("h3",{ref:r,className:(0,o.cn)("text-2xl font-semibold leading-none tracking-tight",t),...a,children:n})});c.displayName="CardTitle",c.propTypes={className:l().string,children:l().node};let u=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("p",{ref:r,className:(0,o.cn)("text-sm text-muted-foreground",t),...a,children:n})});u.displayName="CardDescription",u.propTypes={className:l().string,children:l().node};let f=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("p-6 pt-0",t),...a,children:n})});f.displayName="CardContent",f.propTypes={className:l().string,children:l().node};let m=n.forwardRef((e,r)=>{let{className:t,children:n,...a}=e;return(0,s.jsx)("div",{ref:r,className:(0,o.cn)("flex items-center p-6 pt-0",t),...a,children:n})});m.displayName="CardFooter",m.propTypes={className:l().string,children:l().node}},4513:function(e,r,t){t.r(r),t.d(r,{NewWorkspace:function(){return y}});var s=t(5893),n=t(7294),a=t(1163),l=t(1664),o=t.n(l),i=t(5152),d=t.n(i),c=t(7324),u=t(803),f=t(2350);let m=n.forwardRef((e,r)=>{let{className:t,type:n,...a}=e;return(0,s.jsx)("input",{type:n,className:(0,f.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...a})});m.displayName="Input";var p=t(5320),x=n.forwardRef((e,r)=>(0,s.jsx)(p.WV.label,{...e,ref:r,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));x.displayName="Label";let b=(0,t(2003).j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),h=n.forwardRef((e,r)=>{let{className:t,...n}=e;return(0,s.jsx)(x,{ref:r,className:(0,f.cn)(b(),t),...n})});h.displayName=x.displayName;var g=t(7673);let v=d()(()=>Promise.all([t.e(616),t.e(799),t.e(804),t.e(798),t.e(947),t.e(989),t.e(470),t.e(969),t.e(856),t.e(973),t.e(938),t.e(843)]).then(t.bind(t,5843)).then(e=>e.WorkspaceEditor),{loadableGenerated:{webpack:()=>[5843]},ssr:!1});function y(){(0,a.useRouter)();let[e,r]=(0,n.useState)(""),[t,l]=(0,n.useState)(!1),[i,d]=(0,n.useState)({}),[f,p]=(0,n.useState)(!0);(0,n.useEffect)(()=>{x()},[]);let x=async()=>{try{let e=await (0,c.fX)();d(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{p(!1)}},b=()=>{e.trim()&&!y&&l(!0)},y=e.trim()&&i.hasOwnProperty(e.trim()),N=e.trim()&&!y;return t?(0,s.jsx)(v,{workspaceName:e,isNewWorkspace:!0}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,s.jsxs)("div",{className:"text-base flex items-center",children:[(0,s.jsx)(o(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,s.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,s.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,s.jsxs)(g.Zb,{className:"max-w-md",children:[(0,s.jsx)(g.Ol,{children:(0,s.jsx)(g.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,s.jsxs)(g.aY,{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(h,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,s.jsx)(m,{id:"workspace-name",value:e,onChange:e=>r(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&N&&b()}}),y?(0,s.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,s.jsx)(o(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,s.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,s.jsx)(u.z,{onClick:b,disabled:!N||f,className:"w-full bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:f?"Loading...":"Next: Configure Workspace"})]})]})]})}},2003:function(e,r,t){t.d(r,{j:function(){return l}});var s=t(512);let n=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,a=s.W,l=(e,r)=>t=>{var s;if((null==r?void 0:r.variants)==null)return a(e,null==t?void 0:t.class,null==t?void 0:t.className);let{variants:l,defaultVariants:o}=r,i=Object.keys(l).map(e=>{let r=null==t?void 0:t[e],s=null==o?void 0:o[e];if(null===r)return null;let a=n(r)||n(s);return l[e][a]}),d=t&&Object.entries(t).reduce((e,r)=>{let[t,s]=r;return void 0===s||(e[t]=s),e},{});return a(e,i,null==r?void 0:null===(s=r.compoundVariants)||void 0===s?void 0:s.reduce((e,r)=>{let{class:t,className:s,...n}=r;return Object.entries(n).every(e=>{let[r,t]=e;return Array.isArray(t)?t.includes({...o,...d}[r]):({...o,...d})[r]===t})?[...e,t,s]:e},[]),null==t?void 0:t.class,null==t?void 0:t.className)}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[856],{3266:function(e,t,r){r.d(t,{QL:function(){return g},Sl:function(){return i},getClusters:function(){return c},uR:function(){return u}});var a=r(7294),s=r(5821),o=r(7145),l=r(6378);let n={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function c(){let{clusterNames:e=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await o.x.fetch("/status",{cluster_names:e,all_users:!0})).map(e=>{let t="",r=t=e.zone?e.zone:e.region;return t&&t.length>25&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e||e.length<=t)return e;if(t<=3)return"...";let r=Math.floor((t-3)/2),a=r+(t-3)%2;return 0===r?e.substring(0,a)+"...":e.substring(0,a)+"..."+e.substring(e.length-r)}(t,25)),{status:n[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra:r?"".concat(e.cloud," (").concat(r,")"):e.cloud,cpus:e.cpus,mem:e.memory,gpus:e.accelerators,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:new Date(1e3*e.launched_at),num_nodes:e.nodes,workspace:e.workspace,autostop:e.autostop,to_down:e.to_down,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){return console.error("Error fetching clusters:",e),[]}}async function u(){try{let e=await o.x.fetch("/cost_report",{days:30});console.log("Raw cluster history data:",e);let t=e.map(e=>{let t="Unknown";e.cloud?t=e.cloud:e.resources&&e.resources.cloud&&(t=e.resources.cloud);let r=e.user_name||"-";return{status:e.status?n[e.status]:"TERMINATED",cluster:e.name,user:r,user_hash:e.user_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,to_down:!1,cluster_hash:e.cluster_hash,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",t),t}catch(e){return console.error("Error fetching cluster history:",e),[]}}async function i(e){let{clusterName:t,jobId:r,onNewLog:a,workspace:l}=e;try{await o.x.stream("/logs",{follow:!1,cluster_name:t,job_id:r,override_skypilot_config:{active_workspace:l||"default"}},a)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,s.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function d(e){let{clusterName:t,workspace:r}=e;try{return(await o.x.fetch("/queue",{cluster_name:t,all_users:!0,override_skypilot_config:{active_workspace:r}})).map(e=>{let a=e.end_at?e.end_at:Date.now()/1e3,s=0,o=0;return e.submitted_at&&(s=a-e.submitted_at),e.start_at&&(o=a-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:s,job_duration:o,infra:"",logs:"",workspace:r||"default"}})}catch(e){return console.error("Error fetching cluster jobs:",e),[]}}function g(e){let{cluster:t,job:r=null}=e,[s,o]=(0,a.useState)(null),[n,u]=(0,a.useState)(null),[i,g]=(0,a.useState)(!0),[f,_]=(0,a.useState)(!0),h=(0,a.useCallback)(async()=>{if(t)try{g(!0);let e=await l.default.get(c,[{clusterNames:[t]}]);return o(e[0]),e[0]}catch(e){console.error("Error fetching cluster data:",e)}finally{g(!1)}return null},[t]),p=(0,a.useCallback)(async e=>{if(t)try{_(!0);let r=await l.default.get(d,[{clusterName:t,workspace:e||"default"}]);u(r)}catch(e){console.error("Error fetching cluster job data:",e)}finally{_(!1)}},[t]),m=(0,a.useCallback)(async()=>{l.default.invalidate(c,[{clusterNames:[t]}]);let e=await h();e&&(l.default.invalidate(d,[{clusterName:t,workspace:e.workspace||"default"}]),await p(e.workspace))},[h,p,t]),b=(0,a.useCallback)(async()=>{s&&(l.default.invalidate(d,[{clusterName:t,workspace:s.workspace||"default"}]),await p(s.workspace))},[p,s,t]);return(0,a.useEffect)(()=>{(async()=>{let e=await h();e&&p(e.workspace)})()},[t,r,h,p]),{clusterData:s,clusterJobData:n,loading:i,clusterDetailsLoading:i,clusterJobsLoading:f,refreshData:m,refreshClusterJobsOnly:b}}},2045:function(e,t,r){r.d(t,{l4:function(){return l}});var a=r(3225),s=r(7145);async function o(e,t){try{let r=[];try{let e=await s.x.get("/enabled_clouds"),t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("X-Request-ID"),a=await s.x.get("/api/get?request_id=".concat(t)),o=await a.json();r=o.return_value?JSON.parse(o.return_value):[],console.log("Enabled clouds:",r)}catch(e){console.error("Error fetching enabled clouds:",e),r=[]}let o={};a.$m.forEach(e=>{let t=r.includes(e.toLowerCase());o[e]={name:e,clusters:0,jobs:0,enabled:t}}),e.forEach(e=>{if(e.cloud){let t=e.cloud;o[t]&&(o[t].clusters+=1,o[t].enabled=!0)}}),t.forEach(e=>{if(e.cloud){let t=e.cloud;o[t]&&(o[t].jobs+=1,o[t].enabled=!0)}});let l=a.$m.length,n=Object.values(o).filter(e=>e.enabled).length;return{clouds:Object.values(o).filter(e=>e.enabled).sort((e,t)=>t.clusters-e.clusters||t.jobs-e.jobs),totalClouds:l,enabledClouds:n}}catch(e){return console.error("Error fetching cloud infrastructure:",e),{clouds:[],totalClouds:a.$m.length,enabledClouds:0}}}async function l(){let{getClusters:e}=await Promise.resolve().then(r.bind(r,3266)),{getManagedJobs:t}=await Promise.resolve().then(r.bind(r,8969)),a=(await Promise.resolve().then(r.bind(r,6378))).default,[s,l]=await Promise.all([a.get(e),a.get(t,[{allUsers:!0}])]),c=s||[],u=(null==l?void 0:l.jobs)||[],[i,d]=await Promise.all([n(c,u),o(c,u)]);return{gpuData:i,cloudData:d}}async function n(e,t){return await g({clusters:e||[],jobs:t||[]})}async function c(){try{let e=await s.x.post("/realtime_kubernetes_gpu_availability",{context:null,name_filter:null,quantity_filter:null});if(!e.ok)return console.error("Error fetching Kubernetes context GPUs (in getKubernetesContextGPUs): ".concat(e.status," ").concat(e.statusText)),[];let t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("x-request-id");if(!t)return console.error("No request ID returned for Kubernetes GPU availability (in getKubernetesContextGPUs)"),[];let r=await s.x.get("/api/get?request_id=".concat(t)),a=await r.text();if(500===r.status){try{let e=JSON.parse(a);if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);console.error("[infra.jsx] getKubernetesContextGPUs: Server error detail:",t.message)}catch(t){console.error("[infra.jsx] getKubernetesContextGPUs: Error parsing server error JSON:",t,"Original error text:",e.detail.error)}}catch(e){console.error("[infra.jsx] getKubernetesContextGPUs: Error parsing 500 error response JSON:",e,"Raw text was:",a)}return[]}let o=JSON.parse(a);return o.return_value?JSON.parse(o.return_value):[]}catch(e){return console.error("[infra.jsx] Outer error in getKubernetesContextGPUs:",e),[]}}async function u(){try{let e=await s.x.get("/all_contexts");if(!e.ok)return console.error("Error fetching all contexts: ".concat(e.status," ").concat(e.statusText)),[];let t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("x-request-id");if(!t)return console.error("No request ID returned for /all_contexts"),[];let r=await s.x.get("/api/get?request_id=".concat(t)),a=await r.json();return a.return_value?JSON.parse(a.return_value):[]}catch(e){return console.error("[infra.jsx] Error in getAllContexts:",e),[]}}async function i(e){try{let t=await s.x.post("/kubernetes_node_info",{context:e}),r=t.headers.get("X-Skypilot-Request-ID")||t.headers.get("x-request-id"),a=await s.x.get("/api/get?request_id=".concat(r));if(500===a.status){try{let e=await a.json();if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);console.error("Error fetching Kubernetes per node GPUs:",t.message)}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{}}let o=await a.json();return(o.return_value?JSON.parse(o.return_value):{}).node_info_dict||{}}catch(t){return console.error("[infra.jsx] Error in getKubernetesPerNodeGPUs for context",e,":",t),{}}}async function d(e){try{let t=e.clusters,r=e.jobs,a={};return t.forEach(e=>{let t=null;if("Kubernetes"===e.cloud)(t=e.region)&&(t="kubernetes/".concat(t));else if("SSH"===e.cloud&&(t=e.region)){let e=t.startsWith("ssh-")?t.substring(4):t;t="ssh/".concat(e)}t&&(a[t]||(a[t]={clusters:0,jobs:0}),a[t].clusters+=1)}),r.forEach(e=>{let t=null;if("Kubernetes"===e.cloud)(t=e.region)&&(t="kubernetes/".concat(t));else if("SSH"===e.cloud&&(t=e.region)){let e=t.startsWith("ssh-")?t.substring(4):t;t="ssh/".concat(e)}t&&(a[t]||(a[t]={clusters:0,jobs:0}),a[t].jobs+=1)}),a}catch(e){return console.error("=== Error in getContextClustersAndJobs ===",e),{}}}async function g(e){try{let o=await u();if(!o||0===o.length)return console.log("No contexts found from /all_contexts endpoint."),{allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{}};let l=await d(e),n=await c(),g=new Map;n&&n.forEach(e=>{g.set(e[0],e[1])});let f={},_={},h={};for(let e of o){_[e]||(_[e]=[]);let o=g.get(e);if(o&&o.length>0)for(let t of o){let r=t[0],a=t[1].join(", "),s=t[2],o=t[3];r in f?(f[r].gpu_total+=s,f[r].gpu_free+=o):f[r]={gpu_total:s,gpu_free:o,gpu_name:r},_[e].push({gpu_name:r,gpu_requestable_qty_per_node:a,gpu_total:s,gpu_free:o,context:e})}let l=await i(e);if(l&&Object.keys(l).length>0)for(let o in l){var t,r,a,s;let n=l[o],c=n.accelerator_type||"-",u=null!==(a=null===(t=n.total)||void 0===t?void 0:t.accelerator_count)&&void 0!==a?a:0,i=null!==(s=null===(r=n.free)||void 0===r?void 0:r.accelerators_available)&&void 0!==s?s:0;h["".concat(e,"/").concat(o)]={node_name:n.name,gpu_name:c,gpu_total:u,gpu_free:i,context:e},"-"===c||_[e].some(e=>e.gpu_name===c)||(c in f||(f[c]={gpu_total:0,gpu_free:0,gpu_name:c}),_[e].find(e=>e.gpu_name===c)||_[e].push({gpu_name:c,gpu_requestable_qty_per_node:"-",gpu_total:0,gpu_free:0,context:e}))}0===_[e].length&&l&&Object.keys(l).length}return{allContextNames:o.sort(),allGPUs:Object.values(f).sort((e,t)=>e.gpu_name.localeCompare(t.gpu_name)),perContextGPUs:Object.values(_).flat().sort((e,t)=>e.context.localeCompare(t.context)||e.gpu_name.localeCompare(t.gpu_name)),perNodeGPUs:Object.values(h).sort((e,t)=>e.context.localeCompare(t.context)||e.node_name.localeCompare(t.node_name)||e.gpu_name.localeCompare(t.gpu_name)),contextStats:l}}catch(e){return console.error("[infra.jsx] Outer error in getKubernetesGPUs:",e),{allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{}}}}},3081:function(e,t,r){r.d(t,{R:function(){return s}}),r(3266),r(8969);var a=r(7145);async function s(){try{let e=await a.x.get("/users");if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return(await e.json()).map(e=>({userId:e.id,username:e.name,role:e.role}))||[]}catch(e){return console.error("Failed to fetch users:",e),[]}}},6856:function(e,t,r){var a=r(6378),s=r(3266),o=r(8969),l=r(7324),n=r(3081),c=r(2045);let u={base:{getClusters:{fn:s.getClusters,args:[]},getClusterHistory:{fn:s.uR,args:[]},getManagedJobs:{fn:o.getManagedJobs,args:[{allUsers:!0}]},getWorkspaces:{fn:l.fX,args:[]},getUsers:{fn:n.R,args:[]},getInfraData:{fn:c.l4,args:[]}},dynamic:{getEnabledClouds:{fn:l.yz,requiresWorkspaces:!0}},pages:{clusters:["getClusters","getClusterHistory","getWorkspaces","getUsers"],jobs:["getManagedJobs","getClusters","getWorkspaces","getUsers"],infra:["getInfraData","getClusters","getManagedJobs"],workspaces:["getWorkspaces","getClusters","getManagedJobs","getEnabledClouds"],users:["getUsers","getClusters","getManagedJobs"]}};class i{async preloadForPage(e,t){let{backgroundPreload:r=!0,force:a=!1}=t||{};if(!u.pages[e]){console.warn("Unknown page: ".concat(e));return}console.log("[CachePreloader] Preloading cache for page: ".concat(e));try{await this._loadPageData(e,a),r&&this._backgroundPreloadOtherPages(e)}catch(t){console.error("[CachePreloader] Error preloading for page ".concat(e,":"),t)}}async _loadPageData(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=u.pages[e],s=[];for(let e of r)if(u.base[e]){let{fn:r,args:o}=u.base[e];t&&a.default.invalidate(r,o),s.push(a.default.get(r,o))}else"getEnabledClouds"===e&&s.push(this._loadEnabledCloudsForAllWorkspaces(t));await Promise.allSettled(s),console.log("[CachePreloader] Loaded data for page: ".concat(e))}async _loadEnabledCloudsForAllWorkspaces(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{e&&a.default.invalidate(l.fX);let t=await a.default.get(l.fX),r=Object.keys(t||{}).map(t=>(e&&a.default.invalidate(l.yz,[t]),a.default.get(l.yz,[t])));await Promise.allSettled(r)}catch(e){console.error("[CachePreloader] Error loading enabled clouds:",e)}}_backgroundPreloadOtherPages(e){if(this.isPreloading)return;this.isPreloading=!0;let t=Object.keys(u.pages).filter(t=>t!==e);console.log("[CachePreloader] Background preloading pages: ".concat(t.join(", "))),Promise.allSettled(t.map(async e=>{try{await this._loadPageData(e,!1),console.log("[CachePreloader] Background loaded: ".concat(e))}catch(t){console.error("[CachePreloader] Background load failed for ".concat(e,":"),t)}})).then(()=>{this.isPreloading=!1,console.log("[CachePreloader] Background preloading complete")})}async preloadBaseFunctions(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.log("[CachePreloader] Preloading all base functions");let t=Object.entries(u.base).map(t=>{let[r,{fn:s,args:o}]=t;return e&&a.default.invalidate(s,o),a.default.get(s,o).catch(e=>{console.error("[CachePreloader] Failed to preload ".concat(r,":"),e)})});await Promise.allSettled(t),console.log("[CachePreloader] Base functions preloaded")}getCacheStats(){return{...a.default.getStats(),isPreloading:this.isPreloading}}clearCache(){a.default.clear(),this.isPreloading=!1,this.preloadPromises.clear(),console.log("[CachePreloader] Cache cleared")}constructor(){this.isPreloading=!1,this.preloadPromises=new Map}}let d=new i;t.ZP=d}}]);
@@ -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 z},ManagedJobs:function(){return F},ManagedJobsTable:function(){return U},Status2Actions:function(){return q},filterJobsByName:function(){return _},filterJobsByUser:function(){return A},filterJobsByWorkspace:function(){return M},statusGroups:function(){return E}});var r=t(5893),n=t(7294),a=t(1163),l=t(1664),i=t.n(l),c=t(8799),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(3001),C=t(8950),S=t(6378),L=t(6856);let E={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 _(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.name||"").toLowerCase().includes(t))}function M(e,s){return s&&s!==I?e.filter(e=>(e.workspace||"default").toLowerCase()===s.toLowerCase()):e}function A(e,s){return s&&s!==R?e.filter(e=>(e.user_hash||e.user)===s):e}let D=(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},O=e=>{if(!e)return"-";let s=e instanceof Date?e:new Date(1e3*e);return(0,r.jsx)(h.Zg,{date:s})};function F(){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,k.X)(),[g,b]=(0,n.useState)(I),[w,y]=(0,n.useState)(R),[v,E]=(0,n.useState)(""),[_,M]=(0,n.useState)([]),[A,O]=(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&&E(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})},q=e=>{E(e),F(g,w,e)};return(0,n.useEffect)(()=>{(async()=>{try{await L.ZP.preloadForPage("jobs");let e=await S.default.get(j.fX),s=Object.keys(e),t=(await S.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 S.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:D(e.username,e.userId)})}),l.forEach(e=>{i.has(e.userId)||i.set(e.userId,{userId:e.userId,username:e.username,display:D(e.username,e.userId)})}),O(Array.from(i.values()).sort((e,s)=>e.display.localeCompare(s.display)))}catch(e){console.error("Error fetching data for filters:",e),M(["default"]),O([])}})()},[]),(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=>q(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:()=>q(""),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)(C.Ph,{value:g,onValueChange:e=>{b(e),F(e,w,v)},children:[(0,r.jsx)(C.i4,{className:"h-8 w-48 ml-2 mr-2 text-sm border-none focus:ring-0 focus:outline-none",children:(0,r.jsx)(C.ki,{placeholder:"Filter by workspace...",children:g===I?"All Workspaces":g})}),(0,r.jsxs)(C.Bw,{children:[(0,r.jsx)(C.Ql,{value:I,children:"All Workspaces"}),_.map(e=>(0,r.jsx)(C.Ql,{value:e,children:e},e))]})]}),(0,r.jsxs)(C.Ph,{value:w,onValueChange:e=>{y(e),F(g,e,v)},children:[(0,r.jsx)(C.i4,{className:"h-8 w-48 ml-2 mr-2 text-sm border-none focus:ring-0 focus:outline-none",children:(0,r.jsx)(C.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)(C.Bw,{children:[(0,r.jsx)(C.Ql,{value:R,children:"All Users"}),A.map(e=>(0,r.jsx)(C.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:()=>{S.default.invalidate(x.getManagedJobs,[{allUsers:!0}]),S.default.invalidate(j.fX),S.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)(U,{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 U(e){let{refreshInterval:s,setLoading:t,refreshDataRef:a,workspaceFilter:l,userFilter:j,nameFilter:p}=e,[f,b]=(0,n.useState)([]),[w,k]=(0,n.useState)({key:null,direction:"ascending"}),[C,L]=(0,n.useState)(!1),[I,R]=(0,n.useState)(!0),[D,F]=(0,n.useState)(1),[U,z]=(0,n.useState)(10),[P,Z]=(0,n.useState)(null),B=(0,n.useRef)(null),[T,G]=(0,n.useState)([]),[V,H]=(0,n.useState)({}),[Q,X]=(0,n.useState)(!1),[K,Y]=(0,n.useState)(!1),[$,ee]=(0,n.useState)(!1),[es,et]=(0,n.useState)("all"),[er,en]=(0,n.useState)(!0),[ea,el]=(0,n.useState)({isOpen:!1,title:"",message:"",onConfirm:null}),ei=async()=>{el({isOpen:!0,title:"Restart Controller",message:"Are you sure you want to restart the controller?",onConfirm:async()=>{try{ee(!0),L(!0),await (0,x.Ce)("restartcontroller"),await ec()}catch(e){console.error("Error restarting controller:",e)}finally{ee(!1),L(!1)}}})},ec=n.useCallback(async()=>{L(!0),t(!0);try{let[e,s]=await Promise.all([S.default.get(x.getManagedJobs,[{allUsers:!0}]),S.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?Y(!0):Y(!1),b(t),X(l),R(!1)}catch(e){console.error("Error fetching data:",e),b([]),X(!1),R(!1)}finally{L(!1),t(!1)}},[t]);n.useEffect(()=>{a&&(a.current=ec)},[a,ec]),(0,n.useEffect)(()=>{b([]);let e=!0;ec();let t=setInterval(()=>{e&&ec()},s);return()=>{e=!1,clearInterval(t)}},[s,ec]),(0,n.useEffect)(()=>{F(1)},[es,null==f?void 0:f.length]),(0,n.useEffect)(()=>{G([]),en(!0)},[es]);let eo=e=>{let s="ascending";w.key===e&&"ascending"===w.direction&&(s="descending"),k({key:e,direction:s})},ed=e=>w.key===e?"ascending"===w.direction?" ↑":" ↓":"";n.useMemo(()=>{let e=f||[];return{active:e.filter(e=>E.active.includes(e.status)).length,finished:e.filter(e=>E.finished.includes(e.status)).length}},[f]);let eu=e=>T.length>0?T.includes(e):"all"===es||E[es].includes(e),eh=n.useMemo(()=>{let e=M(f,l);return(e=_(e=A(e,j),p),T.length>0)?e.filter(e=>T.includes(e.status)):er?"all"===es?e:e.filter(e=>E[es].includes(e.status)):[]},[f,es,T,er,l,j,p]),ex=n.useMemo(()=>w.key?[...eh].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):eh,[eh,w]),em=Math.ceil(ex.length/U),ej=(D-1)*U,ep=ej+U,ef=ex.slice(ej,ep),eg=e=>{if(T.includes(e)){let s=T.filter(s=>s!==e);0===s.length?(en(!0),G([])):(G(s),en(!1))}else G([...T,e]),en(!1)};return(0,n.useEffect)(()=>{H((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:[!C&&(!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:()=>eg(s),className:"px-3 py-1 rounded-full flex items-center space-x-2 ".concat(eu(s)||T.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(eu(s)||T.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:()=>{et("all"),G([]),en(!0)},className:"text-sm font-medium ".concat("all"===es&&er?"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:()=>{et("active"),G([]),en(!0)},className:"text-sm font-medium ".concat("active"===es&&er?"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:()=>{et("finished"),G([]),en(!0)},className:"text-sm font-medium ".concat("finished"===es&&er?"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:()=>eo("id"),children:["ID",ed("id")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("name"),children:["Name",ed("name")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("user"),children:["User",ed("user")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("workspace"),children:["Workspace",ed("workspace")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("submitted_at"),children:["Submitted",ed("submitted_at")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("job_duration"),children:["Duration",ed("job_duration")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("status"),children:["Status",ed("status")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("resources_str"),children:["Requested",ed("resources_str")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("infra"),children:["Infra",ed("infra")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("cluster"),children:["Resources",ed("cluster")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>eo("recoveries"),children:["Recoveries",ed("recoveries")]}),(0,r.jsx)(u.ss,{children:"Details"}),(0,r.jsx)(u.ss,{children:"Logs"})]})}),(0,r.jsx)(u.RM,{children:C||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..."})]})})}):ef.length>0?(0,r.jsx)(r.Fragment,{children:ef.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:e.user}),(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:O(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)(J,{text:e.details,rowId:e.id,expandedRowId:P,setExpandedRowId:Z}):"-"}),(0,r.jsx)(u.pj,{children:(0,r.jsx)(q,{jobParent:"/jobs",jobId:e.id,managed:!0})})]}),P===e.id&&(0,r.jsx)(W,{text:e.details,colSpan:12,innerRef:B})]},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:[K&&(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..."})]})]}),!Q&&!K&&(0,r.jsx)("p",{className:"text-gray-500",children:"No active jobs"}),Q&&(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:ei,className:"text-sky-blue hover:text-sky-blue-bright",disabled:C||$,children:$?(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"]})})]})]})})})})]})}),ex&&ex.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:U,onChange:e=>{z(parseInt(e.target.value,10)),F(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:[ej+1," – ",Math.min(ep,ex.length)," of"," ",ex.length]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{F(e=>Math.max(e-1,1))},disabled:1===D,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:()=>{F(e=>Math.min(e+1,em))},disabled:D===em||0===em,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:ea.isOpen,onClose:()=>el({...ea,isOpen:!1}),onConfirm:ea.onConfirm,title:ea.title,message:ea.message,confirmClassName:"bg-blue-600 hover:bg-blue-700 text-white"})]})}function q(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 z(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,k]=(0,n.useState)(10),C=(0,n.useRef)(null),[S,L]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=e=>{j&&C.current&&!C.current.contains(e.target)&&p(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[j]);let E=n.useMemo(()=>{let e=t||[];return x&&x!==R&&(e=A(e,x)),m&&(e=_(e,m)),e},[t,x,m]);(0,n.useEffect)(()=>{JSON.stringify(t)!==JSON.stringify(S)&&L(t)},[t,S]);let I=n.useMemo(()=>g.key?[...E].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):E,[E,g]),M=e=>{let s="ascending";g.key===e&&"ascending"===g.direction&&(s="descending"),b({key:e,direction:s})},D=e=>g.key===e?"ascending"===g.direction?" ↑":" ↓":"",F=Math.ceil(I.length/y),U=(w-1)*y,z=U+y,P=I.slice(U,z);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:()=>M("id"),children:["ID",D("id")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("job"),children:["Name",D("job")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("user"),children:["User",D("user")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("workspace"),children:["Workspace",D("workspace")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("submitted_at"),children:["Submitted",D("submitted_at")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("job_duration"),children:["Duration",D("job_duration")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("status"),children:["Status",D("status")]}),(0,r.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>M("resources"),children:["Resources",D("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..."})]})})}):P.length>0?P.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)(J,{text:e.job||"Unnamed job",rowId:e.id,expandedRowId:j,setExpandedRowId:p})})}),(0,r.jsx)(u.pj,{children:e.user}),(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:O(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)(q,{jobParent:"/clusters/".concat(s),jobId:e.id,managed:!1})})]}),j===e.id&&(0,r.jsx)(W,{text:e.job||"Unnamed job",colSpan:9,innerRef:C})]},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=>{k(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:[U+1," – ",Math.min(z,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,F))},disabled:w===F||0===F,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 W(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 J(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([[969],{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=e.name||"anonymous",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
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[989],{8950:function(e,n,t){t.d(n,{Bw:function(){return h},Ph:function(){return d},Ql:function(){return g},i4:function(){return m},ki:function(){return u}});var a=t(5893),r=t(7294),o=t(2067),l=t(5895),s=t(7242),i=t(282),c=t(2350);let d=o.fC;o.ZA;let u=o.B4,m=r.forwardRef((e,n)=>{let{className:t,children:r,...s}=e;return(0,a.jsxs)(o.xz,{ref:n,className:(0,c.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[r,(0,a.jsx)(o.JO,{asChild:!0,children:(0,a.jsx)(l.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=o.xz.displayName;let f=r.forwardRef((e,n)=>{let{className:t,...r}=e;return(0,a.jsx)(o.u_,{ref:n,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",t),...r,children:(0,a.jsx)(s.Z,{className:"h-4 w-4"})})});f.displayName=o.u_.displayName;let p=r.forwardRef((e,n)=>{let{className:t,...r}=e;return(0,a.jsx)(o.$G,{ref:n,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",t),...r,children:(0,a.jsx)(l.Z,{className:"h-4 w-4"})})});p.displayName=o.$G.displayName;let h=r.forwardRef((e,n)=>{let{className:t,children:r,position:l="popper",...s}=e;return(0,a.jsx)(o.h_,{children:(0,a.jsxs)(o.VY,{ref:n,className:(0,c.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===l&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:l,...s,children:[(0,a.jsx)(f,{}),(0,a.jsx)(o.l_,{className:(0,c.cn)("p-1","popper"===l&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),(0,a.jsx)(p,{})]})})});h.displayName=o.VY.displayName,r.forwardRef((e,n)=>{let{className:t,...r}=e;return(0,a.jsx)(o.__,{ref:n,className:(0,c.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...r})}).displayName=o.__.displayName;let g=r.forwardRef((e,n)=>{let{className:t,children:r,...l}=e;return(0,a.jsxs)(o.ck,{ref:n,className:(0,c.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...l,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(o.wU,{children:(0,a.jsx)(i.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(o.eT,{children:r})]})});g.displayName=o.ck.displayName,r.forwardRef((e,n)=>{let{className:t,...r}=e;return(0,a.jsx)(o.Z0,{ref:n,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",t),...r})}).displayName=o.Z0.displayName},6989:function(e,n,t){t.d(n,{$B:function(){return p},LU:function(){return m},Md:function(){return u},WH:function(){return d},Zg:function(){return h},q8:function(){return f},xn:function(){return g},yc:function(){return i}});var a=t(5893),r=t(7294),o=t(3302),l=t(1886),s=t(8950);let i=t(1214).nb.REFRESH_INTERVAL,c={placement:"bottom",color:"default"},d=e=>{let{children:n,...t}=e,r=t.content;return t.content=void 0,(0,a.jsx)(o.e,{...c,...t,content:(0,a.jsx)("span",{className:"left-full w-max px-2 py-1 text-sm text-gray-100 bg-gray-500 text-sm capitalize rounded",children:r}),children:n})},u=e=>{let{children:n,...t}=e,r=t.content;return t.content=void 0,(0,a.jsx)(o.e,{...c,...t,content:(0,a.jsx)("span",{className:"left-full w-max px-2 py-1 text-sm text-gray-100 bg-gray-500 text-sm rounded",children:r}),children:n})};function m(e){if(!e&&0!==e)return"-";let n=e=Math.floor(e),t="",a=0;for(let e of[{value:31536e3,label:"y"},{value:2592e3,label:"mo"},{value:86400,label:"d"},{value:3600,label:"h"},{value:60,label:"m"},{value:1,label:"s"}])if(n>=e.value&&a<2){let r=Math.floor(n/e.value);t+="".concat(r).concat(e.label," "),n%=e.value,a++}return t.trim()||"0s"}function f(e){return e?(e=e.split("\n").filter(e=>!e.match(/<rich_.*?\[bold cyan\]/)&&!e.match(/<rich_.*>.*<\/rich_.*>/)&&!e.match(/├──/)&&!e.match(/└──/)).join("\n").replace(/\x1b\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGKH]/g,"")).split("\n").map(e=>{let n=e.match(/^([IWED])\s+(\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+([^:]+:\d+\])(.*)/);if(n){let[e,t,a,r,o]=n,l={I:"INFO",W:"WARNING",E:"ERROR",D:"DEBUG"}[t]||"";return'<span class="log-line '.concat(l,'"><span class="level">').concat(t,'</span><span class="timestamp">').concat(a,'</span><span class="location">').concat(r,'</span><span class="message">').concat(o,"</span></span>")}let t=e.match(/^(\([^)]+\))(.*)$/);if(t){let[e,n,a]=t;return'<span class="log-line"><span class="log-prefix">'.concat(n,'</span><span class="log-rest">').concat(a,"</span></span>")}return'<span class="log-line"><span class="message">'.concat(e,"</span></span>")}).join("\n"):""}function p(e){let{logs:n,controller:t=!1}=e,[o,l]=(0,r.useState)("all"),[i,c]=(0,r.useState)(n),[d,u]=(0,r.useState)([]);return(0,r.useEffect)(()=>{u(function(e){let n;let t=/\((head|worker\d+),/g,a=new Set;for(;null!==(n=t.exec(e));)a.add(n[1]);return Array.from(a).sort((e,n)=>"head"===e?-1:"head"===n?1:e.localeCompare(n,void 0,{numeric:!0,sensitivity:"base"}))}(n))},[n]),(0,r.useEffect)(()=>{"all"===o?c(n):c(n.split("\n").filter(e=>e.includes("(".concat(o,","))).join("\n"))},[o,n]),(0,a.jsxs)("div",{children:[(0,a.jsx)("style",{children:'\n .logs-container {\n background-color: #f7f7f7;\n padding: 16px;\n max-height: calc(100vh - 300px);\n overflow-y: auto;\n overflow-x: hidden;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;\n line-height: 1.5;\n border-radius: 6px;\n min-height: fit-content;\n }\n\n .log-line {\n display: block;\n white-space: pre-wrap;\n margin: 2px 0;\n }\n\n .log-line .level {\n display: inline;\n width: 1ch;\n margin-right: 1ch;\n font-weight: bold;\n }\n\n .log-line.INFO .level {\n color: #2563eb;\n }\n\n .log-line.WARNING .level {\n color: #d97706;\n }\n\n .log-line.ERROR .level {\n color: #dc2626;\n }\n\n .log-line.DEBUG .level {\n color: #6b7280;\n }\n\n .log-line .timestamp {\n color: #059669;\n margin-right: 1ch;\n white-space: nowrap;\n }\n\n .log-line .location {\n color: #6366f1;\n margin-right: 1ch;\n white-space: nowrap;\n }\n\n .log-line .message {\n color: #111827;\n word-break: break-word;\n white-space: pre-wrap;\n }\n\n .log-line .log-prefix {\n color: #6366f1;\n font-weight: 500;\n }\n\n .log-line .log-rest {\n color: #111827;\n word-break: break-word;\n white-space: pre-wrap;\n }\n'}),!t&&(0,a.jsx)("div",{style:{marginBottom:"1rem"},children:(0,a.jsxs)(s.Ph,{onValueChange:e=>l(e),value:o,children:[(0,a.jsx)(s.i4,{"aria-label":"Node",className:"focus:ring-0 focus:ring-offset-0",children:(0,a.jsx)(s.ki,{placeholder:"Select Node"})}),(0,a.jsxs)(s.Bw,{children:[(0,a.jsx)(s.Ql,{value:"all",children:"All Nodes"}),d.map(e=>(0,a.jsx)(s.Ql,{value:e,children:e},e))]})]})}),(0,a.jsx)("div",{className:"logs-container",dangerouslySetInnerHTML:{__html:i}})]})}function h(e){let n,{date:t}=e;if(!t)return"N/A";let r=new Date,o=t.getFullYear()+"-"+String(t.getMonth()+1).padStart(2,"0")+"-"+String(t.getDate()).padStart(2,"0"),s=t.toLocaleString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0,timeZoneName:"short"});return n=function(e){if(!e||"string"!=typeof e)return e;if("just now"===e)return"now";if("less than a minute ago"===e.toLowerCase())return"Less than 1m ago";let n=e.match(/^about\s+(\d+)\s+(\w+)\s+ago$/i);if(n){let e=n[1],t=n[2],a={second:"s",seconds:"s",minute:"m",minutes:"m",hour:"h",hours:"h",day:"d",days:"d",month:"mo",months:"mo",year:"yr",years:"yr"};if(a[t])return"".concat(e).concat(a[t]," ago")}let t=e.match(/^a[n]?\s+(\w+)\s+ago$/i);if(t){let e=t[1],n={second:"s",minute:"m",hour:"h",day:"d",month:"mo",year:"yr"};if(n[e])return"1".concat(n[e]," ago")}let a=e.match(/^(\d+)\s+(\w+)\s+ago$/i);if(a){let e=a[1],n=a[2],t={second:"s",seconds:"s",minute:"m",minutes:"m",hour:"h",hours:"h",day:"d",days:"d",month:"mo",months:"mo",year:"yr",years:"yr"};if(t[n])return"".concat(e).concat(t[n]," ago")}return e}((0,l.B)(t,r,{addSuffix:!0})),(0,a.jsx)(d,{content:o+", "+s,className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{className:"border-b border-dotted border-gray-400 cursor-help",children:n})})}function g(e){return e?e.getFullYear()+"-"+String(e.getMonth()+1).padStart(2,"0")+"-"+String(e.getDate()).padStart(2,"0")+", "+e.toLocaleString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0,timeZoneName:"short"}):"N/A"}},1214:function(e,n,t){t.d(n,{MO:function(){return o},ej:function(){return a},nb:function(){return r}});let a={DEFAULT_TTL:12e4},r={REFRESH_INTERVAL:3e4,GPU_REFRESH_INTERVAL:3e4},o={NAME_TRUNCATE_LENGTH:20}}}]);
@@ -17,4 +17,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
17
17
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18
18
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
19
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
20
- */Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return f}});let n=r(260)._(r(7294)),o=r(6725),l=[],u=[],a=!1;function i(e){let t=e(),r={loading:!0,loaded:null,error:null};return r.promise=t.then(e=>(r.loading=!1,r.loaded=e,e)).catch(e=>{throw r.loading=!1,r.error=e,e}),r}class s{promise(){return this._res.promise}retry(){this._clearTimeouts(),this._res=this._loadFn(this._opts.loader),this._state={pastDelay:!1,timedOut:!1};let{_res:e,_opts:t}=this;e.loading&&("number"==typeof t.delay&&(0===t.delay?this._state.pastDelay=!0:this._delay=setTimeout(()=>{this._update({pastDelay:!0})},t.delay)),"number"==typeof t.timeout&&(this._timeout=setTimeout(()=>{this._update({timedOut:!0})},t.timeout))),this._res.promise.then(()=>{this._update({}),this._clearTimeouts()}).catch(e=>{this._update({}),this._clearTimeouts()}),this._update({})}_update(e){this._state={...this._state,error:this._res.error,loaded:this._res.loaded,loading:this._res.loading,...e},this._callbacks.forEach(e=>e())}_clearTimeouts(){clearTimeout(this._delay),clearTimeout(this._timeout)}getCurrentValue(){return this._state}subscribe(e){return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}constructor(e,t){this._loadFn=e,this._opts=t,this._callbacks=new Set,this._delay=null,this._timeout=null,this.retry()}}function d(e){return function(e,t){let r=Object.assign({loader:null,loading:null,delay:200,timeout:null,webpack:null,modules:null},t),l=null;function i(){if(!l){let t=new s(e,r);l={getCurrentValue:t.getCurrentValue.bind(t),subscribe:t.subscribe.bind(t),retry:t.retry.bind(t),promise:t.promise.bind(t)}}return l.promise()}if(!a){let e=r.webpack?r.webpack():r.modules;e&&u.push(t=>{for(let r of e)if(t.includes(r))return i()})}function d(e,t){!function(){i();let e=n.default.useContext(o.LoadableContext);e&&Array.isArray(r.modules)&&r.modules.forEach(t=>{e(t)})}();let u=n.default.useSyncExternalStore(l.subscribe,l.getCurrentValue,l.getCurrentValue);return n.default.useImperativeHandle(t,()=>({retry:l.retry}),[]),n.default.useMemo(()=>{var t;return u.loading||u.error?n.default.createElement(r.loading,{isLoading:u.loading,pastDelay:u.pastDelay,timedOut:u.timedOut,error:u.error,retry:l.retry}):u.loaded?n.default.createElement((t=u.loaded)&&t.default?t.default:t,e):null},[e,u])}return d.preload=()=>i(),d.displayName="LoadableComponent",n.default.forwardRef(d)}(i,e)}function c(e,t){let r=[];for(;e.length;){let n=e.pop();r.push(n(t))}return Promise.all(r).then(()=>{if(e.length)return c(e,t)})}d.preloadAll=()=>new Promise((e,t)=>{c(l).then(e,t)}),d.preloadReady=e=>(void 0===e&&(e=[]),new Promise(t=>{let r=()=>(a=!0,t());c(u,e).then(r,r)})),window.__NEXT_PRELOADREADY=d.preloadReady;let f=d},3225:function(e,t,r){"use strict";r.d(t,{$m:function(){return i},Bo:function(){return u},GW:function(){return o},MN:function(){return s},f4:function(){return n},iW:function(){return a},mF:function(){return l}});let n="/internal/dashboard",o="/dashboard";"/api/v1".replace(/^http/,"ws");let l="ClusterDoesNotExist",u="NotSupportedError",a="ClusterNotUpError",i=["AWS","Azure","GCP","IBM","Lambda","SCP","OCI","RunPod","VAST","vSphere","Cudo","FluidStack","Paperspace","DO","Nebius"],s=Object.fromEntries([...i.map(e=>[e.toLowerCase(),e]),["kubernetes","Kubernetes"],["ssh","SSH Node Pool"]])},2586:function(e,t,r){"use strict";r.r(t);var n=r(5893),o=r(7294),l=r(5152),u=r.n(l),a=r(5697),i=r.n(a);r(6501);var s=r(3225);let d=u()(()=>Promise.all([r.e(616),r.e(760),r.e(804),r.e(664),r.e(470),r.e(350)]).then(r.bind(r,9470)).then(e=>e.Layout),{loadableGenerated:{webpack:()=>[9470]},ssr:!1});function c(e){let{Component:t,pageProps:r}=e;return(0,o.useEffect)(()=>{let e=document.createElement("link");e.rel="icon",e.href="".concat(s.GW,"/favicon.ico"),document.head.appendChild(e)},[]),(0,n.jsx)(d,{highlighted:r.highlighted,children:(0,n.jsx)(t,{...r})})}c.propTypes={Component:i().elementType.isRequired,pageProps:i().object.isRequired},t.default=c},6501:function(){},5152:function(e,t,r){e.exports=r(9606)},2703:function(e,t,r){"use strict";var n=r(414);function o(){}function l(){}l.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,l,u){if(u!==n){var a=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:l,resetWarningCache:o};return r.PropTypes=r,r}},5697:function(e,t,r){e.exports=r(2703)()},414:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[774,179],function(){return t(1118),t(6036)}),_N_E=e.O()}]);
20
+ */Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return f}});let n=r(260)._(r(7294)),o=r(6725),l=[],u=[],a=!1;function i(e){let t=e(),r={loading:!0,loaded:null,error:null};return r.promise=t.then(e=>(r.loading=!1,r.loaded=e,e)).catch(e=>{throw r.loading=!1,r.error=e,e}),r}class s{promise(){return this._res.promise}retry(){this._clearTimeouts(),this._res=this._loadFn(this._opts.loader),this._state={pastDelay:!1,timedOut:!1};let{_res:e,_opts:t}=this;e.loading&&("number"==typeof t.delay&&(0===t.delay?this._state.pastDelay=!0:this._delay=setTimeout(()=>{this._update({pastDelay:!0})},t.delay)),"number"==typeof t.timeout&&(this._timeout=setTimeout(()=>{this._update({timedOut:!0})},t.timeout))),this._res.promise.then(()=>{this._update({}),this._clearTimeouts()}).catch(e=>{this._update({}),this._clearTimeouts()}),this._update({})}_update(e){this._state={...this._state,error:this._res.error,loaded:this._res.loaded,loading:this._res.loading,...e},this._callbacks.forEach(e=>e())}_clearTimeouts(){clearTimeout(this._delay),clearTimeout(this._timeout)}getCurrentValue(){return this._state}subscribe(e){return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}constructor(e,t){this._loadFn=e,this._opts=t,this._callbacks=new Set,this._delay=null,this._timeout=null,this.retry()}}function d(e){return function(e,t){let r=Object.assign({loader:null,loading:null,delay:200,timeout:null,webpack:null,modules:null},t),l=null;function i(){if(!l){let t=new s(e,r);l={getCurrentValue:t.getCurrentValue.bind(t),subscribe:t.subscribe.bind(t),retry:t.retry.bind(t),promise:t.promise.bind(t)}}return l.promise()}if(!a){let e=r.webpack?r.webpack():r.modules;e&&u.push(t=>{for(let r of e)if(t.includes(r))return i()})}function d(e,t){!function(){i();let e=n.default.useContext(o.LoadableContext);e&&Array.isArray(r.modules)&&r.modules.forEach(t=>{e(t)})}();let u=n.default.useSyncExternalStore(l.subscribe,l.getCurrentValue,l.getCurrentValue);return n.default.useImperativeHandle(t,()=>({retry:l.retry}),[]),n.default.useMemo(()=>{var t;return u.loading||u.error?n.default.createElement(r.loading,{isLoading:u.loading,pastDelay:u.pastDelay,timedOut:u.timedOut,error:u.error,retry:l.retry}):u.loaded?n.default.createElement((t=u.loaded)&&t.default?t.default:t,e):null},[e,u])}return d.preload=()=>i(),d.displayName="LoadableComponent",n.default.forwardRef(d)}(i,e)}function c(e,t){let r=[];for(;e.length;){let n=e.pop();r.push(n(t))}return Promise.all(r).then(()=>{if(e.length)return c(e,t)})}d.preloadAll=()=>new Promise((e,t)=>{c(l).then(e,t)}),d.preloadReady=e=>(void 0===e&&(e=[]),new Promise(t=>{let r=()=>(a=!0,t());c(u,e).then(r,r)})),window.__NEXT_PRELOADREADY=d.preloadReady;let f=d},3225:function(e,t,r){"use strict";r.d(t,{$m:function(){return i},Bo:function(){return u},GW:function(){return o},MN:function(){return s},f4:function(){return n},iW:function(){return a},mF:function(){return l}});let n="/internal/dashboard",o="/dashboard";"/api/v1".replace(/^http/,"ws");let l="ClusterDoesNotExist",u="NotSupportedError",a="ClusterNotUpError",i=["AWS","Azure","GCP","IBM","Lambda","SCP","OCI","RunPod","VAST","vSphere","Cudo","FluidStack","Paperspace","DO","Nebius"],s=Object.fromEntries([...i.map(e=>[e.toLowerCase(),e]),["kubernetes","Kubernetes"],["ssh","SSH Node Pool"]])},2586:function(e,t,r){"use strict";r.r(t);var n=r(5893),o=r(7294),l=r(5152),u=r.n(l),a=r(5697),i=r.n(a);r(6501);var s=r(3225);let d=u()(()=>Promise.all([r.e(616),r.e(760),r.e(804),r.e(664),r.e(989),r.e(470),r.e(350)]).then(r.bind(r,9470)).then(e=>e.Layout),{loadableGenerated:{webpack:()=>[9470]},ssr:!1});function c(e){let{Component:t,pageProps:r}=e;return(0,o.useEffect)(()=>{let e=document.createElement("link");e.rel="icon",e.href="".concat(s.GW,"/favicon.ico"),document.head.appendChild(e)},[]),(0,n.jsx)(d,{highlighted:r.highlighted,children:(0,n.jsx)(t,{...r})})}c.propTypes={Component:i().elementType.isRequired,pageProps:i().object.isRequired},t.default=c},6501:function(){},5152:function(e,t,r){e.exports=r(9606)},2703:function(e,t,r){"use strict";var n=r(414);function o(){}function l(){}l.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,l,u){if(u!==n){var a=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:l,resetWarningCache:o};return r.PropTypes=r,r}},5697:function(e,t,r){e.exports=r(2703)()},414:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[774,179],function(){return t(1118),t(6036)}),_N_E=e.O()}]);
@@ -0,0 +1,6 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[826,350],{4966:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters/[cluster]/[job]",function(){return s(190)}])},3626:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});/**
2
+ * @license lucide-react v0.407.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */let a=(0,s(998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},9307:function(e,t,s){"use strict";s.d(t,{Cl:function(){return l},OE:function(){return d}});var a=s(5893);s(7294);var r=s(8799),n=s(6989),c=s(3850);let l=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":return"bg-green-50 text-green-700";case"STOPPED":return"bg-yellow-100 text-yellow-800";case"TERMINATED":default:return"bg-gray-100 text-gray-800";case"PENDING":case"CANCELLED":case"CANCELLING":return"bg-yellow-50 text-yellow-700";case"SUCCEEDED":return"bg-blue-50 text-blue-700";case"FAILED":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":return"bg-red-50 text-red-700";case"RECOVERING":return"bg-orange-50 text-orange-700";case"SUBMITTED":return"bg-indigo-50 text-indigo-700";case"STARTING":return"bg-cyan-50 text-cyan-700";case"FAILED_SETUP":return"bg-pink-50 text-pink-700"}},o=e=>{switch(e){case"LAUNCHING":case"STARTING":return(0,a.jsx)(r.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":default:return(0,a.jsx)(c.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":return(0,a.jsx)(c.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":return(0,a.jsx)(c.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,a.jsx)(c.Ye,{className:"w-3 h-3 mr-1"});case"PENDING":case"RECOVERING":case"SUBMITTED":case"CANCELLING":case"FAILED_SETUP":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":return(0,a.jsx)(c.J$,{className:"w-3 h-3 mr-1"})}},i=e=>{let t=l(e),s=o(e);return(0,a.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(t),children:[s,e]})},d=e=>{let{status:t}=e;return(0,a.jsx)(n.WH,{content:t,className:"text-muted-foreground text-sm",children:(0,a.jsx)("span",{children:i(t)})})}},7673:function(e,t,s){"use strict";s.d(t,{Ol:function(){return i},Zb:function(){return o},aY:function(){return h},eW:function(){return m},ll:function(){return d}});var a=s(5893),r=s(7294),n=s(5697),c=s.n(n),l=s(2350);let o=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",s),...n,children:r})});o.displayName="Card",o.propTypes={className:c().string,children:c().node};let i=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",s),...n,children:r})});i.displayName="CardHeader",i.propTypes={className:c().string,children:c().node};let d=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("h3",{ref:t,className:(0,l.cn)("text-2xl font-semibold leading-none tracking-tight",s),...n,children:r})});d.displayName="CardTitle",d.propTypes={className:c().string,children:c().node};let u=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("p",{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",s),...n,children:r})});u.displayName="CardDescription",u.propTypes={className:c().string,children:c().node};let h=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("p-6 pt-0",s),...n,children:r})});h.displayName="CardContent",h.propTypes={className:c().string,children:c().node};let m=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("flex items-center p-6 pt-0",s),...n,children:r})});m.displayName="CardFooter",m.propTypes={className:c().string,children:c().node}},7145:function(e,t,s){"use strict";s.d(t,{x:function(){return r}});var a=s(3225);let r={fetch:async(e,t)=>{let s=window.location.origin,r="".concat(s).concat(a.f4).concat(e),n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),c=n.headers.get("X-Skypilot-Request-ID")||n.headers.get("X-Request-ID"),l=await fetch("".concat(s).concat(a.f4,"/api/get?request_id=").concat(c)),o=await l.json();return o.return_value?JSON.parse(o.return_value):[]},post:async(e,t)=>{let s=window.location.origin,r="".concat(s).concat(a.f4).concat(e);return await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},stream:async(e,t,s)=>{let a=(await r.post(e,t)).body.getReader();try{for(;;){let{done:e,value:t}=await a.read();if(e)break;let r=new TextDecoder().decode(t);s(r)}}catch(e){throw console.error("Error in stream:",e),e}},get:async e=>{let t=window.location.origin,s="".concat(t).concat(a.f4).concat(e);return await fetch(s)}}},3266:function(e,t,s){"use strict";s.d(t,{QL:function(){return h},Sl:function(){return d},getClusters:function(){return o},uR:function(){return i}});var a=s(7294),r=s(5821),n=s(7145),c=s(6378);let l={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function o(){let{clusterNames:e=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await n.x.fetch("/status",{cluster_names:e,all_users:!0})).map(e=>{let t="",s=t=e.zone?e.zone:e.region;return t&&t.length>25&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e||e.length<=t)return e;if(t<=3)return"...";let s=Math.floor((t-3)/2),a=s+(t-3)%2;return 0===s?e.substring(0,a)+"...":e.substring(0,a)+"..."+e.substring(e.length-s)}(t,25)),{status:l[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra:s?"".concat(e.cloud," (").concat(s,")"):e.cloud,cpus:e.cpus,mem:e.memory,gpus:e.accelerators,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:new Date(1e3*e.launched_at),num_nodes:e.nodes,workspace:e.workspace,autostop:e.autostop,to_down:e.to_down,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){return console.error("Error fetching clusters:",e),[]}}async function i(){try{let e=await n.x.fetch("/cost_report",{days:30});console.log("Raw cluster history data:",e);let t=e.map(e=>{let t="Unknown";e.cloud?t=e.cloud:e.resources&&e.resources.cloud&&(t=e.resources.cloud);let s=e.user_name||"-";return{status:e.status?l[e.status]:"TERMINATED",cluster:e.name,user:s,user_hash:e.user_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,to_down:!1,cluster_hash:e.cluster_hash,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",t),t}catch(e){return console.error("Error fetching cluster history:",e),[]}}async function d(e){let{clusterName:t,jobId:s,onNewLog:a,workspace:c}=e;try{await n.x.stream("/logs",{follow:!1,cluster_name:t,job_id:s,override_skypilot_config:{active_workspace:c||"default"}},a)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,r.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function u(e){let{clusterName:t,workspace:s}=e;try{return(await n.x.fetch("/queue",{cluster_name:t,all_users:!0,override_skypilot_config:{active_workspace:s}})).map(e=>{let a=e.end_at?e.end_at:Date.now()/1e3,r=0,n=0;return e.submitted_at&&(r=a-e.submitted_at),e.start_at&&(n=a-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:r,job_duration:n,infra:"",logs:"",workspace:s||"default"}})}catch(e){return console.error("Error fetching cluster jobs:",e),[]}}function h(e){let{cluster:t,job:s=null}=e,[r,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(null),[d,h]=(0,a.useState)(!0),[m,f]=(0,a.useState)(!0),x=(0,a.useCallback)(async()=>{if(t)try{h(!0);let e=await c.default.get(o,[{clusterNames:[t]}]);return n(e[0]),e[0]}catch(e){console.error("Error fetching cluster data:",e)}finally{h(!1)}return null},[t]),g=(0,a.useCallback)(async e=>{if(t)try{f(!0);let s=await c.default.get(u,[{clusterName:t,workspace:e||"default"}]);i(s)}catch(e){console.error("Error fetching cluster job data:",e)}finally{f(!1)}},[t]),b=(0,a.useCallback)(async()=>{c.default.invalidate(o,[{clusterNames:[t]}]);let e=await x();e&&(c.default.invalidate(u,[{clusterName:t,workspace:e.workspace||"default"}]),await g(e.workspace))},[x,g,t]),N=(0,a.useCallback)(async()=>{r&&(c.default.invalidate(u,[{clusterName:t,workspace:r.workspace||"default"}]),await g(r.workspace))},[g,r,t]);return(0,a.useEffect)(()=>{(async()=>{let e=await x();e&&g(e.workspace)})()},[t,s,x,g]),{clusterData:r,clusterJobData:l,loading:d,clusterDetailsLoading:d,clusterJobsLoading:m,refreshData:b,refreshClusterJobsOnly:N}}},5821:function(e,t,s){"use strict";function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,a=document.getElementById("toast-container");a||((a=document.createElement("div")).id="toast-container",a.className="fixed top-0 right-0 p-4 z-[9999] flex flex-col items-end space-y-2",document.body.appendChild(a));let r=document.createElement("div");switch(r.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":r.className+=" bg-green-100 border-green-500 text-green-800";break;case"error":r.className+=" bg-red-100 border-red-500 text-red-800";break;case"warning":r.className+=" bg-yellow-100 border-yellow-500 text-yellow-800";break;default:r.className+=" bg-blue-100 border-blue-500 text-blue-800"}return r.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 '),a.appendChild(r),r.querySelector("button").addEventListener("click",()=>{a.removeChild(r)}),setTimeout(()=>{a.contains(r)&&a.removeChild(r)},s),r}s.d(t,{C:function(){return a}})},6378:function(e,t,s){"use strict";s.r(t),s.d(t,{DashboardCache:function(){return r},dashboardCache:function(){return n}});let a=s(1214).ej.DEFAULT_TTL;class r{async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=s.ttl||a,n=!1!==s.refreshOnAccess,c=this._generateKey(e,t),l=e.name||"anonymous",o=this.cache.get(c),i=Date.now();if(o&&i-o.lastUpdated<r){let s=Math.round((i-o.lastUpdated)/1e3);return this._debug("Cache HIT for ".concat(l," (age: ").concat(s,"s, TTL: ").concat(Math.round(r/1e3),"s)")),n&&(this.cache.set(c,{data:o.data,lastUpdated:i}),this._debug("Cache TTL refreshed for ".concat(l))),this.backgroundJobs.has(c)||this._refreshInBackground(e,t,c),o.data}try{let s=await e(...t);return this.cache.set(c,{data:s,lastUpdated:i}),s}catch(e){if(o)return console.warn("Failed to fetch fresh data for ".concat(c,", returning stale data:"),e),o.data;throw e}}invalidate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=this._generateKey(e,t);this.cache.delete(s),this.backgroundJobs.delete(s)}invalidateFunction(e){let t=e.name||"anonymous",s=[];for(let e of this.cache.keys())e.startsWith("".concat(t,"_"))&&s.push(e);s.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[s,a]of this.cache.entries()){let r=e-a.lastUpdated;t.push({key:s,age:Math.round(r/1e3),lastUpdated:new Date(a.lastUpdated).toISOString(),hasBackgroundJob:this.backgroundJobs.has(s)})}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,s=Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];this.debugMode&&console.log("[DashboardCache] ".concat(e),...s)}_refreshInBackground(e,t,s){this.backgroundJobs.set(s,!0),e(...t).then(e=>{this.cache.set(s,{data:e,lastUpdated:Date.now()})}).catch(e=>{console.warn("Background refresh failed for ".concat(s,":"),e)}).finally(()=>{this.backgroundJobs.delete(s)})}_generateKey(e,t){let s=e.name||"anonymous",a=t.length>0?JSON.stringify(t):"";return"".concat(s,"_").concat(a)}constructor(){this.cache=new Map,this.backgroundJobs=new Map,this.debugMode=!1}}let n=new r;t.default=n},2350:function(e,t,s){"use strict";s.d(t,{cn:function(){return n}});var a=s(512),r=s(8388);function n(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.m6)((0,a.W)(t))}},190:function(e,t,s){"use strict";s.r(t),s.d(t,{JobDetailPage:function(){return N}});var a=s(5893),r=s(7294);s(9470);var n=s(7673),c=s(1664),l=s.n(c),o=s(1163),i=s(3266),d=s(6989),u=s(3626),h=s(8799),m=s(9307),f=s(3001),x=s(9008),g=s.n(x);function b(e){let{cluster:t,job:s,jobData:r,onRefresh:n,isRefreshing:c,loading:o}=e,i=(0,f.X)();return(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)(l(),{href:"/clusters",className:"text-sky-blue hover:underline",children:"Sky Clusters"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)(l(),{href:"/clusters/".concat(t),className:"text-sky-blue hover:underline",children:t}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsxs)(l(),{href:"/clusters/".concat(t,"/").concat(s),className:"text-sky-blue hover:underline",children:[s,r.job&&"-"!=r.job?" (".concat(r.job,")"):""]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(o||c)&&(0,a.jsxs)("div",{className:"flex items-center mr-2",children:[(0,a.jsx)(h.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"text-sm ml-2 text-gray-500",children:"Loading..."})]}),(0,a.jsx)(d.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,a.jsxs)("button",{onClick:n,disabled:o||c,className:"text-sm text-sky-blue hover:text-sky-blue-bright font-medium mx-2 flex items-center",children:[(0,a.jsx)(u.Z,{className:"w-4 h-4 mr-1.5"}),!i&&(0,a.jsx)("span",{children:"Refresh"})]})})]})]})}function N(){let e=(0,o.useRouter)(),{cluster:t,job:s}=e.query,{clusterData:c,clusterJobData:f,loading:x,refreshData:N}=(0,i.QL)({cluster:t}),[y,p]=(0,r.useState)(!1),[w,j]=(0,r.useState)(!0),[_,v]=(0,r.useState)(!1),[E,k]=(0,r.useState)([]),[C,D]=(0,r.useState)(!1),T=(0,r.useMemo)(()=>["INIT","PENDING","SETTING_UP"],[]),S=(0,r.useMemo)(()=>{if(!f||!s)return!0;let e=f.find(e=>e.id==s);return e&&T.includes(e.status)},[f,s,T]);r.useEffect(()=>{!x&&w&&j(!1)},[x,w]),(0,r.useEffect)(()=>{let e=!0;return t&&s&&!S?(v(!0),(0,i.Sl)({clusterName:t,jobId:s,onNewLog:t=>{if(e){let e=(0,d.q8)(t);k(t=>[...t,e])}},workspace:null==c?void 0:c.workspace}).then(()=>{e&&v(!1)}).catch(t=>{e&&(console.error("Error streaming logs:",t),v(!1))})):v(!1),()=>{e=!1}},[t,s,C,S,c]);let I=async()=>{p(!0),D(e=>!e),k([]);try{N&&await N()}catch(e){console.error("Error refreshing data:",e)}finally{p(!1)}};if(!e.isReady)return(0,a.jsx)("div",{children:"Loading..."});let L={id:s};if(c&&f){let e=f.find(e=>e.id==s);e&&(L={...e,infra:c.infra,cluster:c.cluster,user:c.user})}let R=t&&s?"Job: ".concat(s," @ ").concat(t," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g(),{children:(0,a.jsx)("title",{children:R})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b,{cluster:t,job:s,jobData:L,onRefresh:I,isRefreshing:y,loading:x}),x&&w?(0,a.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,a.jsx)(h.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]}):(0,a.jsxs)("div",{className:"space-y-8",children:[(0,a.jsx)("div",{id:"details",children:(0,a.jsxs)(n.Zb,{children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Details"})}),(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:"Job ID"}),(0,a.jsx)("div",{className:"text-base mt-1",children:L.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job Name"}),(0,a.jsx)("div",{className:"text-base mt-1",children:L.job})]}),(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:(0,a.jsx)(m.OE,{status:L.status})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,a.jsx)("div",{className:"text-base mt-1",children:L.user})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Submitted"}),(0,a.jsx)("div",{className:"text-base mt-1",children:L.submitted_at?(0,d.xn)(L.submitted_at):"N/A"})]}),L.resources&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Requested Resources"}),(0,a.jsx)("div",{className:"text-base mt-1",children:L.resources||"N/A"})]}),L.cluster&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Cluster"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(l(),{href:"/clusters/".concat(L.cluster),className:"text-sky-blue hover:underline",children:L.cluster})})]})]})})]})}),(0,a.jsx)("div",{id:"logs",className:"mt-6",children:(0,a.jsxs)(n.Zb,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Logs"}),(0,a.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,a.jsx)(d.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:()=>{D(e=>!e),k([])},disabled:_,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,a.jsx)(u.Z,{className:"w-4 h-4 ".concat(_?"animate-spin":"")})})})]}),(0,a.jsx)("div",{className:"p-4",children:S?(0,a.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,a.jsx)("span",{children:"Waiting for the job to start; refresh in a few moments."})}):_?(0,a.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,a.jsx)(h.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]}):(0,a.jsx)("div",{className:"max-h-96 overflow-y-auto",children:(0,a.jsx)(d.$B,{logs:E.join("")})})})]})})]})]})]})}t.default=N},9008:function(e,t,s){e.exports=s(7219)}},function(e){e.O(0,[616,760,799,804,664,989,470,888,774,179],function(){return e(e.s=4966)}),_N_E=e.O()}]);
@@ -0,0 +1,6 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[722],{8706:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters/[cluster]",function(){return s(6996)}])},6639:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});/**
2
+ * @license lucide-react v0.407.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */let a=(0,s(998).Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},4303:function(e,t,s){"use strict";s.d(t,{_q:function(){return r},pJ:function(){return i}});var a=s(1272);let r=e=>{if(!e)return"No YAML available";try{let t=a.ZP.load(e),s=a.ZP.dump(t,{lineWidth:-1,styles:{"!!str":"literal"},quotingType:"'",forceQuotes:!1,noRefs:!0,sortKeys:!1,condenseFlow:!1,indent:2}).split("\n"),r=[],l=-1;for(let e=0;e<s.length;e++){let t=s[e],a=t.search(/\S/);0===a&&l>=0&&e>0&&r.push(""),r.push(t),l=a}return r.join("\n").trim()}catch(t){return console.error("YAML formatting error:",t),e}},l=e=>"string"==typeof e?e.substring(0,50)+"...":e&&e.name?"name: ".concat(e.name):e&&e.resources?"Task configuration":"YAML document",n=(e,t)=>{try{let s=a.ZP.load(e),r=a.ZP.dump(s,{lineWidth:-1,styles:{"!!str":"literal"},quotingType:"'",forceQuotes:!1,noRefs:!0,sortKeys:!1,condenseFlow:!1,indent:2}).split("\n"),n=[],i=-1;for(let e=0;e<r.length;e++){let t=r[e],s=t.search(/\S/);0===s&&i>=0&&e>0&&n.push(""),n.push(t),i=s}return{index:t,content:n.join("\n").trim(),preview:l(s)}}catch(s){return console.error("YAML formatting error for document ".concat(t,":"),s),{index:t,content:e,preview:"Invalid YAML"}}},i=e=>{if(!e)return[];try{let t=[],s=e.split(/^---$/m);for(let e=0;e<s.length;e++){let a=s[e].trim();a&&""!==a&&t.push(a)}return(t.length>1?t.slice(1):t).map((e,t)=>n(e,t))}catch(t){return console.error("YAML formatting error:",t),[{index:0,content:e,preview:"Invalid YAML"}]}}},6996:function(e,t,s){"use strict";s.r(t);var a=s(5893),r=s(7294),l=s(8799),n=s(938),i=s(1163);s(9470);var c=s(1664),o=s.n(c),d=s(9037),m=s(9307),u=s(7673),x=s(3266),h=s(6378),f=s(3626),j=s(282),v=s(8671),y=s(5895),N=s(6639);s(1272);var b=s(6989),p=s(9284),g=s(3001),_=s(9008),w=s.n(_),C=s(4303);let k=(e,t)=>{let s="",a="";return e>=0&&(s=e+"m",a=" "),t&&(s+="".concat(a,"(down)")),""===s&&(s="-"),s};function S(e){var t,s;let{clusterData:l,clusterJobData:i,clusterJobsLoading:c,refreshClusterJobsOnly:d,isHistoricalCluster:x=!1}=e,[h,f]=(0,r.useState)(!1),[p,g]=(0,r.useState)(!1),[_,w]=(0,r.useState)(!1),S=async()=>{try{let e=l.task_yaml||l.last_creation_yaml,t=(0,C._q)(e);await navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),2e3)}catch(e){console.error("Failed to copy YAML to clipboard:",e)}},L=async()=>{try{let e=l.command||l.last_creation_command;await navigator.clipboard.writeText(e),w(!0),setTimeout(()=>w(!1),2e3)}catch(e){console.error("Failed to copy command to clipboard:",e)}},A=(null==l?void 0:l.last_creation_command)||(null==l?void 0:l.last_creation_yaml)||(null==l?void 0:l.command)||(null==l?void 0:l.task_yaml);return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsxs)(u.Zb,{children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,a.jsx)("h3",{className:"text-lg font-semibold",children:x?"Historical Cluster Details":"Details"})}),(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:"Status"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(m.OE,{status:l.status})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Cluster"}),(0,a.jsx)("div",{className:"text-base mt-1",children:l.cluster||l.name})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,a.jsx)("div",{className:"text-base mt-1",children:l.user})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:x?"Cloud":"Infra"}),(0,a.jsx)("div",{className:"text-base mt-1",children:x?l.cloud||"N/A":l.infra?(0,a.jsx)(b.Md,{content:l.full_infra||l.infra,className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(o(),{href:"/infra",className:"text-blue-600 hover:underline",children:l.cloud||l.infra.split("(")[0].trim()}),l.infra.includes("(")&&(0,a.jsx)("span",{children:" "+l.infra.substring(l.infra.indexOf("("))})]})}):"N/A"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Resources"}),(0,a.jsx)("div",{className:"text-base mt-1",children:l.resources_str_full||l.resources_str||"N/A"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Started"}),(0,a.jsx)("div",{className:"text-base mt-1",children:l.time?(0,b.xn)(new Date(l.time)):"N/A"})]}),x?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Duration"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(e=>{if(!e||0===e)return"-";let t=e=Math.floor(e),s="",a=0;for(let e of[{value:31536e3,label:"y"},{value:2592e3,label:"mo"},{value:86400,label:"d"},{value:3600,label:"h"},{value:60,label:"m"},{value:1,label:"s"}])if(t>=e.value&&a<2){let r=Math.floor(t/e.value);s+="".concat(r).concat(e.label," "),t%=e.value,a++}return s.trim()||"0s"})(l.duration)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Cost"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(e=>{if(null==e||0===e)return"-";let t=Number(e);return isNaN(t)?"-":"$".concat(t.toFixed(2))})(l.total_cost)})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Autostop"}),(0,a.jsx)("div",{className:"text-base mt-1",children:k(l.autostop,l.to_down)})]}),A&&(0,a.jsxs)("div",{className:"col-span-2",children:[(l.command||l.last_creation_command)&&(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Entrypoint"}),l.command&&(0,a.jsx)(b.WH,{content:_?"Copied!":"Copy command",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:L,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:_?(0,a.jsx)(j.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(v.Z,{className:"w-4 h-4"})})})]}),(0,a.jsxs)("div",{className:"space-y-4 mt-3",children:[(l.command||l.last_creation_command)&&(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3",children:(0,a.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all",children:l.command||l.last_creation_command})})}),(l.task_yaml||l.last_creation_yaml)&&"{}"!==l.task_yaml&&"{}"!==l.last_creation_yaml&&!(null===(t=l.cluster||l.name)||void 0===t?void 0:t.startsWith("sky-jobs-controller-"))&&!(null===(s=l.cluster||l.name)||void 0===s?void 0:s.startsWith("sky-serve-controller-"))&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsxs)("button",{onClick:()=>{f(!h)},className:"flex items-center text-left focus:outline-none text-gray-700 hover:text-gray-900 transition-colors duration-200",children:[h?(0,a.jsx)(y.Z,{className:"w-4 h-4 mr-1"}):(0,a.jsx)(N.Z,{className:"w-4 h-4 mr-1"}),(0,a.jsx)("span",{className:"text-base",children:"Show SkyPilot YAML"})]}),(0,a.jsx)(b.WH,{content:p?"Copied!":"Copy YAML",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:S,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:p?(0,a.jsx)(j.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(v.Z,{className:"w-4 h-4"})})})]}),h&&(0,a.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3 max-h-96 overflow-y-auto",children:(0,a.jsx)("pre",{className:"text-sm text-gray-800 font-mono whitespace-pre-wrap",children:(0,C._q)(l.task_yaml||l.last_creation_yaml)})})]})]})]})]})})]})}),!x&&(0,a.jsx)("div",{className:"mb-8",children:(0,a.jsx)(n.ClusterJobs,{clusterName:l.cluster,clusterJobData:i,loading:c,refreshClusterJobsOnly:d})})]})}t.default=function(){let e=(0,i.useRouter)(),{cluster:t}=e.query,[s,n]=(0,r.useState)(!1),[c,m]=(0,r.useState)(!0),[u,j]=(0,r.useState)(!1),[v,y]=(0,r.useState)(!1),[N,_]=(0,r.useState)(null),[C,k]=(0,r.useState)(!1),[L,A]=(0,r.useState)(!1),Z=(0,g.X)(),{clusterData:M,clusterJobData:D,loading:O,clusterDetailsLoading:E,clusterJobsLoading:J,refreshData:R,refreshClusterJobsOnly:Y}=(0,x.QL)({cluster:t});r.useEffect(()=>{!E&&c&&m(!1)},[E,c]),r.useEffect(()=>{let e=async()=>{if(t&&!E&&!M){A(!0);try{let e=(await h.default.get(x.uR)).find(e=>e.cluster_hash===t||e.cluster===t);e&&(_(e),k(!0))}catch(e){console.error("Error fetching cluster history:",e)}finally{A(!1)}}};E||M||e()},[t,E,M]);let P=async()=>{n(!0),await R(),n(!1)};if(!e.isReady)return(0,a.jsx)("div",{children:"Loading..."});let T=t?"Cluster: ".concat(t," | SkyPilot Dashboard"):"Cluster Details | SkyPilot Dashboard";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w(),{children:(0,a.jsx)("title",{children:T})}),(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)(o(),{href:"/clusters",className:"text-sky-blue hover:underline",children:"Sky Clusters"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)(o(),{href:"/clusters/".concat(t),className:"text-sky-blue hover:underline",children:t})]}),(0,a.jsx)("div",{className:"text-sm flex items-center",children:(0,a.jsxs)("div",{className:"text-sm flex items-center",children:[(E||s)&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)(l.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),M&&(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsx)(b.WH,{content:"Refresh",className:"text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:P,disabled:E||s,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:[(0,a.jsx)(f.Z,{className:"w-4 h-4 mr-1.5"}),!Z&&(0,a.jsx)("span",{children:"Refresh"})]})}),(0,a.jsx)(d.Status2Actions,{withLabel:!0,cluster:M.cluster,status:M.status,onOpenSSHModal:()=>{j(!0)},onOpenVSCodeModal:()=>{y(!0)}})]})]})})]}),E&&c||L?(0,a.jsxs)("div",{className:"flex justify-center items-center py-12",children:[(0,a.jsx)(l.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading cluster details..."})]}):M?(0,a.jsx)(S,{clusterData:M,clusterJobData:D,clusterJobsLoading:J,refreshClusterJobsOnly:Y,isHistoricalCluster:!1}):C&&N?(0,a.jsx)(S,{clusterData:N,clusterJobData:[],clusterJobsLoading:!1,refreshClusterJobsOnly:()=>{},isHistoricalCluster:!0}):(0,a.jsx)("div",{className:"flex justify-center items-center py-12",children:(0,a.jsx)("span",{className:"text-gray-500",children:"Cluster not found in active clusters or history."})}),(0,a.jsx)(p.Oh,{isOpen:u,onClose:()=>j(!1),cluster:t}),(0,a.jsx)(p._R,{isOpen:v,onClose:()=>y(!1),cluster:t})]})]})}},9008:function(e,t,s){e.exports=s(7219)}},function(e){e.O(0,[616,760,799,804,664,798,947,989,470,901,969,856,973,938,37,888,774,179],function(){return e(e.s=8706)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[810],{5833:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters",function(){return t(3450)}])},3450:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return l}});var r=t(5893);t(7294);var s=t(9008),u=t.n(s),i=t(5152);let c=t.n(i)()(()=>Promise.all([t.e(616),t.e(760),t.e(799),t.e(804),t.e(664),t.e(798),t.e(989),t.e(470),t.e(901),t.e(969),t.e(856),t.e(973),t.e(37),t.e(491)]).then(t.bind(t,9037)).then(e=>e.Clusters),{loadableGenerated:{webpack:()=>[9037]},ssr:!1});function l(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u(),{children:(0,r.jsx)("title",{children:"Clusters | SkyPilot Dashboard"})}),(0,r.jsx)(c,{})]})}},9008:function(e,n,t){e.exports=t(7219)}},function(e){e.O(0,[888,774,179],function(){return e(e.s=5833)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[490],{4483:function(n,e,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/config",function(){return t(9649)}])},9649:function(n,e,t){"use strict";t.r(e),t.d(e,{default:function(){return c}});var i=t(5893);t(7294);var r=t(9008),o=t.n(r),u=t(5152);let s=t.n(u)()(()=>Promise.all([t.e(616),t.e(760),t.e(799),t.e(798),t.e(989),t.e(901),t.e(42)]).then(t.bind(t,4042)).then(n=>n.Config),{loadableGenerated:{webpack:()=>[4042]},ssr:!1});function c(){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o(),{children:(0,i.jsx)("title",{children:"Edit SkyPilot Configuration | SkyPilot Dashboard"})}),(0,i.jsx)(s,{})]})}},9008:function(n,e,t){n.exports=t(7219)}},function(n){n.O(0,[888,774,179],function(){return n(n.s=4483)}),_N_E=n.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[233],{1803:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/infra/[context]",function(){return t(1200)}])},1200:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return o}});var r=t(5893);t(7294);var i=t(9008),s=t.n(i),u=t(5152);let c=t.n(u)()(()=>Promise.all([t.e(616),t.e(760),t.e(799),t.e(804),t.e(664),t.e(989),t.e(470),t.e(901),t.e(969),t.e(856),t.e(682)]).then(t.bind(t,8682)).then(e=>e.GPUs),{loadableGenerated:{webpack:()=>[8682]},ssr:!1});function o(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s(),{children:(0,r.jsx)("title",{children:"Infra | SkyPilot Dashboard"})}),(0,r.jsx)(c,{})]})}},9008:function(e,n,t){e.exports=t(7219)}},function(e){e.O(0,[888,774,179],function(){return e(e.s=1803)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[588],{3177:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/infra",function(){return t(9054)}])},9054:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return c}});var r=t(5893);t(7294);var i=t(9008),s=t.n(i),u=t(5152);let a=t.n(u)()(()=>Promise.all([t.e(616),t.e(760),t.e(799),t.e(804),t.e(664),t.e(989),t.e(470),t.e(901),t.e(969),t.e(856),t.e(682)]).then(t.bind(t,8682)).then(e=>e.GPUs),{loadableGenerated:{webpack:()=>[8682]},ssr:!1});function c(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s(),{children:(0,r.jsx)("title",{children:"Infra | SkyPilot Dashboard"})}),(0,r.jsx)(a,{})]})}},9008:function(e,n,t){e.exports=t(7219)}},function(e){e.O(0,[888,774,179],function(){return e(e.s=3177)}),_N_E=e.O()}]);
@@ -13,4 +13,4 @@
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */let r=(0,s(998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},9307:function(e,t,s){"use strict";s.d(t,{Cl:function(){return c},OE:function(){return d}});var r=s(5893);s(7294);var n=s(8799),a=s(6989),l=s(3850);let c=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":return"bg-green-50 text-green-700";case"STOPPED":return"bg-yellow-100 text-yellow-800";case"TERMINATED":default:return"bg-gray-100 text-gray-800";case"PENDING":case"CANCELLED":case"CANCELLING":return"bg-yellow-50 text-yellow-700";case"SUCCEEDED":return"bg-blue-50 text-blue-700";case"FAILED":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":return"bg-red-50 text-red-700";case"RECOVERING":return"bg-orange-50 text-orange-700";case"SUBMITTED":return"bg-indigo-50 text-indigo-700";case"STARTING":return"bg-cyan-50 text-cyan-700";case"FAILED_SETUP":return"bg-pink-50 text-pink-700"}},o=e=>{switch(e){case"LAUNCHING":case"STARTING":return(0,r.jsx)(n.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":default:return(0,r.jsx)(l.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":return(0,r.jsx)(l.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":return(0,r.jsx)(l.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,r.jsx)(l.Ye,{className:"w-3 h-3 mr-1"});case"PENDING":case"RECOVERING":case"SUBMITTED":case"CANCELLING":case"FAILED_SETUP":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":return(0,r.jsx)(l.J$,{className:"w-3 h-3 mr-1"})}},i=e=>{let t=c(e),s=o(e);return(0,r.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(t),children:[s,e]})},d=e=>{let{status:t}=e;return(0,r.jsx)(a.WH,{content:t,className:"text-muted-foreground text-sm",children:(0,r.jsx)("span",{children:i(t)})})}},7673:function(e,t,s){"use strict";s.d(t,{Ol:function(){return i},Zb:function(){return o},aY:function(){return m},eW:function(){return x},ll:function(){return d}});var r=s(5893),n=s(7294),a=s(5697),l=s.n(a),c=s(2350);let o=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",s),...a,children:n})});o.displayName="Card",o.propTypes={className:l().string,children:l().node};let i=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("flex flex-col space-y-1.5 p-6",s),...a,children:n})});i.displayName="CardHeader",i.propTypes={className:l().string,children:l().node};let d=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("h3",{ref:t,className:(0,c.cn)("text-2xl font-semibold leading-none tracking-tight",s),...a,children:n})});d.displayName="CardTitle",d.propTypes={className:l().string,children:l().node};let u=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("p",{ref:t,className:(0,c.cn)("text-sm text-muted-foreground",s),...a,children:n})});u.displayName="CardDescription",u.propTypes={className:l().string,children:l().node};let m=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("p-6 pt-0",s),...a,children:n})});m.displayName="CardContent",m.propTypes={className:l().string,children:l().node};let x=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("flex items-center p-6 pt-0",s),...a,children:n})});x.displayName="CardFooter",x.propTypes={className:l().string,children:l().node}},7145:function(e,t,s){"use strict";s.d(t,{x:function(){return n}});var r=s(3225);let n={fetch:async(e,t)=>{let s=window.location.origin,n="".concat(s).concat(r.f4).concat(e),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=a.headers.get("X-Skypilot-Request-ID")||a.headers.get("X-Request-ID"),c=await fetch("".concat(s).concat(r.f4,"/api/get?request_id=").concat(l)),o=await c.json();return o.return_value?JSON.parse(o.return_value):[]},post:async(e,t)=>{let s=window.location.origin,n="".concat(s).concat(r.f4).concat(e);return await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},stream:async(e,t,s)=>{let r=(await n.post(e,t)).body.getReader();try{for(;;){let{done:e,value:t}=await r.read();if(e)break;let n=new TextDecoder().decode(t);s(n)}}catch(e){throw console.error("Error in stream:",e),e}},get:async e=>{let t=window.location.origin,s="".concat(t).concat(r.f4).concat(e);return await fetch(s)}}},2350:function(e,t,s){"use strict";s.d(t,{cn:function(){return a}});var r=s(512),n=s(8388);function a(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,n.m6)((0,r.W)(t))}},4303:function(e,t,s){"use strict";s.d(t,{_q:function(){return n},pJ:function(){return c}});var r=s(1272);let n=e=>{if(!e)return"No YAML available";try{let t=r.ZP.load(e),s=r.ZP.dump(t,{lineWidth:-1,styles:{"!!str":"literal"},quotingType:"'",forceQuotes:!1,noRefs:!0,sortKeys:!1,condenseFlow:!1,indent:2}).split("\n"),n=[],a=-1;for(let e=0;e<s.length;e++){let t=s[e],r=t.search(/\S/);0===r&&a>=0&&e>0&&n.push(""),n.push(t),a=r}return n.join("\n").trim()}catch(t){return console.error("YAML formatting error:",t),e}},a=e=>"string"==typeof e?e.substring(0,50)+"...":e&&e.name?"name: ".concat(e.name):e&&e.resources?"Task configuration":"YAML document",l=(e,t)=>{try{let s=r.ZP.load(e),n=r.ZP.dump(s,{lineWidth:-1,styles:{"!!str":"literal"},quotingType:"'",forceQuotes:!1,noRefs:!0,sortKeys:!1,condenseFlow:!1,indent:2}).split("\n"),l=[],c=-1;for(let e=0;e<n.length;e++){let t=n[e],s=t.search(/\S/);0===s&&c>=0&&e>0&&l.push(""),l.push(t),c=s}return{index:t,content:l.join("\n").trim(),preview:a(s)}}catch(s){return console.error("YAML formatting error for document ".concat(t,":"),s),{index:t,content:e,preview:"Invalid YAML"}}},c=e=>{if(!e)return[];try{let t=[],s=e.split(/^---$/m);for(let e=0;e<s.length;e++){let r=s[e].trim();r&&""!==r&&t.push(r)}return(t.length>1?t.slice(1):t).map((e,t)=>l(e,t))}catch(t){return console.error("YAML formatting error:",t),[{index:0,content:e,preview:"Invalid YAML"}]}}},8099:function(e,t,s){"use strict";s.r(t);var r=s(5893),n=s(7294),a=s(8799),l=s(1163);s(9470);var c=s(7673),o=s(8969),i=s(1664),d=s.n(i),u=s(3626),m=s(282),x=s(8671),f=s(5895),g=s(6639),h=s(6989),p=s(9307),j=s(3001),y=s(9008),N=s.n(y),b=s(4303);function v(e){let{jobData:t,activeTab:s,setIsLoadingLogs:l,setIsLoadingControllerLogs:c,isLoadingLogs:i,isLoadingControllerLogs:u,refreshFlag:j}=e,[y,N]=(0,n.useState)(""),[v,w]=(0,n.useState)(""),[E,L]=(0,n.useState)(!1),[C,S]=(0,n.useState)({}),[R,T]=(0,n.useState)(!1),[I,k]=(0,n.useState)(!1),[A,D]=(0,n.useState)(0),[_,Z]=(0,n.useState)(0),[P,O]=(0,n.useState)(!1),[q,F]=(0,n.useState)(!1),[M,U]=(0,n.useState)(!1),[G,W]=(0,n.useState)(!1),H=(0,n.useRef)(null),J=(0,n.useRef)(null),Y=(0,n.useRef)(new WeakSet),B=(0,n.useRef)(null),z=(0,n.useRef)(null),$=(0,n.useRef)(""),V=(0,n.useRef)(""),X=(0,n.useRef)(null);(0,n.useRef)(0);let K=(0,n.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"request";if(e){if(Y.current.has(e)){console.log("".concat(t," controller already aborted previously, skipping"));return}try{if("function"!=typeof e.abort){console.warn("Controller for ".concat(t," does not have abort method"));return}if(e.signal&&e.signal.aborted){console.log("".concat(t," already aborted via signal, skipping")),Y.current.add(e);return}e.abort(),Y.current.add(e),console.log("Successfully aborted ".concat(t))}catch(s){console.log("Caught error while aborting ".concat(t,":"),s.name,s.message),Y.current.add(e),"AbortError"!==s.name&&"InvalidStateError"!==s.name&&console.warn("Unexpected error aborting ".concat(t,":"),s)}}},[]),Q=(0,n.useCallback)(e=>{let t="logs"===e?B:z;if(t.current)for(let s of[()=>t.current.querySelector(".logs-container"),()=>t.current.querySelector('[class*="logs-container"]'),()=>t.current.querySelector('div[style*="overflow"]'),()=>t.current]){let t=s();if(t&&t.scrollHeight>t.clientHeight){t.scrollTop=t.scrollHeight,console.log("Auto-scrolled ".concat(e," to bottom"));break}}},[]),ee=["PENDING","SUBMITTED","STARTING"].includes(t.status),et=["PENDING","SUBMITTED"].includes(t.status),es=["RECOVERING"].includes(t.status),er=e=>{S(t=>({...t,[e]:!t[e]}))},en=async()=>{try{let e=(0,b.pJ)(t.dag_yaml),s="";s=1===e.length?e[0].content:e.length>1?e.map(e=>e.content).join("\n---\n"):t.dag_yaml,await navigator.clipboard.writeText(s),T(!0),setTimeout(()=>T(!1),2e3)}catch(e){console.error("Failed to copy YAML to clipboard:",e)}},ea=async()=>{try{await navigator.clipboard.writeText(t.entrypoint),k(!0),setTimeout(()=>k(!1),2e3)}catch(e){console.error("Failed to copy command to clipboard:",e)}};(0,n.useEffect)(()=>{N(""),D(0),W(!1)},[s,t.id]),(0,n.useEffect)(()=>{w(""),Z(0),W(!1)},[s,t.id]);let el=(0,n.useCallback)(function(e,t,s,r){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a="logs"===e?H:J;if(a.current)return console.log("Request already active for ".concat(e,", skipping...")),()=>{};let l=!0,c=new AbortController;return"logs"===e&&(ee||es)?(r(!1),n&&O(!1),()=>{}):"controllerlogs"===e&&et?(r(!1),n&&F(!1),()=>{}):t?(a.current=c,r(!0),U(!0),n&&(s(""),"logs"===e?D(0):Z(0)),(0,o.NJ)({jobId:t,controller:"controllerlogs"===e,signal:c.signal,onNewLog:t=>{if(l){let s=(0,h.q8)(t);G||W(!0),ec(e,s),"logs"===e?D(e=>e+s.length):Z(e=>e+s.length)}}}).then(()=>{l&&(r(!1),n&&("logs"===e?O(!1):F(!1)),requestAnimationFrame(()=>{Q(e)}))}).catch(t=>{l&&("AbortError"!==t.name&&(console.error("Error streaming ".concat(e,":"),t),t.message&&s(e=>e+"Error fetching logs: ".concat(t.message,"\n"))),r(!1),n&&("logs"===e?O(!1):F(!1)))}).finally(()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===c&&(K(c,e),a.current=null),"logs"===e?$.current="":V.current="",X.current&&(clearTimeout(X.current),X.current=null)}),()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===c&&(K(c,"".concat(e," cleanup")),a.current=null),"logs"===e?$.current="":V.current="",X.current&&(clearTimeout(X.current),X.current=null)}):()=>{l=!1}},[ee,et,es,G,K]);(0,n.useEffect)(()=>{if(H.current&&(K(H.current,"logs"),H.current=null),!ee&&!es)return el("logs",t.id,N,l)},[t.id,el,l,ee,es,K]),(0,n.useEffect)(()=>{if(J.current&&(K(J.current,"controller logs"),J.current=null),!et)return el("controllerlogs",t.id,w,c)},[t.id,el,c,et,K]),(0,n.useEffect)(()=>{if(j>0&&"logs"===s)return H.current&&(K(H.current,"logs refresh"),H.current=null),O(!0),el("logs",t.id,N,l,!0)},[j,s,t.id,el,l,K]),(0,n.useEffect)(()=>{if(j>0&&"controllerlogs"===s)return J.current&&(K(J.current,"controller logs refresh"),J.current=null),F(!0),el("controllerlogs",t.id,w,c,!0)},[j,s,t.id,el,c,K]),(0,n.useEffect)(()=>()=>{console.log("Cleaning up managed job log requests..."),H.current&&(K(H.current,"logs cleanup"),H.current=null),J.current&&(K(J.current,"controller logs cleanup"),J.current=null),X.current&&(clearTimeout(X.current),X.current=null),$.current="",V.current="",l(!1),c(!1),O(!1),F(!1)},[K]),(0,n.useEffect)(()=>{let e=()=>{document.hidden?(console.log("Page hidden - pausing log streaming for performance"),X.current&&(clearTimeout(X.current),X.current=null)):console.log("Page visible - resuming normal operation")};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),(0,n.useEffect)(()=>{let e=()=>{("logs"===s&&y||"controllerlogs"===s&&v)&&Q("logs"===s?"logs":"controllerlogs")};requestAnimationFrame(()=>{requestAnimationFrame(e)})},[s,y,v,Q]);let ec=(0,n.useCallback)((e,t)=>{("logs"===e?N:w)(e=>e+t),requestAnimationFrame(()=>{Q(e)})},[Q]);return"logs"===s?(0,r.jsx)("div",{className:"max-h-96 overflow-y-auto",ref:B,children:ee?(0,r.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,r.jsx)("span",{children:"Waiting for the job to start, please refresh after a while"})}):es?(0,r.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,r.jsx)("span",{children:"Waiting for the job to recover, please refresh after a while"})}):G||y?(0,r.jsx)(h.$B,{logs:y}):i?(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,r.jsx)(a.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading logs..."})]}):(0,r.jsx)(h.$B,{logs:y})}):"controllerlogs"===s?(0,r.jsx)("div",{className:"max-h-96 overflow-y-auto",ref:z,children:et?(0,r.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,r.jsx)("span",{children:"Waiting for the job controller process to start, please refresh after a while"})}):G||v?(0,r.jsx)(h.$B,{logs:v,controller:!0}):u?(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,r.jsx)(a.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading logs..."})]}):(0,r.jsx)(h.$B,{logs:v,controller:!0})}):(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job ID (Name)"}),(0,r.jsxs)("div",{className:"text-base mt-1",children:[t.id," ",t.name?"(".concat(t.name,")"):""]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,r.jsxs)("div",{className:"text-base mt-1 flex items-center",children:[(0,r.jsx)(p.OE,{status:t.status}),t.priority&&(0,r.jsxs)("span",{className:"ml-2",children:[" (Priority: ",t.priority,")"]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.user})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Requested Resources"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.requested_resources||"N/A"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Infra"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.infra?(0,r.jsx)(h.Md,{content:t.full_infra||t.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(d(),{href:"/infra",className:"text-blue-600 hover:underline",children:t.cloud||t.infra.split("(")[0].trim()}),t.infra.includes("(")&&(0,r.jsx)("span",{children:" "+t.infra.substring(t.infra.indexOf("("))})]})}):"-"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Resources"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.resources_str_full||t.resources_str||"-"})]}),(t.entrypoint||t.dag_yaml)&&(0,r.jsxs)("div",{className:"col-span-2",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Entrypoint"}),t.entrypoint&&(0,r.jsx)(h.WH,{content:I?"Copied!":"Copy command",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:ea,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:I?(0,r.jsx)(m.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(x.Z,{className:"w-4 h-4"})})})]}),(0,r.jsxs)("div",{className:"space-y-4 mt-3",children:[t.entrypoint&&(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all",children:t.entrypoint})})}),t.dag_yaml&&"{}"!==t.dag_yaml&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center mb-2",children:[(0,r.jsxs)("button",{onClick:()=>{L(!E)},className:"flex items-center text-left focus:outline-none text-gray-700 hover:text-gray-900 transition-colors duration-200",children:[E?(0,r.jsx)(f.Z,{className:"w-4 h-4 mr-1"}):(0,r.jsx)(g.Z,{className:"w-4 h-4 mr-1"}),(0,r.jsx)("span",{className:"text-base",children:"Show SkyPilot YAML"})]}),(0,r.jsx)(h.WH,{content:R?"Copied!":"Copy YAML",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:en,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:R?(0,r.jsx)(m.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(x.Z,{className:"w-4 h-4"})})})]}),E&&(0,r.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3 max-h-96 overflow-y-auto",children:(()=>{let e=(0,b.pJ)(t.dag_yaml);return 0===e.length?(0,r.jsx)("div",{className:"text-gray-500",children:"No YAML available"}):1===e.length?(0,r.jsx)("pre",{className:"text-sm text-gray-800 font-mono whitespace-pre-wrap",children:e[0].content}):(0,r.jsx)("div",{className:"space-y-4",children:e.map((e,t)=>(0,r.jsxs)("div",{className:"border-b border-gray-200 pb-4 last:border-b-0",children:[(0,r.jsx)("button",{onClick:()=>er(t),className:"flex items-center justify-between w-full text-left focus:outline-none",children:(0,r.jsxs)("div",{className:"flex items-center",children:[C[t]?(0,r.jsx)(f.Z,{className:"w-4 h-4 mr-2"}):(0,r.jsx)(g.Z,{className:"w-4 h-4 mr-2"}),(0,r.jsxs)("span",{className:"text-sm font-medium text-gray-700",children:["Task ",t+1,": ",e.preview]})]})}),C[t]&&(0,r.jsx)("div",{className:"mt-3 ml-6",children:(0,r.jsx)("pre",{className:"text-sm text-gray-800 font-mono whitespace-pre-wrap",children:e.content})})]},t))})})()})]})]})]})]})}t.default=function(){var e;let t=(0,l.useRouter)(),{job:s,tab:i}=t.query,[m,x]=(0,n.useState)(0),{jobData:f,loading:g}=(0,o.UA)(s,m),[p,y]=(0,n.useState)(!1),[b,w]=(0,n.useState)(!0),[E,L]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[R,T]=(0,n.useState)(!1),[I,k]=(0,n.useState)(!1),[A,D]=(0,n.useState)(!1),[_,Z]=(0,n.useState)(0),[P,O]=(0,n.useState)(0),q=(0,j.X)();n.useEffect(()=>{!g&&b&&w(!1)},[g,b]);let F=e=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})};(0,n.useEffect)(()=>{k(!0)},[]),(0,n.useEffect)(()=>{if(!A){let e=new MutationObserver(()=>{let t=document.getElementById("logs-section"),s=document.getElementById("controller-logs-section");("logs"===i&&t||"controllerlogs"===i&&s)&&(D(!0),e.disconnect())});return e.observe(document.body,{childList:!0,subtree:!0}),()=>e.disconnect()}},[A,i]),(0,n.useEffect)(()=>{if(t.isReady&&I&&A&&!R){let e=setTimeout(()=>{"logs"===i?(F("logs-section"),T(!0)):"controllerlogs"===i&&(F("controller-logs-section"),T(!0))},800);return()=>clearTimeout(e)}},[t.isReady,i,R,I,A]),(0,n.useEffect)(()=>{T(!1),D(!1)},[i]);let M=async()=>{y(!0);try{x(e=>e+1),Z(e=>e+1),O(e=>e+1)}catch(e){console.error("Error refreshing data:",e)}finally{y(!1)}};if(!t.isReady)return(0,r.jsx)("div",{children:"Loading..."});let U=null==f?void 0:null===(e=f.jobs)||void 0===e?void 0:e.find(e=>String(e.id)===String(s)),G=s?"Job: ".concat(s," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N(),{children:(0,r.jsx)("title",{children:G})}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(d(),{href:"/jobs",className:"text-sky-blue hover:underline",children:"Managed Jobs"}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsxs)(d(),{href:"/jobs/".concat(s),className:"text-sky-blue hover:underline",children:[s," ",(null==U?void 0:U.name)?"(".concat(U.name,")"):""]})]}),(0,r.jsxs)("div",{className:"text-sm flex items-center",children:[(g||p||E||C)&&(0,r.jsxs)("div",{className:"flex items-center mr-4",children:[(0,r.jsx)(a.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,r.jsx)(h.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,r.jsxs)("button",{onClick:M,disabled:g||p,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,r.jsx)(u.Z,{className:"w-4 h-4 mr-1.5"}),!q&&(0,r.jsx)("span",{children:"Refresh"})]})})]})]}),g&&b?(0,r.jsxs)("div",{className:"flex items-center justify-center py-32",children:[(0,r.jsx)(a.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]}):U?(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsx)("div",{id:"details-section",children:(0,r.jsxs)(c.Zb,{children:[(0,r.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Details"})}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(v,{jobData:U,activeTab:"info",setIsLoadingLogs:L,setIsLoadingControllerLogs:S,isLoadingLogs:E,isLoadingControllerLogs:C,refreshFlag:0})})]})}),(0,r.jsx)("div",{id:"logs-section",className:"mt-6",children:(0,r.jsxs)(c.Zb,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Logs"}),(0,r.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,r.jsx)(h.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{Z(e=>e+1)},disabled:E,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(u.Z,{className:"w-4 h-4 ".concat(E?"animate-spin":"")})})})]}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(v,{jobData:U,activeTab:"logs",setIsLoadingLogs:L,setIsLoadingControllerLogs:S,isLoadingLogs:E,isLoadingControllerLogs:C,refreshFlag:_})})]})}),(0,r.jsx)("div",{id:"controller-logs-section",className:"mt-6",children:(0,r.jsxs)(c.Zb,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Controller Logs"}),(0,r.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,r.jsx)(h.WH,{content:"Refresh controller logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{O(e=>e+1)},disabled:C,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(u.Z,{className:"w-4 h-4 ".concat(C?"animate-spin":"")})})})]}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(v,{jobData:U,activeTab:"controllerlogs",setIsLoadingLogs:L,setIsLoadingControllerLogs:S,isLoadingLogs:E,isLoadingControllerLogs:C,refreshFlag:P})})]})})]}):(0,r.jsx)("div",{className:"flex items-center justify-center py-32",children:(0,r.jsx)("span",{children:"Job not found"})})]})]})}},9008:function(e,t,s){e.exports=s(7219)}},function(e){e.O(0,[616,760,799,804,664,798,470,969,888,774,179],function(){return e(e.s=479)}),_N_E=e.O()}]);
16
+ */let r=(0,s(998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},9307:function(e,t,s){"use strict";s.d(t,{Cl:function(){return c},OE:function(){return d}});var r=s(5893);s(7294);var n=s(8799),a=s(6989),l=s(3850);let c=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":return"bg-green-50 text-green-700";case"STOPPED":return"bg-yellow-100 text-yellow-800";case"TERMINATED":default:return"bg-gray-100 text-gray-800";case"PENDING":case"CANCELLED":case"CANCELLING":return"bg-yellow-50 text-yellow-700";case"SUCCEEDED":return"bg-blue-50 text-blue-700";case"FAILED":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":return"bg-red-50 text-red-700";case"RECOVERING":return"bg-orange-50 text-orange-700";case"SUBMITTED":return"bg-indigo-50 text-indigo-700";case"STARTING":return"bg-cyan-50 text-cyan-700";case"FAILED_SETUP":return"bg-pink-50 text-pink-700"}},o=e=>{switch(e){case"LAUNCHING":case"STARTING":return(0,r.jsx)(n.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":default:return(0,r.jsx)(l.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":return(0,r.jsx)(l.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":return(0,r.jsx)(l.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,r.jsx)(l.Ye,{className:"w-3 h-3 mr-1"});case"PENDING":case"RECOVERING":case"SUBMITTED":case"CANCELLING":case"FAILED_SETUP":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":return(0,r.jsx)(l.J$,{className:"w-3 h-3 mr-1"})}},i=e=>{let t=c(e),s=o(e);return(0,r.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(t),children:[s,e]})},d=e=>{let{status:t}=e;return(0,r.jsx)(a.WH,{content:t,className:"text-muted-foreground text-sm",children:(0,r.jsx)("span",{children:i(t)})})}},7673:function(e,t,s){"use strict";s.d(t,{Ol:function(){return i},Zb:function(){return o},aY:function(){return m},eW:function(){return x},ll:function(){return d}});var r=s(5893),n=s(7294),a=s(5697),l=s.n(a),c=s(2350);let o=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",s),...a,children:n})});o.displayName="Card",o.propTypes={className:l().string,children:l().node};let i=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("flex flex-col space-y-1.5 p-6",s),...a,children:n})});i.displayName="CardHeader",i.propTypes={className:l().string,children:l().node};let d=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("h3",{ref:t,className:(0,c.cn)("text-2xl font-semibold leading-none tracking-tight",s),...a,children:n})});d.displayName="CardTitle",d.propTypes={className:l().string,children:l().node};let u=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("p",{ref:t,className:(0,c.cn)("text-sm text-muted-foreground",s),...a,children:n})});u.displayName="CardDescription",u.propTypes={className:l().string,children:l().node};let m=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("p-6 pt-0",s),...a,children:n})});m.displayName="CardContent",m.propTypes={className:l().string,children:l().node};let x=n.forwardRef((e,t)=>{let{className:s,children:n,...a}=e;return(0,r.jsx)("div",{ref:t,className:(0,c.cn)("flex items-center p-6 pt-0",s),...a,children:n})});x.displayName="CardFooter",x.propTypes={className:l().string,children:l().node}},7145:function(e,t,s){"use strict";s.d(t,{x:function(){return n}});var r=s(3225);let n={fetch:async(e,t)=>{let s=window.location.origin,n="".concat(s).concat(r.f4).concat(e),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=a.headers.get("X-Skypilot-Request-ID")||a.headers.get("X-Request-ID"),c=await fetch("".concat(s).concat(r.f4,"/api/get?request_id=").concat(l)),o=await c.json();return o.return_value?JSON.parse(o.return_value):[]},post:async(e,t)=>{let s=window.location.origin,n="".concat(s).concat(r.f4).concat(e);return await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},stream:async(e,t,s)=>{let r=(await n.post(e,t)).body.getReader();try{for(;;){let{done:e,value:t}=await r.read();if(e)break;let n=new TextDecoder().decode(t);s(n)}}catch(e){throw console.error("Error in stream:",e),e}},get:async e=>{let t=window.location.origin,s="".concat(t).concat(r.f4).concat(e);return await fetch(s)}}},2350:function(e,t,s){"use strict";s.d(t,{cn:function(){return a}});var r=s(512),n=s(8388);function a(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,n.m6)((0,r.W)(t))}},4303:function(e,t,s){"use strict";s.d(t,{_q:function(){return n},pJ:function(){return c}});var r=s(1272);let n=e=>{if(!e)return"No YAML available";try{let t=r.ZP.load(e),s=r.ZP.dump(t,{lineWidth:-1,styles:{"!!str":"literal"},quotingType:"'",forceQuotes:!1,noRefs:!0,sortKeys:!1,condenseFlow:!1,indent:2}).split("\n"),n=[],a=-1;for(let e=0;e<s.length;e++){let t=s[e],r=t.search(/\S/);0===r&&a>=0&&e>0&&n.push(""),n.push(t),a=r}return n.join("\n").trim()}catch(t){return console.error("YAML formatting error:",t),e}},a=e=>"string"==typeof e?e.substring(0,50)+"...":e&&e.name?"name: ".concat(e.name):e&&e.resources?"Task configuration":"YAML document",l=(e,t)=>{try{let s=r.ZP.load(e),n=r.ZP.dump(s,{lineWidth:-1,styles:{"!!str":"literal"},quotingType:"'",forceQuotes:!1,noRefs:!0,sortKeys:!1,condenseFlow:!1,indent:2}).split("\n"),l=[],c=-1;for(let e=0;e<n.length;e++){let t=n[e],s=t.search(/\S/);0===s&&c>=0&&e>0&&l.push(""),l.push(t),c=s}return{index:t,content:l.join("\n").trim(),preview:a(s)}}catch(s){return console.error("YAML formatting error for document ".concat(t,":"),s),{index:t,content:e,preview:"Invalid YAML"}}},c=e=>{if(!e)return[];try{let t=[],s=e.split(/^---$/m);for(let e=0;e<s.length;e++){let r=s[e].trim();r&&""!==r&&t.push(r)}return(t.length>1?t.slice(1):t).map((e,t)=>l(e,t))}catch(t){return console.error("YAML formatting error:",t),[{index:0,content:e,preview:"Invalid YAML"}]}}},8099:function(e,t,s){"use strict";s.r(t);var r=s(5893),n=s(7294),a=s(8799),l=s(1163);s(9470);var c=s(7673),o=s(8969),i=s(1664),d=s.n(i),u=s(3626),m=s(282),x=s(8671),f=s(5895),g=s(6639),h=s(6989),j=s(9307),p=s(3001),N=s(9008),y=s.n(N),b=s(4303);function v(e){let{jobData:t,activeTab:s,setIsLoadingLogs:l,setIsLoadingControllerLogs:c,isLoadingLogs:i,isLoadingControllerLogs:u,refreshFlag:p}=e,[N,y]=(0,n.useState)(""),[v,w]=(0,n.useState)(""),[E,L]=(0,n.useState)(!1),[C,S]=(0,n.useState)({}),[R,T]=(0,n.useState)(!1),[I,k]=(0,n.useState)(!1),[A,D]=(0,n.useState)(0),[_,Z]=(0,n.useState)(0),[P,O]=(0,n.useState)(!1),[q,F]=(0,n.useState)(!1),[M,U]=(0,n.useState)(!1),[G,W]=(0,n.useState)(!1),H=(0,n.useRef)(null),J=(0,n.useRef)(null),Y=(0,n.useRef)(new WeakSet),B=(0,n.useRef)(null),z=(0,n.useRef)(null),$=(0,n.useRef)(""),V=(0,n.useRef)(""),X=(0,n.useRef)(null);(0,n.useRef)(0);let K=(0,n.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"request";if(e){if(Y.current.has(e)){console.log("".concat(t," controller already aborted previously, skipping"));return}try{if("function"!=typeof e.abort){console.warn("Controller for ".concat(t," does not have abort method"));return}if(e.signal&&e.signal.aborted){console.log("".concat(t," already aborted via signal, skipping")),Y.current.add(e);return}e.abort(),Y.current.add(e),console.log("Successfully aborted ".concat(t))}catch(s){console.log("Caught error while aborting ".concat(t,":"),s.name,s.message),Y.current.add(e),"AbortError"!==s.name&&"InvalidStateError"!==s.name&&console.warn("Unexpected error aborting ".concat(t,":"),s)}}},[]),Q=(0,n.useCallback)(e=>{let t="logs"===e?B:z;if(t.current)for(let s of[()=>t.current.querySelector(".logs-container"),()=>t.current.querySelector('[class*="logs-container"]'),()=>t.current.querySelector('div[style*="overflow"]'),()=>t.current]){let t=s();if(t&&t.scrollHeight>t.clientHeight){t.scrollTop=t.scrollHeight,console.log("Auto-scrolled ".concat(e," to bottom"));break}}},[]),ee=["PENDING","SUBMITTED","STARTING"].includes(t.status),et=["PENDING","SUBMITTED"].includes(t.status),es=["RECOVERING"].includes(t.status),er=e=>{S(t=>({...t,[e]:!t[e]}))},en=async()=>{try{let e=(0,b.pJ)(t.dag_yaml),s="";s=1===e.length?e[0].content:e.length>1?e.map(e=>e.content).join("\n---\n"):t.dag_yaml,await navigator.clipboard.writeText(s),T(!0),setTimeout(()=>T(!1),2e3)}catch(e){console.error("Failed to copy YAML to clipboard:",e)}},ea=async()=>{try{await navigator.clipboard.writeText(t.entrypoint),k(!0),setTimeout(()=>k(!1),2e3)}catch(e){console.error("Failed to copy command to clipboard:",e)}};(0,n.useEffect)(()=>{y(""),D(0),W(!1)},[s,t.id]),(0,n.useEffect)(()=>{w(""),Z(0),W(!1)},[s,t.id]);let el=(0,n.useCallback)(function(e,t,s,r){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a="logs"===e?H:J;if(a.current)return console.log("Request already active for ".concat(e,", skipping...")),()=>{};let l=!0,c=new AbortController;return"logs"===e&&(ee||es)?(r(!1),n&&O(!1),()=>{}):"controllerlogs"===e&&et?(r(!1),n&&F(!1),()=>{}):t?(a.current=c,r(!0),U(!0),n&&(s(""),"logs"===e?D(0):Z(0)),(0,o.NJ)({jobId:t,controller:"controllerlogs"===e,signal:c.signal,onNewLog:t=>{if(l){let s=(0,h.q8)(t);G||W(!0),ec(e,s),"logs"===e?D(e=>e+s.length):Z(e=>e+s.length)}}}).then(()=>{l&&(r(!1),n&&("logs"===e?O(!1):F(!1)),requestAnimationFrame(()=>{Q(e)}))}).catch(t=>{l&&("AbortError"!==t.name&&(console.error("Error streaming ".concat(e,":"),t),t.message&&s(e=>e+"Error fetching logs: ".concat(t.message,"\n"))),r(!1),n&&("logs"===e?O(!1):F(!1)))}).finally(()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===c&&(K(c,e),a.current=null),"logs"===e?$.current="":V.current="",X.current&&(clearTimeout(X.current),X.current=null)}),()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===c&&(K(c,"".concat(e," cleanup")),a.current=null),"logs"===e?$.current="":V.current="",X.current&&(clearTimeout(X.current),X.current=null)}):()=>{l=!1}},[ee,et,es,G,K]);(0,n.useEffect)(()=>{if(H.current&&(K(H.current,"logs"),H.current=null),!ee&&!es)return el("logs",t.id,y,l)},[t.id,el,l,ee,es,K]),(0,n.useEffect)(()=>{if(J.current&&(K(J.current,"controller logs"),J.current=null),!et)return el("controllerlogs",t.id,w,c)},[t.id,el,c,et,K]),(0,n.useEffect)(()=>{if(p>0&&"logs"===s)return H.current&&(K(H.current,"logs refresh"),H.current=null),O(!0),el("logs",t.id,y,l,!0)},[p,s,t.id,el,l,K]),(0,n.useEffect)(()=>{if(p>0&&"controllerlogs"===s)return J.current&&(K(J.current,"controller logs refresh"),J.current=null),F(!0),el("controllerlogs",t.id,w,c,!0)},[p,s,t.id,el,c,K]),(0,n.useEffect)(()=>()=>{console.log("Cleaning up managed job log requests..."),H.current&&(K(H.current,"logs cleanup"),H.current=null),J.current&&(K(J.current,"controller logs cleanup"),J.current=null),X.current&&(clearTimeout(X.current),X.current=null),$.current="",V.current="",l(!1),c(!1),O(!1),F(!1)},[K]),(0,n.useEffect)(()=>{let e=()=>{document.hidden?(console.log("Page hidden - pausing log streaming for performance"),X.current&&(clearTimeout(X.current),X.current=null)):console.log("Page visible - resuming normal operation")};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),(0,n.useEffect)(()=>{let e=()=>{("logs"===s&&N||"controllerlogs"===s&&v)&&Q("logs"===s?"logs":"controllerlogs")};requestAnimationFrame(()=>{requestAnimationFrame(e)})},[s,N,v,Q]);let ec=(0,n.useCallback)((e,t)=>{("logs"===e?y:w)(e=>e+t),requestAnimationFrame(()=>{Q(e)})},[Q]);return"logs"===s?(0,r.jsx)("div",{className:"max-h-96 overflow-y-auto",ref:B,children:ee?(0,r.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,r.jsx)("span",{children:"Waiting for the job to start; refresh in a few moments."})}):es?(0,r.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,r.jsx)("span",{children:"Waiting for the job to recover; refresh in a few moments."})}):G||N?(0,r.jsx)(h.$B,{logs:N}):i?(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,r.jsx)(a.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading logs..."})]}):(0,r.jsx)(h.$B,{logs:N})}):"controllerlogs"===s?(0,r.jsx)("div",{className:"max-h-96 overflow-y-auto",ref:z,children:et?(0,r.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,r.jsx)("span",{children:"Waiting for the job controller process to start; refresh in a few moments."})}):G||v?(0,r.jsx)(h.$B,{logs:v,controller:!0}):u?(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,r.jsx)(a.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading logs..."})]}):(0,r.jsx)(h.$B,{logs:v,controller:!0})}):(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job ID (Name)"}),(0,r.jsxs)("div",{className:"text-base mt-1",children:[t.id," ",t.name?"(".concat(t.name,")"):""]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,r.jsx)("div",{className:"text-base mt-1",children:(0,r.jsx)(j.OE,{status:t.status})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.user})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Submitted"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.submitted_at?(0,h.xn)(t.submitted_at):"N/A"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Requested Resources"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.requested_resources||"N/A"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Infra"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.infra?(0,r.jsx)(h.Md,{content:t.full_infra||t.infra,className:"text-sm text-muted-foreground",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(d(),{href:"/infra",className:"text-blue-600 hover:underline",children:t.cloud||t.infra.split("(")[0].trim()}),t.infra.includes("(")&&(0,r.jsx)("span",{children:" "+t.infra.substring(t.infra.indexOf("("))})]})}):"-"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Resources"}),(0,r.jsx)("div",{className:"text-base mt-1",children:t.resources_str_full||t.resources_str||"-"})]}),(t.entrypoint||t.dag_yaml)&&(0,r.jsxs)("div",{className:"col-span-2",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Entrypoint"}),t.entrypoint&&(0,r.jsx)(h.WH,{content:I?"Copied!":"Copy command",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:ea,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:I?(0,r.jsx)(m.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(x.Z,{className:"w-4 h-4"})})})]}),(0,r.jsxs)("div",{className:"space-y-4 mt-3",children:[t.entrypoint&&(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all",children:t.entrypoint})})}),t.dag_yaml&&"{}"!==t.dag_yaml&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center mb-2",children:[(0,r.jsxs)("button",{onClick:()=>{L(!E)},className:"flex items-center text-left focus:outline-none text-gray-700 hover:text-gray-900 transition-colors duration-200",children:[E?(0,r.jsx)(f.Z,{className:"w-4 h-4 mr-1"}):(0,r.jsx)(g.Z,{className:"w-4 h-4 mr-1"}),(0,r.jsx)("span",{className:"text-base",children:"Show SkyPilot YAML"})]}),(0,r.jsx)(h.WH,{content:R?"Copied!":"Copy YAML",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:en,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:R?(0,r.jsx)(m.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(x.Z,{className:"w-4 h-4"})})})]}),E&&(0,r.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3 max-h-96 overflow-y-auto",children:(()=>{let e=(0,b.pJ)(t.dag_yaml);return 0===e.length?(0,r.jsx)("div",{className:"text-gray-500",children:"No YAML available"}):1===e.length?(0,r.jsx)("pre",{className:"text-sm text-gray-800 font-mono whitespace-pre-wrap",children:e[0].content}):(0,r.jsx)("div",{className:"space-y-4",children:e.map((e,t)=>(0,r.jsxs)("div",{className:"border-b border-gray-200 pb-4 last:border-b-0",children:[(0,r.jsx)("button",{onClick:()=>er(t),className:"flex items-center justify-between w-full text-left focus:outline-none",children:(0,r.jsxs)("div",{className:"flex items-center",children:[C[t]?(0,r.jsx)(f.Z,{className:"w-4 h-4 mr-2"}):(0,r.jsx)(g.Z,{className:"w-4 h-4 mr-2"}),(0,r.jsxs)("span",{className:"text-sm font-medium text-gray-700",children:["Task ",t+1,": ",e.preview]})]})}),C[t]&&(0,r.jsx)("div",{className:"mt-3 ml-6",children:(0,r.jsx)("pre",{className:"text-sm text-gray-800 font-mono whitespace-pre-wrap",children:e.content})})]},t))})})()})]})]})]})]})}t.default=function(){var e;let t=(0,l.useRouter)(),{job:s,tab:i}=t.query,[m,x]=(0,n.useState)(0),{jobData:f,loading:g}=(0,o.UA)(s,m),[j,N]=(0,n.useState)(!1),[b,w]=(0,n.useState)(!0),[E,L]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[R,T]=(0,n.useState)(!1),[I,k]=(0,n.useState)(!1),[A,D]=(0,n.useState)(!1),[_,Z]=(0,n.useState)(0),[P,O]=(0,n.useState)(0),q=(0,p.X)();n.useEffect(()=>{!g&&b&&w(!1)},[g,b]);let F=e=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})};(0,n.useEffect)(()=>{k(!0)},[]),(0,n.useEffect)(()=>{if(!A){let e=new MutationObserver(()=>{let t=document.getElementById("logs-section"),s=document.getElementById("controller-logs-section");("logs"===i&&t||"controllerlogs"===i&&s)&&(D(!0),e.disconnect())});return e.observe(document.body,{childList:!0,subtree:!0}),()=>e.disconnect()}},[A,i]),(0,n.useEffect)(()=>{if(t.isReady&&I&&A&&!R){let e=setTimeout(()=>{"logs"===i?(F("logs-section"),T(!0)):"controllerlogs"===i&&(F("controller-logs-section"),T(!0))},800);return()=>clearTimeout(e)}},[t.isReady,i,R,I,A]),(0,n.useEffect)(()=>{T(!1),D(!1)},[i]);let M=async()=>{N(!0);try{x(e=>e+1),Z(e=>e+1),O(e=>e+1)}catch(e){console.error("Error refreshing data:",e)}finally{N(!1)}};if(!t.isReady)return(0,r.jsx)("div",{children:"Loading..."});let U=null==f?void 0:null===(e=f.jobs)||void 0===e?void 0:e.find(e=>String(e.id)===String(s)),G=s?"Job: ".concat(s," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(y(),{children:(0,r.jsx)("title",{children:G})}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(d(),{href:"/jobs",className:"text-sky-blue hover:underline",children:"Managed Jobs"}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsxs)(d(),{href:"/jobs/".concat(s),className:"text-sky-blue hover:underline",children:[s," ",(null==U?void 0:U.name)?"(".concat(U.name,")"):""]})]}),(0,r.jsxs)("div",{className:"text-sm flex items-center",children:[(g||j||E||C)&&(0,r.jsxs)("div",{className:"flex items-center mr-4",children:[(0,r.jsx)(a.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,r.jsx)(h.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,r.jsxs)("button",{onClick:M,disabled:g||j,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,r.jsx)(u.Z,{className:"w-4 h-4 mr-1.5"}),!q&&(0,r.jsx)("span",{children:"Refresh"})]})})]})]}),g&&b?(0,r.jsxs)("div",{className:"flex items-center justify-center py-32",children:[(0,r.jsx)(a.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]}):U?(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsx)("div",{id:"details-section",children:(0,r.jsxs)(c.Zb,{children:[(0,r.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Details"})}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(v,{jobData:U,activeTab:"info",setIsLoadingLogs:L,setIsLoadingControllerLogs:S,isLoadingLogs:E,isLoadingControllerLogs:C,refreshFlag:0})})]})}),(0,r.jsx)("div",{id:"logs-section",className:"mt-6",children:(0,r.jsxs)(c.Zb,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Logs"}),(0,r.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,r.jsx)(h.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{Z(e=>e+1)},disabled:E,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(u.Z,{className:"w-4 h-4 ".concat(E?"animate-spin":"")})})})]}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(v,{jobData:U,activeTab:"logs",setIsLoadingLogs:L,setIsLoadingControllerLogs:S,isLoadingLogs:E,isLoadingControllerLogs:C,refreshFlag:_})})]})}),(0,r.jsx)("div",{id:"controller-logs-section",className:"mt-6",children:(0,r.jsxs)(c.Zb,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Controller Logs"}),(0,r.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,r.jsx)(h.WH,{content:"Refresh controller logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{O(e=>e+1)},disabled:C,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(u.Z,{className:"w-4 h-4 ".concat(C?"animate-spin":"")})})})]}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(v,{jobData:U,activeTab:"controllerlogs",setIsLoadingLogs:L,setIsLoadingControllerLogs:S,isLoadingLogs:E,isLoadingControllerLogs:C,refreshFlag:P})})]})})]}):(0,r.jsx)("div",{className:"flex items-center justify-center py-32",children:(0,r.jsx)("span",{children:"Job not found"})})]})]})}},9008:function(e,t,s){e.exports=s(7219)}},function(e){e.O(0,[616,760,799,804,664,798,989,470,969,888,774,179],function(){return e(e.s=479)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[142],{1446:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/jobs",function(){return t(8929)}])},8929:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return a}});var r=t(5893);t(7294);var s=t(9008),i=t.n(s),o=t(5152);let u=t.n(o)()(()=>Promise.all([t.e(616),t.e(760),t.e(799),t.e(804),t.e(664),t.e(947),t.e(989),t.e(470),t.e(901),t.e(969),t.e(856),t.e(973),t.e(938),t.e(211)]).then(t.bind(t,938)).then(e=>e.ManagedJobs),{loadableGenerated:{webpack:()=>[938]},ssr:!1});function a(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i(),{children:(0,r.jsx)("title",{children:"Managed Jobs | SkyPilot Dashboard"})}),(0,r.jsx)(u,{})]})}},9008:function(e,n,t){e.exports=t(7219)}},function(e){e.O(0,[888,774,179],function(){return e(e.s=1446)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[892],{7476:function(e,n,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/users",function(){return r(5126)}])},5126:function(e,n,r){"use strict";r.r(n),r.d(n,{default:function(){return o}});var t=r(5893);r(7294);var s=r(9008),u=r.n(s),i=r(5152);let c=r.n(i)()(()=>Promise.all([r.e(616),r.e(760),r.e(799),r.e(804),r.e(664),r.e(984),r.e(989),r.e(470),r.e(901),r.e(969),r.e(856),r.e(641)]).then(r.bind(r,2641)).then(e=>e.Users),{loadableGenerated:{webpack:()=>[2641]},ssr:!1});function o(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u(),{children:(0,t.jsx)("title",{children:"Users | SkyPilot Dashboard"})}),(0,t.jsx)(c,{})]})}},9008:function(e,n,r){e.exports=r(7219)}},function(e){e.O(0,[888,774,179],function(){return e(e.s=7476)}),_N_E=e.O()}]);