import{a as w,b as y,c as _,d as E,e as j,g as A}from"./chunk-XUSKVTJP.js";import{a as O,b as F}from"./chunk-CC7H2Q52.js";import{b as N}from"./chunk-X6G2MEQP.js";import{a as L}from"./chunk-NUCOBKMO.js";import{n as x,p as D}from"./chunk-B3CI2H5S.js";import{a as C}from"./chunk-LEOOAH45.js";import{c as I}from"./chunk-BYOG7O4N.js";import{b}from"./chunk-DVHWBY5K.js";import{n as T,o as l,p as u,q as n}from"./chunk-DC6G5OHZ.js";import{D as g,ia as m,na as S,x as d}from"./chunk-C2QKZJOP.js";import{d as t,n as v}from"./chunk-INB5GR2I.js";import{a as h,b as k}from"./chunk-B7YGBANW.js";v();v();var s,c=(s=class{static suppliers(e){return e.suppliers}setCharacteristics(e,o){e.setState({suppliers:[...o.suppliers]})}clearCharacteristics(e){e.setState({suppliers:[]})}},s.\u0275fac=function(o){return new(o||s)},s.\u0275prov=m({token:s,factory:s.\u0275fac}),s);t([l(O)],c.prototype,"setCharacteristics",null);t([l(F)],c.prototype,"clearCharacteristics",null);t([n()],c,"suppliers",null);c=t([u({name:"suppliers",defaults:{suppliers:[]}})],c);var f,r,a=(r=class{constructor(e,o){this._localStorageService=e,this._store=o,d(window,"storage").pipe(g(i=>i.key==="authState"&&i.newValue!==null)).subscribe(i=>{let p=JSON.parse(i.newValue);this._store.reset(k(h({},this._store.snapshot()),{auth:p}))})}static tokens(e){return e.tokens}static accessToken(e){return e.tokens.accessToken}static accessTokenExpiration(e){return new Date(e.tokenExpiration)}static isAuthenticated(e){return e.tokens.accessToken!==""&&e.tokens.refreshToken!==""}static userName(e){return e.name}static userId(e){return e.userId}setTokens(e,o){let i=E(o.tokens.accessToken),p={name:i.name,phone:i.sub,tokens:o.tokens,userId:i.unique_name,tokenExpiration:new Date(i.exp*1e3).toString()};e.setState(p),this._localStorageService.set("authState",p)}logout(e){e.dispatch(new j(f,x,I,A,_,b,D,C,N,c)).subscribe(()=>{this._localStorageService.remove("selectedCashboxId"),this._localStorageService.remove("shiftOpenDate"),this._localStorageService.remove("paymentMethods"),this._localStorageService.remove("cart"),this._localStorageService.remove("sellPrice"),this._localStorageService.remove("sellDetails"),this._localStorageService.remove("authState")})}},f=r,r.\u0275fac=function(o){return new(o||r)(S(L),S(T))},r.\u0275prov=m({token:r,factory:r.\u0275fac}),r);t([l(w)],a.prototype,"setTokens",null);t([l(y)],a.prototype,"logout",null);t([n()],a,"tokens",null);t([n()],a,"accessToken",null);t([n()],a,"accessTokenExpiration",null);t([n()],a,"isAuthenticated",null);t([n()],a,"userName",null);t([n()],a,"userId",null);a=f=t([u({name:"auth",defaults:{phone:"",name:"",userId:"",tokens:{accessToken:"",refreshToken:""},tokenExpiration:""}})],a);export{c as a,a as b};
//# sourceMappingURL=chunk-VCKZUP7X.js.map
