1import{b as f}from"./chunk-XNXLFDZX.js";import{a as u}from"./chunk-IENL4UJA.js";import{V as v}from"./chunk-P4C42LQP.js";import{d as k}from"./chunk-RZZCZ2VH.js";import{Da as c,Fa as l,g as h,ma as g}from"./chunk-SRTQBDBP.js";var p="AUT",m="UPH";var y=(()=>{class r{constructor(t,e){this.sessionService=t,this.http=e,this.userData$=new h(null),this.isAuth$=new h(!1),this.router=l(v)}setUserData(t){t?.phoneNumber&&(this.userData$.next(t),this.isAuth$.next(!0),this.sessionService.setItem(m,t.phoneNumber),this.sessionService.crmUserId=t?.crmUserId)}getUserData(){return this.userData$}checkAuth(){return this.isAuth$}isAuthenticatedSync(){return!!this.getToken()}setUserToken(t){let e=JSON.parse(t.replace(/\\|\//g,""));this._token=e.access_token,this.expiresIn=+e.expires_in,this._tokenExpirationDate=new Date(Date.now()+this.expiresIn*1e3),this.sessionService.tokenExpirationDate=this._tokenExpirationDate,this._tokenType=e.token_type,this.sessionService.setItem(p,this._token),this.autoLogout()}getToken(){return this.sessionService.getItem(p)}getCrmUserId(){return this.sessionService.crmUserId}getExpirationDate(){return this.sessionService.tokenExpirationDate}autoLogin(){this.isAuth$.subscribe(t=>{this.checkAutoLoginCases()})}checkAutoLoginCases(){if(!this.isAuth$.value){let e=this.getToken(),i=this.sessionService.getItem(m);e&&i?this.fetchUserDataByPhoneNumber(i):this.logOut()}}fetchUserDataByPhoneNumber(t){let e=`${u.apiUrl}Account/GetUserByPhoneNumber?phoneNumber=${t}`;this.http.get(e).subscribe(({data:i})=>{this.setUserData(i)})}getUserDataByPhoneNumber(t){let e=`${u.apiUrl}Account/GetUserByPhoneNumber?phoneNumber=${t}`;return this.http.get(e)}logOut(){this.userData$.next(null),sessionStorage.clear(),Object.keys(localStorage).forEach(t=>{t!=="lang"&&t!=="rvd"&&localStorage.removeItem(t)})}autoLogout(){this.tokenExpirationTimer&&clearTimeout(this.tokenExpirationTimer);let t=this.getExpirationDate();t&&(this.tokenExpirationTimer=setInterval(()=>{new Date(t).getTime()-new Date().getTime()<=0&&this.logOut()},18e3))}getSignature(t,e){let i=t.split("/").length,n=t.split("?").length;var s=2*e;s=s+i,s=s+n,s=s+8;var o=e+i;o=o-n,o=o-2;var a=s+o;a=a+5;var x=i+n,D=a+x;return D.toString()}navigateToLoginPage(){this.router.navigate(["/auth/login"])}static{this.\u0275fac=function(e){return new(e||r)(c(f),c(k))}}static{this.\u0275prov=g({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();export{p as a,y as b};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.