var blossomcoach=blossomcoach||{};function blossomcoachDomReady(e){if("function"==typeof e)return"interactive"===document.readyState||"complete"===document.readyState?e():void document.addEventListener("DOMContentLoaded",e,!1)}function blossomcoachToggleAttribute(e,t,o,n){void 0===o&&(o=!0),void 0===n&&(n=!1),e.getAttribute(t)!==o?e.setAttribute(t,o):e.setAttribute(t,n)}function blossomcoachFindParents(e,t){var o=[];return function e(n){var a=n.parentNode;a instanceof HTMLElement&&(a.matches(t)&&o.push(a),e(a))}(e),o}blossomcoach.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!1),t},blossomcoach.coverModals={init:function(){document.querySelector(".cover-modal")&&(this.onToggle(),this.closeOnEscape(),this.hideAndShowModals(),this.keepFocusInModal())},onToggle:function(){document.querySelectorAll(".cover-modal").forEach(function(e){e.addEventListener("toggled",function(e){var t=e.target,o=document.body;t.classList.contains("active")?o.classList.add("showing-modal"):(o.classList.remove("showing-modal"),o.classList.add("hiding-modal"),setTimeout(function(){o.classList.remove("hiding-modal")},500))})})},closeOnEscape:function(){document.addEventListener("keydown",function(e){27===e.keyCode&&(e.preventDefault(),document.querySelectorAll(".cover-modal.active").forEach(function(e){this.untoggleModal(e)}.bind(this)))}.bind(this))},hideAndShowModals:function(){var e=document,t=window,o=e.querySelectorAll(".cover-modal"),n=e.documentElement.style,a=e.querySelector("#wpadminbar");function c(e){var o,n=t.pageYOffset;return a?(o=n+a.getBoundingClientRect().height,e?-o:o):0===n?0:-n}function s(){return{"overflow-y":t.innerHeight>e.documentElement.getBoundingClientRect().height?"hidden":"scroll",position:"fixed",width:"100%",top:c(!0)+"px",left:0}}o.forEach(function(o){o.addEventListener("toggle-target-before-inactive",function(l){var i=s(),r=t.pageYOffset,d=Math.abs(c())-r+"px",u=t.matchMedia("(max-width: 600px)");l.target===o&&(Object.keys(i).forEach(function(e){n.setProperty(e,i[e])}),t.blossomcoach.scrolled=parseInt(i.top,10),a&&(e.body.style.setProperty("padding-top",d),u.matches&&(r>=c()?o.style.setProperty("top",0):o.style.setProperty("top",c()-r+"px"))),o.classList.add("show-modal"))}),o.addEventListener("toggle-target-after-inactive",function(l){l.target===o&&setTimeout(function(){var l=blossomcoach.toggles.clickedEl;o.classList.remove("show-modal"),Object.keys(s()).forEach(function(e){n.removeProperty(e)}),a&&(e.body.style.removeProperty("padding-top"),o.style.removeProperty("top")),!1!==l&&(l.focus(),l=!1),t.scrollTo(0,Math.abs(t.blossomcoach.scrolled+c())),t.blossomcoach.scrolled=0},500)})})},untoggleModal:function(e){var t,o=!1;e.dataset.modalTargetString&&(t=e.dataset.modalTargetString,o=document.querySelector('*[data-toggle-target="'+t+'"]')),o?o.click():e.classList.remove("active")},keepFocusInModal:function(){var e=document;e.addEventListener("keydown",function(t){var o,n,a,c,s,l,i,r,d,u,g=blossomcoach.toggles.clickedEl;g&&e.body.classList.contains("showing-modal")&&(o=g.dataset.toggleTarget,"input, a, button",n=e.querySelector(o),a=n.querySelectorAll("input, a, button"),a=Array.prototype.slice.call(a),".menu-modal"===o&&(c=(c=window.matchMedia("(min-width: 768px)").matches)?".expanded-menu":".mobile-menu",(a=a.filter(function(e){return null!==e.closest(c)&&null!==e.offsetParent})).unshift(e.querySelector(".close-nav-toggle")),(s=e.querySelector(".menu-bottom > nav"))&&s.querySelectorAll("input, a, button").forEach(function(e){a.push(e)})),".main-menu-modal"===o&&(c=(c=window.matchMedia("(min-width: 1025px)").matches)?".expanded-menu":".mobile-menu",(a=a.filter(function(e){return null!==e.closest(c)&&null!==e.offsetParent})).unshift(e.querySelector(".close-main-nav-toggle")),(s=e.querySelector(".menu-bottom > nav"))&&s.querySelectorAll("input, a, button").forEach(function(e){a.push(e)})),i=a[a.length-1],r=a[0],l=e.activeElement,d=9===t.keyCode,!(u=t.shiftKey)&&d&&i===l&&(t.preventDefault(),r.focus()),u&&d&&r===l&&(t.preventDefault(),i.focus()))})}},blossomcoach.modalMenu={init:function(){this.expandLevel()},expandLevel:function(){document.querySelectorAll(".modal-menu").forEach(function(e){var t=e.querySelector(".current-menu-item");t&&blossomcoachFindParents(t,"li").forEach(function(e){var t=e.querySelector(".submenu-toggle");t&&blossomcoach.toggles.performToggle(t,!0)})})}},blossomcoach.toggles={clickedEl:!1,init:function(){this.toggle()},performToggle:function(e,t){var o,n,a,c=this,s=document,l=e,i=l.dataset.toggleTarget;s.querySelectorAll(".show-modal").length||(c.clickedEl=s.activeElement),(o="next"===i?l.nextSibling:s.querySelector(i)).classList.contains("active")?o.dispatchEvent(blossomcoach.createEvent("toggle-target-before-active")):o.dispatchEvent(blossomcoach.createEvent("toggle-target-before-inactive")),a=l.dataset.classToToggle?l.dataset.classToToggle:"active",n=0,o.classList.contains("cover-modal")&&(n=10),setTimeout(function(){var e,n=o.classList.contains("sub-menu")?l.closest(".menu-item").querySelector(".sub-menu"):o,r=l.dataset.toggleDuration;"slidetoggle"!==l.dataset.toggleType||t||"0"===r?n.classList.toggle(a):blossomcoachMenuToggle(n,r),"next"===i?l.classList.toggle("active"):o.classList.contains("sub-menu")?l.classList.toggle("active"):s.querySelector('*[data-toggle-target="'+i+'"]').classList.toggle("active"),blossomcoachToggleAttribute(l,"aria-expanded","true","false"),c.clickedEl&&-1!==l.getAttribute("class").indexOf("close-")&&blossomcoachToggleAttribute(c.clickedEl,"aria-expanded","true","false"),l.dataset.toggleBodyClass&&s.body.classList.toggle(l.dataset.toggleBodyClass),l.dataset.setFocus&&(e=s.querySelector(l.dataset.setFocus))&&(o.classList.contains("active")?e.focus():e.blur()),o.dispatchEvent(blossomcoach.createEvent("toggled")),o.classList.contains("active")?o.dispatchEvent(blossomcoach.createEvent("toggle-target-after-active")):o.dispatchEvent(blossomcoach.createEvent("toggle-target-after-inactive"))},n)},toggle:function(){var e=this;document.querySelectorAll("*[data-toggle-target]").forEach(function(t){t.addEventListener("click",function(o){o.preventDefault(),e.performToggle(t)})})}},blossomcoachDomReady(function(){blossomcoach.toggles.init(),blossomcoach.coverModals.init()});