"use strict";define(["app","handlebars","View","../../CommonControls/Localization/Views/SelectLanguageView","text!/v2/webapps/FirstAccess/AdminSettings/Templates/LanguagesTemplate.html","utils"],function(e,g,f,c,b,a){var d=f.extend({languagesTemplate:g.compile(b),events:{},initialize:function(h){f.prototype.initialize.apply(this,arguments);this.options=h||{};this.selectLanguageView=new c({ignoreLanguage:true});this.selectLanguageView.onChangeLanguage=_.bind(function(i){this.defaultLanguage=i;},this);},render:function(m,l,j){if(!l){l=[j];}this.checked=l;this.defaultLanguage=j;var n=$.map(m,function(p){return{langCd:p,name:"adminsetting.languagesView.language."+p,checked:l!==null?l.indexOf(p)!==-1:false};});this.$el.html(this.languagesTemplate({languages:n}));var o=this.$el.find("input[type=checkbox]");var k=this.$el;var i=this;var h=function(){var q=i.checked;var s=$(this);var p=s.val();var r=_.find(q,function(t){return t===p;});if(r){q=_(q).filter(function(t){return t!==p;});}else{q.push(p);}q.sort();if(q.length>0&&q.indexOf(i.defaultLanguage)===-1){i.defaultLanguage=q[0];}i.checked=q;i.selectLanguageView.render(q,i.defaultLanguage,function(t){return a.localize(i,["adminsetting.languagesView.language."+t]);});k.find("#selectLanguage").html(i.selectLanguageView.$el);};o.change(h);this.checked=this.checked.slice(0);this.checked.sort();this.selectLanguageView.render(this.checked,j,function(p){return a.localize(i,["adminsetting.languagesView.language."+p]);});this.$el.find("#selectLanguage").html(this.selectLanguageView.$el);return this;}});return d;});