import{a as M}from"./chunk-TPACFMFL.js";import{d as h}from"./chunk-H2B22MYX.js";import{Bc as f,Bg as A,Hg as g,O,Of as N,Pc as p,U as n,X as r,_f as C,ac as U,eg as u,jd as c,mg as R,n as T,o as v,of as d,pf as e,qg as j,r as y,t as L}from"./chunk-HONMJZOB.js";var w=(()=>{class i{canDeactivate(t){return t.canNavigateBack()}static{this.\u0275fac=function(o){return new(o||i)}}static{this.\u0275prov=n({token:i,factory:i.\u0275fac})}}return i})();var E=(()=>{class i{constructor(t,o,a,s,S,l){this.restService=t,this.router=o,this.translateService=a,this.toastMessageService=s,this.matDialog=S,this.loadingService=l}closeOpenDialogsAndNavigateToLogin(t){return this.closeOpenDialogs(),this.navigateToLoginAndLogout(t)}closeOpenDialogs(){this.matDialog.closeAll()}logout(){return u.hasValidAuthCredentials()?this.restService.delete(p.LOGOUT):v(null)}navigateToLoginAndLogout(t){return t!==f.TYPE_USER_LOGOUT&&this.showToastPanelWithTranslatedErrorMessage(t.valueOf()),y(T(this.router.navigateByUrl(c.Login.path,{state:{forceNavigation:!0}})).pipe(O(o=>this.logout().pipe(L(()=>o))))).then(o=>{o&&this.loadingService.hide(),t===f.TYPE_USER_LOGOUT&&window.location.reload(),d.clearLoginLocalStorage(),C.clearSessionStorage()}).catch(e.EMPTY_REJECTION_HANDLER),v(null)}showToastPanelWithTranslatedErrorMessage(t){if(e.isNullOrUndefinedOrEmpty(t))return;let o=this.translateService.instant(t);this.toastMessageService.showToastPanel(R.getErrorDefaultConfig().withMessage(o))}static{this.\u0275fac=function(o){return new(o||i)(r(h),r(g),r(N),r(A),r(j),r(M))}}static{this.\u0275prov=n({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var x=(()=>{class i{constructor(t,o){this.router=t,this.redirectToLoginService=o}canActivateChild(t,o){if(o.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 o.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(f.TYPE_REFRESH_TOKEN_LOGOUT).subscribe(),!1)}static{this.\u0275fac=function(o){return new(o||i)(r(g),r(E))}}static{this.\u0275prov=n({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var b=(()=>{class i{constructor(t){this.restService=t}getScanningSounds(){let t=new U;return t=t.append("async",!0),this.restService.get(`${p.SOUND_CONFIGURATION}/scanningSounds`,t)}static{this.\u0275fac=function(o){return new(o||i)(r(h))}}static{this.\u0275prov=n({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var I=(()=>{class i{constructor(t){this.soundConfigurationService=t}getScanningSounds(){return this.soundConfigurationService.getScanningSounds()}static{this.\u0275fac=function(o){return new(o||i)(r(b))}}static{this.\u0275prov=n({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var B=(()=>{class i{constructor(t){this.soundConfigurationFacade=t}loadScanningSounds(){return this.soundConfigurationFacade.getScanningSounds()}playErrorScanSound(){let t=d.getScanningSounds();if(e.isNullOrUndefined(t)||e.isNullOrUndefinedOrEmpty(t.internalSoundDataErrorScan))return;let o=this.getBlobUrl(t.internalSoundDataErrorScan);this.playSound(o)}playGoodScanSound(){let t=d.getScanningSounds();if(e.isNullOrUndefined(t)||e.isNullOrUndefinedOrEmpty(t.internalSoundDataGoodScan))return;let o=this.getBlobUrl(t.internalSoundDataGoodScan);this.playSound(o)}playSound(t){let o=new Audio;o.src=t,o.load(),o.play().catch(e.EMPTY_REJECTION_HANDLER)}getBlobUrl(t){let o=window.atob(t),a=o.length,s=new Uint8Array(new ArrayBuffer(a));for(let l=0;l<a;l++)s[l]=o.charCodeAt(l);let S=new Blob([s],{type:"audio/ogg"});return URL.createObjectURL(S)}static{this.\u0275fac=function(o){return new(o||i)(r(I))}}static{this.\u0275prov=n({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();export{E as a,x as b,w as c,B as d};
