import{a as K}from"./chunk-JWB3UQDY.js";import{f as Q,t as V,x as q}from"./chunk-ZVQ5RRLK.js";import{b as J}from"./chunk-GVW75DLG.js";import{b as j,f as $,g as z}from"./chunk-XSARCGYY.js";import{$a as R,B as w,D as U,Ia as M,Ja as O,o as s,q as S,r as k,u as A,w as L,wa as G,z as B}from"./chunk-HE5QLLAI.js";import{a as F,b as h}from"./chunk-2RGQU2W2.js";import{b as P}from"./chunk-ICDY5Q2H.js";import{o as H}from"./chunk-AEEDSABA.js";import{Cb as y,Hb as D,Ic as f,Kc as g,Xb as E,Zb as x,cc as n,dc as p,ec as d,ed as r,fc as u,fd as a,jd as N,kb as i,la as b,uc as I,vb as l,yd as T}from"./chunk-4HRPSKID.js";import{d as v,n as Y}from"./chunk-INB5GR2I.js";import{a as C,b as _}from"./chunk-B7YGBANW.js";Y();function Z(m,t){if(m&1&&u(0,"tis-svg",7),m&2){let e=I(2);n("icon",e.icon.Star)}}function ee(m,t){if(m&1&&(p(0,"div",6),E(1,Z,1,1,"tis-svg",7),p(2,"div",8)(3,"span"),f(4),d(),p(5,"span",9),f(6),d()()()),m&2){let e=t.$implicit;i(),x(e.isQuick?1:-1),i(3),g(" ",e.name),i(),n("title",e.comment),i(),g(" ",e.comment)}}var o,W=(o=class{constructor(t,e,c,X){this.data=t,this._dialogRef=e,this._cdr=c,this._fb=X,this.categories$=b(H).select(P.categories),this.icon=$,this.categories=[],this.categoryForm=this._fb.group({name:this._fb.nonNullable.control(this.data?.name??"",[s.required,s.minLength(V.min),s.maxLength(Q.max)]),isQuick:this._fb.nonNullable.control(!!this.data?.isQuick),parentId:this._fb.control(this.data?.parentId??null),comment:this._fb.nonNullable.control(this.data?.comment??"",s.maxLength(q.max))})}ngOnInit(){this._dialogRef.submitData$$.next(this.categoryForm),this._initSubs()}_initSubs(){this.categories$.pipe(h(this)).subscribe(t=>{this.categories=this._filterOutCurrentCategory(t)}),this._dialogRef.instance?.submitted.pipe(h(this)).subscribe(()=>this._cdr.markForCheck())}_filterOutCurrentCategory(t){return this.data?.id?t.filter(e=>e.id!==this.data?.id).map(e=>_(C({},e),{children:this._filterOutCurrentCategory(e.children)})):t}},o.\u0275fac=function(e){return new(e||o)(l(O),l(M),l(T),l(w))},o.\u0275cmp=y({type:o,selectors:[["tis-upsert-category-dialog"]],decls:13,vars:21,consts:[["treeViewItemTmpl",""],[3,"formGroup"],["formControlName","name","token","name",3,"label","placeholder"],["formControlName","parentId","token","parentId",3,"options","label","placeholder"],["formControlName","comment","token","comment",3,"minHeight","label"],["formControlName","isQuick",3,"label"],[1,"tree-view-item"],[1,"icon-star",3,"icon"],[1,"tree-view-texts"],[1,"font-b1-secondary","tree-view-comment",3,"title"]],template:function(e,c){e&1&&(p(0,"form",1),u(1,"tis-text-field",2),r(2,"translate"),r(3,"translate"),u(4,"wk-tree-input",3),r(5,"translate"),r(6,"translate"),u(7,"tis-text-area",4),r(8,"translate"),u(9,"wk-checkbox",5),r(10,"translate"),D(11,ee,7,4,"ng-template",null,0,N),d()),e&2&&(n("formGroup",c.categoryForm),i(),n("label",a(2,9,"\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438"))("placeholder",a(3,11,"\u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440: \u041E\u0432\u043E\u0449\u0438 \u0438 \u0444\u0440\u0443\u043A\u0442\u044B")),i(3),n("options",c.categories)("label",a(5,13,"\u0420\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u0441\u043A\u0430\u044F \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F"))("placeholder",a(6,15,"\u041D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E")),i(3),n("minHeight",68)("label",a(8,17,"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439")),i(2),n("label",a(10,19,"\u041E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0442\u044C \u0432 \u0431\u044B\u0441\u0442\u0440\u044B\u0445 \u0442\u043E\u0432\u0430\u0440\u0430\u0445")))},dependencies:[U,A,S,k,L,B,J,R,G,K,z,j],styles:[`.tree-view-item[_ngcontent-%COMP%]{width:100%;display:flex;gap:var(--space-horizontal-s);align-items:center}.icon-star[_ngcontent-%COMP%]{fill:var(--color-font-warning)}
/*# sourceMappingURL=upsert-category-dialog.component-4TP2JSGL.css.map */`],changeDetection:0}),o);W=v([F()],W);export{W as a};
//# sourceMappingURL=chunk-THW2RKN4.js.map
