text: /*! For license information please see gmodal.js.LICENSE.txt */
  !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Gmodal",[],e):"object"==typeof exports?exports.Gmodal=e():t.Gmodal=e()}("undefined"!=typeof self?self:this,(function(){return(()=>{"use strict";var t={d:(e,i)=>{for(var o in i)t.o(i,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};return(()=>{function i(){return i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},i.apply(this,arguments)}t.d(e,{default:()=>u});const o={checkScrollbar:function(){return window.innerWidth>document.documentElement.clientWidth},getScrollbarWidth:function(){var t=document.createElement("div");t.style.cssText="\n      width: 100px;\n      height: 100px;\n      overflow: scroll;\n      position: absolute;\n      top: -9999px;\n    ",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e},isVisible:function(t){if("none"===t.style.display)return!1;var e=t.getBoundingClientRect();return e&&e.width>0&&e.height>0},emulateTransitionEnd:function(t,e){void 0===e&&(e=150);var i=!1,o=this.transitionEnd();t.addEventListener(o,(function t(e){this.removeEventListener(e.type,t),i=!0})),setTimeout((function(){if(!i){var e=document.createEvent("HTMLEvents");e.initEvent(o,!1,!1),t.dispatchEvent(e)}}),e)},transitionEnd:function(){var t={transition:"transitionend",WebkitTransition:"webkitTransitionEnd",MozTransition:"mozTransitionEnd"},e=document.documentElement;for(var i in t)if(void 0!==e.style[i])return t[i];return!1},getTransitionDurationFromElement:function(t){if(!t)return 0;var e=window.getComputedStyle(t)["transition-duration"],i=window.getComputedStyle(t)["transition-delay"],o=parseFloat(e),s=parseFloat(i);return o||s?(e=e.split(",")[0],i=i.split(",")[0],1e3*(parseFloat(e)+parseFloat(i))):0},customTrigger:function(t,e,o){var s;void 0===o&&(o={}),"CustomEvent"in window&&"function"==typeof window.CustomEvent?s=new CustomEvent(t,{detail:i({},o)}):(s=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,i({},o)),e.dispatchEvent(s)},onceTransitionEnd:function(t,e,i,o){void 0===o&&(o=!1),t.addEventListener(e,(function e(s){s.target===t&&(t.removeEventListener(s.type,e,o),i.call(this,s))}),o)}};function s(){return s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},s.apply(this,arguments)}function n(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}var a="gmodal-open",r="is-shown",l="is-hidden",d="has-animate",c={stickySelectors:[],animation:!0,backdrop:!0,closeBackdrop:!0,keyboard:!0},h=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'].join(","),m=function(){function t(t,e){return void 0===e&&(e={}),!!t&&(this._modal="string"==typeof t?document.querySelector(t):t,this._modal instanceof Element&&(this._modal.instance?this._modal.instance:(this._modal.instance=this,this._modal.tabIndex="-1",this._isOpen=!1,this._isTransitiong=!1,this._settings=s({},c,e),this._transitionEndEvent=o.transitionEnd(),void this._init())))}var e,i,m=t.prototype;return m._init=function(){this._body=document.body,this._modalContainer=this._modal.querySelector(".gmodal__container"),this._modalDialog=this._modal.querySelector(".gmodal__dialog"),this._modalDismiss=Array.prototype.slice.call(this._modal.querySelectorAll('[data-gmodal="dismiss"]')),this._scrollbarWidth=0,this._settings.animation&&this._modal.classList.add(d),this._observerCallback=this._observerCallback.bind(this),this._observer=new MutationObserver(this._observerCallback),this._observer.observe(this._modalDialog,{childList:!0,subtree:!0,attributes:!0}),this._attachEvents()},m._observerCallback=function(t){var e=t[0];(e.addedNodes.length||e.removedNodes.length||"attributes"===e.type)&&this._focusable()},m._stickySelectorsArray=function(){return Array.isArray(this._settings.stickySelectors)?this._settings.stickySelectors.reduce((function(t,e){var i=Array.prototype.slice.call(document.querySelectorAll(e));return t.push.apply(t,i),t}),[]):[]},m._attachEvents=function(){var t=this;this._closeHandler=function(e){e.preventDefault(),e.stopPropagation(),t.close()},this._clickOutside=function(e){t._ignoreBackdropClick?t._ignoreBackdropClick=!1:t._modalDialog.contains(e.target)||t.close()},this._dialogMouseDown=function(){t._modal.addEventListener("mouseup",(function e(i){t._modal.removeEventListener("mouseup",e),i.target===t._modal&&(t._ignoreBackdropClick=!0)}))},this._modalDismiss.forEach((function(e){e.addEventListener("click",t._closeHandler)})),this._settings.closeBackdrop&&(this._modal.addEventListener("click",this._clickOutside),this._modalDialog.addEventListener("mousedown",this._dialogMouseDown)),this._settings.keyboard&&(this._keyHandler=this._keyHandler.bind(this),this._modal.addEventListener("keydown",this._keyHandler))},m._dettachEvents=function(){var t=this;this._settings.closeBackdrop&&(this._modal.removeEventListener("click",this._clickOutside),this._modalDialog.removeEventListener("mousedown",this._dialogMouseDown)),this._modalDismiss.forEach((function(e){e.removeEventListener("click",t._closeHandler)})),this._settings.keyboard&&this._modal.removeEventListener("keydown",this._keyHandler)},m._focusable=function(){this._focusableEls=Array.prototype.slice.call(this._modal.querySelectorAll(h)).filter((function(t){return o.isVisible(t)})),this._focusableElFirst=this._focusableEls[0],this._focusableElLast=this._focusableEls[this._focusableEls.length-1]},m._keyHandler=function(t){var e=this;switch(t.which){case 9:if(0===this._focusableEls.length){t.preventDefault();break}t.shiftKey?document.activeElement!==e._focusableElFirst&&document.activeElement!==e._modal||(t.preventDefault(),e._focusableElLast.focus()):document.activeElement===e._focusableElLast&&(t.preventDefault(),e._focusableElFirst.focus());break;case 27:t.stopPropagation(),this.close()}},m._createBackdrop=function(){var t=document.createElement("div");return t.className="gmodal-backdrop",this._settings.animation&&(t.className+=" has-animate"),document.body.appendChild(t),t},m._setScrollOffset=function(){var t=this;if(this._hasScrollbar){this._scrollbarWidth=o.getScrollbarWidth();var e=this._body.style.paddingRight,i=parseFloat(getComputedStyle(this._body).paddingRight);e&&this._body.setAttribute("data-gmodal-padding",e),this._body.style.paddingRight=i+this._scrollbarWidth+"px",this._stickySelectorsArray().forEach((function(e){var i=e.style.marginRight,o=parseFloat(getComputedStyle(e).marginRight);i&&e.setAttribute("data-gmodal-margin",i),e.style.marginRight=o+t._scrollbarWidth+"px"}))}},m._resetScrollOffset=function(){this._hasScrollbar&&(this._body.style.paddingRight=this._body.getAttribute("data-gmodal-padding")||"",this._body.removeAttribute("data-gmodal-padding"),this._stickySelectorsArray().forEach((function(t){t.style.marginRight=t.getAttribute("data-gmodal-margin")||"",t.removeAttribute("data-gmodal-margin")})))},m._adjustModal=function(){this._scrollbarWidth=o.getScrollbarWidth(),this._modal.style.overflow="hidden",this._modal.style.marginRight=this._scrollbarWidth+"px"},m._resetAdjustModal=function(){this._modal.style.overflow="",this._modal.style.marginRight=""},m._hideBackdrop=function(){var t=this;if(this._backdrop)if(this._backdrop.classList.remove(r),this._settings.animation){var e=o.getTransitionDurationFromElement(this._backdrop);o.onceTransitionEnd(this._backdrop,this._transitionEndEvent,(function(){t._backdrop.parentNode&&t._backdrop.parentNode.removeChild(t._backdrop)})),o.emulateTransitionEnd(this._backdrop,e)}else this._backdrop.parentNode&&this._backdrop.parentNode.removeChild(this._backdrop)},m._hideModal=function(){if(1===this.modalsLength&&(this._body.classList.remove(a),this._resetScrollOffset()),this._modal.style.display="",this._isTransitiong=!1,this.modalsLength){var e=t.modals[this.modalsLength-1].focusEl;setTimeout((function(){null==e||e.focus()}),0)}t.modals.pop(),this.modalsLength&&t.modals[this.modalsLength-1].item.element.classList.remove(l),this._isOpen&&o.customTrigger("gmodal:close",this._modal),this._isOpen=!1},m.open=function(){var e=this;if(this._modal&&!this._isOpen&&!this._isTransitiong){this._isOpen=!0,this._focusableSave=document.activeElement,this.modalsLength||(this._hasScrollbar=o.checkScrollbar(),this._body.classList.add(a),this._setScrollOffset(),this._settings.backdrop&&(this._backdrop=this._createBackdrop(this))),o.customTrigger("gmodal:beforeopen",this._modal),this._modal.style.display="block",this._isTransitiong=!0,this._modal.scrollTop=0,this.modalsLength&&t.modals.forEach((function(t){t.item.element.classList.add(l)})),t.modals.push({item:this._modal.instance,focusEl:this._focusableSave}),setTimeout((function(){e._backdrop&&e._backdrop.classList.add(r),e._modal.classList.add(r)}),20);var i=function(){e._isTransitiong=!1,e._focusable(),e._modal.focus(),o.customTrigger("gmodal:open",e._modal)};if(this._settings.animation){this._adjustModal();var s=o.getTransitionDurationFromElement(this._modalContainer);o.onceTransitionEnd(this._modalContainer,this._transitionEndEvent,(function(){e._resetAdjustModal(),i()})),o.emulateTransitionEnd(this._modalContainer,s)}else i()}},m.close=function(t){if(void 0===t&&(t=!1),this._modal&&this._isOpen&&!this._isTransitiong)if(o.customTrigger("gmodal:beforeclose",this._modal),this._modal.classList.remove(r),this._hideBackdrop(),this._isTransitiong=!0,this._settings.animation&&!t){var e=o.getTransitionDurationFromElement(this._modalContainer);o.onceTransitionEnd(this._modalContainer,this._transitionEndEvent,this._hideModal.bind(this)),o.emulateTransitionEnd(this._modalContainer,e)}else this._hideModal()},t.closeAll=function(){if(this.modals.length){var t=!1,e=this.modals[0].item._hasScrollbar;this.modals.slice().reverse().forEach((function(i,o){0===o?i.item._hasScrollbar=e:t=!0,i.item.close(t)}))}},m.destroy=function(){var t=this;this._modal&&(this._observer&&this._observer.disconnect(),this._backdrop&&this._backdrop.parentNode&&this._backdrop.parentNode.removeChild(this._backdrop),this._hideModal(),this._modal.classList.remove(d,r),this._dettachEvents(),delete this._modal.instance,Object.keys(this).forEach((function(e){delete t[e]})))},e=t,(i=[{key:"element",get:function(){return this._modal}},{key:"modalsLength",get:function(){return t.modals.length}}])&&n(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();m.modals=[];const u=m})(),e.default})()}));