@meddleware/dev 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/docs/.vitepress/cache/deps/@meddleware_ui.js +614 -0
  2. package/docs/.vitepress/cache/deps/@meddleware_ui.js.map +1 -0
  3. package/docs/.vitepress/cache/deps/_metadata.json +56 -0
  4. package/docs/.vitepress/cache/deps/package.json +3 -0
  5. package/docs/.vitepress/cache/deps/vitepress_n_@vue_devtools-api.js +3808 -0
  6. package/docs/.vitepress/cache/deps/vitepress_n_@vue_devtools-api.js.map +1 -0
  7. package/docs/.vitepress/cache/deps/vitepress_n_@vueuse_core.js +10171 -0
  8. package/docs/.vitepress/cache/deps/vitepress_n_@vueuse_core.js.map +1 -0
  9. package/docs/.vitepress/cache/deps/vitepress_n_@vueuse_integrations_useFocusTrap.js +1225 -0
  10. package/docs/.vitepress/cache/deps/vitepress_n_@vueuse_integrations_useFocusTrap.js.map +1 -0
  11. package/docs/.vitepress/cache/deps/vitepress_n_mark__js_src_vanilla__js.js +1492 -0
  12. package/docs/.vitepress/cache/deps/vitepress_n_mark__js_src_vanilla__js.js.map +1 -0
  13. package/docs/.vitepress/cache/deps/vitepress_n_minisearch.js +1773 -0
  14. package/docs/.vitepress/cache/deps/vitepress_n_minisearch.js.map +1 -0
  15. package/docs/.vitepress/cache/deps/vue.js +2 -0
  16. package/docs/.vitepress/cache/deps/vue.runtime.esm-bundler-Bo_ScjpA.js +8890 -0
  17. package/docs/.vitepress/cache/deps/vue.runtime.esm-bundler-Bo_ScjpA.js.map +1 -0
  18. package/docs/.vitepress/config.ts +1 -4
  19. package/docs/.vitepress/theme/Layout.vue +13 -0
  20. package/docs/.vitepress/theme/custom.css +6 -0
  21. package/docs/.vitepress/theme/index.ts +2 -0
  22. package/docs/index.md +0 -4
  23. package/package.json +2 -2
  24. package/tsconfig.json +1 -1
@@ -0,0 +1,1225 @@
1
+ import { U as computed, Yn as shallowRef, er as toValue, gn as watch } from "./vue.runtime.esm-bundler-Bo_ScjpA.js";
2
+ import { notNullish, toArray, tryOnScopeDispose, unrefElement } from "./vitepress_n_@vueuse_core.js";
3
+ //#region node_modules/tabbable/dist/index.esm.js
4
+ /*!
5
+ * tabbable 6.5.0
6
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
7
+ */
8
+ var candidateSelectors = [
9
+ "input:not([inert]):not([inert] *)",
10
+ "select:not([inert]):not([inert] *)",
11
+ "textarea:not([inert]):not([inert] *)",
12
+ "a[href]:not([inert]):not([inert] *)",
13
+ "area[href]:not([inert]):not([inert] *)",
14
+ "button:not([inert]):not([inert] *)",
15
+ "[tabindex]:not(slot):not([inert]):not([inert] *)",
16
+ "audio[controls]:not([inert]):not([inert] *)",
17
+ "video[controls]:not([inert]):not([inert] *)",
18
+ "[contenteditable]:not([contenteditable=\"false\"]):not([inert]):not([inert] *)",
19
+ "details>summary:first-of-type:not([inert]):not([inert] *)",
20
+ "details:not([inert]):not([inert] *)"
21
+ ];
22
+ var candidateSelector = /* #__PURE__ */ candidateSelectors.join(",");
23
+ var NoElement = typeof Element === "undefined";
24
+ var matches = NoElement ? function() {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
25
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
26
+ var _element$getRootNode;
27
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
28
+ } : function(element) {
29
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
30
+ };
31
+ /**
32
+ * Determines if a node is inert or in an inert ancestor.
33
+ * @param {Node} [node]
34
+ * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
35
+ * see if any of them are inert. If false, only `node` itself is considered.
36
+ * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
37
+ * False if `node` is falsy.
38
+ */
39
+ var _isInert = function isInert(node, lookUp) {
40
+ var _node$getAttribute;
41
+ if (lookUp === void 0) lookUp = true;
42
+ var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
43
+ return inertAtt === "" || inertAtt === "true" || lookUp && node && (typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode));
44
+ };
45
+ /**
46
+ * Determines if a node's content is editable.
47
+ * @param {Element} [node]
48
+ * @returns True if it's content-editable; false if it's not or `node` is falsy.
49
+ */
50
+ var isContentEditable = function isContentEditable(node) {
51
+ var _node$getAttribute2;
52
+ var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
53
+ return attValue === "" || attValue === "true";
54
+ };
55
+ /**
56
+ * @param {Element} el container to check in
57
+ * @param {boolean} includeContainer add container to check
58
+ * @param {(node: Element) => boolean} filter filter candidates
59
+ * @returns {Element[]}
60
+ */
61
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
62
+ if (_isInert(el)) return [];
63
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
64
+ if (includeContainer && matches.call(el, candidateSelector)) candidates.unshift(el);
65
+ candidates = candidates.filter(filter);
66
+ return candidates;
67
+ };
68
+ /**
69
+ * @callback GetShadowRoot
70
+ * @param {Element} element to check for shadow root
71
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
72
+ */
73
+ /**
74
+ * @callback ShadowRootFilter
75
+ * @param {Element} shadowHostNode the element which contains shadow content
76
+ * @returns {boolean} true if a shadow root could potentially contain valid candidates.
77
+ */
78
+ /**
79
+ * @typedef {Object} CandidateScope
80
+ * @property {Element} scopeParent contains inner candidates
81
+ * @property {Element[]} candidates list of candidates found in the scope parent
82
+ */
83
+ /**
84
+ * @typedef {Object} IterativeOptions
85
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
86
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
87
+ * or a boolean stating if it has an undisclosed shadow root
88
+ * @property {(node: Element) => boolean} filter filter candidates
89
+ * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
90
+ * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
91
+ */
92
+ /**
93
+ * @param {Element[]} elements list of element containers to match candidates from
94
+ * @param {boolean} includeContainer add container list to check
95
+ * @param {IterativeOptions} options
96
+ * @returns {Array.<Element|CandidateScope>}
97
+ */
98
+ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
99
+ var candidates = [];
100
+ var elementsToCheck = Array.from(elements);
101
+ while (elementsToCheck.length) {
102
+ var element = elementsToCheck.shift();
103
+ if (_isInert(element, false)) continue;
104
+ if (element.tagName === "SLOT") {
105
+ var assigned = element.assignedElements();
106
+ var nestedCandidates = _getCandidatesIteratively(assigned.length ? assigned : element.children, true, options);
107
+ if (options.flatten) candidates.push.apply(candidates, nestedCandidates);
108
+ else candidates.push({
109
+ scopeParent: element,
110
+ candidates: nestedCandidates
111
+ });
112
+ } else {
113
+ if (matches.call(element, candidateSelector) && options.filter(element) && (includeContainer || !elements.includes(element))) candidates.push(element);
114
+ var shadowRoot = element.shadowRoot || typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
115
+ var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
116
+ if (shadowRoot && validShadowRoot) {
117
+ var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
118
+ if (options.flatten) candidates.push.apply(candidates, _nestedCandidates);
119
+ else candidates.push({
120
+ scopeParent: element,
121
+ candidates: _nestedCandidates
122
+ });
123
+ } else elementsToCheck.unshift.apply(elementsToCheck, element.children);
124
+ }
125
+ }
126
+ return candidates;
127
+ };
128
+ /**
129
+ * @private
130
+ * Determines if the node has an explicitly specified `tabindex` attribute.
131
+ * @param {HTMLElement} node
132
+ * @returns {boolean} True if so; false if not.
133
+ */
134
+ var hasTabIndex = function hasTabIndex(node) {
135
+ return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
136
+ };
137
+ /**
138
+ * Determine the tab index of a given node.
139
+ * @param {HTMLElement} node
140
+ * @returns {number} Tab order (negative, 0, or positive number).
141
+ * @throws {Error} If `node` is falsy.
142
+ */
143
+ var getTabIndex = function getTabIndex(node) {
144
+ if (!node) throw new Error("No node provided");
145
+ if (node.tabIndex < 0) {
146
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) return 0;
147
+ }
148
+ return node.tabIndex;
149
+ };
150
+ /**
151
+ * Determine the tab index of a given node __for sort order purposes__.
152
+ * @param {HTMLElement} node
153
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
154
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
155
+ * inserted into the correct sort position.
156
+ * @returns {number} Tab order (negative, 0, or positive number).
157
+ */
158
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
159
+ var tabIndex = getTabIndex(node);
160
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) return 0;
161
+ return tabIndex;
162
+ };
163
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
164
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
165
+ };
166
+ var isInput = function isInput(node) {
167
+ return node.tagName === "INPUT";
168
+ };
169
+ var isHiddenInput = function isHiddenInput(node) {
170
+ return isInput(node) && node.type === "hidden";
171
+ };
172
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
173
+ return node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
174
+ return child.tagName === "SUMMARY";
175
+ });
176
+ };
177
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
178
+ for (var i = 0; i < nodes.length; i++) if (nodes[i].checked && nodes[i].form === form) return nodes[i];
179
+ };
180
+ var isTabbableRadio = function isTabbableRadio(node) {
181
+ if (!node.name) return true;
182
+ var radioScope = node.form || getRootNode(node);
183
+ var queryRadios = function queryRadios(name) {
184
+ return radioScope.querySelectorAll("input[type=\"radio\"][name=\"" + name + "\"]");
185
+ };
186
+ var radioSet;
187
+ if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") radioSet = queryRadios(window.CSS.escape(node.name));
188
+ else try {
189
+ radioSet = queryRadios(node.name);
190
+ } catch (err) {
191
+ console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
192
+ return false;
193
+ }
194
+ var checked = getCheckedRadio(radioSet, node.form);
195
+ return !checked || checked === node;
196
+ };
197
+ var isRadio = function isRadio(node) {
198
+ return isInput(node) && node.type === "radio";
199
+ };
200
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
201
+ return isRadio(node) && !isTabbableRadio(node);
202
+ };
203
+ var isNodeAttached = function isNodeAttached(node) {
204
+ var _nodeRoot;
205
+ var nodeRoot = node && getRootNode(node);
206
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
207
+ var attached = false;
208
+ if (nodeRoot && nodeRoot !== node) {
209
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
210
+ attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
211
+ while (!attached && nodeRootHost) {
212
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
213
+ nodeRoot = getRootNode(nodeRootHost);
214
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
215
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
216
+ }
217
+ }
218
+ return attached;
219
+ };
220
+ var isZeroArea = function isZeroArea(node) {
221
+ var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
222
+ return width === 0 && height === 0;
223
+ };
224
+ var isHidden = function isHidden(node, _ref) {
225
+ var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
226
+ if (displayCheck === "full-native") {
227
+ if ("checkVisibility" in node) return !node.checkVisibility({
228
+ checkOpacity: false,
229
+ opacityProperty: false,
230
+ contentVisibilityAuto: true,
231
+ visibilityProperty: true,
232
+ checkVisibilityCSS: true
233
+ });
234
+ }
235
+ var visibility = getComputedStyle(node).visibility;
236
+ if (visibility === "hidden" || visibility === "collapse") return true;
237
+ var nodeUnderDetails = matches.call(node, "details>summary:first-of-type") ? node.parentElement : node;
238
+ if (matches.call(nodeUnderDetails, "details:not([open]) *")) return true;
239
+ if (!displayCheck || displayCheck === "full" || displayCheck === "full-native" || displayCheck === "legacy-full") {
240
+ if (typeof getShadowRoot === "function") {
241
+ var originalNode = node;
242
+ while (node) {
243
+ var parentElement = node.parentElement;
244
+ var rootNode = getRootNode(node);
245
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) return isZeroArea(node);
246
+ else if (node.assignedSlot) node = node.assignedSlot;
247
+ else if (!parentElement && rootNode !== node.ownerDocument) node = rootNode.host;
248
+ else node = parentElement;
249
+ }
250
+ node = originalNode;
251
+ }
252
+ if (isNodeAttached(node)) return !node.getClientRects().length;
253
+ if (displayCheck !== "legacy-full") return true;
254
+ } else if (displayCheck === "non-zero-area") return isZeroArea(node);
255
+ return false;
256
+ };
257
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
258
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
259
+ var parentNode = node.parentElement;
260
+ while (parentNode) {
261
+ if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
262
+ for (var i = 0; i < parentNode.children.length; i++) {
263
+ var child = parentNode.children.item(i);
264
+ if (child.tagName === "LEGEND") return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
265
+ }
266
+ return true;
267
+ }
268
+ parentNode = parentNode.parentElement;
269
+ }
270
+ }
271
+ return false;
272
+ };
273
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
274
+ if (node.disabled || isHiddenInput(node) || isHidden(node, options) || isDetailsWithSummary(node) || isDisabledFromFieldset(node)) return false;
275
+ return true;
276
+ };
277
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
278
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) return false;
279
+ return true;
280
+ };
281
+ var isShadowRootTabbable = function isShadowRootTabbable(shadowHostNode) {
282
+ var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
283
+ if (isNaN(tabIndex) || tabIndex >= 0) return true;
284
+ return false;
285
+ };
286
+ /**
287
+ * @param {Array.<Element|CandidateScope>} candidates
288
+ * @returns Element[]
289
+ */
290
+ var _sortByOrder = function sortByOrder(candidates) {
291
+ var regularTabbables = [];
292
+ var orderedTabbables = [];
293
+ candidates.forEach(function(item, i) {
294
+ var isScope = !!item.scopeParent;
295
+ var element = isScope ? item.scopeParent : item;
296
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
297
+ var elements = isScope ? _sortByOrder(item.candidates) : element;
298
+ if (candidateTabindex === 0) isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
299
+ else orderedTabbables.push({
300
+ documentOrder: i,
301
+ tabIndex: candidateTabindex,
302
+ item,
303
+ isScope,
304
+ content: elements
305
+ });
306
+ });
307
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
308
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
309
+ return acc;
310
+ }, []).concat(regularTabbables);
311
+ };
312
+ var tabbable = function tabbable(container, options) {
313
+ options = options || {};
314
+ var candidates;
315
+ if (options.getShadowRoot) candidates = _getCandidatesIteratively([container], options.includeContainer, {
316
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
317
+ flatten: false,
318
+ getShadowRoot: options.getShadowRoot,
319
+ shadowRootFilter: isShadowRootTabbable
320
+ });
321
+ else candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
322
+ return _sortByOrder(candidates);
323
+ };
324
+ var focusable = function focusable(container, options) {
325
+ options = options || {};
326
+ var candidates;
327
+ if (options.getShadowRoot) candidates = _getCandidatesIteratively([container], options.includeContainer, {
328
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
329
+ flatten: true,
330
+ getShadowRoot: options.getShadowRoot
331
+ });
332
+ else candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
333
+ return candidates;
334
+ };
335
+ var isTabbable = function isTabbable(node, options) {
336
+ options = options || {};
337
+ if (!node) throw new Error("No node provided");
338
+ if (matches.call(node, candidateSelector) === false) return false;
339
+ return isNodeMatchingSelectorTabbable(options, node);
340
+ };
341
+ var focusableCandidateSelector = /* #__PURE__ */ candidateSelectors.concat("iframe:not([inert]):not([inert] *)").join(",");
342
+ var isFocusable = function isFocusable(node, options) {
343
+ options = options || {};
344
+ if (!node) throw new Error("No node provided");
345
+ if (matches.call(node, focusableCandidateSelector) === false) return false;
346
+ return isNodeMatchingSelectorFocusable(options, node);
347
+ };
348
+ //#endregion
349
+ //#region node_modules/focus-trap/dist/focus-trap.esm.js
350
+ /*!
351
+ * focus-trap 8.2.2
352
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
353
+ */
354
+ function _arrayLikeToArray(r, a) {
355
+ (null == a || a > r.length) && (a = r.length);
356
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
357
+ return n;
358
+ }
359
+ function _arrayWithoutHoles(r) {
360
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
361
+ }
362
+ function _createForOfIteratorHelper(r, e) {
363
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
364
+ if (!t) {
365
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
366
+ t && (r = t);
367
+ var n = 0, F = function() {};
368
+ return {
369
+ s: F,
370
+ n: function() {
371
+ return n >= r.length ? { done: true } : {
372
+ done: false,
373
+ value: r[n++]
374
+ };
375
+ },
376
+ e: function(r) {
377
+ throw r;
378
+ },
379
+ f: F
380
+ };
381
+ }
382
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
383
+ }
384
+ var o, a = true, u = false;
385
+ return {
386
+ s: function() {
387
+ t = t.call(r);
388
+ },
389
+ n: function() {
390
+ var r = t.next();
391
+ return a = r.done, r;
392
+ },
393
+ e: function(r) {
394
+ u = true, o = r;
395
+ },
396
+ f: function() {
397
+ try {
398
+ a || null == t.return || t.return();
399
+ } finally {
400
+ if (u) throw o;
401
+ }
402
+ }
403
+ };
404
+ }
405
+ function _defineProperty(e, r, t) {
406
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
407
+ value: t,
408
+ enumerable: true,
409
+ configurable: true,
410
+ writable: true
411
+ }) : e[r] = t, e;
412
+ }
413
+ function _iterableToArray(r) {
414
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
415
+ }
416
+ function _nonIterableSpread() {
417
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
418
+ }
419
+ function ownKeys(e, r) {
420
+ var t = Object.keys(e);
421
+ if (Object.getOwnPropertySymbols) {
422
+ var o = Object.getOwnPropertySymbols(e);
423
+ r && (o = o.filter(function(r) {
424
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
425
+ })), t.push.apply(t, o);
426
+ }
427
+ return t;
428
+ }
429
+ function _objectSpread2(e) {
430
+ for (var r = 1; r < arguments.length; r++) {
431
+ var t = null != arguments[r] ? arguments[r] : {};
432
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r) {
433
+ _defineProperty(e, r, t[r]);
434
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
435
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
436
+ });
437
+ }
438
+ return e;
439
+ }
440
+ function _toConsumableArray(r) {
441
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
442
+ }
443
+ function _toPrimitive(t, r) {
444
+ if ("object" != typeof t || !t) return t;
445
+ var e = t[Symbol.toPrimitive];
446
+ if (void 0 !== e) {
447
+ var i = e.call(t, r);
448
+ if ("object" != typeof i) return i;
449
+ throw new TypeError("@@toPrimitive must return a primitive value.");
450
+ }
451
+ return ("string" === r ? String : Number)(t);
452
+ }
453
+ function _toPropertyKey(t) {
454
+ var i = _toPrimitive(t, "string");
455
+ return "symbol" == typeof i ? i : i + "";
456
+ }
457
+ function _unsupportedIterableToArray(r, a) {
458
+ if (r) {
459
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
460
+ var t = {}.toString.call(r).slice(8, -1);
461
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
462
+ }
463
+ }
464
+ var activeFocusTraps = {
465
+ getActiveTrap: function getActiveTrap(trapStack) {
466
+ if ((trapStack === null || trapStack === void 0 ? void 0 : trapStack.length) > 0) return trapStack[trapStack.length - 1];
467
+ return null;
468
+ },
469
+ activateTrap: function activateTrap(trapStack, trap) {
470
+ if (trap !== activeFocusTraps.getActiveTrap(trapStack)) activeFocusTraps.pauseTrap(trapStack);
471
+ var trapIndex = trapStack.indexOf(trap);
472
+ if (trapIndex === -1) trapStack.push(trap);
473
+ else {
474
+ trapStack.splice(trapIndex, 1);
475
+ trapStack.push(trap);
476
+ }
477
+ },
478
+ deactivateTrap: function deactivateTrap(trapStack, trap) {
479
+ var trapIndex = trapStack.indexOf(trap);
480
+ if (trapIndex !== -1) trapStack.splice(trapIndex, 1);
481
+ activeFocusTraps.unpauseTrap(trapStack);
482
+ },
483
+ pauseTrap: function pauseTrap(trapStack) {
484
+ var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
485
+ activeTrap === null || activeTrap === void 0 || activeTrap._setPausedState(true);
486
+ },
487
+ unpauseTrap: function unpauseTrap(trapStack) {
488
+ var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
489
+ if (activeTrap && !activeTrap._isManuallyPaused()) activeTrap._setPausedState(false);
490
+ }
491
+ };
492
+ var isSelectableInput = function isSelectableInput(node) {
493
+ return node.tagName && node.tagName.toLowerCase() === "input" && typeof node.select === "function";
494
+ };
495
+ var isEscapeEvent = function isEscapeEvent(e) {
496
+ return (e === null || e === void 0 ? void 0 : e.key) === "Escape" || (e === null || e === void 0 ? void 0 : e.key) === "Esc" || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
497
+ };
498
+ var isTabEvent = function isTabEvent(e) {
499
+ return (e === null || e === void 0 ? void 0 : e.key) === "Tab" || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
500
+ };
501
+ var isKeyForward = function isKeyForward(e) {
502
+ return isTabEvent(e) && !e.shiftKey;
503
+ };
504
+ var isKeyBackward = function isKeyBackward(e) {
505
+ return isTabEvent(e) && e.shiftKey;
506
+ };
507
+ var delay = function delay(fn) {
508
+ return setTimeout(fn, 0);
509
+ };
510
+ /**
511
+ * Get an option's value when it could be a plain value, or a handler that provides
512
+ * the value.
513
+ * @param {*} value Option's value to check.
514
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
515
+ * @returns {*} The `value`, or the handler's returned value.
516
+ */
517
+ var valueOrHandler = function valueOrHandler(value) {
518
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) params[_key - 1] = arguments[_key];
519
+ return typeof value === "function" ? value.apply(void 0, params) : value;
520
+ };
521
+ var getActualTarget = function getActualTarget(event) {
522
+ return event.target.shadowRoot && typeof event.composedPath === "function" ? event.composedPath()[0] : event.target;
523
+ };
524
+ var internalTrapStack = [];
525
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
526
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
527
+ var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
528
+ var config = _objectSpread2({
529
+ returnFocusOnDeactivate: true,
530
+ escapeDeactivates: true,
531
+ delayInitialFocus: true,
532
+ delayReturnFocus: true,
533
+ isolateSubtrees: false,
534
+ isKeyForward,
535
+ isKeyBackward
536
+ }, userOptions);
537
+ var state = {
538
+ /** @type {Array<HTMLElement>} */
539
+ containers: [],
540
+ /** @type {Array<{
541
+ * container: HTMLElement,
542
+ * tabbableNodes: Array<HTMLElement>, // empty if none
543
+ * focusableNodes: Array<HTMLElement>, // empty if none
544
+ * posTabIndexesFound: boolean,
545
+ * firstTabbableNode: HTMLElement|undefined,
546
+ * lastTabbableNode: HTMLElement|undefined,
547
+ * firstDomTabbableNode: HTMLElement|undefined,
548
+ * lastDomTabbableNode: HTMLElement|undefined,
549
+ * nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
550
+ * }>}
551
+ */
552
+ containerGroups: [],
553
+ tabbableGroups: [],
554
+ /** @type {Set<HTMLElement>} */
555
+ adjacentElements: /* @__PURE__ */ new Set(),
556
+ /** @type {Set<HTMLElement>} */
557
+ alreadySilent: /* @__PURE__ */ new Set(),
558
+ nodeFocusedBeforeActivation: null,
559
+ mostRecentlyFocusedNode: null,
560
+ active: false,
561
+ paused: false,
562
+ manuallyPaused: false,
563
+ delayInitialFocusTimer: void 0,
564
+ recentNavEvent: void 0
565
+ };
566
+ var trap;
567
+ /**
568
+ * Gets a configuration option value.
569
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
570
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
571
+ * @param {string} optionName Name of the option whose value is sought.
572
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
573
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
574
+ */
575
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
576
+ return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : config[configOptionName || optionName];
577
+ };
578
+ /**
579
+ * Finds the index of the container that contains the element.
580
+ * @param {HTMLElement} element
581
+ * @param {Event} [event] If available, and `element` isn't directly found in any container,
582
+ * the event's composed path is used to see if includes any known trap containers in the
583
+ * case where the element is inside a Shadow DOM.
584
+ * @returns {number} Index of the container in either `state.containers` or
585
+ * `state.containerGroups` (the order/length of these lists are the same); -1
586
+ * if the element isn't found.
587
+ */
588
+ var findContainerIndex = function findContainerIndex(element, event) {
589
+ var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === "function" ? event.composedPath() : void 0;
590
+ return state.containerGroups.findIndex(function(_ref) {
591
+ var container = _ref.container, tabbableNodes = _ref.tabbableNodes;
592
+ return container.contains(element) || (composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function(node) {
593
+ return node === element;
594
+ });
595
+ });
596
+ };
597
+ /**
598
+ * Gets the node for the given option, which is expected to be an option that
599
+ * can be either a DOM node, a string that is a selector to get a node, `false`
600
+ * (if a node is explicitly NOT given), or a function that returns any of these
601
+ * values.
602
+ * @param {string} optionName
603
+ * @param {Object} options
604
+ * @param {boolean} [options.hasFallback] True if the option could be a selector string
605
+ * and the option allows for a fallback scenario in the case where the selector is
606
+ * valid but does not match a node (i.e. the queried node doesn't exist in the DOM).
607
+ * @param {Array} [options.params] Params to pass to the option if it's a function.
608
+ * @returns {undefined | null | false | HTMLElement | SVGElement} Returns
609
+ * `undefined` if the option is not specified; `null` if the option didn't resolve
610
+ * to a node but `options.hasFallback=true`, `false` if the option resolved to `false`
611
+ * (node explicitly not given); otherwise, the resolved DOM node.
612
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
613
+ * resolve to a node, unless the option is a selector string and `options.hasFallback=true`.
614
+ */
615
+ var getNodeForOption = function getNodeForOption(optionName) {
616
+ var _ref2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref2$hasFallback = _ref2.hasFallback, hasFallback = _ref2$hasFallback === void 0 ? false : _ref2$hasFallback, _ref2$params = _ref2.params, params = _ref2$params === void 0 ? [] : _ref2$params;
617
+ var optionValue = config[optionName];
618
+ if (typeof optionValue === "function") optionValue = optionValue.apply(void 0, _toConsumableArray(params));
619
+ if (optionValue === true) optionValue = void 0;
620
+ if (!optionValue) {
621
+ if (optionValue === void 0 || optionValue === false) return optionValue;
622
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
623
+ }
624
+ var node = optionValue;
625
+ if (typeof optionValue === "string") {
626
+ try {
627
+ node = doc.querySelector(optionValue);
628
+ } catch (err) {
629
+ throw new Error("`".concat(optionName, "` appears to be an invalid selector; error=\"").concat(err.message, "\""));
630
+ }
631
+ if (!node) {
632
+ if (!hasFallback) throw new Error("`".concat(optionName, "` as selector refers to no known node"));
633
+ }
634
+ }
635
+ return node;
636
+ };
637
+ /**
638
+ * Gets the current activeElement. If it's a web-component and has open shadow-root
639
+ * it will recursively search inside shadow roots for the "true" activeElement.
640
+ *
641
+ * @param {Document | ShadowRoot} el
642
+ *
643
+ * @returns {HTMLElement|null} The element that currently has the focus. `null` if a focused element isn't found.
644
+ **/
645
+ var _getActiveElement = function getActiveElement(el) {
646
+ var activeElement = el.activeElement;
647
+ if (!activeElement) return null;
648
+ if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) return _getActiveElement(activeElement.shadowRoot);
649
+ return activeElement;
650
+ };
651
+ var getInitialFocusNode = function getInitialFocusNode() {
652
+ var node = getNodeForOption("initialFocus", { hasFallback: true });
653
+ if (node === false) return false;
654
+ if (node === void 0 || node && !isFocusable(node, config.tabbableOptions)) {
655
+ var activeElement = _getActiveElement(doc);
656
+ if (findContainerIndex(activeElement) >= 0) node = activeElement;
657
+ else {
658
+ var firstTabbableGroup = state.tabbableGroups[0];
659
+ node = firstTabbableGroup && firstTabbableGroup.firstTabbableNode || getNodeForOption("fallbackFocus");
660
+ }
661
+ } else if (node === null) node = getNodeForOption("fallbackFocus");
662
+ if (!node) throw new Error("Your focus-trap needs to have at least one focusable element");
663
+ return node;
664
+ };
665
+ var updateTabbableNodes = function updateTabbableNodes() {
666
+ state.containerGroups = state.containers.map(function(container) {
667
+ var tabbableNodes = tabbable(container, config.tabbableOptions);
668
+ var focusableNodes = focusable(container, config.tabbableOptions);
669
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : void 0;
670
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : void 0;
671
+ var firstDomTabbableNode = focusableNodes.find(function(node) {
672
+ return isTabbable(node);
673
+ });
674
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function(node) {
675
+ return isTabbable(node);
676
+ });
677
+ return {
678
+ container,
679
+ tabbableNodes,
680
+ focusableNodes,
681
+ /** True if at least one node with positive `tabindex` was found in this container. */
682
+ posTabIndexesFound: !!tabbableNodes.find(function(node) {
683
+ return getTabIndex(node) > 0;
684
+ }),
685
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
686
+ firstTabbableNode,
687
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
688
+ lastTabbableNode,
689
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
690
+ firstDomTabbableNode,
691
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
692
+ lastDomTabbableNode,
693
+ /**
694
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
695
+ * in this container, if any.
696
+ * @param {HTMLElement} node
697
+ * @param {boolean} [forward] True if going in forward tab order; false if going
698
+ * in reverse.
699
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
700
+ */
701
+ nextTabbableNode: function nextTabbableNode(node) {
702
+ var forward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
703
+ var nodeIdx = tabbableNodes.indexOf(node);
704
+ if (nodeIdx < 0) {
705
+ if (forward) return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function(el) {
706
+ return isTabbable(el);
707
+ });
708
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function(el) {
709
+ return isTabbable(el);
710
+ });
711
+ }
712
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
713
+ }
714
+ };
715
+ });
716
+ state.tabbableGroups = state.containerGroups.filter(function(group) {
717
+ return group.tabbableNodes.length > 0;
718
+ });
719
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption("fallbackFocus")) throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
720
+ if (state.containerGroups.find(function(g) {
721
+ return g.posTabIndexesFound;
722
+ }) && state.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.");
723
+ };
724
+ var _tryFocus = function tryFocus(node) {
725
+ if (node === false) return;
726
+ if (node === _getActiveElement(document)) return;
727
+ if (!node || !node.focus) {
728
+ _tryFocus(getInitialFocusNode());
729
+ return;
730
+ }
731
+ node.focus({ preventScroll: !!config.preventScroll });
732
+ state.mostRecentlyFocusedNode = node;
733
+ if (isSelectableInput(node)) node.select();
734
+ };
735
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
736
+ var node = getNodeForOption("setReturnFocus", { params: [previousActiveElement] });
737
+ return node ? node : node === false ? false : previousActiveElement;
738
+ };
739
+ /**
740
+ * Finds the next node (in either direction) where focus should move according to a
741
+ * keyboard focus-in event.
742
+ * @param {Object} params
743
+ * @param {Node} [params.target] Known target __from which__ to navigate, if any.
744
+ * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
745
+ * will be used to determine the `target`). Ignored if `target` is specified.
746
+ * @param {boolean} [params.isBackward] True if focus should move backward.
747
+ * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
748
+ * determined given the current state of the trap.
749
+ */
750
+ var findNextNavNode = function findNextNavNode(_ref3) {
751
+ var target = _ref3.target, event = _ref3.event, _ref3$isBackward = _ref3.isBackward, isBackward = _ref3$isBackward === void 0 ? false : _ref3$isBackward;
752
+ target = target || getActualTarget(event);
753
+ updateTabbableNodes();
754
+ var destinationNode = null;
755
+ if (state.tabbableGroups.length > 0) {
756
+ var containerIndex = findContainerIndex(target, event);
757
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : void 0;
758
+ if (containerIndex < 0) {
759
+ if (isBackward) destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
760
+ else destinationNode = state.tabbableGroups[0].firstTabbableNode;
761
+ } else if (isBackward) {
762
+ var startOfGroupIndex = state.tabbableGroups.findIndex(function(_ref4) {
763
+ var firstTabbableNode = _ref4.firstTabbableNode;
764
+ return target === firstTabbableNode;
765
+ });
766
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) startOfGroupIndex = containerIndex;
767
+ if (startOfGroupIndex >= 0) {
768
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
769
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
770
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
771
+ } else if (!isTabEvent(event)) destinationNode = containerGroup.nextTabbableNode(target, false);
772
+ } else {
773
+ var lastOfGroupIndex = state.tabbableGroups.findIndex(function(_ref5) {
774
+ var lastTabbableNode = _ref5.lastTabbableNode;
775
+ return target === lastTabbableNode;
776
+ });
777
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) lastOfGroupIndex = containerIndex;
778
+ if (lastOfGroupIndex >= 0) {
779
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
780
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
781
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
782
+ } else if (!isTabEvent(event)) destinationNode = containerGroup.nextTabbableNode(target);
783
+ }
784
+ } else destinationNode = getNodeForOption("fallbackFocus");
785
+ return destinationNode;
786
+ };
787
+ var checkPointerDown = function checkPointerDown(e) {
788
+ if (findContainerIndex(getActualTarget(e), e) >= 0) return;
789
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
790
+ trap.deactivate({ returnFocus: config.returnFocusOnDeactivate });
791
+ return;
792
+ }
793
+ if (valueOrHandler(config.allowOutsideClick, e)) return;
794
+ e.preventDefault();
795
+ };
796
+ var checkFocusIn = function checkFocusIn(event) {
797
+ var target = getActualTarget(event);
798
+ var targetContained = findContainerIndex(target, event) >= 0;
799
+ if (targetContained || target instanceof Document) {
800
+ if (targetContained) state.mostRecentlyFocusedNode = target;
801
+ } else {
802
+ event.stopImmediatePropagation();
803
+ var nextNode;
804
+ var navAcrossContainers = true;
805
+ if (state.mostRecentlyFocusedNode) {
806
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
807
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
808
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
809
+ if (tabbableNodes.length > 0) {
810
+ var mruTabIdx = tabbableNodes.findIndex(function(node) {
811
+ return node === state.mostRecentlyFocusedNode;
812
+ });
813
+ if (mruTabIdx >= 0) {
814
+ if (config.isKeyForward(state.recentNavEvent)) {
815
+ if (mruTabIdx + 1 < tabbableNodes.length) {
816
+ nextNode = tabbableNodes[mruTabIdx + 1];
817
+ navAcrossContainers = false;
818
+ }
819
+ } else if (mruTabIdx - 1 >= 0) {
820
+ nextNode = tabbableNodes[mruTabIdx - 1];
821
+ navAcrossContainers = false;
822
+ }
823
+ }
824
+ }
825
+ } else if (!state.containerGroups.some(function(g) {
826
+ return g.tabbableNodes.some(function(n) {
827
+ return getTabIndex(n) > 0;
828
+ });
829
+ })) navAcrossContainers = false;
830
+ } else navAcrossContainers = false;
831
+ if (navAcrossContainers) nextNode = findNextNavNode({
832
+ target: state.mostRecentlyFocusedNode,
833
+ isBackward: config.isKeyBackward(state.recentNavEvent)
834
+ });
835
+ if (nextNode) _tryFocus(nextNode);
836
+ else _tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
837
+ }
838
+ state.recentNavEvent = void 0;
839
+ };
840
+ var checkKeyNav = function checkKeyNav(event) {
841
+ var isBackward = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
842
+ state.recentNavEvent = event;
843
+ var destinationNode = findNextNavNode({
844
+ event,
845
+ isBackward
846
+ });
847
+ if (destinationNode) {
848
+ if (isTabEvent(event)) event.preventDefault();
849
+ _tryFocus(destinationNode);
850
+ }
851
+ };
852
+ var checkTabKey = function checkTabKey(event) {
853
+ if (config.isKeyForward(event) || config.isKeyBackward(event)) checkKeyNav(event, config.isKeyBackward(event));
854
+ };
855
+ var checkEscapeKey = function checkEscapeKey(event) {
856
+ if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
857
+ event.preventDefault();
858
+ trap.deactivate();
859
+ }
860
+ };
861
+ var checkClick = function checkClick(e) {
862
+ if (findContainerIndex(getActualTarget(e), e) >= 0) return;
863
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) return;
864
+ if (valueOrHandler(config.allowOutsideClick, e)) return;
865
+ e.preventDefault();
866
+ e.stopImmediatePropagation();
867
+ };
868
+ /**
869
+ * Adds listeners to the document necessary for trapping focus and attempts to set focus
870
+ * to the configured initial focus node. Does nothing if the trap isn't active.
871
+ * @returns {Promise<void> | undefined} A promise resolved once the initial focus node has
872
+ * been focused when `delayInitialFocus=true`; `undefined` when focus is set synchronously
873
+ * or the trap isn't active.
874
+ */
875
+ var addListeners = function addListeners() {
876
+ if (!state.active) return;
877
+ activeFocusTraps.activateTrap(trapStack, trap);
878
+ /** @type {Promise<void> | undefined} */
879
+ var promise;
880
+ if (config.delayInitialFocus) promise = new Promise(function(resolve) {
881
+ state.delayInitialFocusTimer = delay(function() {
882
+ _tryFocus(getInitialFocusNode());
883
+ resolve();
884
+ });
885
+ });
886
+ else _tryFocus(getInitialFocusNode());
887
+ doc.addEventListener("focusin", checkFocusIn, true);
888
+ doc.addEventListener("mousedown", checkPointerDown, {
889
+ capture: true,
890
+ passive: false
891
+ });
892
+ doc.addEventListener("touchstart", checkPointerDown, {
893
+ capture: true,
894
+ passive: false
895
+ });
896
+ doc.addEventListener("click", checkClick, {
897
+ capture: true,
898
+ passive: false
899
+ });
900
+ doc.addEventListener("keydown", checkTabKey, {
901
+ capture: true,
902
+ passive: false
903
+ });
904
+ doc.addEventListener("keydown", checkEscapeKey);
905
+ return promise;
906
+ };
907
+ /**
908
+ * Traverses up the DOM from each of `containers`, collecting references to
909
+ * the elements that are siblings to `container` or an ancestor of `container`.
910
+ * @param {Array<HTMLElement>} containers
911
+ */
912
+ var collectAdjacentElements = function collectAdjacentElements(containers) {
913
+ if (state.active && !state.paused) trap._setSubtreeIsolation(false);
914
+ state.adjacentElements.clear();
915
+ state.alreadySilent.clear();
916
+ var containerAncestors = /* @__PURE__ */ new Set();
917
+ var adjacentElements = /* @__PURE__ */ new Set();
918
+ var _iterator = _createForOfIteratorHelper(containers), _step;
919
+ try {
920
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
921
+ var container = _step.value;
922
+ containerAncestors.add(container);
923
+ var insideShadowRoot = typeof ShadowRoot !== "undefined" && container.getRootNode() instanceof ShadowRoot;
924
+ var current = container;
925
+ while (current) {
926
+ containerAncestors.add(current);
927
+ var parent = current.parentElement;
928
+ var siblings = [];
929
+ if (parent) siblings = parent.children;
930
+ else if (!parent && insideShadowRoot) {
931
+ siblings = current.getRootNode().children;
932
+ parent = current.getRootNode().host;
933
+ insideShadowRoot = typeof ShadowRoot !== "undefined" && parent.getRootNode() instanceof ShadowRoot;
934
+ }
935
+ var _iterator2 = _createForOfIteratorHelper(siblings), _step2;
936
+ try {
937
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
938
+ var child = _step2.value;
939
+ adjacentElements.add(child);
940
+ }
941
+ } catch (err) {
942
+ _iterator2.e(err);
943
+ } finally {
944
+ _iterator2.f();
945
+ }
946
+ current = parent;
947
+ }
948
+ }
949
+ } catch (err) {
950
+ _iterator.e(err);
951
+ } finally {
952
+ _iterator.f();
953
+ }
954
+ containerAncestors.forEach(function(el) {
955
+ adjacentElements["delete"](el);
956
+ });
957
+ state.adjacentElements = adjacentElements;
958
+ };
959
+ var removeListeners = function removeListeners() {
960
+ if (!state.active) return;
961
+ doc.removeEventListener("focusin", checkFocusIn, true);
962
+ doc.removeEventListener("mousedown", checkPointerDown, true);
963
+ doc.removeEventListener("touchstart", checkPointerDown, true);
964
+ doc.removeEventListener("click", checkClick, true);
965
+ doc.removeEventListener("keydown", checkTabKey, true);
966
+ doc.removeEventListener("keydown", checkEscapeKey);
967
+ return trap;
968
+ };
969
+ var mutationObserver = typeof window !== "undefined" && "MutationObserver" in window ? new MutationObserver(function checkDomRemoval(mutations) {
970
+ var focusedNode = state.mostRecentlyFocusedNode;
971
+ if (!focusedNode) return;
972
+ if (mutations.some(function(mutation) {
973
+ return Array.from(mutation.removedNodes).some(function(node) {
974
+ return node === focusedNode || typeof node.contains === "function" && node.contains(focusedNode);
975
+ });
976
+ }) && state.containers.some(function(container) {
977
+ return container === null || container === void 0 ? void 0 : container.isConnected;
978
+ })) {
979
+ updateTabbableNodes();
980
+ _tryFocus(getInitialFocusNode());
981
+ }
982
+ }) : void 0;
983
+ var updateObservedNodes = function updateObservedNodes() {
984
+ if (!mutationObserver) return;
985
+ mutationObserver.disconnect();
986
+ if (state.active && !state.paused) state.containers.map(function(container) {
987
+ mutationObserver.observe(container, {
988
+ subtree: true,
989
+ childList: true
990
+ });
991
+ });
992
+ };
993
+ trap = {
994
+ get active() {
995
+ return state.active;
996
+ },
997
+ get paused() {
998
+ return state.paused;
999
+ },
1000
+ activate: function activate(activateOptions) {
1001
+ if (state.active) return this;
1002
+ var onActivate = getOption(activateOptions, "onActivate");
1003
+ var onPostActivate = getOption(activateOptions, "onPostActivate");
1004
+ var checkCanFocusTrap = getOption(activateOptions, "checkCanFocusTrap");
1005
+ var preexistingTrap = activeFocusTraps.getActiveTrap(trapStack);
1006
+ var revertState = false;
1007
+ if (preexistingTrap && !preexistingTrap.paused) {
1008
+ var _preexistingTrap$_set;
1009
+ (_preexistingTrap$_set = preexistingTrap._setSubtreeIsolation) === null || _preexistingTrap$_set === void 0 || _preexistingTrap$_set.call(preexistingTrap, false);
1010
+ revertState = true;
1011
+ }
1012
+ try {
1013
+ if (!checkCanFocusTrap) updateTabbableNodes();
1014
+ state.active = true;
1015
+ state.paused = false;
1016
+ state.nodeFocusedBeforeActivation = _getActiveElement(doc);
1017
+ onActivate === null || onActivate === void 0 || onActivate({ trap });
1018
+ var finishActivation = function finishActivation() {
1019
+ if (checkCanFocusTrap) updateTabbableNodes();
1020
+ var afterListeners = function afterListeners() {
1021
+ trap._setSubtreeIsolation(true);
1022
+ updateObservedNodes();
1023
+ onPostActivate === null || onPostActivate === void 0 || onPostActivate({ trap });
1024
+ };
1025
+ var listenersPromise = addListeners();
1026
+ if (listenersPromise) listenersPromise.then(afterListeners);
1027
+ else afterListeners();
1028
+ };
1029
+ if (checkCanFocusTrap) {
1030
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
1031
+ return this;
1032
+ }
1033
+ finishActivation();
1034
+ } catch (error) {
1035
+ if (preexistingTrap === activeFocusTraps.getActiveTrap(trapStack) && revertState) {
1036
+ var _preexistingTrap$_set2;
1037
+ (_preexistingTrap$_set2 = preexistingTrap._setSubtreeIsolation) === null || _preexistingTrap$_set2 === void 0 || _preexistingTrap$_set2.call(preexistingTrap, true);
1038
+ }
1039
+ throw error;
1040
+ }
1041
+ return this;
1042
+ },
1043
+ deactivate: function deactivate(deactivateOptions) {
1044
+ if (!state.active) return this;
1045
+ var options = _objectSpread2({
1046
+ onDeactivate: config.onDeactivate,
1047
+ onPostDeactivate: config.onPostDeactivate,
1048
+ checkCanReturnFocus: config.checkCanReturnFocus
1049
+ }, deactivateOptions);
1050
+ clearTimeout(state.delayInitialFocusTimer);
1051
+ state.delayInitialFocusTimer = void 0;
1052
+ if (!state.paused) trap._setSubtreeIsolation(false);
1053
+ state.alreadySilent.clear();
1054
+ removeListeners();
1055
+ state.active = false;
1056
+ state.paused = false;
1057
+ updateObservedNodes();
1058
+ activeFocusTraps.deactivateTrap(trapStack, trap);
1059
+ var onDeactivate = getOption(options, "onDeactivate");
1060
+ var onPostDeactivate = getOption(options, "onPostDeactivate");
1061
+ var checkCanReturnFocus = getOption(options, "checkCanReturnFocus");
1062
+ var delayReturnFocus = getOption(options, "delayReturnFocus");
1063
+ var returnFocus = getOption(options, "returnFocus", "returnFocusOnDeactivate");
1064
+ onDeactivate === null || onDeactivate === void 0 || onDeactivate({ trap });
1065
+ var completeDeactivation = function completeDeactivation() {
1066
+ if (returnFocus) _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
1067
+ onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate({ trap });
1068
+ };
1069
+ var finishDeactivation = function finishDeactivation() {
1070
+ if (delayReturnFocus && returnFocus) delay(completeDeactivation);
1071
+ else completeDeactivation();
1072
+ };
1073
+ if (returnFocus && checkCanReturnFocus) {
1074
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
1075
+ return this;
1076
+ }
1077
+ finishDeactivation();
1078
+ return this;
1079
+ },
1080
+ pause: function pause(pauseOptions) {
1081
+ if (!state.active) return this;
1082
+ state.manuallyPaused = true;
1083
+ return this._setPausedState(true, pauseOptions);
1084
+ },
1085
+ unpause: function unpause(unpauseOptions) {
1086
+ if (!state.active) return this;
1087
+ state.manuallyPaused = false;
1088
+ if (trapStack[trapStack.length - 1] !== this) return this;
1089
+ return this._setPausedState(false, unpauseOptions);
1090
+ },
1091
+ updateContainerElements: function updateContainerElements(containerElements) {
1092
+ state.containers = [].concat(containerElements).filter(Boolean).map(function(element) {
1093
+ return typeof element === "string" ? doc.querySelector(element) : element;
1094
+ });
1095
+ if (config.isolateSubtrees) collectAdjacentElements(state.containers);
1096
+ if (state.active) {
1097
+ updateTabbableNodes();
1098
+ if (!state.paused) trap._setSubtreeIsolation(true);
1099
+ }
1100
+ updateObservedNodes();
1101
+ return this;
1102
+ }
1103
+ };
1104
+ Object.defineProperties(trap, {
1105
+ _isManuallyPaused: { value: function value() {
1106
+ return state.manuallyPaused;
1107
+ } },
1108
+ _setPausedState: { value: function value(paused, options) {
1109
+ if (state.paused === paused) return this;
1110
+ state.paused = paused;
1111
+ if (paused) {
1112
+ var onPause = getOption(options, "onPause");
1113
+ var onPostPause = getOption(options, "onPostPause");
1114
+ onPause === null || onPause === void 0 || onPause({ trap });
1115
+ removeListeners();
1116
+ trap._setSubtreeIsolation(false);
1117
+ updateObservedNodes();
1118
+ onPostPause === null || onPostPause === void 0 || onPostPause({ trap });
1119
+ } else {
1120
+ var onUnpause = getOption(options, "onUnpause");
1121
+ var onPostUnpause = getOption(options, "onPostUnpause");
1122
+ onUnpause === null || onUnpause === void 0 || onUnpause({ trap });
1123
+ (function finishUnpause() {
1124
+ updateTabbableNodes();
1125
+ var afterListeners = function afterListeners() {
1126
+ trap._setSubtreeIsolation(true);
1127
+ updateObservedNodes();
1128
+ onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause({ trap });
1129
+ };
1130
+ var listenersPromise = addListeners();
1131
+ if (listenersPromise) listenersPromise.then(afterListeners);
1132
+ else afterListeners();
1133
+ })();
1134
+ }
1135
+ return this;
1136
+ } },
1137
+ _setSubtreeIsolation: { value: function value(isEnabled) {
1138
+ if (config.isolateSubtrees) state.adjacentElements.forEach(function(el) {
1139
+ var _el$getAttribute;
1140
+ if (isEnabled) switch (config.isolateSubtrees) {
1141
+ case "aria-hidden":
1142
+ if (el.ariaHidden === "true" || ((_el$getAttribute = el.getAttribute("aria-hidden")) === null || _el$getAttribute === void 0 ? void 0 : _el$getAttribute.toLowerCase()) === "true") state.alreadySilent.add(el);
1143
+ el.setAttribute("aria-hidden", "true");
1144
+ break;
1145
+ default:
1146
+ if (el.inert || el.hasAttribute("inert")) state.alreadySilent.add(el);
1147
+ el.setAttribute("inert", true);
1148
+ }
1149
+ else if (state.alreadySilent.has(el));
1150
+ else switch (config.isolateSubtrees) {
1151
+ case "aria-hidden":
1152
+ el.removeAttribute("aria-hidden");
1153
+ break;
1154
+ default: el.removeAttribute("inert");
1155
+ }
1156
+ });
1157
+ } }
1158
+ });
1159
+ trap.updateContainerElements(elements);
1160
+ return trap;
1161
+ };
1162
+ //#endregion
1163
+ //#region node_modules/@vueuse/integrations/dist/useFocusTrap.js
1164
+ /**
1165
+ * Reactive focus-trap
1166
+ *
1167
+ * @see https://vueuse.org/useFocusTrap
1168
+ */
1169
+ function useFocusTrap(target, options = {}) {
1170
+ let trap;
1171
+ const { immediate, ...focusTrapOptions } = options;
1172
+ const hasFocus = shallowRef(false);
1173
+ const isPaused = shallowRef(false);
1174
+ const activate = (opts) => trap && trap.activate(opts);
1175
+ const deactivate = (opts) => trap && trap.deactivate(opts);
1176
+ const pause = () => {
1177
+ if (trap) {
1178
+ trap.pause();
1179
+ isPaused.value = true;
1180
+ }
1181
+ };
1182
+ const unpause = () => {
1183
+ if (trap) {
1184
+ trap.unpause();
1185
+ isPaused.value = false;
1186
+ }
1187
+ };
1188
+ watch(computed(() => {
1189
+ return toArray(toValue(target)).map((el) => {
1190
+ const _el = toValue(el);
1191
+ return typeof _el === "string" ? _el : unrefElement(_el);
1192
+ }).filter(notNullish);
1193
+ }), (els) => {
1194
+ if (!els.length) return;
1195
+ if (!trap) {
1196
+ trap = createFocusTrap(els, {
1197
+ ...focusTrapOptions,
1198
+ onActivate(params) {
1199
+ hasFocus.value = true;
1200
+ if (options.onActivate) options.onActivate(params);
1201
+ },
1202
+ onDeactivate(params) {
1203
+ hasFocus.value = false;
1204
+ if (options.onDeactivate) options.onDeactivate(params);
1205
+ }
1206
+ });
1207
+ if (immediate) activate();
1208
+ } else {
1209
+ const isActive = trap === null || trap === void 0 ? void 0 : trap.active;
1210
+ trap === null || trap === void 0 || trap.updateContainerElements(els);
1211
+ if (!isActive && immediate) activate();
1212
+ }
1213
+ }, { flush: "post" });
1214
+ tryOnScopeDispose(() => deactivate());
1215
+ return {
1216
+ hasFocus,
1217
+ isPaused,
1218
+ activate,
1219
+ deactivate,
1220
+ pause,
1221
+ unpause
1222
+ };
1223
+ }
1224
+ //#endregion
1225
+ export { useFocusTrap };