function gsurveySetUpLikertFields(){0<jQuery("table.gsurvey-likert").length&&(jQuery("table.gsurvey-likert").find('td.gsurvey-likert-choice, input[type="radio"]').click(function(e){var r=jQuery(this),r=r.is("td.gsurvey-likert-choice")?r.find("input"):r;if(r.is(":disabled"))return!1;r.prop("checked",!0),r.closest("tr").find(".gsurvey-likert-selected").removeClass("gsurvey-likert-selected"),r.parent().addClass("gsurvey-likert-selected"),r.focus().change()}),jQuery("table.gsurvey-likert td").hover(function(e){if(jQuery(e.target).is("td.gsurvey-likert-choice-label")||jQuery(this).find("input").is(":disabled"))return!1;jQuery(this).addClass("gsurvey-likert-hover")},function(e){if(jQuery(e.target).is("td.gsurvey-likert-choice-label")||jQuery(this).find("input").is(":disabled"))return!1;jQuery(this).removeClass("gsurvey-likert-hover")}),jQuery('table.gsurvey-likert input[type="radio"]').focus(function(){jQuery(this).parent().addClass("gsurvey-likert-focus")}).blur(function(){jQuery(this).parent().removeClass("gsurvey-likert-focus")}))}function gsurveyRankUpdateRank(e){var r,t=[];jQuery(e).find("li").each(function(){t.push(this.id)}),gsurveyRankings[e.id]=t,jQuery(e).parent().find("#"+e.id+"-hidden").val(gsurveyRankings[e.id]),window.gf_form_conditional_logic&&(e=e.id.split("-"),r=parseInt(e[e.length-2]),e=parseInt(e[e.length-1]),e=rgars(gf_form_conditional_logic,[r,"fields",e].join("/")))&&gf_apply_rules(r,e)}function gsurveyRankMoveChoice(e,r,t){var i=jQuery(e).attr("id"),n=gsurveyRankings[i][r];gsurveyRankings[i].splice(r,1),gsurveyRankings[i].splice(t,0,n),gsurveyRankUpdateRank(e)}function gsurveySetUpRankSortable(){var e=jQuery(".gsurvey-rank");0<e.length&&(e.sortable({axis:"y",cursor:"move",update:function(e,r){gsurveyRankMoveChoice(this,r.item.data("index"),r.item.index())}}),gsurveyRankings={},jQuery(".gsurvey-rank").each(function(){gsurveyRankUpdateRank(this)}))}function init_fields(){gsurveySetUpRankSortable(),gsurveySetUpLikertFields()}function extractFieldId(e){var r=/^choice_(\d+)_(\d+)_(\d+)_(\d+)$/;return r.test(e)?e.match(r)[2]:null}function gf_is_match_rank(e,r,t,i){jQuery;var[n,u]=r.fieldId.split("."),u=u||0,e=e[0].querySelector("li."+(`choice_${t}_${n}_`+u));if(e){var s=Array.from(e.parentElement.children).indexOf(e)+1,a=parseInt(r.value);switch(r.value||(a=1),r.operator){case"is":return s===a;case"isnot":return s!==a;case">":return a<s;case"<":return s<a;default:return console.error("Invalid operator"),!1}}return!1}jQuery(document).on("gform_post_render",function(){init_fields()}),jQuery(function(e){e("#gform_update_button").length&&init_fields()}),gform.addFilter("gform_field_meta_raw_input_change",function(e,r,t){return r[0].attributes.value&&/^glikert/.test(r[0].attributes.value.value)&&(r=extractFieldId(r[0].attributes.id.value))&&(e.fieldId=r),e}),gform.addFilter("gform_is_value_match",function(e,r,t){var i=jQuery,n=t.fieldId,u=gformExtractFieldId(n),n=gformExtractInputIndex(n);return"function"!=typeof String.prototype.gformFormat?e:($inputs=i('input[id^="choice_{0}_{1}_{2}"]'.gformFormat(r,u,n))).length?(""==t.value&&(t.value=$inputs[0].defaultValue),gf_is_match_checkable($inputs,t,r,u)):($inputs=i('ul[id^="gsurvey-rank-{0}-{1}"]'.gformFormat(r,u,n))).length?gf_is_match_rank($inputs,t,r,u):e});