(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9826,2350],{94966:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters/[cluster]/[job]",function(){return s(50190)}])},27325:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let a=(0,s(60998).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},16826:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let a=(0,s(60998).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},13626:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let a=(0,s(60998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},99307:function(e,t,s){"use strict";s.d(t,{Cl:function(){return l},OE:function(){return d}});var a=s(85893);s(67294);var r=s(55739),n=s(36989),c=s(53850);let l=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":case"IN_USE":case"READY":return"bg-green-50 text-green-700";case"STOPPED":return"bg-yellow-100 text-yellow-800";case"TERMINATED":case"PENDING":case"UNKNOWN":default:return"bg-gray-100 text-gray-800";case"SUCCEEDED":case"PROVISIONING":case"CONTROLLER_INIT":case"REPLICA_INIT":return"bg-blue-50 text-blue-700";case"FAILED":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":case"FAILED_INITIAL_DELAY":case"FAILED_PROBING":case"FAILED_PROVISION":case"FAILED_CLEANUP":case"CONTROLLER_FAILED":return"bg-red-50 text-red-700";case"CANCELLED":case"CANCELLING":case"NOT_READY":return"bg-yellow-50 text-yellow-700";case"RECOVERING":case"SHUTTING_DOWN":return"bg-orange-50 text-orange-700";case"SUBMITTED":return"bg-indigo-50 text-indigo-700";case"STARTING":return"bg-cyan-50 text-cyan-700";case"FAILED_SETUP":return"bg-pink-50 text-pink-700";case"PREEMPTED":case"NO_REPLICA":return"bg-purple-50 text-purple-700"}},o=e=>{switch(e){case"LAUNCHING":case"STARTING":case"PROVISIONING":case"SHUTTING_DOWN":return(0,a.jsx)(r.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":case"IN_USE":default:return(0,a.jsx)(c.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":case"PREEMPTED":return(0,a.jsx)(c.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":case"FAILED_INITIAL_DELAY":case"FAILED_PROBING":case"FAILED_PROVISION":case"FAILED_CLEANUP":case"CONTROLLER_FAILED":case"UNKNOWN":return(0,a.jsx)(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":case"READY":case"NOT_READY":case"CONTROLLER_INIT":case"REPLICA_INIT":case"NO_REPLICA":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)})})}},20546:function(e,t,s){"use strict";s.d(t,{H:function(){return d}});var a=s(85893);s(67294);var r=s(41664),n=s.n(r),c=s(45697),l=s.n(c);function o(e){return!!e&&"string"==typeof e&&e.toLowerCase().startsWith("sa-")}let i=()=>(0,a.jsx)("span",{className:"px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded font-medium ml-1",children:"SA"}),d=e=>{let{username:t,userHash:s,className:r="flex items-center gap-1",linkClassName:c="text-gray-700 hover:text-blue-600 hover:underline",showBadge:l=!0}=e,d=o(s),u=o(s)?"/users?tab=service-accounts":"/users";return(0,a.jsxs)("div",{className:r,children:[(0,a.jsx)(n(),{href:u,className:c,children:t}),l&&d&&(0,a.jsx)(i,{})]})};d.propTypes={username:l().string.isRequired,userHash:l().string,className:l().string,linkClassName:l().string,showBadge:l().bool}},37673:function(e,t,s){"use strict";s.d(t,{Ol:function(){return i},Zb:function(){return o},aY:function(){return h},ll:function(){return d}});var a=s(85893),r=s(67294),n=s(45697),c=s.n(n),l=s(32350);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}},47145:function(e,t,s){"use strict";s.d(t,{x:function(){return r}});var a=s(93225);let r={fetch:async function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST",r=window.location.origin,n="".concat(r).concat(a.f4).concat(e),c=await fetch(n,{method:s,headers:"POST"===s?{"Content-Type":"application/json"}:{},body:"POST"===s?JSON.stringify(t):void 0}),l=c.headers.get("X-Skypilot-Request-ID")||c.headers.get("X-Request-ID"),o=await fetch("".concat(r).concat(a.f4,"/api/get?request_id=").concat(l)),i=await o.json();return i.return_value?JSON.parse(i.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)}}},23266:function(e,t,s){"use strict";s.d(t,{GH:function(){return h},QL:function(){return f},Sl:function(){return u},getClusters:function(){return i},uR:function(){return d}});var a=s(67294),r=s(15821),n=s(47145),c=s(93225),l=s(6378);let o={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function i(){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,include_credentials:!1,summary_response:null==e})).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:o[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra: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,last_event:e.last_event,to_down:e.to_down,cluster_name_on_cloud:e.cluster_name_on_cloud,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){return console.error("Error fetching clusters:",e),[]}}async function d(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;try{let s={days:t,dashboard_summary_response:!0};e&&(s.cluster_hashes=[e]);let a=await n.x.fetch("/cost_report",s);console.log("Raw cluster history data:",a);let r=a.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?o[e.status]:"TERMINATED",cluster:e.name,user:s,user_hash:e.user_hash,cluster_hash:e.cluster_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,last_event:e.last_event,to_down:!1,cluster_name_on_cloud:null,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",r),r}catch(e){return console.error("Error fetching cluster history:",e),[]}}async function u(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,tail:1e4,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 h(e){let{clusterName:t,jobIds:s=null,workspace:a}=e;try{let e=await n.x.fetch("/download_logs",{cluster_name:t,job_ids:s?s.map(String):null,override_skypilot_config:{active_workspace:a||"default"}}),l=Object.values(e||{});if(!l.length){(0,r.C)("No logs found to download.","warning");return}let o=window.location.origin,i="".concat(o).concat(c.f4,"/download"),d=await fetch("".concat(i,"?relative=items"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder_paths:l})});if(!d.ok){let e=await d.text();throw Error("Download failed: ".concat(d.status," ").concat(e))}let u=await d.blob(),h=window.URL.createObjectURL(u),m=document.createElement("a"),f=new Date().toISOString().replace(/[:.]/g,"-"),g=s&&1===s.length?"job-".concat(s[0]):"jobs";m.href=h,m.download="".concat(t,"-").concat(g,"-logs-").concat(f,".zip"),document.body.appendChild(m),m.click(),m.remove(),window.URL.revokeObjectURL(h)}catch(e){console.error("Error downloading logs:",e),(0,r.C)("Error downloading logs: ".concat(e.message),"error")}}async function m(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=>{var a;let r=e.end_at?e.end_at:Date.now()/1e3,n=0,c=0;return e.submitted_at&&(n=r-e.submitted_at),e.start_at&&(c=r-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,user_hash:e.user_hash,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:n,job_duration:c,infra:"",logs:"",workspace:s||"default",git_commit:(null===(a=e.metadata)||void 0===a?void 0:a.git_commit)||"-"}})}catch(e){return console.error("Error fetching cluster jobs:",e),[]}}function f(e){let{cluster:t,job:s=null}=e,[r,n]=(0,a.useState)(null),[c,o]=(0,a.useState)(null),[d,u]=(0,a.useState)(!0),[h,f]=(0,a.useState)(!0),g=(0,a.useCallback)(async()=>{if(t)try{u(!0);let e=await l.default.get(i,[{clusterNames:[t]}]);return n(e[0]),e[0]}catch(e){console.error("Error fetching cluster data:",e)}finally{u(!1)}return null},[t]),x=(0,a.useCallback)(async e=>{if(t)try{f(!0);let s=await l.default.get(m,[{clusterName:t,workspace:e||"default"}]);o(s)}catch(e){console.error("Error fetching cluster job data:",e)}finally{f(!1)}},[t]),p=(0,a.useCallback)(async()=>{l.default.invalidate(i,[{clusterNames:[t]}]);let e=await g();e&&(l.default.invalidate(m,[{clusterName:t,workspace:e.workspace||"default"}]),await x(e.workspace))},[g,x,t]),N=(0,a.useCallback)(async()=>{r&&(l.default.invalidate(m,[{clusterName:t,workspace:r.workspace||"default"}]),await x(r.workspace))},[x,r,t]);return(0,a.useEffect)(()=>{(async()=>{let e=await g();e&&x(e.workspace)})()},[t,s,g,x]),{clusterData:r,clusterJobData:c,loading:d,clusterDetailsLoading:d,clusterJobsLoading:h,refreshData:p,refreshClusterJobsOnly:N}}},15821: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 n},dashboardCache:function(){return c}});let a=s(51214).ej.DEFAULT_TTL;function r(e){let t=5381;for(let s=0;s<e.length;s++)t=(t<<5)+t+e.charCodeAt(s);return t>>>0}class n{setPreloader(e){this.preloader=e}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);if(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)){var d;(null===(d=this.preloader)||void 0===d?void 0:d.wasRecentlyPreloaded(e,t))?this._debug("Skipping background refresh for ".concat(l," - recently preloaded")):this._refreshInBackground(e,t,c)}return o.data}if(this.pendingRequests.has(c))return this._debug("Request deduplication: Waiting for pending request for ".concat(l)),this.pendingRequests.get(c);let u=(async()=>{try{let s=await e(...t);if(s&&s.__skipCache){if(this._debug("Skip caching for ".concat(l," due to __skipCache flag on result")),o)return o.data;return s}return this.cache.set(c,{data:s,lastUpdated:Date.now()}),s}catch(e){if(o)return console.warn("Failed to fetch fresh data for ".concat(c,", returning stale data:"),e),o.data;throw e}finally{this.pendingRequests.delete(c)}})();return this.pendingRequests.set(c,u),u}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),this.pendingRequests.delete(s)}invalidateFunction(e){let t=r(e.toString()),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),this.pendingRequests.delete(e)})}clear(){this.cache.clear(),this.backgroundJobs.clear(),this.pendingRequests.clear()}getStats(){return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,pendingRequests:this.pendingRequests.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),hasPendingRequest:this.pendingRequests.has(s)})}return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,pendingRequests:this.pendingRequests.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=>{e&&e.__skipCache||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=r(e.toString()),a=t.length>0?JSON.stringify(t):"";return"".concat(s,"_").concat(a)}constructor(){this.cache=new Map,this.backgroundJobs=new Map,this.pendingRequests=new Map,this.debugMode=!1,this.preloader=null}}let c=new n;t.default=c},32350:function(e,t,s){"use strict";s.d(t,{cn:function(){return n}});var a=s(90512),r=s(98388);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))}},50190:function(e,t,s){"use strict";s.r(t),s.d(t,{JobDetailPage:function(){return w}});var a=s(85893),r=s(67294);s(6135);var n=s(37673),c=s(41664),l=s.n(c),o=s(11163),i=s(23266),d=s(36989),u=s(13626),h=s(16826),m=s(55739),f=s(99307),g=s(23001),x=s(9008),p=s.n(x),N=s(20546),b=s(70282),_=s(27325);function y(e){let{cluster:t,job:s,jobData:r,onRefresh:n,isRefreshing:c,loading:o}=e,i=(0,g.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)(m.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 w(){let e=(0,o.useRouter)(),{cluster:t,job:s}=e.query,{clusterData:c,clusterJobData:g,loading:x,refreshData:w}=(0,i.QL)({cluster:t}),[j,v]=(0,r.useState)(!1),[E,k]=(0,r.useState)(!0),[I,C]=(0,r.useState)(!1),[R,D]=(0,r.useState)(""),[L,T]=(0,r.useState)(!1),[S,O]=(0,r.useState)(!1),A=(0,r.useMemo)(()=>["INIT","PENDING","SETTING_UP"],[]),P=(0,r.useMemo)(()=>{if(!g||!s)return!0;let e=g.find(e=>e.id==s);return e&&A.includes(e.status)},[g,s,A]);r.useEffect(()=>{!x&&E&&k(!1)},[x,E]),(0,r.useEffect)(()=>{let e=!0;return t&&s&&!P?(C(!0),(0,i.Sl)({clusterName:t,jobId:s,onNewLog:t=>{e&&D(e=>{let s=t.split("\n").filter(e=>e.trim()),a=e;for(let e of s){let t=(0,d.Zn)(e);if(/\d+%\s*\|/.test(t)){let e=t.match(/^\(([^)]+)\)/);if(e&&a){let s=a.split("\n"),r=!1;for(let n=s.length-1;n>=0;n--){let c=s[n];if(/\d+%\s*\|/.test(c)){let l=c.match(/^\(([^)]+)\)/);if(l&&l[1]===e[1]){s[n]=t,a=s.join("\n"),r=!0;break}}}r||(a+=(a?"\n":"")+t)}else a+=(a?"\n":"")+t}else a+=(a?"\n":"")+t}return a})},workspace:null==c?void 0:c.workspace}).then(()=>{e&&C(!1)}).catch(t=>{e&&(console.error("Error streaming logs:",t),C(!1))})):C(!1),()=>{e=!1}},[t,s,L,P,c]);let U=async()=>{v(!0),T(e=>!e),D("");try{w&&await w()}catch(e){console.error("Error refreshing data:",e)}finally{v(!1)}};if(!e.isReady)return(0,a.jsx)("div",{children:"Loading..."});let J={id:s};if(c&&g){let e=g.find(e=>e.id==s);e&&(J={...e,infra:c.infra,cluster:c.cluster,user:c.user,user_hash:c.user_hash})}let q=t&&s?"Job: ".concat(s," @ ").concat(t," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p(),{children:(0,a.jsx)("title",{children:q})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y,{cluster:t,job:s,jobData:J,onRefresh:U,isRefreshing:j,loading:x}),x&&E?(0,a.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,a.jsx)(m.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:J.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:J.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)(f.OE,{status:J.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:(0,a.jsx)(N.H,{username:J.user,userHash:J.user_hash})})]}),(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:J.submitted_at?(0,d.xn)(J.submitted_at):"N/A"})]}),J.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:J.resources||"N/A"})]}),J.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(J.cluster),className:"text-sky-blue hover:underline",children:J.cluster})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Git Commit"}),(0,a.jsx)("div",{className:"text-base mt-1 flex items-center",children:J.git_commit&&"-"!==J.git_commit?(0,a.jsxs)("span",{className:"flex items-center mr-2",children:[J.git_commit,(0,a.jsx)(d.WH,{content:S?"Copied!":"Copy commit",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:async()=>{await navigator.clipboard.writeText(J.git_commit),O(!0),setTimeout(()=>O(!1),2e3)},className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:S?(0,a.jsx)(b.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(_.Z,{className:"w-4 h-4"})})})]}):(0,a.jsx)("span",{className:"text-gray-400",children:"-"})})]})]})})]})}),(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.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,a.jsx)(d.WH,{content:"Download full logs",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:()=>(0,i.GH)({clusterName:t,jobIds:s?[s]:null,workspace:null==c?void 0:c.workspace}),className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,a.jsx)(h.Z,{className:"w-4 h-4"})})}),(0,a.jsx)(d.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:()=>{T(e=>!e),D("")},disabled:I,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,a.jsx)(u.Z,{className:"w-4 h-4 ".concat(I?"animate-spin":"")})})})]})]}),(0,a.jsx)("div",{className:"p-4",children:P?(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."})}):I?(0,a.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,a.jsx)(m.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:R})})})]})})]})]})]})}t.default=w},9008:function(e,t,s){e.exports=s(37219)}},function(e){e.O(0,[616,6130,5739,7411,6989,3850,6135,2888,9774,179],function(){return e(e.s=94966)}),_N_E=e.O()}]);