import{a as l}from"./chunk-LOQVCDFL.js";import{a as d}from"./chunk-XZFVF7OG.js";import{c as w}from"./chunk-FELXYIYL.js";import{g as h,t as r}from"./chunk-H4EID347.js";import{g}from"./chunk-5PXX4U2Z.js";import{d as T}from"./chunk-MX2TZFKO.js";import{b as I}from"./chunk-KMRS4JTH.js";import{c as y}from"./chunk-EZFUKPLV.js";import{a as u}from"./chunk-X73HYPLN.js";import{m as z}from"./chunk-ALPCJSJV.js";import{a as E,b as R}from"./chunk-CKUQY5IU.js";import{Z as M,da as $,g as D,ja as S,ka as v,r as _}from"./chunk-AO7NUUXN.js";import{d as c,n as A}from"./chunk-HE7HQ6LI.js";function b(s,e){return+g(s)-+g(e)}A();function L(s){return e=>{let i=(s?Math[s]:Math.trunc)(e);return i===0?0:i}}function j(s,e,t){let i=b(s,e)/1e3;return L(t?.roundingMethod)(i)}var m=class p{get statusStore$(){return this._statusTrigger$$.pipe(M(()=>this._selectedStore$.pipe(R(this),_(e=>this.getStatus(this._getStore(e)?.license)))))}constructor(e,t){this._retailStoreService=e,this._localizationService=t,this._selectedStore$=v(z).select(y.selectedStoreId),this._statusTrigger$$=new D}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e,t=!1){if(e==null)return{name:"",status:l.None,daysRemaining:null,commonDaysRemaining:null,days:null,commonDays:null,prefix:null,class:"license-status-none",type:d.None};let i=new Date,o=new Date(e.currentExpiring),n=new Date(e.allExpiring),x=j(n,i),f=h(o,i),a=h(n,i);return t&&x<=0||!t&&x<=0?{name:e.name,status:l.Expired,daysRemaining:null,commonDaysRemaining:n?`${this._localizationService.getSync("\u0434\u043E")} ${r(n,"dd.MM.yy")}`:null,days:null,commonDays:a?`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`:null,prefix:e.prefix,class:"license-status-expired",commonExpiringDate:r(n,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:d.Expired}:t&&a<=3||!t&&a<=3?{name:e.name,status:l.ExpiredSoon,daysRemaining:`(${f} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDaysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${r(n,"dd.MM.yy")}`,commonDays:`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`,days:`(${f} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-expired-soon",commonExpiringDate:r(n,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:d.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(n,"dd.MM.yy")}`,days:`(${f} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDays:`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-active",commonExpiringDate:r(n,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:d.Success}}updateStores(e=3){e<=0||this._retailStoreService.getStores().subscribe(t=>{this._statusTrigger$$.next(),t.every(i=>!i?.license)&&setTimeout(()=>this.updateStores(e-1),1e4)})}filteredItems(e){let t=this._getStore(this._selectedStoreId)?.license?.prefix;return t?e.filter(i=>i.options.filter(o=>(o.visible=!o.licence||!o.licence.includes(t),o.visible)).length):e}_getStore(e){return this._stores.find(t=>t.id===e)}_getCashbox(e){return this._cashboxes.find(t=>t.id===e)}static{this.\u0275fac=function(t){return new(t||p)(S(w),S(T))}}static{this.\u0275prov=$({token:p,factory:p.\u0275fac})}};c([u(y.stores)],m.prototype,"_stores",void 0);c([u(y.selectedStoreId)],m.prototype,"_selectedStoreId",void 0);c([u(I.cashboxes)],m.prototype,"_cashboxes",void 0);m=c([E()],m);export{L as a,b,j as c,m as d};
