import{a as k}from"./chunk-ZKAVIEXX.js";import{B as M,a as E,g as L,m as b}from"./chunk-HYHNBP3O.js";import{Db as p,Eb as h,Fc as N,Sa as m,Wb as S,Xb as f,Xf as P,Y as c,Yb as I,Za as T,Zb as C,ba as u,gb as r,ha as v,ia as x,pb as g,pc as R,pf as O,qb as _,ta as n,ug as w,vb as y}from"./chunk-7W5IJG57.js";import{i as o}from"./chunk-RB5FWREQ.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("\u60A8\u7121\u6CD5\u9078\u53D6\u591A\u65BC {maxItems, plural, =1 {1 \u500B\u9805\u76EE} other {{maxItems} \u500B\u9805\u76EE}}",{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:"\u672A\u77E5\u7684\u8A9E\u8A00",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="\u6240\u6709\u8A9E\u8A00";let l;l="\u5DF2\u9078\u53D6 ";let t;return t="\u52A0\u5165\u65B0\u8A9E\u8A00",[["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:3558f4fa3a6acf6a8a484a0589828971efacd00f9f89386e64ec00a5fc269cc5*///# sourceMappingURL=chunk-3MMX7BWE.js.map