import{a as k}from"./chunk-VKQCXZ43.js";import{A as b,a as C,g as E,l as L}from"./chunk-I267ADJP.js";import{$a as o,$e as O,Ga as c,La as u,Mb as h,Nb as I,Ob as S,Pb as f,Qf as P,Ra as x,Sa as T,Y as d,fc as R,hg as w,ia as A,ib as m,ja as v,jb as g,ob as y,vc as N,wb as _,xb as p}from"./chunk-4JM6MIZ5.js";import{i as s}from"./chunk-QJQRWPYR.js";var D=(()=>{let a=class a{notifier;inputId;availableItems=[];placeholder;maxIndividualItems;allSelectedLabel;selectedLabel;virtualScroll=!1;selectedItemsLabel;selectedItems;constructor(e){this.notifier=e;}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(){if(!this.maxIndividualItems)return!0;let e=this.buildOutputItems();return e?!(e.length>=this.maxIndividualItems):!0;}checkMaxItems(){this.isMaxItemsValid()||(this.notifier.error(O("\xDE\xFA getur ekki vali\xF0 meira en {maxItems, plural, =1 {1 atri\xF0i} other {{maxItems} atri\xF0i}}",{maxItems:this.maxIndividualItems})),this.selectAll());}selectAll(){this.selectedItems=this.availableItems.map(e=>e.id+""),this.updateLabel();}updateLabel(){this.selectedItems&&this.availableItems&&this.selectedItems.length===this.availableItems.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;}};s(a,"\u0275fac",function(l){return new(l||a)(c(P));}),s(a,"\u0275cmp",u({type:a,selectors:[["my-select-checkbox-default-all"]],inputs:{inputId:"inputId",availableItems:"availableItems",placeholder:"placeholder",maxIndividualItems:"maxIndividualItems",allSelectedLabel:"allSelectedLabel",selectedLabel:"selectedLabel",virtualScroll:[2,"virtualScroll","virtualScroll",R]},features:[f([{provide:C,useExisting:d(()=>a),multi:!0}]),x],decls:1,vars:6,consts:[["showClear","false",3,"ngModelChange","panelHide","ngModel","availableItems","placeholder","inputId","selectedItemsLabel","virtualScroll"]],template:function(l,t){l&1&&(m(0,"my-select-checkbox",0),S("ngModelChange",function(M){return I(t.selectedItems,M)||(t.selectedItems=M),M;}),_("ngModelChange",function(){return t.onModelChange();})("panelHide",function(){return t.onPanelHide();}),g()),l&2&&(h("ngModel",t.selectedItems),o("availableItems",t.availableItems)("placeholder",t.placeholder)("inputId",t.inputId)("selectedItemsLabel",t.selectedItemsLabel)("virtualScroll",t.virtualScroll));},dependencies:[k,b,E,L],encapsulation:2}));let i=a;return i;})();function V(i,a){if(i&1){let n=y();m(0,"my-select-checkbox-default-all",1),S("ngModelChange",function(l){A(n);let t=p();return I(t.selectedLanguages,l)||(t.selectedLanguages=l),v(l);}),_("ngModelChange",function(){A(n);let l=p();return v(l.onModelChange());}),g();}if(i&2){let n=p();o("availableItems",n.availableLanguages),h("ngModel",n.selectedLanguages),o("inputId",n.inputId)("maxIndividualItems",n.maxLanguages);}}var te=(()=>{let a=class a{server;inputId;maxLanguages;selectedLanguages;availableLanguages;constructor(e){this.server=e;}ngOnInit(){this.server.getVideoLanguages().subscribe(e=>{let l=e.find(t=>t.id==="zxx");this.availableLanguages=[{label:"\xD3\xFEekkt tungum\xE1l",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);}};s(a,"\u0275fac",function(l){return new(l||a)(c(w));}),s(a,"\u0275cmp",u({type:a,selectors:[["my-select-languages"]],inputs:{inputId:"inputId",maxLanguages:"maxLanguages"},features:[f([{provide:C,useExisting:d(()=>a),multi:!0}])],decls:1,vars:1,consts:()=>{let e;e="\xD6ll tungum\xE1l";let l;l="";let t;return t="B\xE6ta vi\xF0 n\xFDju tungum\xE1li",[["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&&o("ngIf",t.availableLanguages);},dependencies:[D,b,E,L,N],encapsulation:2}));let i=a;return i;})();export{D as a,te as b};/**i18n:68865f44f2a527c44cf5136a17c76a0ff8308c2bae5c7c8d50070a5fb9847c44*///# sourceMappingURL=chunk-X4BLRUCF.js.map