import{u as n}from"./common-a2e6f630.js";import{_ as h}from"./_plugin-vue_export-helper-c27b6911.js";import{o as s,k as r,b as c,w as a,F as d,n as u,c as p,d as m,t as g,V as f,aA as y,f as C,ay as _,az as F,l as L}from"./index-e345ed95.js";const v=e=>(_("data-v-e54521ce"),e=e(),F(),e),b={key:0,class:"filter-controls mb-2"},I=v(()=>L("div",{id:"term",style:{"background-color":"#1e1e1e",padding:"16px","border-radius":"8px","overflow-y":"auto",height:"100%"}},null,-1)),N={name:"ConsoleDisplayer",data(){return{autoScroll:!0,logColorAnsiMap:{"\x1B[1;34m":"color: #0000FF; font-weight: bold;","\x1B[1;36m":"color: #00FFFF; font-weight: bold;","\x1B[1;33m":"color: #FFFF00; font-weight: bold;","\x1B[31m":"color: #FF0000;","\x1B[1;31m":"color: #FF0000; font-weight: bold;","\x1B[0m":"color: inherit; font-weight: normal;","\x1B[32m":"color: #00FF00;",default:"color: #FFFFFF;"},logCache:n().getLogCache(),historyNum_:-1,logLevels:["DEBUG","INFO","WARNING","ERROR","CRITICAL"],selectedLevels:[0,1,2,3,4],levelColors:{DEBUG:"grey",INFO:"blue-lighten-3",WARNING:"amber",ERROR:"red",CRITICAL:"purple"}}},props:{historyNum:{type:String,default:"-1"},showLevelBtns:{type:Boolean,default:!0}},watch:{logCache:{handler(e){const t=e[this.logCache.length-1];t&&this.isLevelSelected(t.level)&&this.printLog(t.data)},deep:!0},selectedLevels:{handler(){this.refreshDisplay()},deep:!0}},mounted(){this.logCache.length===0?this.delayInit():this.init()},methods:{getLevelColor(e){return this.levelColors[e]||"grey"},isLevelSelected(e){for(let t=0;t<this.selectedLevels.length;++t)if(this.logLevels[this.selectedLevels[t]]===e)return!0;return!1},refreshDisplay(){const e=document.getElementById("term");e&&(e.innerHTML=""),this.init()},delayInit(){this.logCache.length===0?setTimeout(()=>{this.delayInit()},500):this.init()},init(){this.historyNum_=parseInt(this.historyNum);let e=0;for(let t of this.logCache)this.isLevelSelected(t.level)&&(this.historyNum_!=-1&&e>=this.logCache.length-this.historyNum_?(this.printLog(t.data),++e):this.historyNum_==-1&&this.printLog(t.data))},toggleAutoScroll(){this.autoScroll=!this.autoScroll},printLog(e){let t=document.getElementById("term"),l=document.createElement("pre"),o=this.logColorAnsiMap.default;for(let i in this.logColorAnsiMap)if(e.startsWith(i)){o=this.logColorAnsiMap[i],e=e.replace(i,"").replace("\x1B[0m","");break}l.style=o+"display: block; font-size: 12px; font-family: Consolas, monospace; white-space: pre-wrap;",l.classList.add("fade-in"),l.innerText=`${e}`,t.appendChild(l),this.autoScroll&&(t.scrollTop=t.scrollHeight)}}},w=Object.assign(N,{setup(e){return(t,l)=>(s(),r("div",null,[e.showLevelBtns?(s(),r("div",b,[c(y,{modelValue:t.selectedLevels,"onUpdate:modelValue":l[0]||(l[0]=o=>t.selectedLevels=o),column:"",multiple:""},{default:a(()=>[(s(!0),r(d,null,u(t.logLevels,o=>(s(),p(f,{key:o,color:t.getLevelColor(o),filter:"","text-color":o==="DEBUG"||o==="INFO"?"black":"white"},{default:a(()=>[m(g(o),1)]),_:2},1032,["color","text-color"]))),128))]),_:1},8,["modelValue"])])):C("",!0),I]))}}),A=h(w,[["__scopeId","data-v-e54521ce"]]);export{A as C};
