import{a as l}from"./chunk-7SSPIKUV.js";import{a as c}from"./chunk-NF4G3L36.js";import{b as z}from"./chunk-CYVMZNT7.js";import{g as u,t as r}from"./chunk-TL6VKVO7.js";import{c as R}from"./chunk-J2FWBKXX.js";import{e as E}from"./chunk-LH4LY7P4.js";import{a as _,b as $}from"./chunk-IGFM5CCE.js";import{c as M}from"./chunk-Y5ZINRNV.js";import{c as m}from"./chunk-IXRBBB6V.js";import{a as d}from"./chunk-FPRDBDVD.js";import{o as v}from"./chunk-M6NTKB7A.js";import{Z as h,g as f,ga as x,la as S,ma as D,q as g}from"./chunk-I3FGJX2C.js";import{d as a,n as T}from"./chunk-INB5GR2I.js";T();var n,y=(n=class{get statusStore$(){return this._statusTrigger$$.pipe(h(()=>this._selectedStore$.pipe($(this),g(e=>this.getStatus(this._getStore(e)?.license)))))}constructor(e,t){this._retailStoreService=e,this._localizationService=t,this._selectedStore$=D(v).select(m.selectedStoreId),this._statusTrigger$$=new f}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e){if(e==null)return{name:"",status:l.None,daysRemaining:null,commonDaysRemaining:null,days:null,commonDays:null,prefix:null,class:"license-status-none",type:c.None};let t=new Date,o=new Date(e.currentExpiring),i=new Date(e.allExpiring),b=z(i,t),p=u(o,t),s=u(i,t);return b<=0?{name:e.name,status:l.Expired,daysRemaining:null,commonDaysRemaining:i?`${this._localizationService.getSync("\u0434\u043E")} ${r(i,"dd.MM.yy")}`:null,days:null,commonDays:s?`(${s} ${this._localizationService.getSync("\u0434\u043D.")})`:null,prefix:e.prefix,class:"license-status-expired",commonExpiringDate:r(i,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:c.Expired}:s<=3?{name:e.name,status:l.ExpiredSoon,daysRemaining:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDaysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${r(i,"dd.MM.yy")}`,commonDays:`(${s} ${this._localizationService.getSync("\u0434\u043D.")})`,days:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-expired-soon",commonExpiringDate:r(i,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:c.Warning}:{name:e.name,status:l.Active,daysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${r(o,"dd.MM.yy")}`,commonDaysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${r(i,"dd.MM.yy")}`,days:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDays:`(${s} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-active",commonExpiringDate:r(i,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:c.Success}}updateStores(e=3){e<=0||this._retailStoreService.getStores().subscribe(t=>{this._statusTrigger$$.next(),t.every(o=>!o?.license)&&setTimeout(()=>this.updateStores(e-1),1e4)})}filteredItems(e){let t=this._getStore(this._selectedStoreId)?.license?.prefix;return t?e.filter(o=>o.options.filter(i=>(i.visible=!i.licence||!i.licence.includes(t),i.visible)).length):e}_getStore(e){return this._stores.find(t=>t.id===e)}_getCashbox(e){return this._cashboxes.find(t=>t.id===e)}},n.\u0275fac=function(t){return new(t||n)(S(R),S(E))},n.\u0275prov=x({token:n,factory:n.\u0275fac}),n);a([d(m.stores)],y.prototype,"_stores",void 0);a([d(m.selectedStoreId)],y.prototype,"_selectedStoreId",void 0);a([d(M.cashboxes)],y.prototype,"_cashboxes",void 0);y=a([_()],y);export{y as a};
//# sourceMappingURL=chunk-OVRMBYC7.js.map
