import{a as f}from"./chunk-56M6FJ3C.js";import{a as D}from"./chunk-AFI6Z2RM.js";import{a as _,c as y}from"./chunk-QOLYJUM7.js";import{b as p}from"./chunk-CYVMZNT7.js";import{f as a}from"./chunk-E65EA4Y7.js";import{c as S}from"./chunk-SMAIR2YP.js";import{p as v}from"./chunk-JBWPPKX4.js";import{$ as A,K as m,fa as w,ka as d}from"./chunk-PVUKHE45.js";import{a as g,b as T}from"./chunk-MZPAXKJS.js";var F=(()=>{let r=class r{constructor(t,e){this._nomenclatureDiscountServiceApi=t,this._store=e}getAllNomenclatureDiscounts(t){return this._nomenclatureDiscountServiceApi.getAll(t)}getAllNomenclatureDiscountsForStore(t=1e3){let e=this._nomenclatureDiscountServiceApi.defaultFilter;return this._nomenclatureDiscountServiceApi.getAll(T(g({},e),{take:t})).pipe(A(s=>this._store.dispatch(new _(s.data))))}upsertNomenclatureDiscount(t){return this._nomenclatureDiscountServiceApi.upsert(this._toRequestModel(t)).pipe(m(1))}deleteNomenclatureDiscount(t){return this._nomenclatureDiscountServiceApi.delete(t).pipe(m(1))}sync(){return this._nomenclatureDiscountServiceApi.sync().pipe(m(1))}isNowWithinTimeRange(t,e,s=new Date){if(!t||!e)return!1;let n=f(t,"HH:mm:ss",new Date),i=f(e,"HH:mm:ss",new Date),o=p(n,a(n)),u=p(i,a(i)),c=p(s,a(s));return o<u?c>=o&&c<=u:c>=o||c<=u}isNowWithinDateRange(t,e,s=new Date){if(!t)return!1;let n=a(new Date(t)),i=e?D(new Date(e)):null,o=a(new Date(s));if(!i)return o.getTime()>=n.getTime();let u=n<=i?n:i,c=n<=i?i:n,h=o.getTime();return h>=u.getTime()&&h<=c.getTime()}_formatTime(t){return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:00`}_toRequestModel(t){return{percent:t.discountPercent,startDate:S(t.startDate),endDate:t.endDate?S(D(t.endDate)):null,startTime:t.startTime?this._formatTime(t.startTime):null,endTime:t.endTime?this._formatTime(t.endTime):null,nomenclatureIds:t.positions.map(e=>e.product.id)}}};r.\u0275fac=function(e){return new(e||r)(d(y),d(v))},r.\u0275prov=w({token:r,factory:r.\u0275fac,providedIn:"root"});let l=r;return l})();export{F as a};
//# sourceMappingURL=chunk-5OEXOAQN.js.map
