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