@kakadu/components 2.2.1 → 2.3.1

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 (39) hide show
  1. package/build/components/button-tooltip.d.ts +2 -1
  2. package/build/components/button-tooltip.js +1 -1
  3. package/build/components/button-tooltip.mjs +7 -6
  4. package/build/components/button.js +1 -1
  5. package/build/components/button.mjs +44 -44
  6. package/build/components/collapsible.js +1 -1
  7. package/build/components/collapsible.mjs +12 -12
  8. package/build/components/icon-button.js +1 -1
  9. package/build/components/icon-button.mjs +29 -29
  10. package/build/components/modal.d.ts +3 -2
  11. package/build/components/modal.js +1 -9
  12. package/build/components/modal.mjs +105 -1226
  13. package/build/components/moving-gradients.js +1 -1
  14. package/build/components/moving-gradients.mjs +2 -2
  15. package/build/components/moving-stars.js +1 -1
  16. package/build/components/moving-stars.mjs +17 -17
  17. package/build/components/notification.js +1 -1
  18. package/build/components/notification.mjs +12 -12
  19. package/build/components/popover-menu.d.ts +19 -0
  20. package/build/components/popover-menu.js +1 -0
  21. package/build/components/popover-menu.mjs +68 -0
  22. package/build/components/popover.d.ts +26 -0
  23. package/build/components/popover.js +1 -0
  24. package/build/components/popover.mjs +95 -0
  25. package/build/components/skeleton.js +1 -1
  26. package/build/components/skeleton.mjs +23 -23
  27. package/build/components/spinner.js +1 -1
  28. package/build/components/spinner.mjs +1 -1
  29. package/build/components/text-button.js +1 -1
  30. package/build/components/text-button.mjs +14 -14
  31. package/build/components.css +1 -1
  32. package/build/focus-trap-react-CcpTuiJi.js +9 -0
  33. package/build/focus-trap-react-DYXrtbDH.mjs +1130 -0
  34. package/build/icons/icon.js +1 -1
  35. package/build/icons/icon.mjs +11 -11
  36. package/build/index.d.ts +4 -0
  37. package/build/index.js +1 -1
  38. package/build/index.mjs +161 -154
  39. package/package.json +1 -1
@@ -0,0 +1,1130 @@
1
+ import Ee from "react";
2
+ function pe(r) {
3
+ if (Object.prototype.hasOwnProperty.call(r, "__esModule")) return r;
4
+ var e = r.default;
5
+ if (typeof e == "function") {
6
+ var t = function n() {
7
+ return this instanceof n ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
8
+ };
9
+ t.prototype = e.prototype;
10
+ } else t = {};
11
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(r).forEach(function(n) {
12
+ var u = Object.getOwnPropertyDescriptor(r, n);
13
+ Object.defineProperty(t, n, u.get ? u : {
14
+ enumerable: !0,
15
+ get: function() {
16
+ return r[n];
17
+ }
18
+ });
19
+ }), t;
20
+ }
21
+ var H = { exports: {} };
22
+ /*!
23
+ * tabbable 6.4.0
24
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
25
+ */
26
+ var be = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], J = /* @__PURE__ */ be.join(","), he = typeof Element > "u", M = he ? function() {
27
+ } : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, Q = !he && Element.prototype.getRootNode ? function(r) {
28
+ var e;
29
+ return r == null || (e = r.getRootNode) === null || e === void 0 ? void 0 : e.call(r);
30
+ } : function(r) {
31
+ return r == null ? void 0 : r.ownerDocument;
32
+ }, ee = function(e, t) {
33
+ var n;
34
+ t === void 0 && (t = !0);
35
+ var u = e == null || (n = e.getAttribute) === null || n === void 0 ? void 0 : n.call(e, "inert"), l = u === "" || u === "true", i = l || t && e && // closest does not exist on shadow roots, so we fall back to a manual
36
+ // lookup upward, in case it is not defined.
37
+ (typeof e.closest == "function" ? e.closest("[inert]") : ee(e.parentNode));
38
+ return i;
39
+ }, Fe = function(e) {
40
+ var t, n = e == null || (t = e.getAttribute) === null || t === void 0 ? void 0 : t.call(e, "contenteditable");
41
+ return n === "" || n === "true";
42
+ }, ye = function(e, t, n) {
43
+ if (ee(e))
44
+ return [];
45
+ var u = Array.prototype.slice.apply(e.querySelectorAll(J));
46
+ return t && M.call(e, J) && u.unshift(e), u = u.filter(n), u;
47
+ }, te = function(e, t, n) {
48
+ for (var u = [], l = Array.from(e); l.length; ) {
49
+ var i = l.shift();
50
+ if (!ee(i, !1))
51
+ if (i.tagName === "SLOT") {
52
+ var y = i.assignedElements(), w = y.length ? y : i.children, E = te(w, !0, n);
53
+ n.flatten ? u.push.apply(u, E) : u.push({
54
+ scopeParent: i,
55
+ candidates: E
56
+ });
57
+ } else {
58
+ var k = M.call(i, J);
59
+ k && n.filter(i) && (t || !e.includes(i)) && u.push(i);
60
+ var D = i.shadowRoot || // check for an undisclosed shadow
61
+ typeof n.getShadowRoot == "function" && n.getShadowRoot(i), R = !ee(D, !1) && (!n.shadowRootFilter || n.shadowRootFilter(i));
62
+ if (D && R) {
63
+ var j = te(D === !0 ? i.children : D.children, !0, n);
64
+ n.flatten ? u.push.apply(u, j) : u.push({
65
+ scopeParent: i,
66
+ candidates: j
67
+ });
68
+ } else
69
+ l.unshift.apply(l, i.children);
70
+ }
71
+ }
72
+ return u;
73
+ }, me = function(e) {
74
+ return !isNaN(parseInt(e.getAttribute("tabindex"), 10));
75
+ }, L = function(e) {
76
+ if (!e)
77
+ throw new Error("No node provided");
78
+ return e.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName) || Fe(e)) && !me(e) ? 0 : e.tabIndex;
79
+ }, ke = function(e, t) {
80
+ var n = L(e);
81
+ return n < 0 && t && !me(e) ? 0 : n;
82
+ }, De = function(e, t) {
83
+ return e.tabIndex === t.tabIndex ? e.documentOrder - t.documentOrder : e.tabIndex - t.tabIndex;
84
+ }, ge = function(e) {
85
+ return e.tagName === "INPUT";
86
+ }, Ne = function(e) {
87
+ return ge(e) && e.type === "hidden";
88
+ }, Re = function(e) {
89
+ var t = e.tagName === "DETAILS" && Array.prototype.slice.apply(e.children).some(function(n) {
90
+ return n.tagName === "SUMMARY";
91
+ });
92
+ return t;
93
+ }, Pe = function(e, t) {
94
+ for (var n = 0; n < e.length; n++)
95
+ if (e[n].checked && e[n].form === t)
96
+ return e[n];
97
+ }, Ce = function(e) {
98
+ if (!e.name)
99
+ return !0;
100
+ var t = e.form || Q(e), n = function(y) {
101
+ return t.querySelectorAll('input[type="radio"][name="' + y + '"]');
102
+ }, u;
103
+ if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
104
+ u = n(window.CSS.escape(e.name));
105
+ else
106
+ try {
107
+ u = n(e.name);
108
+ } catch (i) {
109
+ return 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", i.message), !1;
110
+ }
111
+ var l = Pe(u, e.form);
112
+ return !l || l === e;
113
+ }, Ae = function(e) {
114
+ return ge(e) && e.type === "radio";
115
+ }, Ie = function(e) {
116
+ return Ae(e) && !Ce(e);
117
+ }, je = function(e) {
118
+ var t, n = e && Q(e), u = (t = n) === null || t === void 0 ? void 0 : t.host, l = !1;
119
+ if (n && n !== e) {
120
+ var i, y, w;
121
+ for (l = !!((i = u) !== null && i !== void 0 && (y = i.ownerDocument) !== null && y !== void 0 && y.contains(u) || e != null && (w = e.ownerDocument) !== null && w !== void 0 && w.contains(e)); !l && u; ) {
122
+ var E, k, D;
123
+ n = Q(u), u = (E = n) === null || E === void 0 ? void 0 : E.host, l = !!((k = u) !== null && k !== void 0 && (D = k.ownerDocument) !== null && D !== void 0 && D.contains(u));
124
+ }
125
+ }
126
+ return l;
127
+ }, se = function(e) {
128
+ var t = e.getBoundingClientRect(), n = t.width, u = t.height;
129
+ return n === 0 && u === 0;
130
+ }, _e = function(e, t) {
131
+ var n = t.displayCheck, u = t.getShadowRoot;
132
+ if (n === "full-native" && "checkVisibility" in e) {
133
+ var l = e.checkVisibility({
134
+ // Checking opacity might be desirable for some use cases, but natively,
135
+ // opacity zero elements _are_ focusable and tabbable.
136
+ checkOpacity: !1,
137
+ opacityProperty: !1,
138
+ contentVisibilityAuto: !0,
139
+ visibilityProperty: !0,
140
+ // This is an alias for `visibilityProperty`. Contemporary browsers
141
+ // support both. However, this alias has wider browser support (Chrome
142
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
143
+ // we include it anyway.
144
+ checkVisibilityCSS: !0
145
+ });
146
+ return !l;
147
+ }
148
+ if (getComputedStyle(e).visibility === "hidden")
149
+ return !0;
150
+ var i = M.call(e, "details>summary:first-of-type"), y = i ? e.parentElement : e;
151
+ if (M.call(y, "details:not([open]) *"))
152
+ return !0;
153
+ if (!n || n === "full" || // full-native can run this branch when it falls through in case
154
+ // Element#checkVisibility is unsupported
155
+ n === "full-native" || n === "legacy-full") {
156
+ if (typeof u == "function") {
157
+ for (var w = e; e; ) {
158
+ var E = e.parentElement, k = Q(e);
159
+ if (E && !E.shadowRoot && u(E) === !0)
160
+ return se(e);
161
+ e.assignedSlot ? e = e.assignedSlot : !E && k !== e.ownerDocument ? e = k.host : e = E;
162
+ }
163
+ e = w;
164
+ }
165
+ if (je(e))
166
+ return !e.getClientRects().length;
167
+ if (n !== "legacy-full")
168
+ return !0;
169
+ } else if (n === "non-zero-area")
170
+ return se(e);
171
+ return !1;
172
+ }, xe = function(e) {
173
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))
174
+ for (var t = e.parentElement; t; ) {
175
+ if (t.tagName === "FIELDSET" && t.disabled) {
176
+ for (var n = 0; n < t.children.length; n++) {
177
+ var u = t.children.item(n);
178
+ if (u.tagName === "LEGEND")
179
+ return M.call(t, "fieldset[disabled] *") ? !0 : !u.contains(e);
180
+ }
181
+ return !0;
182
+ }
183
+ t = t.parentElement;
184
+ }
185
+ return !1;
186
+ }, re = function(e, t) {
187
+ return !(t.disabled || Ne(t) || _e(t, e) || // For a details element with a summary, the summary element gets the focus
188
+ Re(t) || xe(t));
189
+ }, oe = function(e, t) {
190
+ return !(Ie(t) || L(t) < 0 || !re(e, t));
191
+ }, Le = function(e) {
192
+ var t = parseInt(e.getAttribute("tabindex"), 10);
193
+ return !!(isNaN(t) || t >= 0);
194
+ }, Te = function(e) {
195
+ var t = [], n = [];
196
+ return e.forEach(function(u, l) {
197
+ var i = !!u.scopeParent, y = i ? u.scopeParent : u, w = ke(y, i), E = i ? Te(u.candidates) : y;
198
+ w === 0 ? i ? t.push.apply(t, E) : t.push(y) : n.push({
199
+ documentOrder: l,
200
+ tabIndex: w,
201
+ item: u,
202
+ isScope: i,
203
+ content: E
204
+ });
205
+ }), n.sort(De).reduce(function(u, l) {
206
+ return l.isScope ? u.push.apply(u, l.content) : u.push(l.content), u;
207
+ }, []).concat(t);
208
+ }, we = function(e, t) {
209
+ t = t || {};
210
+ var n;
211
+ return t.getShadowRoot ? n = te([e], t.includeContainer, {
212
+ filter: oe.bind(null, t),
213
+ flatten: !1,
214
+ getShadowRoot: t.getShadowRoot,
215
+ shadowRootFilter: Le
216
+ }) : n = ye(e, t.includeContainer, oe.bind(null, t)), Te(n);
217
+ }, Oe = function(e, t) {
218
+ t = t || {};
219
+ var n;
220
+ return t.getShadowRoot ? n = te([e], t.includeContainer, {
221
+ filter: re.bind(null, t),
222
+ flatten: !0,
223
+ getShadowRoot: t.getShadowRoot
224
+ }) : n = ye(e, t.includeContainer, re.bind(null, t)), n;
225
+ }, K = function(e, t) {
226
+ if (t = t || {}, !e)
227
+ throw new Error("No node provided");
228
+ return M.call(e, J) === !1 ? !1 : oe(t, e);
229
+ }, Be = /* @__PURE__ */ be.concat("iframe:not([inert]):not([inert] *)").join(","), X = function(e, t) {
230
+ if (t = t || {}, !e)
231
+ throw new Error("No node provided");
232
+ return M.call(e, Be) === !1 ? !1 : re(t, e);
233
+ };
234
+ const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
235
+ __proto__: null,
236
+ focusable: Oe,
237
+ getTabIndex: L,
238
+ isFocusable: X,
239
+ isTabbable: K,
240
+ tabbable: we
241
+ }, Symbol.toStringTag, { value: "Module" }));
242
+ /*!
243
+ * focus-trap 7.8.0
244
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
245
+ */
246
+ function ue(r, e) {
247
+ (e == null || e > r.length) && (e = r.length);
248
+ for (var t = 0, n = Array(e); t < e; t++) n[t] = r[t];
249
+ return n;
250
+ }
251
+ function Me(r) {
252
+ if (Array.isArray(r)) return ue(r);
253
+ }
254
+ function ce(r, e) {
255
+ var t = typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"];
256
+ if (!t) {
257
+ if (Array.isArray(r) || (t = Se(r)) || e) {
258
+ t && (r = t);
259
+ var n = 0, u = function() {
260
+ };
261
+ return {
262
+ s: u,
263
+ n: function() {
264
+ return n >= r.length ? {
265
+ done: !0
266
+ } : {
267
+ done: !1,
268
+ value: r[n++]
269
+ };
270
+ },
271
+ e: function(w) {
272
+ throw w;
273
+ },
274
+ f: u
275
+ };
276
+ }
277
+ throw new TypeError(`Invalid attempt to iterate non-iterable instance.
278
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
279
+ }
280
+ var l, i = !0, y = !1;
281
+ return {
282
+ s: function() {
283
+ t = t.call(r);
284
+ },
285
+ n: function() {
286
+ var w = t.next();
287
+ return i = w.done, w;
288
+ },
289
+ e: function(w) {
290
+ y = !0, l = w;
291
+ },
292
+ f: function() {
293
+ try {
294
+ i || t.return == null || t.return();
295
+ } finally {
296
+ if (y) throw l;
297
+ }
298
+ }
299
+ };
300
+ }
301
+ function qe(r, e, t) {
302
+ return (e = We(e)) in r ? Object.defineProperty(r, e, {
303
+ value: t,
304
+ enumerable: !0,
305
+ configurable: !0,
306
+ writable: !0
307
+ }) : r[e] = t, r;
308
+ }
309
+ function Ve(r) {
310
+ if (typeof Symbol < "u" && r[Symbol.iterator] != null || r["@@iterator"] != null) return Array.from(r);
311
+ }
312
+ function Ge() {
313
+ throw new TypeError(`Invalid attempt to spread non-iterable instance.
314
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
315
+ }
316
+ function le(r, e) {
317
+ var t = Object.keys(r);
318
+ if (Object.getOwnPropertySymbols) {
319
+ var n = Object.getOwnPropertySymbols(r);
320
+ e && (n = n.filter(function(u) {
321
+ return Object.getOwnPropertyDescriptor(r, u).enumerable;
322
+ })), t.push.apply(t, n);
323
+ }
324
+ return t;
325
+ }
326
+ function fe(r) {
327
+ for (var e = 1; e < arguments.length; e++) {
328
+ var t = arguments[e] != null ? arguments[e] : {};
329
+ e % 2 ? le(Object(t), !0).forEach(function(n) {
330
+ qe(r, n, t[n]);
331
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) : le(Object(t)).forEach(function(n) {
332
+ Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(t, n));
333
+ });
334
+ }
335
+ return r;
336
+ }
337
+ function $e(r) {
338
+ return Me(r) || Ve(r) || Se(r) || Ge();
339
+ }
340
+ function Ue(r, e) {
341
+ if (typeof r != "object" || !r) return r;
342
+ var t = r[Symbol.toPrimitive];
343
+ if (t !== void 0) {
344
+ var n = t.call(r, e);
345
+ if (typeof n != "object") return n;
346
+ throw new TypeError("@@toPrimitive must return a primitive value.");
347
+ }
348
+ return (e === "string" ? String : Number)(r);
349
+ }
350
+ function We(r) {
351
+ var e = Ue(r, "string");
352
+ return typeof e == "symbol" ? e : e + "";
353
+ }
354
+ function Se(r, e) {
355
+ if (r) {
356
+ if (typeof r == "string") return ue(r, e);
357
+ var t = {}.toString.call(r).slice(8, -1);
358
+ return t === "Object" && r.constructor && (t = r.constructor.name), t === "Map" || t === "Set" ? Array.from(r) : t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? ue(r, e) : void 0;
359
+ }
360
+ }
361
+ var I = {
362
+ // Returns the trap from the top of the stack.
363
+ getActiveTrap: function(e) {
364
+ return (e == null ? void 0 : e.length) > 0 ? e[e.length - 1] : null;
365
+ },
366
+ // Pauses the currently active trap, then adds a new trap to the stack.
367
+ activateTrap: function(e, t) {
368
+ var n = I.getActiveTrap(e);
369
+ t !== n && I.pauseTrap(e);
370
+ var u = e.indexOf(t);
371
+ u === -1 || e.splice(u, 1), e.push(t);
372
+ },
373
+ // Removes the trap from the top of the stack, then unpauses the next trap down.
374
+ deactivateTrap: function(e, t) {
375
+ var n = e.indexOf(t);
376
+ n !== -1 && e.splice(n, 1), I.unpauseTrap(e);
377
+ },
378
+ // Pauses the trap at the top of the stack.
379
+ pauseTrap: function(e) {
380
+ var t = I.getActiveTrap(e);
381
+ t == null || t._setPausedState(!0);
382
+ },
383
+ // Unpauses the trap at the top of the stack.
384
+ unpauseTrap: function(e) {
385
+ var t = I.getActiveTrap(e);
386
+ t && !t._isManuallyPaused() && t._setPausedState(!1);
387
+ }
388
+ }, ze = function(e) {
389
+ return e.tagName && e.tagName.toLowerCase() === "input" && typeof e.select == "function";
390
+ }, Ye = function(e) {
391
+ return (e == null ? void 0 : e.key) === "Escape" || (e == null ? void 0 : e.key) === "Esc" || (e == null ? void 0 : e.keyCode) === 27;
392
+ }, $ = function(e) {
393
+ return (e == null ? void 0 : e.key) === "Tab" || (e == null ? void 0 : e.keyCode) === 9;
394
+ }, He = function(e) {
395
+ return $(e) && !e.shiftKey;
396
+ }, Ze = function(e) {
397
+ return $(e) && e.shiftKey;
398
+ }, de = function(e) {
399
+ return setTimeout(e, 0);
400
+ }, G = function(e) {
401
+ for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), u = 1; u < t; u++)
402
+ n[u - 1] = arguments[u];
403
+ return typeof e == "function" ? e.apply(void 0, n) : e;
404
+ }, Z = function(e) {
405
+ return e.target.shadowRoot && typeof e.composedPath == "function" ? e.composedPath()[0] : e.target;
406
+ }, Xe = [], Je = function(e, t) {
407
+ var n = (t == null ? void 0 : t.document) || document, u = (t == null ? void 0 : t.trapStack) || Xe, l = fe({
408
+ returnFocusOnDeactivate: !0,
409
+ escapeDeactivates: !0,
410
+ delayInitialFocus: !0,
411
+ isolateSubtrees: !1,
412
+ isKeyForward: He,
413
+ isKeyBackward: Ze
414
+ }, t), i = {
415
+ // containers given to createFocusTrap()
416
+ /** @type {Array<HTMLElement>} */
417
+ containers: [],
418
+ // list of objects identifying tabbable nodes in `containers` in the trap
419
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
420
+ // is active, but the trap should never get to a state where there isn't at least one group
421
+ // with at least one tabbable node in it (that would lead to an error condition that would
422
+ // result in an error being thrown)
423
+ /** @type {Array<{
424
+ * container: HTMLElement,
425
+ * tabbableNodes: Array<HTMLElement>, // empty if none
426
+ * focusableNodes: Array<HTMLElement>, // empty if none
427
+ * posTabIndexesFound: boolean,
428
+ * firstTabbableNode: HTMLElement|undefined,
429
+ * lastTabbableNode: HTMLElement|undefined,
430
+ * firstDomTabbableNode: HTMLElement|undefined,
431
+ * lastDomTabbableNode: HTMLElement|undefined,
432
+ * nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
433
+ * }>}
434
+ */
435
+ containerGroups: [],
436
+ // same order/length as `containers` list
437
+ // references to objects in `containerGroups`, but only those that actually have
438
+ // tabbable nodes in them
439
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
440
+ // the same length
441
+ tabbableGroups: [],
442
+ // references to nodes that are siblings to the ancestors of this trap's containers.
443
+ /** @type {Set<HTMLElement>} */
444
+ adjacentElements: /* @__PURE__ */ new Set(),
445
+ // references to nodes that were inert or aria-hidden before the trap was activated.
446
+ /** @type {Set<HTMLElement>} */
447
+ alreadySilent: /* @__PURE__ */ new Set(),
448
+ nodeFocusedBeforeActivation: null,
449
+ mostRecentlyFocusedNode: null,
450
+ active: !1,
451
+ paused: !1,
452
+ manuallyPaused: !1,
453
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
454
+ // has been delayed during activation
455
+ delayInitialFocusTimer: void 0,
456
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
457
+ recentNavEvent: void 0
458
+ }, y, w = function(o, a, c) {
459
+ return o && o[a] !== void 0 ? o[a] : l[c || a];
460
+ }, E = function(o, a) {
461
+ var c = typeof (a == null ? void 0 : a.composedPath) == "function" ? a.composedPath() : void 0;
462
+ return i.containerGroups.findIndex(function(h) {
463
+ var b = h.container, g = h.tabbableNodes;
464
+ return b.contains(o) || // fall back to explicit tabbable search which will take into consideration any
465
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
466
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
467
+ // look inside web components even if open)
468
+ (c == null ? void 0 : c.includes(b)) || g.find(function(v) {
469
+ return v === o;
470
+ });
471
+ });
472
+ }, k = function(o) {
473
+ var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, c = a.hasFallback, h = c === void 0 ? !1 : c, b = a.params, g = b === void 0 ? [] : b, v = l[o];
474
+ if (typeof v == "function" && (v = v.apply(void 0, $e(g))), v === !0 && (v = void 0), !v) {
475
+ if (v === void 0 || v === !1)
476
+ return v;
477
+ throw new Error("`".concat(o, "` was specified but was not a node, or did not return a node"));
478
+ }
479
+ var O = v;
480
+ if (typeof v == "string") {
481
+ try {
482
+ O = n.querySelector(v);
483
+ } catch (S) {
484
+ throw new Error("`".concat(o, '` appears to be an invalid selector; error="').concat(S.message, '"'));
485
+ }
486
+ if (!O && !h)
487
+ throw new Error("`".concat(o, "` as selector refers to no known node"));
488
+ }
489
+ return O;
490
+ }, D = function() {
491
+ var o = k("initialFocus", {
492
+ hasFallback: !0
493
+ });
494
+ if (o === !1)
495
+ return !1;
496
+ if (o === void 0 || o && !X(o, l.tabbableOptions))
497
+ if (E(n.activeElement) >= 0)
498
+ o = n.activeElement;
499
+ else {
500
+ var a = i.tabbableGroups[0], c = a && a.firstTabbableNode;
501
+ o = c || k("fallbackFocus");
502
+ }
503
+ else o === null && (o = k("fallbackFocus"));
504
+ if (!o)
505
+ throw new Error("Your focus-trap needs to have at least one focusable element");
506
+ return o;
507
+ }, R = function() {
508
+ if (i.containerGroups = i.containers.map(function(o) {
509
+ var a = we(o, l.tabbableOptions), c = Oe(o, l.tabbableOptions), h = a.length > 0 ? a[0] : void 0, b = a.length > 0 ? a[a.length - 1] : void 0, g = c.find(function(S) {
510
+ return K(S);
511
+ }), v = c.slice().reverse().find(function(S) {
512
+ return K(S);
513
+ }), O = !!a.find(function(S) {
514
+ return L(S) > 0;
515
+ });
516
+ return {
517
+ container: o,
518
+ tabbableNodes: a,
519
+ focusableNodes: c,
520
+ /** True if at least one node with positive `tabindex` was found in this container. */
521
+ posTabIndexesFound: O,
522
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
523
+ firstTabbableNode: h,
524
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
525
+ lastTabbableNode: b,
526
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
527
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
528
+ // because that API doesn't work with Shadow DOM as well as it should (@see
529
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
530
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
531
+ // "close enough most of the time" alternative for positive tabindexes which should generally
532
+ // be avoided anyway...
533
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
534
+ firstDomTabbableNode: g,
535
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
536
+ lastDomTabbableNode: v,
537
+ /**
538
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
539
+ * in this container, if any.
540
+ * @param {HTMLElement} node
541
+ * @param {boolean} [forward] True if going in forward tab order; false if going
542
+ * in reverse.
543
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
544
+ */
545
+ nextTabbableNode: function(N) {
546
+ var A = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, C = a.indexOf(N);
547
+ return C < 0 ? A ? c.slice(c.indexOf(N) + 1).find(function(B) {
548
+ return K(B);
549
+ }) : c.slice(0, c.indexOf(N)).reverse().find(function(B) {
550
+ return K(B);
551
+ }) : a[C + (A ? 1 : -1)];
552
+ }
553
+ };
554
+ }), i.tabbableGroups = i.containerGroups.filter(function(o) {
555
+ return o.tabbableNodes.length > 0;
556
+ }), i.tabbableGroups.length <= 0 && !k("fallbackFocus"))
557
+ throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
558
+ if (i.containerGroups.find(function(o) {
559
+ return o.posTabIndexesFound;
560
+ }) && i.containerGroups.length > 1)
561
+ 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.");
562
+ }, j = function(o) {
563
+ var a = o.activeElement;
564
+ if (a)
565
+ return a.shadowRoot && a.shadowRoot.activeElement !== null ? j(a.shadowRoot) : a;
566
+ }, P = function(o) {
567
+ if (o !== !1 && o !== j(document)) {
568
+ if (!o || !o.focus) {
569
+ P(D());
570
+ return;
571
+ }
572
+ o.focus({
573
+ preventScroll: !!l.preventScroll
574
+ }), i.mostRecentlyFocusedNode = o, ze(o) && o.select();
575
+ }
576
+ }, U = function(o) {
577
+ var a = k("setReturnFocus", {
578
+ params: [o]
579
+ });
580
+ return a || (a === !1 ? !1 : o);
581
+ }, _ = function(o) {
582
+ var a = o.target, c = o.event, h = o.isBackward, b = h === void 0 ? !1 : h;
583
+ a = a || Z(c), R();
584
+ var g = null;
585
+ if (i.tabbableGroups.length > 0) {
586
+ var v = E(a, c), O = v >= 0 ? i.containerGroups[v] : void 0;
587
+ if (v < 0)
588
+ b ? g = i.tabbableGroups[i.tabbableGroups.length - 1].lastTabbableNode : g = i.tabbableGroups[0].firstTabbableNode;
589
+ else if (b) {
590
+ var S = i.tabbableGroups.findIndex(function(ne) {
591
+ var ie = ne.firstTabbableNode;
592
+ return a === ie;
593
+ });
594
+ if (S < 0 && (O.container === a || X(a, l.tabbableOptions) && !K(a, l.tabbableOptions) && !O.nextTabbableNode(a, !1)) && (S = v), S >= 0) {
595
+ var N = S === 0 ? i.tabbableGroups.length - 1 : S - 1, A = i.tabbableGroups[N];
596
+ g = L(a) >= 0 ? A.lastTabbableNode : A.lastDomTabbableNode;
597
+ } else $(c) || (g = O.nextTabbableNode(a, !1));
598
+ } else {
599
+ var C = i.tabbableGroups.findIndex(function(ne) {
600
+ var ie = ne.lastTabbableNode;
601
+ return a === ie;
602
+ });
603
+ if (C < 0 && (O.container === a || X(a, l.tabbableOptions) && !K(a, l.tabbableOptions) && !O.nextTabbableNode(a)) && (C = v), C >= 0) {
604
+ var B = C === i.tabbableGroups.length - 1 ? 0 : C + 1, x = i.tabbableGroups[B];
605
+ g = L(a) >= 0 ? x.firstTabbableNode : x.firstDomTabbableNode;
606
+ } else $(c) || (g = O.nextTabbableNode(a));
607
+ }
608
+ } else
609
+ g = k("fallbackFocus");
610
+ return g;
611
+ }, q = function(o) {
612
+ var a = Z(o);
613
+ if (!(E(a, o) >= 0)) {
614
+ if (G(l.clickOutsideDeactivates, o)) {
615
+ y.deactivate({
616
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
617
+ // which will result in the outside click setting focus to the node
618
+ // that was clicked (and if not focusable, to "nothing"); by setting
619
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
620
+ // on activation (or the configured `setReturnFocus` node), whether the
621
+ // outside click was on a focusable node or not
622
+ returnFocus: l.returnFocusOnDeactivate
623
+ });
624
+ return;
625
+ }
626
+ G(l.allowOutsideClick, o) || o.preventDefault();
627
+ }
628
+ }, W = function(o) {
629
+ var a = Z(o), c = E(a, o) >= 0;
630
+ if (c || a instanceof Document)
631
+ c && (i.mostRecentlyFocusedNode = a);
632
+ else {
633
+ o.stopImmediatePropagation();
634
+ var h, b = !0;
635
+ if (i.mostRecentlyFocusedNode)
636
+ if (L(i.mostRecentlyFocusedNode) > 0) {
637
+ var g = E(i.mostRecentlyFocusedNode), v = i.containerGroups[g].tabbableNodes;
638
+ if (v.length > 0) {
639
+ var O = v.findIndex(function(S) {
640
+ return S === i.mostRecentlyFocusedNode;
641
+ });
642
+ O >= 0 && (l.isKeyForward(i.recentNavEvent) ? O + 1 < v.length && (h = v[O + 1], b = !1) : O - 1 >= 0 && (h = v[O - 1], b = !1));
643
+ }
644
+ } else
645
+ i.containerGroups.some(function(S) {
646
+ return S.tabbableNodes.some(function(N) {
647
+ return L(N) > 0;
648
+ });
649
+ }) || (b = !1);
650
+ else
651
+ b = !1;
652
+ b && (h = _({
653
+ // move FROM the MRU node, not event-related node (which will be the node that is
654
+ // outside the trap causing the focus escape we're trying to fix)
655
+ target: i.mostRecentlyFocusedNode,
656
+ isBackward: l.isKeyBackward(i.recentNavEvent)
657
+ })), P(h || i.mostRecentlyFocusedNode || D());
658
+ }
659
+ i.recentNavEvent = void 0;
660
+ }, ae = function(o) {
661
+ var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
662
+ i.recentNavEvent = o;
663
+ var c = _({
664
+ event: o,
665
+ isBackward: a
666
+ });
667
+ c && ($(o) && o.preventDefault(), P(c));
668
+ }, z = function(o) {
669
+ (l.isKeyForward(o) || l.isKeyBackward(o)) && ae(o, l.isKeyBackward(o));
670
+ }, Y = function(o) {
671
+ Ye(o) && G(l.escapeDeactivates, o) !== !1 && (o.preventDefault(), y.deactivate());
672
+ }, V = function(o) {
673
+ var a = Z(o);
674
+ E(a, o) >= 0 || G(l.clickOutsideDeactivates, o) || G(l.allowOutsideClick, o) || (o.preventDefault(), o.stopImmediatePropagation());
675
+ }, d = function() {
676
+ if (i.active)
677
+ return I.activateTrap(u, y), i.delayInitialFocusTimer = l.delayInitialFocus ? de(function() {
678
+ P(D());
679
+ }) : P(D()), n.addEventListener("focusin", W, !0), n.addEventListener("mousedown", q, {
680
+ capture: !0,
681
+ passive: !1
682
+ }), n.addEventListener("touchstart", q, {
683
+ capture: !0,
684
+ passive: !1
685
+ }), n.addEventListener("click", V, {
686
+ capture: !0,
687
+ passive: !1
688
+ }), n.addEventListener("keydown", z, {
689
+ capture: !0,
690
+ passive: !1
691
+ }), n.addEventListener("keydown", Y), y;
692
+ }, f = function(o) {
693
+ i.active && !i.paused && y._setSubtreeIsolation(!1), i.adjacentElements.clear(), i.alreadySilent.clear();
694
+ var a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), h = ce(o), b;
695
+ try {
696
+ for (h.s(); !(b = h.n()).done; ) {
697
+ var g = b.value;
698
+ a.add(g);
699
+ for (var v = typeof ShadowRoot < "u" && g.getRootNode() instanceof ShadowRoot, O = g; O; ) {
700
+ a.add(O);
701
+ var S = O.parentElement, N = [];
702
+ S ? N = S.children : !S && v && (N = O.getRootNode().children, S = O.getRootNode().host, v = typeof ShadowRoot < "u" && S.getRootNode() instanceof ShadowRoot);
703
+ var A = ce(N), C;
704
+ try {
705
+ for (A.s(); !(C = A.n()).done; ) {
706
+ var B = C.value;
707
+ c.add(B);
708
+ }
709
+ } catch (x) {
710
+ A.e(x);
711
+ } finally {
712
+ A.f();
713
+ }
714
+ O = S;
715
+ }
716
+ }
717
+ } catch (x) {
718
+ h.e(x);
719
+ } finally {
720
+ h.f();
721
+ }
722
+ a.forEach(function(x) {
723
+ c.delete(x);
724
+ }), i.adjacentElements = c;
725
+ }, m = function() {
726
+ if (i.active)
727
+ return n.removeEventListener("focusin", W, !0), n.removeEventListener("mousedown", q, !0), n.removeEventListener("touchstart", q, !0), n.removeEventListener("click", V, !0), n.removeEventListener("keydown", z, !0), n.removeEventListener("keydown", Y), y;
728
+ }, s = function(o) {
729
+ var a = o.some(function(c) {
730
+ var h = Array.from(c.removedNodes);
731
+ return h.some(function(b) {
732
+ return b === i.mostRecentlyFocusedNode;
733
+ });
734
+ });
735
+ a && P(D());
736
+ }, T = typeof window < "u" && "MutationObserver" in window ? new MutationObserver(s) : void 0, F = function() {
737
+ T && (T.disconnect(), i.active && !i.paused && i.containers.map(function(o) {
738
+ T.observe(o, {
739
+ subtree: !0,
740
+ childList: !0
741
+ });
742
+ }));
743
+ };
744
+ return y = {
745
+ get active() {
746
+ return i.active;
747
+ },
748
+ get paused() {
749
+ return i.paused;
750
+ },
751
+ activate: function(o) {
752
+ if (i.active)
753
+ return this;
754
+ var a = w(o, "onActivate"), c = w(o, "onPostActivate"), h = w(o, "checkCanFocusTrap"), b = I.getActiveTrap(u), g = !1;
755
+ if (b && !b.paused) {
756
+ var v;
757
+ (v = b._setSubtreeIsolation) === null || v === void 0 || v.call(b, !1), g = !0;
758
+ }
759
+ try {
760
+ h || R(), i.active = !0, i.paused = !1, i.nodeFocusedBeforeActivation = j(n), a == null || a();
761
+ var O = function() {
762
+ h && R(), d(), F(), l.isolateSubtrees && y._setSubtreeIsolation(!0), c == null || c();
763
+ };
764
+ if (h)
765
+ return h(i.containers.concat()).then(O, O), this;
766
+ O();
767
+ } catch (N) {
768
+ if (b === I.getActiveTrap(u) && g) {
769
+ var S;
770
+ (S = b._setSubtreeIsolation) === null || S === void 0 || S.call(b, !0);
771
+ }
772
+ throw N;
773
+ }
774
+ return this;
775
+ },
776
+ deactivate: function(o) {
777
+ if (!i.active)
778
+ return this;
779
+ var a = fe({
780
+ onDeactivate: l.onDeactivate,
781
+ onPostDeactivate: l.onPostDeactivate,
782
+ checkCanReturnFocus: l.checkCanReturnFocus
783
+ }, o);
784
+ clearTimeout(i.delayInitialFocusTimer), i.delayInitialFocusTimer = void 0, i.paused || y._setSubtreeIsolation(!1), i.alreadySilent.clear(), m(), i.active = !1, i.paused = !1, F(), I.deactivateTrap(u, y);
785
+ var c = w(a, "onDeactivate"), h = w(a, "onPostDeactivate"), b = w(a, "checkCanReturnFocus"), g = w(a, "returnFocus", "returnFocusOnDeactivate");
786
+ c == null || c();
787
+ var v = function() {
788
+ de(function() {
789
+ g && P(U(i.nodeFocusedBeforeActivation)), h == null || h();
790
+ });
791
+ };
792
+ return g && b ? (b(U(i.nodeFocusedBeforeActivation)).then(v, v), this) : (v(), this);
793
+ },
794
+ pause: function(o) {
795
+ return i.active ? (i.manuallyPaused = !0, this._setPausedState(!0, o)) : this;
796
+ },
797
+ unpause: function(o) {
798
+ return i.active ? (i.manuallyPaused = !1, u[u.length - 1] !== this ? this : this._setPausedState(!1, o)) : this;
799
+ },
800
+ updateContainerElements: function(o) {
801
+ var a = [].concat(o).filter(Boolean);
802
+ return i.containers = a.map(function(c) {
803
+ return typeof c == "string" ? n.querySelector(c) : c;
804
+ }), l.isolateSubtrees && f(i.containers), i.active && (R(), l.isolateSubtrees && !i.paused && y._setSubtreeIsolation(!0)), F(), this;
805
+ }
806
+ }, Object.defineProperties(y, {
807
+ _isManuallyPaused: {
808
+ value: function() {
809
+ return i.manuallyPaused;
810
+ }
811
+ },
812
+ _setPausedState: {
813
+ value: function(o, a) {
814
+ if (i.paused === o)
815
+ return this;
816
+ if (i.paused = o, o) {
817
+ var c = w(a, "onPause"), h = w(a, "onPostPause");
818
+ c == null || c(), m(), F(), y._setSubtreeIsolation(!1), h == null || h();
819
+ } else {
820
+ var b = w(a, "onUnpause"), g = w(a, "onPostUnpause");
821
+ b == null || b(), y._setSubtreeIsolation(!0), R(), d(), F(), g == null || g();
822
+ }
823
+ return this;
824
+ }
825
+ },
826
+ _setSubtreeIsolation: {
827
+ value: function(o) {
828
+ l.isolateSubtrees && i.adjacentElements.forEach(function(a) {
829
+ var c;
830
+ if (o)
831
+ switch (l.isolateSubtrees) {
832
+ case "aria-hidden":
833
+ (a.ariaHidden === "true" || ((c = a.getAttribute("aria-hidden")) === null || c === void 0 ? void 0 : c.toLowerCase()) === "true") && i.alreadySilent.add(a), a.setAttribute("aria-hidden", "true");
834
+ break;
835
+ default:
836
+ (a.inert || a.hasAttribute("inert")) && i.alreadySilent.add(a), a.setAttribute("inert", !0);
837
+ break;
838
+ }
839
+ else if (!i.alreadySilent.has(a)) switch (l.isolateSubtrees) {
840
+ case "aria-hidden":
841
+ a.removeAttribute("aria-hidden");
842
+ break;
843
+ default:
844
+ a.removeAttribute("inert");
845
+ break;
846
+ }
847
+ });
848
+ }
849
+ }
850
+ }), y.updateContainerElements(e), y;
851
+ };
852
+ const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
853
+ __proto__: null,
854
+ createFocusTrap: Je
855
+ }, Symbol.toStringTag, { value: "Module" })), et = /* @__PURE__ */ pe(Qe), tt = /* @__PURE__ */ pe(Ke);
856
+ var ve;
857
+ function rt() {
858
+ if (ve) return H.exports;
859
+ ve = 1;
860
+ function r(d) {
861
+ "@babel/helpers - typeof";
862
+ return r = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(f) {
863
+ return typeof f;
864
+ } : function(f) {
865
+ return f && typeof Symbol == "function" && f.constructor === Symbol && f !== Symbol.prototype ? "symbol" : typeof f;
866
+ }, r(d);
867
+ }
868
+ var e, t;
869
+ function n(d, f) {
870
+ if (!(d instanceof f)) throw new TypeError("Cannot call a class as a function");
871
+ }
872
+ function u(d, f) {
873
+ for (var m = 0; m < f.length; m++) {
874
+ var s = f[m];
875
+ s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(d, P(s.key), s);
876
+ }
877
+ }
878
+ function l(d, f, m) {
879
+ return f && u(d.prototype, f), Object.defineProperty(d, "prototype", { writable: !1 }), d;
880
+ }
881
+ function i(d, f, m) {
882
+ return f = k(f), y(d, E() ? Reflect.construct(f, m || [], k(d).constructor) : f.apply(d, m));
883
+ }
884
+ function y(d, f) {
885
+ if (f && (r(f) == "object" || typeof f == "function")) return f;
886
+ if (f !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
887
+ return w(d);
888
+ }
889
+ function w(d) {
890
+ if (d === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
891
+ return d;
892
+ }
893
+ function E() {
894
+ try {
895
+ var d = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
896
+ }));
897
+ } catch {
898
+ }
899
+ return (E = function() {
900
+ return !!d;
901
+ })();
902
+ }
903
+ function k(d) {
904
+ return k = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(f) {
905
+ return f.__proto__ || Object.getPrototypeOf(f);
906
+ }, k(d);
907
+ }
908
+ function D(d, f) {
909
+ if (typeof f != "function" && f !== null) throw new TypeError("Super expression must either be null or a function");
910
+ d.prototype = Object.create(f && f.prototype, { constructor: { value: d, writable: !0, configurable: !0 } }), Object.defineProperty(d, "prototype", { writable: !1 }), f && R(d, f);
911
+ }
912
+ function R(d, f) {
913
+ return R = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(m, s) {
914
+ return m.__proto__ = s, m;
915
+ }, R(d, f);
916
+ }
917
+ function j(d, f, m) {
918
+ return (f = P(f)) in d ? Object.defineProperty(d, f, { value: m, enumerable: !0, configurable: !0, writable: !0 }) : d[f] = m, d;
919
+ }
920
+ function P(d) {
921
+ var f = U(d, "string");
922
+ return r(f) == "symbol" ? f : f + "";
923
+ }
924
+ function U(d, f) {
925
+ if (r(d) != "object" || !d) return d;
926
+ var m = d[Symbol.toPrimitive];
927
+ if (m !== void 0) {
928
+ var s = m.call(d, f);
929
+ if (r(s) != "object") return s;
930
+ throw new TypeError("@@toPrimitive must return a primitive value.");
931
+ }
932
+ return (f === "string" ? String : Number)(d);
933
+ }
934
+ var _ = Ee, q = et, W = q.createFocusTrap, ae = tt, z = ae.isFocusable, Y = parseInt((e = (t = /^(\d+)\./.exec(_.version)) === null || t === void 0 ? void 0 : t[1]) !== null && e !== void 0 ? e : 0, 10), V = /* @__PURE__ */ (function(d) {
935
+ function f(m) {
936
+ var s;
937
+ n(this, f), s = i(this, f, [m]), j(s, "getNodeForOption", function(p) {
938
+ var o, a = (o = this.internalOptions[p]) !== null && o !== void 0 ? o : this.originalOptions[p];
939
+ if (typeof a == "function") {
940
+ for (var c = arguments.length, h = new Array(c > 1 ? c - 1 : 0), b = 1; b < c; b++)
941
+ h[b - 1] = arguments[b];
942
+ a = a.apply(void 0, h);
943
+ }
944
+ if (a === !0 && (a = void 0), !a) {
945
+ if (a === void 0 || a === !1)
946
+ return a;
947
+ throw new Error("`".concat(p, "` was specified but was not a node, or did not return a node"));
948
+ }
949
+ var g = a;
950
+ if (typeof a == "string") {
951
+ var v;
952
+ if (g = (v = this.getDocument()) === null || v === void 0 ? void 0 : v.querySelector(a), !g)
953
+ throw new Error("`".concat(p, "` as selector refers to no known node"));
954
+ }
955
+ return g;
956
+ }), s.handleDeactivate = s.handleDeactivate.bind(s), s.handlePostDeactivate = s.handlePostDeactivate.bind(s), s.handleClickOutsideDeactivates = s.handleClickOutsideDeactivates.bind(s), s.internalOptions = {
957
+ // We need to hijack the returnFocusOnDeactivate option,
958
+ // because React can move focus into the element before we arrived at
959
+ // this lifecycle hook (e.g. with autoFocus inputs). So the component
960
+ // captures the previouslyFocusedElement in componentWillMount,
961
+ // then (optionally) returns focus to it in componentWillUnmount.
962
+ returnFocusOnDeactivate: !1,
963
+ // the rest of these are also related to deactivation of the trap, and we
964
+ // need to use them and control them as well
965
+ checkCanReturnFocus: null,
966
+ onDeactivate: s.handleDeactivate,
967
+ onPostDeactivate: s.handlePostDeactivate,
968
+ // we need to special-case this setting as well so that we can know if we should
969
+ // NOT return focus if the trap gets auto-deactivated as the result of an
970
+ // outside click (otherwise, we'll always think we should return focus because
971
+ // of how we manage that flag internally here)
972
+ clickOutsideDeactivates: s.handleClickOutsideDeactivates
973
+ }, s.originalOptions = {
974
+ // because of the above `internalOptions`, we maintain our own flag for
975
+ // this option, and default it to `true` because that's focus-trap's default
976
+ returnFocusOnDeactivate: !0,
977
+ // because of the above `internalOptions`, we keep these separate since
978
+ // they're part of the deactivation process which we configure (internally) to
979
+ // be shared between focus-trap and focus-trap-react
980
+ onDeactivate: null,
981
+ onPostDeactivate: null,
982
+ checkCanReturnFocus: null,
983
+ // the user's setting, defaulted to false since focus-trap defaults this to false
984
+ clickOutsideDeactivates: !1
985
+ };
986
+ var T = m.focusTrapOptions;
987
+ for (var F in T)
988
+ if (Object.prototype.hasOwnProperty.call(T, F)) {
989
+ if (F === "returnFocusOnDeactivate" || F === "onDeactivate" || F === "onPostDeactivate" || F === "checkCanReturnFocus" || F === "clickOutsideDeactivates") {
990
+ s.originalOptions[F] = T[F];
991
+ continue;
992
+ }
993
+ s.internalOptions[F] = T[F];
994
+ }
995
+ return s.outsideClick = null, s.focusTrapElements = m.containerElements || [], s.updatePreviousElement(), s;
996
+ }
997
+ return D(f, d), l(f, [{
998
+ key: "getDocument",
999
+ value: function() {
1000
+ return this.props.focusTrapOptions.document || (typeof document < "u" ? document : void 0);
1001
+ }
1002
+ }, {
1003
+ key: "getReturnFocusNode",
1004
+ value: function() {
1005
+ var s = this.getNodeForOption("setReturnFocus", this.previouslyFocusedElement);
1006
+ return s || (s === !1 ? !1 : this.previouslyFocusedElement);
1007
+ }
1008
+ /** Update the previously focused element with the currently focused element. */
1009
+ }, {
1010
+ key: "updatePreviousElement",
1011
+ value: function() {
1012
+ var s = this.getDocument();
1013
+ s && (this.previouslyFocusedElement = s.activeElement);
1014
+ }
1015
+ }, {
1016
+ key: "deactivateTrap",
1017
+ value: function() {
1018
+ !this.focusTrap || !this.focusTrap.active || this.focusTrap.deactivate({
1019
+ // NOTE: we never let the trap return the focus since we do that ourselves
1020
+ returnFocus: !1,
1021
+ // we'll call this in our own post deactivate handler so make sure the trap doesn't
1022
+ // do it prematurely
1023
+ checkCanReturnFocus: null,
1024
+ // let it call the user's original deactivate handler, if any, instead of
1025
+ // our own which calls back into this function
1026
+ onDeactivate: this.originalOptions.onDeactivate
1027
+ // NOTE: for post deactivate, don't specify anything so that it calls the
1028
+ // onPostDeactivate handler specified on `this.internalOptions`
1029
+ // which will always be our own `handlePostDeactivate()` handler, which
1030
+ // will finish things off by calling the user's provided onPostDeactivate
1031
+ // handler, if any, at the right time
1032
+ // onPostDeactivate: NOTHING
1033
+ });
1034
+ }
1035
+ }, {
1036
+ key: "handleClickOutsideDeactivates",
1037
+ value: function(s) {
1038
+ var T = typeof this.originalOptions.clickOutsideDeactivates == "function" ? this.originalOptions.clickOutsideDeactivates.call(null, s) : this.originalOptions.clickOutsideDeactivates;
1039
+ return T && (this.outsideClick = {
1040
+ target: s.target,
1041
+ allowDeactivation: T
1042
+ }), T;
1043
+ }
1044
+ }, {
1045
+ key: "handleDeactivate",
1046
+ value: function() {
1047
+ this.originalOptions.onDeactivate && this.originalOptions.onDeactivate.call(null), this.deactivateTrap();
1048
+ }
1049
+ }, {
1050
+ key: "handlePostDeactivate",
1051
+ value: function() {
1052
+ var s = this, T = function() {
1053
+ var p = s.getReturnFocusNode(), o = !!// did the consumer allow it?
1054
+ (s.originalOptions.returnFocusOnDeactivate && // can we actually focus the node?
1055
+ p !== null && p !== void 0 && p.focus && // was there an outside click that allowed deactivation?
1056
+ (!s.outsideClick || // did the consumer allow deactivation when the outside node was clicked?
1057
+ s.outsideClick.allowDeactivation && // is the outside node NOT focusable (implying that it did NOT receive focus
1058
+ // as a result of the click-through) -- in which case do NOT restore focus
1059
+ // to `returnFocusNode` because focus should remain on the outside node
1060
+ !z(s.outsideClick.target, s.internalOptions.tabbableOptions))), a = s.internalOptions.preventScroll, c = a === void 0 ? !1 : a;
1061
+ o && p.focus({
1062
+ preventScroll: c
1063
+ }), s.originalOptions.onPostDeactivate && s.originalOptions.onPostDeactivate.call(null), s.outsideClick = null;
1064
+ };
1065
+ this.originalOptions.checkCanReturnFocus ? this.originalOptions.checkCanReturnFocus.call(null, this.getReturnFocusNode()).then(T, T) : T();
1066
+ }
1067
+ }, {
1068
+ key: "setupFocusTrap",
1069
+ value: function() {
1070
+ if (this.focusTrap)
1071
+ this.props.active && !this.focusTrap.active && (this.focusTrap.activate(), this.props.paused && this.focusTrap.pause());
1072
+ else {
1073
+ var s = this.focusTrapElements.some(Boolean);
1074
+ s && (this.focusTrap = this.props._createFocusTrap(this.focusTrapElements, this.internalOptions), this.props.active && this.focusTrap.activate(), this.props.paused && this.focusTrap.pause());
1075
+ }
1076
+ }
1077
+ }, {
1078
+ key: "componentDidMount",
1079
+ value: function() {
1080
+ this.props.active && this.setupFocusTrap();
1081
+ }
1082
+ }, {
1083
+ key: "componentDidUpdate",
1084
+ value: function(s) {
1085
+ if (this.focusTrap) {
1086
+ s.containerElements !== this.props.containerElements && this.focusTrap.updateContainerElements(this.props.containerElements);
1087
+ var T = !s.active && this.props.active, F = s.active && !this.props.active, p = !s.paused && this.props.paused, o = s.paused && !this.props.paused;
1088
+ if (T && (this.updatePreviousElement(), this.focusTrap.activate()), F) {
1089
+ this.deactivateTrap();
1090
+ return;
1091
+ }
1092
+ p && this.focusTrap.pause(), o && this.focusTrap.unpause();
1093
+ } else
1094
+ s.containerElements !== this.props.containerElements && (this.focusTrapElements = this.props.containerElements), this.props.active && (this.updatePreviousElement(), this.setupFocusTrap());
1095
+ }
1096
+ }, {
1097
+ key: "componentWillUnmount",
1098
+ value: function() {
1099
+ this.deactivateTrap();
1100
+ }
1101
+ }, {
1102
+ key: "render",
1103
+ value: function() {
1104
+ var s = this, T = this.props.children ? _.Children.only(this.props.children) : void 0;
1105
+ if (T) {
1106
+ if (T.type && T.type === _.Fragment)
1107
+ throw new Error("A focus-trap cannot use a Fragment as its child container. Try replacing it with a <div> element.");
1108
+ var F = function(a) {
1109
+ var c = s.props.containerElements;
1110
+ T && (Y >= 19 ? typeof T.props.ref == "function" ? T.props.ref(a) : T.props.ref && (T.props.ref.current = a) : typeof T.ref == "function" ? T.ref(a) : T.ref && (T.ref.current = a)), s.focusTrapElements = c || [a];
1111
+ }, p = _.cloneElement(T, {
1112
+ ref: F
1113
+ });
1114
+ return p;
1115
+ }
1116
+ return null;
1117
+ }
1118
+ }]);
1119
+ })(_.Component);
1120
+ return V.defaultProps = {
1121
+ active: !0,
1122
+ paused: !1,
1123
+ focusTrapOptions: {},
1124
+ _createFocusTrap: W
1125
+ }, H.exports = V, H.exports.FocusTrap = V, H.exports;
1126
+ }
1127
+ var nt = rt();
1128
+ export {
1129
+ nt as f
1130
+ };