import{a as p}from"./chunk-56M6FJ3C.js";import{t as a}from"./chunk-E65EA4Y7.js";import{a as m}from"./chunk-7N232KV6.js";import{i as l}from"./chunk-NDLDFKR2.js";import{fa as n,ka as c}from"./chunk-PVUKHE45.js";var h=(()=>{let i=class i{constructor(t){this._http=t}getById(t){return this._http.get("/api/sell-restriction",{params:{cashboxId:t}})}create(t){return this._http.post("/api/sell-restriction/category-time",t)}delete(t){return this._http.delete(`/api/sell-restriction/${t}`)}sync(t){return this._http.post(`/api/sell-restriction/${t}/sync`,{},{headers:m})}};i.\u0275fac=function(e){return new(e||i)(c(l))},i.\u0275prov=n({token:i,factory:i.\u0275fac,providedIn:"root"});let s=i;return s})();var S=(()=>{let i=class i{constructor(t){this._sellRestrictionServiceApi=t}getSellRestriction(t){return this._sellRestrictionServiceApi.getById(t)}createSellRestriction(t){return this._sellRestrictionServiceApi.create(t)}buildCreateRequest(t,e){if(!e.categoryId||!e.startTime||!e.endTime)return null;let r=`${this._formatTimeToString(e.startTime)}:00`,o=`${this._formatTimeToString(e.endTime)}:00`;return this._createRestrictionRequest(t,e.categoryId,r,o)}deleteSellRestriction(t){return this._sellRestrictionServiceApi.delete(t)}sync(t){return this._sellRestrictionServiceApi.sync(t)}isRestrictionActive(t,e){let r=a(new Date,"HH:mm:ss");return t<=e?r>=t&&r<=e:r>=t||r<=e}getActiveSellRestriction(t){return t?.find(e=>this.isRestrictionActive(e.startTime,e.endTime))}hasActiveSellRestriction(t){return!!this.getActiveSellRestriction(t)}formatRestrictionTime(t){return a(p(t,"HH:mm:ss",new Date),"HH:mm")}getRestrictionBadgeText(t,e){let r=this.getActiveSellRestriction(t);return r?`${e("\u0417\u0430\u043F\u0440\u0435\u0442 \u0434\u043E")} ${this.formatRestrictionTime(r.endTime)}`:""}_formatTimeToString(t){return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}_createRestrictionRequest(t,e,r,o){return{cashboxId:t,categoryId:e,startTime:r,endTime:o}}};i.\u0275fac=function(e){return new(e||i)(c(h))},i.\u0275prov=n({token:i,factory:i.\u0275fac});let s=i;return s})();export{S as a};
//# sourceMappingURL=chunk-5CMAEFYA.js.map
