import{u as i}from"./common-8ef9a0d2.js";import{o as s,k as a}from"./index-733aa71a.js";const n={id:"term",style:{"background-color":"#1e1e1e",padding:"16px","border-radius":"8px","overflow-y":"auto"}},h={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:i().getLogCache(),historyNum_:-1}},props:{historyNum:{type:String,default:-1}},watch:{logCache:{handler(o){this.printLog(o[this.logCache.length-1])},deep:!0}},mounted(){this.historyNum_=parseInt(this.historyNum);let o=0;for(let t of this.logCache)this.historyNum_!=-1&&o>=this.logCache.length-this.historyNum_?(this.printLog(t),++o):this.historyNum_==-1&&this.printLog(t)},methods:{toggleAutoScroll(){this.autoScroll=!this.autoScroll},printLog(o){let t=document.getElementById("term"),e=document.createElement("pre"),r=this.logColorAnsiMap.default;for(let l in this.logColorAnsiMap)if(o.startsWith(l)){r=this.logColorAnsiMap[l],o=o.replace(l,"").replace("\x1B[0m","");break}e.style=r+"display: block; font-size: 12px; font-family: Consolas, monospace; white-space: pre-wrap;",e.classList.add("fade-in"),e.innerText=o,t.appendChild(e),this.autoScroll&&(t.scrollTop=t.scrollHeight)}}},p=Object.assign(h,{setup(o){return(t,e)=>(s(),a("div",n))}});export{p as _};
