import{a as k}from"./chunk-ZI33XDIM.js";import{B as M,a as E,g as L,m as b}from"./chunk-EKD65OAZ.js";import{Ab as p,Bb as h,Cc as N,Ra as m,Tb as S,Ub as f,Vb as I,Wb as C,Wf as P,X as c,Xa as T,aa as u,db as r,ga as v,ha as x,mb as g,nb as _,nc as R,of as O,sa as n,sb as y,wg as w}from"./chunk-XBTZE2EC.js";import{i as o}from"./chunk-WHYNGVB3.js";var D=(()=>{let a=class a{notifier=u(P);inputId=n.required();availableItems=n([]);placeholder=n(void 0);maxIndividualItems=n(void 0);allSelectedLabel=n(void 0);selectedLabel=n(void 0);virtualScroll=n(!1,{transform:R});selectedItemsLabel;selectedItems;propagateChange=e=>{};writeValue(e){e?this.selectedItems=e:this.selectAll();}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}onModelChange(){this.updateLabel(),this.isMaxItemsValid()&&this.propagateChange(this.buildOutputItems());}onPanelHide(){Array.isArray(this.selectedItems)&&this.selectedItems.length===0&&this.selectAll(),this.checkMaxItems();}isMaxItemsValid(){let e=this.maxIndividualItems();if(!e)return!0;let l=this.buildOutputItems();return l?!(l.length>=e):!0;}checkMaxItems(){this.isMaxItemsValid()||(this.notifier.error(O("Nem\xF4\u017Eete vybra\u0165 viac ne\u017E {maxItems, plural, =1 {1 polo\u017Eku} other {{maxItems} polo\u017Eiek}}",{maxItems:this.maxIndividualItems()})),this.selectAll());}selectAll(){this.selectedItems=this.availableItems().map(e=>e.id+""),this.updateLabel();}updateLabel(){let e=this.availableItems();this.selectedItems&&e&&this.selectedItems.length===e.length?this.selectedItemsLabel=this.allSelectedLabel():this.selectedItemsLabel=this.selectedLabel();}buildOutputItems(){if(Array.isArray(this.selectedItems))return this.selectedItems.length===0||this.selectedItems.length===this.availableItems().length?null:this.selectedItems;}};o(a,"\u0275fac",function(l){return new(l||a)();}),o(a,"\u0275cmp",m({type:a,selectors:[["my-select-checkbox-default-all"]],inputs:{inputId:[1,"inputId"],availableItems:[1,"availableItems"],placeholder:[1,"placeholder"],maxIndividualItems:[1,"maxIndividualItems"],allSelectedLabel:[1,"allSelectedLabel"],selectedLabel:[1,"selectedLabel"],virtualScroll:[1,"virtualScroll"]},features:[C([{provide:E,useExisting:c(()=>a),multi:!0}])],decls:1,vars:6,consts:[["showClear","false","showToggleAll","true",3,"ngModelChange","panelHide","ngModel","availableItems","placeholder","inputId","selectedItemsLabel","virtualScroll"]],template:function(l,t){l&1&&(g(0,"my-select-checkbox",0),I("ngModelChange",function(A){return f(t.selectedItems,A)||(t.selectedItems=A),A;}),p("ngModelChange",function(){return t.onModelChange();})("panelHide",function(){return t.onPanelHide();}),_()),l&2&&(S("ngModel",t.selectedItems),r("availableItems",t.availableItems())("placeholder",t.placeholder())("inputId",t.inputId())("selectedItemsLabel",t.selectedItemsLabel)("virtualScroll",t.virtualScroll()));},dependencies:[k,M,L,b],encapsulation:2}));let i=a;return i;})();function V(i,a){if(i&1){let s=y();g(0,"my-select-checkbox-default-all",1),I("ngModelChange",function(l){v(s);let t=h();return f(t.selectedLanguages,l)||(t.selectedLanguages=l),x(l);}),p("ngModelChange",function(){v(s);let l=h();return x(l.onModelChange());}),_();}if(i&2){let s=h();r("availableItems",s.availableLanguages),S("ngModel",s.selectedLanguages),r("inputId",s.inputId())("maxIndividualItems",s.maxLanguages());}}var ee=(()=>{let a=class a{server=u(w);inputId=n.required();maxLanguages=n(void 0);selectedLanguages;availableLanguages;ngOnInit(){this.server.getVideoLanguages().subscribe(e=>{let l=e.find(t=>t.id==="zxx");this.availableLanguages=[{label:"Nezn\xE1my jazyk",id:"_unknown"},l,...e.filter(t=>t.id!=="zxx").map(t=>({label:t.label,id:t.id}))];});}propagateChange=e=>{};writeValue(e){this.selectedLanguages=e;}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}onModelChange(){this.propagateChange(this.selectedLanguages);}};o(a,"\u0275fac",function(l){return new(l||a)();}),o(a,"\u0275cmp",m({type:a,selectors:[["my-select-languages"]],inputs:{inputId:[1,"inputId"],maxLanguages:[1,"maxLanguages"]},features:[C([{provide:E,useExisting:c(()=>a),multi:!0}])],decls:1,vars:1,consts:()=>{let e;e="V\u0161etky jazyky";let l;l="";let t;return t="Prida\u0165 nov\xFD jazyk",[["virtualScroll","true","virtualScrollItemSize","37","allSelectedLabel",e,"selectedLabel",l,"placeholder",t,3,"availableItems","ngModel","inputId","maxIndividualItems","ngModelChange",4,"ngIf"],["virtualScroll","true","virtualScrollItemSize","37","allSelectedLabel",e,"selectedLabel",l,"placeholder",t,3,"ngModelChange","availableItems","ngModel","inputId","maxIndividualItems"]];},template:function(l,t){l&1&&T(0,V,1,4,"my-select-checkbox-default-all",0),l&2&&r("ngIf",t.availableLanguages);},dependencies:[D,M,L,b,N],encapsulation:2}));let i=a;return i;})();export{D as a,ee as b};/**i18n:56bde403ffba090cdb11aaac0f86ffb9ae7c2bab95df4b44d5dba510264fcf4f*///# sourceMappingURL=chunk-YWPWXCFC.js.map