import{a as J}from"./chunk-J6LAIIRO.js";import{f as Q,s as V,w as q}from"./chunk-QIDUJNWO.js";import{a as P,f as z}from"./chunk-GPCBDOQR.js";import{b as j}from"./chunk-MO5UALXZ.js";import{m as R}from"./chunk-SOETE4NY.js";import{a as H,b as $}from"./chunk-XS5S3HQB.js";import{$a as O,B,E as L,Fa as w,G as U,Oa as G,Pa as M,p,r as T,s as k,w as A,y as S}from"./chunk-D2E2EQ56.js";import{a as F,b as h}from"./chunk-XVWHZ5TH.js";import{$c as I,Bb as b,Bc as f,Dc as g,Gb as d,Ub as o,Wc as n,Xc as r,_b as E,dc as l,ec as c,fc as a,gd as N,la as D,nb as i,qc as x,sb as m}from"./chunk-LEOKSAW2.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(R).select(j.categories),this.icon=H,this.categories=[],this.categoryForm=this._fb.group({name:this._fb.nonNullable.control(this.data?.name??"",[p.required,p.minLength(V.min),p.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??"",p.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=>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,$,P],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};
