@arc-ui/components 13.0.0 → 13.2.0

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 (176) hide show
  1. package/lib/Alert/styles.css +1 -1
  2. package/lib/Align/styles.css +1 -1
  3. package/lib/AppButton/styles.css +1 -1
  4. package/lib/Avatar/styles.css +1 -1
  5. package/lib/AvatarGroup/styles.css +1 -1
  6. package/lib/Badge/styles.css +1 -1
  7. package/lib/Banner/Banner.cjs +7 -3
  8. package/lib/Banner/Banner.mjs +7 -3
  9. package/lib/Box/styles.css +1 -1
  10. package/lib/BrandLogo/styles.css +1 -1
  11. package/lib/Breadcrumbs/styles.css +1 -1
  12. package/lib/Button/styles.css +1 -1
  13. package/lib/ButtonGroup/styles.css +1 -1
  14. package/lib/ButtonV2/styles.css +1 -1
  15. package/lib/Calendar/Calendar.cjs +2 -2
  16. package/lib/Calendar/Calendar.mjs +2 -2
  17. package/lib/Calendar/styles.css +1 -1
  18. package/lib/CardFooter/styles.css +1 -1
  19. package/lib/CardHeading/styles.css +1 -1
  20. package/lib/Carousel/Carousel.cjs +26 -14
  21. package/lib/Carousel/Carousel.mjs +26 -14
  22. package/lib/Carousel/styles.css +1 -1
  23. package/lib/Checkbox/styles.css +1 -1
  24. package/lib/CheckboxIcon/styles.css +1 -1
  25. package/lib/ClientSideVisible/ClientSideVisible.cjs +1 -0
  26. package/lib/ClientSideVisible/ClientSideVisible.mjs +1 -0
  27. package/lib/Columns/styles.css +1 -1
  28. package/lib/ComboBox/ComboBox.cjs +530 -136
  29. package/lib/ComboBox/ComboBox.mjs +530 -136
  30. package/lib/ComboBox/styles.css +1 -1
  31. package/lib/ConditionalWrapper/ConditionalWrapper.cjs +1 -0
  32. package/lib/ConditionalWrapper/ConditionalWrapper.mjs +1 -0
  33. package/lib/ContentSwitcher/styles.css +1 -1
  34. package/lib/ContentSwitcherDropdown/styles.css +1 -1
  35. package/lib/DatePicker/DatePicker.cjs +3 -3
  36. package/lib/DatePicker/DatePicker.mjs +3 -3
  37. package/lib/DatePicker/styles.css +1 -1
  38. package/lib/Disclosure/styles.css +1 -1
  39. package/lib/DisclosureMini/styles.css +1 -1
  40. package/lib/Download/styles.css +1 -1
  41. package/lib/Drawer/styles.css +1 -1
  42. package/lib/Elevation/styles.css +1 -1
  43. package/lib/Filter/styles.css +1 -1
  44. package/lib/FormControl/styles.css +1 -1
  45. package/lib/GhostedHeroBanner/styles.css +1 -1
  46. package/lib/GradientPageBackground/GradientPageBackground.cjs +2 -2
  47. package/lib/GradientPageBackground/GradientPageBackground.mjs +2 -2
  48. package/lib/GradientPageBackground/styles.css +1 -1
  49. package/lib/Grid/Grid.cjs +1 -0
  50. package/lib/Grid/Grid.mjs +1 -0
  51. package/lib/Grid/styles.css +1 -1
  52. package/lib/Group/styles.css +1 -1
  53. package/lib/Heading/styles.css +1 -1
  54. package/lib/HeroBanner/HeroBanner.cjs +7 -3
  55. package/lib/HeroBanner/HeroBanner.mjs +7 -3
  56. package/lib/HeroBanner/styles.css +1 -1
  57. package/lib/HeroButton/styles.css +1 -1
  58. package/lib/Hidden/styles.css +1 -1
  59. package/lib/HorizontalCard/styles.css +1 -1
  60. package/lib/Icon/styles.css +1 -1
  61. package/lib/Image/styles.css +1 -1
  62. package/lib/ImpactCard/ImpactCard.cjs +28 -15
  63. package/lib/ImpactCard/ImpactCard.mjs +29 -16
  64. package/lib/ImpactCard/styles.css +1 -1
  65. package/lib/InformationCard/InformationCard.cjs +57 -33
  66. package/lib/InformationCard/InformationCard.mjs +59 -35
  67. package/lib/InformationCard/styles.css +1 -1
  68. package/lib/Link/styles.css +1 -1
  69. package/lib/Markup/styles.css +1 -1
  70. package/lib/MediaCard/MediaCard.cjs +40 -21
  71. package/lib/MediaCard/MediaCard.mjs +41 -22
  72. package/lib/MediaCard/styles.css +1 -1
  73. package/lib/Menu/styles.css +1 -1
  74. package/lib/Modal/styles.css +1 -1
  75. package/lib/NavigationHeader/NavigationHeader.cjs +2764 -472
  76. package/lib/NavigationHeader/NavigationHeader.mjs +2707 -436
  77. package/lib/NavigationHeader/styles.css +1 -1
  78. package/lib/Pagination/styles.css +1 -1
  79. package/lib/PaginationSimple/styles.css +1 -1
  80. package/lib/Popover/Popover.cjs +1 -1
  81. package/lib/Popover/Popover.mjs +1 -1
  82. package/lib/Popover/styles.css +1 -1
  83. package/lib/Poster/styles.css +1 -1
  84. package/lib/ProgressBar/styles.css +1 -1
  85. package/lib/ProgressStepper/styles.css +1 -1
  86. package/lib/ProgressStepperOverflow/styles.css +1 -1
  87. package/lib/RadioCardGroup/styles.css +1 -1
  88. package/lib/RadioGroup/RadioGroup.cjs +2 -1
  89. package/lib/RadioGroup/RadioGroup.mjs +2 -1
  90. package/lib/RadioGroup/styles.css +1 -1
  91. package/lib/Rule/styles.css +1 -1
  92. package/lib/ScrollToTop/styles.css +1 -1
  93. package/lib/Section/styles.css +1 -1
  94. package/lib/Select/styles.css +1 -1
  95. package/lib/SemanticButton/SemanticButton.cjs +10 -0
  96. package/lib/SemanticButton/SemanticButton.mjs +4 -0
  97. package/lib/SemanticButton/styles.css +1 -0
  98. package/lib/SemanticHeading/styles.css +1 -1
  99. package/lib/SemanticLink/SemanticLink.cjs +10 -0
  100. package/lib/SemanticLink/SemanticLink.mjs +4 -0
  101. package/lib/SemanticLink/styles.css +1 -0
  102. package/lib/SiteFooter/styles.css +1 -1
  103. package/lib/SiteFooterV2/SiteFooterV2.cjs +3 -2
  104. package/lib/SiteFooterV2/SiteFooterV2.mjs +3 -2
  105. package/lib/SiteFooterV2/styles.css +1 -1
  106. package/lib/SiteHeaderV2/SiteHeaderV2.cjs +1 -1
  107. package/lib/SiteHeaderV2/SiteHeaderV2.mjs +1 -1
  108. package/lib/SiteHeaderV2/styles.css +1 -1
  109. package/lib/Skeleton/styles.css +1 -1
  110. package/lib/SkipLink/SkipLink.cjs +1 -0
  111. package/lib/SkipLink/SkipLink.mjs +1 -0
  112. package/lib/SkipLink/styles.css +1 -1
  113. package/lib/Spacing/Spacing.cjs +38 -0
  114. package/lib/Spacing/Spacing.mjs +36 -0
  115. package/lib/Spacing/styles.css +1 -0
  116. package/lib/Spinner/styles.css +1 -1
  117. package/lib/Surface/styles.css +1 -1
  118. package/lib/Switch/styles.css +1 -1
  119. package/lib/TabbedBanner/TabbedBanner.cjs +5 -3
  120. package/lib/TabbedBanner/TabbedBanner.mjs +5 -3
  121. package/lib/TabbedBanner/styles.css +1 -1
  122. package/lib/Tabs/Tabs.cjs +57 -25
  123. package/lib/Tabs/Tabs.mjs +57 -25
  124. package/lib/Tabs/styles.css +1 -1
  125. package/lib/Tag/styles.css +1 -1
  126. package/lib/TemplateBanner/TemplateBanner.cjs +5 -1
  127. package/lib/TemplateBanner/TemplateBanner.mjs +5 -1
  128. package/lib/TemplateBanner/styles.css +1 -1
  129. package/lib/Text/styles.css +1 -1
  130. package/lib/TextArea/styles.css +1 -1
  131. package/lib/TextInput/TextInput.cjs +1 -1
  132. package/lib/TextInput/TextInput.mjs +1 -1
  133. package/lib/TextInput/styles.css +1 -1
  134. package/lib/Theme/Theme.cjs +1 -1
  135. package/lib/Theme/Theme.mjs +1 -1
  136. package/lib/Theme/styles.css +1 -1
  137. package/lib/ThemeIcon/styles.css +1 -1
  138. package/lib/ThumbnailSignpost/styles.css +1 -1
  139. package/lib/Toast/styles.css +1 -1
  140. package/lib/Tooltip/styles.css +1 -1
  141. package/lib/Truncate/styles.css +1 -1
  142. package/lib/TypographyCard/TypographyCard.cjs +38 -14
  143. package/lib/TypographyCard/TypographyCard.mjs +39 -15
  144. package/lib/TypographyCard/styles.css +1 -1
  145. package/lib/UniversalHeader/UniversalHeader.cjs +10 -8
  146. package/lib/UniversalHeader/UniversalHeader.mjs +10 -8
  147. package/lib/UniversalHeader/styles.css +1 -1
  148. package/lib/VerticalSpace/styles.css +1 -1
  149. package/lib/VideoPlayer/styles.css +1 -1
  150. package/lib/Visible/styles.css +1 -1
  151. package/lib/VisuallyHidden/styles.css +1 -1
  152. package/lib/_shared/cjs/{Calendar-CdLn9iv6.cjs → Calendar-B-DmNni2.cjs} +1 -1
  153. package/lib/_shared/cjs/{Popover-BtvRErpC.cjs → Popover-BxuQPltF.cjs} +2 -2
  154. package/lib/_shared/cjs/SemanticButton-Be0gsNLA.cjs +16 -0
  155. package/lib/_shared/cjs/SemanticLink-DYO9HLGa.cjs +16 -0
  156. package/lib/_shared/cjs/{TemplateBanner-DyXBKuMw.cjs → TemplateBanner-DfzDwiVT.cjs} +35 -5
  157. package/lib/_shared/cjs/{TextInput-C_K2PLf5.cjs → TextInput-CLkhL2KT.cjs} +39 -6
  158. package/lib/_shared/cjs/{arc-breakpoints-uADxN-b4.cjs → arc-breakpoints-C3HREhvT.cjs} +1 -1
  159. package/lib/_shared/cjs/{index.es-BAsay4oe.cjs → index.es-D5DdMrn2.cjs} +1 -1
  160. package/lib/_shared/esm/{Calendar-CzFIMyD1.mjs → Calendar-CfEBiAjy.mjs} +1 -1
  161. package/lib/_shared/esm/{Popover-DRQSgAog.mjs → Popover-Pjtmu_TN.mjs} +2 -2
  162. package/lib/_shared/esm/SemanticButton-NGAMAw3m.mjs +14 -0
  163. package/lib/_shared/esm/SemanticLink-DfJjaHk2.mjs +14 -0
  164. package/lib/_shared/esm/{TemplateBanner-BPzuH5bz.mjs → TemplateBanner-oQjgkrBQ.mjs} +36 -6
  165. package/lib/_shared/esm/{TextInput-BCvKXfM_.mjs → TextInput-WczTCUvp.mjs} +40 -7
  166. package/lib/_shared/esm/{arc-breakpoints-ChQgbftE.mjs → arc-breakpoints-ANMn37k9.mjs} +1 -1
  167. package/lib/_shared/esm/{index.es-99J0r2va.mjs → index.es-Du5Lyvbp.mjs} +2 -2
  168. package/lib/index.cjs +9958 -7073
  169. package/lib/index.cjs.map +1 -1
  170. package/lib/index.d.cts +560 -203
  171. package/lib/index.d.mts +560 -203
  172. package/lib/index.js.map +1 -1
  173. package/lib/index.mjs +16949 -14068
  174. package/lib/index.mjs.map +1 -1
  175. package/lib/styles.css +6 -2
  176. package/package.json +9 -8
@@ -4,31 +4,62 @@
4
4
  var tslib_es6 = require('../_shared/cjs/tslib.es6-CCZ3TN_7.cjs');
5
5
  var React = require('react');
6
6
  var Visible = require('../_shared/cjs/Visible-Ca2H20zc.cjs');
7
- var index = require('../_shared/cjs/index-CTlXMLug.cjs');
8
- var suffixModifier = require('../_shared/cjs/suffix-modifier-DLUGR-yG.cjs');
7
+ var index$2 = require('../_shared/cjs/index-CTlXMLug.cjs');
9
8
  var Surface = require('../_shared/cjs/Surface-DIU5ciDT.cjs');
10
- var index$2 = require('../_shared/cjs/index-BDUrOKEW.cjs');
11
- var index$1 = require('../_shared/cjs/index-DlWZZNwu.cjs');
9
+ var suffixModifier = require('../_shared/cjs/suffix-modifier-DLUGR-yG.cjs');
10
+ var SemanticLink = require('../_shared/cjs/SemanticLink-DYO9HLGa.cjs');
12
11
  var Tooltip = require('../_shared/cjs/Tooltip-CdmWvrnr.cjs');
13
12
  var ThemeIcon = require('../_shared/cjs/ThemeIcon-CwYN77IF.cjs');
14
13
  var VisuallyHidden = require('../_shared/cjs/VisuallyHidden-CQg3cOVK.cjs');
14
+ var SemanticButton = require('../_shared/cjs/SemanticButton-Be0gsNLA.cjs');
15
+ var index$4 = require('../_shared/cjs/index-BDUrOKEW.cjs');
16
+ var index$3 = require('../_shared/cjs/index-DlWZZNwu.cjs');
15
17
  var Icon = require('../_shared/cjs/Icon-Dk2XHa7V.cjs');
16
18
  var Text = require('../_shared/cjs/Text-jwsn80lQ.cjs');
17
19
  var ConditionalWrapper = require('../_shared/cjs/ConditionalWrapper-Cl6kgjCL.cjs');
18
- var arcBreakpoints = require('../_shared/cjs/arc-breakpoints-uADxN-b4.cjs');
19
- var Popover = require('../_shared/cjs/Popover-BtvRErpC.cjs');
20
+ var filterAttrs = require('../_shared/cjs/filter-attrs-D19P2s1V.cjs');
21
+ var Heading = require('../_shared/cjs/Heading-BYBmZkmS.cjs');
22
+ var VerticalSpace = require('../_shared/cjs/VerticalSpace-DLQUYsvc.cjs');
23
+ var Rule = require('../_shared/cjs/Rule-essaguo_.cjs');
24
+ require('../_shared/cjs/index-DR8Rkav9.cjs');
25
+ var arcBreakpoints = require('../_shared/cjs/arc-breakpoints-C3HREhvT.cjs');
26
+ var Popover = require('../_shared/cjs/Popover-BxuQPltF.cjs');
27
+ var index$5 = require('../_shared/cjs/index-BCu-VH8y.cjs');
28
+ var ButtonV2 = require('../_shared/cjs/ButtonV2-CxyploaQ.cjs');
29
+ require('react/jsx-runtime');
30
+ var ReactDOM = require('react-dom');
20
31
  var isSymbol = require('../_shared/cjs/isSymbol-BGrHFUbV.cjs');
21
32
  var Hidden = require('../_shared/cjs/Hidden-BpWHucG2.cjs');
22
- require('../_shared/cjs/filter-attrs-D19P2s1V.cjs');
23
- require('../_shared/cjs/index-DR8Rkav9.cjs');
33
+ require('../_shared/cjs/index-BdJeAKfz.cjs');
24
34
  require('../_shared/cjs/Combination-Cm62lfyr.cjs');
25
- require('react/jsx-runtime');
26
- require('react-dom');
27
35
  require('../_shared/cjs/index-BBDa9gnQ.cjs');
28
- require('../_shared/cjs/index-BdJeAKfz.cjs');
29
- require('../_shared/cjs/index.es-BAsay4oe.cjs');
36
+ require('../_shared/cjs/SemanticHeading-C1-fyc3V.cjs');
37
+ require('../_shared/cjs/index.es-D5DdMrn2.cjs');
30
38
  require('../_shared/cjs/index-DsqYRMfM.cjs');
31
39
  require('../_shared/cjs/index-WO7l1Mfx.cjs');
40
+ require('../_shared/cjs/index-CztwwwKE.cjs');
41
+ require('../_shared/cjs/index-DmvtEa22.cjs');
42
+ require('../_shared/cjs/Spinner-427lpnHI.cjs');
43
+
44
+ function _interopNamespaceDefault(e) {
45
+ var n = Object.create(null);
46
+ if (e) {
47
+ Object.keys(e).forEach(function (k) {
48
+ if (k !== 'default') {
49
+ var d = Object.getOwnPropertyDescriptor(e, k);
50
+ Object.defineProperty(n, k, d.get ? d : {
51
+ enumerable: true,
52
+ get: function () { return e[k]; }
53
+ });
54
+ }
55
+ });
56
+ }
57
+ n.default = e;
58
+ return Object.freeze(n);
59
+ }
60
+
61
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
62
+ var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
32
63
 
33
64
  /**
34
65
  * Detect interaction mode
@@ -64,6 +95,51 @@ var useUniqueString = function (value) {
64
95
  return "".concat(value, "-").concat(id);
65
96
  };
66
97
 
98
+ var NavigationHeaderContainer = function (_a) {
99
+ var _b = _a.isPill, isPill = _b === void 0 ? false : _b, _c = _a.isExtended, isExtended = _c === void 0 ? false : _c, _d = _a.isFluid, isFluid = _d === void 0 ? false : _d, ref = _a.ref, backgroundColor = _a.backgroundColor, children = _a.children;
100
+ var backgroundColors = {
101
+ light: {
102
+ surface: "light-white",
103
+ classSuffix: "backgroundLight",
104
+ },
105
+ neutral: {
106
+ surface: "light-white",
107
+ classSuffix: "backgroundNeutral",
108
+ },
109
+ lightElevated: {
110
+ surface: "light-white",
111
+ classSuffix: "backgroundLightElevated",
112
+ },
113
+ transparentOnDark: {
114
+ surface: "dark-black",
115
+ classSuffix: "backgroundTransparent",
116
+ },
117
+ transparentOnLight: {
118
+ surface: "light-white",
119
+ classSuffix: "backgroundTransparent",
120
+ },
121
+ ghostedOnLight: {
122
+ surface: "light-white",
123
+ classSuffix: "backgroundGhosted",
124
+ },
125
+ ghostedOnDark: {
126
+ surface: "dark-black",
127
+ classSuffix: "backgroundGhosted",
128
+ },
129
+ };
130
+ return (React.createElement("div", { "data-testid": "NavigationHeader-container", className: index$2.classNames("arc-NavigationHeaderContainer--".concat(backgroundColors[backgroundColor].classSuffix), {
131
+ "arc-NavigationHeaderContainer--pill": isPill,
132
+ "arc-NavigationHeaderContainer--fullWidth": !isPill,
133
+ "arc-NavigationHeaderContainer--regular": !isExtended,
134
+ "arc-NavigationHeaderContainer--extended": isExtended,
135
+ "arc-NavigationHeaderContainer--fluid": isFluid,
136
+ }) },
137
+ React.createElement("div", { ref: ref, className: "arc-NavigationHeaderContainer-outer" },
138
+ React.createElement(Surface.Surface, { isTransparent: true, background: backgroundColors[backgroundColor].surface },
139
+ React.createElement("div", { className: "arc-NavigationHeaderContainer-inner" },
140
+ React.createElement("div", { className: "arc-NavigationHeaderContainer-content" }, children))))));
141
+ };
142
+
67
143
  var BtLogo = function () { return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 50 50" },
68
144
  React.createElement("path", { d: "M26.225 16.475h12.45v3.65H34.5v13.35h-4.1v-13.35h-4.175v-3.65zM25 46.925c-12.1 0-21.925-9.825-21.925-21.924C3.075 12.9 12.9 3.075 25 3.075 37.1 3.075 46.926 12.9 46.926 25c0 12.1-9.825 21.926-21.926 21.926zM25 50c13.8 0 25-11.2 25-25C50 11.199 38.8 0 25 0S0 11.2 0 25c0 13.801 11.2 25 25 25zm-4.225-21.725c0-1.074-.674-1.8-1.825-1.8H16.2v3.55h2.75c1.15 0 1.825-.725 1.825-1.75zm-.5-6.824c0-.9-.574-1.526-1.55-1.526h-2.524v3.1h2.525c.975 0 1.55-.624 1.55-1.574zm4.65 7.025c0 3.225-2.275 5-5.524 5h-7.246v-17h6.771c3.275 0 5.5 1.674 5.5 4.75 0 1.399-.625 2.649-1.625 3.4 1.15.674 2.124 1.974 2.124 3.85z", fill: "currentColor" }))); };
69
145
 
@@ -86,417 +162,2547 @@ var NavigationHeaderLogo = function (_a) {
86
162
  btGlobalFabric: BtGlobalFabricLogo,
87
163
  btWholesale: BtWholesaleLogo,
88
164
  };
89
- var icon = svg || React.createElement(logos[brand]);
90
- return (React.createElement("a", { className: index.classNames("arc-NavigationHeaderLogo", suffixModifier.suffixModifier("arc-NavigationHeaderLogo--on", surface)), "aria-label": ariaLabel, onClick: onClick, href: href }, icon));
91
- };
92
-
93
- // src/check-element-visibility/check-element-visibility.ts
94
- var checkElementVisibility = (element) => {
95
- if (element.checkVisibility) {
96
- return element.checkVisibility();
97
- } else {
98
- const el = element;
99
- return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
100
- }
101
- };
165
+ var icon = svg || React.createElement(logos[brand]);
166
+ return (React.createElement(SemanticLink.SemanticLink, { className: index$2.classNames("arc-NavigationHeaderLogo", suffixModifier.suffixModifier("arc-NavigationHeaderLogo--on", surface)), "aria-label": ariaLabel, onClick: onClick, href: href }, icon));
167
+ };
168
+
169
+ var DELAY_DURATION = 500;
170
+
171
+ var NavigationHeaderButton = function (_a) {
172
+ var ref = _a.ref, isActive = _a.isActive, children = _a.children, onClick = _a.onClick, href = _a.href, _b = _a.isPadded, isPadded = _b === void 0 ? true : _b, props = tslib_es6.__rest(_a, ["ref", "isActive", "children", "onClick", "href", "isPadded"]);
173
+ var surface = React.useContext(Surface.Context).surface;
174
+ var classes = index$2.classNames("arc-NavigationHeaderButton", suffixModifier.suffixModifier("arc-NavigationHeaderButton--on", surface), {
175
+ "arc-NavigationHeaderButton--active": isActive,
176
+ "arc-NavigationHeaderButton--padded": isPadded,
177
+ });
178
+ var commonProps = {
179
+ className: classes,
180
+ onClick: onClick,
181
+ };
182
+ if (href) {
183
+ return (React.createElement(SemanticLink.SemanticLink, tslib_es6.__assign({}, props, commonProps, { ref: ref, href: href }), children));
184
+ }
185
+ return (React.createElement(SemanticButton.SemanticButton, tslib_es6.__assign({}, props, commonProps, { ref: ref }), children));
186
+ };
187
+
188
+ var getMenuColorConfig = function (background, pathway) {
189
+ var colorConfig = {
190
+ light: {
191
+ surface: "light-white",
192
+ menuColorType: "light",
193
+ },
194
+ dark: {
195
+ surface: "dark-black",
196
+ menuColorType: "dark",
197
+ },
198
+ };
199
+ switch (background) {
200
+ case "transparentOnDark":
201
+ case "ghostedOnDark":
202
+ return pathway === "invert" ? colorConfig.light : colorConfig.dark;
203
+ default:
204
+ return pathway === "invert" ? colorConfig.dark : colorConfig.light;
205
+ }
206
+ };
207
+
208
+ // src/check-element-visibility/check-element-visibility.ts
209
+ var checkElementVisibility = (element) => {
210
+ if (element.checkVisibility) {
211
+ return element.checkVisibility();
212
+ } else {
213
+ const el = element;
214
+ return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
215
+ }
216
+ };
217
+
218
+ var useTriggerHidden = function (_a) {
219
+ var onTriggerHidden = _a.onTriggerHidden, triggerEl = _a.triggerEl;
220
+ React.useEffect(function () {
221
+ var resizeObserver = new ResizeObserver(function (entries) {
222
+ var entry = entries[0];
223
+ if (!checkElementVisibility(entry.target)) {
224
+ onTriggerHidden();
225
+ }
226
+ });
227
+ if (triggerEl) {
228
+ resizeObserver.observe(triggerEl);
229
+ }
230
+ return function () {
231
+ if (triggerEl) {
232
+ resizeObserver.unobserve(triggerEl);
233
+ }
234
+ };
235
+ }, [onTriggerHidden, triggerEl]);
236
+ };
237
+
238
+ var SideMenuHeader = function (_a) {
239
+ var children = _a.children, onCloseClick = _a.onCloseClick;
240
+ var surface = React.useContext(Surface.Context).surface;
241
+ return (React.createElement("div", { className: "arc-SideMenuHeader" },
242
+ React.createElement("div", { className: "arc-SideMenuHeader-closeButtonContainer" },
243
+ React.createElement(SemanticButton.SemanticButton, { "aria-label": "close", onClick: onCloseClick, className: index$2.classNames("arc-SideMenuHeader-closeButton", suffixModifier.suffixModifier("arc-SideMenuHeader-closeButton--on", surface)) },
244
+ React.createElement(ThemeIcon.ThemeIcon, { size: 32, icon: "navigationHeaderClose" }))),
245
+ React.createElement("div", { className: "arc-SideMenuHeader-logoContainer" },
246
+ React.createElement("div", { className: "arc-SideMenuHeader-logoWrapper" }, children))));
247
+ };
248
+
249
+ var SideMenuDrawer = function (_a) {
250
+ var children = _a.children, onCloseAutoFocus = _a.onCloseAutoFocus, onInteractOutside = _a.onInteractOutside, onEscapeKeyDown = _a.onEscapeKeyDown, title = _a.title, drawerType = _a.drawerType, isOpen = _a.isOpen, colorType = _a.colorType, surface = _a.surface, menuPosition = _a.menuPosition;
251
+ var _b = index$3.useThemeElement(), themeElement = _b[0], setThemeElement = _b[1];
252
+ return (React.createElement("div", { ref: setThemeElement },
253
+ React.createElement(index$4.Root, { open: isOpen },
254
+ React.createElement(index$4.Portal, { container: themeElement },
255
+ React.createElement(index$4.Overlay, { className: "arc-SideMenuDrawer-overlay" },
256
+ React.createElement(index$4.Content, { "aria-describedby": undefined, className: index$2.classNames("arc-SideMenuDrawer-slider", suffixModifier.suffixModifier("arc-SideMenuDrawer-slider--position", menuPosition), suffixModifier.suffixModifier("arc-SideMenuDrawer-slider--on", colorType), suffixModifier.suffixModifier("arc-SideMenuDrawer-slider--type", drawerType)), onCloseAutoFocus: onCloseAutoFocus, onEscapeKeyDown: onEscapeKeyDown, onInteractOutside: onInteractOutside, "aria-modal": "true" },
257
+ React.createElement(VisuallyHidden.VisuallyHidden, null,
258
+ React.createElement(index$4.Title, null, title)),
259
+ React.createElement(Surface.Surface, { growVertically: true, isTransparent: true, background: surface }, children)))))));
260
+ };
261
+
262
+ var SideMenuNavSection = function (_a) {
263
+ var children = _a.children;
264
+ return (React.createElement("div", { className: "arc-SideMenuNavSection" }, children));
265
+ };
266
+
267
+ var getCommonProps = function (_a) {
268
+ var text = _a.text, onClick = _a.onClick;
269
+ return ({
270
+ className: "arc-SideMenuActions-item",
271
+ "aria-label": text,
272
+ onClick: onClick,
273
+ });
274
+ };
275
+ var SideMenuActions = function (_a) {
276
+ var showSeparator = _a.showSeparator, actions = _a.actions;
277
+ var id = React.useId();
278
+ var surface = React.useContext(Surface.Context).surface;
279
+ return (React.createElement("div", { className: index$2.classNames("arc-SideMenuActions", suffixModifier.suffixModifier("arc-SideMenuActions--on", surface)) },
280
+ React.createElement("div", { className: index$2.classNames("arc-SideMenuActions-wrapper", {
281
+ "arc-SideMenuActions--seperator": showSeparator,
282
+ }) }, actions.map(function (action, i) { return (React.createElement(ConditionalWrapper.ConditionalWrapper, { key: "".concat(id, "-action-{").concat(i, "}"), condition: Boolean(action.href), wrapper: function (children) { return (React.createElement(SemanticLink.SemanticLink, tslib_es6.__assign({}, getCommonProps(action), { href: action.href }), children)); }, fallback: function (children) { return (React.createElement(SemanticButton.SemanticButton, tslib_es6.__assign({}, getCommonProps(action)), children)); } },
283
+ React.createElement("div", { className: "arc-SideMenuActions-content" },
284
+ React.createElement("div", { className: index$2.classNames("arc-SideMenuActions-icon", {
285
+ "arc-SideMenuActions-icon--attention": action.isAttention,
286
+ }) },
287
+ React.createElement(Icon.Icon, { "aria-hidden": true, icon: action.icon, size: 28 })),
288
+ React.createElement(Text.Text, { size: "l" }, action.text)))); }))));
289
+ };
290
+
291
+ var SideMenuLink = function (_a) {
292
+ var ref = _a.ref, href = _a.href, onClick = _a.onClick, text = _a.text, props = tslib_es6.__rest(_a, ["ref", "href", "onClick", "text"]);
293
+ var surface = React.useContext(Surface.Context).surface;
294
+ var commonProps = tslib_es6.__assign({ "aria-label": text, onClick: onClick, className: index$2.classNames("arc-SideMenuLink", suffixModifier.suffixModifier("arc-SideMenuLink--on", surface)) }, filterAttrs.filterAttrs(props));
295
+ return (React.createElement(ConditionalWrapper.ConditionalWrapper, { condition: Boolean(href), wrapper: function (children) { return (React.createElement(SemanticLink.SemanticLink, tslib_es6.__assign({}, commonProps, { href: href, ref: ref }), children)); }, fallback: function (children) { return (React.createElement(SemanticButton.SemanticButton, tslib_es6.__assign({}, commonProps, { ref: ref }), children)); } },
296
+ React.createElement("div", { className: "arc-SideMenuLink-text" }, text),
297
+ React.createElement("span", { className: "arc-SideMenuLink-icon" },
298
+ React.createElement(ThemeIcon.ThemeIcon, { icon: "navigationHeaderMenuLinkLarge" }))));
299
+ };
300
+
301
+ // src/get-focusable-elements/get-focusable-elements.ts
302
+ var getFocusableElements = (rootElement) => {
303
+ const nodes = [];
304
+ const walker = document.createTreeWalker(
305
+ rootElement,
306
+ NodeFilter.SHOW_ELEMENT,
307
+ {
308
+ acceptNode: (node) => {
309
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
310
+ if (node.disabled || node.hidden || isHiddenInput || !checkElementVisibility(node))
311
+ return NodeFilter.FILTER_SKIP;
312
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
313
+ }
314
+ }
315
+ );
316
+ while (walker.nextNode()) nodes.push(walker.currentNode);
317
+ return nodes;
318
+ };
319
+
320
+ var SideMenuDisclosure = function (_a) {
321
+ var heading = _a.heading, children = _a.children;
322
+ var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
323
+ var surface = React.useContext(Surface.Context).surface;
324
+ var containerRef = React.useRef(null);
325
+ var handleOnClick = function (e) {
326
+ e.preventDefault();
327
+ setIsOpen(function (isOpen) { return !isOpen; });
328
+ };
329
+ React.useEffect(function () {
330
+ var _a;
331
+ if (containerRef.current && containerRef.current.firstChild && isOpen) {
332
+ (_a = getFocusableElements(containerRef.current)[0]) === null || _a === void 0 ? void 0 : _a.focus();
333
+ }
334
+ }, [isOpen]);
335
+ return (React.createElement("details", { className: index$2.classNames("arc-SideMenuDisclosure", suffixModifier.suffixModifier("arc-SideMenuDisclosure--on", surface)), open: isOpen },
336
+ React.createElement("summary", { "aria-expanded": isOpen, onClick: handleOnClick, className: "arc-SideMenuDisclosure-summary" },
337
+ React.createElement("span", { className: "arc-SideMenuDisclosure-heading" }, heading),
338
+ React.createElement("span", { className: "arc-SideMenuDisclosure-icon" },
339
+ React.createElement(ThemeIcon.ThemeIcon, { size: 20, icon: "navigationHeaderDisclosure" }))),
340
+ React.createElement("div", { ref: containerRef, className: "arc-SideMenuDisclosure-content" }, children)));
341
+ };
342
+
343
+ var createNavigationHeaderContext = function (errorMessage) {
344
+ var componentContext = React.createContext(null);
345
+ var useComponentContext = function () {
346
+ var context = React.useContext(componentContext);
347
+ if (!context) {
348
+ throw new Error(errorMessage);
349
+ }
350
+ return context;
351
+ };
352
+ return [componentContext, useComponentContext];
353
+ };
354
+
355
+ var _a$2 = createNavigationHeaderContext("NavigationHeaderSideMenu sub components must be used within NavigationHeaderSideMenu"), NavigationHeaderSideMenuContext = _a$2[0], useNavigationHeaderSideMenuContext = _a$2[1];
356
+
357
+ var SideMenuSubMenu = function (_a) {
358
+ var children = _a.children, heading = _a.heading, isOpen = _a.isOpen, onBackClick = _a.onBackClick, onCloseAutoFocus = _a.onCloseAutoFocus, supportingText = _a.supportingText, _b = _a.headingSize, headingSize = _b === void 0 ? "l" : _b, _c = _a.backButtonLabel, backButtonLabel = _c === void 0 ? "Back" : _c, _d = _a.backButtonAriaLabel, backButtonAriaLabel = _d === void 0 ? "Back to main menu" : _d;
359
+ var _e = useNavigationHeaderSideMenuContext(), menuColorConfig = _e.menuColorConfig, menuPosition = _e.menuPosition, onEscapeKeyDown = _e.onEscapeKeyDown, closeMenu = _e.closeMenu;
360
+ return (React.createElement(React.Fragment, null,
361
+ React.createElement(SideMenuDrawer, { drawerType: "sub", title: "Secondary menu", isOpen: isOpen, onCloseAutoFocus: onCloseAutoFocus, colorType: menuColorConfig.menuColorType, surface: menuColorConfig.surface, menuPosition: menuPosition, onEscapeKeyDown: onEscapeKeyDown, onInteractOutside: closeMenu },
362
+ React.createElement(SideMenuHeader, { onCloseClick: closeMenu },
363
+ React.createElement(SemanticButton.SemanticButton, { className: index$2.classNames("arc-SideMenuSubMenu-backButton", suffixModifier.suffixModifier("arc-SideMenuSubMenu-backButton--on", menuColorConfig.menuColorType)), "aria-label": backButtonAriaLabel, onClick: onBackClick },
364
+ React.createElement("div", { className: "arc-SideMenuSubMenu-backButtonIcon" },
365
+ React.createElement(ThemeIcon.ThemeIcon, { icon: "navigationHeaderSideMenuBack", size: 32 })),
366
+ React.createElement("div", { className: "arc-SideMenuSubMenu-backButtonText" }, backButtonLabel))),
367
+ React.createElement(SideMenuNavSection, null,
368
+ React.createElement("div", { className: "arc-SideMenuSubMenu-heading" },
369
+ React.createElement(Heading.Heading, { size: headingSize }, heading),
370
+ supportingText && (React.createElement(React.Fragment, null,
371
+ React.createElement(VerticalSpace.VerticalSpace, { size: "4" }),
372
+ React.createElement(Text.Text, { tone: "muted", size: "s" }, supportingText)))),
373
+ children))));
374
+ };
375
+
376
+ var ArrowRightIcon = function () { return (React.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
377
+ React.createElement("path", { d: "M14.0306 8.52927L9.53063 13.0293C9.38973 13.1702 9.19863 13.2493 8.99938 13.2493C8.80012 13.2493 8.60902 13.1702 8.46813 13.0293C8.32723 12.8884 8.24807 12.6973 8.24807 12.498C8.24807 12.2988 8.32723 12.1077 8.46813 11.9668L11.6875 8.74864H2.5C2.30109 8.74864 2.11032 8.66963 1.96967 8.52897C1.82902 8.38832 1.75 8.19756 1.75 7.99864C1.75 7.79973 1.82902 7.60897 1.96967 7.46831C2.11032 7.32766 2.30109 7.24864 2.5 7.24864H11.6875L8.46937 4.02864C8.32848 3.88775 8.24932 3.69665 8.24932 3.49739C8.24932 3.29814 8.32848 3.10704 8.46937 2.96614C8.61027 2.82525 8.80137 2.74609 9.00062 2.74609C9.19988 2.74609 9.39098 2.82525 9.53187 2.96614L14.0319 7.46614C14.1018 7.53592 14.1573 7.61881 14.1951 7.71008C14.2329 7.80135 14.2523 7.89918 14.2522 7.99797C14.252 8.09675 14.2324 8.19454 14.1944 8.28572C14.1564 8.37689 14.1007 8.45966 14.0306 8.52927Z", fill: "currentColor" }))); };
378
+
379
+ var NavigationHeaderCta = function (_a) {
380
+ var href = _a.href, onClick = _a.onClick, text = _a.text, _b = _a.revealLinkIconOnHover, revealLinkIconOnHover = _b === void 0 ? false : _b;
381
+ var surface = React.useContext(Surface.Context).surface;
382
+ return (React.createElement(SemanticLink.SemanticLink, { className: index$2.classNames("arc-NavigationHeaderCta", suffixModifier.suffixModifier("arc-NavigationHeaderCta--on", surface)), onClick: onClick, href: href },
383
+ React.createElement("div", { className: "arc-NavigationHeaderCta-heading" },
384
+ React.createElement(Heading.Heading, { size: "xxs" }, text)),
385
+ React.createElement("div", { className: index$2.classNames("arc-NavigationHeaderCta-linkIcon", {
386
+ "arc-NavigationHeaderCta-linkIcon--revealLinkIconOnHover": revealLinkIconOnHover,
387
+ }) },
388
+ React.createElement(ArrowRightIcon, null))));
389
+ };
390
+
391
+ var NavigationHeaderCollapsingNavList = function (_a) {
392
+ var mainLink = _a.mainLink, description = _a.description, category = _a.category, links = _a.links, revealLinkIconOnHover = _a.revealLinkIconOnHover, _b = _a.autoFocusOnExpand, autoFocusOnExpand = _b === void 0 ? true : _b, _c = _a.background, background = _c === void 0 ? "dark" : _c, _d = _a.defaultOpen, defaultOpen = _d === void 0 ? false : _d;
393
+ var id = React.useId();
394
+ var surface = React.useContext(Surface.Context).surface;
395
+ var _e = React.useState(defaultOpen), isOpen = _e[0], setIsOpen = _e[1];
396
+ var containerRef = React.useRef(null);
397
+ var onClick = function (e) {
398
+ setIsOpen(e.currentTarget.open);
399
+ };
400
+ React.useEffect(function () {
401
+ if (containerRef.current &&
402
+ containerRef.current.firstChild &&
403
+ autoFocusOnExpand &&
404
+ isOpen) {
405
+ getFocusableElements(containerRef.current)[0].focus();
406
+ }
407
+ }, [isOpen, autoFocusOnExpand]);
408
+ return (React.createElement("details", { className: index$2.classNames("arc-NavigationHeaderCollapsingNavList-disclosure", suffixModifier.suffixModifier("arc-NavigationHeaderCollapsingNavList-disclosure--on", surface), {
409
+ "arc-NavigationHeaderCollapsingNavList-disclosure--open": isOpen,
410
+ }), open: isOpen, onToggle: onClick },
411
+ React.createElement("summary", { className: index$2.classNames("arc-NavigationHeaderCollapsingNavList-disclosureSummary", suffixModifier.suffixModifier("arc-NavigationHeaderCollapsingNavList-disclosureSummary--background", background)), "aria-expanded": isOpen },
412
+ React.createElement("div", { className: "arc-NavigationHeaderCollapsingNavList-disclosureSummaryHeading" },
413
+ React.createElement(Heading.Heading, { level: "2" }, category)),
414
+ React.createElement("span", { className: "arc-NavigationHeaderCollapsingNavList-disclosureSummaryIcon" },
415
+ React.createElement(ThemeIcon.ThemeIcon, { size: 16, icon: "disclosureExpand" }))),
416
+ React.createElement("div", { className: "arc-NavigationHeaderCollapsingNavList-content" },
417
+ React.createElement(VerticalSpace.VerticalSpace, { size: "8" }),
418
+ description && (React.createElement("div", { className: "arc-NavigationHeaderCollapsingNavList-description" },
419
+ React.createElement(Text.Text, { size: "s", tone: "muted" }, description))),
420
+ React.createElement("div", { ref: containerRef },
421
+ mainLink && (React.createElement(React.Fragment, null,
422
+ React.createElement(VerticalSpace.VerticalSpace, { size: "16" }),
423
+ React.createElement(NavigationHeaderCta, tslib_es6.__assign({}, mainLink, { revealLinkIconOnHover: revealLinkIconOnHover })),
424
+ React.createElement(VerticalSpace.VerticalSpace, { size: "8" }),
425
+ React.createElement(Rule.Rule, null))),
426
+ links && (React.createElement(React.Fragment, null,
427
+ React.createElement(VerticalSpace.VerticalSpace, { size: "8" }),
428
+ React.createElement("ul", { className: "arc-NavigationHeaderCollapsingNavList-list" }, links.map(function (link, i) { return (React.createElement("li", { key: "".concat(id, "-NavigationHeader-megamenu-link-").concat(i) },
429
+ React.createElement(NavigationHeaderCta, tslib_es6.__assign({}, link, { revealLinkIconOnHover: revealLinkIconOnHover })))); })))),
430
+ React.createElement(VerticalSpace.VerticalSpace, { size: "24" })))));
431
+ };
432
+
433
+ var SideMenuCategoryLinksItem = function (_a) {
434
+ var items = _a.items, text = _a.text, backButtonLabel = _a.backButtonLabel, backButtonAriaLabel = _a.backButtonAriaLabel, panelHeading = _a.panelHeading;
435
+ var id = React.useId();
436
+ var _b = React.useState(false), isDrawerOpen = _b[0], setIsDrawerOpen = _b[1];
437
+ var triggerRef = React.useRef(null);
438
+ var onItemClick = function () {
439
+ setIsDrawerOpen(true);
440
+ };
441
+ var onBackClick = function () {
442
+ setIsDrawerOpen(false);
443
+ };
444
+ var onCloseAutoFocus = function () {
445
+ var _a;
446
+ (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
447
+ };
448
+ return (React.createElement(React.Fragment, null,
449
+ React.createElement(SideMenuLink, { "aria-haspopup": "dialog", "aria-expanded": isDrawerOpen, ref: triggerRef, onClick: onItemClick, text: text }),
450
+ React.createElement(SideMenuSubMenu, { isOpen: isDrawerOpen, heading: panelHeading.heading, supportingText: panelHeading.supportingText, onBackClick: onBackClick, onCloseAutoFocus: onCloseAutoFocus, backButtonLabel: backButtonLabel, backButtonAriaLabel: backButtonAriaLabel },
451
+ React.createElement("div", { className: "arc-SideMenuCategoryLinksItem-navItems" }, items.map(function (navItem, navItemIndex) { return (React.createElement(NavigationHeaderCollapsingNavList, tslib_es6.__assign({}, navItem, { key: "".concat(id, "-side-menu-category-link-item-").concat(navItemIndex) }))); })))));
452
+ };
453
+
454
+ var NavigationHeaderFeatureCard = function (_a) {
455
+ var title = _a.title, description = _a.description, href = _a.href, onClick = _a.onClick, img = _a.img, label = _a.label, isFeatured = _a.isFeatured, props = tslib_es6.__rest(_a, ["title", "description", "href", "onClick", "img", "label", "isFeatured"]);
456
+ return (React.createElement("div", tslib_es6.__assign({ className: index$2.classNames("arc-NavigationHeaderFeatureCard", {
457
+ "arc-NavigationHeaderFeatureCard--featured": isFeatured,
458
+ }) }, filterAttrs.filterAttrs(props)),
459
+ img && (React.createElement("div", { className: "arc-NavigationHeaderFeatureCard-imgContainer" },
460
+ React.createElement("img", { alt: "", src: img, className: "arc-NavigationHeaderFeatureCard-img" }))),
461
+ React.createElement("div", { className: "arc-NavigationHeaderFeatureCard-content" },
462
+ React.createElement("div", { className: "arc-NavigationHeaderFeatureCard-header" },
463
+ label && (React.createElement("div", { className: "arc-NavigationHeaderFeatureCard-label" },
464
+ React.createElement(Heading.Heading, { size: "xxxs" }, label))),
465
+ React.createElement(Heading.Heading, { level: "4", size: "s" },
466
+ React.createElement(SemanticLink.SemanticLink, { className: "arc-NavigationHeaderFeatureCard-link", href: href, onClick: onClick }, title)),
467
+ React.createElement(VerticalSpace.VerticalSpace, { size: "16" })),
468
+ React.createElement("div", { className: "arc-NavigationHeaderFeatureCard-body" }, description && (React.createElement(React.Fragment, null,
469
+ React.createElement(Text.Text, { size: "s" }, description),
470
+ React.createElement(VerticalSpace.VerticalSpace, { size: "16" })))),
471
+ React.createElement("div", { className: "arc-NavigationHeaderFeatureCard-footer" },
472
+ React.createElement("span", { className: "arc-NavigationHeaderFeatureCard-cta" },
473
+ React.createElement(ArrowRightIcon, null))))));
474
+ };
475
+
476
+ var NavigationHeaderPanelLink = function (_a) {
477
+ var icon = _a.icon, href = _a.href, onClick = _a.onClick, heading = _a.heading, description = _a.description;
478
+ var surface = React.useContext(Surface.Context).surface;
479
+ return (React.createElement("div", { className: index$2.classNames("arc-NavigationHeaderPanelLink", suffixModifier.suffixModifier("arc-NavigationHeaderPanelLink--on", surface)) },
480
+ React.createElement("div", { className: "arc-NavigationHeaderPanelLink-icon" },
481
+ React.createElement(Icon.Icon, { color: "brand", icon: icon, size: 88 })),
482
+ React.createElement("div", { className: "arc-NavigationHeaderPanelLink-textCol" },
483
+ React.createElement("div", { className: "arc-NavigationHeaderPanelLink-heading" },
484
+ React.createElement(Heading.Heading, { size: "s" },
485
+ React.createElement(SemanticLink.SemanticLink, { className: "arc-NavigationHeaderPanelLink-link", href: href, onClick: onClick }, heading))),
486
+ React.createElement(VerticalSpace.VerticalSpace, { size: "12" }),
487
+ React.createElement("div", { className: "arc-NavigationHeaderPanelLink-description" },
488
+ React.createElement(Text.Text, { size: "s" }, description))),
489
+ React.createElement("div", { className: "arc-NavigationHeaderPanelLink-ctaCol" },
490
+ React.createElement("span", { className: "arc-NavigationHeaderPanelLink-cta" },
491
+ React.createElement(ArrowRightIcon, null)))));
492
+ };
493
+
494
+ var MegaMenuSubMenu = function (_a) {
495
+ var item = _a.item, heading = _a.heading, backButtonLabel = _a.backButtonLabel, backButtonAriaLabel = _a.backButtonAriaLabel;
496
+ var id = React.useId();
497
+ var triggerRef = React.useRef(null);
498
+ var _b = React.useState(false), isDrawerOpen = _b[0], setIsDrawerOpen = _b[1];
499
+ var menuColorConfig = useNavigationHeaderSideMenuContext().menuColorConfig;
500
+ var onItemClick = function () {
501
+ setIsDrawerOpen(true);
502
+ };
503
+ var onBackClick = function () {
504
+ setIsDrawerOpen(false);
505
+ };
506
+ var onCloseAutoFocus = function () {
507
+ var _a;
508
+ (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
509
+ };
510
+ return (React.createElement(React.Fragment, null,
511
+ React.createElement(SemanticButton.SemanticButton, { "aria-haspopup": "dialog", "aria-expanded": isDrawerOpen, ref: triggerRef, "aria-label": item.triggerText, className: index$2.classNames("arc-SideMenuMegaMenuItem-button", suffixModifier.suffixModifier("arc-SideMenuMegaMenuItem-button--on", menuColorConfig.menuColorType)), onClick: onItemClick },
512
+ React.createElement("div", { className: "arc-SideMenuMegaMenuItem-buttonIcon" },
513
+ React.createElement(Icon.Icon, { icon: item.icon, size: 32 })),
514
+ React.createElement("div", { className: "arc-SideMenuMegaMenuItem-buttonText" },
515
+ React.createElement(Heading.Heading, { size: "xxs" }, item.triggerText))),
516
+ React.createElement(SideMenuSubMenu, { isOpen: isDrawerOpen, heading: heading, headingSize: "s", onBackClick: onBackClick, onCloseAutoFocus: onCloseAutoFocus, backButtonLabel: backButtonLabel, backButtonAriaLabel: backButtonAriaLabel },
517
+ React.createElement(NavigationHeaderPanelLink, tslib_es6.__assign({}, item.panelLink, { icon: item.icon })),
518
+ React.createElement(VerticalSpace.VerticalSpace, { size: "16" }),
519
+ React.createElement("div", { className: "arc-SideMenuMegaMenuItem-navItems" }, item.items.map(function (navItem, navItemIndex) { return (React.createElement(NavigationHeaderCollapsingNavList, tslib_es6.__assign({}, navItem, { key: "".concat(id, "-side-mega-menu-drawer-navItem-").concat(navItemIndex) }))); })))));
520
+ };
521
+ var SideMenuMegaMenuItem = function (_a) {
522
+ var featureCards = _a.featureCards, text = _a.text, panelHeading = _a.panelHeading, tabs = _a.tabs, backButtonLabel = _a.backButtonLabel, backButtonAriaLabel = _a.backButtonAriaLabel;
523
+ var id = React.useId();
524
+ return (React.createElement(SideMenuDisclosure, { heading: text },
525
+ tabs.map(function (item, itemIndex) { return (React.createElement(MegaMenuSubMenu, { key: "".concat(id, "-side-menu-mega-menu-item-").concat(itemIndex), item: item, heading: panelHeading.heading, backButtonLabel: backButtonLabel, backButtonAriaLabel: backButtonAriaLabel })); }),
526
+ featureCards && (React.createElement(Surface.Surface, { isTransparent: true, background: "light-white" },
527
+ React.createElement("div", { className: "arc-SideMenuMegaMenuItem-featureCards" },
528
+ React.createElement("div", { className: "arc-SideMenuMegaMenuItem-featureCardContainer" }, featureCards.map(function (card, cardIndex) { return (React.createElement(NavigationHeaderFeatureCard, { title: card.title, href: card.href, isFeatured: card.isFeatured, label: card.label, onClick: card.onClick, key: "".concat(id, "-side-menu-mega-menu-card-").concat(cardIndex) })); })))))));
529
+ };
530
+
531
+ var SideMenuNavItem = function (_a) {
532
+ var navItem = _a.navItem;
533
+ var id = React.useId();
534
+ return (React.createElement(React.Fragment, null,
535
+ navItem.type === "link" && (React.createElement(SideMenuLink, { href: navItem.href, onClick: navItem.onClick, text: navItem.text })),
536
+ navItem.type === "levelTwo" && (React.createElement(SideMenuDisclosure, { heading: navItem.text }, navItem.items.map(function (link, linkIndex) { return (React.createElement(NavigationHeaderCta, { key: "".concat(id, "-side-menu-level-two-link-item-").concat(linkIndex), href: link.href, onClick: link.onClick, text: link.text })); }))),
537
+ navItem.type === "categoryLinks" && (React.createElement(SideMenuCategoryLinksItem, tslib_es6.__assign({}, navItem))),
538
+ navItem.type === "megamenu" && React.createElement(SideMenuMegaMenuItem, tslib_es6.__assign({}, navItem))));
539
+ };
540
+
541
+ var SideMenuNavList = function (_a) {
542
+ var children = _a.children;
543
+ return (React.createElement("nav", null,
544
+ React.createElement("ul", { className: "arc-SideMenuNavList" }, children)));
545
+ };
546
+
547
+ var NavigationHeaderSideMenu = function (_a) {
548
+ var navItems = _a.navItems, children = _a.children, actions = _a.actions, header = _a.header, footer = _a.footer, logo = _a.logo, background = _a.background, onOpenChange = _a.onOpenChange, trigger = _a.trigger, menuPosition = _a.menuPosition, _b = _a.showLogo, showLogo = _b === void 0 ? true : _b, _c = _a.tooltip, tooltip = _c === void 0 ? "Menu" : _c, _d = _a.pathway, pathway = _d === void 0 ? "invert" : _d, _e = _a.triggerAriaLabel, triggerAriaLabel = _e === void 0 ? "Open menu" : _e;
549
+ var id = React.useId();
550
+ var _f = React.useState(false), isMenuOpen = _f[0], setIsMenuOpen = _f[1];
551
+ var triggerRef = React.useRef(null);
552
+ var mainContentRef = React.useRef(null);
553
+ var _g = React.useState("pointer"), interactionMode = _g[0], setInterActionMode = _g[1];
554
+ React.useEffect(function () {
555
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(isMenuOpen);
556
+ }, [isMenuOpen, onOpenChange]);
557
+ useTriggerHidden({
558
+ triggerEl: triggerRef.current,
559
+ onTriggerHidden: function () {
560
+ closeMenu();
561
+ },
562
+ });
563
+ var closeMenu = React.useCallback(function () {
564
+ setIsMenuOpen(false);
565
+ }, [setIsMenuOpen]);
566
+ var onEscapeKeyDown = React.useCallback(function () {
567
+ setInterActionMode("keyboard");
568
+ closeMenu();
569
+ }, [closeMenu]);
570
+ var onSideMenuMouseDown = function () {
571
+ setInterActionMode("pointer");
572
+ };
573
+ var onSideMenuKeyDown = function () {
574
+ setInterActionMode("keyboard");
575
+ };
576
+ var focusTriggerElement = function () {
577
+ var _a;
578
+ interactionMode === "keyboard" && ((_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus());
579
+ };
580
+ var menuColorConfig = getMenuColorConfig(background, pathway);
581
+ var contextValue = React.useMemo(function () { return ({ menuPosition: menuPosition, menuColorConfig: menuColorConfig, onEscapeKeyDown: onEscapeKeyDown, closeMenu: closeMenu }); }, [menuPosition, menuColorConfig, onEscapeKeyDown, closeMenu]);
582
+ return (React.createElement(NavigationHeaderSideMenuContext.Provider, { value: contextValue },
583
+ React.createElement("div", { className: "arc-NavigationHeaderSideMenu", onMouseDown: onSideMenuMouseDown, onKeyDown: onSideMenuKeyDown },
584
+ React.createElement(Tooltip.Tooltip, { delayDuration: DELAY_DURATION, asChild: true, title: tooltip, side: "bottom" },
585
+ React.createElement(NavigationHeaderButton, { ref: triggerRef, isPadded: Boolean(trigger) || false, "aria-expanded": isMenuOpen, "aria-label": isMenuOpen ? "close menu" : triggerAriaLabel, onClick: function () { return setIsMenuOpen(!isMenuOpen); } },
586
+ trigger || (React.createElement("div", { className: "arc-NavigationHeaderSideMenu-trigger" }, React.createElement(ThemeIcon.ThemeIcon, { icon: "siteHeaderBurger", size: 24 }))),
587
+ React.createElement(VisuallyHidden.VisuallyHidden, null, isMenuOpen ? "close menu" : "open menu"))),
588
+ React.createElement(SideMenuDrawer, { drawerType: "main", title: "Navigation menu", menuPosition: menuPosition, isOpen: isMenuOpen, colorType: menuColorConfig.menuColorType, surface: menuColorConfig.surface, onCloseAutoFocus: focusTriggerElement, onEscapeKeyDown: onEscapeKeyDown, onInteractOutside: closeMenu },
589
+ React.createElement("div", { className: "arc-NavigationHeaderSideMenu-container" },
590
+ React.createElement("div", { className: "arc-NavigationHeaderSideMenu-mainContent" },
591
+ showLogo && (React.createElement(SideMenuHeader, { onCloseClick: closeMenu },
592
+ React.createElement(NavigationHeaderLogo, tslib_es6.__assign({}, logo)))),
593
+ React.createElement("div", { ref: mainContentRef },
594
+ header && (React.createElement("div", { className: index$2.classNames("arc-NavigationHeaderSideMenu-topContent", {
595
+ "arc-NavigationHeaderSideMenu-topContent--bottomSpacing": !navItems,
596
+ }) }, header)),
597
+ navItems && !children && (React.createElement(SideMenuNavSection, null,
598
+ React.createElement(SideMenuNavList, null, navItems === null || navItems === void 0 ? void 0 : navItems.map(function (navItem, navItemIndex) { return (React.createElement(React.Fragment, { key: "".concat(id, "-side-nav-item-").concat(navItemIndex) },
599
+ React.createElement("li", { className: index$2.classNames({
600
+ "arc-NavigationHeaderSideMenu--separator": navItem.isSeparator,
601
+ }, suffixModifier.suffixModifier("arc-NavigationHeaderSideMenu--separatorOn", menuColorConfig.menuColorType)) },
602
+ React.createElement(SideMenuNavItem, { navItem: navItem })))); })))),
603
+ children && (React.createElement(SideMenuNavSection, null, children)),
604
+ actions && (React.createElement(SideMenuActions, { showSeparator: Boolean(navItems || header), actions: actions })))),
605
+ footer && (React.createElement("div", { className: "arc-NavigationHeaderSideMenu-footer" }, footer)))))));
606
+ };
607
+
608
+ var NavigationHeaderNavLink = function (_a) {
609
+ var ref = _a.ref, text = _a.text, onClick = _a.onClick, href = _a.href, borderRadiusSize = _a.borderRadiusSize;
610
+ var surface = React.useContext(Surface.Context).surface;
611
+ return (React.createElement(SemanticLink.SemanticLink, { ref: ref, href: href, onClick: onClick, className: index$2.classNames("arc-NavigationHeaderNavLink", suffixModifier.suffixModifier("arc-NavigationHeaderNavLink--borderRadiusSize", borderRadiusSize), suffixModifier.suffixModifier("arc-NavigationHeaderNavLink--on", surface)) },
612
+ React.createElement(Text.Text, null, text)));
613
+ };
614
+
615
+ var NavigationHeaderDropdown = function (_a) {
616
+ var children = _a.children, trigger = _a.trigger, ariaLabel = _a.ariaLabel, tooltip = _a.tooltip, onClick = _a.onClick;
617
+ var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
618
+ var triggerRef = React.useRef(null);
619
+ var containerRef = React.useRef(null);
620
+ var interactionMode = useInteractionMode().interactionMode;
621
+ useTriggerHidden({
622
+ triggerEl: triggerRef.current,
623
+ onTriggerHidden: function () {
624
+ setIsOpen(false);
625
+ },
626
+ });
627
+ // if focus isnt going anywhere else and closed via keyboard, return focus to the trigger
628
+ var onCloseAutoFocus = function () {
629
+ var _a, _b;
630
+ if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName) === "BODY" &&
631
+ interactionMode === "keyboard") {
632
+ (_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.focus();
633
+ }
634
+ };
635
+ // Only count it as an outside interaction if the trigger isnt being clicked.
636
+ var handleOutSideInteraction = function (event) {
637
+ var _a;
638
+ if (!((_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.currentTarget))) {
639
+ setIsOpen(false);
640
+ }
641
+ };
642
+ // Find the first focusable element.
643
+ var focusOnFirstElement = function () {
644
+ var _a;
645
+ (_a = getFocusableElements(containerRef.current)[0]) === null || _a === void 0 ? void 0 : _a.focus({
646
+ preventScroll: true,
647
+ });
648
+ };
649
+ var toggleVisibility = function (e) {
650
+ onClick && onClick(e);
651
+ setIsOpen(function (isOpen) { return !isOpen; });
652
+ };
653
+ return (React.createElement(React.Fragment, null,
654
+ React.createElement(Popover.Popover, { useBespokeTrigger: true, constrainToViewport: false, align: "center", background: "light", arrow: true, sideOffset: 12, alignOffset: 0, open: isOpen, onCloseAutoFocus: onCloseAutoFocus, onOpenAutoFocus: focusOnFirstElement, onEscapeKeyDown: handleOutSideInteraction, onFocusOutside: handleOutSideInteraction, onInteractOutside: handleOutSideInteraction, onPointerDownOutside: handleOutSideInteraction, content: React.createElement("div", { ref: containerRef }, children), className: "arc-NavigationHeaderDropdown" }, tooltip ? (React.createElement(Tooltip.Tooltip, { asChild: true, title: tooltip, alignContent: "center", delayDuration: DELAY_DURATION, side: "bottom" },
655
+ React.createElement(NavigationHeaderButton, { isPadded: false, ref: triggerRef, "aria-label": ariaLabel, "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-describedby": undefined, onClick: toggleVisibility }, trigger))) : (React.createElement(NavigationHeaderButton, { ref: triggerRef, "aria-label": ariaLabel, "aria-expanded": isOpen, "aria-haspopup": "dialog", isActive: isOpen, onClick: toggleVisibility }, trigger)))));
656
+ };
657
+
658
+ var NavigationHeaderPanelHeading = function (_a) {
659
+ var heading = _a.heading, supportingText = _a.supportingText, link = _a.link, props = tslib_es6.__rest(_a, ["heading", "supportingText", "link"]);
660
+ return (React.createElement("div", tslib_es6.__assign({ className: "arc-NavigationHeaderPanelHeading" }, filterAttrs.filterAttrs(props)),
661
+ React.createElement("div", { className: "arc-NavigationHeaderPanelHeading-grid" },
662
+ React.createElement("div", { className: "arc-NavigationHeaderPanelHeading-text" },
663
+ React.createElement(Heading.Heading, { level: "2", size: "m" }, heading)),
664
+ React.createElement("div", { className: "arc-NavigationHeaderPanelHeading-cta" }, link && (React.createElement(ButtonV2.ButtonV2, { buttonStyle: "secondary", ariaLabel: link.ariaLabel, href: link.href, onClick: link.onClick, label: link.text })))),
665
+ React.createElement(VerticalSpace.VerticalSpace, { size: "4" }),
666
+ React.createElement(Text.Text, { size: "s", tone: "muted" }, supportingText)));
667
+ };
668
+
669
+ var _a$1 = createNavigationHeaderContext("NavigationHeaderSubnav sub components must be used within NavigationHeaderSubnav"), SubNavContext = _a$1[0], useSubNavContext = _a$1[1];
670
+
671
+ var NavigationHeaderSubnav = function (_a) {
672
+ var children = _a.children, onOpenChange = _a.onOpenChange;
673
+ var id = useUniqueString("subnav");
674
+ var rootRef = React.useRef(null);
675
+ var triggerRef = React.useRef(null);
676
+ var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
677
+ var value = React.useMemo(function () { return ({ id: id, triggerRef: triggerRef, rootRef: rootRef, isOpen: isOpen, setIsOpen: setIsOpen, onOpenChange: onOpenChange }); }, [id, isOpen, onOpenChange]);
678
+ return (React.createElement(SubNavContext.Provider, { value: value },
679
+ React.createElement("div", { ref: rootRef }, children)));
680
+ };
681
+
682
+ var NavigationHeaderSubnavTrigger = function (_a) {
683
+ var _b;
684
+ var children = _a.children, asChild = _a.asChild, onClick = _a.onClick, ariaLabel = _a.ariaLabel, props = tslib_es6.__rest(_a, ["children", "asChild", "onClick", "ariaLabel"]);
685
+ var subNavContext = useSubNavContext();
686
+ var onTriggerClick = function (e) {
687
+ var _a;
688
+ onClick && onClick(e);
689
+ subNavContext.setIsOpen(!subNavContext.isOpen);
690
+ (_a = subNavContext.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(subNavContext, !subNavContext.isOpen);
691
+ };
692
+ useTriggerHidden({
693
+ triggerEl: (_b = subNavContext.triggerRef) === null || _b === void 0 ? void 0 : _b.current,
694
+ onTriggerHidden: function () {
695
+ var _a;
696
+ subNavContext.setIsOpen(false);
697
+ (_a = subNavContext.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(subNavContext, false);
698
+ },
699
+ });
700
+ if (asChild) {
701
+ return React.cloneElement(children, tslib_es6.__assign(tslib_es6.__assign({ onClick: function (e) {
702
+ var _a, _b;
703
+ onTriggerClick(e);
704
+ (_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
705
+ }, ref: subNavContext.triggerRef }, props), children.props));
706
+ }
707
+ return (React.createElement(NavigationHeaderButton, { "aria-label": ariaLabel, "aria-haspopup": "dialog", "aria-describedby": undefined, onClick: onTriggerClick, ref: subNavContext.triggerRef, "aria-expanded": subNavContext.isOpen, isActive: subNavContext.isOpen }, children));
708
+ };
709
+
710
+ function hasWindow() {
711
+ return typeof window !== 'undefined';
712
+ }
713
+ function getNodeName(node) {
714
+ if (isNode(node)) {
715
+ return (node.nodeName || '').toLowerCase();
716
+ }
717
+ // Mocked nodes in testing environments may not be instances of Node. By
718
+ // returning `#document` an infinite loop won't occur.
719
+ // https://github.com/floating-ui/floating-ui/issues/2317
720
+ return '#document';
721
+ }
722
+ function getWindow(node) {
723
+ var _node$ownerDocument;
724
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
725
+ }
726
+ function getDocumentElement(node) {
727
+ var _ref;
728
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
729
+ }
730
+ function isNode(value) {
731
+ if (!hasWindow()) {
732
+ return false;
733
+ }
734
+ return value instanceof Node || value instanceof getWindow(value).Node;
735
+ }
736
+ function isElement(value) {
737
+ if (!hasWindow()) {
738
+ return false;
739
+ }
740
+ return value instanceof Element || value instanceof getWindow(value).Element;
741
+ }
742
+ function isHTMLElement(value) {
743
+ if (!hasWindow()) {
744
+ return false;
745
+ }
746
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
747
+ }
748
+ function isShadowRoot(value) {
749
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
750
+ return false;
751
+ }
752
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
753
+ }
754
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
755
+ function isOverflowElement(element) {
756
+ const {
757
+ overflow,
758
+ overflowX,
759
+ overflowY,
760
+ display
761
+ } = getComputedStyle$1(element);
762
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
763
+ }
764
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
765
+ function isTableElement(element) {
766
+ return tableElements.has(getNodeName(element));
767
+ }
768
+ const topLayerSelectors = [':popover-open', ':modal'];
769
+ function isTopLayer(element) {
770
+ return topLayerSelectors.some(selector => {
771
+ try {
772
+ return element.matches(selector);
773
+ } catch (_e) {
774
+ return false;
775
+ }
776
+ });
777
+ }
778
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
779
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
780
+ const containValues = ['paint', 'layout', 'strict', 'content'];
781
+ function isContainingBlock(elementOrCss) {
782
+ const webkit = isWebKit();
783
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
784
+
785
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
786
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
787
+ return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
788
+ }
789
+ function getContainingBlock(element) {
790
+ let currentNode = getParentNode(element);
791
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
792
+ if (isContainingBlock(currentNode)) {
793
+ return currentNode;
794
+ } else if (isTopLayer(currentNode)) {
795
+ return null;
796
+ }
797
+ currentNode = getParentNode(currentNode);
798
+ }
799
+ return null;
800
+ }
801
+ function isWebKit() {
802
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
803
+ return CSS.supports('-webkit-backdrop-filter', 'none');
804
+ }
805
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
806
+ function isLastTraversableNode(node) {
807
+ return lastTraversableNodeNames.has(getNodeName(node));
808
+ }
809
+ function getComputedStyle$1(element) {
810
+ return getWindow(element).getComputedStyle(element);
811
+ }
812
+ function getNodeScroll(element) {
813
+ if (isElement(element)) {
814
+ return {
815
+ scrollLeft: element.scrollLeft,
816
+ scrollTop: element.scrollTop
817
+ };
818
+ }
819
+ return {
820
+ scrollLeft: element.scrollX,
821
+ scrollTop: element.scrollY
822
+ };
823
+ }
824
+ function getParentNode(node) {
825
+ if (getNodeName(node) === 'html') {
826
+ return node;
827
+ }
828
+ const result =
829
+ // Step into the shadow DOM of the parent of a slotted node.
830
+ node.assignedSlot ||
831
+ // DOM Element detected.
832
+ node.parentNode ||
833
+ // ShadowRoot detected.
834
+ isShadowRoot(node) && node.host ||
835
+ // Fallback.
836
+ getDocumentElement(node);
837
+ return isShadowRoot(result) ? result.host : result;
838
+ }
839
+ function getNearestOverflowAncestor(node) {
840
+ const parentNode = getParentNode(node);
841
+ if (isLastTraversableNode(parentNode)) {
842
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
843
+ }
844
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
845
+ return parentNode;
846
+ }
847
+ return getNearestOverflowAncestor(parentNode);
848
+ }
849
+ function getOverflowAncestors(node, list, traverseIframes) {
850
+ var _node$ownerDocument2;
851
+ if (list === void 0) {
852
+ list = [];
853
+ }
854
+ if (traverseIframes === void 0) {
855
+ traverseIframes = true;
856
+ }
857
+ const scrollableAncestor = getNearestOverflowAncestor(node);
858
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
859
+ const win = getWindow(scrollableAncestor);
860
+ if (isBody) {
861
+ const frameElement = getFrameElement(win);
862
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
863
+ }
864
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
865
+ }
866
+ function getFrameElement(win) {
867
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
868
+ }
869
+
870
+ /**
871
+ * Custom positioning reference element.
872
+ * @see https://floating-ui.com/docs/virtual-elements
873
+ */
874
+
875
+ const min = Math.min;
876
+ const max = Math.max;
877
+ const round = Math.round;
878
+ const floor = Math.floor;
879
+ const createCoords = v => ({
880
+ x: v,
881
+ y: v
882
+ });
883
+ function evaluate(value, param) {
884
+ return typeof value === 'function' ? value(param) : value;
885
+ }
886
+ function getSide(placement) {
887
+ return placement.split('-')[0];
888
+ }
889
+ function getAlignment(placement) {
890
+ return placement.split('-')[1];
891
+ }
892
+ function getOppositeAxis(axis) {
893
+ return axis === 'x' ? 'y' : 'x';
894
+ }
895
+ function getAxisLength(axis) {
896
+ return axis === 'y' ? 'height' : 'width';
897
+ }
898
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
899
+ function getSideAxis(placement) {
900
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
901
+ }
902
+ function getAlignmentAxis(placement) {
903
+ return getOppositeAxis(getSideAxis(placement));
904
+ }
905
+ function expandPaddingObject(padding) {
906
+ return {
907
+ top: 0,
908
+ right: 0,
909
+ bottom: 0,
910
+ left: 0,
911
+ ...padding
912
+ };
913
+ }
914
+ function getPaddingObject(padding) {
915
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
916
+ top: padding,
917
+ right: padding,
918
+ bottom: padding,
919
+ left: padding
920
+ };
921
+ }
922
+ function rectToClientRect(rect) {
923
+ const {
924
+ x,
925
+ y,
926
+ width,
927
+ height
928
+ } = rect;
929
+ return {
930
+ width,
931
+ height,
932
+ top: y,
933
+ left: x,
934
+ right: x + width,
935
+ bottom: y + height,
936
+ x,
937
+ y
938
+ };
939
+ }
940
+
941
+ var isClient$1 = typeof document !== 'undefined';
942
+
943
+ var noop$1 = function noop() {};
944
+ var index$1 = isClient$1 ? React.useLayoutEffect : noop$1;
945
+
946
+ // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
947
+ const SafeReact$1 = {
948
+ ...React__namespace
949
+ };
950
+ const useInsertionEffect = SafeReact$1.useInsertionEffect;
951
+ const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
952
+ function useEffectEvent(callback) {
953
+ const ref = React__namespace.useRef(() => {
954
+ if (process.env.NODE_ENV !== "production") {
955
+ throw new Error('Cannot call an event handler while rendering.');
956
+ }
957
+ });
958
+ useSafeInsertionEffect(() => {
959
+ ref.current = callback;
960
+ });
961
+ return React__namespace.useCallback(function () {
962
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
963
+ args[_key] = arguments[_key];
964
+ }
965
+ return ref.current == null ? void 0 : ref.current(...args);
966
+ }, []);
967
+ }
968
+
969
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
970
+ let {
971
+ reference,
972
+ floating
973
+ } = _ref;
974
+ const sideAxis = getSideAxis(placement);
975
+ const alignmentAxis = getAlignmentAxis(placement);
976
+ const alignLength = getAxisLength(alignmentAxis);
977
+ const side = getSide(placement);
978
+ const isVertical = sideAxis === 'y';
979
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
980
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
981
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
982
+ let coords;
983
+ switch (side) {
984
+ case 'top':
985
+ coords = {
986
+ x: commonX,
987
+ y: reference.y - floating.height
988
+ };
989
+ break;
990
+ case 'bottom':
991
+ coords = {
992
+ x: commonX,
993
+ y: reference.y + reference.height
994
+ };
995
+ break;
996
+ case 'right':
997
+ coords = {
998
+ x: reference.x + reference.width,
999
+ y: commonY
1000
+ };
1001
+ break;
1002
+ case 'left':
1003
+ coords = {
1004
+ x: reference.x - floating.width,
1005
+ y: commonY
1006
+ };
1007
+ break;
1008
+ default:
1009
+ coords = {
1010
+ x: reference.x,
1011
+ y: reference.y
1012
+ };
1013
+ }
1014
+ switch (getAlignment(placement)) {
1015
+ case 'start':
1016
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1017
+ break;
1018
+ case 'end':
1019
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1020
+ break;
1021
+ }
1022
+ return coords;
1023
+ }
1024
+
1025
+ /**
1026
+ * Computes the `x` and `y` coordinates that will place the floating element
1027
+ * next to a given reference element.
1028
+ *
1029
+ * This export does not have any `platform` interface logic. You will need to
1030
+ * write one for the platform you are using Floating UI with.
1031
+ */
1032
+ const computePosition$1 = async (reference, floating, config) => {
1033
+ const {
1034
+ placement = 'bottom',
1035
+ strategy = 'absolute',
1036
+ middleware = [],
1037
+ platform
1038
+ } = config;
1039
+ const validMiddleware = middleware.filter(Boolean);
1040
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1041
+ let rects = await platform.getElementRects({
1042
+ reference,
1043
+ floating,
1044
+ strategy
1045
+ });
1046
+ let {
1047
+ x,
1048
+ y
1049
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1050
+ let statefulPlacement = placement;
1051
+ let middlewareData = {};
1052
+ let resetCount = 0;
1053
+ for (let i = 0; i < validMiddleware.length; i++) {
1054
+ const {
1055
+ name,
1056
+ fn
1057
+ } = validMiddleware[i];
1058
+ const {
1059
+ x: nextX,
1060
+ y: nextY,
1061
+ data,
1062
+ reset
1063
+ } = await fn({
1064
+ x,
1065
+ y,
1066
+ initialPlacement: placement,
1067
+ placement: statefulPlacement,
1068
+ strategy,
1069
+ middlewareData,
1070
+ rects,
1071
+ platform,
1072
+ elements: {
1073
+ reference,
1074
+ floating
1075
+ }
1076
+ });
1077
+ x = nextX != null ? nextX : x;
1078
+ y = nextY != null ? nextY : y;
1079
+ middlewareData = {
1080
+ ...middlewareData,
1081
+ [name]: {
1082
+ ...middlewareData[name],
1083
+ ...data
1084
+ }
1085
+ };
1086
+ if (reset && resetCount <= 50) {
1087
+ resetCount++;
1088
+ if (typeof reset === 'object') {
1089
+ if (reset.placement) {
1090
+ statefulPlacement = reset.placement;
1091
+ }
1092
+ if (reset.rects) {
1093
+ rects = reset.rects === true ? await platform.getElementRects({
1094
+ reference,
1095
+ floating,
1096
+ strategy
1097
+ }) : reset.rects;
1098
+ }
1099
+ ({
1100
+ x,
1101
+ y
1102
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1103
+ }
1104
+ i = -1;
1105
+ }
1106
+ }
1107
+ return {
1108
+ x,
1109
+ y,
1110
+ placement: statefulPlacement,
1111
+ strategy,
1112
+ middlewareData
1113
+ };
1114
+ };
1115
+
1116
+ /**
1117
+ * Resolves with an object of overflow side offsets that determine how much the
1118
+ * element is overflowing a given clipping boundary on each side.
1119
+ * - positive = overflowing the boundary by that number of pixels
1120
+ * - negative = how many pixels left before it will overflow
1121
+ * - 0 = lies flush with the boundary
1122
+ * @see https://floating-ui.com/docs/detectOverflow
1123
+ */
1124
+ async function detectOverflow(state, options) {
1125
+ var _await$platform$isEle;
1126
+ if (options === void 0) {
1127
+ options = {};
1128
+ }
1129
+ const {
1130
+ x,
1131
+ y,
1132
+ platform,
1133
+ rects,
1134
+ elements,
1135
+ strategy
1136
+ } = state;
1137
+ const {
1138
+ boundary = 'clippingAncestors',
1139
+ rootBoundary = 'viewport',
1140
+ elementContext = 'floating',
1141
+ altBoundary = false,
1142
+ padding = 0
1143
+ } = evaluate(options, state);
1144
+ const paddingObject = getPaddingObject(padding);
1145
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1146
+ const element = elements[altBoundary ? altContext : elementContext];
1147
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1148
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1149
+ boundary,
1150
+ rootBoundary,
1151
+ strategy
1152
+ }));
1153
+ const rect = elementContext === 'floating' ? {
1154
+ x,
1155
+ y,
1156
+ width: rects.floating.width,
1157
+ height: rects.floating.height
1158
+ } : rects.reference;
1159
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1160
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1161
+ x: 1,
1162
+ y: 1
1163
+ } : {
1164
+ x: 1,
1165
+ y: 1
1166
+ };
1167
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1168
+ elements,
1169
+ rect,
1170
+ offsetParent,
1171
+ strategy
1172
+ }) : rect);
1173
+ return {
1174
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1175
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1176
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1177
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1178
+ };
1179
+ }
1180
+
1181
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
1182
+
1183
+ // For type backwards-compatibility, the `OffsetOptions` type was also
1184
+ // Derivable.
1185
+
1186
+ async function convertValueToCoords(state, options) {
1187
+ const {
1188
+ placement,
1189
+ platform,
1190
+ elements
1191
+ } = state;
1192
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1193
+ const side = getSide(placement);
1194
+ const alignment = getAlignment(placement);
1195
+ const isVertical = getSideAxis(placement) === 'y';
1196
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
1197
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1198
+ const rawValue = evaluate(options, state);
1199
+
1200
+ // eslint-disable-next-line prefer-const
1201
+ let {
1202
+ mainAxis,
1203
+ crossAxis,
1204
+ alignmentAxis
1205
+ } = typeof rawValue === 'number' ? {
1206
+ mainAxis: rawValue,
1207
+ crossAxis: 0,
1208
+ alignmentAxis: null
1209
+ } : {
1210
+ mainAxis: rawValue.mainAxis || 0,
1211
+ crossAxis: rawValue.crossAxis || 0,
1212
+ alignmentAxis: rawValue.alignmentAxis
1213
+ };
1214
+ if (alignment && typeof alignmentAxis === 'number') {
1215
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1216
+ }
1217
+ return isVertical ? {
1218
+ x: crossAxis * crossAxisMulti,
1219
+ y: mainAxis * mainAxisMulti
1220
+ } : {
1221
+ x: mainAxis * mainAxisMulti,
1222
+ y: crossAxis * crossAxisMulti
1223
+ };
1224
+ }
1225
+
1226
+ /**
1227
+ * Modifies the placement by translating the floating element along the
1228
+ * specified axes.
1229
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1230
+ * object may be passed.
1231
+ * @see https://floating-ui.com/docs/offset
1232
+ */
1233
+ const offset$2 = function (options) {
1234
+ if (options === void 0) {
1235
+ options = 0;
1236
+ }
1237
+ return {
1238
+ name: 'offset',
1239
+ options,
1240
+ async fn(state) {
1241
+ var _middlewareData$offse, _middlewareData$arrow;
1242
+ const {
1243
+ x,
1244
+ y,
1245
+ placement,
1246
+ middlewareData
1247
+ } = state;
1248
+ const diffCoords = await convertValueToCoords(state, options);
1249
+
1250
+ // If the placement is the same and the arrow caused an alignment offset
1251
+ // then we don't need to change the positioning coordinates.
1252
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1253
+ return {};
1254
+ }
1255
+ return {
1256
+ x: x + diffCoords.x,
1257
+ y: y + diffCoords.y,
1258
+ data: {
1259
+ ...diffCoords,
1260
+ placement
1261
+ }
1262
+ };
1263
+ }
1264
+ };
1265
+ };
1266
+
1267
+ /**
1268
+ * Provides data that allows you to change the size of the floating element —
1269
+ * for instance, prevent it from overflowing the clipping boundary or match the
1270
+ * width of the reference element.
1271
+ * @see https://floating-ui.com/docs/size
1272
+ */
1273
+ const size$2 = function (options) {
1274
+ if (options === void 0) {
1275
+ options = {};
1276
+ }
1277
+ return {
1278
+ name: 'size',
1279
+ options,
1280
+ async fn(state) {
1281
+ var _state$middlewareData, _state$middlewareData2;
1282
+ const {
1283
+ placement,
1284
+ rects,
1285
+ platform,
1286
+ elements
1287
+ } = state;
1288
+ const {
1289
+ apply = () => {},
1290
+ ...detectOverflowOptions
1291
+ } = evaluate(options, state);
1292
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1293
+ const side = getSide(placement);
1294
+ const alignment = getAlignment(placement);
1295
+ const isYAxis = getSideAxis(placement) === 'y';
1296
+ const {
1297
+ width,
1298
+ height
1299
+ } = rects.floating;
1300
+ let heightSide;
1301
+ let widthSide;
1302
+ if (side === 'top' || side === 'bottom') {
1303
+ heightSide = side;
1304
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
1305
+ } else {
1306
+ widthSide = side;
1307
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
1308
+ }
1309
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
1310
+ const maximumClippingWidth = width - overflow.left - overflow.right;
1311
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1312
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1313
+ const noShift = !state.middlewareData.shift;
1314
+ let availableHeight = overflowAvailableHeight;
1315
+ let availableWidth = overflowAvailableWidth;
1316
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1317
+ availableWidth = maximumClippingWidth;
1318
+ }
1319
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1320
+ availableHeight = maximumClippingHeight;
1321
+ }
1322
+ if (noShift && !alignment) {
1323
+ const xMin = max(overflow.left, 0);
1324
+ const xMax = max(overflow.right, 0);
1325
+ const yMin = max(overflow.top, 0);
1326
+ const yMax = max(overflow.bottom, 0);
1327
+ if (isYAxis) {
1328
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1329
+ } else {
1330
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1331
+ }
1332
+ }
1333
+ await apply({
1334
+ ...state,
1335
+ availableWidth,
1336
+ availableHeight
1337
+ });
1338
+ const nextDimensions = await platform.getDimensions(elements.floating);
1339
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1340
+ return {
1341
+ reset: {
1342
+ rects: true
1343
+ }
1344
+ };
1345
+ }
1346
+ return {};
1347
+ }
1348
+ };
1349
+ };
1350
+
1351
+ function getCssDimensions(element) {
1352
+ const css = getComputedStyle$1(element);
1353
+ // In testing environments, the `width` and `height` properties are empty
1354
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1355
+ let width = parseFloat(css.width) || 0;
1356
+ let height = parseFloat(css.height) || 0;
1357
+ const hasOffset = isHTMLElement(element);
1358
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1359
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1360
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1361
+ if (shouldFallback) {
1362
+ width = offsetWidth;
1363
+ height = offsetHeight;
1364
+ }
1365
+ return {
1366
+ width,
1367
+ height,
1368
+ $: shouldFallback
1369
+ };
1370
+ }
1371
+
1372
+ function unwrapElement(element) {
1373
+ return !isElement(element) ? element.contextElement : element;
1374
+ }
1375
+
1376
+ function getScale(element) {
1377
+ const domElement = unwrapElement(element);
1378
+ if (!isHTMLElement(domElement)) {
1379
+ return createCoords(1);
1380
+ }
1381
+ const rect = domElement.getBoundingClientRect();
1382
+ const {
1383
+ width,
1384
+ height,
1385
+ $
1386
+ } = getCssDimensions(domElement);
1387
+ let x = ($ ? round(rect.width) : rect.width) / width;
1388
+ let y = ($ ? round(rect.height) : rect.height) / height;
1389
+
1390
+ // 0, NaN, or Infinity should always fallback to 1.
1391
+
1392
+ if (!x || !Number.isFinite(x)) {
1393
+ x = 1;
1394
+ }
1395
+ if (!y || !Number.isFinite(y)) {
1396
+ y = 1;
1397
+ }
1398
+ return {
1399
+ x,
1400
+ y
1401
+ };
1402
+ }
1403
+
1404
+ const noOffsets = /*#__PURE__*/createCoords(0);
1405
+ function getVisualOffsets(element) {
1406
+ const win = getWindow(element);
1407
+ if (!isWebKit() || !win.visualViewport) {
1408
+ return noOffsets;
1409
+ }
1410
+ return {
1411
+ x: win.visualViewport.offsetLeft,
1412
+ y: win.visualViewport.offsetTop
1413
+ };
1414
+ }
1415
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1416
+ if (isFixed === void 0) {
1417
+ isFixed = false;
1418
+ }
1419
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1420
+ return false;
1421
+ }
1422
+ return isFixed;
1423
+ }
1424
+
1425
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1426
+ if (includeScale === void 0) {
1427
+ includeScale = false;
1428
+ }
1429
+ if (isFixedStrategy === void 0) {
1430
+ isFixedStrategy = false;
1431
+ }
1432
+ const clientRect = element.getBoundingClientRect();
1433
+ const domElement = unwrapElement(element);
1434
+ let scale = createCoords(1);
1435
+ if (includeScale) {
1436
+ if (offsetParent) {
1437
+ if (isElement(offsetParent)) {
1438
+ scale = getScale(offsetParent);
1439
+ }
1440
+ } else {
1441
+ scale = getScale(element);
1442
+ }
1443
+ }
1444
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1445
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1446
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1447
+ let width = clientRect.width / scale.x;
1448
+ let height = clientRect.height / scale.y;
1449
+ if (domElement) {
1450
+ const win = getWindow(domElement);
1451
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1452
+ let currentWin = win;
1453
+ let currentIFrame = getFrameElement(currentWin);
1454
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1455
+ const iframeScale = getScale(currentIFrame);
1456
+ const iframeRect = currentIFrame.getBoundingClientRect();
1457
+ const css = getComputedStyle$1(currentIFrame);
1458
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1459
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1460
+ x *= iframeScale.x;
1461
+ y *= iframeScale.y;
1462
+ width *= iframeScale.x;
1463
+ height *= iframeScale.y;
1464
+ x += left;
1465
+ y += top;
1466
+ currentWin = getWindow(currentIFrame);
1467
+ currentIFrame = getFrameElement(currentWin);
1468
+ }
1469
+ }
1470
+ return rectToClientRect({
1471
+ width,
1472
+ height,
1473
+ x,
1474
+ y
1475
+ });
1476
+ }
1477
+
1478
+ // If <html> has a CSS width greater than the viewport, then this will be
1479
+ // incorrect for RTL.
1480
+ function getWindowScrollBarX(element, rect) {
1481
+ const leftScroll = getNodeScroll(element).scrollLeft;
1482
+ if (!rect) {
1483
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1484
+ }
1485
+ return rect.left + leftScroll;
1486
+ }
1487
+
1488
+ function getHTMLOffset(documentElement, scroll) {
1489
+ const htmlRect = documentElement.getBoundingClientRect();
1490
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1491
+ const y = htmlRect.top + scroll.scrollTop;
1492
+ return {
1493
+ x,
1494
+ y
1495
+ };
1496
+ }
1497
+
1498
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1499
+ let {
1500
+ elements,
1501
+ rect,
1502
+ offsetParent,
1503
+ strategy
1504
+ } = _ref;
1505
+ const isFixed = strategy === 'fixed';
1506
+ const documentElement = getDocumentElement(offsetParent);
1507
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1508
+ if (offsetParent === documentElement || topLayer && isFixed) {
1509
+ return rect;
1510
+ }
1511
+ let scroll = {
1512
+ scrollLeft: 0,
1513
+ scrollTop: 0
1514
+ };
1515
+ let scale = createCoords(1);
1516
+ const offsets = createCoords(0);
1517
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1518
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1519
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1520
+ scroll = getNodeScroll(offsetParent);
1521
+ }
1522
+ if (isHTMLElement(offsetParent)) {
1523
+ const offsetRect = getBoundingClientRect(offsetParent);
1524
+ scale = getScale(offsetParent);
1525
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1526
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1527
+ }
1528
+ }
1529
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1530
+ return {
1531
+ width: rect.width * scale.x,
1532
+ height: rect.height * scale.y,
1533
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1534
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1535
+ };
1536
+ }
1537
+
1538
+ function getClientRects(element) {
1539
+ return Array.from(element.getClientRects());
1540
+ }
1541
+
1542
+ // Gets the entire size of the scrollable document area, even extending outside
1543
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1544
+ function getDocumentRect(element) {
1545
+ const html = getDocumentElement(element);
1546
+ const scroll = getNodeScroll(element);
1547
+ const body = element.ownerDocument.body;
1548
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1549
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1550
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1551
+ const y = -scroll.scrollTop;
1552
+ if (getComputedStyle$1(body).direction === 'rtl') {
1553
+ x += max(html.clientWidth, body.clientWidth) - width;
1554
+ }
1555
+ return {
1556
+ width,
1557
+ height,
1558
+ x,
1559
+ y
1560
+ };
1561
+ }
1562
+
1563
+ // Safety check: ensure the scrollbar space is reasonable in case this
1564
+ // calculation is affected by unusual styles.
1565
+ // Most scrollbars leave 15-18px of space.
1566
+ const SCROLLBAR_MAX = 25;
1567
+ function getViewportRect(element, strategy) {
1568
+ const win = getWindow(element);
1569
+ const html = getDocumentElement(element);
1570
+ const visualViewport = win.visualViewport;
1571
+ let width = html.clientWidth;
1572
+ let height = html.clientHeight;
1573
+ let x = 0;
1574
+ let y = 0;
1575
+ if (visualViewport) {
1576
+ width = visualViewport.width;
1577
+ height = visualViewport.height;
1578
+ const visualViewportBased = isWebKit();
1579
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1580
+ x = visualViewport.offsetLeft;
1581
+ y = visualViewport.offsetTop;
1582
+ }
1583
+ }
1584
+ const windowScrollbarX = getWindowScrollBarX(html);
1585
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1586
+ // visual width of the <html> but this is not considered in the size
1587
+ // of `html.clientWidth`.
1588
+ if (windowScrollbarX <= 0) {
1589
+ const doc = html.ownerDocument;
1590
+ const body = doc.body;
1591
+ const bodyStyles = getComputedStyle(body);
1592
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1593
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1594
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1595
+ width -= clippingStableScrollbarWidth;
1596
+ }
1597
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1598
+ // If the <body> scrollbar is on the left, the width needs to be extended
1599
+ // by the scrollbar amount so there isn't extra space on the right.
1600
+ width += windowScrollbarX;
1601
+ }
1602
+ return {
1603
+ width,
1604
+ height,
1605
+ x,
1606
+ y
1607
+ };
1608
+ }
1609
+
1610
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1611
+ // Returns the inner client rect, subtracting scrollbars if present.
1612
+ function getInnerBoundingClientRect(element, strategy) {
1613
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1614
+ const top = clientRect.top + element.clientTop;
1615
+ const left = clientRect.left + element.clientLeft;
1616
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1617
+ const width = element.clientWidth * scale.x;
1618
+ const height = element.clientHeight * scale.y;
1619
+ const x = left * scale.x;
1620
+ const y = top * scale.y;
1621
+ return {
1622
+ width,
1623
+ height,
1624
+ x,
1625
+ y
1626
+ };
1627
+ }
1628
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1629
+ let rect;
1630
+ if (clippingAncestor === 'viewport') {
1631
+ rect = getViewportRect(element, strategy);
1632
+ } else if (clippingAncestor === 'document') {
1633
+ rect = getDocumentRect(getDocumentElement(element));
1634
+ } else if (isElement(clippingAncestor)) {
1635
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1636
+ } else {
1637
+ const visualOffsets = getVisualOffsets(element);
1638
+ rect = {
1639
+ x: clippingAncestor.x - visualOffsets.x,
1640
+ y: clippingAncestor.y - visualOffsets.y,
1641
+ width: clippingAncestor.width,
1642
+ height: clippingAncestor.height
1643
+ };
1644
+ }
1645
+ return rectToClientRect(rect);
1646
+ }
1647
+ function hasFixedPositionAncestor(element, stopNode) {
1648
+ const parentNode = getParentNode(element);
1649
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1650
+ return false;
1651
+ }
1652
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1653
+ }
1654
+
1655
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1656
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1657
+ // of the given element up the tree.
1658
+ function getClippingElementAncestors(element, cache) {
1659
+ const cachedResult = cache.get(element);
1660
+ if (cachedResult) {
1661
+ return cachedResult;
1662
+ }
1663
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1664
+ let currentContainingBlockComputedStyle = null;
1665
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1666
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1667
+
1668
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1669
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1670
+ const computedStyle = getComputedStyle$1(currentNode);
1671
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1672
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1673
+ currentContainingBlockComputedStyle = null;
1674
+ }
1675
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1676
+ if (shouldDropCurrentNode) {
1677
+ // Drop non-containing blocks.
1678
+ result = result.filter(ancestor => ancestor !== currentNode);
1679
+ } else {
1680
+ // Record last containing block for next iteration.
1681
+ currentContainingBlockComputedStyle = computedStyle;
1682
+ }
1683
+ currentNode = getParentNode(currentNode);
1684
+ }
1685
+ cache.set(element, result);
1686
+ return result;
1687
+ }
1688
+
1689
+ // Gets the maximum area that the element is visible in due to any number of
1690
+ // clipping ancestors.
1691
+ function getClippingRect(_ref) {
1692
+ let {
1693
+ element,
1694
+ boundary,
1695
+ rootBoundary,
1696
+ strategy
1697
+ } = _ref;
1698
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1699
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1700
+ const firstClippingAncestor = clippingAncestors[0];
1701
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1702
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1703
+ accRect.top = max(rect.top, accRect.top);
1704
+ accRect.right = min(rect.right, accRect.right);
1705
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1706
+ accRect.left = max(rect.left, accRect.left);
1707
+ return accRect;
1708
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1709
+ return {
1710
+ width: clippingRect.right - clippingRect.left,
1711
+ height: clippingRect.bottom - clippingRect.top,
1712
+ x: clippingRect.left,
1713
+ y: clippingRect.top
1714
+ };
1715
+ }
1716
+
1717
+ function getDimensions(element) {
1718
+ const {
1719
+ width,
1720
+ height
1721
+ } = getCssDimensions(element);
1722
+ return {
1723
+ width,
1724
+ height
1725
+ };
1726
+ }
1727
+
1728
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1729
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1730
+ const documentElement = getDocumentElement(offsetParent);
1731
+ const isFixed = strategy === 'fixed';
1732
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1733
+ let scroll = {
1734
+ scrollLeft: 0,
1735
+ scrollTop: 0
1736
+ };
1737
+ const offsets = createCoords(0);
1738
+
1739
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1740
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1741
+ function setLeftRTLScrollbarOffset() {
1742
+ offsets.x = getWindowScrollBarX(documentElement);
1743
+ }
1744
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1745
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1746
+ scroll = getNodeScroll(offsetParent);
1747
+ }
1748
+ if (isOffsetParentAnElement) {
1749
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1750
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1751
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1752
+ } else if (documentElement) {
1753
+ setLeftRTLScrollbarOffset();
1754
+ }
1755
+ }
1756
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1757
+ setLeftRTLScrollbarOffset();
1758
+ }
1759
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1760
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1761
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1762
+ return {
1763
+ x,
1764
+ y,
1765
+ width: rect.width,
1766
+ height: rect.height
1767
+ };
1768
+ }
1769
+
1770
+ function isStaticPositioned(element) {
1771
+ return getComputedStyle$1(element).position === 'static';
1772
+ }
1773
+
1774
+ function getTrueOffsetParent(element, polyfill) {
1775
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1776
+ return null;
1777
+ }
1778
+ if (polyfill) {
1779
+ return polyfill(element);
1780
+ }
1781
+ let rawOffsetParent = element.offsetParent;
1782
+
1783
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1784
+ // while Chrome and Safari return the <body> element. The <body> element must
1785
+ // be used to perform the correct calculations even if the <html> element is
1786
+ // non-static.
1787
+ if (getDocumentElement(element) === rawOffsetParent) {
1788
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1789
+ }
1790
+ return rawOffsetParent;
1791
+ }
1792
+
1793
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1794
+ // such as table ancestors and cross browser bugs.
1795
+ function getOffsetParent(element, polyfill) {
1796
+ const win = getWindow(element);
1797
+ if (isTopLayer(element)) {
1798
+ return win;
1799
+ }
1800
+ if (!isHTMLElement(element)) {
1801
+ let svgOffsetParent = getParentNode(element);
1802
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1803
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1804
+ return svgOffsetParent;
1805
+ }
1806
+ svgOffsetParent = getParentNode(svgOffsetParent);
1807
+ }
1808
+ return win;
1809
+ }
1810
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1811
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1812
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1813
+ }
1814
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1815
+ return win;
1816
+ }
1817
+ return offsetParent || getContainingBlock(element) || win;
1818
+ }
1819
+
1820
+ const getElementRects = async function (data) {
1821
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1822
+ const getDimensionsFn = this.getDimensions;
1823
+ const floatingDimensions = await getDimensionsFn(data.floating);
1824
+ return {
1825
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1826
+ floating: {
1827
+ x: 0,
1828
+ y: 0,
1829
+ width: floatingDimensions.width,
1830
+ height: floatingDimensions.height
1831
+ }
1832
+ };
1833
+ };
1834
+
1835
+ function isRTL(element) {
1836
+ return getComputedStyle$1(element).direction === 'rtl';
1837
+ }
1838
+
1839
+ const platform = {
1840
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1841
+ getDocumentElement,
1842
+ getClippingRect,
1843
+ getOffsetParent,
1844
+ getElementRects,
1845
+ getClientRects,
1846
+ getDimensions,
1847
+ getScale,
1848
+ isElement,
1849
+ isRTL
1850
+ };
1851
+
1852
+ function rectsAreEqual(a, b) {
1853
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1854
+ }
1855
+
1856
+ // https://samthor.au/2021/observing-dom/
1857
+ function observeMove(element, onMove) {
1858
+ let io = null;
1859
+ let timeoutId;
1860
+ const root = getDocumentElement(element);
1861
+ function cleanup() {
1862
+ var _io;
1863
+ clearTimeout(timeoutId);
1864
+ (_io = io) == null || _io.disconnect();
1865
+ io = null;
1866
+ }
1867
+ function refresh(skip, threshold) {
1868
+ if (skip === void 0) {
1869
+ skip = false;
1870
+ }
1871
+ if (threshold === void 0) {
1872
+ threshold = 1;
1873
+ }
1874
+ cleanup();
1875
+ const elementRectForRootMargin = element.getBoundingClientRect();
1876
+ const {
1877
+ left,
1878
+ top,
1879
+ width,
1880
+ height
1881
+ } = elementRectForRootMargin;
1882
+ if (!skip) {
1883
+ onMove();
1884
+ }
1885
+ if (!width || !height) {
1886
+ return;
1887
+ }
1888
+ const insetTop = floor(top);
1889
+ const insetRight = floor(root.clientWidth - (left + width));
1890
+ const insetBottom = floor(root.clientHeight - (top + height));
1891
+ const insetLeft = floor(left);
1892
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1893
+ const options = {
1894
+ rootMargin,
1895
+ threshold: max(0, min(1, threshold)) || 1
1896
+ };
1897
+ let isFirstUpdate = true;
1898
+ function handleObserve(entries) {
1899
+ const ratio = entries[0].intersectionRatio;
1900
+ if (ratio !== threshold) {
1901
+ if (!isFirstUpdate) {
1902
+ return refresh();
1903
+ }
1904
+ if (!ratio) {
1905
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1906
+ // to prevent an infinite loop of updates.
1907
+ timeoutId = setTimeout(() => {
1908
+ refresh(false, 1e-7);
1909
+ }, 1000);
1910
+ } else {
1911
+ refresh(false, ratio);
1912
+ }
1913
+ }
1914
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1915
+ // It's possible that even though the ratio is reported as 1, the
1916
+ // element is not actually fully within the IntersectionObserver's root
1917
+ // area anymore. This can happen under performance constraints. This may
1918
+ // be a bug in the browser's IntersectionObserver implementation. To
1919
+ // work around this, we compare the element's bounding rect now with
1920
+ // what it was at the time we created the IntersectionObserver. If they
1921
+ // are not equal then the element moved, so we refresh.
1922
+ refresh();
1923
+ }
1924
+ isFirstUpdate = false;
1925
+ }
1926
+
1927
+ // Older browsers don't support a `document` as the root and will throw an
1928
+ // error.
1929
+ try {
1930
+ io = new IntersectionObserver(handleObserve, {
1931
+ ...options,
1932
+ // Handle <iframe>s
1933
+ root: root.ownerDocument
1934
+ });
1935
+ } catch (_e) {
1936
+ io = new IntersectionObserver(handleObserve, options);
1937
+ }
1938
+ io.observe(element);
1939
+ }
1940
+ refresh(true);
1941
+ return cleanup;
1942
+ }
1943
+
1944
+ /**
1945
+ * Automatically updates the position of the floating element when necessary.
1946
+ * Should only be called when the floating element is mounted on the DOM or
1947
+ * visible on the screen.
1948
+ * @returns cleanup function that should be invoked when the floating element is
1949
+ * removed from the DOM or hidden from the screen.
1950
+ * @see https://floating-ui.com/docs/autoUpdate
1951
+ */
1952
+ function autoUpdate(reference, floating, update, options) {
1953
+ if (options === void 0) {
1954
+ options = {};
1955
+ }
1956
+ const {
1957
+ ancestorScroll = true,
1958
+ ancestorResize = true,
1959
+ elementResize = typeof ResizeObserver === 'function',
1960
+ layoutShift = typeof IntersectionObserver === 'function',
1961
+ animationFrame = false
1962
+ } = options;
1963
+ const referenceEl = unwrapElement(reference);
1964
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1965
+ ancestors.forEach(ancestor => {
1966
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1967
+ passive: true
1968
+ });
1969
+ ancestorResize && ancestor.addEventListener('resize', update);
1970
+ });
1971
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1972
+ let reobserveFrame = -1;
1973
+ let resizeObserver = null;
1974
+ if (elementResize) {
1975
+ resizeObserver = new ResizeObserver(_ref => {
1976
+ let [firstEntry] = _ref;
1977
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1978
+ // Prevent update loops when using the `size` middleware.
1979
+ // https://github.com/floating-ui/floating-ui/issues/1740
1980
+ resizeObserver.unobserve(floating);
1981
+ cancelAnimationFrame(reobserveFrame);
1982
+ reobserveFrame = requestAnimationFrame(() => {
1983
+ var _resizeObserver;
1984
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1985
+ });
1986
+ }
1987
+ update();
1988
+ });
1989
+ if (referenceEl && !animationFrame) {
1990
+ resizeObserver.observe(referenceEl);
1991
+ }
1992
+ resizeObserver.observe(floating);
1993
+ }
1994
+ let frameId;
1995
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1996
+ if (animationFrame) {
1997
+ frameLoop();
1998
+ }
1999
+ function frameLoop() {
2000
+ const nextRefRect = getBoundingClientRect(reference);
2001
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
2002
+ update();
2003
+ }
2004
+ prevRefRect = nextRefRect;
2005
+ frameId = requestAnimationFrame(frameLoop);
2006
+ }
2007
+ update();
2008
+ return () => {
2009
+ var _resizeObserver2;
2010
+ ancestors.forEach(ancestor => {
2011
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
2012
+ ancestorResize && ancestor.removeEventListener('resize', update);
2013
+ });
2014
+ cleanupIo == null || cleanupIo();
2015
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2016
+ resizeObserver = null;
2017
+ if (animationFrame) {
2018
+ cancelAnimationFrame(frameId);
2019
+ }
2020
+ };
2021
+ }
2022
+
2023
+ /**
2024
+ * Modifies the placement by translating the floating element along the
2025
+ * specified axes.
2026
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2027
+ * object may be passed.
2028
+ * @see https://floating-ui.com/docs/offset
2029
+ */
2030
+ const offset$1 = offset$2;
2031
+
2032
+ /**
2033
+ * Provides data that allows you to change the size of the floating element —
2034
+ * for instance, prevent it from overflowing the clipping boundary or match the
2035
+ * width of the reference element.
2036
+ * @see https://floating-ui.com/docs/size
2037
+ */
2038
+ const size$1 = size$2;
2039
+
2040
+ /**
2041
+ * Computes the `x` and `y` coordinates that will place the floating element
2042
+ * next to a given reference element.
2043
+ */
2044
+ const computePosition = (reference, floating, options) => {
2045
+ // This caches the expensive `getClippingElementAncestors` function so that
2046
+ // multiple lifecycle resets re-use the same result. It only lives for a
2047
+ // single call. If other functions become expensive, we can add them as well.
2048
+ const cache = new Map();
2049
+ const mergedOptions = {
2050
+ platform,
2051
+ ...options
2052
+ };
2053
+ const platformWithCache = {
2054
+ ...mergedOptions.platform,
2055
+ _c: cache
2056
+ };
2057
+ return computePosition$1(reference, floating, {
2058
+ ...mergedOptions,
2059
+ platform: platformWithCache
2060
+ });
2061
+ };
2062
+
2063
+ var isClient = typeof document !== 'undefined';
2064
+
2065
+ var noop = function noop() {};
2066
+ var index = isClient ? React.useLayoutEffect : noop;
2067
+
2068
+ // Fork of `fast-deep-equal` that only does the comparisons we need and compares
2069
+ // functions
2070
+ function deepEqual(a, b) {
2071
+ if (a === b) {
2072
+ return true;
2073
+ }
2074
+ if (typeof a !== typeof b) {
2075
+ return false;
2076
+ }
2077
+ if (typeof a === 'function' && a.toString() === b.toString()) {
2078
+ return true;
2079
+ }
2080
+ let length;
2081
+ let i;
2082
+ let keys;
2083
+ if (a && b && typeof a === 'object') {
2084
+ if (Array.isArray(a)) {
2085
+ length = a.length;
2086
+ if (length !== b.length) return false;
2087
+ for (i = length; i-- !== 0;) {
2088
+ if (!deepEqual(a[i], b[i])) {
2089
+ return false;
2090
+ }
2091
+ }
2092
+ return true;
2093
+ }
2094
+ keys = Object.keys(a);
2095
+ length = keys.length;
2096
+ if (length !== Object.keys(b).length) {
2097
+ return false;
2098
+ }
2099
+ for (i = length; i-- !== 0;) {
2100
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
2101
+ return false;
2102
+ }
2103
+ }
2104
+ for (i = length; i-- !== 0;) {
2105
+ const key = keys[i];
2106
+ if (key === '_owner' && a.$$typeof) {
2107
+ continue;
2108
+ }
2109
+ if (!deepEqual(a[key], b[key])) {
2110
+ return false;
2111
+ }
2112
+ }
2113
+ return true;
2114
+ }
2115
+ return a !== a && b !== b;
2116
+ }
2117
+
2118
+ function getDPR(element) {
2119
+ if (typeof window === 'undefined') {
2120
+ return 1;
2121
+ }
2122
+ const win = element.ownerDocument.defaultView || window;
2123
+ return win.devicePixelRatio || 1;
2124
+ }
2125
+
2126
+ function roundByDPR(element, value) {
2127
+ const dpr = getDPR(element);
2128
+ return Math.round(value * dpr) / dpr;
2129
+ }
2130
+
2131
+ function useLatestRef(value) {
2132
+ const ref = React__namespace.useRef(value);
2133
+ index(() => {
2134
+ ref.current = value;
2135
+ });
2136
+ return ref;
2137
+ }
2138
+
2139
+ /**
2140
+ * Provides data to position a floating element.
2141
+ * @see https://floating-ui.com/docs/useFloating
2142
+ */
2143
+ function useFloating$1(options) {
2144
+ if (options === void 0) {
2145
+ options = {};
2146
+ }
2147
+ const {
2148
+ placement = 'bottom',
2149
+ strategy = 'absolute',
2150
+ middleware = [],
2151
+ platform,
2152
+ elements: {
2153
+ reference: externalReference,
2154
+ floating: externalFloating
2155
+ } = {},
2156
+ transform = true,
2157
+ whileElementsMounted,
2158
+ open
2159
+ } = options;
2160
+ const [data, setData] = React__namespace.useState({
2161
+ x: 0,
2162
+ y: 0,
2163
+ strategy,
2164
+ placement,
2165
+ middlewareData: {},
2166
+ isPositioned: false
2167
+ });
2168
+ const [latestMiddleware, setLatestMiddleware] = React__namespace.useState(middleware);
2169
+ if (!deepEqual(latestMiddleware, middleware)) {
2170
+ setLatestMiddleware(middleware);
2171
+ }
2172
+ const [_reference, _setReference] = React__namespace.useState(null);
2173
+ const [_floating, _setFloating] = React__namespace.useState(null);
2174
+ const setReference = React__namespace.useCallback(node => {
2175
+ if (node !== referenceRef.current) {
2176
+ referenceRef.current = node;
2177
+ _setReference(node);
2178
+ }
2179
+ }, []);
2180
+ const setFloating = React__namespace.useCallback(node => {
2181
+ if (node !== floatingRef.current) {
2182
+ floatingRef.current = node;
2183
+ _setFloating(node);
2184
+ }
2185
+ }, []);
2186
+ const referenceEl = externalReference || _reference;
2187
+ const floatingEl = externalFloating || _floating;
2188
+ const referenceRef = React__namespace.useRef(null);
2189
+ const floatingRef = React__namespace.useRef(null);
2190
+ const dataRef = React__namespace.useRef(data);
2191
+ const hasWhileElementsMounted = whileElementsMounted != null;
2192
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2193
+ const platformRef = useLatestRef(platform);
2194
+ const openRef = useLatestRef(open);
2195
+ const update = React__namespace.useCallback(() => {
2196
+ if (!referenceRef.current || !floatingRef.current) {
2197
+ return;
2198
+ }
2199
+ const config = {
2200
+ placement,
2201
+ strategy,
2202
+ middleware: latestMiddleware
2203
+ };
2204
+ if (platformRef.current) {
2205
+ config.platform = platformRef.current;
2206
+ }
2207
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
2208
+ const fullData = {
2209
+ ...data,
2210
+ // The floating element's position may be recomputed while it's closed
2211
+ // but still mounted (such as when transitioning out). To ensure
2212
+ // `isPositioned` will be `false` initially on the next open, avoid
2213
+ // setting it to `true` when `open === false` (must be specified).
2214
+ isPositioned: openRef.current !== false
2215
+ };
2216
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2217
+ dataRef.current = fullData;
2218
+ ReactDOM__namespace.flushSync(() => {
2219
+ setData(fullData);
2220
+ });
2221
+ }
2222
+ });
2223
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2224
+ index(() => {
2225
+ if (open === false && dataRef.current.isPositioned) {
2226
+ dataRef.current.isPositioned = false;
2227
+ setData(data => ({
2228
+ ...data,
2229
+ isPositioned: false
2230
+ }));
2231
+ }
2232
+ }, [open]);
2233
+ const isMountedRef = React__namespace.useRef(false);
2234
+ index(() => {
2235
+ isMountedRef.current = true;
2236
+ return () => {
2237
+ isMountedRef.current = false;
2238
+ };
2239
+ }, []);
2240
+ index(() => {
2241
+ if (referenceEl) referenceRef.current = referenceEl;
2242
+ if (floatingEl) floatingRef.current = floatingEl;
2243
+ if (referenceEl && floatingEl) {
2244
+ if (whileElementsMountedRef.current) {
2245
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2246
+ }
2247
+ update();
2248
+ }
2249
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2250
+ const refs = React__namespace.useMemo(() => ({
2251
+ reference: referenceRef,
2252
+ floating: floatingRef,
2253
+ setReference,
2254
+ setFloating
2255
+ }), [setReference, setFloating]);
2256
+ const elements = React__namespace.useMemo(() => ({
2257
+ reference: referenceEl,
2258
+ floating: floatingEl
2259
+ }), [referenceEl, floatingEl]);
2260
+ const floatingStyles = React__namespace.useMemo(() => {
2261
+ const initialStyles = {
2262
+ position: strategy,
2263
+ left: 0,
2264
+ top: 0
2265
+ };
2266
+ if (!elements.floating) {
2267
+ return initialStyles;
2268
+ }
2269
+ const x = roundByDPR(elements.floating, data.x);
2270
+ const y = roundByDPR(elements.floating, data.y);
2271
+ if (transform) {
2272
+ return {
2273
+ ...initialStyles,
2274
+ transform: "translate(" + x + "px, " + y + "px)",
2275
+ ...(getDPR(elements.floating) >= 1.5 && {
2276
+ willChange: 'transform'
2277
+ })
2278
+ };
2279
+ }
2280
+ return {
2281
+ position: strategy,
2282
+ left: x,
2283
+ top: y
2284
+ };
2285
+ }, [strategy, transform, elements.floating, data.x, data.y]);
2286
+ return React__namespace.useMemo(() => ({
2287
+ ...data,
2288
+ update,
2289
+ refs,
2290
+ elements,
2291
+ floatingStyles
2292
+ }), [data, update, refs, elements, floatingStyles]);
2293
+ }
102
2294
 
103
- var DELAY_DURATION = 500;
2295
+ /**
2296
+ * Modifies the placement by translating the floating element along the
2297
+ * specified axes.
2298
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2299
+ * object may be passed.
2300
+ * @see https://floating-ui.com/docs/offset
2301
+ */
2302
+ const offset = (options, deps) => ({
2303
+ ...offset$1(options),
2304
+ options: [options, deps]
2305
+ });
104
2306
 
105
- var NavigationHeaderInlineAction = function (_a) {
106
- var icon = _a.icon, text = _a.text, href = _a.href, onClick = _a.onClick;
107
- var surface = React.useContext(Surface.Context).surface;
108
- var commonClasses = [
109
- "arc-NavigationHeaderInlineAction",
110
- suffixModifier.suffixModifier("arc-NavigationHeaderInlineAction--on", surface),
111
- ];
112
- return (React.createElement(ConditionalWrapper.ConditionalWrapper, { condition: Boolean(href), wrapper: function (children) { return (React.createElement("a", { "aria-label": text, className: index.classNames.apply(void 0, tslib_es6.__spreadArray(tslib_es6.__spreadArray([], commonClasses, false), ["arc-NavigationHeaderInlineAction-link"], false)), href: href, onClick: onClick }, children)); }, fallback: function (children) { return (React.createElement("button", { "aria-label": text, className: index.classNames.apply(void 0, tslib_es6.__spreadArray(tslib_es6.__spreadArray([], commonClasses, false), ["arc-NavigationHeaderInlineAction-button"], false)), onClick: onClick }, children)); } },
113
- React.createElement("div", { className: "arc-NavigationHeaderInlineAction-content" },
114
- React.createElement(Icon.Icon, { "aria-hidden": true, icon: icon, size: 28 }),
115
- React.createElement(Text.Text, { size: "l" }, text))));
2307
+ /**
2308
+ * Provides data that allows you to change the size of the floating element —
2309
+ * for instance, prevent it from overflowing the clipping boundary or match the
2310
+ * width of the reference element.
2311
+ * @see https://floating-ui.com/docs/size
2312
+ */
2313
+ const size = (options, deps) => ({
2314
+ ...size$1(options),
2315
+ options: [options, deps]
2316
+ });
2317
+
2318
+ // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
2319
+ const SafeReact = {
2320
+ ...React__namespace
116
2321
  };
117
2322
 
118
- var NavigationHeaderButton = function (_a) {
119
- var ref = _a.ref, isActive = _a.isActive, children = _a.children, onClick = _a.onClick, _b = _a.isPadded, isPadded = _b === void 0 ? true : _b, props = tslib_es6.__rest(_a, ["ref", "isActive", "children", "onClick", "isPadded"]);
120
- var surface = React.useContext(Surface.Context).surface;
121
- return (React.createElement("button", tslib_es6.__assign({}, props, { ref: ref, onClick: onClick, className: index.classNames("arc-NavigationHeaderButton", suffixModifier.suffixModifier("arc-NavigationHeaderButton--on", surface), {
122
- "arc-NavigationHeaderButton--active": isActive,
123
- "arc-NavigationHeaderButton--padded": isPadded,
124
- }) }), children));
125
- };
2323
+ let serverHandoffComplete = false;
2324
+ let count = 0;
2325
+ const genId = () => // Ensure the id is unique with multiple independent versions of Floating UI
2326
+ // on <React 18
2327
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
2328
+ function useFloatingId() {
2329
+ const [id, setId] = React__namespace.useState(() => serverHandoffComplete ? genId() : undefined);
2330
+ index$1(() => {
2331
+ if (id == null) {
2332
+ setId(genId());
2333
+ }
2334
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2335
+ }, []);
2336
+ React__namespace.useEffect(() => {
2337
+ serverHandoffComplete = true;
2338
+ }, []);
2339
+ return id;
2340
+ }
2341
+ const useReactId = SafeReact.useId;
126
2342
 
127
- var NavigationHeaderDisclosure = function (_a) {
128
- var heading = _a.heading, children = _a.children;
129
- var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
130
- var surface = React.useContext(Surface.Context).surface;
131
- var containerRef = React.useRef(null);
132
- var handleOnClick = function (e) {
133
- e.preventDefault();
134
- setIsOpen(function (isOpen) { return !isOpen; });
135
- };
136
- React.useEffect(function () {
137
- if (containerRef.current && containerRef.current.firstChild && isOpen) {
138
- containerRef.current.firstChild.focus();
139
- }
140
- }, [isOpen]);
141
- return (React.createElement("details", { className: index.classNames("arc-NavigationHeaderDisclosure", suffixModifier.suffixModifier("arc-NavigationHeaderDisclosure--on", surface)), open: isOpen },
142
- React.createElement("summary", { "aria-expanded": isOpen, onClick: handleOnClick, className: "arc-NavigationHeaderDisclosure-summary" },
143
- React.createElement("span", { className: "arc-NavigationHeaderDisclosure-heading" }, heading),
144
- React.createElement("span", { className: "arc-NavigationHeaderDisclosure-icon" },
145
- React.createElement(Visible.Visible, { xs: true, s: true },
146
- React.createElement(ThemeIcon.ThemeIcon, { size: 20, icon: "navigationHeaderDisclosure" })),
147
- React.createElement(Visible.Visible, { m: true, l: true },
148
- React.createElement(ThemeIcon.ThemeIcon, { size: 24, icon: "navigationHeaderDisclosure" })),
149
- React.createElement(Visible.Visible, { xl: true, xxl: true },
150
- React.createElement(ThemeIcon.ThemeIcon, { size: 28, icon: "navigationHeaderDisclosure" })))),
151
- React.createElement("div", { ref: containerRef, className: "arc-NavigationHeaderDisclosure-details" }, children)));
152
- };
2343
+ /**
2344
+ * Uses React 18's built-in `useId()` when available, or falls back to a
2345
+ * slightly less performant (requiring a double render) implementation for
2346
+ * earlier React versions.
2347
+ * @see https://floating-ui.com/docs/react-utils#useid
2348
+ */
2349
+ const useId = useReactId || useFloatingId;
153
2350
 
154
- var NavigationHeaderMenuLink = function (_a) {
155
- var href = _a.href, onClick = _a.onClick, text = _a.text, _b = _a.size, size = _b === void 0 ? "l" : _b;
156
- var surface = React.useContext(Surface.Context).surface;
157
- return (React.createElement("a", { "aria-label": text, href: href, onClick: onClick, className: index.classNames("arc-NavigationHeaderMenuLink", suffixModifier.suffixModifier("arc-NavigationHeaderMenuLink--on", surface), suffixModifier.suffixModifier("arc-NavigationHeaderMenuLink--size", size)) },
158
- React.createElement("div", { className: "arc-NavigationHeaderMenuLink-text" }, text),
159
- React.createElement("span", { className: "arc-NavigationHeaderMenuLink-icon" },
160
- size === "s" && (React.createElement("div", { className: "arc-NavigationHeaderMenuLink-smallIconContainer" },
161
- React.createElement(ThemeIcon.ThemeIcon, { icon: "navigationHeaderMenuLinkSmall" }))),
162
- size === "l" && (React.createElement(React.Fragment, null,
163
- React.createElement(Visible.Visible, { xs: true, s: true },
164
- React.createElement(ThemeIcon.ThemeIcon, { size: 20, icon: "navigationHeaderMenuLinkLarge" })),
165
- React.createElement(Visible.Visible, { m: true, l: true },
166
- React.createElement(ThemeIcon.ThemeIcon, { size: 24, icon: "navigationHeaderMenuLinkLarge" })),
167
- React.createElement(Visible.Visible, { xl: true, xxl: true },
168
- React.createElement(ThemeIcon.ThemeIcon, { size: 28, icon: "navigationHeaderMenuLinkLarge" })))))));
169
- };
2351
+ let devMessageSet;
2352
+ if (process.env.NODE_ENV !== "production") {
2353
+ devMessageSet = /*#__PURE__*/new Set();
2354
+ }
2355
+ function error() {
2356
+ var _devMessageSet3;
2357
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2358
+ messages[_key2] = arguments[_key2];
2359
+ }
2360
+ const message = "Floating UI: " + messages.join(' ');
2361
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
2362
+ var _devMessageSet4;
2363
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
2364
+ console.error(message);
2365
+ }
2366
+ }
170
2367
 
171
- var NavigationHeaderCloseButton = function (_a) {
172
- var ref = _a.ref, onClick = _a.onClick, props = tslib_es6.__rest(_a, ["ref", "onClick"]);
173
- var surface = React.useContext(Surface.Context).surface;
174
- return (React.createElement("button", tslib_es6.__assign({}, props, { ref: ref, "aria-label": "close", onClick: onClick, className: index.classNames("arc-NavigationHeaderCloseButton", suffixModifier.suffixModifier("arc-NavigationHeaderCloseButton--on", surface)) }),
175
- React.createElement(ThemeIcon.ThemeIcon, { size: 32, icon: "navigationHeaderClose" })));
176
- };
2368
+ function createEventEmitter() {
2369
+ const map = new Map();
2370
+ return {
2371
+ emit(event, data) {
2372
+ var _map$get;
2373
+ (_map$get = map.get(event)) == null || _map$get.forEach(listener => listener(data));
2374
+ },
2375
+ on(event, listener) {
2376
+ if (!map.has(event)) {
2377
+ map.set(event, new Set());
2378
+ }
2379
+ map.get(event).add(listener);
2380
+ },
2381
+ off(event, listener) {
2382
+ var _map$get2;
2383
+ (_map$get2 = map.get(event)) == null || _map$get2.delete(listener);
2384
+ }
2385
+ };
2386
+ }
177
2387
 
178
- var NavigationHeaderBurgerMenu = function (_a) {
179
- var navItems = _a.navItems, actions = _a.actions, header = _a.header, footer = _a.footer, logo = _a.logo, background = _a.background, onOpenChange = _a.onOpenChange, _b = _a.pathway, pathway = _b === void 0 ? "invert" : _b;
180
- var id = React.useId();
181
- var _c = React.useState(false), isOpen = _c[0], setIsOpen = _c[1];
182
- var triggerRef = React.useRef(null);
183
- var listRef = React.useRef(null);
184
- var interactionMode = useInteractionMode().interactionMode;
185
- var _d = index$1.useThemeElement(), themeElement = _d[0], setThemeElement = _d[1];
186
- var closeMenu = function () {
187
- setIsOpen(false);
188
- };
189
- var focusTriggerElement = function () {
190
- if (triggerRef.current && interactionMode === "keyboard") {
191
- triggerRef.current.focus();
192
- }
193
- };
194
- React.useEffect(function () {
195
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(isOpen);
196
- }, [isOpen, onOpenChange]);
197
- // Close the menu if the nav or trigger is hidden
198
- React.useEffect(function () {
199
- var trigger = triggerRef.current;
200
- var resizeObserver = new ResizeObserver(function (entries) {
201
- var entry = entries[0];
202
- if (!checkElementVisibility(entry.target) && isOpen) {
203
- setIsOpen(false);
204
- }
205
- });
206
- if (trigger) {
207
- resizeObserver.observe(trigger);
208
- }
209
- return function () {
210
- if (trigger) {
211
- resizeObserver.unobserve(trigger);
212
- }
213
- };
214
- }, [isOpen, setIsOpen]);
215
- var colorScheme = React.useMemo(function () {
216
- var colorConfig = {
217
- light: {
218
- surface: "light-white",
219
- menuColorType: "light",
220
- },
221
- dark: {
222
- surface: "dark-black",
223
- menuColorType: "dark",
224
- },
225
- };
226
- switch (background) {
227
- case "transparentOnDark":
228
- case "ghostedOnDark":
229
- return pathway === "invert" ? colorConfig.light : colorConfig.dark;
230
- default:
231
- return pathway === "invert" ? colorConfig.dark : colorConfig.light;
232
- }
233
- }, [pathway, background]);
234
- return (React.createElement(React.Fragment, null,
235
- React.createElement(Tooltip.Tooltip, { delayDuration: DELAY_DURATION, asChild: true, title: "Menu", side: "bottom" },
236
- React.createElement(NavigationHeaderButton, { ref: triggerRef, isPadded: false, "aria-expanded": isOpen, "aria-label": isOpen ? "close menu" : "open menu", onClick: function () { return setIsOpen(!isOpen); } },
237
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-trigger" },
238
- React.createElement(ThemeIcon.ThemeIcon, { icon: "siteHeaderBurger", size: 24 })),
239
- React.createElement(VisuallyHidden.VisuallyHidden, null, isOpen ? "close menu" : "open menu"))),
240
- React.createElement("div", { ref: setThemeElement },
241
- React.createElement(index$2.Root, { open: isOpen },
242
- React.createElement(index$2.Portal, { container: themeElement },
243
- React.createElement(index$2.Overlay, { className: "arc-NavigationHeaderBurgerMenu-overlay" },
244
- React.createElement(index$2.Content, { "aria-describedby": undefined, className: index.classNames("arc-NavigationHeaderBurgerMenu-slider", suffixModifier.suffixModifier("arc-NavigationHeaderBurgerMenu-slider--on", colorScheme.menuColorType)), onCloseAutoFocus: focusTriggerElement, onEscapeKeyDown: closeMenu, onInteractOutside: closeMenu, "aria-modal": "true" },
245
- React.createElement(Surface.Surface, { growVertically: true, isTransparent: true, background: colorScheme.surface },
246
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-container" },
247
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-mainContent" },
248
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-header" },
249
- React.createElement(index$2.Title, null,
250
- React.createElement(VisuallyHidden.VisuallyHidden, null, "Navigation menu")),
251
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-closeButtonContainer" },
252
- React.createElement(NavigationHeaderCloseButton, { onClick: closeMenu })),
253
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-logoContainer" },
254
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-logoWrapper" },
255
- React.createElement(NavigationHeaderLogo, tslib_es6.__assign({}, logo))))),
256
- header && (React.createElement("div", { className: index.classNames("arc-NavigationHeaderBurgerMenu-topContent", {
257
- "arc-NavigationHeaderBurgerMenu-topContent--bottomSpacing": !navItems,
258
- }) }, header)),
259
- navItems && (React.createElement("ul", { ref: listRef, className: "arc-NavigationHeaderBurgerMenu-list" }, navItems.map(function (navItem, navItemIndex) { return (React.createElement(React.Fragment, { key: "".concat(id, "-burger-nav-item-").concat(navItemIndex) },
260
- React.createElement("li", { className: "arc-NavigationHeaderBurgerMenu-listItem" },
261
- React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-listItemContent" },
262
- (navItem.type === "link" ||
263
- navItem.type === "meatball") && (React.createElement(NavigationHeaderMenuLink, { href: navItem.href, onClick: navItem.onClick, text: navItem.text })),
264
- (navItem.type === "subnav" ||
265
- navItem.type === "dropdown") && (React.createElement(NavigationHeaderDisclosure, { heading: navItem.text }, navItem.items.map(function (subNavItem, subNavItemIndex) { return (React.createElement(NavigationHeaderMenuLink, { size: "s", key: "".concat(id, "-").concat(navItemIndex, "-burger-sub-nav-item-").concat(subNavItemIndex), href: subNavItem.href, onClick: subNavItem.onClick, text: subNavItem.text })); }))))))); }))),
266
- actions && (React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-actionsContainer" },
267
- React.createElement("div", { className: index.classNames("arc-NavigationHeaderBurgerMenu-actions", {
268
- "arc-NavigationHeaderBurgerMenu-actions--seperator": navItems || header,
269
- }) }, actions.map(function (props, i) { return (React.createElement(NavigationHeaderInlineAction, tslib_es6.__assign({ key: "".concat(id, "-action-{").concat(i, "}") }, props))); }))))),
270
- footer && (React.createElement("div", { className: "arc-NavigationHeaderBurgerMenu-footer" }, footer)))))))))));
271
- };
2388
+ const FloatingNodeContext = /*#__PURE__*/React__namespace.createContext(null);
2389
+ const FloatingTreeContext = /*#__PURE__*/React__namespace.createContext(null);
272
2390
 
273
- var NavigationHeaderNavLink = function (_a) {
274
- var text = _a.text, onClick = _a.onClick, href = _a.href, _b = _a.borderRadiusSize, borderRadiusSize = _b === void 0 ? "s" : _b;
275
- var surface = React.useContext(Surface.Context).surface;
276
- return (React.createElement("a", { href: href, onClick: onClick, className: index.classNames("arc-NavigationHeaderNavLink", suffixModifier.suffixModifier("arc-NavigationHeaderNavLink--borderRadiusSize", borderRadiusSize), suffixModifier.suffixModifier("arc-NavigationHeaderNavLink--on", surface)) },
277
- React.createElement(Text.Text, null, text)));
2391
+ /**
2392
+ * Returns the parent node id for nested floating elements, if available.
2393
+ * Returns `null` for top-level floating elements.
2394
+ */
2395
+ const useFloatingParentNodeId = () => {
2396
+ var _React$useContext;
2397
+ return ((_React$useContext = React__namespace.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
278
2398
  };
279
2399
 
280
- // src/get-focusable-elements/get-focusable-elements.ts
281
- var getFocusableElements = (rootElement) => {
282
- const nodes = [];
283
- const walker = document.createTreeWalker(
284
- rootElement,
285
- NodeFilter.SHOW_ELEMENT,
286
- {
287
- acceptNode: (node) => {
288
- const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
289
- if (node.disabled || node.hidden || isHiddenInput || !checkElementVisibility(node))
290
- return NodeFilter.FILTER_SKIP;
291
- return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
292
- }
2400
+ /**
2401
+ * Returns the nearest floating tree context, if available.
2402
+ */
2403
+ const useFloatingTree = () => React__namespace.useContext(FloatingTreeContext);
2404
+
2405
+ function useFloatingRootContext(options) {
2406
+ const {
2407
+ open = false,
2408
+ onOpenChange: onOpenChangeProp,
2409
+ elements: elementsProp
2410
+ } = options;
2411
+ const floatingId = useId();
2412
+ const dataRef = React__namespace.useRef({});
2413
+ const [events] = React__namespace.useState(() => createEventEmitter());
2414
+ const nested = useFloatingParentNodeId() != null;
2415
+ if (process.env.NODE_ENV !== "production") {
2416
+ const optionDomReference = elementsProp.reference;
2417
+ if (optionDomReference && !isElement(optionDomReference)) {
2418
+ error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
293
2419
  }
294
- );
295
- while (walker.nextNode()) nodes.push(walker.currentNode);
296
- return nodes;
297
- };
2420
+ }
2421
+ const [positionReference, setPositionReference] = React__namespace.useState(elementsProp.reference);
2422
+ const onOpenChange = useEffectEvent((open, event, reason) => {
2423
+ dataRef.current.openEvent = open ? event : undefined;
2424
+ events.emit('openchange', {
2425
+ open,
2426
+ event,
2427
+ reason,
2428
+ nested
2429
+ });
2430
+ onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
2431
+ });
2432
+ const refs = React__namespace.useMemo(() => ({
2433
+ setPositionReference
2434
+ }), []);
2435
+ const elements = React__namespace.useMemo(() => ({
2436
+ reference: positionReference || elementsProp.reference || null,
2437
+ floating: elementsProp.floating || null,
2438
+ domReference: elementsProp.reference
2439
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
2440
+ return React__namespace.useMemo(() => ({
2441
+ dataRef,
2442
+ open,
2443
+ onOpenChange,
2444
+ elements,
2445
+ events,
2446
+ floatingId,
2447
+ refs
2448
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
2449
+ }
298
2450
 
299
- var NavigationHeaderContext = React.createContext(null);
2451
+ /**
2452
+ * Provides data to position a floating element and context to add interactions.
2453
+ * @see https://floating-ui.com/docs/useFloating
2454
+ */
2455
+ function useFloating(options) {
2456
+ if (options === void 0) {
2457
+ options = {};
2458
+ }
2459
+ const {
2460
+ nodeId
2461
+ } = options;
2462
+ const internalRootContext = useFloatingRootContext({
2463
+ ...options,
2464
+ elements: {
2465
+ reference: null,
2466
+ floating: null,
2467
+ ...options.elements
2468
+ }
2469
+ });
2470
+ const rootContext = options.rootContext || internalRootContext;
2471
+ const computedElements = rootContext.elements;
2472
+ const [_domReference, setDomReference] = React__namespace.useState(null);
2473
+ const [positionReference, _setPositionReference] = React__namespace.useState(null);
2474
+ const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;
2475
+ const domReference = optionDomReference || _domReference;
2476
+ const domReferenceRef = React__namespace.useRef(null);
2477
+ const tree = useFloatingTree();
2478
+ index$1(() => {
2479
+ if (domReference) {
2480
+ domReferenceRef.current = domReference;
2481
+ }
2482
+ }, [domReference]);
2483
+ const position = useFloating$1({
2484
+ ...options,
2485
+ elements: {
2486
+ ...computedElements,
2487
+ ...(positionReference && {
2488
+ reference: positionReference
2489
+ })
2490
+ }
2491
+ });
2492
+ const setPositionReference = React__namespace.useCallback(node => {
2493
+ const computedPositionReference = isElement(node) ? {
2494
+ getBoundingClientRect: () => node.getBoundingClientRect(),
2495
+ getClientRects: () => node.getClientRects(),
2496
+ contextElement: node
2497
+ } : node;
2498
+ // Store the positionReference in state if the DOM reference is specified externally via the
2499
+ // `elements.reference` option. This ensures that it won't be overridden on future renders.
2500
+ _setPositionReference(computedPositionReference);
2501
+ position.refs.setReference(computedPositionReference);
2502
+ }, [position.refs]);
2503
+ const setReference = React__namespace.useCallback(node => {
2504
+ if (isElement(node) || node === null) {
2505
+ domReferenceRef.current = node;
2506
+ setDomReference(node);
2507
+ }
300
2508
 
301
- var NavigationHeaderDropdown = function (_a) {
302
- var children = _a.children, trigger = _a.trigger, ariaLabel = _a.ariaLabel, tooltip = _a.tooltip;
303
- var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
304
- var triggerRef = React.useRef(null);
305
- var containerRef = React.useRef(null);
306
- var _c = React.useState(false), isTooltipOpen = _c[0], setIsTooltipOpen = _c[1];
307
- var interactionMode = useInteractionMode().interactionMode;
308
- var navigationHeaderContext = React.useContext(NavigationHeaderContext);
309
- // Close the dropdown if the nav or trigger is hidden
310
- React.useEffect(function () {
311
- var trigger = triggerRef.current;
312
- var resizeObserver = new ResizeObserver(function (entries) {
313
- var entry = entries[0];
314
- if (!checkElementVisibility(entry.target) && isOpen) {
315
- setIsOpen(false);
316
- setIsTooltipOpen(false);
317
- }
318
- });
319
- if (trigger) {
320
- resizeObserver.observe(trigger);
321
- }
322
- return function () {
323
- if (trigger) {
324
- resizeObserver.unobserve(trigger);
325
- }
326
- };
327
- }, [isOpen, setIsOpen, navigationHeaderContext]);
328
- // if focus isnt going anywhere else and closed via keyboard, return focus to the trigger
329
- var onCloseAutoFocus = function () {
330
- var _a, _b;
331
- if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName) === "BODY" &&
332
- interactionMode === "keyboard") {
333
- (_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.focus();
334
- }
335
- };
336
- // Only count it as an outside interaction if the trigger isnt being clicked.
337
- var handleOutSideInteraction = function (event) {
338
- var _a;
339
- if (!((_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.currentTarget))) {
340
- setIsOpen(false);
341
- }
342
- };
343
- // Find the first focusable element.
344
- var focusOnFirstElement = function () {
345
- getFocusableElements(containerRef.current)[0].focus();
346
- };
347
- var toggleVisibility = function () { return setIsOpen(function (isOpen) { return !isOpen; }); };
348
- return (React.createElement(Popover.Popover, { useBespokeTrigger: true, align: "center", background: "light", arrow: true, sideOffset: 12, alignOffset: 0, open: isOpen, onCloseAutoFocus: onCloseAutoFocus, onOpenAutoFocus: focusOnFirstElement, onEscapeKeyDown: handleOutSideInteraction, onFocusOutside: handleOutSideInteraction, onInteractOutside: handleOutSideInteraction, onPointerDownOutside: handleOutSideInteraction, content: React.createElement("div", { ref: containerRef },
349
- React.createElement("ul", { className: "arc-NavigationHeaderDropdown-navList" }, children)) }, tooltip ? (React.createElement(Tooltip.Tooltip, { asChild: true, title: tooltip, open: isTooltipOpen, alignContent: "center", side: "bottom" },
350
- React.createElement(NavigationHeaderButton, { ref: triggerRef, "aria-label": ariaLabel, "aria-expanded": isOpen, "aria-haspopup": "dialog", "aria-describedby": undefined, isActive: isOpen, onClick: toggleVisibility, onMouseEnter: function () { return setIsTooltipOpen(!isOpen); }, onMouseLeave: function () { return setIsTooltipOpen(false); }, onFocus: function () { return setIsTooltipOpen(true); }, onBlur: function () { return setIsTooltipOpen(false); } }, trigger))) : (React.createElement(NavigationHeaderButton, { ref: triggerRef, "aria-label": ariaLabel, "aria-expanded": isOpen, "aria-haspopup": "dialog", isActive: isOpen, onClick: toggleVisibility }, trigger))));
351
- };
2509
+ // Backwards-compatibility for passing a virtual element to `reference`
2510
+ // after it has set the DOM reference.
2511
+ if (isElement(position.refs.reference.current) || position.refs.reference.current === null ||
2512
+ // Don't allow setting virtual elements using the old technique back to
2513
+ // `null` to support `positionReference` + an unstable `reference`
2514
+ // callback ref.
2515
+ node !== null && !isElement(node)) {
2516
+ position.refs.setReference(node);
2517
+ }
2518
+ }, [position.refs]);
2519
+ const refs = React__namespace.useMemo(() => ({
2520
+ ...position.refs,
2521
+ setReference,
2522
+ setPositionReference,
2523
+ domReference: domReferenceRef
2524
+ }), [position.refs, setReference, setPositionReference]);
2525
+ const elements = React__namespace.useMemo(() => ({
2526
+ ...position.elements,
2527
+ domReference: domReference
2528
+ }), [position.elements, domReference]);
2529
+ const context = React__namespace.useMemo(() => ({
2530
+ ...position,
2531
+ ...rootContext,
2532
+ refs,
2533
+ elements,
2534
+ nodeId
2535
+ }), [position, refs, elements, nodeId, rootContext]);
2536
+ index$1(() => {
2537
+ rootContext.dataRef.current.floatingContext = context;
2538
+ const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
2539
+ if (node) {
2540
+ node.context = context;
2541
+ }
2542
+ });
2543
+ return React__namespace.useMemo(() => ({
2544
+ ...position,
2545
+ context,
2546
+ refs,
2547
+ elements
2548
+ }), [position, refs, elements, context]);
2549
+ }
352
2550
 
353
- var NavigationHeaderContainer = function (_a) {
354
- var _b = _a.isPill, isPill = _b === void 0 ? false : _b, _c = _a.isExtended, isExtended = _c === void 0 ? false : _c, _d = _a.isFluid, isFluid = _d === void 0 ? false : _d, background = _a.background, children = _a.children;
355
- var backgrounds = {
356
- light: {
357
- surface: "light-white",
358
- classSuffix: "backgroundLight",
359
- },
360
- neutral: {
361
- surface: "light-white",
362
- classSuffix: "backgroundNeutral",
363
- },
364
- lightElevated: {
365
- surface: "light-white",
366
- classSuffix: "backgroundLightElevated",
367
- },
368
- transparentOnDark: {
369
- surface: "dark-black",
370
- classSuffix: "backgroundTransparent",
371
- },
372
- transparentOnLight: {
373
- surface: "light-white",
374
- classSuffix: "backgroundTransparent",
375
- },
376
- ghostedOnLight: {
377
- surface: "light-white",
378
- classSuffix: "backgroundGhosted",
379
- },
380
- ghostedOnDark: {
381
- surface: "dark-black",
382
- classSuffix: "backgroundGhosted",
383
- },
384
- };
385
- return (React.createElement("div", { "data-testid": "NavigationHeader-container", className: index.classNames("arc-NavigationHeaderContainer", "arc-NavigationHeaderContainer--".concat(backgrounds[background].classSuffix), {
386
- "arc-NavigationHeaderContainer--pill": isPill,
387
- "arc-NavigationHeaderContainer--fullWidth": !isPill,
388
- "arc-NavigationHeaderContainer--regular": !isExtended,
389
- "arc-NavigationHeaderContainer--extended": isExtended,
390
- "arc-NavigationHeaderContainer--fluid": isFluid,
391
- }) },
392
- React.createElement("div", { className: "arc-NavigationHeaderContainer-outer" },
393
- React.createElement(Surface.Surface, { isTransparent: true, background: backgrounds[background].surface },
394
- React.createElement("div", { className: "arc-NavigationHeaderContainer-contentWrapper" },
395
- React.createElement("div", { className: "arc-NavigationHeaderContainer-inner" },
396
- React.createElement("div", { className: "arc-NavigationHeaderContainer-content" }, children)))))));
397
- };
2551
+ var _a = createNavigationHeaderContext("NavigationHeader sub components must be used within NavigationHeader"), NavigationHeaderContext = _a[0], useNavigationHeaderContext = _a[1];
398
2552
 
399
- var NavigationHeaderSubnav = function (_a) {
400
- var _b;
401
- var trigger = _a.trigger, ariaLabel = _a.ariaLabel, children = _a.children;
402
- var _c = React.useState(false), isOpen = _c[0], setIsOpen = _c[1];
403
- var navigationHeaderContext = React.useContext(NavigationHeaderContext);
404
- var containerRef = React.useRef(null);
2553
+ var NavigationHeaderSubnavContent = function (_a) {
2554
+ var children = _a.children, background = _a.background, menuTitle = _a.menuTitle;
2555
+ var navigationHeaderContext = useNavigationHeaderContext();
2556
+ var subNavContext = useSubNavContext();
405
2557
  var dialogRef = React.useRef(null);
406
- var listRef = React.useRef(null);
407
- var triggerRef = React.useRef(null);
2558
+ var childContainerRef = React.useRef(null);
2559
+ var _b = index$3.useThemeElement(), themeElement = _b[0], setThemeElement = _b[1];
2560
+ var _c = React.useState("pointer"), interactionMode = _c[0], setInterActionMode = _c[1];
2561
+ var isOpen = subNavContext.isOpen, rootRef = subNavContext.rootRef, setIsOpen = subNavContext.setIsOpen, id = subNavContext.id;
2562
+ var _d = useFloating({
2563
+ whileElementsMounted: autoUpdate,
2564
+ elements: {
2565
+ reference: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.navBarEl,
2566
+ },
2567
+ placement: "bottom-end",
2568
+ middleware: [
2569
+ size({
2570
+ apply: function (_a) {
2571
+ var rects = _a.rects, elements = _a.elements;
2572
+ Object.assign(elements.floating.style, {
2573
+ width: "".concat(rects.reference.width, "px"),
2574
+ });
2575
+ },
2576
+ }),
2577
+ offset(navigationHeaderContext.isPill ? 12 : 0),
2578
+ ],
2579
+ }), subNavRefs = _d.refs, subNavFloatStyles = _d.floatingStyles;
408
2580
  // if focus isnt going anywhere else, return it to the trigger
409
2581
  var onCloseAutoFocus = function () {
410
- var _a, _b;
411
- if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName) === "BODY") {
412
- (_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.focus();
2582
+ var _a, _b, _c;
2583
+ if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName) === "BODY" &&
2584
+ interactionMode === "keyboard") {
2585
+ (_c = (_b = subNavContext.triggerRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.focus();
413
2586
  }
414
2587
  };
415
2588
  // close when escape key is pressed
416
2589
  var onEscapeKeyDown = function () {
2590
+ var _a;
2591
+ setInterActionMode("keyboard");
417
2592
  setIsOpen(false);
418
- navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.setIsSubMenuItemActive(false);
2593
+ (_a = subNavContext.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(subNavContext, false);
2594
+ };
2595
+ // close when escape key is pressed
2596
+ var onInteractOutside = function () {
2597
+ setInterActionMode("pointer");
419
2598
  };
420
2599
  // Find the first focusable element.
421
- var onOpenAutoFocus = function () {
422
- getFocusableElements(listRef.current)[0].focus();
2600
+ var onOpenAutoFocus = function (e) {
2601
+ e.preventDefault();
2602
+ var firstFocusable = getFocusableElements(childContainerRef.current)[0];
2603
+ if (firstFocusable) {
2604
+ firstFocusable.focus({ preventScroll: true });
2605
+ }
423
2606
  };
424
- // Toggle visibility when trigger is clicked
425
- var onTriggerClick = function () {
426
- setIsOpen(!isOpen);
427
- navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.setIsSubMenuItemActive(!isOpen);
2607
+ var onContainerMouseDown = function () {
2608
+ setInterActionMode("pointer");
2609
+ };
2610
+ var onContainerKeyDown = function () {
2611
+ setInterActionMode("keyboard");
428
2612
  };
429
2613
  React.useEffect(function () {
430
- var handleClickOutside = function (event) {
2614
+ if (!isOpen)
2615
+ return;
2616
+ var clickListener = function (event) {
2617
+ var _a;
431
2618
  var target = event.target;
432
- var isThisTriggerClicked = containerRef.current && containerRef.current.contains(target);
433
- var otherSubNavItemClicked = !isThisTriggerClicked && target.getAttribute("data-sub-nav-item");
434
- var outSideSubnavClicked = !otherSubNavItemClicked &&
435
- dialogRef.current &&
436
- !dialogRef.current.contains(target);
437
- // dont do anything if the trigger was clicked, toggling is already handled.
2619
+ var isThisTriggerClicked = rootRef.current && rootRef.current.contains(target);
2620
+ var outSideSubnavClicked = dialogRef.current && !dialogRef.current.contains(target);
2621
+ // dont do anything if the click was on the trigger.
438
2622
  if (isThisTriggerClicked) {
439
2623
  return;
440
2624
  }
441
- // just hide the current menu if another one was clicked
442
- if (otherSubNavItemClicked) {
443
- setIsOpen(false);
444
- }
445
- // close and reset the navbar if clicking outside the dialog
2625
+ // close if clicking outside the dialog
446
2626
  if (outSideSubnavClicked) {
447
2627
  setIsOpen(false);
448
- navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.setIsSubMenuItemActive(false);
2628
+ (_a = subNavContext.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(subNavContext, false);
449
2629
  }
450
2630
  };
451
- document.addEventListener("click", handleClickOutside);
452
- return function () {
453
- document.removeEventListener("click", handleClickOutside);
454
- };
455
- }, [setIsOpen, navigationHeaderContext]);
456
- // Close the subnav if the trigger is hidden and the submenu is open
457
- React.useEffect(function () {
458
- var trigger = triggerRef.current;
459
- var resizeObserver = new ResizeObserver(function (entries) {
460
- var entry = entries[0];
461
- if (!checkElementVisibility(entry.target) && isOpen) {
462
- setIsOpen(false);
463
- navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.setIsSubMenuItemActive(false);
464
- }
465
- });
466
- if (trigger) {
467
- resizeObserver.observe(trigger);
468
- }
2631
+ document.addEventListener("click", clickListener);
469
2632
  return function () {
470
- if (trigger) {
471
- resizeObserver.unobserve(trigger);
472
- }
2633
+ document.removeEventListener("click", clickListener);
473
2634
  };
474
- }, [isOpen, setIsOpen, navigationHeaderContext]);
475
- return (React.createElement("div", { ref: containerRef },
476
- React.createElement(NavigationHeaderButton, { "data-sub-nav-item": true, ref: triggerRef, isActive: isOpen, "aria-label": ariaLabel, onClick: onTriggerClick }, trigger),
477
- React.createElement(index$2.Root, { open: isOpen, modal: false },
478
- React.createElement(index$2.Portal, { container: (_b = navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.navBarPortalRef) === null || _b === void 0 ? void 0 : _b.current },
479
- React.createElement("div", { className: "arc-NavigationHeaderSubnav" },
480
- React.createElement("div", { className: "arc-NavigationHeaderSubnav-container" },
481
- React.createElement(NavigationHeaderContainer, { isExtended: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.isExtended, isFluid: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.isFluid, isPill: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.isPill, background: "neutral" },
482
- React.createElement(index$2.Content, { ref: dialogRef, "aria-describedby": undefined, onEscapeKeyDown: onEscapeKeyDown, onCloseAutoFocus: onCloseAutoFocus, onOpenAutoFocus: onOpenAutoFocus },
483
- React.createElement("div", { className: "arc-NavigationHeaderSubnav-content" },
484
- React.createElement(VisuallyHidden.VisuallyHidden, null,
485
- React.createElement(index$2.Title, null,
486
- trigger,
487
- " sub menu")),
488
- React.createElement("ul", { ref: listRef, className: "arc-NavigationHeaderSubnav-navList" }, children))))))))));
2635
+ }, [isOpen, setIsOpen, rootRef, id, subNavContext]);
2636
+ return (React.createElement("div", { ref: setThemeElement, onMouseDown: onContainerMouseDown, onKeyDown: onContainerKeyDown },
2637
+ React.createElement(index$4.Root, { open: subNavContext.isOpen, modal: false },
2638
+ React.createElement(index$4.Portal, { container: themeElement },
2639
+ React.createElement("div", { className: "arc-NavigationHeaderSubnavContent", ref: subNavRefs.setFloating, style: subNavFloatStyles },
2640
+ React.createElement(NavigationHeaderContainer, { isExtended: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.isExtended, isFluid: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.isFluid, isPill: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.isPill, backgroundColor: background },
2641
+ React.createElement(index$4.Content, { className: "arc-NavigationHeaderSubnavContent-dialog", ref: dialogRef, "aria-describedby": undefined, onInteractOutside: onInteractOutside, onEscapeKeyDown: onEscapeKeyDown, onCloseAutoFocus: onCloseAutoFocus, onOpenAutoFocus: onOpenAutoFocus },
2642
+ React.createElement(VisuallyHidden.VisuallyHidden, null,
2643
+ React.createElement(index$4.Title, null, menuTitle)),
2644
+ React.createElement("div", { ref: childContainerRef }, children))),
2645
+ React.createElement(VerticalSpace.VerticalSpace, null))))));
2646
+ };
2647
+
2648
+ var NavigationHeaderMegaMenu = function (_a) {
2649
+ var tabs = _a.tabs, panelHeading = _a.panelHeading, featureCards = _a.featureCards, onClick = _a.onClick, onOpenChange = _a.onOpenChange, ariaLabel = _a.ariaLabel, text = _a.text;
2650
+ var id = React.useId();
2651
+ var getColumns = function (tab) { return [
2652
+ tab.items.filter(function (_, i) { return i % 2 === 0; }),
2653
+ tab.items.filter(function (_, i) { return i % 2 === 1; }),
2654
+ ]; };
2655
+ return (React.createElement(NavigationHeaderSubnav, { onOpenChange: onOpenChange },
2656
+ React.createElement(NavigationHeaderSubnavTrigger, { ariaLabel: ariaLabel, onClick: onClick }, text),
2657
+ React.createElement(NavigationHeaderSubnavContent, { background: "lightElevated", menuTitle: "".concat(text, " sub menu}") },
2658
+ React.createElement("div", { className: "arc-NavigationHeaderMegaMenu" },
2659
+ React.createElement("div", { className: "arc-NavigationHeaderMegaMenu-navCol" },
2660
+ React.createElement(NavigationHeaderPanelHeading, tslib_es6.__assign({}, panelHeading)),
2661
+ React.createElement(index$5.$69cb30bb0017df05$export$be92b6f5f03c0fe9, { orientation: "vertical", className: "arc-NavigationHeaderMegaMenu-nav", defaultValue: "".concat(tabs[0].triggerText, "-").concat(0) },
2662
+ React.createElement("div", { className: "arc-NavigationHeaderMegaMenu-tabs" },
2663
+ React.createElement(index$5.$69cb30bb0017df05$export$54c2e3dc7acea9f5, { className: "arc-NavigationHeaderMegaMenu-tabList" }, tabs.map(function (item, i) { return (React.createElement("div", { key: "".concat(id, "-NavigationHeader-megamenu-trigger-").concat(i), className: "arc-NavigationHeaderMegaMenu-tabWrapper" },
2664
+ React.createElement(index$5.$69cb30bb0017df05$export$41fb9f06171c75f4, { className: "arc-NavigationHeaderMegaMenu-tab", "aria-label": item.triggerText, value: "".concat(item.triggerText, "-").concat(i), onClick: item.onClick },
2665
+ React.createElement(Heading.Heading, { level: "3", size: "xs" }, item.triggerText)))); }))),
2666
+ React.createElement("div", { className: "arc-NavigationHeaderMegaMenu-mainContent" },
2667
+ React.createElement("div", { className: "arc-NavigationHeaderMegaMenu-linksPanel" }, tabs.map(function (tab, i) { return (React.createElement(index$5.$69cb30bb0017df05$export$7c6e2c02157bb7d2, { tabIndex: -1, className: "arc-NavigationHeaderMegaMenu-content", key: "".concat(id, "-NavigationHeader-megamenu-content-").concat(i), value: "".concat(tab.triggerText, "-").concat(i) },
2668
+ React.createElement(NavigationHeaderPanelLink, tslib_es6.__assign({}, tab.panelLink, { icon: tab.icon })),
2669
+ React.createElement(VerticalSpace.VerticalSpace, { size: "32" }),
2670
+ React.createElement("div", { className: "arc-NavigationHeaderMegaMenu-linksContainer" }, getColumns(tab).map(function (items, itemIndex) { return (React.createElement("div", { className: "arc-NavigationHeaderMegaMenu-linksColumn", key: "column-".concat(itemIndex) }, items.map(function (item, i) { return (React.createElement(NavigationHeaderCollapsingNavList, tslib_es6.__assign({}, item, { defaultOpen: true, revealLinkIconOnHover: true, autoFocusOnExpand: false, background: "light", key: "".concat(id, "-NavigationHeader-megamenu-item-").concat(i) }))); }))); })))); }))))),
2671
+ React.createElement("div", { className: "arc-NavigationHeaderMegaMenu-featureCol" }, featureCards && (React.createElement("div", { className: index$2.classNames("arc-NavigationHeaderMegaMenu-featureCardsPanel", {
2672
+ "arc-NavigationHeaderMegaMenu-featureCardsPanel--equalWidthColumns": featureCards.length <= 3,
2673
+ "arc-NavigationHeaderMegaMenu-featureCardsPanel--manyColumns": featureCards.length > 3,
2674
+ }) }, featureCards.map(function (card, i) { return (React.createElement(NavigationHeaderFeatureCard, tslib_es6.__assign({ key: "".concat(id, "-NavigationHeader-megamenu-featureCard-").concat(i) }, card))); }))))))));
2675
+ };
2676
+
2677
+ var NavigationHeaderCategoryLinks = function (_a) {
2678
+ var items = _a.items, panelHeading = _a.panelHeading, ariaLabel = _a.ariaLabel, onClick = _a.onClick, text = _a.text, onOpenChange = _a.onOpenChange;
2679
+ var id = React.useId();
2680
+ return (React.createElement(NavigationHeaderSubnav, { onOpenChange: onOpenChange },
2681
+ React.createElement(NavigationHeaderSubnavTrigger, { ariaLabel: ariaLabel, onClick: onClick }, text),
2682
+ React.createElement(NavigationHeaderSubnavContent, { background: "lightElevated", menuTitle: "".concat(text, " sub menu}") },
2683
+ React.createElement("div", { className: "arc-NavigationHeaderCategoryLinks" },
2684
+ React.createElement(NavigationHeaderPanelHeading, tslib_es6.__assign({}, panelHeading)),
2685
+ React.createElement("div", { className: "arc-NavigationHeaderCategoryLinks-container" }, items.map(function (item, i) { return (React.createElement("div", { key: "".concat(id, "-NavigationHeader-category-link-item-").concat(i) },
2686
+ React.createElement(NavigationHeaderCollapsingNavList, tslib_es6.__assign({}, item, { defaultOpen: true, revealLinkIconOnHover: true, autoFocusOnExpand: false, background: "light" })))); }))))));
2687
+ };
2688
+
2689
+ var NavigationHeaderLevelTwoLinks = function (_a) {
2690
+ var links = _a.links, children = _a.children;
2691
+ var id = React.useId();
2692
+ return (React.createElement("ul", { className: "arc-NavigationHeaderLevelTwoLinks" },
2693
+ links.map(function (navLink, i) { return (React.createElement("li", { key: "".concat(id, "-NavigationHeader-subnav-item-").concat(i) },
2694
+ React.createElement(NavigationHeaderNavLink, tslib_es6.__assign({}, navLink, { borderRadiusSize: "s" })))); }),
2695
+ children));
489
2696
  };
490
2697
 
491
2698
  var NavigationHeaderNavItem = function (_a) {
492
2699
  var navItem = _a.navItem;
493
- var id = React.useId();
494
2700
  return (React.createElement(React.Fragment, null,
495
2701
  navItem.type === "link" && (React.createElement(NavigationHeaderNavLink, tslib_es6.__assign({}, navItem, { borderRadiusSize: "m" }))),
496
- navItem.type === "dropdown" && (React.createElement(NavigationHeaderDropdown, { visibleFrom: navItem.visibleFrom, trigger: navItem.text, ariaLabel: navItem.ariaLabel }, navItem.items.map(function (navLink, i) { return (React.createElement("li", { key: "".concat(id, "-NavigationHeader-dropdown-item-").concat(i) },
497
- React.createElement(NavigationHeaderNavLink, tslib_es6.__assign({}, navLink)))); }))),
498
- navItem.type === "subnav" && (React.createElement(NavigationHeaderSubnav, { visibleFrom: navItem.visibleFrom, trigger: navItem.text, ariaLabel: navItem.ariaLabel }, navItem.items.map(function (navLink, i) { return (React.createElement("li", { key: "".concat(id, "-NavigationHeader-subnav-item-").concat(i) },
499
- React.createElement(NavigationHeaderNavLink, tslib_es6.__assign({}, navLink, { borderRadiusSize: "m" })))); })))));
2702
+ navItem.type === "levelTwo" && (React.createElement(NavigationHeaderDropdown, { trigger: navItem.text, onClick: navItem.onClick, ariaLabel: navItem.ariaLabel },
2703
+ React.createElement(NavigationHeaderLevelTwoLinks, { links: navItem.items }))),
2704
+ navItem.type === "categoryLinks" && (React.createElement(NavigationHeaderCategoryLinks, { onOpenChange: navItem.onOpenChange, ariaLabel: navItem.ariaLabel, onClick: navItem.onClick, text: navItem.text, panelHeading: navItem.panelHeading, items: navItem.items })),
2705
+ navItem.type === "megamenu" && (React.createElement(NavigationHeaderMegaMenu, { onOpenChange: navItem.onOpenChange, panelHeading: navItem.panelHeading, ariaLabel: navItem.ariaLabel, onClick: navItem.onClick, text: navItem.text, tabs: navItem.tabs, featureCards: navItem.featureCards }))));
500
2706
  };
501
2707
 
502
2708
  var MeatBall = function () { return (React.createElement("svg", { width: 18, "aria-hidden": true, viewBox: "0 0 17 3", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
@@ -624,7 +2830,7 @@ function requireCssesc () {
624
2830
  }
625
2831
 
626
2832
  var cssescExports = requireCssesc();
627
- var cssEscape = /*@__PURE__*/index.getDefaultExportFromCjs(cssescExports);
2833
+ var cssEscape = /*@__PURE__*/index$2.getDefaultExportFromCjs(cssescExports);
628
2834
 
629
2835
  /**
630
2836
  * A specialized version of `_.reduce` for arrays without support for
@@ -1214,7 +3420,7 @@ function requireKebabCase () {
1214
3420
  }
1215
3421
 
1216
3422
  var kebabCaseExports = requireKebabCase();
1217
- var kebabCase = /*@__PURE__*/index.getDefaultExportFromCjs(kebabCaseExports);
3423
+ var kebabCase = /*@__PURE__*/index$2.getDefaultExportFromCjs(kebabCaseExports);
1218
3424
 
1219
3425
  var getQuery = function (_a) {
1220
3426
  var breakpoint = _a.breakpoint, type = _a.type, _b = _a.isMatchMedia, isMatchMedia = _b === void 0 ? false : _b;
@@ -1222,12 +3428,6 @@ var getQuery = function (_a) {
1222
3428
  return "".concat(isMatchMedia ? "" : "@media", "(").concat(type, "-width: ").concat(breakpointValue, "px)");
1223
3429
  };
1224
3430
 
1225
- /*
1226
- This is to ensure there are no cumulative layout shifts on SSR because of the dynamic media queries.
1227
- matchMedia can cause flickering when it returns a different value than the default state the server used.
1228
- This is plain old css so the styles will appear correctly on first paint.
1229
- The items these styles are applied to will still appear in the server rendered HTML for SEO purposes.
1230
- */
1231
3431
  var NavigationHeaderStyleElement = function (_a) {
1232
3432
  var css = _a.css;
1233
3433
  var generateCssStyles = function (declarations) {
@@ -1248,43 +3448,13 @@ var NavigationHeaderStyleElement = function (_a) {
1248
3448
  return React.createElement("style", null, styleStrings.join("").replace(/\s/g, ""));
1249
3449
  };
1250
3450
 
1251
- var NavigationHeaderMeatBallMenu = function (_a) {
1252
- var extraNavItems = _a.extraNavItems, mainNavItems = _a.mainNavItems, _b = _a.tooltip, tooltip = _b === void 0 ? "More links" : _b, _c = _a.ariaLabel, ariaLabel = _c === void 0 ? "Show hidden menu items" : _c;
1253
- var id = React.useId();
1254
- var meatBallMenuItemClassName = useUniqueString("arc-NavigationHeaderMeatBalllMenu-item");
1255
- return (React.createElement(React.Fragment, null,
1256
- React.createElement(NavigationHeaderStyleElement, { css: tslib_es6.__spreadArray([
1257
- {
1258
- className: meatBallMenuItemClassName,
1259
- declarations: {
1260
- display: "none",
1261
- },
1262
- }
1263
- ], mainNavItems.map(function (navItem, i) { return ({
1264
- mediaQuery: { type: "max", breakpoint: navItem.visibleFrom || 0 },
1265
- className: "".concat(meatBallMenuItemClassName, "-").concat(i),
1266
- declarations: {
1267
- display: "block",
1268
- },
1269
- }); }), true) }),
1270
- React.createElement("div", { className: "arc-NavigationHeaderMeatBalllMenu-container" },
1271
- React.createElement(NavigationHeaderDropdown, { ariaLabel: ariaLabel, tooltip: tooltip, trigger: React.createElement(MeatBall, null) },
1272
- extraNavItems.map(function (navItem, i) { return (React.createElement("li", { key: "".concat(id, "-NavigationHeader-meatball-item-").concat(i) },
1273
- React.createElement(NavigationHeaderNavLink, tslib_es6.__assign({}, navItem)))); }),
1274
- mainNavItems.map(function (navItem, itemIndex) { return (React.createElement("li", { key: "".concat(id, "-NavigationHeader-meatball-item-").concat(itemIndex), className: index.classNames(meatBallMenuItemClassName, "".concat(meatBallMenuItemClassName, "-").concat(itemIndex)) },
1275
- navItem.type === "link" && (React.createElement(NavigationHeaderNavLink, tslib_es6.__assign({}, navItem))),
1276
- (navItem.type === "subnav" || navItem.type === "dropdown") &&
1277
- navItem.items.map(function (navLink, subItemIndex) { return (React.createElement(NavigationHeaderNavLink, tslib_es6.__assign({ key: "".concat(id, "-NavigationHeader-meatball-link--").concat(itemIndex, "-").concat(subItemIndex) }, navLink))); }))); })))));
1278
- };
1279
-
1280
- var NavigationHeaderNavList = function (_a) {
1281
- var navItems = _a.navItems, meatBallMenuAriaLabel = _a.meatBallMenuAriaLabel, meatballMenuTooltip = _a.meatballMenuTooltip;
3451
+ var NavigationHeaderNavList = React.memo(function (_a) {
3452
+ var navItems = _a.navItems, background = _a.background, extraMenuTooltip = _a.extraMenuTooltip, _b = _a.extraNavItems, extraNavItems = _b === void 0 ? [] : _b, extraMenuAriaLabel = _a.extraMenuAriaLabel;
1282
3453
  var id = React.useId();
1283
3454
  var navListItemClassName = useUniqueString("arc-NavigationHeaderNavList-item");
1284
- var meatBallMenuClassName = useUniqueString("arc-NavigationHeaderNavList-meatballMenu");
3455
+ var sideMenuClassName = useUniqueString("arc-NavigationHeaderNavList-sideMenu");
3456
+ var sideMenuNavItemClassName = useUniqueString("arc-NavigationHeaderNavList-sideMenuItem");
1285
3457
  var ref = React.useRef(null);
1286
- var mainNavItems = navItems.filter(function (navItem) { return navItem.type !== "meatball"; });
1287
- var meatBallMenuItems = navItems.filter(function (navItem) { return navItem.type === "meatball"; });
1288
3458
  var largestElementBreakpoint = function (navItems) {
1289
3459
  return Math.max.apply(Math, navItems.map(function (navItem) {
1290
3460
  if (navItem.visibleFrom) {
@@ -1295,14 +3465,14 @@ var NavigationHeaderNavList = function (_a) {
1295
3465
  return 0;
1296
3466
  }));
1297
3467
  };
1298
- var meatBallMenuBreakpoint = meatBallMenuItems.length
3468
+ var extraMenuBreakpoint = extraNavItems.length
1299
3469
  ? { type: "max", breakpoint: 0 }
1300
- : { type: "min", breakpoint: largestElementBreakpoint(mainNavItems) };
3470
+ : { type: "min", breakpoint: largestElementBreakpoint(navItems) };
1301
3471
  return (React.createElement("div", { className: "arc-NavigationHeaderNavList-container" },
1302
3472
  React.createElement(NavigationHeaderStyleElement, { css: tslib_es6.__spreadArray([
1303
3473
  {
1304
- className: meatBallMenuClassName,
1305
- mediaQuery: meatBallMenuBreakpoint,
3474
+ className: sideMenuClassName,
3475
+ mediaQuery: extraMenuBreakpoint,
1306
3476
  declarations: {
1307
3477
  display: "none",
1308
3478
  },
@@ -1313,25 +3483,45 @@ var NavigationHeaderNavList = function (_a) {
1313
3483
  display: "none",
1314
3484
  },
1315
3485
  }
1316
- ], mainNavItems.map(function (navItem, i) { return ({
1317
- mediaQuery: { type: "min", breakpoint: navItem.visibleFrom || 0 },
1318
- className: "".concat(navListItemClassName, "-").concat(i),
1319
- declarations: {
1320
- display: "block",
1321
- },
1322
- }); }), true) }),
1323
- React.createElement("ul", { ref: ref, className: "arc-NavigationHeaderNavList" }, mainNavItems.map(function (navItem, i) { return (React.createElement("li", { key: "".concat(id, "-navigation-header-navitem-").concat(i), className: index.classNames(navListItemClassName, "".concat(navListItemClassName, "-").concat(i)) },
1324
- React.createElement(NavigationHeaderNavItem, { navItem: navItem }))); })),
1325
- React.createElement("div", { className: meatBallMenuClassName },
1326
- React.createElement(NavigationHeaderMeatBallMenu, { tooltip: meatballMenuTooltip, ariaLabel: meatBallMenuAriaLabel, mainNavItems: mainNavItems, extraNavItems: meatBallMenuItems }))));
1327
- };
1328
-
1329
- var NavigationHeaderNav = function (props) {
1330
- var navigationHeaderContext = React.useContext(NavigationHeaderContext);
1331
- return (React.createElement("nav", { "aria-label": "primary" },
1332
- React.createElement("div", { ref: navigationHeaderContext === null || navigationHeaderContext === void 0 ? void 0 : navigationHeaderContext.navBarPortalRef }),
1333
- React.createElement(NavigationHeaderContainer, tslib_es6.__assign({}, props))));
1334
- };
3486
+ ], navItems.reduce(function (acc, navItem, i) {
3487
+ return tslib_es6.__spreadArray(tslib_es6.__spreadArray([], acc, true), [
3488
+ {
3489
+ mediaQuery: {
3490
+ type: "min",
3491
+ breakpoint: navItem.visibleFrom || 0,
3492
+ },
3493
+ className: "".concat(sideMenuNavItemClassName, "-").concat(i),
3494
+ declarations: {
3495
+ display: "none",
3496
+ },
3497
+ },
3498
+ {
3499
+ mediaQuery: {
3500
+ type: "min",
3501
+ breakpoint: navItem.visibleFrom || 0,
3502
+ },
3503
+ className: "".concat(navListItemClassName, "-").concat(i),
3504
+ declarations: {
3505
+ display: "block",
3506
+ },
3507
+ },
3508
+ ], false);
3509
+ }, []), true) }),
3510
+ React.createElement("ul", { ref: ref, className: "arc-NavigationHeaderNavList" }, navItems.map(function (navItem, i) { return (React.createElement("li", { key: "".concat(id, "-navigation-header-navitem-").concat(i), className: index$2.classNames(navListItemClassName, "".concat(navListItemClassName, "-").concat(i)) },
3511
+ React.createElement("div", { className: index$2.classNames({
3512
+ "arc-NavigationHeaderNavList-itemContent--separator": navItem.isSeparator,
3513
+ }) },
3514
+ React.createElement(NavigationHeaderNavItem, { navItem: navItem })))); })),
3515
+ React.createElement("div", { className: sideMenuClassName },
3516
+ React.createElement(NavigationHeaderSideMenu, { showLogo: false, menuPosition: "left", pathway: "match", triggerAriaLabel: extraMenuAriaLabel, trigger: React.createElement(MeatBall, null), tooltip: extraMenuTooltip, background: background },
3517
+ React.createElement(SideMenuNavList, null, extraNavItems === null || extraNavItems === void 0 ? void 0 :
3518
+ extraNavItems.map(function (navItem, navItemIndex) { return (React.createElement(React.Fragment, { key: "".concat(id, "-side-nav-item-").concat(navItemIndex) },
3519
+ React.createElement("li", null,
3520
+ React.createElement(SideMenuNavItem, { navItem: navItem })))); }), navItems === null || navItems === void 0 ? void 0 :
3521
+ navItems.map(function (navItem, navItemIndex) { return (React.createElement(React.Fragment, { key: "".concat(id, "-side-main-nav-item-").concat(navItemIndex) },
3522
+ React.createElement("li", { className: index$2.classNames(sideMenuNavItemClassName, "".concat(sideMenuNavItemClassName, "-").concat(navItemIndex)) },
3523
+ React.createElement(SideMenuNavItem, { navItem: navItem })))); }))))));
3524
+ });
1335
3525
 
1336
3526
  var defaultHeaderVisibility = {
1337
3527
  burgerMenu: {
@@ -1352,50 +3542,150 @@ var defaultHeaderVisibility = {
1352
3542
  },
1353
3543
  };
1354
3544
 
3545
+ function defaultEmptyArray(items) {
3546
+ return items || [];
3547
+ }
3548
+
1355
3549
  /**
1356
3550
  * Use `NavigationHeader` as a Top-level UI element that displays branding, page titles, and primary navigation actions.
1357
3551
  */
1358
3552
  var NavigationHeader = function (_a) {
1359
- var leftSlot = _a.leftSlot, middleSlot = _a.middleSlot, rightSlot = _a.rightSlot, isPill = _a.isPill, isExtended = _a.isExtended, isFluid = _a.isFluid, logo = _a.logo, navItems = _a.navItems, meatballMenuTooltip = _a.meatballMenuTooltip, burgerMenuActions = _a.burgerMenuActions, burgerMenuFooter = _a.burgerMenuFooter, burgerMenuHeader = _a.burgerMenuHeader, burgerMenuVisibility = _a.burgerMenuVisibility, onOpenChange = _a.onOpenChange, burgerMenuPathway = _a.burgerMenuPathway, navMenuVisibility = _a.navMenuVisibility, _b = _a.background, background = _b === void 0 ? "transparentOnLight" : _b;
1360
- var navBarPortalRef = React.useRef(null);
1361
- var _c = React.useState(false), isSubMenuItemActive = _c[0], setIsSubMenuItemActive = _c[1];
1362
- var navBarBackground = isSubMenuItemActive ? "lightElevated" : background;
3553
+ var leftSlot = _a.leftSlot, middleSlot = _a.middleSlot, rightSlot = _a.rightSlot, isPill = _a.isPill, isExtended = _a.isExtended, isFluid = _a.isFluid, logo = _a.logo, navItems = _a.navItems, extraNavItems = _a.extraNavItems, extraMenuTooltip = _a.extraMenuTooltip, extraMenuAriaLabel = _a.extraMenuAriaLabel, burgerMenuActions = _a.burgerMenuActions, burgerMenuFooter = _a.burgerMenuFooter, burgerMenuHeader = _a.burgerMenuHeader, burgerMenuVisibility = _a.burgerMenuVisibility, onBurgerMenuOpenChange = _a.onBurgerMenuOpenChange, burgerMenuPathway = _a.burgerMenuPathway, navMenuVisibility = _a.navMenuVisibility, _b = _a.background, background = _b === void 0 ? "transparentOnLight" : _b;
3554
+ var _c = React.useState(), navBarEl = _c[0], setNavBarEl = _c[1];
1363
3555
  var burgerMenuVisibilityProps = tslib_es6.__assign(tslib_es6.__assign({}, defaultHeaderVisibility.burgerMenu), burgerMenuVisibility);
1364
3556
  var navMenuVisibilityProps = tslib_es6.__assign(tslib_es6.__assign({}, defaultHeaderVisibility.navItems), navMenuVisibility);
1365
- return (React.createElement(NavigationHeaderContext.Provider, { value: {
1366
- navBarPortalRef: navBarPortalRef,
1367
- isPill: isPill,
1368
- isExtended: isExtended,
1369
- isFluid: isFluid,
1370
- setIsSubMenuItemActive: setIsSubMenuItemActive,
1371
- } },
1372
- React.createElement(NavigationHeaderNav, { isFluid: isFluid, isExtended: isExtended, background: navBarBackground, isPill: isPill },
1373
- React.createElement("div", { className: "arc-NavigationHeader-inner" },
1374
- React.createElement("div", { className: "arc-NavigationHeader-leftSlot" },
1375
- React.createElement(NavigationHeaderLogo, tslib_es6.__assign({}, logo)),
1376
- leftSlot),
1377
- React.createElement("div", { className: "arc-NavigationHeader-navSlot" },
1378
- navItems && (React.createElement(Visible.Visible, tslib_es6.__assign({}, navMenuVisibilityProps),
1379
- React.createElement(NavigationHeaderNavList, { navItems: navItems, meatballMenuTooltip: meatballMenuTooltip }))),
1380
- React.createElement("div", { className: "arc-NavigationHeader-middleSlot" }, middleSlot)),
1381
- rightSlot && (React.createElement("div", { className: "arc-NavigationHeader-rightSlot" }, rightSlot)),
1382
- React.createElement(Visible.Visible, tslib_es6.__assign({}, burgerMenuVisibilityProps),
1383
- React.createElement("div", { className: "arc-NavigationHeader-burgerMenuSlot" },
1384
- React.createElement(NavigationHeaderBurgerMenu, { logo: logo, background: background, pathway: burgerMenuPathway, navItems: navItems, actions: burgerMenuActions, header: burgerMenuHeader, footer: burgerMenuFooter, onOpenChange: onOpenChange })))))));
3557
+ var setNavBarRef = function (el) {
3558
+ el && setNavBarEl(el);
3559
+ };
3560
+ var contextValue = React.useMemo(function () { return ({
3561
+ navBarEl: navBarEl,
3562
+ isPill: isPill,
3563
+ isExtended: isExtended,
3564
+ isFluid: isFluid,
3565
+ }); }, [navBarEl, isPill, isExtended, isFluid]);
3566
+ var allNavItems = tslib_es6.__spreadArray(tslib_es6.__spreadArray([], defaultEmptyArray(navItems), true), defaultEmptyArray(extraNavItems), true);
3567
+ return (React.createElement(NavigationHeaderContext.Provider, { value: contextValue },
3568
+ React.createElement("nav", { "aria-label": "primary" },
3569
+ React.createElement(NavigationHeaderContainer, { ref: setNavBarRef, isPill: isPill, isExtended: isExtended, isFluid: isFluid, backgroundColor: background },
3570
+ React.createElement("div", { className: "arc-NavigationHeader-inner" },
3571
+ React.createElement("div", { className: "arc-NavigationHeader-leftSlot" },
3572
+ React.createElement(NavigationHeaderLogo, tslib_es6.__assign({}, logo)),
3573
+ leftSlot),
3574
+ React.createElement("div", { className: "arc-NavigationHeader-navSlot" },
3575
+ navItems && (React.createElement(Visible.Visible, tslib_es6.__assign({}, navMenuVisibilityProps),
3576
+ React.createElement(NavigationHeaderNavList, { navItems: navItems, background: background, extraNavItems: extraNavItems, extraMenuAriaLabel: extraMenuAriaLabel, extraMenuTooltip: extraMenuTooltip }))),
3577
+ React.createElement("div", { className: "arc-NavigationHeader-middleSlot" }, middleSlot)),
3578
+ rightSlot && (React.createElement("div", { className: "arc-NavigationHeader-rightSlot" }, rightSlot)),
3579
+ React.createElement(Visible.Visible, tslib_es6.__assign({}, burgerMenuVisibilityProps),
3580
+ React.createElement("div", { className: "arc-NavigationHeader-burgerMenuSlot" },
3581
+ React.createElement(NavigationHeaderSideMenu, { menuPosition: "right", logo: logo, background: background, pathway: burgerMenuPathway, navItems: allNavItems, actions: burgerMenuActions, header: burgerMenuHeader, footer: burgerMenuFooter, onOpenChange: onBurgerMenuOpenChange }))))))));
1385
3582
  };
1386
3583
 
1387
3584
  var NavigationHeaderAction = function (_a) {
1388
- var ariaLabel = _a.ariaLabel, icon = _a.icon, onClick = _a.onClick, title = _a.title, supportingCopy = _a.supportingCopy, _b = _a.isAttention, isAttention = _b === void 0 ? false : _b;
1389
- return (React.createElement("div", { className: index.classNames("arc-NavigationHeaderAction", {
3585
+ var ariaLabel = _a.ariaLabel, icon = _a.icon, onClick = _a.onClick, title = _a.title, supportingCopy = _a.supportingCopy, ref = _a.ref, href = _a.href, _b = _a.isAttention, isAttention = _b === void 0 ? false : _b;
3586
+ return (React.createElement("div", { className: index$2.classNames("arc-NavigationHeaderAction", {
1390
3587
  "arc-NavigationHeaderAction--attention": isAttention,
1391
3588
  }) },
1392
3589
  React.createElement(Tooltip.Tooltip, { asChild: true, title: title, alignContent: "center", supportingCopy: supportingCopy, delayDuration: DELAY_DURATION, side: "bottom" },
1393
- React.createElement(NavigationHeaderButton, { isPadded: false, onClick: onClick },
3590
+ React.createElement(NavigationHeaderButton, { href: href, ref: ref, isPadded: false, onClick: onClick },
1394
3591
  React.createElement("div", { className: "arc-NavigationHeaderAction-content" },
1395
- React.createElement(Icon.Icon, { "aria-hidden": true, icon: icon, size: 24 }),
3592
+ typeof icon === "string" ? (React.createElement(Icon.Icon, { "aria-hidden": true, icon: icon, size: 24 })) : (icon),
1396
3593
  React.createElement(VisuallyHidden.VisuallyHidden, null, ariaLabel))))));
1397
3594
  };
1398
3595
 
3596
+ var NavigationHeaderSearchMenu = function (_a) {
3597
+ var onSubmit = _a.onSubmit, quickLinks = _a.quickLinks, onInputChange = _a.onInputChange, _b = _a.submitButtonAriaLabel, submitButtonAriaLabel = _b === void 0 ? "Submit search" : _b, _c = _a.panelTitle, panelTitle = _c === void 0 ? "Quick links" : _c, _d = _a.description, description = _d === void 0 ? "Discover our products and how we can help your business grow" : _d, _e = _a.accessibleMenuTitle, accessibleMenuTitle = _e === void 0 ? "Search menu" : _e, _f = _a.label, label = _f === void 0 ? "Search" : _f, _g = _a.triggerTooltip, triggerTooltip = _g === void 0 ? "Search" : _g, _h = _a.triggerAriaLabel, triggerAriaLabel = _h === void 0 ? "Open search menu" : _h;
3598
+ var id = React.useId();
3599
+ var listBoxId = React.useId();
3600
+ var inputId = React.useId();
3601
+ var _j = React.useState(undefined), highlightedOptionIndex = _j[0], setHighlightedOptionIndex = _j[1];
3602
+ var _k = React.useState(""), searchTerm = _k[0], setSearchTerm = _k[1];
3603
+ var inputRef = React.useRef(null);
3604
+ var hasHighlightedOption = typeof highlightedOptionIndex === "number";
3605
+ var onChange = function (e) {
3606
+ onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(e.target.value);
3607
+ setSearchTerm(e.target.value);
3608
+ setHighlightedOptionIndex(undefined);
3609
+ };
3610
+ var onFormSubmit = function (e) {
3611
+ e.preventDefault();
3612
+ onSubmit && onSubmit(searchTerm);
3613
+ };
3614
+ var onOpenChange = function (isOpen) {
3615
+ if (!isOpen) {
3616
+ setSearchTerm("");
3617
+ setHighlightedOptionIndex(undefined);
3618
+ }
3619
+ };
3620
+ var onInputKeyDown = function (e) {
3621
+ var key = e.key;
3622
+ if (key === KeyNames.Enter || key === KeyNames.Space) {
3623
+ !searchTerm && e.preventDefault();
3624
+ }
3625
+ if (key === KeyNames.ArrowDown) {
3626
+ e.preventDefault();
3627
+ var newIndex = !hasHighlightedOption ||
3628
+ highlightedOptionIndex === quickLinks.length - 1
3629
+ ? 0
3630
+ : highlightedOptionIndex + 1;
3631
+ setHighlightedOptionIndex(newIndex);
3632
+ setSearchTerm(quickLinks[newIndex].text);
3633
+ }
3634
+ if (key === KeyNames.ArrowUp) {
3635
+ e.preventDefault();
3636
+ var newIndex = (!hasHighlightedOption || highlightedOptionIndex === 0
3637
+ ? quickLinks.length
3638
+ : highlightedOptionIndex) - 1;
3639
+ setHighlightedOptionIndex(newIndex);
3640
+ setSearchTerm(quickLinks[newIndex].text);
3641
+ }
3642
+ };
3643
+ return (React.createElement(NavigationHeaderSubnav, { onOpenChange: onOpenChange },
3644
+ React.createElement(NavigationHeaderSubnavTrigger, { asChild: true },
3645
+ React.createElement(NavigationHeaderAction, { title: triggerTooltip, ariaLabel: triggerAriaLabel, icon: React.createElement(ThemeIcon.ThemeIcon, { icon: "navigationHeaderSearch", size: 24 }) })),
3646
+ React.createElement(NavigationHeaderSubnavContent, { background: "lightElevated", menuTitle: accessibleMenuTitle },
3647
+ React.createElement("div", { className: "arc-NavigationHeaderSearchMenu" },
3648
+ React.createElement("div", { className: "arc-NavigationHeaderSearchMenu-labelContainer" },
3649
+ React.createElement("label", { htmlFor: inputId },
3650
+ React.createElement(Heading.Heading, { size: "m" }, label)),
3651
+ React.createElement(Text.Text, null, description)),
3652
+ React.createElement("form", { onSubmit: onFormSubmit, className: "arc-NavigationHeaderSearchMenu-form" },
3653
+ React.createElement("input", { id: inputId, role: "combobox", autoComplete: "off", "aria-autocomplete": "none", "aria-controls": listBoxId, "aria-activedescendant": hasHighlightedOption
3654
+ ? "".concat(listBoxId, "-").concat(highlightedOptionIndex)
3655
+ : undefined, ref: inputRef, value: searchTerm, onChange: onChange, onKeyDown: onInputKeyDown, className: "arc-NavigationHeaderSearchMenu-input", type: "text" }),
3656
+ React.createElement("div", { className: "arc-NavigationHeaderSearchMenu-actions" },
3657
+ React.createElement(SemanticButton.SemanticButton, { "aria-label": submitButtonAriaLabel, className: "arc-NavigationHeaderSearchMenu-submitButton", type: "submit" },
3658
+ React.createElement(ThemeIcon.ThemeIcon, { icon: "navigationHeaderSearch" })))),
3659
+ React.createElement("div", { className: "arc-NavigationHeaderSearchMenu-results" },
3660
+ React.createElement(Heading.Heading, { level: "3", size: "xxxs" }, panelTitle),
3661
+ React.createElement("ul", { id: listBoxId, role: "listbox", onMouseLeave: function () { return setHighlightedOptionIndex(undefined); }, className: "arc-NavigationHeaderSearchMenu-resultsList" }, quickLinks === null || quickLinks === void 0 ? void 0 : quickLinks.map(function (_a, i) {
3662
+ var text = _a.text, href = _a.href, onClick = _a.onClick;
3663
+ return (React.createElement("li", { className: index$2.classNames("arc-NavigationHeaderSearchMenu-listItem", {
3664
+ "arc-NavigationHeaderSearchMenu-listItem--highlighted": highlightedOptionIndex === i,
3665
+ }), role: "option", "aria-label": text, onMouseMove: function () { return setHighlightedOptionIndex(i); }, "aria-selected": highlightedOptionIndex === i, id: "".concat(listBoxId, "-").concat(i), key: "".concat(id, "-search-link-").concat(text, "-").concat(i) },
3666
+ React.createElement("div", { className: "arc-NavigationHeaderSearchMenu-linkContainer" },
3667
+ React.createElement(Heading.Heading, { size: "xxs" },
3668
+ React.createElement(SemanticLink.SemanticLink, { className: "arc-NavigationHeaderSearchMenu-link", href: href, onClick: onClick, tabIndex: -1 }, text))),
3669
+ React.createElement("div", { className: "arc-NavigationHeaderSearchMenu-iconContainer" },
3670
+ React.createElement(ArrowRightIcon, null))));
3671
+ })))))));
3672
+ };
3673
+ var KeyNames;
3674
+ (function (KeyNames) {
3675
+ KeyNames["ArrowUp"] = "ArrowUp";
3676
+ KeyNames["ArrowDown"] = "ArrowDown";
3677
+ KeyNames["Home"] = "Home";
3678
+ KeyNames["Enter"] = "Enter";
3679
+ KeyNames["Escape"] = "Escape";
3680
+ KeyNames["Space"] = " ";
3681
+ })(KeyNames || (KeyNames = {}));
3682
+
3683
+ var NavigationHeaderBasket = function (_a) {
3684
+ var supportingCopy = _a.supportingCopy, onClick = _a.onClick, href = _a.href, _b = _a.popoverText, popoverText = _b === void 0 ? "No items in basket" : _b, _c = _a.title, title = _c === void 0 ? "Basket" : _c, _d = _a.ariaLabel, ariaLabel = _d === void 0 ? "Basket, empty" : _d, _e = _a.isAttention, isAttention = _e === void 0 ? false : _e;
3685
+ return isAttention ? (React.createElement(NavigationHeaderAction, { isAttention: true, href: href, title: title, onClick: onClick, supportingCopy: supportingCopy, ariaLabel: ariaLabel, icon: React.createElement(ThemeIcon.ThemeIcon, { icon: "navigationHeaderBasket", size: 24 }) })) : (React.createElement(NavigationHeaderDropdown, { tooltip: title, ariaLabel: ariaLabel, onClick: onClick, trigger: React.createElement("div", { className: "arc-NavigationHeaderBasket-trigger" },
3686
+ React.createElement(ThemeIcon.ThemeIcon, { icon: "navigationHeaderBasket", size: 24 })) }, popoverText));
3687
+ };
3688
+
1399
3689
  var NavigationHeaderActionBar = function (_a) {
1400
3690
  var children = _a.children;
1401
3691
  var id = React.useId();
@@ -1407,7 +3697,7 @@ var NavigationHeaderPage = function (_a) {
1407
3697
  var icon = _a.icon, title = _a.title, page = _a.page;
1408
3698
  var surface = React.useContext(Surface.Context).surface;
1409
3699
  var iconToRender = function (size) { return React.createElement(Icon.Icon, { size: size, icon: icon }); };
1410
- return (React.createElement("div", { className: index.classNames("arc-NavigationHeaderPage", suffixModifier.suffixModifier("arc-NavigationHeaderPage--on", surface)) },
3700
+ return (React.createElement("div", { className: index$2.classNames("arc-NavigationHeaderPage", suffixModifier.suffixModifier("arc-NavigationHeaderPage--on", surface)) },
1411
3701
  icon && (React.createElement("div", { className: "arc-NavigationHeaderPage-icon" },
1412
3702
  React.createElement(Visible.Visible, { xs: true }, iconToRender(20)),
1413
3703
  React.createElement(Hidden.Hidden, { xs: true }, iconToRender(32)))),
@@ -1420,4 +3710,6 @@ var NavigationHeaderPage = function (_a) {
1420
3710
  exports.NavigationHeader = NavigationHeader;
1421
3711
  exports.NavigationHeaderAction = NavigationHeaderAction;
1422
3712
  exports.NavigationHeaderActionBar = NavigationHeaderActionBar;
3713
+ exports.NavigationHeaderBasket = NavigationHeaderBasket;
1423
3714
  exports.NavigationHeaderPage = NavigationHeaderPage;
3715
+ exports.NavigationHeaderSearchMenu = NavigationHeaderSearchMenu;