import{c as G}from"./chunk-FCLJQZXD.js";import{C as M,a as L,g as E,n as b}from"./chunk-AWFGIQSJ.js";import{Cb as p,Db as h,Gh as D,Ic as O,Rc as P,Sa as m,Wb as S,X as u,Xb as f,Ya as y,Yb as I,aa as c,ac as C,eb as r,eh as k,ga as T,ha as v,ia as x,ob as g,pb as _,ta as n,tc as N,ub as R,yg as w}from"./chunk-GKQGDBUU.js";import{i as o}from"./chunk-QVFSZZWQ.js";var H=(()=>{let a=class a{notifier=c(k);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:N});selectedItemsLabel;selectedItems;propagateChange=e=>{};writeValue(e){if(e){this.selectedItems=e,this.updateLabel();return;}this.selectAll();}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}ngOnChanges(){this.updateLabel();}onModelChange(){this.updateLabel(),this.isMaxItemsValid()&&this.propagateChange(this.buildOutputItems());}onPanelHide(){Array.isArray(this.selectedItems)&&this.selectedItems.length===0&&this.selectAll(),this.checkMaxItemsOrSelectAll();}isMaxItemsValid(){let e=this.maxIndividualItems();if(!e)return!0;let l=this.buildOutputItems();return l?!(l.length>=e):!0;}checkMaxItemsOrSelectAll(){this.isMaxItemsValid()||(this.notifier.error(w("You can't select more than {maxItems, plural, =1 {1 item} other {{maxItems} items}}",{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:L,useExisting:u(()=>a),multi:!0}]),T],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:[G,M,E,b],encapsulation:2}));let i=a;return i;})();function $(i,a){if(i&1){let s=R();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 ae=(()=>{let a=class a{server=c(D);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:"Unknown language",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:L,useExisting:u(()=>a),multi:!0}])],decls:1,vars:1,consts:()=>{let e;e="All languages";let l;l="";let t;return t="Add a new language",[["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&&y(0,$,1,4,"my-select-checkbox-default-all",0),l&2&&r("ngIf",t.availableLanguages);},dependencies:[H,M,E,b,P,O],encapsulation:2}));let i=a;return i;})();export{H as a,ae as b};/**i18n:42345378061bf3c93df67acfa161b751a7b03cc91f3ede7c1f1cdf2bba62fe26*///# sourceMappingURL=chunk-X2ED62BI.js.map