import{a as _,b as w,c as A,d as E,e as j,g as D}from"./chunk-KHQ5XVGA.js";import{l as C,n as I,o as L}from"./chunk-VCTLKCBQ.js";import{b as N}from"./chunk-CTEJME6N.js";import{a as b}from"./chunk-2577PVTZ.js";import{c as x}from"./chunk-NDJVQ6MR.js";import{b as T}from"./chunk-WKS4J6VW.js";import{a as O,b as F}from"./chunk-NIGRN2AN.js";import{m as y,n as c,o as p,p as s}from"./chunk-H7LDOWEY.js";import{E as d,da as l,ja as u,y as g}from"./chunk-ZGECHOBP.js";import{b as e,i as v}from"./chunk-QOJKCMZT.js";import{a as f,b as k}from"./chunk-K4ALXBGI.js";v();v();var i=class m{static suppliers(t){return t.suppliers}setCharacteristics(t,r){t.setState({suppliers:[...r.suppliers]})}clearCharacteristics(t){t.setState({suppliers:[]})}static{this.\u0275fac=function(r){return new(r||m)}}static{this.\u0275prov=l({token:m,factory:m.\u0275fac})}};e([c(O)],i.prototype,"setCharacteristics",null);e([c(F)],i.prototype,"clearCharacteristics",null);e([s()],i,"suppliers",null);i=e([p({name:"suppliers",defaults:{suppliers:[]}})],i);var h,o=class S{static{h=this}constructor(t,r){this._localStorageService=t,this._store=r,g(window,"storage").pipe(d(a=>a.key==="authState"&&a.newValue!==null)).subscribe(a=>{let n=JSON.parse(a.newValue);this._store.reset(k(f({},this._store.snapshot()),{auth:n}))})}static tokens(t){return t.tokens}static accessToken(t){return t.tokens.accessToken}static accessTokenExpiration(t){return new Date(t.tokenExpiration)}static isAuthenticated(t){return t.tokens.accessToken!==""&&t.tokens.refreshToken!==""}static userName(t){return t.name}setTokens(t,r){let a=E(r.tokens.accessToken),n={name:a.name,phone:a.sub,tokens:r.tokens,tokenExpiration:new Date(a.exp*1e3).toString()};t.setState(n),this._localStorageService.set("authState",n)}logout(t){t.dispatch(new j(h,C,x,D,A,T,I,b,N,i)).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")})}static{this.\u0275fac=function(r){return new(r||S)(u(L),u(y))}}static{this.\u0275prov=l({token:S,factory:S.\u0275fac})}};e([c(_)],o.prototype,"setTokens",null);e([c(w)],o.prototype,"logout",null);e([s()],o,"tokens",null);e([s()],o,"accessToken",null);e([s()],o,"accessTokenExpiration",null);e([s()],o,"isAuthenticated",null);e([s()],o,"userName",null);o=h=e([p({name:"auth",defaults:{phone:"",name:"",tokens:{accessToken:"",refreshToken:""},tokenExpiration:""}})],o);export{i as a,o as b};
