import{a as I}from"./chunk-K6FNA4WM.js";import{d as g}from"./chunk-Y5QSZXVS.js";import{$b as R,$f as A,Bf as j,Kc as p,Nf as C,O as T,Of as N,Tf as u,U as n,X as r,ad as c,bf as m,cf as e,dg as U,n as D,o as S,og as b,r as E,t as y,ug as f}from"./chunk-PAINK2EC.js";var w=(()=>{class o{canDeactivate(t){return t.canNavigateBack()}static{this.\u0275fac=function(i){return new(i||o)}}static{this.\u0275prov=n({token:o,factory:o.\u0275fac})}}return o})();var v=(()=>{class o{constructor(t,i,a,s,h,l){this.restService=t,this.router=i,this.translateService=a,this.toastMessageService=s,this.matDialog=h,this.loadingService=l}closeOpenDialogsAndNavigateToLogin(t){return this.closeOpenDialogs(),this.navigateToLoginAndLogout(t)}closeOpenDialogs(){e.isNullOrUndefined(this.matDialog.openDialogs)||this.matDialog.openDialogs.length===0||this.matDialog.openDialogs.forEach(t=>{t.close()})}logout(){return u.hasValidAuthCredentials()?this.restService.delete(p.LOGOUT):S(null)}navigateToLoginAndLogout(t){return this.showToastPanelWithTranslatedErrorMessage(t),E(D(this.router.navigateByUrl(c.Login.path,{state:{forceNavigation:!0}})).pipe(T(i=>this.logout().pipe(y(()=>i))))).then(i=>{i&&this.loadingService.hide(),window.location.reload(),m.clearLoginLocalStorage(),C.clearSessionStorage()}).catch(e.EMPTY_REJECTION_HANDLER),S(null)}showToastPanelWithTranslatedErrorMessage(t){if(e.isNullOrUndefinedOrEmpty(t))return;let i=this.translateService.instant(t);this.toastMessageService.showToastPanel(A.getErrorDefaultConfig().withMessage(i))}static{this.\u0275fac=function(i){return new(i||o)(r(g),r(f),r(j),r(b),r(U),r(I))}}static{this.\u0275prov=n({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var P=(()=>{class o{constructor(t,i){this.router=t,this.redirectToLoginService=i}canActivateChild(t,i){if(i.url.includes(`/${c.Login.path}/`)){let a=this.router.getCurrentNavigation().extras.state,s=!1;return!e.isNullOrUndefined(a)&&a.forceNavigation&&(s=!0),u.isFullyAuthenticated()&&!s?(this.router.navigate([c.MainPanel.path]).catch(e.EMPTY_REJECTION_HANDLER),!1):!0}return i.url.includes("/"+c.ChooseBuWorkstation.path)&&!u.hasValidAuthCredentials()?(this.router.navigate([c.Auth.path]).catch(e.EMPTY_REJECTION_HANDLER),!1):u.isFullyAuthenticated()?!0:(this.redirectToLoginService.closeOpenDialogsAndNavigateToLogin("ERROR_REFRESH_TOKEN_FAILED").subscribe(),!1)}static{this.\u0275fac=function(i){return new(i||o)(r(f),r(v))}}static{this.\u0275prov=n({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var k=(()=>{class o{constructor(t,i){this.router=t,this.dialogTilesService=i}canActivateChild(t,i){if(i.url.includes(`/${c.Dashboard.path}`))return!0;let a=this.dialogTilesService.findDialogConfigForUrlPath(i.url),s=this.dialogTilesService.isDevDialog(i.url);return!!(!e.isNullOrUndefined(a)&&!this.dialogTilesService.isDialogReadOnly(a.dialogCode)||s)}static{this.\u0275fac=function(i){return new(i||o)(r(f),r(N))}}static{this.\u0275prov=n({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var O=(()=>{class o{constructor(t){this.restService=t}getScanningSounds(){let t=new R;return t=t.append("async",!0),this.restService.get(`${p.SOUND_CONFIGURATION}/scanningSounds`,t)}static{this.\u0275fac=function(i){return new(i||o)(r(g))}}static{this.\u0275prov=n({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var M=(()=>{class o{constructor(t){this.soundConfigurationService=t}getScanningSounds(){return this.soundConfigurationService.getScanningSounds()}static{this.\u0275fac=function(i){return new(i||o)(r(O))}}static{this.\u0275prov=n({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var H=(()=>{class o{constructor(t){this.soundConfigurationFacade=t}loadScanningSounds(){return this.soundConfigurationFacade.getScanningSounds()}playErrorScanSound(){let t=m.getScanningSounds();if(e.isNullOrUndefined(t)||e.isNullOrUndefinedOrEmpty(t.internalSoundDataErrorScan))return;let i=this.getBlobUrl(t.internalSoundDataErrorScan);this.playSound(i)}playGoodScanSound(){let t=m.getScanningSounds();if(e.isNullOrUndefined(t)||e.isNullOrUndefinedOrEmpty(t.internalSoundDataGoodScan))return;let i=this.getBlobUrl(t.internalSoundDataGoodScan);this.playSound(i)}playSound(t){let i=new Audio;i.src=t,i.load(),i.play().catch(e.EMPTY_REJECTION_HANDLER)}getBlobUrl(t){let i=window.atob(t),a=i.length,s=new Uint8Array(new ArrayBuffer(a));for(let l=0;l<a;l++)s[l]=i.charCodeAt(l);let h=new Blob([s],{type:"audio/ogg"});return URL.createObjectURL(h)}static{this.\u0275fac=function(i){return new(i||o)(r(M))}}static{this.\u0275prov=n({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();export{v as a,P as b,k as c,w as d,H as e};
