/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */ !function(){"use strict";var t=window.dsfr,e={MODAL:t.internals.ns.selector("modal"),SCROLL_DIVIDER:t.internals.ns.selector("scroll-divider"),BODY:t.internals.ns.selector("modal__body"),TITLE:t.internals.ns.selector("modal__title")},i=function(e){function i(){e.call(this,t.core.DisclosureType.OPENED)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"ModalButton"},Object.defineProperties(i,n),i}(t.core.DisclosureButton),n={CONCEALING_BACKDROP:t.internals.ns.attr("concealing-backdrop")},o=function(o){function s(){o.call(this,t.core.DisclosureType.OPENED,e.MODAL,i,"ModalsGroup"),this._isActive=!1,this.scrolling=this.resize.bind(this,!1),this.resizing=this.resize.bind(this,!0)}o&&(s.__proto__=o),s.prototype=Object.create(o&&o.prototype),s.prototype.constructor=s;var r={body:{configurable:!0},isDialog:{configurable:!0}},a={instanceClassName:{configurable:!0}};return a.instanceClassName.get=function(){return"Modal"},s.prototype.init=function(){o.prototype.init.call(this),this._isDialog="DIALOG"===this.node.tagName,this.isScrolling=!1,this.listenClick(),this.addEmission(t.core.RootEmission.KEYDOWN,this._keydown.bind(this))},s.prototype._keydown=function(e){if(e===t.core.KeyCodes.ESCAPE)this._escape()},s.prototype._escape=function(){switch(document.activeElement?document.activeElement.tagName:void 0){case"INPUT":case"LABEL":case"TEXTAREA":case"SELECT":case"AUDIO":case"VIDEO":break;default:this.isDisclosed&&(this.conceal(),this.focus())}},s.prototype.retrieved=function(){this._ensureAccessibleName()},r.body.get=function(){return this.element.getDescendantInstances("ModalBody","Modal")[0]},s.prototype.handleClick=function(t){t.target===this.node&&"false"!==this.getAttribute(n.CONCEALING_BACKDROP)&&this.conceal()},s.prototype.disclose=function(t){return!!o.prototype.disclose.call(this,t)&&(this.body&&this.body.activate(),this.isScrollLocked=!0,this.setAttribute("aria-modal","true"),this.setAttribute("open","true"),this._isDialog||this.activateModal(),!0)},s.prototype.conceal=function(t,e){return!!o.prototype.conceal.call(this,t,e)&&(this.isScrollLocked=!1,this.removeAttribute("aria-modal"),this.removeAttribute("open"),this.body&&this.body.deactivate(),this._isDialog||this.deactivateModal(),!0)},r.isDialog.get=function(){return this._isDialog},r.isDialog.set=function(t){this._isDialog=t},s.prototype.activateModal=function(){this._isActive||(this._isActive=!0,this._hasDialogRole="dialog"===this.getAttribute("role"),this._hasDialogRole||this.setAttribute("role","dialog"))},s.prototype.deactivateModal=function(){this._isActive&&(this._isActive=!1,this._hasDialogRole||this.removeAttribute("role"))},s.prototype._setAccessibleName=function(t,e){var i=this.retrieveNodeId(t,e);this.warn("add reference to "+e+" for accessible name (aria-labelledby)"),this.setAttribute("aria-labelledby",i)},s.prototype._ensureAccessibleName=function(){if(!this.hasAttribute("aria-labelledby")&&!this.hasAttribute("aria-label")){this.warn("missing accessible name");var t=this.node.querySelector(e.TITLE),i=this.primaryButtons[0];switch(!0){case null!==t:this._setAccessibleName(t,"title");break;case void 0!==i:this.warn("missing required title, fallback to primary button"),this._setAccessibleName(i,"primary")}}},Object.defineProperties(s.prototype,r),Object.defineProperties(s,a),s}(t.core.Disclosure),s=['[tabindex="0"]',"a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details","iframe"].join(),r=['[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'].join(),a=function(t,e){if(!(t instanceof Element))return!1;var i=window.getComputedStyle(t);if(!i)return!1;if("hidden"===i.visibility)return!1;for(void 0===e&&(e=t);e.contains(t);){if("none"===i.display)return!1;t=t.parentElement}return!0},l=function(t,e){this.element=null,this.activeElement=null,this.onTrap=t,this.onUntrap=e,this.waiting=this.wait.bind(this),this.handling=this.handle.bind(this),this.focusing=this.maintainFocus.bind(this),this.current=null},c={trapped:{configurable:!0},focusables:{configurable:!0}};c.trapped.get=function(){return null!==this.element},l.prototype.trap=function(t){this.trapped&&this.untrap(),this.element=t,this.isTrapping=!0,this.wait(),this.onTrap&&this.onTrap()},l.prototype.wait=function(){a(this.element)?this.trapping():window.requestAnimationFrame(this.waiting)},l.prototype.trapping=function(){if(this.isTrapping){this.isTrapping=!1;var t=this.focusables;t.length&&-1===t.indexOf(document.activeElement)&&t[0].focus(),this.element.setAttribute("aria-modal",!0),window.addEventListener("keydown",this.handling),document.body.addEventListener("focus",this.focusing,!0)}},l.prototype.stun=function(t){for(var e=0,i=t.children;e0||e[o-1].tabIndex>0)&&(t.preventDefault(),e[o-1].focus()):this.element.contains(document.activeElement)&&o!==e.length-1&&-1!==o?document.activeElement.tabIndex>0&&(t.preventDefault(),e[o+1].focus()):(t.preventDefault(),i.focus())}}},c.focusables.get=function(){var e=this,i=t.internals.dom.querySelectorAllArray(this.element,s),n=t.internals.dom.querySelectorAllArray(document.documentElement,'input[type="radio"]');if(n.length){for(var o={},l=0,c=n;lthis.node.clientHeight?this.node.offsetHeight+this.node.scrollTop>=this.node.scrollHeight?this.removeClass(e.SCROLL_DIVIDER):this.addClass(e.SCROLL_DIVIDER):this.removeClass(e.SCROLL_DIVIDER)},n.prototype.resize=function(){this.adjust(),this.request(this.adjust.bind(this))},n.prototype.adjust=function(){var e=32*(this.isBreakpoint(t.core.Breakpoints.MD)?2:1);this.isLegacy?this.style.maxHeight=window.innerHeight-e+"px":this.style.setProperty("--modal-max-height",window.innerHeight-e+"px"),this.divide()},Object.defineProperties(n,o),n}(t.core.Instance);t.modal={Modal:o,ModalButton:i,ModalBody:p,ModalsGroup:d,ModalSelector:e},t.internals.register(t.modal.ModalSelector.MODAL,t.modal.Modal),t.internals.register(t.modal.ModalSelector.BODY,t.modal.ModalBody),t.internals.register(t.core.RootSelector.ROOT,t.modal.ModalsGroup)}(); //# sourceMappingURL=modal.nomodule.min.js.map