(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9315,2544],{479:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/jobs/[job]",function(){return s(8099)}])},6639:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @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 r=(0,s(998).Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},8671:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @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 r=(0,s(998).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"}]])},3626:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @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 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(5739),a=s(6989),l=s(3850);let c=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":case"IN_USE":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":case"READY":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":case"IN_USE":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":case"READY":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)})})}},546:function(e,t,s){"use strict";s.d(t,{H:function(){return d}});var r=s(5893);s(7294);var n=s(1664),a=s.n(n),l=s(5697),c=s.n(l);function o(e){return!!e&&"string"==typeof e&&e.toLowerCase().startsWith("sa-")}let i=()=>(0,r.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:n="flex items-center gap-1",linkClassName:l="text-blue-600 hover:underline",showBadge:c=!0}=e,d=o(s),u=o(s)?"/users?tab=service-accounts":"/users";return(0,r.jsxs)("div",{className:n,children:[(0,r.jsx)(a(),{href:u,className:l,children:t}),c&&d&&(0,r.jsx)(i,{})]})};d.propTypes={username:c().string.isRequired,userHash:c().string,className:c().string,linkClassName:c().string,showBadge:c().bool}},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 function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST",n=window.location.origin,a="".concat(n).concat(r.f4).concat(e),l=await fetch(a,{method:s,headers:"POST"===s?{"Content-Type":"application/json"}:{},body:"POST"===s?JSON.stringify(t):void 0}),c=l.headers.get("X-Skypilot-Request-ID")||l.headers.get("X-Request-ID"),o=await fetch("".concat(n).concat(r.f4,"/api/get?request_id=").concat(c)),i=await o.json();return i.return_value?JSON.parse(i.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(5739),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),v=s(546);function w(e){let{jobData:t,activeTab:s,setIsLoadingLogs:l,setIsLoadingControllerLogs:c,isLoadingLogs:i,isLoadingControllerLogs:u,refreshFlag:p}=e,[N,y]=(0,n.useState)(""),[w,E]=(0,n.useState)(""),[L,C]=(0,n.useState)(!1),[S,R]=(0,n.useState)({}),[T,I]=(0,n.useState)(!1),[k,A]=(0,n.useState)(!1),[D,_]=(0,n.useState)(0),[Z,P]=(0,n.useState)(0),[O,q]=(0,n.useState)(!1),[F,M]=(0,n.useState)(!1),[U,H]=(0,n.useState)(!1),[G,W]=(0,n.useState)(!1),Y=(0,n.useRef)(null),J=(0,n.useRef)(null),B=(0,n.useRef)(new WeakSet),z=(0,n.useRef)(null),$=(0,n.useRef)(null),V=(0,n.useRef)(""),X=(0,n.useRef)(""),K=(0,n.useRef)(null);(0,n.useRef)(0);let Q=(0,n.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"request";if(e){if(B.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")),B.current.add(e);return}e.abort(),B.current.add(e),console.log("Successfully aborted ".concat(t))}catch(s){console.log("Caught error while aborting ".concat(t,":"),s.name,s.message),B.current.add(e),"AbortError"!==s.name&&"InvalidStateError"!==s.name&&console.warn("Unexpected error aborting ".concat(t,":"),s)}}},[]),ee=(0,n.useCallback)(e=>{let t="logs"===e?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}}},[]),et=["PENDING","SUBMITTED","STARTING"].includes(t.status),es=["PENDING","SUBMITTED"].includes(t.status),er=["RECOVERING"].includes(t.status),en=e=>{R(t=>({...t,[e]:!t[e]}))},ea=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),I(!0),setTimeout(()=>I(!1),2e3)}catch(e){console.error("Failed to copy YAML to clipboard:",e)}},el=async()=>{try{await navigator.clipboard.writeText(t.entrypoint),A(!0),setTimeout(()=>A(!1),2e3)}catch(e){console.error("Failed to copy command to clipboard:",e)}};(0,n.useEffect)(()=>{y(""),_(0),W(!1)},[s,t.id]),(0,n.useEffect)(()=>{E(""),P(0),W(!1)},[s,t.id]);let ec=(0,n.useCallback)((e,t)=>{("logs"===e?y:E)(e=>e+t),requestAnimationFrame(()=>{ee(e)})},[ee]),eo=(0,n.useCallback)(function(e,t,s,r){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a="logs"===e?Y:J;if(a.current)return console.log("Request already active for ".concat(e,", skipping...")),()=>{};let l=!0,c=new AbortController;return"logs"===e&&(et||er)?(r(!1),n&&q(!1),()=>{}):"controllerlogs"===e&&es?(r(!1),n&&M(!1),()=>{}):t?(a.current=c,r(!0),H(!0),n&&(s(""),"logs"===e?_(0):P(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?_(e=>e+s.length):P(e=>e+s.length)}}}).then(()=>{l&&(r(!1),n&&("logs"===e?q(!1):M(!1)),requestAnimationFrame(()=>{ee(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?q(!1):M(!1)))}).finally(()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===c&&(Q(c,e),a.current=null),"logs"===e?V.current="":X.current="",K.current&&(clearTimeout(K.current),K.current=null)}),()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===c&&(Q(c,"".concat(e," cleanup")),a.current=null),"logs"===e?V.current="":X.current="",K.current&&(clearTimeout(K.current),K.current=null)}):()=>{l=!1}},[et,es,er,G,Q,ee,ec]);return((0,n.useEffect)(()=>{if(Y.current&&(Q(Y.current,"logs"),Y.current=null),!et&&!er)return eo("logs",t.id,y,l)},[t.id,eo,l,et,er,Q]),(0,n.useEffect)(()=>{if(J.current&&(Q(J.current,"controller logs"),J.current=null),!es)return eo("controllerlogs",t.id,E,c)},[t.id,eo,c,es,Q]),(0,n.useEffect)(()=>{if(p>0&&"logs"===s)return Y.current&&(Q(Y.current,"logs refresh"),Y.current=null),q(!0),eo("logs",t.id,y,l,!0)},[p,s,t.id,eo,l,Q]),(0,n.useEffect)(()=>{if(p>0&&"controllerlogs"===s)return J.current&&(Q(J.current,"controller logs refresh"),J.current=null),M(!0),eo("controllerlogs",t.id,E,c,!0)},[p,s,t.id,eo,c,Q]),(0,n.useEffect)(()=>()=>{console.log("Cleaning up managed job log requests..."),Y.current&&(Q(Y.current,"logs cleanup"),Y.current=null),J.current&&(Q(J.current,"controller logs cleanup"),J.current=null),K.current&&(clearTimeout(K.current),K.current=null),V.current="",X.current="",l(!1),c(!1),q(!1),M(!1)},[Q,l,c]),(0,n.useEffect)(()=>{let e=()=>{document.hidden?(console.log("Page hidden - pausing log streaming for performance"),K.current&&(clearTimeout(K.current),K.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&&w)&&ee("logs"===s?"logs":"controllerlogs")};requestAnimationFrame(()=>{requestAnimationFrame(e)})},[s,N,w,ee]),"logs"===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 to start; refresh in a few moments."})}):er?(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:$,children: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 controller process to start; refresh in a few moments."})}):G||w?(0,r.jsx)(h.$B,{logs:w,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:w,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:(0,r.jsx)(v.H,{username:t.user,userHash:t.user_hash})})]}),(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:k?"Copied!":"Copy command",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:el,className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:k?(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:()=>{C(!L)},className:"flex items-center text-left focus:outline-none text-gray-700 hover:text-gray-900 transition-colors duration-200",children:[L?(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:T?"Copied!":"Copy YAML",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:T?(0,r.jsx)(m.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(x.Z,{className:"w-4 h-4"})})})]}),L&&(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:()=>en(t),className:"flex items-center justify-between w-full text-left focus:outline-none",children:(0,r.jsxs)("div",{className:"flex items-center",children:[S[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]})]})}),S[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,v]=(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&&v(!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)),H=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:H})}),(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)(w,{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)(w,{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)(w,{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)},1163:function(e,t,s){e.exports=s(6036)}},function(e){e.O(0,[616,5230,5739,1664,804,1272,6989,3698,9470,8969,2888,9774,179],function(){return e(e.s=479)}),_N_E=e.O()}]);