function setupSelectDropdown(){var n=document.querySelectorAll(".select-dropdown-container");Array.prototype.slice.call(n).forEach(function(n){var t=n.querySelector(".select-dropdown-value"),i=n.querySelector(".select-dropdown-options"),r=n.querySelector(".select-dropdown");r.addEventListener("click",function(){n.classList.toggle("open")});r.addEventListener("keydown",function(t){var s=t.keyCode||t.which,r,e,o;switch(s){case 13:n.classList.contains("open")?(r=n.querySelector(".select-dropdown-options > li.visiting"),r==null&&(r=n.querySelector(".select-dropdown-options > li.selected")),u(r),n.classList.remove("open")):n.classList.toggle("open");break;case 27:n.classList.remove("open");break;case 38:r=n.querySelector(".select-dropdown-options > li.visiting");r==null&&(r=n.querySelector(".select-dropdown-options > li.selected"));r.classList.remove("visiting");e=r.previousElementSibling!=null?r.previousElementSibling:r;e.classList.add("visiting");i.scrollTop=e.offsetTop-50;t.stopPropagation();t.preventDefault();break;case 40:n.classList.contains("open")||n.classList.toggle("open");r=n.querySelector(".select-dropdown-options > li.visiting");r==null&&(r=n.querySelector(".select-dropdown-options > li.selected"));r==null&&(r=n.querySelector(".select-dropdown-options > li:first-of-type"),r.classList.add("selected"));r.classList.remove("visiting");e=r.nextElementSibling!=null?r.nextElementSibling:r;e.classList.add("visiting");i.scrollTop=e.offsetTop-50;t.stopPropagation();t.preventDefault();break;case 9:n.classList.remove("open");for(o of f)o.classList.remove("visiting")}});var u=function(i,r){var u,h,o,s;for(u of f)u.classList.remove("selected"),u.classList.remove("visiting");h=i.attributes;for(o of h)t.setAttribute(o.name,o.value);t.value=i.getAttribute("data-value");r||t.dispatchEvent(new Event("change"));n.classList.remove("open");i.classList.add("selected");s=i.querySelector("a");s!=null&&s.dispatchEvent(new Event("click",{bubbles:!1}));e.innerHTML=i.getAttribute("data-text")||i.innerHTML},e=r.querySelector(".select-dropdown-text"),o=i.querySelectorAll("li"),f=Array.prototype.slice.call(o);f.forEach(function(t){t.addEventListener("click",function(){u(t);methodist.analytics.pushEvent("component_cta_clicked",{component:{interaction_item:"dropdown: "+n.getAttribute("data-name"),sc_item_id:n.getAttribute("data-id"),sc_rendering_id:n.getAttribute("data-rendering"),sc_component_name:n.getAttribute("data-name"),sc_component_cta_label:e.innerText}})});t.getAttribute("data-pre-selected")==="true"&&u(t,t.getAttribute("data-pre-selected-omit")==="true");t.removeAttribute("data-pre-selected")})});document.addEventListener("click",function(t){Array.prototype.slice.call(n).forEach(function(n){n.contains(t.target)||n.classList.remove("open")})})}document.readyState!=="loading"?setupSelectDropdown():document.addEventListener("DOMContentLoaded",setupSelectDropdown)