import{a as m}from"./chunk-7SSPIKUV.js";import{a as c}from"./chunk-NF4G3L36.js";import{b as R}from"./chunk-CYVMZNT7.js";import{c as b}from"./chunk-Z6SX4HYB.js";import{g as S,t as r}from"./chunk-E65EA4Y7.js";import{e as E}from"./chunk-Y5ITWXM5.js";import{a as _,b as $}from"./chunk-KXDO3JYP.js";import{f as M}from"./chunk-ZNYLCQSJ.js";import{c as l}from"./chunk-UU4K5RCK.js";import{a as d}from"./chunk-F24KRXZV.js";import{p as v}from"./chunk-JBWPPKX4.js";import{Z as h,fa as x,g as f,ka as u,la as D,q as g}from"./chunk-PVUKHE45.js";import{d as a,n as w}from"./chunk-VD6R3735.js";w();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(l.selectedStoreId),this._statusTrigger$$=new f}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e){if(e==null)return{name:"",status:m.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),T=R(i,t),p=S(o,t),s=S(i,t);return T<=0?{name:e.name,status:m.Expired,daysRemaining:null,commonDaysRemaining:i?`${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:m.ExpiredSoon,daysRemaining:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDaysRemaining:`${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:m.Active,daysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${r(o,"dd.MM.yy")}`,commonDaysRemaining:`${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)(u(b),u(E))},n.\u0275prov=x({token:n,factory:n.\u0275fac}),n);a([d(l.stores)],y.prototype,"_stores",void 0);a([d(l.selectedStoreId)],y.prototype,"_selectedStoreId",void 0);a([d(M.cashboxes)],y.prototype,"_cashboxes",void 0);y=a([_()],y);export{y as a};
//# sourceMappingURL=chunk-JGGQPL63.js.map
