(function(){"use strict";u8.Crm.Widgets.TargetGroupsAndSegmentPopup=function(e,t){$.extend(this,u8.Crm.Widgets.TargetGroupsAndSegmentPopup.defaults,t);this.commandBindings={RefreshLyrisSegmentContacts:this._onCommandRefreshLyrisSegmentContacts.bind(this)};this.WidgetContainer();this.element=e;this.$=$w(e).$;this.id=u8.Base.Dom.uniqueId();this._popup=null;if(this.parent&&this.parent.children){this.parent.children.add(this)}this.bind()};u8.Crm.Widgets.TargetGroupsAndSegmentPopup.makeClass({name:"TargetGroupsAndSegmentPopup",deriveFrom:u8.Base.Widgets.WidgetContainer,events:[]});u8.Crm.Widgets.TargetGroupsAndSegmentPopup.defaults={popup:{size:{width:.8,height:.8}}};$.extend(u8.Crm.Widgets.TargetGroupsAndSegmentPopup.prototype,{open:function(){u8.using({texts:["Campaign_Designer"]},function(){var e=$.extend(this.popup,{autoShow:false,parent:this,onCreate:this._onPopupCreate.bind(this),onClose:this._onPopupClose.bind(this),title:"TXT_Campaign_Designer_208"});var t=$("<div/>");this._popup=new u8.Base.Widgets.Popup(t,e);this._popup.open()}.bind(this))},dispose:function(){if(this._isDisposed){return}this.unbind();this._popup=null;this.WidgetContainer_dispose();if(this.parent&&this.parent.children){this.parent.children.remove(this.id)}},setValue:function(e){this.model=e||null},getValue:function(){return this.model},_onPopupCreate:function(e,t){var n=e.getContent();this._form=new u8.Base.Widgets.Form(n,{formName:"TargetGroupsAndSegment",parent:this.popup,context:this._createBindingContext()});this._popup.autoSizeAndPosition().show()},_onPopupClose:function(){this.dispose()},_createBindingContext:function(){var e=new u8.Base.Model({properties:{fixedFieldValues:this.model.fixedFieldValues,link:this.model.link}});return e},_onCommandRefreshLyrisSegmentContacts:function(){u8.services.lyris.refreshSegmentContacts(this.model.link);var e=function e(t){if(!t){return null}var n;for(n=0;n<t.size();++n){var i=t.at(n);if(i){if(i.name&&i.name==="EG.Designer.Readonly.LyrisEnabled"){return i}i=e(i.children);if(i){return i}}}return null}(this._form.children);if(e==null){return}e.execute()}})})();