var GF_CONDITIONAL_INSTANCE=!1,GF_CONDITIONAL_INSTANCES_COLLECTION=[],FOCUSABLE_ELEMENTS=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],TAB_KEY=9,ESCAPE_KEY=27,FOCUSED_BEFORE_DIALOG=null,FOCUSED_BEFORE_RENDER=null;function setFocusToFirstItem(t,e){e&&e.target&&!gform.tools.getClosest(e.target,"#"+t.id)||(e=getFocusableChildren(t)).length&&e[0].focus()}function getFocusableChildren(t){return $$(FOCUSABLE_ELEMENTS.join(","),t).filter(function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)})}function trapTabKey(t,e){var t=getFocusableChildren(t),i=t.indexOf(document.activeElement);e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault())}function $$(t,e){return gform.tools.convertElements((e||document).querySelectorAll(t))}function renderView(t,e,i,o){FOCUSED_BEFORE_RENDER=document.activeElement;var n,s=t;for(n in i)var l=i[n],a=new RegExp("{{ "+n+" }}","g"),s=s.replace(a,l);return o?(e.innerHTML=s,FOCUSED_BEFORE_RENDER.id&&window.setTimeout(function(){null!=document.getElementById(FOCUSED_BEFORE_RENDER.id)&&document.getElementById(FOCUSED_BEFORE_RENDER.id).focus()},10),!0):s}function getFieldById(e){var t=this.form.fields.filter(function(t){return t.id==e});return!!t.length&&t[0]}function getCorrectDefaultFieldId(t){var e;return t?("checkbox"!==t.type&&"radio"!==t.type&&"checkbox"!==t.inputType&&"radio"!==t.inputType&&t.inputs&&t.inputs.length&&(e=t.inputs.filter(function(t){return!t.isHidden})).length?e[0]:t).id:null}function getOptionsFromSelect(t,e){var i=[],o=gf_vars.emptyChoice,o={label:o=t.placeholder?t.placeholder:o,value:"",selected:""===e?'selected="selected"':""};i.push(o);for(var n=0;n"].indexOf(t.operator)}function GFConditionalLogic(t,e){this.fieldId=t,this.form=form,this.objectType=e,this.els=this.gatherElements(),this.state=this.getStateForField(t),this.visible=!1,this._handleToggleClick=this.handleToggleClick.bind(this),this._handleFlyoutChange=this.handleFlyoutChange.bind(this),this._handleBodyClick=this.handleBodyClick.bind(this),this._handleAccordionClick=this.handleAccordionClick.bind(this),this._handleSidebarClick=this.handleSidebarClick.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.init()}GFConditionalLogic.prototype.renderSidebar=function(){var t={title:this.getAccordionTitle(),toggleText:gf_vars.configure+" "+gf_vars.conditional_logic_text,active_class:this.isEnabled()?"gform-status--active":"",active_text:this.isEnabled()?"Active":"Inactive",desc_class:GetFirstRuleField()<=0?"active":"",toggle_class:GetFirstRuleField()<=0?"":"active",desc:gf_vars.conditionalLogic.conditionalLogicHelperText};renderView(gf_vars.conditionalLogic.views.sidebar,this.els[this.objectType],t,!0)},GFConditionalLogic.prototype.renderFlyout=function(){var t={objectType:this.objectType,fieldId:this.fieldId,checked:this.state.enabled?"checked":"",activeClass:this.visible?"active":"inactive",enabledText:this.state.enabled?gf_vars.enabled:gf_vars.disabled,configure:gf_vars.configure,conditionalLogic:gf_vars.conditional_logic_text,enable:gf_vars.enable,desc:gf_vars.conditional_logic_desc,main:this.renderMainControls(!1)};renderView(gf_vars.conditionalLogic.views.flyout,this.els.flyouts[this.objectType],t,!0),gform.tools.trigger("gform_render_simplebars")},GFConditionalLogic.prototype.renderLogicDescription=function(){var t={actionType:this.state.actionType,logicType:this.state.logicType,objectTypeText:this.getObjectTypeText(),objectShowText:this.getObjectShowText(),objectHideText:this.getObjectHideText(),matchText:gf_vars.ofTheFollowingMatch,allText:gf_vars.all,anyText:gf_vars.any,hideSelected:"hide"===this.state.actionType?'selected="selected"':"",showSelected:"show"===this.state.actionType?'selected="selected"':"",allSelected:"all"===this.state.logicType?'selected="selected"':"",anySelected:"any"===this.state.logicType?'selected="selected"':""},t=renderView(gf_vars.conditionalLogic.views.logicDescription,this.els.flyouts[this.objectType],t,!1);return gform.applyFilters("gform_conditional_logic_description",t,[],this.objectType,this)},GFConditionalLogic.prototype.renderMainControls=function(t){var e={enabledClass:this.state.enabled?"active":"",logicDescription:this.renderLogicDescription(),a11yWarning:"button"===this.objectType?gf_vars.conditionalLogic.views.a11yWarning:"",a11yWarningText:gf_vars.conditional_logic_a11y},i=gf_vars.conditionalLogic.views.main;if(!t)return renderView(i,this.els.flyouts[this.objectType],e,!1);renderView(i,this.els.flyouts[this.objectType].querySelector(".conditional_logic_flyout__main"),e,!0)},GFConditionalLogic.prototype.renderFieldOptions=function(t){for(var e="",i=gf_vars.conditionalLogic.views.option,o=[],n=0;n":gf_vars.greaterThan,"<":gf_vars.lessThan,contains:gf_vars.contains,starts_with:gf_vars.startsWith,ends_with:gf_vars.endsWith};for(key in o=gform.applyFilters("gform_conditional_logic_operators",o,this.objectType,t.fieldId))e+=renderView(i,null,{label:o[key],value:key,selected:key==t.operator?'selected="selected"':""},!1);return e},GFConditionalLogic.prototype.renderValueOptions=function(t,e){var i=getFieldById(t.fieldId),o="",n=gf_vars.conditionalLogic.views.option,s=[];if((i=-1!==t.fieldId.toString().indexOf(".")?getFieldById(t.fieldId.toString().split(".")[0]):i)||IsAddressSelect(t.fieldId,i)){IsAddressSelect(t.fieldId,i)&&(s=getAddressOptions(i,t.fieldId,t.value)),i&&"post_category"==i.type&&i.displayAllCategories&&(s=getCategoryOptions(i,t.value)),i&&i.choices&&"post_category"!=i.type&&(s=getOptionsFromSelect(i,t.value));for(var l=0;l