"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[223],{2223:(F,g,s)=>{s.r(g),s.d(g,{LogsModule:()=>Z});var h=s(6895),m=s(8304),c=s(4463),u=s(7750),p=s(5861),v=s(4327),$=s(7579),d=s(1862),t=s(4650),L=s(2503),y=s(9274),b=s(6726),C=s(7185);const w=["logoutput"],x=[{path:"",component:(()=>{class e{constructor(n,o,a,l,r,f){this.$settings=n,this.$api=o,this.$log=a,this.$toastr=l,this.$translate=r,this.$modal=f,this.resizeEvent=new $.x}onWindowResize(){this.resizeEvent.next(void 0)}ngOnInit(){window.document.querySelector("body").classList.add("bg-black"),this.$log.startTerminal(this.termTarget,{},this.resizeEvent)}ngOnDestroy(){window.document.querySelector("body").classList.remove("bg-black"),this.$log.destroyTerminal()}downloadLogFile(){var n=this;const o=this.$modal.open(d.X);o.componentInstance.title=this.$translate.instant("logs.title_download_log_file"),o.componentInstance.message=this.$translate.instant("logs.message_download_warning"),o.componentInstance.confirmButtonLabel=this.$translate.instant("logs.label_download"),o.componentInstance.faIconClass="fas fa-fw fa-user-secret primary-text",o.result.then(()=>{this.$api.get("/platform-tools/hb-service/log/download",{observe:"response",responseType:"blob"}).subscribe(a=>{(0,v.saveAs)(a.body,"homebridge.log.txt")},function(){var a=(0,p.Z)(function*(l){let r;try{r=JSON.parse(yield l.error.text()).message}catch{}n.$toastr.error(r||"Failed to download log file",n.$translate.instant("toast.title_error"))});return function(l){return a.apply(this,arguments)}}())}).catch(()=>{})}truncateLogFile(){const n=this.$modal.open(d.X);n.componentInstance.title=this.$translate.instant("logs.title_truncate_log_file"),n.componentInstance.message=this.$translate.instant("logs.message_truncate_log_warning"),n.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_delete"),n.componentInstance.faIconClass="fas fa-fw fa-circle-exclamation primary-text",n.result.then(()=>{this.$api.put("/platform-tools/hb-service/log/truncate",{}).subscribe(()=>{this.$toastr.success(this.$translate.instant("logs.message_log_file_truncated"),this.$translate.instant("toast.title_success")),this.$log.term.clear()},o=>{this.$toastr.error(o.error.message||"Failed to truncate log file",this.$translate.instant("toast.title_error"))})}).catch(()=>{})}}return e.\u0275fac=function(n){return new(n||e)(t.Y36(L.g),t.Y36(y.s),t.Y36(b.$),t.Y36(C._W),t.Y36(c.sK),t.Y36(m.FF))},e.\u0275cmp=t.Xpm({type:e,selectors:[["app-logs"]],viewQuery:function(n,o){if(1&n&&t.Gf(w,7),2&n){let a;t.iGM(a=t.CRH())&&(o.termTarget=a.first)}},hostBindings:function(n,o){1&n&&t.NdJ("resize",function(l){return o.onWindowResize(l)},!1,t.Jf7)},decls:13,vars:3,consts:[[1,"row","mb-3"],[1,"col-6"],[1,"primary-text","m-0"],[1,"col-6","text-right"],[1,"btn","btn-elegant","my-0",3,"click"],[1,"fas","fa-fw","fa-download"],[1,"btn","btn-elegant","my-0","mr-0",3,"click"],[1,"fas","fa-fw","fa-trash-alt"],[1,"flex-column","d-flex","align-items-stretch",2,"height","calc(100% - 52px)"],["id","log-output",1,"terminal","align-self-end","w-100","h-100","mb-1"],["logoutput",""]],template:function(n,o){1&n&&(t.TgZ(0,"div",0)(1,"div",1)(2,"h3",2),t._uU(3),t.ALo(4,"translate"),t.qZA()(),t.TgZ(5,"div",3)(6,"button",4),t.NdJ("click",function(){return o.downloadLogFile()}),t._UZ(7,"i",5),t.qZA(),t.TgZ(8,"button",6),t.NdJ("click",function(){return o.truncateLogFile()}),t._UZ(9,"i",7),t.qZA()()(),t.TgZ(10,"div",8),t._UZ(11,"div",9,10),t.qZA()),2&n&&(t.xp6(3),t.Oqu(t.lcZ(4,1,"menu.linux.label_logs")))},dependencies:[c.X$]}),e})()}];let T=(()=>{class e{}return e.\u0275fac=function(n){return new(n||e)},e.\u0275mod=t.oAB({type:e}),e.\u0275inj=t.cJS({imports:[u.Bz.forChild(x),u.Bz]}),e})(),Z=(()=>{class e{}return e.\u0275fac=function(n){return new(n||e)},e.\u0275mod=t.oAB({type:e}),e.\u0275inj=t.cJS({imports:[h.ez,T,m.IJ,c.aw.forChild()]}),e})()}}]);