@carbon/ai-chat 0.1.1-alpha5 → 0.1.1-react17

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 (75) hide show
  1. package/dist/App.js +933 -55468
  2. package/dist/Carousel.js +1 -5705
  3. package/dist/Chat.js +1 -8339
  4. package/dist/GenesysMessengerServiceDesk.js +1 -579
  5. package/dist/HumanAgentServiceImpl.js +1 -1122
  6. package/dist/NiceDFOServiceDesk.js +2 -2097
  7. package/dist/PDFViewerContainer.js +2 -27439
  8. package/dist/SFServiceDesk.js +1 -1012
  9. package/dist/ServiceDeskImpl.js +1 -72
  10. package/dist/ZendeskServiceDesk.js +1 -649
  11. package/dist/_commonjsHelpers.js +1 -33
  12. package/dist/_node-resolve_empty.js +1 -25
  13. package/dist/agentActions.js +1 -187
  14. package/dist/aiChatEntry.js +1 -28
  15. package/dist/aiChatEntry2.js +4 -7022
  16. package/dist/anonymousUserIDStorage.js +2 -250
  17. package/dist/ar-dz.js +1 -55
  18. package/dist/ar-kw.js +1 -55
  19. package/dist/ar-ly.js +1 -55
  20. package/dist/ar-ma.js +1 -55
  21. package/dist/ar-sa.js +1 -55
  22. package/dist/ar-tn.js +1 -55
  23. package/dist/ar.js +1 -55
  24. package/dist/ar2.js +1 -470
  25. package/dist/cs.js +1 -55
  26. package/dist/cs2.js +1 -470
  27. package/dist/de-at.js +1 -55
  28. package/dist/de-ch.js +1 -55
  29. package/dist/de.js +1 -55
  30. package/dist/de2.js +1 -470
  31. package/dist/domUtils.js +2 -820
  32. package/dist/en-au.js +1 -55
  33. package/dist/en-ca.js +1 -55
  34. package/dist/en-gb.js +1 -55
  35. package/dist/en-ie.js +1 -55
  36. package/dist/en-il.js +1 -55
  37. package/dist/en-nz.js +1 -55
  38. package/dist/es-do.js +1 -55
  39. package/dist/es-us.js +1 -55
  40. package/dist/es.js +1 -55
  41. package/dist/es2.js +1 -470
  42. package/dist/export.js +1 -25
  43. package/dist/export.legacy.js +1 -25
  44. package/dist/fontUtils.js +1 -1036
  45. package/dist/fr-ca.js +1 -55
  46. package/dist/fr-ch.js +1 -55
  47. package/dist/fr.js +1 -55
  48. package/dist/fr2.js +1 -470
  49. package/dist/humanAgentUtils.js +1 -1393
  50. package/dist/it-ch.js +1 -55
  51. package/dist/it.js +1 -55
  52. package/dist/it2.js +1 -470
  53. package/dist/ja.js +1 -55
  54. package/dist/ja2.js +1 -470
  55. package/dist/jstz.min.js +1 -41
  56. package/dist/ko.js +1 -55
  57. package/dist/ko2.js +1 -470
  58. package/dist/messageUtils.js +1 -1338
  59. package/dist/mockServiceDesk.js +1 -851
  60. package/dist/moduleFederationPluginUtils.js +2 -5852
  61. package/dist/nl.js +1 -55
  62. package/dist/nl2.js +1 -470
  63. package/dist/pt-br.js +1 -55
  64. package/dist/pt-br2.js +1 -470
  65. package/dist/pt.js +1 -55
  66. package/dist/render.js +1 -88
  67. package/dist/web-components/cds-aichat-container/index.js +3 -3
  68. package/dist/web-components/cds-aichat-container/index.js.map +1 -1
  69. package/dist/web-components/cds-aichat-custom-element/index.js +2 -2
  70. package/dist/web-components/cds-aichat-custom-element/index.js.map +1 -1
  71. package/dist/zh-cn.js +1 -55
  72. package/dist/zh-tw.js +1 -55
  73. package/dist/zh-tw2.js +1 -470
  74. package/dist/zh.js +1 -470
  75. package/package.json +1 -1
package/dist/domUtils.js CHANGED
@@ -1,823 +1,5 @@
1
- /*
2
-
3
-
4
- (C) Copyright IBM Corp. 2017, 2024. All Rights Reserved.
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7
- in compliance with the License. You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software distributed under the License
12
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13
- or implied. See the License for the specific language governing permissions and limitations under
14
- the License.
15
-
16
- @carbon/ai-chat 0.1.1-alpha5
17
-
18
- Built: Oct 24 2024 10:59 am -04:00
19
-
20
-
21
-
22
- */
23
- import { ab as memoizeOne } from './messageUtils.js';
24
-
25
- const t=t=>"object"==typeof t&&null!=t&&1===t.nodeType,e=(t,e)=>(!e||"hidden"!==t)&&("visible"!==t&&"clip"!==t),n=(t,n)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const o=getComputedStyle(t,null);return e(o.overflowY,n)||e(o.overflowX,n)||(t=>{const e=(t=>{if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}})(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)})(t)}return !1},o=(t,e,n,o,l,r,i,s)=>r<t&&i>e||r>t&&i<e?0:r<=t&&s<=n||i>=e&&s>=n?r-t-o:i>e&&s<n||r<t&&s>n?i-e+l:0,l=t=>{const e=t.parentElement;return null==e?t.getRootNode().host||null:e},r=(e,r)=>{var i,s,d,h;if("undefined"==typeof document)return [];const{scrollMode:c,block:f,inline:u,boundary:a,skipOverflowHiddenElements:g}=r,p="function"==typeof a?a:t=>t!==a;if(!t(e))throw new TypeError("Invalid target");const m=document.scrollingElement||document.documentElement,w=[];let W=e;for(;t(W)&&p(W);){if(W=l(W),W===m){w.push(W);break}null!=W&&W===document.body&&n(W)&&!n(document.documentElement)||null!=W&&n(W,g)&&w.push(W);}const b=null!=(s=null==(i=window.visualViewport)?void 0:i.width)?s:innerWidth,H=null!=(h=null==(d=window.visualViewport)?void 0:d.height)?h:innerHeight,{scrollX:y,scrollY:M}=window,{height:v,width:E,top:x,right:C,bottom:I,left:R}=e.getBoundingClientRect(),{top:T,right:B,bottom:F,left:V}=(t=>{const e=window.getComputedStyle(t);return {top:parseFloat(e.scrollMarginTop)||0,right:parseFloat(e.scrollMarginRight)||0,bottom:parseFloat(e.scrollMarginBottom)||0,left:parseFloat(e.scrollMarginLeft)||0}})(e);let k="start"===f||"nearest"===f?x-T:"end"===f?I+F:x+v/2-T+F,D="center"===u?R+E/2-V+B:"end"===u?C+B:R-V;const L=[];for(let t=0;t<w.length;t++){const e=w[t],{height:n,width:l,top:r,right:i,bottom:s,left:d}=e.getBoundingClientRect();if("if-needed"===c&&x>=0&&R>=0&&I<=H&&C<=b&&x>=r&&I<=s&&R>=d&&C<=i)return L;const h=getComputedStyle(e),a=parseInt(h.borderLeftWidth,10),g=parseInt(h.borderTopWidth,10),p=parseInt(h.borderRightWidth,10),W=parseInt(h.borderBottomWidth,10);let T=0,B=0;const F="offsetWidth"in e?e.offsetWidth-e.clientWidth-a-p:0,V="offsetHeight"in e?e.offsetHeight-e.clientHeight-g-W:0,S="offsetWidth"in e?0===e.offsetWidth?0:l/e.offsetWidth:0,X="offsetHeight"in e?0===e.offsetHeight?0:n/e.offsetHeight:0;if(m===e)T="start"===f?k:"end"===f?k-H:"nearest"===f?o(M,M+H,H,g,W,M+k,M+k+v,v):k-H/2,B="start"===u?D:"center"===u?D-b/2:"end"===u?D-b:o(y,y+b,b,a,p,y+D,y+D+E,E),T=Math.max(0,T+M),B=Math.max(0,B+y);else {T="start"===f?k-r-g:"end"===f?k-s+W+V:"nearest"===f?o(r,s,n,g,W+V,k,k+v,v):k-(r+n/2)+V/2,B="start"===u?D-d-a:"center"===u?D-(d+l/2)+F/2:"end"===u?D-i+p+F:o(d,i,l,a,p+F,D,D+E,E);const{scrollLeft:t,scrollTop:h}=e;T=0===X?0:Math.max(0,Math.min(h+T/X,e.scrollHeight-n/X+V)),B=0===S?0:Math.max(0,Math.min(t+B/S,e.scrollWidth-l/S+F)),k+=h-T,D+=t-B;}L.push({el:e,top:T,left:B});}return L};
26
-
1
+ import{ab as t}from"./messageUtils.js";const e=t=>"object"==typeof t&&null!=t&&1===t.nodeType,n=(t,e)=>(!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t,o=(t,e)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const o=getComputedStyle(t,null);return n(o.overflowY,e)||n(o.overflowX,e)||(t=>{const e=(t=>{if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}})(t);return!!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)})(t)}return!1},r=(t,e,n,o,r,i,l,a)=>i<t&&l>e||i>t&&l<e?0:i<=t&&a<=n||l>=e&&a>=n?i-t-o:l>e&&a<n||i<t&&a>n?l-e+r:0,i=t=>{const e=t.parentElement;return null==e?t.getRootNode().host||null:e};
27
2
  /*!
28
3
  * tabbable 6.2.0
29
4
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
30
- */
31
- // NOTE: separate `:not()` selectors has broader browser support than the newer
32
- // `:not([inert], [inert] *)` (Feb 2023)
33
- // CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes
34
- // the entire query to fail, resulting in no nodes found, which will break a lot
35
- // of things... so we have to rely on JS to identify nodes inside an inert container
36
- var candidateSelectors = ['input:not([inert])', 'select:not([inert])', 'textarea:not([inert])', 'a[href]:not([inert])', 'button:not([inert])', '[tabindex]:not(slot):not([inert])', 'audio[controls]:not([inert])', 'video[controls]:not([inert])', '[contenteditable]:not([contenteditable="false"]):not([inert])', 'details>summary:first-of-type:not([inert])', 'details:not([inert])'];
37
- var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
38
- var NoElement = typeof Element === 'undefined';
39
- var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
40
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
41
- var _element$getRootNode;
42
- return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
43
- } : function (element) {
44
- return element === null || element === void 0 ? void 0 : element.ownerDocument;
45
- };
46
-
47
- /**
48
- * Determines if a node is inert or in an inert ancestor.
49
- * @param {Element} [node]
50
- * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
51
- * see if any of them are inert. If false, only `node` itself is considered.
52
- * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
53
- * False if `node` is falsy.
54
- */
55
- var isInert = function isInert(node, lookUp) {
56
- var _node$getAttribute;
57
- if (lookUp === void 0) {
58
- lookUp = true;
59
- }
60
- // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
61
- // JS API property; we have to check the attribute, which can either be empty or 'true';
62
- // if it's `null` (not specified) or 'false', it's an active element
63
- 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');
64
- var inert = inertAtt === '' || inertAtt === 'true';
65
-
66
- // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
67
- // if it weren't for `matches()` not being a function on shadow roots; the following
68
- // code works for any kind of node
69
- // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`
70
- // so it likely would not support `:is([inert] *)` either...
71
- var result = inert || lookUp && node && isInert(node.parentNode); // recursive
72
-
73
- return result;
74
- };
75
-
76
- /**
77
- * Determines if a node's content is editable.
78
- * @param {Element} [node]
79
- * @returns True if it's content-editable; false if it's not or `node` is falsy.
80
- */
81
- var isContentEditable = function isContentEditable(node) {
82
- var _node$getAttribute2;
83
- // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
84
- // to use the attribute directly to check for this, which can either be empty or 'true';
85
- // if it's `null` (not specified) or 'false', it's a non-editable element
86
- 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');
87
- return attValue === '' || attValue === 'true';
88
- };
89
-
90
- /**
91
- * @param {Element} el container to check in
92
- * @param {boolean} includeContainer add container to check
93
- * @param {(node: Element) => boolean} filter filter candidates
94
- * @returns {Element[]}
95
- */
96
- var getCandidates = function getCandidates(el, includeContainer, filter) {
97
- // even if `includeContainer=false`, we still have to check it for inertness because
98
- // if it's inert, all its children are inert
99
- if (isInert(el)) {
100
- return [];
101
- }
102
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
103
- if (includeContainer && matches.call(el, candidateSelector)) {
104
- candidates.unshift(el);
105
- }
106
- candidates = candidates.filter(filter);
107
- return candidates;
108
- };
109
-
110
- /**
111
- * @callback GetShadowRoot
112
- * @param {Element} element to check for shadow root
113
- * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
114
- */
115
-
116
- /**
117
- * @callback ShadowRootFilter
118
- * @param {Element} shadowHostNode the element which contains shadow content
119
- * @returns {boolean} true if a shadow root could potentially contain valid candidates.
120
- */
121
-
122
- /**
123
- * @typedef {Object} CandidateScope
124
- * @property {Element} scopeParent contains inner candidates
125
- * @property {Element[]} candidates list of candidates found in the scope parent
126
- */
127
-
128
- /**
129
- * @typedef {Object} IterativeOptions
130
- * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
131
- * if a function, implies shadow support is enabled and either returns the shadow root of an element
132
- * or a boolean stating if it has an undisclosed shadow root
133
- * @property {(node: Element) => boolean} filter filter candidates
134
- * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
135
- * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
136
- */
137
-
138
- /**
139
- * @param {Element[]} elements list of element containers to match candidates from
140
- * @param {boolean} includeContainer add container list to check
141
- * @param {IterativeOptions} options
142
- * @returns {Array.<Element|CandidateScope>}
143
- */
144
- var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
145
- var candidates = [];
146
- var elementsToCheck = Array.from(elements);
147
- while (elementsToCheck.length) {
148
- var element = elementsToCheck.shift();
149
- if (isInert(element, false)) {
150
- // no need to look up since we're drilling down
151
- // anything inside this container will also be inert
152
- continue;
153
- }
154
- if (element.tagName === 'SLOT') {
155
- // add shadow dom slot scope (slot itself cannot be focusable)
156
- var assigned = element.assignedElements();
157
- var content = assigned.length ? assigned : element.children;
158
- var nestedCandidates = getCandidatesIteratively(content, true, options);
159
- if (options.flatten) {
160
- candidates.push.apply(candidates, nestedCandidates);
161
- } else {
162
- candidates.push({
163
- scopeParent: element,
164
- candidates: nestedCandidates
165
- });
166
- }
167
- } else {
168
- // check candidate element
169
- var validCandidate = matches.call(element, candidateSelector);
170
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
171
- candidates.push(element);
172
- }
173
-
174
- // iterate over shadow content if possible
175
- var shadowRoot = element.shadowRoot ||
176
- // check for an undisclosed shadow
177
- typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
178
-
179
- // no inert look up because we're already drilling down and checking for inertness
180
- // on the way down, so all containers to this root node should have already been
181
- // vetted as non-inert
182
- var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
183
- if (shadowRoot && validShadowRoot) {
184
- // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
185
- // shadow exists, so look at light dom children as fallback BUT create a scope for any
186
- // child candidates found because they're likely slotted elements (elements that are
187
- // children of the web component element (which has the shadow), in the light dom, but
188
- // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
189
- // _after_ we return from this recursive call
190
- var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
191
- if (options.flatten) {
192
- candidates.push.apply(candidates, _nestedCandidates);
193
- } else {
194
- candidates.push({
195
- scopeParent: element,
196
- candidates: _nestedCandidates
197
- });
198
- }
199
- } else {
200
- // there's not shadow so just dig into the element's (light dom) children
201
- // __without__ giving the element special scope treatment
202
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
203
- }
204
- }
205
- }
206
- return candidates;
207
- };
208
-
209
- /**
210
- * @private
211
- * Determines if the node has an explicitly specified `tabindex` attribute.
212
- * @param {HTMLElement} node
213
- * @returns {boolean} True if so; false if not.
214
- */
215
- var hasTabIndex = function hasTabIndex(node) {
216
- return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
217
- };
218
-
219
- /**
220
- * Determine the tab index of a given node.
221
- * @param {HTMLElement} node
222
- * @returns {number} Tab order (negative, 0, or positive number).
223
- * @throws {Error} If `node` is falsy.
224
- */
225
- var getTabIndex = function getTabIndex(node) {
226
- if (!node) {
227
- throw new Error('No node provided');
228
- }
229
- if (node.tabIndex < 0) {
230
- // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
231
- // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
232
- // yet they are still part of the regular tab order; in FF, they get a default
233
- // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
234
- // order, consider their tab index to be 0.
235
- // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
236
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
237
- if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
238
- return 0;
239
- }
240
- }
241
- return node.tabIndex;
242
- };
243
-
244
- /**
245
- * Determine the tab index of a given node __for sort order purposes__.
246
- * @param {HTMLElement} node
247
- * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
248
- * has tabIndex -1, but needs to be sorted by document order in order for its content to be
249
- * inserted into the correct sort position.
250
- * @returns {number} Tab order (negative, 0, or positive number).
251
- */
252
- var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
253
- var tabIndex = getTabIndex(node);
254
- if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
255
- return 0;
256
- }
257
- return tabIndex;
258
- };
259
- var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
260
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
261
- };
262
- var isInput = function isInput(node) {
263
- return node.tagName === 'INPUT';
264
- };
265
- var isHiddenInput = function isHiddenInput(node) {
266
- return isInput(node) && node.type === 'hidden';
267
- };
268
- var isDetailsWithSummary = function isDetailsWithSummary(node) {
269
- var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
270
- return child.tagName === 'SUMMARY';
271
- });
272
- return r;
273
- };
274
- var getCheckedRadio = function getCheckedRadio(nodes, form) {
275
- for (var i = 0; i < nodes.length; i++) {
276
- if (nodes[i].checked && nodes[i].form === form) {
277
- return nodes[i];
278
- }
279
- }
280
- };
281
- var isTabbableRadio = function isTabbableRadio(node) {
282
- if (!node.name) {
283
- return true;
284
- }
285
- var radioScope = node.form || getRootNode(node);
286
- var queryRadios = function queryRadios(name) {
287
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
288
- };
289
- var radioSet;
290
- if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
291
- radioSet = queryRadios(window.CSS.escape(node.name));
292
- } else {
293
- try {
294
- radioSet = queryRadios(node.name);
295
- } catch (err) {
296
- // eslint-disable-next-line no-console
297
- 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);
298
- return false;
299
- }
300
- }
301
- var checked = getCheckedRadio(radioSet, node.form);
302
- return !checked || checked === node;
303
- };
304
- var isRadio = function isRadio(node) {
305
- return isInput(node) && node.type === 'radio';
306
- };
307
- var isNonTabbableRadio = function isNonTabbableRadio(node) {
308
- return isRadio(node) && !isTabbableRadio(node);
309
- };
310
-
311
- // determines if a node is ultimately attached to the window's document
312
- var isNodeAttached = function isNodeAttached(node) {
313
- var _nodeRoot;
314
- // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
315
- // (but NOT _the_ document; see second 'If' comment below for more).
316
- // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
317
- // is attached, and the one we need to check if it's in the document or not (because the
318
- // shadow, and all nodes it contains, is never considered in the document since shadows
319
- // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
320
- // is hidden, or is not in the document itself but is detached, it will affect the shadow's
321
- // visibility, including all the nodes it contains). The host could be any normal node,
322
- // or a custom element (i.e. web component). Either way, that's the one that is considered
323
- // part of the document, not the shadow root, nor any of its children (i.e. the node being
324
- // tested).
325
- // To further complicate things, we have to look all the way up until we find a shadow HOST
326
- // that is attached (or find none) because the node might be in nested shadows...
327
- // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
328
- // document (per the docs) and while it's a Document-type object, that document does not
329
- // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
330
- // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
331
- // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
332
- // node is actually detached.
333
- // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
334
- // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
335
- // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
336
- // `ownerDocument` will be `null`, hence the optional chaining on it.
337
- var nodeRoot = node && getRootNode(node);
338
- var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
339
-
340
- // in some cases, a detached node will return itself as the root instead of a document or
341
- // shadow root object, in which case, we shouldn't try to look further up the host chain
342
- var attached = false;
343
- if (nodeRoot && nodeRoot !== node) {
344
- var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
345
- 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));
346
- while (!attached && nodeRootHost) {
347
- var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
348
- // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
349
- // which means we need to get the host's host and check if that parent host is contained
350
- // in (i.e. attached to) the document
351
- nodeRoot = getRootNode(nodeRootHost);
352
- nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
353
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
354
- }
355
- }
356
- return attached;
357
- };
358
- var isZeroArea = function isZeroArea(node) {
359
- var _node$getBoundingClie = node.getBoundingClientRect(),
360
- width = _node$getBoundingClie.width,
361
- height = _node$getBoundingClie.height;
362
- return width === 0 && height === 0;
363
- };
364
- var isHidden = function isHidden(node, _ref) {
365
- var displayCheck = _ref.displayCheck,
366
- getShadowRoot = _ref.getShadowRoot;
367
- // NOTE: visibility will be `undefined` if node is detached from the document
368
- // (see notes about this further down), which means we will consider it visible
369
- // (this is legacy behavior from a very long way back)
370
- // NOTE: we check this regardless of `displayCheck="none"` because this is a
371
- // _visibility_ check, not a _display_ check
372
- if (getComputedStyle(node).visibility === 'hidden') {
373
- return true;
374
- }
375
- var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
376
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
377
- if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
378
- return true;
379
- }
380
- if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
381
- if (typeof getShadowRoot === 'function') {
382
- // figure out if we should consider the node to be in an undisclosed shadow and use the
383
- // 'non-zero-area' fallback
384
- var originalNode = node;
385
- while (node) {
386
- var parentElement = node.parentElement;
387
- var rootNode = getRootNode(node);
388
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
389
- ) {
390
- // node has an undisclosed shadow which means we can only treat it as a black box, so we
391
- // fall back to a non-zero-area test
392
- return isZeroArea(node);
393
- } else if (node.assignedSlot) {
394
- // iterate up slot
395
- node = node.assignedSlot;
396
- } else if (!parentElement && rootNode !== node.ownerDocument) {
397
- // cross shadow boundary
398
- node = rootNode.host;
399
- } else {
400
- // iterate up normal dom
401
- node = parentElement;
402
- }
403
- }
404
- node = originalNode;
405
- }
406
- // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
407
- // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
408
- // it might be a falsy value, which means shadow DOM support is disabled
409
-
410
- // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
411
- // now we can just test to see if it would normally be visible or not, provided it's
412
- // attached to the main document.
413
- // NOTE: We must consider case where node is inside a shadow DOM and given directly to
414
- // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
415
-
416
- if (isNodeAttached(node)) {
417
- // this works wherever the node is: if there's at least one client rect, it's
418
- // somehow displayed; it also covers the CSS 'display: contents' case where the
419
- // node itself is hidden in place of its contents; and there's no need to search
420
- // up the hierarchy either
421
- return !node.getClientRects().length;
422
- }
423
-
424
- // Else, the node isn't attached to the document, which means the `getClientRects()`
425
- // API will __always__ return zero rects (this can happen, for example, if React
426
- // is used to render nodes onto a detached tree, as confirmed in this thread:
427
- // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
428
- //
429
- // It also means that even window.getComputedStyle(node).display will return `undefined`
430
- // because styles are only computed for nodes that are in the document.
431
- //
432
- // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
433
- // somehow. Though it was never stated officially, anyone who has ever used tabbable
434
- // APIs on nodes in detached containers has actually implicitly used tabbable in what
435
- // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
436
- // considering __everything__ to be visible because of the innability to determine styles.
437
- //
438
- // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
439
- // nodes as visible with the 'none' fallback.__
440
- if (displayCheck !== 'legacy-full') {
441
- return true; // hidden
442
- }
443
- // else, fallback to 'none' mode and consider the node visible
444
- } else if (displayCheck === 'non-zero-area') {
445
- // NOTE: Even though this tests that the node's client rect is non-zero to determine
446
- // whether it's displayed, and that a detached node will __always__ have a zero-area
447
- // client rect, we don't special-case for whether the node is attached or not. In
448
- // this mode, we do want to consider nodes that have a zero area to be hidden at all
449
- // times, and that includes attached or not.
450
- return isZeroArea(node);
451
- }
452
-
453
- // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
454
- // it's visible
455
- return false;
456
- };
457
-
458
- // form fields (nested) inside a disabled fieldset are not focusable/tabbable
459
- // unless they are in the _first_ <legend> element of the top-most disabled
460
- // fieldset
461
- var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
462
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
463
- var parentNode = node.parentElement;
464
- // check if `node` is contained in a disabled <fieldset>
465
- while (parentNode) {
466
- if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
467
- // look for the first <legend> among the children of the disabled <fieldset>
468
- for (var i = 0; i < parentNode.children.length; i++) {
469
- var child = parentNode.children.item(i);
470
- // when the first <legend> (in document order) is found
471
- if (child.tagName === 'LEGEND') {
472
- // if its parent <fieldset> is not nested in another disabled <fieldset>,
473
- // return whether `node` is a descendant of its first <legend>
474
- return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
475
- }
476
- }
477
- // the disabled <fieldset> containing `node` has no <legend>
478
- return true;
479
- }
480
- parentNode = parentNode.parentElement;
481
- }
482
- }
483
-
484
- // else, node's tabbable/focusable state should not be affected by a fieldset's
485
- // enabled/disabled state
486
- return false;
487
- };
488
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
489
- if (node.disabled ||
490
- // we must do an inert look up to filter out any elements inside an inert ancestor
491
- // because we're limited in the type of selectors we can use in JSDom (see related
492
- // note related to `candidateSelectors`)
493
- isInert(node) || isHiddenInput(node) || isHidden(node, options) ||
494
- // For a details element with a summary, the summary element gets the focus
495
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
496
- return false;
497
- }
498
- return true;
499
- };
500
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
501
- if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
502
- return false;
503
- }
504
- return true;
505
- };
506
- var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
507
- var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
508
- if (isNaN(tabIndex) || tabIndex >= 0) {
509
- return true;
510
- }
511
- // If a custom element has an explicit negative tabindex,
512
- // browsers will not allow tab targeting said element's children.
513
- return false;
514
- };
515
-
516
- /**
517
- * @param {Array.<Element|CandidateScope>} candidates
518
- * @returns Element[]
519
- */
520
- var sortByOrder = function sortByOrder(candidates) {
521
- var regularTabbables = [];
522
- var orderedTabbables = [];
523
- candidates.forEach(function (item, i) {
524
- var isScope = !!item.scopeParent;
525
- var element = isScope ? item.scopeParent : item;
526
- var candidateTabindex = getSortOrderTabIndex(element, isScope);
527
- var elements = isScope ? sortByOrder(item.candidates) : element;
528
- if (candidateTabindex === 0) {
529
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
530
- } else {
531
- orderedTabbables.push({
532
- documentOrder: i,
533
- tabIndex: candidateTabindex,
534
- item: item,
535
- isScope: isScope,
536
- content: elements
537
- });
538
- }
539
- });
540
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
541
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
542
- return acc;
543
- }, []).concat(regularTabbables);
544
- };
545
- var tabbable = function tabbable(container, options) {
546
- options = options || {};
547
- var candidates;
548
- if (options.getShadowRoot) {
549
- candidates = getCandidatesIteratively([container], options.includeContainer, {
550
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
551
- flatten: false,
552
- getShadowRoot: options.getShadowRoot,
553
- shadowRootFilter: isValidShadowRootTabbable
554
- });
555
- } else {
556
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
557
- }
558
- return sortByOrder(candidates);
559
- };
560
- var focusable = function focusable(container, options) {
561
- options = options || {};
562
- var candidates;
563
- if (options.getShadowRoot) {
564
- candidates = getCandidatesIteratively([container], options.includeContainer, {
565
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
566
- flatten: true,
567
- getShadowRoot: options.getShadowRoot
568
- });
569
- } else {
570
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
571
- }
572
- return candidates;
573
- };
574
- var isTabbable = function isTabbable(node, options) {
575
- options = options || {};
576
- if (!node) {
577
- throw new Error('No node provided');
578
- }
579
- if (matches.call(node, candidateSelector) === false) {
580
- return false;
581
- }
582
- return isNodeMatchingSelectorTabbable(options, node);
583
- };
584
- var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
585
- var isFocusable = function isFocusable(node, options) {
586
- options = options || {};
587
- if (!node) {
588
- throw new Error('No node provided');
589
- }
590
- if (matches.call(node, focusableCandidateSelector) === false) {
591
- return false;
592
- }
593
- return isNodeMatchingSelectorFocusable(options, node);
594
- };
595
-
596
- var index_esm = /*#__PURE__*/Object.freeze({
597
- __proto__: null,
598
- focusable: focusable,
599
- getTabIndex: getTabIndex,
600
- isFocusable: isFocusable,
601
- isTabbable: isTabbable,
602
- tabbable: tabbable
603
- });
604
-
605
- /**
606
- *
607
- * IBM Confidential
608
- *
609
- * (C) Copyright IBM Corp. 2020, 2024
610
- *
611
- * The source code for this program is not published or otherwise
612
- * divested of its trade secrets, irrespective of what has been
613
- * deposited with the U. S. Copyright Office
614
- *
615
- * US Government Users Restricted Rights - Use, duplication or
616
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
617
- *
618
- */
619
- /**
620
- * The calculated size of scrollbars in the application. Note that this value can vary by browser and operating
621
- * system. This is memoized so it's calculated lazily after the application has loaded.
622
- */
623
- const SCROLLBAR_WIDTH = memoizeOne(getScrollbarWidth);
624
- /**
625
- * Scrolls the given element into view if necessary.
626
- *
627
- * @param element The element to scroll.
628
- * @param animate Indicates if the scroll should be animated.
629
- * @param boundary An optional boundary element that tells the computation code where to stop when trying to find a
630
- * scrollable container.
631
- */
632
- function doScrollElementIntoView(element, animate = false, boundary) {
633
- if (element) {
634
- const actions = r(element, {
635
- boundary,
636
- scrollMode: 'if-needed',
637
- block: 'nearest',
638
- inline: 'nearest',
639
- });
640
- actions.forEach(({ el, top, left }) => {
641
- // noinspection JSSuspiciousNameCombination
642
- doScrollElement(el, Math.round(top), Math.round(left), animate);
643
- });
644
- }
645
- }
646
- /**
647
- * Sets the scroll position on the given scrollable element to the given top and left values.
648
- *
649
- * @param element The scrollable element to set the scroll position of.
650
- * @param scrollTop The scrollTop value to set.
651
- * @param scrollLeft The scrollLeft value to set.
652
- * @param animate Indicates if the scrolling should be done using animation.
653
- */
654
- function doScrollElement(element, scrollTop, scrollLeft, animate = false) {
655
- setTimeout(() => {
656
- if (element) {
657
- if (animate && element.scroll) {
658
- element.scroll({
659
- top: scrollTop,
660
- left: scrollLeft,
661
- behavior: 'smooth',
662
- });
663
- }
664
- else {
665
- element.scrollTop = scrollTop;
666
- element.scrollLeft = scrollLeft;
667
- }
668
- }
669
- });
670
- }
671
- /**
672
- * Calculates the width of a scrollbar in the system. This will add a temporary scrollable div to the document with
673
- * a div inside and then measure the difference in size of the element.
674
- */
675
- function getScrollbarWidth() {
676
- // Creating invisible container
677
- const outer = document.createElement('div');
678
- outer.style.visibility = 'hidden';
679
- outer.style.overflow = 'scroll';
680
- document.body.appendChild(outer);
681
- // Creating inner element and placing it in the container.
682
- const inner = document.createElement('div');
683
- outer.appendChild(inner);
684
- // Calculating difference between container's full width and the child width.
685
- const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
686
- // Removing temporary elements from the DOM.
687
- outer.parentNode.removeChild(outer);
688
- return scrollbarWidth;
689
- }
690
- /**
691
- * Requests focus be moved to the given element, optionally deferring it to the next event loop.
692
- *
693
- * @param element The element to move focus to.
694
- * @param preventScroll Indicates if scrolling should be prevented as a result of the focus change.
695
- */
696
- function doFocus(element, preventScroll = false) {
697
- if (element && document.activeElement !== element && tabbable(element, { getShadowRoot: true })) {
698
- element.focus({ preventScroll });
699
- }
700
- }
701
- /**
702
- * Requests focus be moved to the element referenced by the given react ref if the referenced element is defined.
703
- *
704
- * @param ref The reference to the element to move focus to.
705
- * @param defer Indicates if the focus should be executed now or if it should be deferred to another event loop.
706
- * @param preventScroll Indicates if scrolling should be prevented as a result of the focus change.
707
- */
708
- function doFocusRef(ref, defer = false, preventScroll = false) {
709
- if (ref) {
710
- if (defer) {
711
- setTimeout(() => {
712
- doFocusRef(ref);
713
- });
714
- }
715
- else if (ref.current) {
716
- doFocus(ref.current, preventScroll);
717
- }
718
- }
719
- }
720
- /**
721
- * Determines if the given node is an Element.
722
- */
723
- function isElement(node) {
724
- return node?.nodeType === 1;
725
- }
726
- /**
727
- * Determines if the given node is a Text node.
728
- */
729
- function isTextNode(node) {
730
- return node?.nodeType === 3;
731
- }
732
- /**
733
- * Determines if the given node is a INPUT html element.
734
- */
735
- function isInputNode(node) {
736
- return node?.tagName === 'INPUT';
737
- }
738
- /**
739
- * Determines if the given node is an IMG html element.
740
- */
741
- function isImageNode(node) {
742
- return node?.tagName === 'IMG';
743
- }
744
- /**
745
- * Determines if the given node is a TEXTAREA html element.
746
- */
747
- function isTextAreaNode(node) {
748
- return node?.tagName === 'TEXTAREA';
749
- }
750
- /**
751
- * Looks through an array of elements for the first child element that should receive focus.
752
- * If no elements should receive focus, returns false.
753
- *
754
- * @param elements An array of HTMLElements.
755
- *
756
- * @returns boolean explaining if there was a focusable element or not.
757
- */
758
- function focusOnFirstFocusableItemInArrayOfElements(elements) {
759
- for (let index = 0; index < elements.length; index++) {
760
- if (focusOnFirstFocusableElement(elements[index])) {
761
- return true;
762
- }
763
- }
764
- return false;
765
- }
766
- /**
767
- * Searches through the children of an element for an element to focus on. The first child that can get focus that is
768
- * found will receive focus. If no elements are found, returns false.
769
- *
770
- * @param parentElement An element with potential focusable children.
771
- */
772
- function focusOnFirstFocusableElement(parentElement) {
773
- const focusableElements = tabbable(parentElement, { getShadowRoot: true });
774
- if (focusableElements?.length) {
775
- doFocus(focusableElements[0]);
776
- return true;
777
- }
778
- return false;
779
- }
780
- /**
781
- * Determines if the given keyboard event represent a press of the enter key. This will exclude the key when pressed
782
- * as part of IME composing and it will also exclude the key if there are any modifier keys that are pressed at the same
783
- * time. This function supports both the built-in typescript KeyboardEvent type and the React version (which is
784
- * missing some properties).
785
- */
786
- function isEnterKey(event) {
787
- if (event.key === 'Enter' && !hasModifiers(event)) {
788
- // Users using IMEs could be making a word selection when they hit enter. This check will prevent the user’s
789
- // message from being sent prematurely.
790
- return !(event.isComposing || event.keyCode === 229);
791
- }
792
- return false;
793
- }
794
- /**
795
- * Determines if the given keyboard event has any modifier keys pressed.
796
- */
797
- function hasModifiers(event) {
798
- return event.shiftKey || event.altKey || event.metaKey || event.ctrlKey;
799
- }
800
- /**
801
- * Returns the "scrollBottom" value for the given element. This is similar to "scrollTop" except that it represents
802
- * the distance the element has been scrolled from the bottom.
803
- */
804
- function getScrollBottom(element) {
805
- if (element) {
806
- return element.scrollHeight - element.offsetHeight - element.scrollTop;
807
- }
808
- return 0;
809
- }
810
- /**
811
- * Loads the script at the given URL.
812
- */
813
- async function loadScript(url) {
814
- return new Promise((resolve, reject) => {
815
- const script = document.createElement('script');
816
- script.src = url;
817
- script.onload = () => resolve();
818
- script.onerror = reject;
819
- document.head.appendChild(script);
820
- });
821
- }
822
-
823
- export { SCROLLBAR_WIDTH as S, isInputNode as a, isTextAreaNode as b, isImageNode as c, isTextNode as d, doFocusRef as e, isFocusable as f, focusable as g, isTabbable as h, isElement as i, getTabIndex as j, index_esm as k, doScrollElementIntoView as l, getScrollBottom as m, doScrollElement as n, doFocus as o, isEnterKey as p, focusOnFirstFocusableItemInArrayOfElements as q, loadScript as r, tabbable as t };
5
+ */var l=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],a=l.join(","),u="undefined"==typeof Element,c=u?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,d=!u&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},s=function t(e,n){var o;void 0===n&&(n=!0);var r=null==e||null===(o=e.getAttribute)||void 0===o?void 0:o.call(e,"inert");return""===r||"true"===r||n&&e&&t(e.parentNode)},f=function(t,e,n){if(s(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(a));return e&&c.call(t,a)&&o.unshift(t),o=o.filter(n)},h=function t(e,n,o){for(var r=[],i=Array.from(e);i.length;){var l=i.shift();if(!s(l,!1))if("SLOT"===l.tagName){var u=l.assignedElements(),d=t(u.length?u:l.children,!0,o);o.flatten?r.push.apply(r,d):r.push({scopeParent:l,candidates:d})}else{c.call(l,a)&&o.filter(l)&&(n||!e.includes(l))&&r.push(l);var f=l.shadowRoot||"function"==typeof o.getShadowRoot&&o.getShadowRoot(l),h=!s(f,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(l));if(f&&h){var p=t(!0===f?l.children:f.children,!0,o);o.flatten?r.push.apply(r,p):r.push({scopeParent:l,candidates:p})}else i.unshift.apply(i,l.children)}}return r},p=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},m=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!p(t)?0:t.tabIndex},g=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},v=function(t){return"INPUT"===t.tagName},w=function(t){return function(t){return v(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||d(t),o=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=o(window.CSS.escape(t.name));else try{e=o(t.name)}catch(t){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",t.message),!1}var r=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!r||r===t}(t)},y=function(t){var e=t.getBoundingClientRect(),n=e.width,o=e.height;return 0===n&&0===o},b=function(t,e){var n=e.displayCheck,o=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var r=c.call(t,"details>summary:first-of-type")?t.parentElement:t;if(c.call(r,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return y(t)}else{if("function"==typeof o){for(var i=t;t;){var l=t.parentElement,a=d(t);if(l&&!l.shadowRoot&&!0===o(l))return y(t);t=t.assignedSlot?t.assignedSlot:l||a===t.ownerDocument?l:a.host}t=i}if(function(t){var e,n,o,r,i=t&&d(t),l=null===(e=i)||void 0===e?void 0:e.host,a=!1;if(i&&i!==t)for(a=!!(null!==(n=l)&&void 0!==n&&null!==(o=n.ownerDocument)&&void 0!==o&&o.contains(l)||null!=t&&null!==(r=t.ownerDocument)&&void 0!==r&&r.contains(t));!a&&l;){var u,c,s;a=!(null===(c=l=null===(u=i=d(l))||void 0===u?void 0:u.host)||void 0===c||null===(s=c.ownerDocument)||void 0===s||!s.contains(l))}return a}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},S=function(t,e){return!(e.disabled||s(e)||function(t){return v(t)&&"hidden"===t.type}(e)||b(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var o=e.children.item(n);if("LEGEND"===o.tagName)return!!c.call(e,"fieldset[disabled] *")||!o.contains(t)}return!0}e=e.parentElement}return!1}(e))},E=function(t,e){return!(w(e)||m(e)<0||!S(t,e))},N=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},R=function t(e){var n=[],o=[];return e.forEach((function(e,r){var i=!!e.scopeParent,l=i?e.scopeParent:e,a=function(t,e){var n=m(t);return n<0&&e&&!p(t)?0:n}(l,i),u=i?t(e.candidates):l;0===a?i?n.push.apply(n,u):n.push(l):o.push({documentOrder:r,tabIndex:a,item:e,isScope:i,content:u})})),o.sort(g).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},T=function(t,e){var n;return n=(e=e||{}).getShadowRoot?h([t],e.includeContainer,{filter:E.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:N}):f(t,e.includeContainer,E.bind(null,e)),R(n)},C=function(t,e){return(e=e||{}).getShadowRoot?h([t],e.includeContainer,{filter:S.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):f(t,e.includeContainer,S.bind(null,e))},I=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==c.call(t,a)&&E(e,t)},M=l.concat("iframe").join(","),W=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return!1!==c.call(t,M)&&S(e,t)},x=Object.freeze({__proto__:null,focusable:C,getTabIndex:m,isFocusable:W,isTabbable:I,tabbable:T});const A=t((function(){const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t);const e=document.createElement("div");t.appendChild(e);const n=t.offsetWidth-e.offsetWidth;return t.parentNode.removeChild(t),n}));function H(t,n=!1,l){if(t){const a=((t,n)=>{var l,a,u,c;if("undefined"==typeof document)return[];const{scrollMode:d,block:s,inline:f,boundary:h,skipOverflowHiddenElements:p}=n,m="function"==typeof h?h:t=>t!==h;if(!e(t))throw new TypeError("Invalid target");const g=document.scrollingElement||document.documentElement,v=[];let w=t;for(;e(w)&&m(w);){if(w=i(w),w===g){v.push(w);break}null!=w&&w===document.body&&o(w)&&!o(document.documentElement)||null!=w&&o(w,p)&&v.push(w)}const y=null!=(a=null==(l=window.visualViewport)?void 0:l.width)?a:innerWidth,b=null!=(c=null==(u=window.visualViewport)?void 0:u.height)?c:innerHeight,{scrollX:S,scrollY:E}=window,{height:N,width:R,top:T,right:C,bottom:I,left:M}=t.getBoundingClientRect(),{top:W,right:x,bottom:A,left:H}=(t=>{const e=window.getComputedStyle(t);return{top:parseFloat(e.scrollMarginTop)||0,right:parseFloat(e.scrollMarginRight)||0,bottom:parseFloat(e.scrollMarginBottom)||0,left:parseFloat(e.scrollMarginLeft)||0}})(t);let D="start"===s||"nearest"===s?T-W:"end"===s?I+A:T+N/2-W+A,k="center"===f?M+R/2-H+x:"end"===f?C+x:M-H;const L=[];for(let t=0;t<v.length;t++){const e=v[t],{height:n,width:o,top:i,right:l,bottom:a,left:u}=e.getBoundingClientRect();if("if-needed"===d&&T>=0&&M>=0&&I<=b&&C<=y&&T>=i&&I<=a&&M>=u&&C<=l)return L;const c=getComputedStyle(e),h=parseInt(c.borderLeftWidth,10),p=parseInt(c.borderTopWidth,10),m=parseInt(c.borderRightWidth,10),w=parseInt(c.borderBottomWidth,10);let W=0,x=0;const A="offsetWidth"in e?e.offsetWidth-e.clientWidth-h-m:0,H="offsetHeight"in e?e.offsetHeight-e.clientHeight-p-w:0,F="offsetWidth"in e?0===e.offsetWidth?0:o/e.offsetWidth:0,O="offsetHeight"in e?0===e.offsetHeight?0:n/e.offsetHeight:0;if(g===e)W="start"===s?D:"end"===s?D-b:"nearest"===s?r(E,E+b,b,p,w,E+D,E+D+N,N):D-b/2,x="start"===f?k:"center"===f?k-y/2:"end"===f?k-y:r(S,S+y,y,h,m,S+k,S+k+R,R),W=Math.max(0,W+E),x=Math.max(0,x+S);else{W="start"===s?D-i-p:"end"===s?D-a+w+H:"nearest"===s?r(i,a,n,p,w+H,D,D+N,N):D-(i+n/2)+H/2,x="start"===f?k-u-h:"center"===f?k-(u+o/2)+A/2:"end"===f?k-l+m+A:r(u,l,o,h,m+A,k,k+R,R);const{scrollLeft:t,scrollTop:c}=e;W=0===O?0:Math.max(0,Math.min(c+W/O,e.scrollHeight-n/O+H)),x=0===F?0:Math.max(0,Math.min(t+x/F,e.scrollWidth-o/F+A)),D+=c-W,k+=t-x}L.push({el:e,top:W,left:x})}return L})(t,{boundary:l,scrollMode:"if-needed",block:"nearest",inline:"nearest"});a.forEach((({el:t,top:e,left:o})=>{D(t,Math.round(e),Math.round(o),n)}))}}function D(t,e,n,o=!1){setTimeout((()=>{t&&(o&&t.scroll?t.scroll({top:e,left:n,behavior:"smooth"}):(t.scrollTop=e,t.scrollLeft=n))}))}function k(t,e=!1){t&&document.activeElement!==t&&T(t,{getShadowRoot:!0})&&t.focus({preventScroll:e})}function L(t,e=!1,n=!1){t&&(e?setTimeout((()=>{L(t)})):t.current&&k(t.current,n))}function F(t){return 1===t?.nodeType}function O(t){return 3===t?.nodeType}function P(t){return"INPUT"===t?.tagName}function U(t){return"IMG"===t?.tagName}function j(t){return"TEXTAREA"===t?.tagName}function B(t){for(let e=0;e<t.length;e++)if(V(t[e]))return!0;return!1}function V(t){const e=T(t,{getShadowRoot:!0});return!!e?.length&&(k(e[0]),!0)}function K(t){return"Enter"===t.key&&!function(t){return t.shiftKey||t.altKey||t.metaKey||t.ctrlKey}(t)&&!(t.isComposing||229===t.keyCode)}function X(t){return t?t.scrollHeight-t.offsetHeight-t.scrollTop:0}async function _(t){return new Promise(((e,n)=>{const o=document.createElement("script");o.src=t,o.onload=()=>e(),o.onerror=n,document.head.appendChild(o)}))}export{A as S,P as a,j as b,U as c,O as d,L as e,W as f,C as g,I as h,F as i,m as j,x as k,H as l,X as m,D as n,k as o,K as p,B as q,_ as r,T as t};