import{f as w}from"./chunk-LBZE4AC4.js";import{a as u}from"./chunk-IFY4UZPR.js";import{p as h}from"./chunk-JBWPPKX4.js";import{a as v}from"./chunk-7N232KV6.js";import{e as f,i as g}from"./chunk-NDLDFKR2.js";import{$ as c,K as n,Z as d,fa as p,ka as s,q as m}from"./chunk-PVUKHE45.js";import{a as l}from"./chunk-MZPAXKJS.js";var o=(function(r){return r[r.Text=0]="Text",r[r.List=1]="List",r})(o||{}),j={[o.Text]:"\u0422\u0435\u043A\u0441\u0442",[o.List]:"\u0421\u043F\u0438\u0441\u043E\u043A"};var _=(()=>{let i=class i{constructor(t,e){this._http=t,this._store=e}get(t){let e=new f;return t!==void 0&&(e=e.append("onlyList",t)),this._http.post("/api/characteristic/all",{},{headers:v,params:e}).pipe(c(a=>{this._store.dispatch(new u({characteristics:[...a]}))}))}getById(t){return this._http.get(`/api/characteristic/${t}`)}create(t){return this._http.post("/api/characteristic",l({},t))}edit(t,e){return this._http.put(`/api/characteristic/${e}`,l({},t))}delete(t){return this._http.delete(`/api/characteristic/${t}`)}};i.\u0275fac=function(e){return new(e||i)(s(g),s(h))},i.\u0275prov=p({token:i,factory:i.\u0275fac});let r=i;return r})();var M=(()=>{let i=class i{constructor(t,e){this._characteristicService=t,this._store=e}get(){return this._characteristicService.get().pipe(n(1),c(t=>{this._store.dispatch(new u({characteristics:[...t.sort((e,a)=>a.id-e.id)]}))}))}create(t){return this._characteristicService.create(t).pipe(d(()=>this.get()),n(1),m(()=>{}))}edit(t,e){return this._characteristicService.edit(t,e).pipe(c(()=>this.get().subscribe()),n(1))}delete(t){return this._characteristicService.delete(t).pipe(c(()=>this.get().subscribe()),n(1))}checkForDuplicates(t){let e=t.get("values")?.value.map(S=>S.new),a=new Set(e);return e?.length!==a.size}checkValid(t){let e=t.get("values")?.value.map(a=>a.new).findIndex(a=>a.length==0||a.length>w.max);return!t.valid||t.get("type")?.value===o.List&&!t.get("values")?.value.length||e!==-1}isFormValid(t){return!this.checkValid(t)&&!this.checkForDuplicates(t)}mappedValues(t){return t.values?.map(e=>e.old.length?{newValue:e.new,oldValue:e.old}:{newValue:e.new})}};i.\u0275fac=function(e){return new(e||i)(s(_),s(h))},i.\u0275prov=p({token:i,factory:i.\u0275fac});let r=i;return r})();export{o as a,j as b,_ as c,M as d};
//# sourceMappingURL=chunk-DYXT7TK5.js.map
