(function(){"use strict";u8.Base.Widgets.ChoiceInput=function(t,e){this.Widget(t,$.extend({},u8.Base.Widgets.ChoiceInput.defaults,e));this._create()};u8.Base.Widgets.ChoiceInput.defaults={keyProperty:"key",textProperty:"text",itemType:"ToggleButton"};u8.Base.Widgets.ChoiceInput.makeClass({name:"ChoiceInput",deriveFrom:u8.Base.Widgets.Widget,events:["ValueChange"]});$.extend(u8.Base.Widgets.ChoiceInput.prototype,{dispose:function(){if(this._isDisposed){return}this.$(this.element).removeClass("u8-choiceinput");this.Widget_dispose()},getValue:function(){var t=this.children.at(0);if(t){var e=t.getGroupValue();return e===undefined?null:e}return this.value||null},setValue:function(t){var e=this.children.at(0);if(e){e.setGroupValue(t)}else{this.value=t}return this},setDisabled:function(t){this.disabled=t;var e=this.children;for(var i=0;i<e.size();i++){var s=e.at(i);s.setDisabled(t)}return this},getDisabled:function(){return!!this.disabled},setItems:function(t){if(!this.items&&!t){return this}this.items=t;if(this._isCreated){this.update()}return this},getItems:function(){return this.items||[]},update:function(){this._create();return this},_create:function(){this.empty();this.$(this.element).addClass("u8-choiceinput");var e=u8.services.factory.getType(this.itemType);if(!e){return}var i=t[this.itemType];if(!i){return}var s=u8.Base.Widgets.Widget.createElementHtml({type:this.itemType});var r=this.items||[];for(var n=0;n<r.size();n++){var u=r.at(n);var a=i.getOptionsForItem.call(this,{key:this._key(u),text:this._text(u)},u);a=$.extend(a,{parent:this,context:this,onGroupValueChange:this._onChildGroupValueChange.bind(this)});this.$(s).appendTo(this.element).widget(this.itemType,a)}this.setValue(this.value);delete this.value;this._isCreated=true},_onChildGroupValueChange:function(t,e){if(this._isCreated){this.raise("ValueChange")}},_key:function(t){if(typeof t=="string"){return t}return t&&this.keyProperty in t?t[this.keyProperty]:null},_text:function(t){if(typeof t=="string"){return t}return t&&t[this.textProperty]}});var t={RadioButton:{getOptionsForItem:function(t){return{label:t.text,value:t.key,groupName:"group"+this.id}}},ToggleButton:{getOptionsForItem:function(t,e){return{image:e.image,imageDecorator:this.imageDecorator,text:t.text,value:t.key,tooltip:e.tooltip,groupName:"group"+this.id}}}}})();