import{u as c}from"./common-a3b3ada7.js";import{_ as h}from"./_plugin-vue_export-helper-c27b6911.js";import{o as i,m as r,q as n,b as d,w as a,F as u,p,ay as m,c as g,V as f,e as y,t as _,a5 as C,a6 as F}from"./index-809c946b.js";const L=e=>(C("data-v-2c912926"),e=e(),F(),e),v={class:"filter-controls mb-2"},b=L(()=>n("div",{id:"term",style:{"background-color":"#1e1e1e",padding:"16px","border-radius":"8px","overflow-y":"auto",height:"100%"}},null,-1)),I={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:c().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}},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 s in this.logColorAnsiMap)if(e.startsWith(s)){o=this.logColorAnsiMap[s],e=e.replace(s,"").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)}}},N=Object.assign(I,{setup(e){return(t,l)=>(i(),r("div",null,[n("div",v,[d(m,{modelValue:t.selectedLevels,"onUpdate:modelValue":l[0]||(l[0]=o=>t.selectedLevels=o),column:"",multiple:""},{default:a(()=>[(i(!0),r(u,null,p(t.logLevels,o=>(i(),g(f,{key:o,color:t.getLevelColor(o),filter:"","text-color":o==="DEBUG"||o==="INFO"?"black":"white"},{default:a(()=>[y(_(o),1)]),_:2},1032,["color","text-color"]))),128))]),_:1},8,["modelValue"])]),b]))}}),R=h(N,[["__scopeId","data-v-2c912926"]]);export{R as C};
