Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

focus-trap

Package Overview
Dependencies
Maintainers
0
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

focus-trap - npm Package Compare versions

Comparing version 7.6.1 to 7.6.2

6

CHANGELOG.md
# Changelog
## 7.6.2
### Patch Changes
- d4a4c34: Replace findIndex with native implementation - [Closes #1305](https://github.com/focus-trap/focus-trap/issues/1305
## 7.6.1

@@ -4,0 +10,0 @@

20

dist/focus-trap.esm.js
/*!
* focus-trap 7.6.1
* focus-trap 7.6.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -125,16 +125,2 @@ */

// Array.find/findIndex() are not supported on IE; this replicates enough
// of Array.findIndex() for our needs
var findIndex = function findIndex(arr, fn) {
var idx = -1;
arr.every(function (value, i) {
if (fn(value)) {
idx = i;
return false; // break
}
return true; // next
});
return idx;
};
/**

@@ -525,3 +511,3 @@ * Get an option's value when it could be a plain value, or a handler that provides

// is the target the first tabbable node in a group?
var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
var firstTabbableNode = _ref4.firstTabbableNode;

@@ -555,3 +541,3 @@ return target === firstTabbableNode;

// is the target the last tabbable node in a group?
var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref5) {
var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
var lastTabbableNode = _ref5.lastTabbableNode;

@@ -558,0 +544,0 @@ return target === lastTabbableNode;

/*!
* focus-trap 7.6.1
* focus-trap 7.6.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
import{isFocusable as e,tabbable as t,focusable as n,isTabbable as o,getTabIndex as r}from"tabbable";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var l=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},d=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},f=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},b=function(e){return f(e)&&!e.shiftKey},v=function(e){return f(e)&&e.shiftKey},p=function(e){return setTimeout(e,0)},m=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},y=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},h=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},w=[],g=function(a,i){var u,g=(null==i?void 0:i.document)||document,N=(null==i?void 0:i.trapStack)||w,F=c({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:b,isKeyBackward:v},i),O={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},E=function(e,t,n){return e&&void 0!==e[t]?e[t]:F[n||t]},k=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return O.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},T=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,o=void 0!==n&&n,r=t.params,a=void 0===r?[]:r,i=F[e];if("function"==typeof i&&(i=i.apply(void 0,s(a))),!0===i&&(i=void 0),!i){if(void 0===i||!1===i)return i;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var u=i;if("string"==typeof i){try{u=g.querySelector(i)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!u&&!o)throw new Error("`".concat(e,"` as selector refers to no known node"))}return u},D=function(){var t=T("initialFocus",{hasFallback:!0});if(!1===t)return!1;if(void 0===t||t&&!e(t,F.tabbableOptions))if(k(g.activeElement)>=0)t=g.activeElement;else{var n=O.tabbableGroups[0];t=n&&n.firstTabbableNode||T("fallbackFocus")}else null===t&&(t=T("fallbackFocus"));if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},P=function(){if(O.containerGroups=O.containers.map((function(e){var a=t(e,F.tabbableOptions),i=n(e,F.tabbableOptions),u=a.length>0?a[0]:void 0,c=a.length>0?a[a.length-1]:void 0,s=i.find((function(e){return o(e)})),l=i.slice().reverse().find((function(e){return o(e)})),d=!!a.find((function(e){return r(e)>0}));return{container:e,tabbableNodes:a,focusableNodes:i,posTabIndexesFound:d,firstTabbableNode:u,lastTabbableNode:c,firstDomTabbableNode:s,lastDomTabbableNode:l,nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=a.indexOf(e);return n<0?t?i.slice(i.indexOf(e)+1).find((function(e){return o(e)})):i.slice(0,i.indexOf(e)).reverse().find((function(e){return o(e)})):a[n+(t?1:-1)]}}})),O.tabbableGroups=O.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),O.tabbableGroups.length<=0&&!T("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(O.containerGroups.find((function(e){return e.posTabIndexesFound}))&&O.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},G=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?G(t.shadowRoot):t},R=function(e){!1!==e&&e!==G(document)&&(e&&e.focus?(e.focus({preventScroll:!!F.preventScroll}),O.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):R(D()))},x=function(e){var t=T("setReturnFocus",{params:[e]});return t||!1!==t&&e},j=function(t){var n=t.target,a=t.event,i=t.isBackward,u=void 0!==i&&i;n=n||h(a),P();var c=null;if(O.tabbableGroups.length>0){var s=k(n,a),l=s>=0?O.containerGroups[s]:void 0;if(s<0)c=u?O.tabbableGroups[O.tabbableGroups.length-1].lastTabbableNode:O.tabbableGroups[0].firstTabbableNode;else if(u){var d=m(O.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(d<0&&(l.container===n||e(n,F.tabbableOptions)&&!o(n,F.tabbableOptions)&&!l.nextTabbableNode(n,!1))&&(d=s),d>=0){var b=0===d?O.tabbableGroups.length-1:d-1,v=O.tabbableGroups[b];c=r(n)>=0?v.lastTabbableNode:v.lastDomTabbableNode}else f(a)||(c=l.nextTabbableNode(n,!1))}else{var p=m(O.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(p<0&&(l.container===n||e(n,F.tabbableOptions)&&!o(n,F.tabbableOptions)&&!l.nextTabbableNode(n))&&(p=s),p>=0){var y=p===O.tabbableGroups.length-1?0:p+1,w=O.tabbableGroups[y];c=r(n)>=0?w.firstTabbableNode:w.firstDomTabbableNode}else f(a)||(c=l.nextTabbableNode(n))}}else c=T("fallbackFocus");return c},A=function(e){var t=h(e);k(t,e)>=0||(y(F.clickOutsideDeactivates,e)?u.deactivate({returnFocus:F.returnFocusOnDeactivate}):y(F.allowOutsideClick,e)||e.preventDefault())},I=function(e){var t=h(e),n=k(t,e)>=0;if(n||t instanceof Document)n&&(O.mostRecentlyFocusedNode=t);else{var o;e.stopImmediatePropagation();var a=!0;if(O.mostRecentlyFocusedNode)if(r(O.mostRecentlyFocusedNode)>0){var i=k(O.mostRecentlyFocusedNode),u=O.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===O.mostRecentlyFocusedNode}));c>=0&&(F.isKeyForward(O.recentNavEvent)?c+1<u.length&&(o=u[c+1],a=!1):c-1>=0&&(o=u[c-1],a=!1))}}else O.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return r(e)>0}))}))||(a=!1);else a=!1;a&&(o=j({target:O.mostRecentlyFocusedNode,isBackward:F.isKeyBackward(O.recentNavEvent)})),R(o||(O.mostRecentlyFocusedNode||D()))}O.recentNavEvent=void 0},L=function(e){(F.isKeyForward(e)||F.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];O.recentNavEvent=e;var n=j({event:e,isBackward:t});n&&(f(e)&&e.preventDefault(),R(n))}(e,F.isKeyBackward(e))},S=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===y(F.escapeDeactivates,e)||(e.preventDefault(),u.deactivate())},B=function(e){var t=h(e);k(t,e)>=0||y(F.clickOutsideDeactivates,e)||y(F.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},C=function(){if(O.active)return l(N,u),O.delayInitialFocusTimer=F.delayInitialFocus?p((function(){R(D())})):R(D()),g.addEventListener("focusin",I,!0),g.addEventListener("mousedown",A,{capture:!0,passive:!1}),g.addEventListener("touchstart",A,{capture:!0,passive:!1}),g.addEventListener("click",B,{capture:!0,passive:!1}),g.addEventListener("keydown",L,{capture:!0,passive:!1}),g.addEventListener("keydown",S),u},K=function(){if(O.active)return g.removeEventListener("focusin",I,!0),g.removeEventListener("mousedown",A,!0),g.removeEventListener("touchstart",A,!0),g.removeEventListener("click",B,!0),g.removeEventListener("keydown",L,!0),g.removeEventListener("keydown",S),u},M="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===O.mostRecentlyFocusedNode}))}))&&R(D())})):void 0,U=function(){M&&(M.disconnect(),O.active&&!O.paused&&O.containers.map((function(e){M.observe(e,{subtree:!0,childList:!0})})))};return(u={get active(){return O.active},get paused(){return O.paused},activate:function(e){if(O.active)return this;var t=E(e,"onActivate"),n=E(e,"onPostActivate"),o=E(e,"checkCanFocusTrap");o||P(),O.active=!0,O.paused=!1,O.nodeFocusedBeforeActivation=g.activeElement,null==t||t();var r=function(){o&&P(),C(),U(),null==n||n()};return o?(o(O.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!O.active)return this;var t=c({onDeactivate:F.onDeactivate,onPostDeactivate:F.onPostDeactivate,checkCanReturnFocus:F.checkCanReturnFocus},e);clearTimeout(O.delayInitialFocusTimer),O.delayInitialFocusTimer=void 0,K(),O.active=!1,O.paused=!1,U(),d(N,u);var n=E(t,"onDeactivate"),o=E(t,"onPostDeactivate"),r=E(t,"checkCanReturnFocus"),a=E(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var i=function(){p((function(){a&&R(x(O.nodeFocusedBeforeActivation)),null==o||o()}))};return a&&r?(r(x(O.nodeFocusedBeforeActivation)).then(i,i),this):(i(),this)},pause:function(e){if(O.paused||!O.active)return this;var t=E(e,"onPause"),n=E(e,"onPostPause");return O.paused=!0,null==t||t(),K(),U(),null==n||n(),this},unpause:function(e){if(!O.paused||!O.active)return this;var t=E(e,"onUnpause"),n=E(e,"onPostUnpause");return O.paused=!1,null==t||t(),P(),C(),U(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return O.containers=t.map((function(e){return"string"==typeof e?g.querySelector(e):e})),O.active&&P(),U(),this}}).updateContainerElements(a),u};export{g as createFocusTrap};
import{isFocusable as e,tabbable as t,focusable as n,isTabbable as o,getTabIndex as r}from"tabbable";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var l=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},d=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},f=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},b=function(e){return f(e)&&!e.shiftKey},v=function(e){return f(e)&&e.shiftKey},p=function(e){return setTimeout(e,0)},m=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},y=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},h=[],w=function(a,i){var u,w=(null==i?void 0:i.document)||document,g=(null==i?void 0:i.trapStack)||h,N=c({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:b,isKeyBackward:v},i),F={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},O=function(e,t,n){return e&&void 0!==e[t]?e[t]:N[n||t]},E=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return F.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},k=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,o=void 0!==n&&n,r=t.params,a=void 0===r?[]:r,i=N[e];if("function"==typeof i&&(i=i.apply(void 0,s(a))),!0===i&&(i=void 0),!i){if(void 0===i||!1===i)return i;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var u=i;if("string"==typeof i){try{u=w.querySelector(i)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!u&&!o)throw new Error("`".concat(e,"` as selector refers to no known node"))}return u},T=function(){var t=k("initialFocus",{hasFallback:!0});if(!1===t)return!1;if(void 0===t||t&&!e(t,N.tabbableOptions))if(E(w.activeElement)>=0)t=w.activeElement;else{var n=F.tabbableGroups[0];t=n&&n.firstTabbableNode||k("fallbackFocus")}else null===t&&(t=k("fallbackFocus"));if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},D=function(){if(F.containerGroups=F.containers.map((function(e){var a=t(e,N.tabbableOptions),i=n(e,N.tabbableOptions),u=a.length>0?a[0]:void 0,c=a.length>0?a[a.length-1]:void 0,s=i.find((function(e){return o(e)})),l=i.slice().reverse().find((function(e){return o(e)})),d=!!a.find((function(e){return r(e)>0}));return{container:e,tabbableNodes:a,focusableNodes:i,posTabIndexesFound:d,firstTabbableNode:u,lastTabbableNode:c,firstDomTabbableNode:s,lastDomTabbableNode:l,nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=a.indexOf(e);return n<0?t?i.slice(i.indexOf(e)+1).find((function(e){return o(e)})):i.slice(0,i.indexOf(e)).reverse().find((function(e){return o(e)})):a[n+(t?1:-1)]}}})),F.tabbableGroups=F.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),F.tabbableGroups.length<=0&&!k("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(F.containerGroups.find((function(e){return e.posTabIndexesFound}))&&F.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},P=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?P(t.shadowRoot):t},G=function(e){!1!==e&&e!==P(document)&&(e&&e.focus?(e.focus({preventScroll:!!N.preventScroll}),F.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):G(T()))},x=function(e){var t=k("setReturnFocus",{params:[e]});return t||!1!==t&&e},R=function(t){var n=t.target,a=t.event,i=t.isBackward,u=void 0!==i&&i;n=n||y(a),D();var c=null;if(F.tabbableGroups.length>0){var s=E(n,a),l=s>=0?F.containerGroups[s]:void 0;if(s<0)c=u?F.tabbableGroups[F.tabbableGroups.length-1].lastTabbableNode:F.tabbableGroups[0].firstTabbableNode;else if(u){var d=F.tabbableGroups.findIndex((function(e){var t=e.firstTabbableNode;return n===t}));if(d<0&&(l.container===n||e(n,N.tabbableOptions)&&!o(n,N.tabbableOptions)&&!l.nextTabbableNode(n,!1))&&(d=s),d>=0){var b=0===d?F.tabbableGroups.length-1:d-1,v=F.tabbableGroups[b];c=r(n)>=0?v.lastTabbableNode:v.lastDomTabbableNode}else f(a)||(c=l.nextTabbableNode(n,!1))}else{var p=F.tabbableGroups.findIndex((function(e){var t=e.lastTabbableNode;return n===t}));if(p<0&&(l.container===n||e(n,N.tabbableOptions)&&!o(n,N.tabbableOptions)&&!l.nextTabbableNode(n))&&(p=s),p>=0){var m=p===F.tabbableGroups.length-1?0:p+1,h=F.tabbableGroups[m];c=r(n)>=0?h.firstTabbableNode:h.firstDomTabbableNode}else f(a)||(c=l.nextTabbableNode(n))}}else c=k("fallbackFocus");return c},I=function(e){var t=y(e);E(t,e)>=0||(m(N.clickOutsideDeactivates,e)?u.deactivate({returnFocus:N.returnFocusOnDeactivate}):m(N.allowOutsideClick,e)||e.preventDefault())},j=function(e){var t=y(e),n=E(t,e)>=0;if(n||t instanceof Document)n&&(F.mostRecentlyFocusedNode=t);else{var o;e.stopImmediatePropagation();var a=!0;if(F.mostRecentlyFocusedNode)if(r(F.mostRecentlyFocusedNode)>0){var i=E(F.mostRecentlyFocusedNode),u=F.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===F.mostRecentlyFocusedNode}));c>=0&&(N.isKeyForward(F.recentNavEvent)?c+1<u.length&&(o=u[c+1],a=!1):c-1>=0&&(o=u[c-1],a=!1))}}else F.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return r(e)>0}))}))||(a=!1);else a=!1;a&&(o=R({target:F.mostRecentlyFocusedNode,isBackward:N.isKeyBackward(F.recentNavEvent)})),G(o||(F.mostRecentlyFocusedNode||T()))}F.recentNavEvent=void 0},A=function(e){(N.isKeyForward(e)||N.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];F.recentNavEvent=e;var n=R({event:e,isBackward:t});n&&(f(e)&&e.preventDefault(),G(n))}(e,N.isKeyBackward(e))},L=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===m(N.escapeDeactivates,e)||(e.preventDefault(),u.deactivate())},S=function(e){var t=y(e);E(t,e)>=0||m(N.clickOutsideDeactivates,e)||m(N.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},B=function(){if(F.active)return l(g,u),F.delayInitialFocusTimer=N.delayInitialFocus?p((function(){G(T())})):G(T()),w.addEventListener("focusin",j,!0),w.addEventListener("mousedown",I,{capture:!0,passive:!1}),w.addEventListener("touchstart",I,{capture:!0,passive:!1}),w.addEventListener("click",S,{capture:!0,passive:!1}),w.addEventListener("keydown",A,{capture:!0,passive:!1}),w.addEventListener("keydown",L),u},C=function(){if(F.active)return w.removeEventListener("focusin",j,!0),w.removeEventListener("mousedown",I,!0),w.removeEventListener("touchstart",I,!0),w.removeEventListener("click",S,!0),w.removeEventListener("keydown",A,!0),w.removeEventListener("keydown",L),u},K="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===F.mostRecentlyFocusedNode}))}))&&G(T())})):void 0,M=function(){K&&(K.disconnect(),F.active&&!F.paused&&F.containers.map((function(e){K.observe(e,{subtree:!0,childList:!0})})))};return(u={get active(){return F.active},get paused(){return F.paused},activate:function(e){if(F.active)return this;var t=O(e,"onActivate"),n=O(e,"onPostActivate"),o=O(e,"checkCanFocusTrap");o||D(),F.active=!0,F.paused=!1,F.nodeFocusedBeforeActivation=w.activeElement,null==t||t();var r=function(){o&&D(),B(),M(),null==n||n()};return o?(o(F.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!F.active)return this;var t=c({onDeactivate:N.onDeactivate,onPostDeactivate:N.onPostDeactivate,checkCanReturnFocus:N.checkCanReturnFocus},e);clearTimeout(F.delayInitialFocusTimer),F.delayInitialFocusTimer=void 0,C(),F.active=!1,F.paused=!1,M(),d(g,u);var n=O(t,"onDeactivate"),o=O(t,"onPostDeactivate"),r=O(t,"checkCanReturnFocus"),a=O(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var i=function(){p((function(){a&&G(x(F.nodeFocusedBeforeActivation)),null==o||o()}))};return a&&r?(r(x(F.nodeFocusedBeforeActivation)).then(i,i),this):(i(),this)},pause:function(e){if(F.paused||!F.active)return this;var t=O(e,"onPause"),n=O(e,"onPostPause");return F.paused=!0,null==t||t(),C(),M(),null==n||n(),this},unpause:function(e){if(!F.paused||!F.active)return this;var t=O(e,"onUnpause"),n=O(e,"onPostUnpause");return F.paused=!1,null==t||t(),D(),B(),M(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return F.containers=t.map((function(e){return"string"==typeof e?w.querySelector(e):e})),F.active&&D(),M(),this}}).updateContainerElements(a),u};export{w as createFocusTrap};
//# sourceMappingURL=focus-trap.esm.min.js.map
/*!
* focus-trap 7.6.1
* focus-trap 7.6.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -127,16 +127,2 @@ */

// Array.find/findIndex() are not supported on IE; this replicates enough
// of Array.findIndex() for our needs
var findIndex = function findIndex(arr, fn) {
var idx = -1;
arr.every(function (value, i) {
if (fn(value)) {
idx = i;
return false; // break
}
return true; // next
});
return idx;
};
/**

@@ -527,3 +513,3 @@ * Get an option's value when it could be a plain value, or a handler that provides

// is the target the first tabbable node in a group?
var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
var firstTabbableNode = _ref4.firstTabbableNode;

@@ -557,3 +543,3 @@ return target === firstTabbableNode;

// is the target the last tabbable node in a group?
var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref5) {
var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
var lastTabbableNode = _ref5.lastTabbableNode;

@@ -560,0 +546,0 @@ return target === lastTabbableNode;

/*!
* focus-trap 7.6.1
* focus-trap 7.6.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
"use strict";var e=require("tabbable");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function n(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},u=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},c=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},s=function(e){return c(e)&&!e.shiftKey},l=function(e){return c(e)&&e.shiftKey},b=function(e){return setTimeout(e,0)},d=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},f=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},v=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},p=[];exports.createFocusTrap=function(t,n){var o,m=(null==n?void 0:n.document)||document,y=(null==n?void 0:n.trapStack)||p,h=r({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:s,isKeyBackward:l},n),w={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},g=function(e,t,n){return e&&void 0!==e[t]?e[t]:h[n||t]},F=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return w.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},N=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,o=void 0!==n&&n,r=t.params,i=void 0===r?[]:r,u=h[e];if("function"==typeof u&&(u=u.apply(void 0,a(i))),!0===u&&(u=void 0),!u){if(void 0===u||!1===u)return u;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var c=u;if("string"==typeof u){try{c=m.querySelector(u)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!c&&!o)throw new Error("`".concat(e,"` as selector refers to no known node"))}return c},T=function(){var t=N("initialFocus",{hasFallback:!0});if(!1===t)return!1;if(void 0===t||t&&!e.isFocusable(t,h.tabbableOptions))if(F(m.activeElement)>=0)t=m.activeElement;else{var n=w.tabbableGroups[0];t=n&&n.firstTabbableNode||N("fallbackFocus")}else null===t&&(t=N("fallbackFocus"));if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},O=function(){if(w.containerGroups=w.containers.map((function(t){var n=e.tabbable(t,h.tabbableOptions),o=e.focusable(t,h.tabbableOptions),r=n.length>0?n[0]:void 0,a=n.length>0?n[n.length-1]:void 0,i=o.find((function(t){return e.isTabbable(t)})),u=o.slice().reverse().find((function(t){return e.isTabbable(t)})),c=!!n.find((function(t){return e.getTabIndex(t)>0}));return{container:t,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:c,firstTabbableNode:r,lastTabbableNode:a,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=n.indexOf(t);return a<0?r?o.slice(o.indexOf(t)+1).find((function(t){return e.isTabbable(t)})):o.slice(0,o.indexOf(t)).reverse().find((function(t){return e.isTabbable(t)})):n[a+(r?1:-1)]}}})),w.tabbableGroups=w.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),w.tabbableGroups.length<=0&&!N("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(w.containerGroups.find((function(e){return e.posTabIndexesFound}))&&w.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},E=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?E(t.shadowRoot):t},k=function(e){!1!==e&&e!==E(document)&&(e&&e.focus?(e.focus({preventScroll:!!h.preventScroll}),w.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):k(T()))},D=function(e){var t=N("setReturnFocus",{params:[e]});return t||!1!==t&&e},P=function(t){var n=t.target,o=t.event,r=t.isBackward,a=void 0!==r&&r;n=n||v(o),O();var i=null;if(w.tabbableGroups.length>0){var u=F(n,o),s=u>=0?w.containerGroups[u]:void 0;if(u<0)i=a?w.tabbableGroups[w.tabbableGroups.length-1].lastTabbableNode:w.tabbableGroups[0].firstTabbableNode;else if(a){var l=d(w.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(s.container===n||e.isFocusable(n,h.tabbableOptions)&&!e.isTabbable(n,h.tabbableOptions)&&!s.nextTabbableNode(n,!1))&&(l=u),l>=0){var b=0===l?w.tabbableGroups.length-1:l-1,f=w.tabbableGroups[b];i=e.getTabIndex(n)>=0?f.lastTabbableNode:f.lastDomTabbableNode}else c(o)||(i=s.nextTabbableNode(n,!1))}else{var p=d(w.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(p<0&&(s.container===n||e.isFocusable(n,h.tabbableOptions)&&!e.isTabbable(n,h.tabbableOptions)&&!s.nextTabbableNode(n))&&(p=u),p>=0){var m=p===w.tabbableGroups.length-1?0:p+1,y=w.tabbableGroups[m];i=e.getTabIndex(n)>=0?y.firstTabbableNode:y.firstDomTabbableNode}else c(o)||(i=s.nextTabbableNode(n))}}else i=N("fallbackFocus");return i},G=function(e){var t=v(e);F(t,e)>=0||(f(h.clickOutsideDeactivates,e)?o.deactivate({returnFocus:h.returnFocusOnDeactivate}):f(h.allowOutsideClick,e)||e.preventDefault())},x=function(t){var n=v(t),o=F(n,t)>=0;if(o||n instanceof Document)o&&(w.mostRecentlyFocusedNode=n);else{var r;t.stopImmediatePropagation();var a=!0;if(w.mostRecentlyFocusedNode)if(e.getTabIndex(w.mostRecentlyFocusedNode)>0){var i=F(w.mostRecentlyFocusedNode),u=w.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===w.mostRecentlyFocusedNode}));c>=0&&(h.isKeyForward(w.recentNavEvent)?c+1<u.length&&(r=u[c+1],a=!1):c-1>=0&&(r=u[c-1],a=!1))}}else w.containerGroups.some((function(t){return t.tabbableNodes.some((function(t){return e.getTabIndex(t)>0}))}))||(a=!1);else a=!1;a&&(r=P({target:w.mostRecentlyFocusedNode,isBackward:h.isKeyBackward(w.recentNavEvent)})),k(r||(w.mostRecentlyFocusedNode||T()))}w.recentNavEvent=void 0},I=function(e){(h.isKeyForward(e)||h.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];w.recentNavEvent=e;var n=P({event:e,isBackward:t});n&&(c(e)&&e.preventDefault(),k(n))}(e,h.isKeyBackward(e))},R=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===f(h.escapeDeactivates,e)||(e.preventDefault(),o.deactivate())},j=function(e){var t=v(e);F(t,e)>=0||f(h.clickOutsideDeactivates,e)||f(h.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},A=function(){if(w.active)return i(y,o),w.delayInitialFocusTimer=h.delayInitialFocus?b((function(){k(T())})):k(T()),m.addEventListener("focusin",x,!0),m.addEventListener("mousedown",G,{capture:!0,passive:!1}),m.addEventListener("touchstart",G,{capture:!0,passive:!1}),m.addEventListener("click",j,{capture:!0,passive:!1}),m.addEventListener("keydown",I,{capture:!0,passive:!1}),m.addEventListener("keydown",R),o},L=function(){if(w.active)return m.removeEventListener("focusin",x,!0),m.removeEventListener("mousedown",G,!0),m.removeEventListener("touchstart",G,!0),m.removeEventListener("click",j,!0),m.removeEventListener("keydown",I,!0),m.removeEventListener("keydown",R),o},S="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===w.mostRecentlyFocusedNode}))}))&&k(T())})):void 0,B=function(){S&&(S.disconnect(),w.active&&!w.paused&&w.containers.map((function(e){S.observe(e,{subtree:!0,childList:!0})})))};return(o={get active(){return w.active},get paused(){return w.paused},activate:function(e){if(w.active)return this;var t=g(e,"onActivate"),n=g(e,"onPostActivate"),o=g(e,"checkCanFocusTrap");o||O(),w.active=!0,w.paused=!1,w.nodeFocusedBeforeActivation=m.activeElement,null==t||t();var r=function(){o&&O(),A(),B(),null==n||n()};return o?(o(w.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!w.active)return this;var t=r({onDeactivate:h.onDeactivate,onPostDeactivate:h.onPostDeactivate,checkCanReturnFocus:h.checkCanReturnFocus},e);clearTimeout(w.delayInitialFocusTimer),w.delayInitialFocusTimer=void 0,L(),w.active=!1,w.paused=!1,B(),u(y,o);var n=g(t,"onDeactivate"),a=g(t,"onPostDeactivate"),i=g(t,"checkCanReturnFocus"),c=g(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var s=function(){b((function(){c&&k(D(w.nodeFocusedBeforeActivation)),null==a||a()}))};return c&&i?(i(D(w.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(w.paused||!w.active)return this;var t=g(e,"onPause"),n=g(e,"onPostPause");return w.paused=!0,null==t||t(),L(),B(),null==n||n(),this},unpause:function(e){if(!w.paused||!w.active)return this;var t=g(e,"onUnpause"),n=g(e,"onPostUnpause");return w.paused=!1,null==t||t(),O(),A(),B(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return w.containers=t.map((function(e){return"string"==typeof e?m.querySelector(e):e})),w.active&&O(),B(),this}}).updateContainerElements(t),o};
"use strict";var e=require("tabbable");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function n(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},u=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},c=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},s=function(e){return c(e)&&!e.shiftKey},l=function(e){return c(e)&&e.shiftKey},b=function(e){return setTimeout(e,0)},d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},f=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},v=[];exports.createFocusTrap=function(t,n){var o,p=(null==n?void 0:n.document)||document,m=(null==n?void 0:n.trapStack)||v,y=r({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:s,isKeyBackward:l},n),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},w=function(e,t,n){return e&&void 0!==e[t]?e[t]:y[n||t]},g=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},F=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,o=void 0!==n&&n,r=t.params,i=void 0===r?[]:r,u=y[e];if("function"==typeof u&&(u=u.apply(void 0,a(i))),!0===u&&(u=void 0),!u){if(void 0===u||!1===u)return u;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var c=u;if("string"==typeof u){try{c=p.querySelector(u)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!c&&!o)throw new Error("`".concat(e,"` as selector refers to no known node"))}return c},N=function(){var t=F("initialFocus",{hasFallback:!0});if(!1===t)return!1;if(void 0===t||t&&!e.isFocusable(t,y.tabbableOptions))if(g(p.activeElement)>=0)t=p.activeElement;else{var n=h.tabbableGroups[0];t=n&&n.firstTabbableNode||F("fallbackFocus")}else null===t&&(t=F("fallbackFocus"));if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},T=function(){if(h.containerGroups=h.containers.map((function(t){var n=e.tabbable(t,y.tabbableOptions),o=e.focusable(t,y.tabbableOptions),r=n.length>0?n[0]:void 0,a=n.length>0?n[n.length-1]:void 0,i=o.find((function(t){return e.isTabbable(t)})),u=o.slice().reverse().find((function(t){return e.isTabbable(t)})),c=!!n.find((function(t){return e.getTabIndex(t)>0}));return{container:t,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:c,firstTabbableNode:r,lastTabbableNode:a,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=n.indexOf(t);return a<0?r?o.slice(o.indexOf(t)+1).find((function(t){return e.isTabbable(t)})):o.slice(0,o.indexOf(t)).reverse().find((function(t){return e.isTabbable(t)})):n[a+(r?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!F("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?O(t.shadowRoot):t},E=function(e){!1!==e&&e!==O(document)&&(e&&e.focus?(e.focus({preventScroll:!!y.preventScroll}),h.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):E(N()))},k=function(e){var t=F("setReturnFocus",{params:[e]});return t||!1!==t&&e},D=function(t){var n=t.target,o=t.event,r=t.isBackward,a=void 0!==r&&r;n=n||f(o),T();var i=null;if(h.tabbableGroups.length>0){var u=g(n,o),s=u>=0?h.containerGroups[u]:void 0;if(u<0)i=a?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(a){var l=h.tabbableGroups.findIndex((function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(s.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!s.nextTabbableNode(n,!1))&&(l=u),l>=0){var b=0===l?h.tabbableGroups.length-1:l-1,d=h.tabbableGroups[b];i=e.getTabIndex(n)>=0?d.lastTabbableNode:d.lastDomTabbableNode}else c(o)||(i=s.nextTabbableNode(n,!1))}else{var v=h.tabbableGroups.findIndex((function(e){var t=e.lastTabbableNode;return n===t}));if(v<0&&(s.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!s.nextTabbableNode(n))&&(v=u),v>=0){var p=v===h.tabbableGroups.length-1?0:v+1,m=h.tabbableGroups[p];i=e.getTabIndex(n)>=0?m.firstTabbableNode:m.firstDomTabbableNode}else c(o)||(i=s.nextTabbableNode(n))}}else i=F("fallbackFocus");return i},P=function(e){var t=f(e);g(t,e)>=0||(d(y.clickOutsideDeactivates,e)?o.deactivate({returnFocus:y.returnFocusOnDeactivate}):d(y.allowOutsideClick,e)||e.preventDefault())},x=function(t){var n=f(t),o=g(n,t)>=0;if(o||n instanceof Document)o&&(h.mostRecentlyFocusedNode=n);else{var r;t.stopImmediatePropagation();var a=!0;if(h.mostRecentlyFocusedNode)if(e.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=g(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));c>=0&&(y.isKeyForward(h.recentNavEvent)?c+1<u.length&&(r=u[c+1],a=!1):c-1>=0&&(r=u[c-1],a=!1))}}else h.containerGroups.some((function(t){return t.tabbableNodes.some((function(t){return e.getTabIndex(t)>0}))}))||(a=!1);else a=!1;a&&(r=D({target:h.mostRecentlyFocusedNode,isBackward:y.isKeyBackward(h.recentNavEvent)})),E(r||(h.mostRecentlyFocusedNode||N()))}h.recentNavEvent=void 0},G=function(e){(y.isKeyForward(e)||y.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=D({event:e,isBackward:t});n&&(c(e)&&e.preventDefault(),E(n))}(e,y.isKeyBackward(e))},I=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===d(y.escapeDeactivates,e)||(e.preventDefault(),o.deactivate())},R=function(e){var t=f(e);g(t,e)>=0||d(y.clickOutsideDeactivates,e)||d(y.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},j=function(){if(h.active)return i(m,o),h.delayInitialFocusTimer=y.delayInitialFocus?b((function(){E(N())})):E(N()),p.addEventListener("focusin",x,!0),p.addEventListener("mousedown",P,{capture:!0,passive:!1}),p.addEventListener("touchstart",P,{capture:!0,passive:!1}),p.addEventListener("click",R,{capture:!0,passive:!1}),p.addEventListener("keydown",G,{capture:!0,passive:!1}),p.addEventListener("keydown",I),o},A=function(){if(h.active)return p.removeEventListener("focusin",x,!0),p.removeEventListener("mousedown",P,!0),p.removeEventListener("touchstart",P,!0),p.removeEventListener("click",R,!0),p.removeEventListener("keydown",G,!0),p.removeEventListener("keydown",I),o},L="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&E(N())})):void 0,S=function(){L&&(L.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){L.observe(e,{subtree:!0,childList:!0})})))};return(o={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=w(e,"onActivate"),n=w(e,"onPostActivate"),o=w(e,"checkCanFocusTrap");o||T(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=p.activeElement,null==t||t();var r=function(){o&&T(),j(),S(),null==n||n()};return o?(o(h.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!h.active)return this;var t=r({onDeactivate:y.onDeactivate,onPostDeactivate:y.onPostDeactivate,checkCanReturnFocus:y.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,A(),h.active=!1,h.paused=!1,S(),u(m,o);var n=w(t,"onDeactivate"),a=w(t,"onPostDeactivate"),i=w(t,"checkCanReturnFocus"),c=w(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var s=function(){b((function(){c&&E(k(h.nodeFocusedBeforeActivation)),null==a||a()}))};return c&&i?(i(k(h.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(h.paused||!h.active)return this;var t=w(e,"onPause"),n=w(e,"onPostPause");return h.paused=!0,null==t||t(),A(),S(),null==n||n(),this},unpause:function(e){if(!h.paused||!h.active)return this;var t=w(e,"onUnpause"),n=w(e,"onPostUnpause");return h.paused=!1,null==t||t(),T(),j(),S(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?p.querySelector(e):e})),h.active&&T(),S(),this}}).updateContainerElements(t),o};
//# sourceMappingURL=focus-trap.min.js.map
/*!
* focus-trap 7.6.1
* focus-trap 7.6.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -134,16 +134,2 @@ */

// Array.find/findIndex() are not supported on IE; this replicates enough
// of Array.findIndex() for our needs
var findIndex = function findIndex(arr, fn) {
var idx = -1;
arr.every(function (value, i) {
if (fn(value)) {
idx = i;
return false; // break
}
return true; // next
});
return idx;
};
/**

@@ -534,3 +520,3 @@ * Get an option's value when it could be a plain value, or a handler that provides

// is the target the first tabbable node in a group?
var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
var firstTabbableNode = _ref4.firstTabbableNode;

@@ -564,3 +550,3 @@ return target === firstTabbableNode;

// is the target the last tabbable node in a group?
var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref5) {
var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
var lastTabbableNode = _ref5.lastTabbableNode;

@@ -567,0 +553,0 @@ return target === lastTabbableNode;

/*!
* focus-trap 7.6.1
* focus-trap 7.6.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tabbable")):"function"==typeof define&&define.amd?define(["exports","tabbable"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.focusTrap,o=e.focusTrap={};t(o,e.tabbable),o.noConflict=function(){return e.focusTrap=n,o}}())}(this,(function(e,t){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var u=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},c=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},s=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},l=function(e){return s(e)&&!e.shiftKey},b=function(e){return s(e)&&e.shiftKey},d=function(e){return setTimeout(e,0)},f=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},v=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},p=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},m=[];e.createFocusTrap=function(e,n){var o,r=(null==n?void 0:n.document)||document,y=(null==n?void 0:n.trapStack)||m,h=a({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:l,isKeyBackward:b},n),w={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},g=function(e,t,n){return e&&void 0!==e[t]?e[t]:h[n||t]},T=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return w.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},F=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,o=void 0!==n&&n,a=t.params,u=void 0===a?[]:a,c=h[e];if("function"==typeof c&&(c=c.apply(void 0,i(u))),!0===c&&(c=void 0),!c){if(void 0===c||!1===c)return c;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var s=c;if("string"==typeof c){try{s=r.querySelector(c)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!s&&!o)throw new Error("`".concat(e,"` as selector refers to no known node"))}return s},N=function(){var e=F("initialFocus",{hasFallback:!0});if(!1===e)return!1;if(void 0===e||e&&!t.isFocusable(e,h.tabbableOptions))if(T(r.activeElement)>=0)e=r.activeElement;else{var n=w.tabbableGroups[0];e=n&&n.firstTabbableNode||F("fallbackFocus")}else null===e&&(e=F("fallbackFocus"));if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},O=function(){if(w.containerGroups=w.containers.map((function(e){var n=t.tabbable(e,h.tabbableOptions),o=t.focusable(e,h.tabbableOptions),r=n.length>0?n[0]:void 0,a=n.length>0?n[n.length-1]:void 0,i=o.find((function(e){return t.isTabbable(e)})),u=o.slice().reverse().find((function(e){return t.isTabbable(e)})),c=!!n.find((function(e){return t.getTabIndex(e)>0}));return{container:e,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:c,firstTabbableNode:r,lastTabbableNode:a,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=n.indexOf(e);return a<0?r?o.slice(o.indexOf(e)+1).find((function(e){return t.isTabbable(e)})):o.slice(0,o.indexOf(e)).reverse().find((function(e){return t.isTabbable(e)})):n[a+(r?1:-1)]}}})),w.tabbableGroups=w.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),w.tabbableGroups.length<=0&&!F("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(w.containerGroups.find((function(e){return e.posTabIndexesFound}))&&w.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},E=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?E(t.shadowRoot):t},k=function(e){!1!==e&&e!==E(document)&&(e&&e.focus?(e.focus({preventScroll:!!h.preventScroll}),w.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):k(N()))},D=function(e){var t=F("setReturnFocus",{params:[e]});return t||!1!==t&&e},P=function(e){var n=e.target,o=e.event,r=e.isBackward,a=void 0!==r&&r;n=n||p(o),O();var i=null;if(w.tabbableGroups.length>0){var u=T(n,o),c=u>=0?w.containerGroups[u]:void 0;if(u<0)i=a?w.tabbableGroups[w.tabbableGroups.length-1].lastTabbableNode:w.tabbableGroups[0].firstTabbableNode;else if(a){var l=f(w.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(c.container===n||t.isFocusable(n,h.tabbableOptions)&&!t.isTabbable(n,h.tabbableOptions)&&!c.nextTabbableNode(n,!1))&&(l=u),l>=0){var b=0===l?w.tabbableGroups.length-1:l-1,d=w.tabbableGroups[b];i=t.getTabIndex(n)>=0?d.lastTabbableNode:d.lastDomTabbableNode}else s(o)||(i=c.nextTabbableNode(n,!1))}else{var v=f(w.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(v<0&&(c.container===n||t.isFocusable(n,h.tabbableOptions)&&!t.isTabbable(n,h.tabbableOptions)&&!c.nextTabbableNode(n))&&(v=u),v>=0){var m=v===w.tabbableGroups.length-1?0:v+1,y=w.tabbableGroups[m];i=t.getTabIndex(n)>=0?y.firstTabbableNode:y.firstDomTabbableNode}else s(o)||(i=c.nextTabbableNode(n))}}else i=F("fallbackFocus");return i},x=function(e){var t=p(e);T(t,e)>=0||(v(h.clickOutsideDeactivates,e)?o.deactivate({returnFocus:h.returnFocusOnDeactivate}):v(h.allowOutsideClick,e)||e.preventDefault())},G=function(e){var n=p(e),o=T(n,e)>=0;if(o||n instanceof Document)o&&(w.mostRecentlyFocusedNode=n);else{var r;e.stopImmediatePropagation();var a=!0;if(w.mostRecentlyFocusedNode)if(t.getTabIndex(w.mostRecentlyFocusedNode)>0){var i=T(w.mostRecentlyFocusedNode),u=w.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===w.mostRecentlyFocusedNode}));c>=0&&(h.isKeyForward(w.recentNavEvent)?c+1<u.length&&(r=u[c+1],a=!1):c-1>=0&&(r=u[c-1],a=!1))}}else w.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return t.getTabIndex(e)>0}))}))||(a=!1);else a=!1;a&&(r=P({target:w.mostRecentlyFocusedNode,isBackward:h.isKeyBackward(w.recentNavEvent)})),k(r||(w.mostRecentlyFocusedNode||N()))}w.recentNavEvent=void 0},I=function(e){(h.isKeyForward(e)||h.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];w.recentNavEvent=e;var n=P({event:e,isBackward:t});n&&(s(e)&&e.preventDefault(),k(n))}(e,h.isKeyBackward(e))},R=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===v(h.escapeDeactivates,e)||(e.preventDefault(),o.deactivate())},j=function(e){var t=p(e);T(t,e)>=0||v(h.clickOutsideDeactivates,e)||v(h.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},A=function(){if(w.active)return u(y,o),w.delayInitialFocusTimer=h.delayInitialFocus?d((function(){k(N())})):k(N()),r.addEventListener("focusin",G,!0),r.addEventListener("mousedown",x,{capture:!0,passive:!1}),r.addEventListener("touchstart",x,{capture:!0,passive:!1}),r.addEventListener("click",j,{capture:!0,passive:!1}),r.addEventListener("keydown",I,{capture:!0,passive:!1}),r.addEventListener("keydown",R),o},L=function(){if(w.active)return r.removeEventListener("focusin",G,!0),r.removeEventListener("mousedown",x,!0),r.removeEventListener("touchstart",x,!0),r.removeEventListener("click",j,!0),r.removeEventListener("keydown",I,!0),r.removeEventListener("keydown",R),o},S="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===w.mostRecentlyFocusedNode}))}))&&k(N())})):void 0,C=function(){S&&(S.disconnect(),w.active&&!w.paused&&w.containers.map((function(e){S.observe(e,{subtree:!0,childList:!0})})))};return(o={get active(){return w.active},get paused(){return w.paused},activate:function(e){if(w.active)return this;var t=g(e,"onActivate"),n=g(e,"onPostActivate"),o=g(e,"checkCanFocusTrap");o||O(),w.active=!0,w.paused=!1,w.nodeFocusedBeforeActivation=r.activeElement,null==t||t();var a=function(){o&&O(),A(),C(),null==n||n()};return o?(o(w.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!w.active)return this;var t=a({onDeactivate:h.onDeactivate,onPostDeactivate:h.onPostDeactivate,checkCanReturnFocus:h.checkCanReturnFocus},e);clearTimeout(w.delayInitialFocusTimer),w.delayInitialFocusTimer=void 0,L(),w.active=!1,w.paused=!1,C(),c(y,o);var n=g(t,"onDeactivate"),r=g(t,"onPostDeactivate"),i=g(t,"checkCanReturnFocus"),u=g(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var s=function(){d((function(){u&&k(D(w.nodeFocusedBeforeActivation)),null==r||r()}))};return u&&i?(i(D(w.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(w.paused||!w.active)return this;var t=g(e,"onPause"),n=g(e,"onPostPause");return w.paused=!0,null==t||t(),L(),C(),null==n||n(),this},unpause:function(e){if(!w.paused||!w.active)return this;var t=g(e,"onUnpause"),n=g(e,"onPostUnpause");return w.paused=!1,null==t||t(),O(),A(),C(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return w.containers=t.map((function(e){return"string"==typeof e?r.querySelector(e):e})),w.active&&O(),C(),this}}).updateContainerElements(e),o}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tabbable")):"function"==typeof define&&define.amd?define(["exports","tabbable"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.focusTrap,o=e.focusTrap={};t(o,e.tabbable),o.noConflict=function(){return e.focusTrap=n,o}}())}(this,(function(e,t){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var u=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},c=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},s=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},l=function(e){return s(e)&&!e.shiftKey},b=function(e){return s(e)&&e.shiftKey},d=function(e){return setTimeout(e,0)},f=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},v=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},p=[];e.createFocusTrap=function(e,n){var o,a=(null==n?void 0:n.document)||document,m=(null==n?void 0:n.trapStack)||p,y=r({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:l,isKeyBackward:b},n),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},w=function(e,t,n){return e&&void 0!==e[t]?e[t]:y[n||t]},g=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var o=t.container,a=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||a.find((function(t){return t===e}))}))},T=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,o=void 0!==n&&n,r=t.params,u=void 0===r?[]:r,c=y[e];if("function"==typeof c&&(c=c.apply(void 0,i(u))),!0===c&&(c=void 0),!c){if(void 0===c||!1===c)return c;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var s=c;if("string"==typeof c){try{s=a.querySelector(c)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!s&&!o)throw new Error("`".concat(e,"` as selector refers to no known node"))}return s},F=function(){var e=T("initialFocus",{hasFallback:!0});if(!1===e)return!1;if(void 0===e||e&&!t.isFocusable(e,y.tabbableOptions))if(g(a.activeElement)>=0)e=a.activeElement;else{var n=h.tabbableGroups[0];e=n&&n.firstTabbableNode||T("fallbackFocus")}else null===e&&(e=T("fallbackFocus"));if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},N=function(){if(h.containerGroups=h.containers.map((function(e){var n=t.tabbable(e,y.tabbableOptions),o=t.focusable(e,y.tabbableOptions),a=n.length>0?n[0]:void 0,r=n.length>0?n[n.length-1]:void 0,i=o.find((function(e){return t.isTabbable(e)})),u=o.slice().reverse().find((function(e){return t.isTabbable(e)})),c=!!n.find((function(e){return t.getTabIndex(e)>0}));return{container:e,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:c,firstTabbableNode:a,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(e){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=n.indexOf(e);return r<0?a?o.slice(o.indexOf(e)+1).find((function(e){return t.isTabbable(e)})):o.slice(0,o.indexOf(e)).reverse().find((function(e){return t.isTabbable(e)})):n[r+(a?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!T("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?O(t.shadowRoot):t},E=function(e){!1!==e&&e!==O(document)&&(e&&e.focus?(e.focus({preventScroll:!!y.preventScroll}),h.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):E(F()))},k=function(e){var t=T("setReturnFocus",{params:[e]});return t||!1!==t&&e},x=function(e){var n=e.target,o=e.event,a=e.isBackward,r=void 0!==a&&a;n=n||v(o),N();var i=null;if(h.tabbableGroups.length>0){var u=g(n,o),c=u>=0?h.containerGroups[u]:void 0;if(u<0)i=r?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(r){var l=h.tabbableGroups.findIndex((function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(c.container===n||t.isFocusable(n,y.tabbableOptions)&&!t.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n,!1))&&(l=u),l>=0){var b=0===l?h.tabbableGroups.length-1:l-1,d=h.tabbableGroups[b];i=t.getTabIndex(n)>=0?d.lastTabbableNode:d.lastDomTabbableNode}else s(o)||(i=c.nextTabbableNode(n,!1))}else{var f=h.tabbableGroups.findIndex((function(e){var t=e.lastTabbableNode;return n===t}));if(f<0&&(c.container===n||t.isFocusable(n,y.tabbableOptions)&&!t.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n))&&(f=u),f>=0){var p=f===h.tabbableGroups.length-1?0:f+1,m=h.tabbableGroups[p];i=t.getTabIndex(n)>=0?m.firstTabbableNode:m.firstDomTabbableNode}else s(o)||(i=c.nextTabbableNode(n))}}else i=T("fallbackFocus");return i},D=function(e){var t=v(e);g(t,e)>=0||(f(y.clickOutsideDeactivates,e)?o.deactivate({returnFocus:y.returnFocusOnDeactivate}):f(y.allowOutsideClick,e)||e.preventDefault())},P=function(e){var n=v(e),o=g(n,e)>=0;if(o||n instanceof Document)o&&(h.mostRecentlyFocusedNode=n);else{var a;e.stopImmediatePropagation();var r=!0;if(h.mostRecentlyFocusedNode)if(t.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=g(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));c>=0&&(y.isKeyForward(h.recentNavEvent)?c+1<u.length&&(a=u[c+1],r=!1):c-1>=0&&(a=u[c-1],r=!1))}}else h.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return t.getTabIndex(e)>0}))}))||(r=!1);else r=!1;r&&(a=x({target:h.mostRecentlyFocusedNode,isBackward:y.isKeyBackward(h.recentNavEvent)})),E(a||(h.mostRecentlyFocusedNode||F()))}h.recentNavEvent=void 0},G=function(e){(y.isKeyForward(e)||y.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=x({event:e,isBackward:t});n&&(s(e)&&e.preventDefault(),E(n))}(e,y.isKeyBackward(e))},I=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===f(y.escapeDeactivates,e)||(e.preventDefault(),o.deactivate())},R=function(e){var t=v(e);g(t,e)>=0||f(y.clickOutsideDeactivates,e)||f(y.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},j=function(){if(h.active)return u(m,o),h.delayInitialFocusTimer=y.delayInitialFocus?d((function(){E(F())})):E(F()),a.addEventListener("focusin",P,!0),a.addEventListener("mousedown",D,{capture:!0,passive:!1}),a.addEventListener("touchstart",D,{capture:!0,passive:!1}),a.addEventListener("click",R,{capture:!0,passive:!1}),a.addEventListener("keydown",G,{capture:!0,passive:!1}),a.addEventListener("keydown",I),o},A=function(){if(h.active)return a.removeEventListener("focusin",P,!0),a.removeEventListener("mousedown",D,!0),a.removeEventListener("touchstart",D,!0),a.removeEventListener("click",R,!0),a.removeEventListener("keydown",G,!0),a.removeEventListener("keydown",I),o},L="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&E(F())})):void 0,S=function(){L&&(L.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){L.observe(e,{subtree:!0,childList:!0})})))};return(o={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=w(e,"onActivate"),n=w(e,"onPostActivate"),o=w(e,"checkCanFocusTrap");o||N(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=a.activeElement,null==t||t();var r=function(){o&&N(),j(),S(),null==n||n()};return o?(o(h.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!h.active)return this;var t=r({onDeactivate:y.onDeactivate,onPostDeactivate:y.onPostDeactivate,checkCanReturnFocus:y.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,A(),h.active=!1,h.paused=!1,S(),c(m,o);var n=w(t,"onDeactivate"),a=w(t,"onPostDeactivate"),i=w(t,"checkCanReturnFocus"),u=w(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var s=function(){d((function(){u&&E(k(h.nodeFocusedBeforeActivation)),null==a||a()}))};return u&&i?(i(k(h.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(h.paused||!h.active)return this;var t=w(e,"onPause"),n=w(e,"onPostPause");return h.paused=!0,null==t||t(),A(),S(),null==n||n(),this},unpause:function(e){if(!h.paused||!h.active)return this;var t=w(e,"onUnpause"),n=w(e,"onPostUnpause");return h.paused=!1,null==t||t(),N(),j(),S(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?a.querySelector(e):e})),h.active&&N(),S(),this}}).updateContainerElements(e),o}}));
//# sourceMappingURL=focus-trap.umd.min.js.map

@@ -70,19 +70,2 @@ import {

// Array.find/findIndex() are not supported on IE; this replicates enough
// of Array.findIndex() for our needs
const findIndex = function (arr, fn) {
let idx = -1;
arr.every(function (value, i) {
if (fn(value)) {
idx = i;
return false; // break
}
return true; // next
});
return idx;
};
/**

@@ -541,4 +524,3 @@ * Get an option's value when it could be a plain value, or a handler that provides

// is the target the first tabbable node in a group?
let startOfGroupIndex = findIndex(
state.tabbableGroups,
let startOfGroupIndex = state.tabbableGroups.findIndex(
({ firstTabbableNode }) => target === firstTabbableNode

@@ -587,4 +569,3 @@ );

// is the target the last tabbable node in a group?
let lastOfGroupIndex = findIndex(
state.tabbableGroups,
let lastOfGroupIndex = state.tabbableGroups.findIndex(
({ lastTabbableNode }) => target === lastTabbableNode

@@ -591,0 +572,0 @@ );

{
"name": "focus-trap",
"version": "7.6.1",
"version": "7.6.2",
"description": "Trap focus within a DOM node.",

@@ -93,3 +93,3 @@ "main": "dist/focus-trap.js",

"prettier": "^3.3.3",
"rollup": "^4.24.4",
"rollup": "^4.25.0",
"rollup-plugin-livereload": "^2.0.5",

@@ -96,0 +96,0 @@ "rollup-plugin-serve": "^3.0.0",

# focus-trap [![CI](https://github.com/focus-trap/focus-trap/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/focus-trap/focus-trap/actions?query=workflow:CI+branch:master) [![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-33-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-34-orange.svg?style=flat-square)](#contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

@@ -420,2 +420,3 @@

<td align="center" valign="top" width="14.28%"><a href="https://github.com/konradr33"><img src="https://avatars.githubusercontent.com/u/32595283?v=4?s=100" width="100px;" alt="konradr33"/><br /><sub><b>konradr33</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Akonradr33" title="Bug reports">๐Ÿ›</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tomasvn"><img src="https://avatars.githubusercontent.com/u/17225564?v=4?s=100" width="100px;" alt="tomasvn"/><br /><sub><b>tomasvn</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=tomasvn" title="Code">๐Ÿ’ป</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/simonxabris"><img src="https://avatars.githubusercontent.com/u/27497229?v=4?s=100" width="100px;" alt="รbris Simon"/><br /><sub><b>รbris Simon</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=simonxabris" title="Code">๐Ÿ’ป</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Asimonxabris" title="Bug reports">๐Ÿ›</a></td>

@@ -422,0 +423,0 @@ </tr>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc