text: !function(){function e(e){for(;e;){if("DIALOG"==e.nodeName.toUpperCase())return e;e=e.parentElement}return null}function t(e){e&&e.blur&&e!=document.body&&e.blur()}function o(e,t){for(var o=0;o<e.length;++o)if(e[o]==t)return!0;return!1}function i(e){if(this.dialog_=e,this.replacedStyleTop_=!1,this.openAsModal_=!1,e.hasAttribute("role")||e.setAttribute("role","dialog"),e.show=this.show.bind(this),e.showModal=this.showModal.bind(this),e.close=this.close.bind(this),"returnValue"in e||(e.returnValue=""),this.maybeHideModal=this.maybeHideModal.bind(this),"MutationObserver"in window){var t=new MutationObserver(this.maybeHideModal);t.observe(e,{attributes:!0,attributeFilter:["open"]})}else e.addEventListener("DOMAttrModified",this.maybeHideModal);Object.defineProperty(e,"open",{set:this.setOpen.bind(this),get:e.hasAttribute.bind(e,"open")}),this.backdrop_=document.createElement("div"),this.backdrop_.className="backdrop",this.backdropClick_=this.backdropClick_.bind(this)}var n=window.CustomEvent;n&&"object"!=typeof n||(n=function(e,t){t=t||{};var o=document.createEvent("CustomEvent");return o.initCustomEvent(e,!!t.bubbles,!!t.cancelable,t.detail||null),o},n.prototype=window.Event.prototype),i.prototype={get dialog(){return this.dialog_},maybeHideModal:function(){this.openAsModal_&&(this.dialog_.hasAttribute("open")&&document.body.contains(this.dialog_)||(this.openAsModal_=!1,this.dialog_.style.zIndex="",this.replacedStyleTop_&&(this.dialog_.style.top="",this.replacedStyleTop_=!1),this.backdrop_.removeEventListener("click",this.backdropClick_),this.backdrop_.parentElement&&this.backdrop_.parentElement.removeChild(this.backdrop_),a.dm.removeDialog(this)))},setOpen:function(e){e?this.dialog_.hasAttribute("open")||this.dialog_.setAttribute("open",""):(this.dialog_.removeAttribute("open"),this.maybeHideModal())},backdropClick_:function(e){var t=document.createEvent("MouseEvents");t.initMouseEvent(e.type,e.bubbles,e.cancelable,window,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget),this.dialog_.dispatchEvent(t),e.stopPropagation()},focus_:function(){var e=this.dialog_.querySelector("[autofocus]:not([disabled])");if(!e){var o=["button","input","keygen","select","textarea"],i=o.map(function(e){return e+":not([disabled])"});i.push('[tabindex]:not([disabled]):not([tabindex=""])'),e=this.dialog_.querySelector(i.join(", "))}t(document.activeElement),e&&e.focus()},updateZIndex:function(e,t){this.backdrop_.style.zIndex=e,this.dialog_.style.zIndex=t},show:function(){this.dialog_.open||(this.setOpen(!0),this.focus_())},showModal:function(){if(this.dialog_.hasAttribute("open"))throw new Error("Failed to execute 'showModal' on dialog: The element is already open, and therefore cannot be opened modally.");if(!document.body.contains(this.dialog_))throw new Error("Failed to execute 'showModal' on dialog: The element is not in a Document.");if(!a.dm.pushDialog(this))throw new Error("Failed to execute 'showModal' on dialog: There are too many open modal dialogs.");this.show(),this.openAsModal_=!0,a.needsCentering(this.dialog_)?(a.reposition(this.dialog_),this.replacedStyleTop_=!0):this.replacedStyleTop_=!1,this.backdrop_.addEventListener("click",this.backdropClick_),this.dialog_.parentNode.insertBefore(this.backdrop_,this.dialog_.nextSibling)},close:function(e){if(!this.dialog_.hasAttribute("open"))throw new Error("Failed to execute 'close' on dialog: The element does not have an 'open' attribute, and therefore cannot be closed.");this.setOpen(!1),void 0!==e&&(this.dialog_.returnValue=e);var t=new n("close",{bubbles:!1,cancelable:!1});this.dialog_.dispatchEvent(t)}};var a={};a.reposition=function(e){var t=document.body.scrollTop||document.documentElement.scrollTop,o=t+(window.innerHeight-e.offsetHeight)/2;e.style.top=Math.max(t,o)+"px"},a.isInlinePositionSetByStylesheet=function(e){for(var t=0;t<document.styleSheets.length;++t){var i=document.styleSheets[t],n=null;try{n=i.cssRules}catch(e){}if(n)for(var a=0;a<n.length;++a){var l=n[a],r=null;try{r=document.querySelectorAll(l.selectorText)}catch(e){}if(r&&o(r,e)){var s=l.style.getPropertyValue("top"),d=l.style.getPropertyValue("bottom");if(s&&"auto"!=s||d&&"auto"!=d)return!0}}}return!1},a.needsCentering=function(e){var t=window.getComputedStyle(e);return"absolute"==t.position&&(!("auto"!=e.style.top&&""!=e.style.top||"auto"!=e.style.bottom&&""!=e.style.bottom)&&!a.isInlinePositionSetByStylesheet(e))},a.forceRegisterDialog=function(e){if(e.showModal&&console.warn("This browser already supports <dialog>, the polyfill may not work correctly",e),"DIALOG"!=e.nodeName.toUpperCase())throw new Error("Failed to register dialog: The element is not a dialog.");new i(e)},a.registerDialog=function(e){e.showModal||a.forceRegisterDialog(e)},a.DialogManager=function(){this.pendingDialogStack=[],this.overlay=document.createElement("div"),this.overlay.className="_dialog_overlay",this.overlay.addEventListener("click",function(e){e.stopPropagation()}),this.handleKey_=this.handleKey_.bind(this),this.handleFocus_=this.handleFocus_.bind(this),this.handleRemove_=this.handleRemove_.bind(this),this.zIndexLow_=1e5,this.zIndexHigh_=100150},a.DialogManager.prototype.topDialogElement=function(){if(this.pendingDialogStack.length){var e=this.pendingDialogStack[this.pendingDialogStack.length-1];return e.dialog}return null},a.DialogManager.prototype.blockDocument=function(){document.body.appendChild(this.overlay),document.body.addEventListener("focus",this.handleFocus_,!0),document.addEventListener("keydown",this.handleKey_),document.addEventListener("DOMNodeRemoved",this.handleRemove_)},a.DialogManager.prototype.unblockDocument=function(){document.body.removeChild(this.overlay),document.body.removeEventListener("focus",this.handleFocus_,!0),document.removeEventListener("keydown",this.handleKey_),document.removeEventListener("DOMNodeRemoved",this.handleRemove_)},a.DialogManager.prototype.updateStacking=function(){for(var e=this.zIndexLow_,t=0;t<this.pendingDialogStack.length;t++)t==this.pendingDialogStack.length-1&&(this.overlay.style.zIndex=e++),this.pendingDialogStack[t].updateZIndex(e++,e++)},a.DialogManager.prototype.handleFocus_=function(o){var i=e(o.target);if(i!=this.topDialogElement())return o.preventDefault(),o.stopPropagation(),t(o.target),!1},a.DialogManager.prototype.handleKey_=function(e){if(27==e.keyCode){e.preventDefault(),e.stopPropagation();var t=new n("cancel",{bubbles:!1,cancelable:!0}),o=this.topDialogElement();o.dispatchEvent(t)&&o.close()}},a.DialogManager.prototype.handleRemove_=function(e){if("DIALOG"==e.target.nodeName.toUpperCase()){var t=e.target;t.open&&this.pendingDialogStack.some(function(e){if(e.dialog==t)return e.maybeHideModal(),!0})}},a.DialogManager.prototype.pushDialog=function(e){var t=(this.zIndexHigh_-this.zIndexLow_)/2-1;return!(this.pendingDialogStack.length>=t)&&(this.pendingDialogStack.push(e),1==this.pendingDialogStack.length&&this.blockDocument(),this.updateStacking(),!0)},a.DialogManager.prototype.removeDialog=function(e){var t=this.pendingDialogStack.indexOf(e);t!=-1&&(this.pendingDialogStack.splice(t,1),this.updateStacking(),0==this.pendingDialogStack.length&&this.unblockDocument())},a.dm=new a.DialogManager,document.addEventListener("submit",function(t){var o=t.target;if(o&&o.hasAttribute("method")&&"dialog"==o.getAttribute("method").toLowerCase()){t.preventDefault();var i=e(t.target);if(i){var n,a=[document.activeElement,t.explicitOriginalTarget],l=["BUTTON","INPUT"];a.some(function(e){if(e&&e.form==t.target&&l.indexOf(e.nodeName.toUpperCase())!=-1)return n=e.value,!0}),i.close(n)}}},!0),a.forceRegisterDialog=a.forceRegisterDialog,a.registerDialog=a.registerDialog,"function"==typeof define&&"amd"in define?define(function(){return a}):"object"==typeof module&&"object"==typeof module.exports?module.exports=a:window.dialogPolyfill=a}();
  //# sourceMappingURL=dialog-polyfill.min.js.map