import{_ as e,i as l,c as a,j as t,h as n,ag as r,a as o,g as s,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 k}from"./index-Co2lzP8_.js";import{u as b}from"./experiment-Cr-ZeruY.js";import{_ as S}from"./SLLoading-CnT10KtK.js";import{F as j}from"./FuncBar-BLEi3Zu1.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 flex-col items-center text-lg font-semibold"},L={key:1,class:"flex h-full items-center justify-center"},C=e({__name:"LogPage",setup(e){const C=b().id,F=l(),N=a((()=>{var e;const l=null==(e=F.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?P(a,B.value):a}})),a=I(l);return A.value.map(((e,t)=>l.push({index:a+t+1,value:e,error:!0}))),l})),$=a((()=>{var e;let l=1;const a=null==(e=N.value)?void 0:e.length;return a&&(l=""===N.value[a-1].index?N.value[a-2].index:N.value[a-1].index),l?8*l.length+"px":"0px"})),I=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)},M=a((()=>{var e;return(null==(e=F.value)?void 0:e.join("\n"))+A.value.join("\n")})),P=(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),z=a((()=>{var e;return(null==(e=N.value)?void 0:e.length)*V.value})),D=w((e=>{const l=e.target;G(l)}),100),G=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]=N.value.length-1:R.value[1]=n+30},J=a((()=>R.value[0]*V.value));return t((async()=>{const{data:e}=await n.get(`/experiment/${C}/recent_log`).catch((e=>{3404===e.data.code&&(F.value=[])}));F.value=e.logs||[],e.error&&(A.value=e.error),r((()=>{G(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=k;return h(),o("div",_,[F.value?(h(),s(j,{key:0,class:"pb-6",onInput:E,content:M.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(D)&&m(D)(...e))},[F.value?(h(),o("div",{key:0,class:"log-area",style:c({height:z.value+"px"})},[i("div",{class:"log-board",style:c({top:J.value+"px"})},[(h(!0),o(v,null,d(N.value.slice(R.value[0],R.value[1]+1),((e,l)=>(h(),o("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:$.value})},p(e.index),7),e.error?(h(),o("div",T,p(e.value),1)):(h(),o("div",q,[f(i("span",null,p(e.value),513),[[y,!e.isTarget]]),f(i("span",null,[(h(!0),o(v,null,d(e.value,(e=>(h(),o("span",{key:e,class:x({"bg-warning-dimmest":e.toLowerCase()===B.value})},p(e),3)))),128))],512),[[y,e.isTarget]])]))])))),128))],4),0===F.value.length&&0===A.value.length?(h(),o("div",H,[g(a,{class:"magnifier",icon:"search"}),i("span",null,p(e.$t("experiment.empty_log")),1)])):u("",!0)],4)):(h(),o("div",L,[g(S)]))],32)])}}},[["__scopeId","data-v-dc47f543"]]);export{C as default};
