"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[3165],{3165:(B,d,s)=>{s.r(d),s.d(d,{QrscannerPageModule:()=>L});var m=s(6019),v=s(9133),r=s(4599),c=s(8699),a=s(7582);const l=(0,s(1278).fo)("BarcodeScanner",{web:()=>s.e(7843).then(s.bind(s,7843)).then(e=>new e.BarcodeScannerWeb)});var R=s(2227),t=s(3668),u=s(6875),g=s(4501),A=s(8410),f=s(6636),O=s(4987),P=s(3321);const E=[{path:"",component:(()=>{class e{constructor(n,i,C,p,I,Z,G,y,Q,U){this.translate=n,this.modalCtrl=i,this.us=C,this.alertCtrl=p,this.notificationService=I,this.authService=Z,this.siteService=G,this.ws=y,this.router=Q,this.userService=U,this.startScan=()=>(0,a.mG)(this,void 0,void 0,function*(){document.documentElement.style.setProperty("--ion-background-color","transparent"),l.hideBackground();const h=yield l.startScan();h.hasContent&&(document.documentElement.style.setProperty("--ion-background-color","var(--lightbackground-color)"),/^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i.test(h.content)?this.handleResult(atob(h.content)):(this.notificationService.showError("NOBASE64"),this.restartAlert()))})}ngOnInit(){this.getTranslations().then(()=>{this.us.activeUser?this.alertCtrl.create({header:this.translations.NOTPOSSIBLE,message:this.translations.ALREADYLOGIN,buttons:[{text:this.translations.LOGIN,handler:()=>{this.router.navigate(["/home"])}}]}).then(n=>{n.present()}):this.checkPermission()})}getTranslations(){return(0,a.mG)(this,void 0,void 0,function*(){this.translations=yield this.translate.get(["NOTPOSSIBLE","ALREADYLOGIN","CANCEL","LOGOUT","OK","CAMERAREQUIRED","LOGIN","TOLOGIN","OPENSETTINGS","ERROR","SCANAGAIN","SCANRESTART","QREXPIRED"]).toPromise()})}ionViewWillEnter(){this.siteService.showMenu=!1}ionViewWillLeave(){this.code="",this.scannedUserSite="",this.serverURL="",this.qrmodal&&this.qrmodal.dismiss(),document.documentElement.style.setProperty("--ion-background-color","var(--lightbackground-color)"),this.siteService.showMenu=!0}checkPermission(){return(0,a.mG)(this,void 0,void 0,function*(){return l.prepare(),(yield l.checkPermission({force:!0})).granted?(this.startScan(),!0):(this.alertCtrl.create({header:this.translations.NOTPOSSIBLE,message:this.translations.CAMERAREQUIRED,buttons:[{text:this.translations.TOLOGIN,handler:()=>{this.router.navigate(["/login"])}},{text:this.translations.OPENSETTINGS,handler:()=>{l.openAppSettings()}}]}).then(i=>{i.present()}),!1)})}handleResult(n){return(0,a.mG)(this,void 0,void 0,function*(){let i;i=n.split(";"),this.serverURL=i[0],this.token=i[1],this.code=i[2],yield this.siteService.setSiteURL(this.serverURL),this.handleQRLogin()})}handleQRLogin(){this.ws.getCoreInfoScanned(this.token,this.serverURL).subscribe(n=>(0,a.mG)(this,void 0,void 0,function*(){"invalidtoken"===n.errorcode?this.alertCtrl.create({header:this.translations.ERROR,message:this.translations.QREXPIRED,buttons:[{text:this.translations.TOLOGIN,handler:()=>{this.router.navigate(["/login"])}}]}).then(i=>{i.present()}):(this.scannedUserSite=n,this.qrmodal=yield this.modalCtrl.create({component:R.H,cssClass:"qrresult",showBackdrop:!1,componentProps:{code:this.code,token:this.token,serverurl:this.serverURL,scannedUserSite:this.scannedUserSite}}),this.qrmodal.present())}))}restartAlert(){this.alertCtrl.create({header:this.translations.ERROR,message:this.translations.SCANRESTART,buttons:[{text:this.translations.TOLOGIN,handler:()=>{this.router.navigate(["/login"])}},{text:this.translations.SCANAGAIN,handler:()=>{this.startScan()}}]}).then(n=>{n.present()})}}return e.\u0275fac=function(n){return new(n||e)(t.Y36(u.sK),t.Y36(r.IN),t.Y36(g.K),t.Y36(r.Br),t.Y36(A.g),t.Y36(f.e),t.Y36(O.P),t.Y36(P.N),t.Y36(c.F0),t.Y36(g.K))},e.\u0275cmp=t.Xpm({type:e,selectors:[["app-qrscanner"]],decls:12,vars:3,consts:[["slot","start"],["defaultHref","/login"],["size","10","size-md","6"],["src","assets/images/camera.png"]],template:function(n,i){1&n&&(t.TgZ(0,"ion-header"),t.TgZ(1,"ion-toolbar"),t.TgZ(2,"ion-buttons",0),t._UZ(3,"ion-back-button",1),t.qZA(),t.TgZ(4,"ion-title"),t._uU(5),t.ALo(6,"translate"),t.qZA(),t.qZA(),t.qZA(),t.TgZ(7,"ion-content"),t.TgZ(8,"ion-grid"),t.TgZ(9,"ion-row"),t.TgZ(10,"ion-col",2),t._UZ(11,"ion-img",3),t.qZA(),t.qZA(),t.qZA(),t.qZA()),2&n&&(t.xp6(5),t.Oqu(t.lcZ(6,1,"SCANTOLOGIN")))},directives:[r.Gu,r.sr,r.Sm,r.oU,r.cs,r.wd,r.W2,r.jY,r.Nd,r.wI,r.Xz],pipes:[u.X$],styles:["ion-col[_ngcontent-%COMP%]{margin:0 auto}ion-grid[_ngcontent-%COMP%]{height:100%}ion-row[_ngcontent-%COMP%]{height:100%;align-items:center}"]}),e})()}];let N=(()=>{class e{}return e.\u0275fac=function(n){return new(n||e)},e.\u0275mod=t.oAB({type:e}),e.\u0275inj=t.cJS({imports:[[c.Bz.forChild(E)],c.Bz]}),e})();var T=s(1382);let L=(()=>{class e{}return e.\u0275fac=function(n){return new(n||e)},e.\u0275mod=t.oAB({type:e}),e.\u0275inj=t.cJS({imports:[[T.m,m.ez,v.u5,r.Pc,N]]}),e})()}}]);