import{a as d}from"./chunk-MJT556FT.js";import{a as l}from"./chunk-NF4G3L36.js";import{g,t as n}from"./chunk-W3BEWLBM.js";import{g as S}from"./chunk-LINAD4CC.js";import{c as I}from"./chunk-L7HVTKKS.js";import{d as z}from"./chunk-BOZT4LSN.js";import{a as $,b as v}from"./chunk-EK6YV2TW.js";import{b as R}from"./chunk-TTT4O4HK.js";import{c as y}from"./chunk-VJXA7ZH3.js";import{a as p}from"./chunk-Y75MWVBQ.js";import{o as E}from"./chunk-GW2OL5S3.js";import{X as D,ea as M,g as h,ja as f,ka as _,q as x}from"./chunk-DYUFV4HF.js";import{d as c,n as C}from"./chunk-INB5GR2I.js";function b(s,e){return+S(s)-+S(e)}C();function T(s){return e=>{let r=(s?Math[s]:Math.trunc)(e);return r===0?0:r}}function w(s,e,t){let r=b(s,e)/1e3;return T(t?.roundingMethod)(r)}var o,m=(o=class{get statusStore$(){return this._statusTrigger$$.pipe(D(()=>this._selectedStore$.pipe(v(this),x(e=>this.getStatus(this._getStore(e)?.license)))))}constructor(e,t){this._retailStoreService=e,this._localizationService=t,this._selectedStore$=_(E).select(y.selectedStoreId),this._statusTrigger$$=new h}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e){if(e==null)return{name:"",status:d.None,daysRemaining:null,commonDaysRemaining:null,days:null,commonDays:null,prefix:null,class:"license-status-none",type:l.None};let t=new Date,r=new Date(e.currentExpiring),i=new Date(e.allExpiring),j=w(i,t),u=g(r,t),a=g(i,t);return j<=0?{name:e.name,status:d.Expired,daysRemaining:null,commonDaysRemaining:i?`${this._localizationService.getSync("\u0434\u043E")} ${n(i,"dd.MM.yy")}`:null,days:null,commonDays:a?`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`:null,prefix:e.prefix,class:"license-status-expired",commonExpiringDate:n(i,"dd.MM.yyyy"),expiringDate:n(new Date(e.currentExpiring),"dd.MM.yyyy"),type:l.Expired}:a<=3?{name:e.name,status:d.ExpiredSoon,daysRemaining:`(${u} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDaysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${n(i,"dd.MM.yy")}`,commonDays:`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`,days:`(${u} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-expired-soon",commonExpiringDate:n(i,"dd.MM.yyyy"),expiringDate:n(new Date(e.currentExpiring),"dd.MM.yyyy"),type:l.Warning}:{name:e.name,status:d.Active,daysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${n(r,"dd.MM.yy")}`,commonDaysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${n(i,"dd.MM.yy")}`,days:`(${u} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDays:`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-active",commonExpiringDate:n(i,"dd.MM.yyyy"),expiringDate:n(new Date(e.currentExpiring),"dd.MM.yyyy"),type:l.Success}}updateStores(e=3){e<=0||this._retailStoreService.getStores().subscribe(t=>{this._statusTrigger$$.next(),t.every(r=>!r?.license)&&setTimeout(()=>this.updateStores(e-1),1e4)})}filteredItems(e){let t=this._getStore(this._selectedStoreId)?.license?.prefix;return t?(console.log(e),e.filter(r=>r.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)}},o.\u0275fac=function(t){return new(t||o)(f(I),f(z))},o.\u0275prov=M({token:o,factory:o.\u0275fac}),o);c([p(y.stores)],m.prototype,"_stores",void 0);c([p(y.selectedStoreId)],m.prototype,"_selectedStoreId",void 0);c([p(R.cashboxes)],m.prototype,"_cashboxes",void 0);m=c([$()],m);export{T as a,b,w as c,m as d};
//# sourceMappingURL=chunk-4SYOTA34.js.map
