import{C as B}from"./Container-D40_MO5w.js";import{f as w,_ as U}from"./index-CyXUjyDM.js";import{p as $,a4 as E,C as S,m as C,e as j,q as N,k as R,d as z,r as D,a as H}from"./vuetify-DHCm6MV9.js";import{d as O,w as q,o as A,r as n,a as F,D as M,E as s,H as a,f as u,$ as y,a1 as r,b as g,I as x,c as V,j as P,e as m}from"./lucide-BsOfcLnq.js";import"./index-kQIztB-E.js";import"./qrcode-DcFvg0BH.js";import"./marked-i_gIkIP3.js";import"./color-BTziYnFN.js";import"./vue-router-hLkI791z.js";import"./vue-i18n-CXdnqGsF.js";import"./vueuse-CmMrRm2c.js";/* empty css            */import"./swiper-BIRaDS2w.js";const G={class:"d-flex flex-column flex-sm-row align-start align-sm-center ga-2 w-100"},J={class:"d-flex flex-wrap ga-2"},K={key:0,class:"pa-8 text-center"},Q={class:"mt-4"},W={key:1,class:"pa-8 text-center"},X={class:"text-error"},Y={key:2,class:"pa-4 text-center"},Z={class:"log-content"},_=150,ee=O({__name:"ServerLogs",setup(te){const i=n(""),p=n(!0),h=n(!1),c=n(""),v=n(!0),d=n(null);let l=null;const k=V(()=>{const e=i.value.split(`
`);return e.length>_?e.slice(-_).join(`
`):i.value}),b=V(()=>i.value.split(`
`).length>_),L=()=>{d.value&&P(()=>{d.value&&(d.value.scrollTop=d.value.scrollHeight)})},f=async(e=!1)=>{try{e?h.value=!0:p.value=!0,c.value="";const t=await w.sendCommand("logging/get"),o=i.value;i.value=t,(!e||t!==o)&&setTimeout(()=>L(),100)}catch(t){c.value=t.message||"Failed to load server logs",console.error("Error loading logs:",t)}finally{p.value=!1,h.value=!1}},I=()=>{f(!0)},T=async()=>{try{const e=await w.sendCommand("logging/get"),t=window.URL.createObjectURL(new Blob([e],{type:"text/plain"})),o=document.createElement("a");o.href=t,o.download="music-assistant.log",document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(t)}catch(e){console.error("Error downloading log:",e)}};return q(v,e=>{e?l=setInterval(()=>{f(!0)},5e3):l&&(clearInterval(l),l=null)}),A(async()=>{await f(!1),v.value&&(l=setInterval(()=>{f(!0)},5e3))}),F(()=>{l&&clearInterval(l)}),(e,t)=>(m(),M(B,null,{default:s(()=>[a(H,{class:"mb-4",elevation:"0",variant:"flat"},{default:s(()=>[a($,{class:"text-subtitle-1 font-weight-bold py-3"},{default:s(()=>[u("div",G,[a(E,{modelValue:v.value,"onUpdate:modelValue":t[0]||(t[0]=o=>v.value=o),color:"primary",density:"compact","hide-details":"",label:e.$t("settings.auto_refresh_log")},null,8,["modelValue","label"]),a(S,{class:"d-none d-sm-block"}),u("div",J,[a(C,{color:"primary",variant:"text",loading:h.value,"prepend-icon":"mdi-refresh",size:"small",onClick:I},{default:s(()=>[y(r(e.$t("settings.reload")),1)]),_:1},8,["loading"]),a(C,{color:"primary",variant:"elevated","prepend-icon":"mdi-download",size:"small",onClick:T},{default:s(()=>[y(r(e.$t("settings.download_log")),1)]),_:1})])])]),_:1}),a(j),a(N,{class:"pa-0"},{default:s(()=>[p.value?(m(),g("div",K,[a(R,{indeterminate:"",color:"primary"}),u("div",Q,r(e.$t("loading")),1)])):c.value?(m(),g("div",W,[a(z,{icon:"mdi-alert-circle",color:"error",size:"48",class:"mb-4"}),u("div",X,r(c.value),1)])):b.value?(m(),g("div",Y,[a(D,{type:"info",variant:"tonal"},{default:s(()=>[y(r(e.$t("settings.log_truncated",[_])),1)]),_:1})])):x("",!0),!p.value&&!c.value?(m(),g("div",{key:3,ref_key:"logContainer",ref:d,class:"log-container"},[u("pre",Z,r(k.value),1)],512)):x("",!0)]),_:1})]),_:1})]),_:1}))}}),fe=U(ee,[["__scopeId","data-v-a0b3fa15"]]);export{fe as default};
