import{m as h}from"./chunk-OWZ5YAMH.js";import{j as l}from"./chunk-GQAU5ACB.js";import{S as o,fa as c,la as s,pa as p}from"./chunk-ISMRT7VU.js";import{a as n}from"./chunk-M5TX2NVG.js";var k=(()=>{class e{static{this.type="[QuickGroup] Set Quick Groups"}constructor(t){this.quickGroup=t}}return e})(),Q=(()=>{class e{static{this.type="[QuickGroup] Clear Quick Groups"}}return e})();var d=(()=>{class e{constructor(t){this._http=t}getAll(){return this._http.get("/api/quick-group/all")}getById(t){return this._http.get(`/api/quick-group/${t}`)}create(t){return this._http.post("/api/quick-group",n({},t))}update(t,r){return this._http.put(`/api/quick-group/${t}`,n({},r))}delete(t){return this._http.delete(`/api/quick-group/${t}`)}static{this.\u0275fac=function(r){return new(r||e)(p(l))}}static{this.\u0275prov=s({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();var v=(()=>{class e{constructor(t,r){this._store=t,this._quickGroupServiceApi=r}getQuickGroups(){return this._quickGroupServiceApi.getAll().pipe(c(t=>this._store.dispatch(new k({quickGroups:t}))),o(1))}createQuickGroup(t){let r={nameRu:t.name,nameKk:t.name,parentId:t.parentId};return this._quickGroupServiceApi.create(r).pipe(c(()=>this.getQuickGroups().subscribe()),o(1))}editQuickGroup(t,r){let i={nameRu:r.name,nameKk:r.name,parentId:r.parentId};return this._quickGroupServiceApi.update(t,i).pipe(c(()=>this.getQuickGroups().subscribe()),o(1))}deleteQuickGroup(t){return this._quickGroupServiceApi.delete(t).pipe(c(()=>this.getQuickGroups().subscribe()),o(1))}findParentId(t,r){return r?this._searchForParentId(t,r,null):null}isNameDuplicate(t,r,i){return this._checkNameDuplicate(t,r.trim().toLowerCase(),i)}isGroupAChild(t,r){for(let i of t)for(let u of i.children)if(u.id===r)return!0;return!1}_checkNameDuplicate(t,r,i){for(let u of t)if(u.id!==i&&u.name.trim().toLowerCase()===r||this._checkNameDuplicate(u.children,r,i))return!0;return!1}_searchForParentId(t,r,i){for(let u of t){if(u.id===r)return i;if(u.children){let a=this._searchForParentId(u.children,r,u.id);if(a!==null)return a}}return null}static{this.\u0275fac=function(r){return new(r||e)(p(h),p(d))}}static{this.\u0275prov=s({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();export{k as a,Q as b,v as c};
//# sourceMappingURL=chunk-JEOVGUX6.js.map
