import{a as w}from"./chunk-Q6T4NRVD.js";import{a as d}from"./chunk-LOQVCDFL.js";import{d as g,i}from"./chunk-ZLFLH4BI.js";import{c as T}from"./chunk-RE7ESXYK.js";import{a as E,b as v}from"./chunk-RBR4ZJRC.js";import{a as c}from"./chunk-XZFVF7OG.js";import{b as I}from"./chunk-CTEJME6N.js";import{c as y}from"./chunk-NDJVQ6MR.js";import{a as f}from"./chunk-LANMKLUZ.js";import{m as R}from"./chunk-H7LDOWEY.js";import{Z as h,da as M,g as x,ja as _,ka as $,r as D}from"./chunk-ZGECHOBP.js";import{b as a,i as A}from"./chunk-QOJKCMZT.js";A();function b(u){return e=>{let r=(u?Math[u]:Math.trunc)(e);return r===0?0:r}}function S(u,e,t){let r=w(u,e)/1e3;return b(t?.roundingMethod)(r)}var m=class l{get statusStore$(){return this._statusTrigger$$.pipe(h(()=>this._selectedStore$.pipe(v(this),D(e=>this.getStatus(this._getStore(e)?.license)))))}constructor(e){this._retailStoreService=e,this._selectedStore$=$(R).select(y.selectedStoreId),this._statusTrigger$$=new x}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e,t=!1){if(e==null)return{name:"",status:d.None,daysRemaining:null,commonDaysRemaining:null,days:null,commonDays:null,prefix:null,class:"license-status-none",type:c.None};let r=new Date,o=new Date(e.currentExpiring),n=new Date(e.allExpiring),L=S(o,r),j=S(n,r),p=g(o,r),s=g(n,r);return t&&j<=0||!t&&L<=0?{name:e.name,status:d.Expired,daysRemaining:null,commonDaysRemaining:n?`\u0434\u043E ${i(n,"dd.MM.yy")}`:null,days:null,commonDays:s?`(${s} \u0434\u043D.)`:null,prefix:e.prefix,class:"license-status-expired",commonExpiringDate:i(n,"dd.MM.yyyy"),expiringDate:i(new Date(e.currentExpiring),"dd.MM.yyyy"),type:c.Expired}:t&&s<=3||!t&&p<=3?{name:e.name,status:d.ExpiredSoon,daysRemaining:`(${p} \u0434\u043D.)`,commonDaysRemaining:`\u0434\u043E ${i(n,"dd.MM.yy")}`,commonDays:`(${s} \u0434\u043D.)`,days:`(${p} \u0434\u043D.)`,prefix:e.prefix,class:"license-status-expired-soon",commonExpiringDate:i(n,"dd.MM.yyyy"),expiringDate:i(new Date(e.currentExpiring),"dd.MM.yyyy"),type:c.Warning}:{name:e.name,status:d.Active,daysRemaining:`\u0434\u043E ${i(o,"dd.MM.yy")}`,commonDaysRemaining:`\u0434\u043E ${i(n,"dd.MM.yy")}`,days:`(${p} \u0434\u043D.)`,commonDays:`(${s} \u0434\u043D.)`,prefix:e.prefix,class:"license-status-active",commonExpiringDate:i(n,"dd.MM.yyyy"),expiringDate:i(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(r=>!r?.license)&&setTimeout(()=>this.updateStores(e-1),1e4)})}filteredItems(e){let t=this._getStore(this._selectedStoreId)?.license?.prefix;return t?e.filter(r=>r.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||l)(_(T))}}static{this.\u0275prov=M({token:l,factory:l.\u0275fac})}};a([f(y.stores)],m.prototype,"_stores",void 0);a([f(y.selectedStoreId)],m.prototype,"_selectedStoreId",void 0);a([f(I.cashboxes)],m.prototype,"_cashboxes",void 0);m=a([E()],m);export{b as a,m as b};
