import{a as l}from"./chunk-IUBVOCNY.js";import{p as d}from"./chunk-7WGMNLRJ.js";import{i as g}from"./chunk-YMOV4UGM.js";import{$ as c,K as o,ga as p,la as s}from"./chunk-I3FGJX2C.js";import{a as h}from"./chunk-B7YGBANW.js";var y=(()=>{let r=class r{constructor(t){this._http=t}getCategories(){return this._http.get("/api/category")}getCategoryById(t){return this._http.get(`/api/category/${t}`)}createCategory(t){return this._http.post("/api/category",h({},t))}editCategory(t,e){return this._http.put(`/api/category/${t}`,h({},e))}deleteCategory(t){return this._http.delete(`/api/category/${t}`)}};r.\u0275fac=function(e){return new(e||r)(s(g))},r.\u0275prov=p({token:r,factory:r.\u0275fac});let n=r;return n})();var j=(()=>{let r=class r{constructor(t,e){this._store=t,this._categoryServiceApi=e}getCategories(){return this._categoryServiceApi.getCategories().pipe(c(t=>this._store.dispatch(new l({categories:t}))),o(1))}deleteCategory(t){return this._categoryServiceApi.deleteCategory(t).pipe(c(()=>this.getCategories().subscribe()),o(1))}editCategory(t,e){let i={nameRu:e.name,nameKk:e.name,isQuick:e.isQuick,parentId:e.parentId,comment:e.comment};return this._categoryServiceApi.editCategory(t,i).pipe(c(()=>this.getCategories().subscribe()),o(1))}createCategory(t){let e={nameRu:t.name,nameKk:t.name,isQuick:t.isQuick,parentId:t.parentId,comment:t.comment};return this._categoryServiceApi.createCategory(e).pipe(c(()=>this.getCategories().subscribe()),o(1))}findParentId(t,e){return e?this._searchForParentId(t,e,null):null}findCategoryChildren(t,e){for(let i of t){if(i.id===e)return i.children??[];if(i.children){let a=this.findCategoryChildren(i.children,e);if(a.length>0)return a}}return[]}_searchForParentId(t,e,i){for(let a of t){if(a.id===e)return i;if(a.children){let u=this._searchForParentId(a.children,e,a.id);if(u!==null)return u}}return null}};r.\u0275fac=function(e){return new(e||r)(s(d),s(y))},r.\u0275prov=p({token:r,factory:r.\u0275fac});let n=r;return n})();export{y as a,j as b};
//# sourceMappingURL=chunk-ADJVAMS3.js.map
