(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[315],{479:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/jobs/[job]",function(){return r(8099)}])},6639:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});/**
 * @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 s=(0,r(998).Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},3626:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});/**
 * @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 s=(0,r(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,r){"use strict";r.d(t,{Cl:function(){return o},OE:function(){return d}});var s=r(5893);r(7294);var n=r(8799),a=r(6989),l=r(3850);let o=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"}},c=e=>{switch(e){case"LAUNCHING":case"STARTING":return(0,s.jsx)(n.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":default:return(0,s.jsx)(l.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":return(0,s.jsx)(l.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":return(0,s.jsx)(l.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,s.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,s.jsx)(l.J$,{className:"w-3 h-3 mr-1"})}},i=e=>{let t=o(e),r=c(e);return(0,s.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(t),children:[r,e]})},d=e=>{let{status:t}=e;return(0,s.jsx)(a.WH,{content:t,className:"text-muted-foreground text-sm",children:(0,s.jsx)("span",{children:i(t)})})}},7673:function(e,t,r){"use strict";r.d(t,{Ol:function(){return i},Zb:function(){return c},aY:function(){return m},eW:function(){return f},ll:function(){return d}});var s=r(5893),n=r(7294),a=r(5697),l=r.n(a),o=r(2350);let c=n.forwardRef((e,t)=>{let{className:r,children:n,...a}=e;return(0,s.jsx)("div",{ref:t,className:(0,o.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",r),...a,children:n})});c.displayName="Card",c.propTypes={className:l().string,children:l().node};let i=n.forwardRef((e,t)=>{let{className:r,children:n,...a}=e;return(0,s.jsx)("div",{ref:t,className:(0,o.cn)("flex flex-col space-y-1.5 p-6",r),...a,children:n})});i.displayName="CardHeader",i.propTypes={className:l().string,children:l().node};let d=n.forwardRef((e,t)=>{let{className:r,children:n,...a}=e;return(0,s.jsx)("h3",{ref:t,className:(0,o.cn)("text-2xl font-semibold leading-none tracking-tight",r),...a,children:n})});d.displayName="CardTitle",d.propTypes={className:l().string,children:l().node};let u=n.forwardRef((e,t)=>{let{className:r,children:n,...a}=e;return(0,s.jsx)("p",{ref:t,className:(0,o.cn)("text-sm text-muted-foreground",r),...a,children:n})});u.displayName="CardDescription",u.propTypes={className:l().string,children:l().node};let m=n.forwardRef((e,t)=>{let{className:r,children:n,...a}=e;return(0,s.jsx)("div",{ref:t,className:(0,o.cn)("p-6 pt-0",r),...a,children:n})});m.displayName="CardContent",m.propTypes={className:l().string,children:l().node};let f=n.forwardRef((e,t)=>{let{className:r,children:n,...a}=e;return(0,s.jsx)("div",{ref:t,className:(0,o.cn)("flex items-center p-6 pt-0",r),...a,children:n})});f.displayName="CardFooter",f.propTypes={className:l().string,children:l().node}},8969:function(e,t,r){"use strict";r.d(t,{Ce:function(){return i},NJ:function(){return c},Pr:function(){return o},getManagedJobs:function(){return l}});var s=r(7294),n=r(5821),a=r(3225);async function l(){let{allUsers:e=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let t=(await fetch("".concat(a.f4,"/jobs/queue"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({all_users:e})})).headers.get("X-Skypilot-Request-ID"),r=await fetch("".concat(a.f4,"/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===a.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 s=await r.json();return{jobs:(s.return_value?JSON.parse(s.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,s=e.cloud,n=e.cluster_resources;if(!s){if(e.cluster_resources&&"-"!==e.cluster_resources)try{s=e.cluster_resources.split("(")[0].split("x").pop().trim(),n=e.cluster_resources.replace("".concat(s,"("),"(").replace("x ","x")}catch(e){s="Unknown"}else s="Unknown"}let a="",l=a=e.zone?e.zone:e.region;a&&a.length>15&&(a=a.substring(0,15)+"...");let o=s+" ("+a+")";"-"===a&&(o=s);let c=s+" ("+l+")";return"-"===l&&(c=s),{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,priority:e.priority,requested_resources:e.resources,resources_str:n,resources_str_full:e.cluster_resources_full||n,cloud:s,region:e.region,infra:o,full_infra:c,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.dag_yaml,entrypoint:e.entrypoint}}),controllerStopped:!1}}catch(e){return console.error("Error fetching managed job data:",e),{jobs:[],controllerStopped:!1}}}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,[t,r]=(0,s.useState)(null),[n,a]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{(async function(){try{a(!0);let e=await l({allUsers:!0});r(e)}catch(e){console.error("Error fetching managed job data:",e)}finally{a(!1)}})()},[e]),{jobData:t,loading:n}}async function c(e){let t,{jobId:r,controller:s=!1,signal:l,onNewLog:o}=e,c=Date.now(),i=new Promise(e=>{let r=()=>{let s=Date.now()-c;s>=3e4?e({timeout:!0}):t=setTimeout(r,3e4-s)};t=setTimeout(r,3e4)}),d=(async()=>{try{let e=(await fetch("".concat(a.f4,"/jobs/logs"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({controller:s,follow:!1,job_id:r,tail:1e3}),...l?{signal:l}:{}})).body.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)break;c=Date.now();let s=new TextDecoder().decode(r);o(s)}}finally{e.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),u=await Promise.race([d,i]);if(t&&clearTimeout(t),u.timeout){(0,n.C)("Log request for job ".concat(r," timed out after ").concat(30,"s of inactivity"),"warning");return}}async function i(e,t,r){let s="",l="",o="",c={};if("restartcontroller"===e)s="Restarting",l="restarted",o="jobs/queue",c={all_users:!0,refresh:!0},t="controller";else throw Error("Invalid action: ".concat(e));(0,n.C)("".concat(s," job ").concat(t,"..."),"info");try{try{let e=(await fetch("".concat(a.f4,"/").concat(o),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})).headers.get("X-Skypilot-Request-ID"),i=await fetch("".concat(a.f4,"/api/get?request_id=").concat(e));if(200===i.status)(0,n.C)("Job ".concat(t," ").concat(l," successfully."),"success");else if(500===i.status)try{let e=await i.json();if(e.detail&&e.detail.error)try{let l=JSON.parse(e.detail.error);l.type&&l.type===a.Bo?(0,n.C)("".concat(s," job ").concat(t," is not supported!"),"error",1e4):l.type&&l.type===a.mF?(0,n.C)("Cluster ".concat(r," does not exist."),"error"):l.type&&l.type===a.iW?(0,n.C)("Cluster ".concat(r," is not up."),"error"):(0,n.C)("".concat(s," job ").concat(t," failed: ").concat(l.type),"error")}catch(r){(0,n.C)("".concat(s," job ").concat(t," failed: ").concat(e.detail.error),"error")}else(0,n.C)("".concat(s," job ").concat(t," failed with no details."),"error")}catch(e){(0,n.C)("".concat(s," job ").concat(t," failed with parse error."),"error")}else(0,n.C)("".concat(s," job ").concat(t," failed with status ").concat(i.status,"."),"error")}catch(e){console.error("Fetch error:",e),(0,n.C)("Network error ".concat(s," job ").concat(t,": ").concat(e.message),"error")}}catch(e){console.error("Error in handleStop:",e),(0,n.C)("Critical error ".concat(s," job ").concat(t,": ").concat(e.message),"error")}}},5821:function(e,t,r){"use strict";function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,s=document.getElementById("toast-container");s||((s=document.createElement("div")).id="toast-container",s.className="fixed top-0 right-0 p-4 z-[9999] flex flex-col items-end space-y-2",document.body.appendChild(s));let n=document.createElement("div");switch(n.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":n.className+=" bg-green-100 border-green-500 text-green-800";break;case"error":n.className+=" bg-red-100 border-red-500 text-red-800";break;case"warning":n.className+=" bg-yellow-100 border-yellow-500 text-yellow-800";break;default:n.className+=" bg-blue-100 border-blue-500 text-blue-800"}return n.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    '),s.appendChild(n),n.querySelector("button").addEventListener("click",()=>{s.removeChild(n)}),setTimeout(()=>{s.contains(n)&&s.removeChild(n)},r),n}r.d(t,{C:function(){return s}})},8099:function(e,t,r){"use strict";r.r(t);var s=r(5893),n=r(7294),a=r(8799),l=r(1163),o=r(9470),c=r(7673),i=r(8969),d=r(1664),u=r.n(d),m=r(3626),f=r(5895),h=r(6639),g=r(6989),x=r(9307),p=r(3001),b=r(9008),j=r.n(b),y=r(1272);function N(e){let{jobData:t,activeTab:r,setIsLoadingLogs:l,setIsLoadingControllerLogs:o,isLoadingLogs:c,isLoadingControllerLogs:d,refreshFlag:m}=e,[p,b]=(0,n.useState)(""),[j,N]=(0,n.useState)(""),[v,w]=(0,n.useState)(!1),[E,C]=(0,n.useState)({}),[_,L]=(0,n.useState)(0),[S,T]=(0,n.useState)(0),[R,k]=(0,n.useState)(!1),[I,D]=(0,n.useState)(!1),[A,O]=(0,n.useState)(!1),[P,q]=(0,n.useState)(!1),J=(0,n.useRef)(null),F=(0,n.useRef)(null),Z=(0,n.useRef)(null),M=(0,n.useRef)(null),U=(0,n.useRef)(""),G=(0,n.useRef)(""),B=(0,n.useRef)(null);(0,n.useRef)(0);let H=(0,n.useCallback)(e=>{let t="logs"===e?Z:M;if(t.current)for(let r of[()=>t.current.querySelector(".logs-container"),()=>t.current.querySelector('[class*="logs-container"]'),()=>t.current.querySelector('div[style*="overflow"]'),()=>t.current]){let t=r();if(t&&t.scrollHeight>t.clientHeight){t.scrollTop=t.scrollHeight,console.log("Auto-scrolled ".concat(e," to bottom"));break}}},[]),W=["PENDING","SUBMITTED","STARTING"].includes(t.status),Y=["PENDING","SUBMITTED"].includes(t.status),z=["RECOVERING"].includes(t.status),$=e=>{C(t=>({...t,[e]:!t[e]}))},X=e=>{if(!e)return[];try{let t=[],r=e.split(/^---$/m);for(let e=0;e<r.length;e++){let s=r[e].trim();s&&""!==s&&t.push(s)}return(t.length>1?t.slice(1):t).map((e,t)=>{try{let r=y.ZP.load(e),s=y.ZP.dump(r,{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{index:t,content:n.join("\n").trim(),preview:V(r)}}catch(r){return console.error("YAML formatting error for document ".concat(t,":"),r),{index:t,content:e,preview:"Invalid YAML"}}})}catch(t){return console.error("YAML formatting error:",t),[{index:0,content:e,preview:"Invalid YAML"}]}},V=e=>"string"==typeof e?e.substring(0,50)+"...":e&&e.name?"name: ".concat(e.name):e&&e.resources?"Task configuration":"YAML document";(0,n.useEffect)(()=>{b(""),L(0),q(!1)},[r,t.id]),(0,n.useEffect)(()=>{N(""),T(0),q(!1)},[r,t.id]);let K=(0,n.useCallback)(function(e,t,r,s){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a="logs"===e?J:F;if(a.current)return console.log("Request already active for ".concat(e,", skipping...")),()=>{};let l=!0,o=new AbortController;return"logs"===e&&(W||z)?(s(!1),n&&k(!1),()=>{}):"controllerlogs"===e&&Y?(s(!1),n&&D(!1),()=>{}):t?(a.current=o,s(!0),O(!0),n&&(r(""),"logs"===e?L(0):T(0)),(0,i.NJ)({jobId:t,controller:"controllerlogs"===e,signal:o.signal,onNewLog:t=>{if(l){let r=(0,g.q8)(t);P||q(!0),Q(e,r),"logs"===e?L(e=>e+r.length):T(e=>e+r.length)}}}).then(()=>{l&&(s(!1),n&&("logs"===e?k(!1):D(!1)),requestAnimationFrame(()=>{H(e)}))}).catch(t=>{l&&("AbortError"!==t.name&&(console.error("Error streaming ".concat(e,":"),t),t.message&&r(e=>e+"Error fetching logs: ".concat(t.message,"\n"))),s(!1),n&&("logs"===e?k(!1):D(!1)))}).finally(()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===o&&(a.current.abort(),a.current=null),"logs"===e?U.current="":G.current="",B.current&&(clearTimeout(B.current),B.current=null)}),()=>{console.log("Cleaning up ".concat(e," request")),l=!1,a.current===o&&(a.current.abort(),a.current=null),"logs"===e?U.current="":G.current="",B.current&&(clearTimeout(B.current),B.current=null)}):()=>{l=!1}},[W,Y,z,P]);(0,n.useEffect)(()=>{if(J.current&&(J.current.abort(),J.current=null),!W&&!z)return K("logs",t.id,b,l)},[t.id,K,l,W,z]),(0,n.useEffect)(()=>{if(F.current&&(F.current.abort(),F.current=null),!Y)return K("controllerlogs",t.id,N,o)},[t.id,K,o,Y]),(0,n.useEffect)(()=>{if(m>0&&"logs"===r)return J.current&&(J.current.abort(),J.current=null),k(!0),K("logs",t.id,b,l,!0)},[m,r,t.id,K,l]),(0,n.useEffect)(()=>{if(m>0&&"controllerlogs"===r)return F.current&&(F.current.abort(),F.current=null),D(!0),K("controllerlogs",t.id,N,o,!0)},[m,r,t.id,K,o]),(0,n.useEffect)(()=>()=>{console.log("Cleaning up managed job log requests..."),J.current&&(J.current.abort(),J.current=null),F.current&&(F.current.abort(),F.current=null),B.current&&(clearTimeout(B.current),B.current=null),U.current="",G.current="",l(!1),o(!1),k(!1),D(!1)},[]),(0,n.useEffect)(()=>{let e=()=>{document.hidden?(console.log("Page hidden - pausing log streaming for performance"),B.current&&(clearTimeout(B.current),B.current=null)):console.log("Page visible - resuming normal operation")};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),(0,n.useEffect)(()=>{let e=()=>{("logs"===r&&p||"controllerlogs"===r&&j)&&H("logs"===r?"logs":"controllerlogs")};requestAnimationFrame(()=>{requestAnimationFrame(e)})},[r,p,j,H]);let Q=(0,n.useCallback)((e,t)=>{("logs"===e?b:N)(e=>e+t),requestAnimationFrame(()=>{H(e)})},[H]);return"logs"===r?(0,s.jsx)("div",{className:"max-h-96 overflow-y-auto",ref:Z,children:W?(0,s.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,s.jsx)("span",{children:"Waiting for the job to start, please refresh after a while"})}):z?(0,s.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,s.jsx)("span",{children:"Waiting for the job to recover, please refresh after a while"})}):P||p?(0,s.jsx)(g.$B,{logs:p}):c?(0,s.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,s.jsx)(a.Z,{size:20,className:"mr-2"}),(0,s.jsx)("span",{children:"Loading logs..."})]}):(0,s.jsx)(g.$B,{logs:p})}):"controllerlogs"===r?(0,s.jsx)("div",{className:"max-h-96 overflow-y-auto",ref:M,children:Y?(0,s.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,s.jsx)("span",{children:"Waiting for the job controller process to start, please refresh after a while"})}):P||j?(0,s.jsx)(g.$B,{logs:j,controller:!0}):d?(0,s.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,s.jsx)(a.Z,{size:20,className:"mr-2"}),(0,s.jsx)("span",{children:"Loading logs..."})]}):(0,s.jsx)(g.$B,{logs:j,controller:!0})}):(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job ID (Name)"}),(0,s.jsxs)("div",{className:"text-base mt-1",children:[t.id," ",t.name?"(".concat(t.name,")"):""]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,s.jsxs)("div",{className:"text-base mt-1 flex items-center",children:[(0,s.jsx)(x.OE,{status:t.status}),t.priority&&(0,s.jsxs)("span",{className:"ml-2",children:[" (priority: ",t.priority,")"]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,s.jsx)("div",{className:"text-base mt-1",children:t.user})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Requested Resources"}),(0,s.jsx)("div",{className:"text-base mt-1",children:t.requested_resources||"N/A"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Infra"}),(0,s.jsx)("div",{className:"text-base mt-1",children:t.infra?(0,s.jsx)(g.Md,{content:t.full_infra||t.infra,className:"text-sm text-muted-foreground",children:(0,s.jsxs)("span",{children:[(0,s.jsx)(u(),{href:"/infra",className:"text-blue-600 hover:underline",children:t.cloud||t.infra.split("(")[0].trim()}),t.infra.includes("(")&&(0,s.jsx)("span",{children:" "+t.infra.substring(t.infra.indexOf("("))})]})}):"-"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Resources"}),(0,s.jsx)("div",{className:"text-base mt-1",children:t.resources_str_full||t.resources_str||"-"})]}),(t.entrypoint||t.dag_yaml)&&(0,s.jsxs)("div",{className:"col-span-2",children:[(0,s.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Entrypoint"}),(0,s.jsxs)("div",{className:"space-y-4 mt-3",children:[t.entrypoint&&(0,s.jsx)("div",{children:(0,s.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3",children:(0,s.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all",children:t.entrypoint})})}),t.dag_yaml&&"{}"!==t.dag_yaml&&(0,s.jsxs)("div",{children:[(0,s.jsx)("button",{onClick:()=>{w(!v)},className:"flex items-center text-left focus:outline-none mb-2 text-gray-700 hover:text-gray-900 transition-colors duration-200",children:(0,s.jsxs)("div",{className:"flex items-center",children:[v?(0,s.jsx)(f.Z,{className:"w-4 h-4 mr-1"}):(0,s.jsx)(h.Z,{className:"w-4 h-4 mr-1"}),(0,s.jsx)("span",{className:"text-base",children:"Show SkyPilot YAML"})]})}),v&&(0,s.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-3 max-h-96 overflow-y-auto",children:(()=>{let e=X(t.dag_yaml);return 0===e.length?(0,s.jsx)("div",{className:"text-gray-500",children:"No YAML available"}):1===e.length?(0,s.jsx)("pre",{className:"text-sm text-gray-800 font-mono whitespace-pre-wrap",children:e[0].content}):(0,s.jsx)("div",{className:"space-y-4",children:e.map((e,t)=>(0,s.jsxs)("div",{className:"border-b border-gray-200 pb-4 last:border-b-0",children:[(0,s.jsx)("button",{onClick:()=>$(t),className:"flex items-center justify-between w-full text-left focus:outline-none",children:(0,s.jsxs)("div",{className:"flex items-center",children:[E[t]?(0,s.jsx)(f.Z,{className:"w-4 h-4 mr-2"}):(0,s.jsx)(h.Z,{className:"w-4 h-4 mr-2"}),(0,s.jsxs)("span",{className:"text-sm font-medium text-gray-700",children:["Task ",t+1,": ",e.preview]})]})}),E[t]&&(0,s.jsx)("div",{className:"mt-3 ml-6",children:(0,s.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:r,tab:d}=t.query,[f,h]=(0,n.useState)(0),{jobData:x,loading:b}=(0,i.Pr)(f),[y,v]=(0,n.useState)(!1),[w,E]=(0,n.useState)(!0),[C,_]=(0,n.useState)(!1),[L,S]=(0,n.useState)(!1),[T,R]=(0,n.useState)(!1),[k,I]=(0,n.useState)(!1),[D,A]=(0,n.useState)(!1),[O,P]=(0,n.useState)(0),[q,J]=(0,n.useState)(0),F=(0,p.X)();n.useEffect(()=>{!b&&w&&E(!1)},[b,w]);let Z=e=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth"})};(0,n.useEffect)(()=>{I(!0)},[]),(0,n.useEffect)(()=>{if(!D){let e=new MutationObserver(()=>{let t=document.getElementById("logs-section"),r=document.getElementById("controller-logs-section");("logs"===d&&t||"controllerlogs"===d&&r)&&(A(!0),e.disconnect())});return e.observe(document.body,{childList:!0,subtree:!0}),()=>e.disconnect()}},[D,d]),(0,n.useEffect)(()=>{if(t.isReady&&k&&D&&!T){let e=setTimeout(()=>{"logs"===d?(Z("logs-section"),R(!0)):"controllerlogs"===d&&(Z("controller-logs-section"),R(!0))},800);return()=>clearTimeout(e)}},[t.isReady,d,T,k,D]),(0,n.useEffect)(()=>{R(!1),A(!1)},[d]);let M=async()=>{v(!0);try{h(e=>e+1),P(e=>e+1),J(e=>e+1)}catch(e){console.error("Error refreshing data:",e)}finally{v(!1)}};if(!t.isReady)return(0,s.jsx)("div",{children:"Loading..."});let U=null==x?void 0:null===(e=x.jobs)||void 0===e?void 0:e.find(e=>String(e.id)===String(r)),G=r?"Job: ".concat(r," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j(),{children:(0,s.jsx)("title",{children:G})}),(0,s.jsxs)(o.A,{highlighted:"managed-jobs",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"text-base flex items-center",children:[(0,s.jsx)(u(),{href:"/jobs",className:"text-sky-blue hover:underline",children:"Managed Jobs"}),(0,s.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,s.jsxs)(u(),{href:"/jobs/".concat(r),className:"text-sky-blue hover:underline",children:[r," ",(null==U?void 0:U.name)?"(".concat(U.name,")"):""]})]}),(0,s.jsxs)("div",{className:"text-sm flex items-center",children:[(b||y||C||L)&&(0,s.jsxs)("div",{className:"flex items-center mr-4",children:[(0,s.jsx)(a.Z,{size:15,className:"mt-0"}),(0,s.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,s.jsx)(g.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,s.jsxs)("button",{onClick:M,disabled:b||y,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,s.jsx)(m.Z,{className:"w-4 h-4 mr-1.5"}),!F&&(0,s.jsx)("span",{children:"Refresh"})]})})]})]}),b&&w?(0,s.jsxs)("div",{className:"flex items-center justify-center py-32",children:[(0,s.jsx)(a.Z,{size:20,className:"mr-2"}),(0,s.jsx)("span",{children:"Loading..."})]}):U?(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)("div",{id:"details-section",children:(0,s.jsxs)(c.Zb,{children:[(0,s.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,s.jsx)("h3",{className:"text-lg font-semibold",children:"Details"})}),(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(N,{jobData:U,activeTab:"info",setIsLoadingLogs:_,setIsLoadingControllerLogs:S,isLoadingLogs:C,isLoadingControllerLogs:L,refreshFlag:0})})]})}),(0,s.jsx)("div",{id:"logs-section",className:"mt-6",children:(0,s.jsxs)(c.Zb,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold",children:"Logs"}),(0,s.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,s.jsx)(g.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,s.jsx)("button",{onClick:()=>{P(e=>e+1)},disabled:C,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,s.jsx)(m.Z,{className:"w-4 h-4 ".concat(C?"animate-spin":"")})})})]}),(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(N,{jobData:U,activeTab:"logs",setIsLoadingLogs:_,setIsLoadingControllerLogs:S,isLoadingLogs:C,isLoadingControllerLogs:L,refreshFlag:O})})]})}),(0,s.jsx)("div",{id:"controller-logs-section",className:"mt-6",children:(0,s.jsxs)(c.Zb,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold",children:"Controller Logs"}),(0,s.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,s.jsx)(g.WH,{content:"Refresh controller logs",className:"text-muted-foreground",children:(0,s.jsx)("button",{onClick:()=>{J(e=>e+1)},disabled:L,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,s.jsx)(m.Z,{className:"w-4 h-4 ".concat(L?"animate-spin":"")})})})]}),(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(N,{jobData:U,activeTab:"controllerlogs",setIsLoadingLogs:_,setIsLoadingControllerLogs:S,isLoadingLogs:C,isLoadingControllerLogs:L,refreshFlag:q})})]})})]}):(0,s.jsx)("div",{className:"flex items-center justify-center py-32",children:(0,s.jsx)("span",{children:"Job not found"})})]})]})}}},function(e){e.O(0,[614,798,470,888,774,179],function(){return e(e.s=479)}),_N_E=e.O()}]);