import{_ as e,i as l,h as a,ag as t,c as n,g as r,e as s,a as o,n as u,F as i,q as c,d as v,v as d,t as g,b as p,s as m,f as h,aj as x,o as f,p as y,N as w,af as b}from"./index-5CctA6VU.js";import{u as j}from"./experiment-BWsAMZL-.js";import{_ as k}from"./SLLoading-CnnPDveI.js";import{F as S}from"./FuncBar-CGKNjWmP.js";const _={class:"w-full h-full px-7 py-6 relative overflow-hidden"},q={key:0},T={key:1,class:"text-negative-default"},H={key:0,class:"w-full py-10 flex justify-center items-center gap-2 font-semibold"},L={class:"text-base"},C={key:1,class:"flex h-full items-center justify-center"},F=e({__name:"LogPage",setup(e){const F=j().id,N=m(),$=h(()=>{var e;const l=null==(e=N.value)?void 0:e.map((e,l)=>{const a=e,t=""!==E.value&&a.toLowerCase().includes(E.value);return{isTarget:t,index:l+1,value:t?z(a,E.value):a}}),a=M(l);return B.value.map((e,t)=>l.push({index:a+t+1,value:e,error:!0})),l}),I=h(()=>{var e;let l=1;const a=null==(e=$.value)?void 0:e.length;return a&&(l=""===$.value[a-1].index?$.value[a-2].index:$.value[a-1].index),l?8*l.length+"px":"0px"}),M=e=>{const l=null==e?void 0:e.reduce((e,l)=>l.index&&Number(l.index)>Number(e)?l.index:e,0);return Number(l)},P=h(()=>{var e;return(null==(e=N.value)?void 0:e.join("\n"))+B.value.join("\n")}),z=(e,l)=>{let a=e.split(new RegExp(`(${l})`,"i"));return a=a.filter(e=>""!==e),a},B=m([]),E=m(""),R=e=>{E.value=e.toLowerCase()},V=m([0,0]),A=m(16),D=h(()=>{var e;return(null==(e=$.value)?void 0:e.length)*A.value}),G=x(e=>{const l=e.target;J(l)},100),J=e=>{const l=A.value,a=Math.ceil(e.clientHeight/l),t=Math.floor(e.scrollTop/l),n=t+a;e.scrollTop<=30*l?V.value[0]=0:V.value[0]=t-30,e.scrollTop+e.clientHeight>=e.scrollHeight-30*l?V.value[1]=$.value.length-1:V.value[1]=n+30},K=h(()=>V.value[0]*A.value);return l(async()=>{const{data:e}=await a.get(`/experiment/${F}/recent_log`).catch(e=>{3404===e.data.code&&(N.value=[])});N.value=e.logs||[],e.error&&(B.value=e.error),t(()=>{J(document.querySelector(".log-container")),(()=>{const e=document.querySelector(".log-line");if(!e)return 0;const l=window.getComputedStyle(e);A.value=parseFloat(l.getPropertyValue("line-height"))})(),document.querySelector(".log-container").scrollHeight>document.querySelector(".log-container").clientHeight&&(document.querySelector(".log-container").scrollTop=document.querySelector(".log-container").scrollHeight)})}),(e,l)=>{const a=d;return f(),n("div",_,[N.value?(f(),r(S,{key:0,class:"pb-6",onInput:R,content:P.value,placeholder:e.$t("experiment.func-bar.placeholder.log"),filename:"print.log"},null,8,["content","placeholder"])):s("",!0),o("section",{class:"log-container",onScroll:l[0]||(l[0]=(...e)=>p(G)&&p(G)(...e))},[N.value?(f(),n("div",{key:0,class:"log-area",style:u({height:D.value+"px"})},[o("div",{class:"log-board",style:u({top:K.value+"px"})},[(f(!0),n(i,null,c($.value.slice(V.value[0],V.value[1]+1),(e,l)=>(f(),n("div",{class:"log-line",key:e.value+V.value[0]+l},[o("span",{class:y(["w-8 text-right flex-shrink-0 text-dimmest select-none",{"text-negative-default":e.error}]),style:u({width:I.value})},g(e.index),7),e.error?(f(),n("div",T,g(e.value),1)):(f(),n("div",q,[w(o("span",null,g(e.value),513),[[b,!e.isTarget]]),w(o("span",null,[(f(!0),n(i,null,c(e.value,e=>(f(),n("span",{key:e,class:y({"bg-warning-dimmest":e.toLowerCase()===E.value})},g(e),3))),128))],512),[[b,e.isTarget]])]))]))),128))],4),0===N.value.length&&0===B.value.length?(f(),n("div",H,[v(a,{class:"size-5",icon:"search"}),o("span",L,g(e.$t("experiment.empty_log")),1)])):s("",!0)],4)):(f(),n("div",C,[v(k)]))],32)])}}},[["__scopeId","data-v-0942f820"]]);export{F as default};
