import{a as J}from"./chunk-YC7GTVSG.js";import{f as P,s as Q,w as V}from"./chunk-QIDUJNWO.js";import{b as z}from"./chunk-KSOO7RKS.js";import{a as R}from"./chunk-JTYOM5WI.js";import{b as H}from"./chunk-7DOUXWOI.js";import{m as j}from"./chunk-3VQS547U.js";import{a as $,b as q}from"./chunk-QV3XX5C6.js";import{B,E as L,Fa as w,G as U,Oa as G,Pa as M,cb as O,p,r as T,s as k,w as A,y as S}from"./chunk-JTDXTMDS.js";import{a as F,b as h}from"./chunk-NSGLSIBS.js";import{$c as I,Ab as b,Ac as f,Cc as g,Fb as d,Tb as o,Wc as n,Xc as r,Zb as E,cc as l,dc as c,ec as a,gd as N,ka as D,mb as i,pc as x,rb as m}from"./chunk-QMYHTLAJ.js";import{d as y,n as X}from"./chunk-HE7HQ6LI.js";import{a as _,b as v}from"./chunk-K4ALXBGI.js";X();function Y(u,t){if(u&1&&a(0,"tis-svg",7),u&2){let e=x(2);o("icon",e.icon.Star)}}function Z(u,t){if(u&1&&(l(0,"div",6),d(1,Y,1,1,"tis-svg",7),l(2,"div",8)(3,"span"),f(4),c(),l(5,"span",9),f(6),c()()()),u&2){let e=t.$implicit;i(),E(e.isQuick?1:-1),i(3),g(" ",e.name,""),i(),o("title",e.comment),i(),g(" ",e.comment,"")}}var K=class C{constructor(t,e,s,W){this.data=t,this._dialogRef=e,this._cdr=s,this._fb=W,this.categories$=D(j).select(H.categories),this.icon=$,this.categories=[],this.categoryForm=this._fb.group({name:this._fb.nonNullable.control(this.data?.name??"",[p.required,p.minLength(Q.min),p.maxLength(P.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??"",p.maxLength(V.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=>v(_({},e),{children:this._filterOutCurrentCategory(e.children)})):t}static{this.\u0275fac=function(e){return new(e||C)(m(M),m(G),m(N),m(L))}}static{this.\u0275cmp=b({type:C,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,s){e&1&&(l(0,"form",1),a(1,"tis-text-field",2),n(2,"translate"),n(3,"translate"),a(4,"wk-tree-input",3),n(5,"translate"),n(6,"translate"),a(7,"tis-text-area",4),n(8,"translate"),a(9,"wk-checkbox",5),n(10,"translate"),d(11,Z,7,4,"ng-template",null,0,I),c()),e&2&&(o("formGroup",s.categoryForm),i(),o("label",r(2,9,"\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438"))("placeholder",r(3,11,"\u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440: \u041E\u0432\u043E\u0449\u0438 \u0438 \u0444\u0440\u0443\u043A\u0442\u044B")),i(3),o("options",s.categories)("label",r(5,13,"\u0420\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u0441\u043A\u0430\u044F \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F"))("placeholder",r(6,15,"\u041D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E")),i(3),o("minHeight",68)("label",r(8,17,"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439")),i(2),o("label",r(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,T,k,S,B,z,O,w,J,q,R],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)}"],changeDetection:0})}};K=y([F()],K);export{K as a};
