text: JRS.Controls=function(e,t,i){function n(e){if(t.isArray(e)){var i=t.filter(e,function(e){return e.selected});return t.map(i,function(e){return e.id||""===e.id?e:e.value})}return e}return t.extend(i,{BaseControl:i.Base.extend({id:null,elem:null,error:null,templateChunks:{},constructor:function(){this.initialize.apply(this,arguments)},getElem:function(){return this.elem},setElem:function(e){this.elem=e},bindCustomEventListeners:function(){},isSingleSelect:function(){return!t.isArray(this.get("selection"))},isSingleValue:function(){return!t.isArray(this.get("values"))},getTemplateSection:function(e){return this.templateChunks[this.type+"_"+e]||(this.templateChunks[this.type+"_"+e]=i.TemplateEngine.createTemplateSection(e,this.type)),this.templateChunks[this.type+"_"+e]},initialize:function(e){this.baseRender(e),this.isVisible(e)&&this.bindCustomEventListeners()},fireControlSelectionChangeEvent:function(t){e(document).trigger(i.CHANGE_CONTROL,this,t)},baseRender:function(n){n&&t.extend(this,n);var s=i.TemplateEngine.createTemplate(this.type);if(s){var r=e(s(this));this.setElem(r)}},update:function(){},get:function(e){return this[e]},isValid:function(){return null===this.error||this.error&&this.error instanceof String&&0===this.error.length},isVisible:function(e){return!e||void 0==e.visible||e.visible===!0},updateWarningMessage:function(){var e=null!=this.error?this.error:"";this.getElem()&&this.getElem().find(".warning").text(e)},refresh:function(){var e=this.get("values"),t=this.get("selection");e=this.isSingleValue()?t:i.BaseControl.merge(e,t),this.values=e,this.initialize(this),this.isVisible(this)&&this.update(e)},set:function(e,i){if(t.extend(this,e),void 0!==e.values&&(this.isVisible(this)&&this.update(e.values),this.selection=this.isSingleValue()?e.values:this.isSingleSelect()?n(e.values)[0]:n(e.values)),void 0!==e.selection&&(this.isSingleValue()&&(this.values=e.selection),!i&&this.fireControlSelectionChangeEvent()),void 0!==e.disabled&&!this.get("readOnly")){var s=e.disabled;i||(s?this.disable():this.enable())}void 0!==e.error&&this.updateWarningMessage()},find:function(e){if(void 0!==e&&e&&"object"==typeof e){var i=t.keys(e)[0],n=t.values(e)[0];return t.find(this.get("values"),function(e){return e[i]===n})}},enable:function(){this.getElem().find("input").prop("disabled",!1),this.getElem().find("select").prop("disabled",!1)},disable:function(){this.getElem().find("input").prop("disabled",!0),this.getElem().find("select").prop("disabled",!0)}},{merge:function(e,i){return t.isNull(e)||t.isUndefined(e)?i:t.isNull(i)||t.isUndefined(i)?e:t.isArray(i)?t.map(e,function(e){var n=t.find(i,function(t){return t===e.value});return void 0!=n?e.selected=!0:delete e.selected,e}):this.merge(e,[i])}}),CHANGE_CONTROL:"changed:control"})}(jQuery,_,JRS.Controls);