import{a as k}from"./chunk-WPRQ5SGB.js";import{t as x}from"./chunk-TL6VKVO7.js";import{f as b}from"./chunk-RCWJCOBH.js";import{$a as Q,Fa as L,Ma as $}from"./chunk-NKXT7PF4.js";import{Ac as D,Bc as T,Db as y,Xc as E,Yb as M,_b as I,bc as N,cc as A,dc as c,ec as p,fc as d,lb as S,nc as _,pd as m,tc as h,td as g,ua as s,ud as w,va as a,vc as u,zc as F}from"./chunk-I3FGJX2C.js";var O=["dropdown"],U=()=>[];function H(o,n){if(o&1){let r=_();p(0,"wk-dropdown",4,0),h("changed",function(t){s(r);let e=u();return a(e.changedSelection(t))}),d()}if(o&2){let r=u();c("value",r.dropdownValue())("multiple",r.isMultiple())("dataSource",r.item().dataSource)("displayFieldName",r.item().displayExpr??"name")("enableSearch",!0)("highlightSelectedItems",!1)("showClearButton",!1)("placeholder",r.item().label)("emptyMessage",r.emptyMessage)("label","")}}function G(o,n){if(o&1){let r=_();p(0,"wk-dropdown",5,0),h("changed",function(t){s(r);let e=u();return a(e.changedSelection(t))}),d()}if(o&2){let r=u();c("value",r.dropdownValue())("multiple",r.isMultiple())("options",r.item().options??E(10,U))("displayFieldName",r.displayFieldName)("enableSearch",!0)("highlightSelectedItems",!1)("showClearButton",!1)("placeholder",r.item().label)("emptyMessage",r.emptyMessage)("label","")}}var B=(()=>{let n=class n{constructor(){this.item=w.required(),this.selectionChanged=g(),this.displayFieldName="label",this.emptyMessage="\u041D\u0435\u0442 \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u043E\u0432",this.icons=b,this.isDataSourceMode=m(()=>!!this.item().dataSource),this.isMultiple=m(()=>this.item().multiple??!0),this.isActive=m(()=>this.item().selectedIds.length>0),this.dropdownValue=m(()=>{let{selectedIds:i}=this.item();return this.isMultiple()?i:i[0]??null}),this.chipLabel=m(()=>{let{label:i,selectedIds:t,options:e,selectedLabels:l,dataSource:C}=this.item();if(!t.length)return i;if(C)return l?.[0]??i;let v=e?.find(R=>R.id===t[0])?.label??i;return t.length===1?v:`${i} +${t.length}`})}openDropdown(){this._dropdown?.open()}clearSelection(){this._dropdown?.close(),this.selectionChanged.emit({key:this.item().key,ids:[]})}changedSelection(i){let t=Array.isArray(i)?i.map(String):i?[String(i)]:[],e;if(this.isDataSourceMode()&&t.length&&this._dropdown){let l=this.item().displayExpr??"name";e=this._dropdown.selectedOptions().map(f=>String(f[l]??"")).filter(Boolean)}this.selectionChanged.emit({key:this.item().key,ids:t,labels:e})}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=y({type:n,selectors:[["bs-select-filter-chip"]],viewQuery:function(t,e){if(t&1&&F(O,5),t&2){let l;D(l=T())&&(e._dropdown=l.first)}},hostAttrs:[1,"bs-select-filter-chip"],inputs:{item:[1,"item"]},outputs:{selectionChanged:"selectionChanged"},decls:3,vars:4,consts:[["dropdown",""],["variant","tertiary","size","small",3,"clicked","arrowClicked","rightIconClicked","label","arrow","rightIcon"],["size","small",3,"value","multiple","dataSource","displayFieldName","enableSearch","highlightSelectedItems","showClearButton","placeholder","emptyMessage","label"],["size","small",3,"value","multiple","options","displayFieldName","enableSearch","highlightSelectedItems","showClearButton","placeholder","emptyMessage","label"],["size","small",3,"changed","value","multiple","dataSource","displayFieldName","enableSearch","highlightSelectedItems","showClearButton","placeholder","emptyMessage","label"],["size","small",3,"changed","value","multiple","options","displayFieldName","enableSearch","highlightSelectedItems","showClearButton","placeholder","emptyMessage","label"]],template:function(t,e){t&1&&(p(0,"tis-chips",1),h("clicked",function(){return e.openDropdown()})("arrowClicked",function(){return e.openDropdown()})("rightIconClicked",function(){return e.clearSelection()}),d(),M(1,H,2,10,"wk-dropdown",2)(2,G,2,11,"wk-dropdown",3)),t&2&&(c("label",e.chipLabel())("arrow",!0)("rightIcon",e.isActive()?e.icons.Cross:null),S(),I(e.isDataSourceMode()?1:2))},dependencies:[$,k],styles:[`.bs-select-filter-chip{position:relative;display:inline-flex}.bs-select-filter-chip wk-dropdown{position:absolute;bottom:0;left:0;visibility:hidden;pointer-events:none;margin-bottom:0}.wk-popover__content wk-list-item{width:100%!important}
/*# sourceMappingURL=select-filter-chip.component-QXSGFMVI.css.map */
`],encapsulation:2,changeDetection:0});let o=n;return o})();var J=["datePicker"],P=(()=>{let n=class n{constructor(){this.item=w.required(),this.selectionChanged=g(),this.icons=b,this.isActive=m(()=>!!this.item().dateFrom||!!this.item().dateTo),this.isSingle=m(()=>this.item().pickerType==="default"),this.datePickerValue=m(()=>this.isSingle()?this.item().dateFrom??this.item().dateTo:[this.item().dateFrom,this.item().dateTo]),this.chipLabel=m(()=>{let{label:i,dateFrom:t,dateTo:e,format:l}=this.item();if(!t&&!e)return i;let C=l==="time"?"HH:mm":"dd.MM.yyyy",f=t?x(t,C):null,v=e?x(e,C):null;return this.isSingle()?`${i}: ${f??v}`:f&&v?`${f} - ${v}`:`${i}: ${f??v}`})}openDatePicker(){this._datePicker.activeComponent?.instance?.open?.()}clearSelection(){this.selectionChanged.emit({key:this.item().key,dateFrom:null,dateTo:null})}changedDate(i){if(this.isSingle()){let t=Array.isArray(i)?i[0]??null:i??null;this.selectionChanged.emit({key:this.item().key,dateFrom:t,dateTo:null});return}Array.isArray(i)&&this.selectionChanged.emit({key:this.item().key,dateFrom:i[0]??null,dateTo:i[1]??null})}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=y({type:n,selectors:[["bs-date-filter-chip"]],viewQuery:function(t,e){if(t&1&&F(J,5),t&2){let l;D(l=T())&&(e._datePicker=l.first)}},hostAttrs:[1,"bs-date-filter-chip"],inputs:{item:[1,"item"]},outputs:{selectionChanged:"selectionChanged"},decls:3,vars:9,consts:[["datePicker",""],["variant","tertiary","size","small",3,"clicked","arrowClicked","rightIconClicked","label","arrow","rightIcon"],["applyValueModeInput","instantly",3,"changed","type","value","format","minDate","maxDate","label"]],template:function(t,e){if(t&1){let l=_();p(0,"tis-chips",1),h("clicked",function(){return s(l),a(e.openDatePicker())})("arrowClicked",function(){return s(l),a(e.openDatePicker())})("rightIconClicked",function(){return s(l),a(e.clearSelection())}),d(),p(1,"wk-date-picker",2,0),h("changed",function(f){return s(l),a(e.changedDate(f))}),d()}t&2&&(c("label",e.chipLabel())("arrow",!0)("rightIcon",e.isActive()?e.icons.Cross:null),S(),c("type",e.isSingle()?"default":"range")("value",e.datePickerValue())("format",e.item().format??"date")("minDate",e.item().minDate??void 0)("maxDate",e.item().maxDate??void 0)("label",""))},dependencies:[L,k],styles:[`.bs-date-filter-chip{position:relative;display:inline-flex}.bs-date-filter-chip wk-date-picker{position:absolute;bottom:0;left:0;visibility:hidden;pointer-events:none;margin-bottom:0}
/*# sourceMappingURL=date-filter-chip.component-BSCMEQO4.css.map */
`],encapsulation:2,changeDetection:0});let o=n;return o})();var W=["treeInput"],z=(()=>{let n=class n{constructor(){this.item=w.required(),this.selectionChanged=g(),this.icons=b,this.isActive=m(()=>this.item().selectedIds.length>0),this.chipLabel=m(()=>{let{label:i,selectedIds:t,options:e}=this.item();return t.length?t.length===1?this._findInTree(e,t[0])?.name??i:`${i} +${t.length}`:i})}openTree(){this._treeInput.open()}clearSelection(){this.selectionChanged.emit({key:this.item().key,ids:[]})}changedSelection(i){let t=Array.isArray(i)?i:i!=null?[i]:[];this.selectionChanged.emit({key:this.item().key,ids:t})}_findInTree(i,t){for(let e of i){if(e.id===t)return e;if(e.children?.length){let l=this._findInTree(e.children,t);if(l)return l}}return null}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=y({type:n,selectors:[["bs-tree-filter-chip"]],viewQuery:function(t,e){if(t&1&&F(W,5),t&2){let l;D(l=T())&&(e._treeInput=l.first)}},hostAttrs:[1,"bs-tree-filter-chip"],inputs:{item:[1,"item"]},outputs:{selectionChanged:"selectionChanged"},decls:3,vars:10,consts:[["treeInput",""],["variant","tertiary","size","small",3,"clicked","arrowClicked","rightIconClicked","label","arrow","rightIcon"],[3,"changed","options","value","openSelectedTree","label","multiple","searchInput","showClearButton"]],template:function(t,e){if(t&1){let l=_();p(0,"tis-chips",1),h("clicked",function(){return s(l),a(e.openTree())})("arrowClicked",function(){return s(l),a(e.openTree())})("rightIconClicked",function(){return s(l),a(e.clearSelection())}),d(),p(1,"wk-tree-input",2,0),h("changed",function(f){return s(l),a(e.changedSelection(f))}),d()}t&2&&(c("label",e.chipLabel())("arrow",!0)("rightIcon",e.isActive()?e.icons.Cross:null),S(),c("options",e.item().options)("value",e.item().selectedIds)("openSelectedTree",!0)("label","")("multiple",!0)("searchInput",!0)("showClearButton",!1))},dependencies:[Q,k],styles:[`.bs-tree-filter-chip{position:relative;display:inline-flex}.bs-tree-filter-chip wk-tree-input{position:absolute;bottom:0;left:0;visibility:hidden;pointer-events:none;margin-bottom:0}
/*# sourceMappingURL=tree-filter-chip.component-TSLSNZLO.css.map */
`],encapsulation:2,changeDetection:0});let o=n;return o})();var q=(()=>{let n=class n{constructor(){this.item=w.required(),this.selectionChanged=g(),this.icons=b}clear(){this.selectionChanged.emit({key:this.item().key,value:!1})}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=y({type:n,selectors:[["bs-boolean-filter-chip"]],inputs:{item:[1,"item"]},outputs:{selectionChanged:"selectionChanged"},decls:1,vars:2,consts:[["variant","tertiary","size","small",3,"rightIconClicked","label","rightIcon"]],template:function(t,e){t&1&&(p(0,"tis-chips",0),h("rightIconClicked",function(){return e.clear()}),d()),t&2&&c("label",e.item().label)("rightIcon",e.icons.Cross)},dependencies:[k],encapsulation:2,changeDetection:0});let o=n;return o})();var X=(o,n)=>n.key;function Y(o,n){if(o&1){let r=_();p(0,"bs-select-filter-chip",1),h("selectionChanged",function(t){s(r);let e=u(2);return a(e.handleSelectChanged(t))}),d()}if(o&2){let r=u().$implicit;c("item",r)}}function Z(o,n){if(o&1){let r=_();p(0,"bs-date-filter-chip",1),h("selectionChanged",function(t){s(r);let e=u(2);return a(e.handleDateChanged(t))}),d()}if(o&2){let r=u().$implicit;c("item",r)}}function j(o,n){if(o&1){let r=_();p(0,"bs-tree-filter-chip",1),h("selectionChanged",function(t){s(r);let e=u(2);return a(e.handleTreeChanged(t))}),d()}if(o&2){let r=u().$implicit;c("item",r)}}function K(o,n){if(o&1){let r=_();p(0,"bs-boolean-filter-chip",1),h("selectionChanged",function(t){s(r);let e=u(2);return a(e.handleBooleanChanged(t))}),d()}if(o&2){let r=u().$implicit;c("item",r)}}function ee(o,n){if(o&1&&M(0,Y,1,1,"bs-select-filter-chip",0)(1,Z,1,1,"bs-date-filter-chip",0)(2,j,1,1,"bs-tree-filter-chip",0)(3,K,1,1,"bs-boolean-filter-chip",0),o&2){let r=n.$implicit;I(r.type==="select"?0:r.type==="date"?1:r.type==="tree"?2:r.type==="boolean"?3:-1)}}var Re=(()=>{let n=class n{constructor(){this.items=w([]),this.selectChanged=g(),this.dateChanged=g(),this.treeChanged=g(),this.booleanChanged=g(),this.visibleItems=m(()=>this.items().filter(i=>{switch(i.type){case"date":return!!i.dateFrom||!!i.dateTo;case"select":return i.selectedIds.length>0;case"tree":return i.selectedIds.length>0;case"boolean":return i.value;default:return!1}}))}handleSelectChanged(i){this.selectChanged.emit(i)}handleDateChanged(i){this.dateChanged.emit(i)}handleTreeChanged(i){this.treeChanged.emit(i)}handleBooleanChanged(i){this.booleanChanged.emit(i)}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=y({type:n,selectors:[["bs-filter-chips-container"]],inputs:{items:[1,"items"]},outputs:{selectChanged:"selectChanged",dateChanged:"dateChanged",treeChanged:"treeChanged",booleanChanged:"booleanChanged"},decls:2,vars:0,consts:[[3,"item"],[3,"selectionChanged","item"]],template:function(t,e){t&1&&N(0,ee,4,1,null,null,X),t&2&&A(e.visibleItems())},dependencies:[B,P,z,q],styles:[`[_nghost-%COMP%]{display:flex;flex-wrap:wrap;gap:var(--space-horizontal-s);width:100%;margin-bottom:12px}
/*# sourceMappingURL=filter-chips-container.component-YI2H4JWQ.css.map */`],changeDetection:0});let o=n;return o})();export{Re as a};
//# sourceMappingURL=chunk-ZUBKTMG4.js.map
