@arc-ui/components 11.0.0 → 11.1.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 (127) hide show
  1. package/dist/Align/Align.esm.js +4 -4
  2. package/dist/Badge/Badge.cjs.d.ts +26 -0
  3. package/dist/Badge/Badge.cjs.js +37 -0
  4. package/dist/Badge/Badge.esm.d.ts +26 -0
  5. package/dist/Badge/Badge.esm.js +29 -0
  6. package/dist/Badge/package.json +7 -0
  7. package/dist/Base/Base.cjs.d.ts +1 -16
  8. package/dist/Base/Base.cjs.js +4 -16
  9. package/dist/Base/Base.esm.d.ts +1 -16
  10. package/dist/Base/Base.esm.js +3 -15
  11. package/dist/BrandLogo/BrandLogo.esm.d.ts +1 -1
  12. package/dist/BrandLogo/BrandLogo.esm.js +2 -2
  13. package/dist/Breadcrumbs/Breadcrumbs.esm.js +27 -27
  14. package/dist/Button/Button.esm.d.ts +1 -1
  15. package/dist/Button/Button.esm.js +4 -4
  16. package/dist/Card/Card.esm.js +27 -27
  17. package/dist/Checkbox/Checkbox.cjs.js +4 -1
  18. package/dist/Checkbox/Checkbox.esm.js +18 -15
  19. package/dist/Clock/Clock.esm.js +3 -3
  20. package/dist/Columns/Columns.esm.js +5 -5
  21. package/dist/Curve/Curve.esm.d.ts +1 -1
  22. package/dist/Curve/Curve.esm.js +1 -1
  23. package/dist/Disclosure/Disclosure.esm.d.ts +1 -1
  24. package/dist/Disclosure/Disclosure.esm.js +10 -10
  25. package/dist/Elevation/Elevation.esm.js +2 -2
  26. package/dist/FormControl/FormControl.cjs.d.ts +1 -1
  27. package/dist/FormControl/FormControl.cjs.js +4 -1
  28. package/dist/FormControl/FormControl.esm.d.ts +1 -1
  29. package/dist/FormControl/FormControl.esm.js +5 -2
  30. package/dist/Group/Group.esm.js +6 -6
  31. package/dist/Heading/Heading.esm.d.ts +1 -1
  32. package/dist/Heading/Heading.esm.js +2 -2
  33. package/dist/Icon/Icon.esm.d.ts +1 -1
  34. package/dist/Icon/Icon.esm.js +2 -2
  35. package/dist/Image/Image.esm.d.ts +1 -1
  36. package/dist/Image/Image.esm.js +1 -1
  37. package/dist/Markup/Markup.esm.js +3 -3
  38. package/dist/Poster/Poster.esm.d.ts +1 -1
  39. package/dist/Poster/Poster.esm.js +9 -9
  40. package/dist/RadioGroup/RadioGroup.cjs.d.ts +1 -1
  41. package/dist/RadioGroup/RadioGroup.cjs.js +4 -1
  42. package/dist/RadioGroup/RadioGroup.esm.d.ts +1 -1
  43. package/dist/RadioGroup/RadioGroup.esm.js +15 -12
  44. package/dist/Rule/Rule.esm.js +3 -3
  45. package/dist/Section/Section.esm.d.ts +1 -1
  46. package/dist/Section/Section.esm.js +1 -1
  47. package/dist/Select/Select.cjs.d.ts +25 -0
  48. package/dist/Select/Select.cjs.js +3010 -0
  49. package/dist/Select/Select.esm.d.ts +25 -0
  50. package/dist/Select/Select.esm.js +2983 -0
  51. package/dist/Select/package.json +7 -0
  52. package/dist/SiteFooter/SiteFooter.esm.js +33 -33
  53. package/dist/SiteHeader/SiteHeader.esm.d.ts +1 -1
  54. package/dist/SiteHeader/SiteHeader.esm.js +98 -98
  55. package/dist/Surface/Surface.esm.d.ts +1 -1
  56. package/dist/Surface/Surface.esm.js +1 -1
  57. package/dist/Text/Text.esm.d.ts +1 -1
  58. package/dist/Text/Text.esm.js +2 -2
  59. package/dist/TextInput/TextInput.cjs.d.ts +5 -1
  60. package/dist/TextInput/TextInput.cjs.js +25 -6
  61. package/dist/TextInput/TextInput.esm.d.ts +5 -1
  62. package/dist/TextInput/TextInput.esm.js +28 -9
  63. package/dist/Truncate/Truncate.cjs.d.ts +18 -0
  64. package/dist/Truncate/Truncate.cjs.js +17 -0
  65. package/dist/Truncate/Truncate.esm.d.ts +18 -0
  66. package/dist/Truncate/Truncate.esm.js +9 -0
  67. package/dist/Truncate/package.json +7 -0
  68. package/dist/UniversalHeader/UniversalHeader.esm.js +8 -8
  69. package/dist/VerticalSpace/VerticalSpace.esm.js +2 -2
  70. package/dist/VisuallyHidden/VisuallyHidden.cjs.d.ts +1 -12
  71. package/dist/VisuallyHidden/VisuallyHidden.cjs.js +3 -12
  72. package/dist/VisuallyHidden/VisuallyHidden.esm.d.ts +1 -12
  73. package/dist/VisuallyHidden/VisuallyHidden.esm.js +2 -11
  74. package/dist/_shared/cjs/Base-e2b846fe.d.ts +19 -0
  75. package/dist/_shared/cjs/Base-e2b846fe.js +22 -0
  76. package/dist/_shared/cjs/{FormControl-a1b7421b.d.ts → FormControl-e6b7d7c5.d.ts} +51 -3
  77. package/dist/_shared/cjs/{FormControl-a1b7421b.js → FormControl-e6b7d7c5.js} +40 -8
  78. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.d.ts +12 -0
  79. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.js +17 -0
  80. package/dist/_shared/cjs/index-c81c9401.d.ts +1 -1
  81. package/dist/_shared/esm/Base-c235dc45.d.ts +19 -0
  82. package/dist/_shared/esm/Base-c235dc45.js +15 -0
  83. package/dist/_shared/esm/{BrandLogo-ea3dd0e6.js → BrandLogo-4f13fe85.js} +4 -4
  84. package/dist/_shared/esm/{BtIconChevronDown2Px-4abd079b.js → BtIconChevronDown2Px-782876e2.js} +2 -2
  85. package/dist/_shared/esm/{BtIconChevronRight2Px-a5cc1d05.js → BtIconChevronRight2Px-b8e7b4ad.js} +3 -3
  86. package/dist/_shared/esm/{BtIconChevronRightMid-386cf272.js → BtIconChevronRightMid-d9b11761.js} +2 -2
  87. package/dist/_shared/esm/{Button-5ff56a7b.js → Button-69439f8f.js} +15 -15
  88. package/dist/_shared/esm/{Curve-cfdca379.js → Curve-50697f7e.js} +2 -2
  89. package/dist/_shared/esm/{FormControl-feedc495.d.ts → FormControl-84c9ace6.d.ts} +51 -3
  90. package/dist/_shared/esm/FormControl-84c9ace6.js +138 -0
  91. package/dist/_shared/esm/{Heading-183be76c.js → Heading-eb1e42db.js} +4 -4
  92. package/dist/_shared/esm/{Icon-76d0d8c0.js → Icon-61f7237a.js} +5 -5
  93. package/dist/_shared/esm/{Image-7e4948f6.js → Image-c0f3d42f.js} +7 -7
  94. package/dist/_shared/esm/{Section-f1256c87.js → Section-7bc71e26.js} +2 -2
  95. package/dist/_shared/esm/{Surface-d515d212.js → Surface-bf201530.js} +3 -3
  96. package/dist/_shared/esm/{Text-d8988620.js → Text-6b958ad8.js} +3 -3
  97. package/dist/_shared/esm/VisuallyHidden-b9eebf71.d.ts +12 -0
  98. package/dist/_shared/esm/VisuallyHidden-b9eebf71.js +11 -0
  99. package/dist/_shared/esm/index-c81c9401.d.ts +1 -1
  100. package/dist/index.es.js +34424 -522
  101. package/dist/index.es.js.map +1 -1
  102. package/dist/index.js +34329 -406
  103. package/dist/index.js.map +1 -1
  104. package/dist/styles.css +1 -1
  105. package/dist/types/components/Badge/Badge.d.ts +25 -0
  106. package/dist/types/components/Badge/index.d.ts +1 -0
  107. package/dist/types/components/FormControl/FormControl.d.ts +17 -0
  108. package/dist/types/components/FormControl/FormControlDisclosure/FormControlDisclosure.d.ts +28 -0
  109. package/dist/types/components/FormControl/FormControlDisclosure/index.d.ts +1 -0
  110. package/dist/types/components/Select/Select.d.ts +2 -1
  111. package/dist/types/components/TextInput/TextInput.d.ts +4 -0
  112. package/dist/types/components/Truncate/Truncate.d.ts +17 -0
  113. package/dist/types/components/Truncate/index.d.ts +1 -0
  114. package/dist/types/components/index.d.ts +3 -0
  115. package/dist/types/hooks/use-aria-describedby.d.ts +5 -1
  116. package/dist/types/styles.d.ts +4 -0
  117. package/package.json +4 -4
  118. package/dist/_shared/esm/FormControl-feedc495.js +0 -106
  119. /package/dist/_shared/esm/{BrandLogo-ea3dd0e6.d.ts → BrandLogo-4f13fe85.d.ts} +0 -0
  120. /package/dist/_shared/esm/{Button-5ff56a7b.d.ts → Button-69439f8f.d.ts} +0 -0
  121. /package/dist/_shared/esm/{Curve-cfdca379.d.ts → Curve-50697f7e.d.ts} +0 -0
  122. /package/dist/_shared/esm/{Heading-183be76c.d.ts → Heading-eb1e42db.d.ts} +0 -0
  123. /package/dist/_shared/esm/{Icon-76d0d8c0.d.ts → Icon-61f7237a.d.ts} +0 -0
  124. /package/dist/_shared/esm/{Image-7e4948f6.d.ts → Image-c0f3d42f.d.ts} +0 -0
  125. /package/dist/_shared/esm/{Section-f1256c87.d.ts → Section-7bc71e26.d.ts} +0 -0
  126. /package/dist/_shared/esm/{Surface-d515d212.d.ts → Surface-bf201530.d.ts} +0 -0
  127. /package/dist/_shared/esm/{Text-d8988620.d.ts → Text-6b958ad8.d.ts} +0 -0
@@ -0,0 +1,3010 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index = require('../_shared/cjs/index-45bfb67b.js');
6
+ var React$2 = require('react');
7
+ var $7SXl2$reactdom = require('react-dom');
8
+ var BtIconChevronDown2Px = require('../_shared/cjs/BtIconChevronDown2Px-8fb4e2eb.js');
9
+ var Icon = require('../_shared/cjs/Icon-719d13d4.js');
10
+ var FormControl = require('../_shared/cjs/FormControl-e6b7d7c5.js');
11
+ var Surface = require('../_shared/cjs/Surface-d6b8010e.js');
12
+ var Base = require('../_shared/cjs/Base-e2b846fe.js');
13
+ require('../_shared/cjs/index-78b35bc1.js');
14
+ require('../_shared/cjs/suffix-modifier-edf7851e.js');
15
+ require('../_shared/cjs/Text-1d3844be.js');
16
+ require('../_shared/cjs/BtIconChevronRightMid-5a38d855.js');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ function _interopNamespace(e) {
21
+ if (e && e.__esModule) return e;
22
+ var n = Object.create(null);
23
+ if (e) {
24
+ Object.keys(e).forEach(function (k) {
25
+ if (k !== 'default') {
26
+ var d = Object.getOwnPropertyDescriptor(e, k);
27
+ Object.defineProperty(n, k, d.get ? d : {
28
+ enumerable: true,
29
+ get: function () { return e[k]; }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ n["default"] = e;
35
+ return Object.freeze(n);
36
+ }
37
+
38
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$2);
39
+ var React__namespace = /*#__PURE__*/_interopNamespace(React$2);
40
+ var $7SXl2$reactdom__default = /*#__PURE__*/_interopDefaultLegacy($7SXl2$reactdom);
41
+
42
+ function _extends() {
43
+ _extends = Object.assign || function (target) {
44
+ for (var i = 1; i < arguments.length; i++) {
45
+ var source = arguments[i];
46
+
47
+ for (var key in source) {
48
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
49
+ target[key] = source[key];
50
+ }
51
+ }
52
+ }
53
+
54
+ return target;
55
+ };
56
+
57
+ return _extends.apply(this, arguments);
58
+ }
59
+
60
+ function $ae6933e535247d3d$export$7d15b64cf5a3a4c4(value, [min, max]) {
61
+ return Math.min(max, Math.max(min, value));
62
+ }
63
+
64
+ function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented: checkForDefaultPrevented = true } = {}) {
65
+ return function handleEvent(event) {
66
+ originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event);
67
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
68
+ };
69
+ }
70
+
71
+ /* -------------------------------------------------------------------------------------------------
72
+ * createContextScope
73
+ * -----------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) {
74
+ let defaultContexts = [];
75
+ /* -----------------------------------------------------------------------------------------------
76
+ * createContext
77
+ * ---------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
78
+ const BaseContext = /*#__PURE__*/ React$2.createContext(defaultContext);
79
+ const index = defaultContexts.length;
80
+ defaultContexts = [
81
+ ...defaultContexts,
82
+ defaultContext
83
+ ];
84
+ function Provider(props) {
85
+ const { scope: scope , children: children , ...context } = props;
86
+ const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext; // Only re-memoize when prop values change
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ const value = React$2.useMemo(()=>context
89
+ , Object.values(context));
90
+ return /*#__PURE__*/ React$2.createElement(Context.Provider, {
91
+ value: value
92
+ }, children);
93
+ }
94
+ function useContext(consumerName, scope) {
95
+ const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext;
96
+ const context = React$2.useContext(Context);
97
+ if (context) return context;
98
+ if (defaultContext !== undefined) return defaultContext; // if a defaultContext wasn't specified, it's a required context.
99
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
100
+ }
101
+ Provider.displayName = rootComponentName + 'Provider';
102
+ return [
103
+ Provider,
104
+ useContext
105
+ ];
106
+ }
107
+ /* -----------------------------------------------------------------------------------------------
108
+ * createScope
109
+ * ---------------------------------------------------------------------------------------------*/ const createScope = ()=>{
110
+ const scopeContexts = defaultContexts.map((defaultContext)=>{
111
+ return /*#__PURE__*/ React$2.createContext(defaultContext);
112
+ });
113
+ return function useScope(scope) {
114
+ const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
115
+ return React$2.useMemo(()=>({
116
+ [`__scope${scopeName}`]: {
117
+ ...scope,
118
+ [scopeName]: contexts
119
+ }
120
+ })
121
+ , [
122
+ scope,
123
+ contexts
124
+ ]);
125
+ };
126
+ };
127
+ createScope.scopeName = scopeName;
128
+ return [
129
+ $c512c27ab02ef895$export$fd42f52fd3ae1109,
130
+ $c512c27ab02ef895$var$composeContextScopes(createScope, ...createContextScopeDeps)
131
+ ];
132
+ }
133
+ /* -------------------------------------------------------------------------------------------------
134
+ * composeContextScopes
135
+ * -----------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$var$composeContextScopes(...scopes) {
136
+ const baseScope = scopes[0];
137
+ if (scopes.length === 1) return baseScope;
138
+ const createScope1 = ()=>{
139
+ const scopeHooks = scopes.map((createScope)=>({
140
+ useScope: createScope(),
141
+ scopeName: createScope.scopeName
142
+ })
143
+ );
144
+ return function useComposedScopes(overrideScopes) {
145
+ const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope: useScope , scopeName: scopeName })=>{
146
+ // We are calling a hook inside a callback which React warns against to avoid inconsistent
147
+ // renders, however, scoping doesn't have render side effects so we ignore the rule.
148
+ // eslint-disable-next-line react-hooks/rules-of-hooks
149
+ const scopeProps = useScope(overrideScopes);
150
+ const currentScope = scopeProps[`__scope${scopeName}`];
151
+ return {
152
+ ...nextScopes,
153
+ ...currentScope
154
+ };
155
+ }, {});
156
+ return React$2.useMemo(()=>({
157
+ [`__scope${baseScope.scopeName}`]: nextScopes1
158
+ })
159
+ , [
160
+ nextScopes1
161
+ ]);
162
+ };
163
+ };
164
+ createScope1.scopeName = baseScope.scopeName;
165
+ return createScope1;
166
+ }
167
+
168
+ /**
169
+ * Set a given ref to a given value
170
+ * This utility takes care of different types of refs: callback refs and RefObject(s)
171
+ */ function $6ed0406888f73fc4$var$setRef(ref, value) {
172
+ if (typeof ref === 'function') ref(value);
173
+ else if (ref !== null && ref !== undefined) ref.current = value;
174
+ }
175
+ /**
176
+ * A utility to compose multiple refs together
177
+ * Accepts callback refs and RefObject(s)
178
+ */ function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {
179
+ return (node)=>refs.forEach((ref)=>$6ed0406888f73fc4$var$setRef(ref, node)
180
+ )
181
+ ;
182
+ }
183
+ /**
184
+ * A custom hook that composes multiple refs
185
+ * Accepts callback refs and RefObject(s)
186
+ */ function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {
187
+ // eslint-disable-next-line react-hooks/exhaustive-deps
188
+ return React$2.useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);
189
+ }
190
+
191
+ /* -------------------------------------------------------------------------------------------------
192
+ * Slot
193
+ * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
194
+ const { children: children , ...slotProps } = props;
195
+ const childrenArray = React$2.Children.toArray(children);
196
+ const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);
197
+ if (slottable) {
198
+ // the new element to render is the one passed as a child of `Slottable`
199
+ const newElement = slottable.props.children;
200
+ const newChildren = childrenArray.map((child)=>{
201
+ if (child === slottable) {
202
+ // because the new element will be the one rendered, we are only interested
203
+ // in grabbing its children (`newElement.props.children`)
204
+ if (React$2.Children.count(newElement) > 1) return React$2.Children.only(null);
205
+ return /*#__PURE__*/ React$2.isValidElement(newElement) ? newElement.props.children : null;
206
+ } else return child;
207
+ });
208
+ return /*#__PURE__*/ React$2.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
209
+ ref: forwardedRef
210
+ }), /*#__PURE__*/ React$2.isValidElement(newElement) ? /*#__PURE__*/ React$2.cloneElement(newElement, undefined, newChildren) : null);
211
+ }
212
+ return /*#__PURE__*/ React$2.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
213
+ ref: forwardedRef
214
+ }), children);
215
+ });
216
+ $5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = 'Slot';
217
+ /* -------------------------------------------------------------------------------------------------
218
+ * SlotClone
219
+ * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$var$SlotClone = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
220
+ const { children: children , ...slotProps } = props;
221
+ if (/*#__PURE__*/ React$2.isValidElement(children)) return /*#__PURE__*/ React$2.cloneElement(children, {
222
+ ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
223
+ ref: $6ed0406888f73fc4$export$43e446d32b3d21af(forwardedRef, children.ref)
224
+ });
225
+ return React$2.Children.count(children) > 1 ? React$2.Children.only(null) : null;
226
+ });
227
+ $5e63c961fc1ce211$var$SlotClone.displayName = 'SlotClone';
228
+ /* -------------------------------------------------------------------------------------------------
229
+ * Slottable
230
+ * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children: children })=>{
231
+ return /*#__PURE__*/ React$2.createElement(React$2.Fragment, null, children);
232
+ };
233
+ /* ---------------------------------------------------------------------------------------------- */ function $5e63c961fc1ce211$var$isSlottable(child) {
234
+ return /*#__PURE__*/ React$2.isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
235
+ }
236
+ function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
237
+ // all child props should override
238
+ const overrideProps = {
239
+ ...childProps
240
+ };
241
+ for(const propName in childProps){
242
+ const slotPropValue = slotProps[propName];
243
+ const childPropValue = childProps[propName];
244
+ const isHandler = /^on[A-Z]/.test(propName);
245
+ if (isHandler) {
246
+ // if the handler exists on both, we compose them
247
+ if (slotPropValue && childPropValue) overrideProps[propName] = (...args)=>{
248
+ childPropValue(...args);
249
+ slotPropValue(...args);
250
+ };
251
+ else if (slotPropValue) overrideProps[propName] = slotPropValue;
252
+ } else if (propName === 'style') overrideProps[propName] = {
253
+ ...slotPropValue,
254
+ ...childPropValue
255
+ };
256
+ else if (propName === 'className') overrideProps[propName] = [
257
+ slotPropValue,
258
+ childPropValue
259
+ ].filter(Boolean).join(' ');
260
+ }
261
+ return {
262
+ ...slotProps,
263
+ ...overrideProps
264
+ };
265
+ }
266
+
267
+ // We have resorted to returning slots directly rather than exposing primitives that can then
268
+ // be slotted like `<CollectionItem as={Slot}>…</CollectionItem>`.
269
+ // This is because we encountered issues with generic types that cannot be statically analysed
270
+ // due to creating them dynamically via createCollection.
271
+ function $e02a7d9cb1dc128c$export$c74125a8e3af6bb2(name) {
272
+ /* -----------------------------------------------------------------------------------------------
273
+ * CollectionProvider
274
+ * ---------------------------------------------------------------------------------------------*/ const PROVIDER_NAME = name + 'CollectionProvider';
275
+ const [createCollectionContext, createCollectionScope] = $c512c27ab02ef895$export$50c7b4e9d9f19c1(PROVIDER_NAME);
276
+ const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
277
+ collectionRef: {
278
+ current: null
279
+ },
280
+ itemMap: new Map()
281
+ });
282
+ const CollectionProvider = (props)=>{
283
+ const { scope: scope , children: children } = props;
284
+ const ref = React__default["default"].useRef(null);
285
+ const itemMap = React__default["default"].useRef(new Map()).current;
286
+ return /*#__PURE__*/ React__default["default"].createElement(CollectionProviderImpl, {
287
+ scope: scope,
288
+ itemMap: itemMap,
289
+ collectionRef: ref
290
+ }, children);
291
+ };
292
+ /* -----------------------------------------------------------------------------------------------
293
+ * CollectionSlot
294
+ * ---------------------------------------------------------------------------------------------*/ const COLLECTION_SLOT_NAME = name + 'CollectionSlot';
295
+ const CollectionSlot = /*#__PURE__*/ React__default["default"].forwardRef((props, forwardedRef)=>{
296
+ const { scope: scope , children: children } = props;
297
+ const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
298
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.collectionRef);
299
+ return /*#__PURE__*/ React__default["default"].createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
300
+ ref: composedRefs
301
+ }, children);
302
+ });
303
+ /* -----------------------------------------------------------------------------------------------
304
+ * CollectionItem
305
+ * ---------------------------------------------------------------------------------------------*/ const ITEM_SLOT_NAME = name + 'CollectionItemSlot';
306
+ const ITEM_DATA_ATTR = 'data-radix-collection-item';
307
+ const CollectionItemSlot = /*#__PURE__*/ React__default["default"].forwardRef((props, forwardedRef)=>{
308
+ const { scope: scope , children: children , ...itemData } = props;
309
+ const ref = React__default["default"].useRef(null);
310
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
311
+ const context = useCollectionContext(ITEM_SLOT_NAME, scope);
312
+ React__default["default"].useEffect(()=>{
313
+ context.itemMap.set(ref, {
314
+ ref: ref,
315
+ ...itemData
316
+ });
317
+ return ()=>void context.itemMap.delete(ref)
318
+ ;
319
+ });
320
+ return /*#__PURE__*/ React__default["default"].createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
321
+ [ITEM_DATA_ATTR]: '',
322
+ ref: composedRefs
323
+ }, children);
324
+ });
325
+ /* -----------------------------------------------------------------------------------------------
326
+ * useCollection
327
+ * ---------------------------------------------------------------------------------------------*/ function useCollection(scope) {
328
+ const context = useCollectionContext(name + 'CollectionConsumer', scope);
329
+ const getItems = React__default["default"].useCallback(()=>{
330
+ const collectionNode = context.collectionRef.current;
331
+ if (!collectionNode) return [];
332
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
333
+ const items = Array.from(context.itemMap.values());
334
+ const orderedItems = items.sort((a, b)=>orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
335
+ );
336
+ return orderedItems;
337
+ }, [
338
+ context.collectionRef,
339
+ context.itemMap
340
+ ]);
341
+ return getItems;
342
+ }
343
+ return [
344
+ {
345
+ Provider: CollectionProvider,
346
+ Slot: CollectionSlot,
347
+ ItemSlot: CollectionItemSlot
348
+ },
349
+ useCollection,
350
+ createCollectionScope
351
+ ];
352
+ }
353
+
354
+ const $f631663db3294ace$var$DirectionContext = /*#__PURE__*/ React$2.createContext(undefined);
355
+ /* -----------------------------------------------------------------------------------------------*/ function $f631663db3294ace$export$b39126d51d94e6f3(localDir) {
356
+ const globalDir = React$2.useContext($f631663db3294ace$var$DirectionContext);
357
+ return localDir || globalDir || 'ltr';
358
+ }
359
+
360
+ const $8927f6f2acc4f386$var$NODES = [
361
+ 'a',
362
+ 'button',
363
+ 'div',
364
+ 'h2',
365
+ 'h3',
366
+ 'img',
367
+ 'label',
368
+ 'li',
369
+ 'nav',
370
+ 'ol',
371
+ 'p',
372
+ 'span',
373
+ 'svg',
374
+ 'ul'
375
+ ]; // Temporary while we await merge of this fix:
376
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396
377
+ // prettier-ignore
378
+ /* -------------------------------------------------------------------------------------------------
379
+ * Primitive
380
+ * -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node)=>{
381
+ const Node = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
382
+ const { asChild: asChild , ...primitiveProps } = props;
383
+ const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : node;
384
+ React$2.useEffect(()=>{
385
+ window[Symbol.for('radix-ui')] = true;
386
+ }, []);
387
+ return /*#__PURE__*/ React$2.createElement(Comp, _extends({}, primitiveProps, {
388
+ ref: forwardedRef
389
+ }));
390
+ });
391
+ Node.displayName = `Primitive.${node}`;
392
+ return {
393
+ ...primitive,
394
+ [node]: Node
395
+ };
396
+ }, {});
397
+ /* -------------------------------------------------------------------------------------------------
398
+ * Utils
399
+ * -----------------------------------------------------------------------------------------------*/ /**
400
+ * Flush custom event dispatch
401
+ * https://github.com/radix-ui/primitives/pull/1378
402
+ *
403
+ * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
404
+ *
405
+ * Internally, React prioritises events in the following order:
406
+ * - discrete
407
+ * - continuous
408
+ * - default
409
+ *
410
+ * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350
411
+ *
412
+ * `discrete` is an important distinction as updates within these events are applied immediately.
413
+ * React however, is not able to infer the priority of custom event types due to how they are detected internally.
414
+ * Because of this, it's possible for updates from custom events to be unexpectedly batched when
415
+ * dispatched by another `discrete` event.
416
+ *
417
+ * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
418
+ * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
419
+ * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
420
+ * For example:
421
+ *
422
+ * dispatching a known click 👎
423
+ * target.dispatchEvent(new Event(‘click’))
424
+ *
425
+ * dispatching a custom type within a non-discrete event 👎
426
+ * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
427
+ *
428
+ * dispatching a custom type within a `discrete` event 👍
429
+ * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
430
+ *
431
+ * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
432
+ * this utility with them. This is because it's possible for those handlers to be called implicitly during render
433
+ * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
434
+ */ function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {
435
+ if (target) $7SXl2$reactdom.flushSync(()=>target.dispatchEvent(event)
436
+ );
437
+ }
438
+
439
+ /**
440
+ * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
441
+ * prop or avoid re-executing effects when passed as a dependency
442
+ */ function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) {
443
+ const callbackRef = React$2.useRef(callback);
444
+ React$2.useEffect(()=>{
445
+ callbackRef.current = callback;
446
+ }); // https://github.com/facebook/react/issues/19240
447
+ return React$2.useMemo(()=>(...args)=>{
448
+ var _callbackRef$current;
449
+ return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
450
+ }
451
+ , []);
452
+ }
453
+
454
+ /**
455
+ * Listens for when the escape key is down
456
+ */ function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
457
+ const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp);
458
+ React$2.useEffect(()=>{
459
+ const handleKeyDown = (event)=>{
460
+ if (event.key === 'Escape') onEscapeKeyDown(event);
461
+ };
462
+ ownerDocument.addEventListener('keydown', handleKeyDown);
463
+ return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown)
464
+ ;
465
+ }, [
466
+ onEscapeKeyDown,
467
+ ownerDocument
468
+ ]);
469
+ }
470
+
471
+ const $5cb92bef7577960e$var$CONTEXT_UPDATE = 'dismissableLayer.update';
472
+ const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';
473
+ const $5cb92bef7577960e$var$FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';
474
+ let $5cb92bef7577960e$var$originalBodyPointerEvents;
475
+ const $5cb92bef7577960e$var$DismissableLayerContext = /*#__PURE__*/ React$2.createContext({
476
+ layers: new Set(),
477
+ layersWithOutsidePointerEventsDisabled: new Set(),
478
+ branches: new Set()
479
+ });
480
+ const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
481
+ var _node$ownerDocument;
482
+ const { disableOutsidePointerEvents: disableOutsidePointerEvents = false , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , onFocusOutside: onFocusOutside , onInteractOutside: onInteractOutside , onDismiss: onDismiss , ...layerProps } = props;
483
+ const context = React$2.useContext($5cb92bef7577960e$var$DismissableLayerContext);
484
+ const [node1, setNode] = React$2.useState(null);
485
+ const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
486
+ const [, force] = React$2.useState({});
487
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setNode(node)
488
+ );
489
+ const layers = Array.from(context.layers);
490
+ const [highestLayerWithOutsidePointerEventsDisabled] = [
491
+ ...context.layersWithOutsidePointerEventsDisabled
492
+ ].slice(-1); // prettier-ignore
493
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); // prettier-ignore
494
+ const index = node1 ? layers.indexOf(node1) : -1;
495
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
496
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
497
+ const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event)=>{
498
+ const target = event.target;
499
+ const isPointerDownOnBranch = [
500
+ ...context.branches
501
+ ].some((branch)=>branch.contains(target)
502
+ );
503
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
504
+ onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event);
505
+ onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
506
+ if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
507
+ }, ownerDocument);
508
+ const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event)=>{
509
+ const target = event.target;
510
+ const isFocusInBranch = [
511
+ ...context.branches
512
+ ].some((branch)=>branch.contains(target)
513
+ );
514
+ if (isFocusInBranch) return;
515
+ onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event);
516
+ onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event);
517
+ if (!event.defaultPrevented) onDismiss === null || onDismiss === void 0 || onDismiss();
518
+ }, ownerDocument);
519
+ $addc16e1bbe58fd0$export$3a72a57244d6e765((event)=>{
520
+ const isHighestLayer = index === context.layers.size - 1;
521
+ if (!isHighestLayer) return;
522
+ onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event);
523
+ if (!event.defaultPrevented && onDismiss) {
524
+ event.preventDefault();
525
+ onDismiss();
526
+ }
527
+ }, ownerDocument);
528
+ React$2.useEffect(()=>{
529
+ if (!node1) return;
530
+ if (disableOutsidePointerEvents) {
531
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
532
+ $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
533
+ ownerDocument.body.style.pointerEvents = 'none';
534
+ }
535
+ context.layersWithOutsidePointerEventsDisabled.add(node1);
536
+ }
537
+ context.layers.add(node1);
538
+ $5cb92bef7577960e$var$dispatchUpdate();
539
+ return ()=>{
540
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents;
541
+ };
542
+ }, [
543
+ node1,
544
+ ownerDocument,
545
+ disableOutsidePointerEvents,
546
+ context
547
+ ]);
548
+ /**
549
+ * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect
550
+ * because a change to `disableOutsidePointerEvents` would remove this layer from the stack
551
+ * and add it to the end again so the layering order wouldn't be _creation order_.
552
+ * We only want them to be removed from context stacks when unmounted.
553
+ */ React$2.useEffect(()=>{
554
+ return ()=>{
555
+ if (!node1) return;
556
+ context.layers.delete(node1);
557
+ context.layersWithOutsidePointerEventsDisabled.delete(node1);
558
+ $5cb92bef7577960e$var$dispatchUpdate();
559
+ };
560
+ }, [
561
+ node1,
562
+ context
563
+ ]);
564
+ React$2.useEffect(()=>{
565
+ const handleUpdate = ()=>force({})
566
+ ;
567
+ document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate);
568
+ return ()=>document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate)
569
+ ;
570
+ }, []);
571
+ return /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, layerProps, {
572
+ ref: composedRefs,
573
+ style: {
574
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? 'auto' : 'none' : undefined,
575
+ ...props.style
576
+ },
577
+ onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture),
578
+ onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture),
579
+ onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
580
+ }));
581
+ });
582
+ /* -----------------------------------------------------------------------------------------------*/ /**
583
+ * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`
584
+ * to mimic layer dismissing behaviour present in OS.
585
+ * Returns props to pass to the node we want to check for outside events.
586
+ */ function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
587
+ const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside);
588
+ const isPointerInsideReactTreeRef = React$2.useRef(false);
589
+ const handleClickRef = React$2.useRef(()=>{});
590
+ React$2.useEffect(()=>{
591
+ const handlePointerDown = (event)=>{
592
+ if (event.target && !isPointerInsideReactTreeRef.current) {
593
+ const eventDetail = {
594
+ originalEvent: event
595
+ };
596
+ function handleAndDispatchPointerDownOutsideEvent() {
597
+ $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
598
+ discrete: true
599
+ });
600
+ }
601
+ /**
602
+ * On touch devices, we need to wait for a click event because browsers implement
603
+ * a ~350ms delay between the time the user stops touching the display and when the
604
+ * browser executres events. We need to ensure we don't reactivate pointer-events within
605
+ * this timeframe otherwise the browser may execute events that should have been prevented.
606
+ *
607
+ * Additionally, this also lets us deal automatically with cancellations when a click event
608
+ * isn't raised because the page was considered scrolled/drag-scrolled, long-pressed, etc.
609
+ *
610
+ * This is why we also continuously remove the previous listener, because we cannot be
611
+ * certain that it was raised, and therefore cleaned-up.
612
+ */ if (event.pointerType === 'touch') {
613
+ ownerDocument.removeEventListener('click', handleClickRef.current);
614
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
615
+ ownerDocument.addEventListener('click', handleClickRef.current, {
616
+ once: true
617
+ });
618
+ } else handleAndDispatchPointerDownOutsideEvent();
619
+ }
620
+ isPointerInsideReactTreeRef.current = false;
621
+ };
622
+ /**
623
+ * if this hook executes in a component that mounts via a `pointerdown` event, the event
624
+ * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid
625
+ * this by delaying the event listener registration on the document.
626
+ * This is not React specific, but rather how the DOM works, ie:
627
+ * ```
628
+ * button.addEventListener('pointerdown', () => {
629
+ * console.log('I will log');
630
+ * document.addEventListener('pointerdown', () => {
631
+ * console.log('I will also log');
632
+ * })
633
+ * });
634
+ */ const timerId = window.setTimeout(()=>{
635
+ ownerDocument.addEventListener('pointerdown', handlePointerDown);
636
+ }, 0);
637
+ return ()=>{
638
+ window.clearTimeout(timerId);
639
+ ownerDocument.removeEventListener('pointerdown', handlePointerDown);
640
+ ownerDocument.removeEventListener('click', handleClickRef.current);
641
+ };
642
+ }, [
643
+ ownerDocument,
644
+ handlePointerDownOutside
645
+ ]);
646
+ return {
647
+ // ensures we check React component tree (not just DOM tree)
648
+ onPointerDownCapture: ()=>isPointerInsideReactTreeRef.current = true
649
+ };
650
+ }
651
+ /**
652
+ * Listens for when focus happens outside a react subtree.
653
+ * Returns props to pass to the root (node) of the subtree we want to check.
654
+ */ function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
655
+ const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside);
656
+ const isFocusInsideReactTreeRef = React$2.useRef(false);
657
+ React$2.useEffect(()=>{
658
+ const handleFocus = (event)=>{
659
+ if (event.target && !isFocusInsideReactTreeRef.current) {
660
+ const eventDetail = {
661
+ originalEvent: event
662
+ };
663
+ $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
664
+ discrete: false
665
+ });
666
+ }
667
+ };
668
+ ownerDocument.addEventListener('focusin', handleFocus);
669
+ return ()=>ownerDocument.removeEventListener('focusin', handleFocus)
670
+ ;
671
+ }, [
672
+ ownerDocument,
673
+ handleFocusOutside
674
+ ]);
675
+ return {
676
+ onFocusCapture: ()=>isFocusInsideReactTreeRef.current = true
677
+ ,
678
+ onBlurCapture: ()=>isFocusInsideReactTreeRef.current = false
679
+ };
680
+ }
681
+ function $5cb92bef7577960e$var$dispatchUpdate() {
682
+ const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE);
683
+ document.dispatchEvent(event);
684
+ }
685
+ function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name, handler, detail, { discrete: discrete }) {
686
+ const target = detail.originalEvent.target;
687
+ const event = new CustomEvent(name, {
688
+ bubbles: false,
689
+ cancelable: true,
690
+ detail: detail
691
+ });
692
+ if (handler) target.addEventListener(name, handler, {
693
+ once: true
694
+ });
695
+ if (discrete) $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event);
696
+ else target.dispatchEvent(event);
697
+ }
698
+
699
+ /** Number of components which have requested interest to have focus guards */ let $3db38b7d1fb3fe6a$var$count = 0;
700
+ /**
701
+ * Injects a pair of focus guards at the edges of the whole DOM tree
702
+ * to ensure `focusin` & `focusout` events can be caught consistently.
703
+ */ function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() {
704
+ React$2.useEffect(()=>{
705
+ var _edgeGuards$, _edgeGuards$2;
706
+ const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');
707
+ document.body.insertAdjacentElement('afterbegin', (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard());
708
+ document.body.insertAdjacentElement('beforeend', (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard());
709
+ $3db38b7d1fb3fe6a$var$count++;
710
+ return ()=>{
711
+ if ($3db38b7d1fb3fe6a$var$count === 1) document.querySelectorAll('[data-radix-focus-guard]').forEach((node)=>node.remove()
712
+ );
713
+ $3db38b7d1fb3fe6a$var$count--;
714
+ };
715
+ }, []);
716
+ }
717
+ function $3db38b7d1fb3fe6a$var$createFocusGuard() {
718
+ const element = document.createElement('span');
719
+ element.setAttribute('data-radix-focus-guard', '');
720
+ element.tabIndex = 0;
721
+ element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';
722
+ return element;
723
+ }
724
+
725
+ const $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = 'focusScope.autoFocusOnMount';
726
+ const $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = 'focusScope.autoFocusOnUnmount';
727
+ const $d3863c46a17e8a28$var$EVENT_OPTIONS = {
728
+ bubbles: false,
729
+ cancelable: true
730
+ };
731
+ const $d3863c46a17e8a28$export$20e40289641fbbb6 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
732
+ const { loop: loop = false , trapped: trapped = false , onMountAutoFocus: onMountAutoFocusProp , onUnmountAutoFocus: onUnmountAutoFocusProp , ...scopeProps } = props;
733
+ const [container1, setContainer] = React$2.useState(null);
734
+ const onMountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onMountAutoFocusProp);
735
+ const onUnmountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onUnmountAutoFocusProp);
736
+ const lastFocusedElementRef = React$2.useRef(null);
737
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContainer(node)
738
+ );
739
+ const focusScope = React$2.useRef({
740
+ paused: false,
741
+ pause () {
742
+ this.paused = true;
743
+ },
744
+ resume () {
745
+ this.paused = false;
746
+ }
747
+ }).current; // Takes care of trapping focus if focus is moved outside programmatically for example
748
+ React$2.useEffect(()=>{
749
+ if (trapped) {
750
+ function handleFocusIn(event) {
751
+ if (focusScope.paused || !container1) return;
752
+ const target = event.target;
753
+ if (container1.contains(target)) lastFocusedElementRef.current = target;
754
+ else $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
755
+ select: true
756
+ });
757
+ }
758
+ function handleFocusOut(event) {
759
+ if (focusScope.paused || !container1) return;
760
+ if (!container1.contains(event.relatedTarget)) $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, {
761
+ select: true
762
+ });
763
+ }
764
+ document.addEventListener('focusin', handleFocusIn);
765
+ document.addEventListener('focusout', handleFocusOut);
766
+ return ()=>{
767
+ document.removeEventListener('focusin', handleFocusIn);
768
+ document.removeEventListener('focusout', handleFocusOut);
769
+ };
770
+ }
771
+ }, [
772
+ trapped,
773
+ container1,
774
+ focusScope.paused
775
+ ]);
776
+ React$2.useEffect(()=>{
777
+ if (container1) {
778
+ $d3863c46a17e8a28$var$focusScopesStack.add(focusScope);
779
+ const previouslyFocusedElement = document.activeElement;
780
+ const hasFocusedCandidate = container1.contains(previouslyFocusedElement);
781
+ if (!hasFocusedCandidate) {
782
+ const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
783
+ container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
784
+ container1.dispatchEvent(mountEvent);
785
+ if (!mountEvent.defaultPrevented) {
786
+ $d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), {
787
+ select: true
788
+ });
789
+ if (document.activeElement === previouslyFocusedElement) $d3863c46a17e8a28$var$focus(container1);
790
+ }
791
+ }
792
+ return ()=>{
793
+ container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); // We hit a react bug (fixed in v17) with focusing in unmount.
794
+ // We need to delay the focus a little to get around it for now.
795
+ // See: https://github.com/facebook/react/issues/17894
796
+ setTimeout(()=>{
797
+ const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS);
798
+ container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
799
+ container1.dispatchEvent(unmountEvent);
800
+ if (!unmountEvent.defaultPrevented) $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, {
801
+ select: true
802
+ });
803
+ // we need to remove the listener after we `dispatchEvent`
804
+ container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
805
+ $d3863c46a17e8a28$var$focusScopesStack.remove(focusScope);
806
+ }, 0);
807
+ };
808
+ }
809
+ }, [
810
+ container1,
811
+ onMountAutoFocus,
812
+ onUnmountAutoFocus,
813
+ focusScope
814
+ ]); // Takes care of looping focus (when tabbing whilst at the edges)
815
+ const handleKeyDown = React$2.useCallback((event)=>{
816
+ if (!loop && !trapped) return;
817
+ if (focusScope.paused) return;
818
+ const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;
819
+ const focusedElement = document.activeElement;
820
+ if (isTabKey && focusedElement) {
821
+ const container = event.currentTarget;
822
+ const [first, last] = $d3863c46a17e8a28$var$getTabbableEdges(container);
823
+ const hasTabbableElementsInside = first && last; // we can only wrap focus if we have tabbable edges
824
+ if (!hasTabbableElementsInside) {
825
+ if (focusedElement === container) event.preventDefault();
826
+ } else {
827
+ if (!event.shiftKey && focusedElement === last) {
828
+ event.preventDefault();
829
+ if (loop) $d3863c46a17e8a28$var$focus(first, {
830
+ select: true
831
+ });
832
+ } else if (event.shiftKey && focusedElement === first) {
833
+ event.preventDefault();
834
+ if (loop) $d3863c46a17e8a28$var$focus(last, {
835
+ select: true
836
+ });
837
+ }
838
+ }
839
+ }
840
+ }, [
841
+ loop,
842
+ trapped,
843
+ focusScope.paused
844
+ ]);
845
+ return /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
846
+ tabIndex: -1
847
+ }, scopeProps, {
848
+ ref: composedRefs,
849
+ onKeyDown: handleKeyDown
850
+ }));
851
+ });
852
+ /* -------------------------------------------------------------------------------------------------
853
+ * Utils
854
+ * -----------------------------------------------------------------------------------------------*/ /**
855
+ * Attempts focusing the first element in a list of candidates.
856
+ * Stops when focus has actually moved.
857
+ */ function $d3863c46a17e8a28$var$focusFirst(candidates, { select: select = false } = {}) {
858
+ const previouslyFocusedElement = document.activeElement;
859
+ for (const candidate of candidates){
860
+ $d3863c46a17e8a28$var$focus(candidate, {
861
+ select: select
862
+ });
863
+ if (document.activeElement !== previouslyFocusedElement) return;
864
+ }
865
+ }
866
+ /**
867
+ * Returns the first and last tabbable elements inside a container.
868
+ */ function $d3863c46a17e8a28$var$getTabbableEdges(container) {
869
+ const candidates = $d3863c46a17e8a28$var$getTabbableCandidates(container);
870
+ const first = $d3863c46a17e8a28$var$findVisible(candidates, container);
871
+ const last = $d3863c46a17e8a28$var$findVisible(candidates.reverse(), container);
872
+ return [
873
+ first,
874
+ last
875
+ ];
876
+ }
877
+ /**
878
+ * Returns a list of potential tabbable candidates.
879
+ *
880
+ * NOTE: This is only a close approximation. For example it doesn't take into account cases like when
881
+ * elements are not visible. This cannot be worked out easily by just reading a property, but rather
882
+ * necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.
883
+ *
884
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
885
+ * Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
886
+ */ function $d3863c46a17e8a28$var$getTabbableCandidates(container) {
887
+ const nodes = [];
888
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
889
+ acceptNode: (node)=>{
890
+ const isHiddenInput = node.tagName === 'INPUT' && node.type === 'hidden';
891
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP; // `.tabIndex` is not the same as the `tabindex` attribute. It works on the
892
+ // runtime's understanding of tabbability, so this automatically accounts
893
+ // for any kind of element that could be tabbed to.
894
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
895
+ }
896
+ });
897
+ while(walker.nextNode())nodes.push(walker.currentNode); // we do not take into account the order of nodes with positive `tabIndex` as it
898
+ // hinders accessibility to have tab order different from visual order.
899
+ return nodes;
900
+ }
901
+ /**
902
+ * Returns the first visible element in a list.
903
+ * NOTE: Only checks visibility up to the `container`.
904
+ */ function $d3863c46a17e8a28$var$findVisible(elements, container) {
905
+ for (const element of elements){
906
+ // we stop checking if it's hidden at the `container` level (excluding)
907
+ if (!$d3863c46a17e8a28$var$isHidden(element, {
908
+ upTo: container
909
+ })) return element;
910
+ }
911
+ }
912
+ function $d3863c46a17e8a28$var$isHidden(node, { upTo: upTo }) {
913
+ if (getComputedStyle(node).visibility === 'hidden') return true;
914
+ while(node){
915
+ // we stop at `upTo` (excluding it)
916
+ if (upTo !== undefined && node === upTo) return false;
917
+ if (getComputedStyle(node).display === 'none') return true;
918
+ node = node.parentElement;
919
+ }
920
+ return false;
921
+ }
922
+ function $d3863c46a17e8a28$var$isSelectableInput(element) {
923
+ return element instanceof HTMLInputElement && 'select' in element;
924
+ }
925
+ function $d3863c46a17e8a28$var$focus(element, { select: select = false } = {}) {
926
+ // only focus if that element is focusable
927
+ if (element && element.focus) {
928
+ const previouslyFocusedElement = document.activeElement; // NOTE: we prevent scrolling on focus, to minimize jarring transitions for users
929
+ element.focus({
930
+ preventScroll: true
931
+ }); // only select if its not the same element, it supports selection and we need to select
932
+ if (element !== previouslyFocusedElement && $d3863c46a17e8a28$var$isSelectableInput(element) && select) element.select();
933
+ }
934
+ }
935
+ /* -------------------------------------------------------------------------------------------------
936
+ * FocusScope stack
937
+ * -----------------------------------------------------------------------------------------------*/ const $d3863c46a17e8a28$var$focusScopesStack = $d3863c46a17e8a28$var$createFocusScopesStack();
938
+ function $d3863c46a17e8a28$var$createFocusScopesStack() {
939
+ /** A stack of focus scopes, with the active one at the top */ let stack = [];
940
+ return {
941
+ add (focusScope) {
942
+ // pause the currently active focus scope (at the top of the stack)
943
+ const activeFocusScope = stack[0];
944
+ if (focusScope !== activeFocusScope) activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause();
945
+ // remove in case it already exists (because we'll re-add it at the top of the stack)
946
+ stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
947
+ stack.unshift(focusScope);
948
+ },
949
+ remove (focusScope) {
950
+ var _stack$;
951
+ stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope);
952
+ (_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume();
953
+ }
954
+ };
955
+ }
956
+ function $d3863c46a17e8a28$var$arrayRemove(array, item) {
957
+ const updatedArray = [
958
+ ...array
959
+ ];
960
+ const index = updatedArray.indexOf(item);
961
+ if (index !== -1) updatedArray.splice(index, 1);
962
+ return updatedArray;
963
+ }
964
+ function $d3863c46a17e8a28$var$removeLinks(items) {
965
+ return items.filter((item)=>item.tagName !== 'A'
966
+ );
967
+ }
968
+
969
+ /**
970
+ * On the server, React emits a warning when calling `useLayoutEffect`.
971
+ * This is because neither `useLayoutEffect` nor `useEffect` run on the server.
972
+ * We use this safe version which suppresses the warning by replacing it with a noop on the server.
973
+ *
974
+ * See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
975
+ */ const $9f79659886946c16$export$e5c5a5f917a5871c = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) ? React$2.useLayoutEffect : ()=>{};
976
+
977
+ const $1746a345f3d73bb7$var$useReactId = React__namespace['useId'.toString()] || (()=>undefined
978
+ );
979
+ let $1746a345f3d73bb7$var$count = 0;
980
+ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
981
+ const [id, setId] = React__namespace.useState($1746a345f3d73bb7$var$useReactId()); // React versions older than 18 will have client-side ids only.
982
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
983
+ if (!deterministicId) setId((reactId)=>reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++)
984
+ );
985
+ }, [
986
+ deterministicId
987
+ ]);
988
+ return deterministicId || (id ? `radix-${id}` : '');
989
+ }
990
+
991
+ const $f1701beae083dbae$export$602eac185826482c = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
992
+ var _globalThis$document;
993
+ const { container: container = globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body , ...portalProps } = props;
994
+ return container ? /*#__PURE__*/ $7SXl2$reactdom__default["default"].createPortal(/*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, portalProps, {
995
+ ref: forwardedRef
996
+ })), container) : null;
997
+ });
998
+
999
+ function $71cd76cc60e0454e$export$6f32135080cb4c3({ prop: prop , defaultProp: defaultProp , onChange: onChange = ()=>{} }) {
1000
+ const [uncontrolledProp, setUncontrolledProp] = $71cd76cc60e0454e$var$useUncontrolledState({
1001
+ defaultProp: defaultProp,
1002
+ onChange: onChange
1003
+ });
1004
+ const isControlled = prop !== undefined;
1005
+ const value1 = isControlled ? prop : uncontrolledProp;
1006
+ const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
1007
+ const setValue = React$2.useCallback((nextValue)=>{
1008
+ if (isControlled) {
1009
+ const setter = nextValue;
1010
+ const value = typeof nextValue === 'function' ? setter(prop) : nextValue;
1011
+ if (value !== prop) handleChange(value);
1012
+ } else setUncontrolledProp(nextValue);
1013
+ }, [
1014
+ isControlled,
1015
+ prop,
1016
+ setUncontrolledProp,
1017
+ handleChange
1018
+ ]);
1019
+ return [
1020
+ value1,
1021
+ setValue
1022
+ ];
1023
+ }
1024
+ function $71cd76cc60e0454e$var$useUncontrolledState({ defaultProp: defaultProp , onChange: onChange }) {
1025
+ const uncontrolledState = React$2.useState(defaultProp);
1026
+ const [value] = uncontrolledState;
1027
+ const prevValueRef = React$2.useRef(value);
1028
+ const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
1029
+ React$2.useEffect(()=>{
1030
+ if (prevValueRef.current !== value) {
1031
+ handleChange(value);
1032
+ prevValueRef.current = value;
1033
+ }
1034
+ }, [
1035
+ value,
1036
+ prevValueRef,
1037
+ handleChange
1038
+ ]);
1039
+ return uncontrolledState;
1040
+ }
1041
+
1042
+ function $010c2913dbd2fe3d$export$5cae361ad82dce8b(value) {
1043
+ const ref = React$2.useRef({
1044
+ value: value,
1045
+ previous: value
1046
+ }); // We compare values before making an update to ensure that
1047
+ // a change has been made. This ensures the previous value is
1048
+ // persisted correctly between renders.
1049
+ return React$2.useMemo(()=>{
1050
+ if (ref.current.value !== value) {
1051
+ ref.current.previous = ref.current.value;
1052
+ ref.current.value = value;
1053
+ }
1054
+ return ref.current.previous;
1055
+ }, [
1056
+ value
1057
+ ]);
1058
+ }
1059
+
1060
+ const $ea1ef594cf570d83$export$439d29a4e110a164 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
1061
+ return /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, props, {
1062
+ ref: forwardedRef,
1063
+ style: {
1064
+ // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
1065
+ position: 'absolute',
1066
+ border: 0,
1067
+ width: 1,
1068
+ height: 1,
1069
+ padding: 0,
1070
+ margin: -1,
1071
+ overflow: 'hidden',
1072
+ clip: 'rect(0, 0, 0, 0)',
1073
+ whiteSpace: 'nowrap',
1074
+ wordWrap: 'normal',
1075
+ ...props.style
1076
+ }
1077
+ }));
1078
+ });
1079
+
1080
+ var getDefaultParent = function (originalTarget) {
1081
+ if (typeof document === 'undefined') {
1082
+ return null;
1083
+ }
1084
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
1085
+ return sampleTarget.ownerDocument.body;
1086
+ };
1087
+ var counterMap = new WeakMap();
1088
+ var uncontrolledNodes = new WeakMap();
1089
+ var markerMap = {};
1090
+ var lockCount = 0;
1091
+ var unwrapHost = function (node) {
1092
+ return node && (node.host || unwrapHost(node.parentNode));
1093
+ };
1094
+ var correctTargets = function (parent, targets) {
1095
+ return targets.map(function (target) {
1096
+ if (parent.contains(target)) {
1097
+ return target;
1098
+ }
1099
+ var correctedTarget = unwrapHost(target);
1100
+ if (correctedTarget && parent.contains(correctedTarget)) {
1101
+ return correctedTarget;
1102
+ }
1103
+ console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
1104
+ return null;
1105
+ }).filter(function (x) { return Boolean(x); });
1106
+ };
1107
+ /**
1108
+ * Marks everything except given node(or nodes) as aria-hidden
1109
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
1110
+ * @param [parentNode] - top element, defaults to document.body
1111
+ * @param {String} [markerName] - a special attribute to mark every node
1112
+ * @param {String} [controlAttribute] - html Attribute to control
1113
+ * @return {Undo} undo command
1114
+ */
1115
+ var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
1116
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
1117
+ if (!markerMap[markerName]) {
1118
+ markerMap[markerName] = new WeakMap();
1119
+ }
1120
+ var markerCounter = markerMap[markerName];
1121
+ var hiddenNodes = [];
1122
+ var elementsToKeep = new Set();
1123
+ var elementsToStop = new Set(targets);
1124
+ var keep = function (el) {
1125
+ if (!el || elementsToKeep.has(el)) {
1126
+ return;
1127
+ }
1128
+ elementsToKeep.add(el);
1129
+ keep(el.parentNode);
1130
+ };
1131
+ targets.forEach(keep);
1132
+ var deep = function (parent) {
1133
+ if (!parent || elementsToStop.has(parent)) {
1134
+ return;
1135
+ }
1136
+ Array.prototype.forEach.call(parent.children, function (node) {
1137
+ if (elementsToKeep.has(node)) {
1138
+ deep(node);
1139
+ }
1140
+ else {
1141
+ var attr = node.getAttribute(controlAttribute);
1142
+ var alreadyHidden = attr !== null && attr !== 'false';
1143
+ var counterValue = (counterMap.get(node) || 0) + 1;
1144
+ var markerValue = (markerCounter.get(node) || 0) + 1;
1145
+ counterMap.set(node, counterValue);
1146
+ markerCounter.set(node, markerValue);
1147
+ hiddenNodes.push(node);
1148
+ if (counterValue === 1 && alreadyHidden) {
1149
+ uncontrolledNodes.set(node, true);
1150
+ }
1151
+ if (markerValue === 1) {
1152
+ node.setAttribute(markerName, 'true');
1153
+ }
1154
+ if (!alreadyHidden) {
1155
+ node.setAttribute(controlAttribute, 'true');
1156
+ }
1157
+ }
1158
+ });
1159
+ };
1160
+ deep(parentNode);
1161
+ elementsToKeep.clear();
1162
+ lockCount++;
1163
+ return function () {
1164
+ hiddenNodes.forEach(function (node) {
1165
+ var counterValue = counterMap.get(node) - 1;
1166
+ var markerValue = markerCounter.get(node) - 1;
1167
+ counterMap.set(node, counterValue);
1168
+ markerCounter.set(node, markerValue);
1169
+ if (!counterValue) {
1170
+ if (!uncontrolledNodes.has(node)) {
1171
+ node.removeAttribute(controlAttribute);
1172
+ }
1173
+ uncontrolledNodes.delete(node);
1174
+ }
1175
+ if (!markerValue) {
1176
+ node.removeAttribute(markerName);
1177
+ }
1178
+ });
1179
+ lockCount--;
1180
+ if (!lockCount) {
1181
+ // clear
1182
+ counterMap = new WeakMap();
1183
+ counterMap = new WeakMap();
1184
+ uncontrolledNodes = new WeakMap();
1185
+ markerMap = {};
1186
+ }
1187
+ };
1188
+ };
1189
+ /**
1190
+ * Marks everything except given node(or nodes) as aria-hidden
1191
+ * @param {Element | Element[]} originalTarget - elements to keep on the page
1192
+ * @param [parentNode] - top element, defaults to document.body
1193
+ * @param {String} [markerName] - a special attribute to mark every node
1194
+ * @return {Undo} undo command
1195
+ */
1196
+ var hideOthers = function (originalTarget, parentNode, markerName) {
1197
+ if (markerName === void 0) { markerName = 'data-aria-hidden'; }
1198
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
1199
+ var activeParentNode = parentNode || getDefaultParent(originalTarget);
1200
+ if (!activeParentNode) {
1201
+ return function () { return null; };
1202
+ }
1203
+ // we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
1204
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
1205
+ return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
1206
+ };
1207
+
1208
+ /******************************************************************************
1209
+ Copyright (c) Microsoft Corporation.
1210
+
1211
+ Permission to use, copy, modify, and/or distribute this software for any
1212
+ purpose with or without fee is hereby granted.
1213
+
1214
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1215
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1216
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1217
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1218
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1219
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1220
+ PERFORMANCE OF THIS SOFTWARE.
1221
+ ***************************************************************************** */
1222
+
1223
+ var __assign$1 = function() {
1224
+ __assign$1 = Object.assign || function __assign(t) {
1225
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1226
+ s = arguments[i];
1227
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1228
+ }
1229
+ return t;
1230
+ };
1231
+ return __assign$1.apply(this, arguments);
1232
+ };
1233
+
1234
+ function __rest$1(s, e) {
1235
+ var t = {};
1236
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1237
+ t[p] = s[p];
1238
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1239
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1240
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1241
+ t[p[i]] = s[p[i]];
1242
+ }
1243
+ return t;
1244
+ }
1245
+
1246
+ function __spreadArray(to, from, pack) {
1247
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1248
+ if (ar || !(i in from)) {
1249
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1250
+ ar[i] = from[i];
1251
+ }
1252
+ }
1253
+ return to.concat(ar || Array.prototype.slice.call(from));
1254
+ }
1255
+
1256
+ var zeroRightClassName = 'right-scroll-bar-position';
1257
+ var fullWidthClassName = 'width-before-scroll-bar';
1258
+ var noScrollbarsClassName = 'with-scroll-bars-hidden';
1259
+ /**
1260
+ * Name of a CSS variable containing the amount of "hidden" scrollbar
1261
+ * ! might be undefined ! use will fallback!
1262
+ */
1263
+ var removedBarSizeVariable = '--removed-body-scroll-bar-size';
1264
+
1265
+ /**
1266
+ * Assigns a value for a given ref, no matter of the ref format
1267
+ * @param {RefObject} ref - a callback function or ref object
1268
+ * @param value - a new value
1269
+ *
1270
+ * @see https://github.com/theKashey/use-callback-ref#assignref
1271
+ * @example
1272
+ * const refObject = useRef();
1273
+ * const refFn = (ref) => {....}
1274
+ *
1275
+ * assignRef(refObject, "refValue");
1276
+ * assignRef(refFn, "refValue");
1277
+ */
1278
+ function assignRef(ref, value) {
1279
+ if (typeof ref === 'function') {
1280
+ ref(value);
1281
+ }
1282
+ else if (ref) {
1283
+ ref.current = value;
1284
+ }
1285
+ return ref;
1286
+ }
1287
+
1288
+ /**
1289
+ * creates a MutableRef with ref change callback
1290
+ * @param initialValue - initial ref value
1291
+ * @param {Function} callback - a callback to run when value changes
1292
+ *
1293
+ * @example
1294
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
1295
+ * ref.current = 1;
1296
+ * // prints 0 -> 1
1297
+ *
1298
+ * @see https://reactjs.org/docs/hooks-reference.html#useref
1299
+ * @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
1300
+ * @returns {MutableRefObject}
1301
+ */
1302
+ function useCallbackRef(initialValue, callback) {
1303
+ var ref = React$2.useState(function () { return ({
1304
+ // value
1305
+ value: initialValue,
1306
+ // last callback
1307
+ callback: callback,
1308
+ // "memoized" public interface
1309
+ facade: {
1310
+ get current() {
1311
+ return ref.value;
1312
+ },
1313
+ set current(value) {
1314
+ var last = ref.value;
1315
+ if (last !== value) {
1316
+ ref.value = value;
1317
+ ref.callback(value, last);
1318
+ }
1319
+ },
1320
+ },
1321
+ }); })[0];
1322
+ // update callback
1323
+ ref.callback = callback;
1324
+ return ref.facade;
1325
+ }
1326
+
1327
+ /**
1328
+ * Merges two or more refs together providing a single interface to set their value
1329
+ * @param {RefObject|Ref} refs
1330
+ * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
1331
+ *
1332
+ * @see {@link mergeRefs} a version without buit-in memoization
1333
+ * @see https://github.com/theKashey/use-callback-ref#usemergerefs
1334
+ * @example
1335
+ * const Component = React.forwardRef((props, ref) => {
1336
+ * const ownRef = useRef();
1337
+ * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
1338
+ * return <div ref={domRef}>...</div>
1339
+ * }
1340
+ */
1341
+ function useMergeRefs(refs, defaultValue) {
1342
+ return useCallbackRef(defaultValue || null, function (newValue) { return refs.forEach(function (ref) { return assignRef(ref, newValue); }); });
1343
+ }
1344
+
1345
+ /*! *****************************************************************************
1346
+ Copyright (c) Microsoft Corporation.
1347
+
1348
+ Permission to use, copy, modify, and/or distribute this software for any
1349
+ purpose with or without fee is hereby granted.
1350
+
1351
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1352
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1353
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1354
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1355
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1356
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1357
+ PERFORMANCE OF THIS SOFTWARE.
1358
+ ***************************************************************************** */
1359
+
1360
+ var __assign = function() {
1361
+ __assign = Object.assign || function __assign(t) {
1362
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1363
+ s = arguments[i];
1364
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1365
+ }
1366
+ return t;
1367
+ };
1368
+ return __assign.apply(this, arguments);
1369
+ };
1370
+
1371
+ function __rest(s, e) {
1372
+ var t = {};
1373
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1374
+ t[p] = s[p];
1375
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1376
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1377
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1378
+ t[p[i]] = s[p[i]];
1379
+ }
1380
+ return t;
1381
+ }
1382
+
1383
+ function ItoI(a) {
1384
+ return a;
1385
+ }
1386
+ function innerCreateMedium(defaults, middleware) {
1387
+ if (middleware === void 0) { middleware = ItoI; }
1388
+ var buffer = [];
1389
+ var assigned = false;
1390
+ var medium = {
1391
+ read: function () {
1392
+ if (assigned) {
1393
+ throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
1394
+ }
1395
+ if (buffer.length) {
1396
+ return buffer[buffer.length - 1];
1397
+ }
1398
+ return defaults;
1399
+ },
1400
+ useMedium: function (data) {
1401
+ var item = middleware(data, assigned);
1402
+ buffer.push(item);
1403
+ return function () {
1404
+ buffer = buffer.filter(function (x) { return x !== item; });
1405
+ };
1406
+ },
1407
+ assignSyncMedium: function (cb) {
1408
+ assigned = true;
1409
+ while (buffer.length) {
1410
+ var cbs = buffer;
1411
+ buffer = [];
1412
+ cbs.forEach(cb);
1413
+ }
1414
+ buffer = {
1415
+ push: function (x) { return cb(x); },
1416
+ filter: function () { return buffer; },
1417
+ };
1418
+ },
1419
+ assignMedium: function (cb) {
1420
+ assigned = true;
1421
+ var pendingQueue = [];
1422
+ if (buffer.length) {
1423
+ var cbs = buffer;
1424
+ buffer = [];
1425
+ cbs.forEach(cb);
1426
+ pendingQueue = buffer;
1427
+ }
1428
+ var executeQueue = function () {
1429
+ var cbs = pendingQueue;
1430
+ pendingQueue = [];
1431
+ cbs.forEach(cb);
1432
+ };
1433
+ var cycle = function () { return Promise.resolve().then(executeQueue); };
1434
+ cycle();
1435
+ buffer = {
1436
+ push: function (x) {
1437
+ pendingQueue.push(x);
1438
+ cycle();
1439
+ },
1440
+ filter: function (filter) {
1441
+ pendingQueue = pendingQueue.filter(filter);
1442
+ return buffer;
1443
+ },
1444
+ };
1445
+ },
1446
+ };
1447
+ return medium;
1448
+ }
1449
+ // eslint-disable-next-line @typescript-eslint/ban-types
1450
+ function createSidecarMedium(options) {
1451
+ if (options === void 0) { options = {}; }
1452
+ var medium = innerCreateMedium(null);
1453
+ medium.options = __assign({ async: true, ssr: false }, options);
1454
+ return medium;
1455
+ }
1456
+
1457
+ var SideCar$1 = function (_a) {
1458
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
1459
+ if (!sideCar) {
1460
+ throw new Error('Sidecar: please provide `sideCar` property to import the right car');
1461
+ }
1462
+ var Target = sideCar.read();
1463
+ if (!Target) {
1464
+ throw new Error('Sidecar medium not found');
1465
+ }
1466
+ return React__namespace.createElement(Target, __assign({}, rest));
1467
+ };
1468
+ SideCar$1.isSideCarExport = true;
1469
+ function exportSidecar(medium, exported) {
1470
+ medium.useMedium(exported);
1471
+ return SideCar$1;
1472
+ }
1473
+
1474
+ var effectCar = createSidecarMedium();
1475
+
1476
+ var nothing = function () {
1477
+ return;
1478
+ };
1479
+ /**
1480
+ * Removes scrollbar from the page and contain the scroll within the Lock
1481
+ */
1482
+ var RemoveScroll = React__namespace.forwardRef(function (props, parentRef) {
1483
+ var ref = React__namespace.useRef(null);
1484
+ var _a = React__namespace.useState({
1485
+ onScrollCapture: nothing,
1486
+ onWheelCapture: nothing,
1487
+ onTouchMoveCapture: nothing,
1488
+ }), callbacks = _a[0], setCallbacks = _a[1];
1489
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, rest = __rest$1(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as"]);
1490
+ var SideCar = sideCar;
1491
+ var containerRef = useMergeRefs([ref, parentRef]);
1492
+ var containerProps = __assign$1(__assign$1({}, rest), callbacks);
1493
+ return (React__namespace.createElement(React__namespace.Fragment, null,
1494
+ enabled && (React__namespace.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref })),
1495
+ forwardProps ? (React__namespace.cloneElement(React__namespace.Children.only(children), __assign$1(__assign$1({}, containerProps), { ref: containerRef }))) : (React__namespace.createElement(Container, __assign$1({}, containerProps, { className: className, ref: containerRef }), children))));
1496
+ });
1497
+ RemoveScroll.defaultProps = {
1498
+ enabled: true,
1499
+ removeScrollBar: true,
1500
+ inert: false,
1501
+ };
1502
+ RemoveScroll.classNames = {
1503
+ fullWidth: fullWidthClassName,
1504
+ zeroRight: zeroRightClassName,
1505
+ };
1506
+
1507
+ var getNonce = function () {
1508
+ if (typeof __webpack_nonce__ !== 'undefined') {
1509
+ return __webpack_nonce__;
1510
+ }
1511
+ return undefined;
1512
+ };
1513
+
1514
+ function makeStyleTag() {
1515
+ if (!document)
1516
+ return null;
1517
+ var tag = document.createElement('style');
1518
+ tag.type = 'text/css';
1519
+ var nonce = getNonce();
1520
+ if (nonce) {
1521
+ tag.setAttribute('nonce', nonce);
1522
+ }
1523
+ return tag;
1524
+ }
1525
+ function injectStyles(tag, css) {
1526
+ // @ts-ignore
1527
+ if (tag.styleSheet) {
1528
+ // @ts-ignore
1529
+ tag.styleSheet.cssText = css;
1530
+ }
1531
+ else {
1532
+ tag.appendChild(document.createTextNode(css));
1533
+ }
1534
+ }
1535
+ function insertStyleTag(tag) {
1536
+ var head = document.head || document.getElementsByTagName('head')[0];
1537
+ head.appendChild(tag);
1538
+ }
1539
+ var stylesheetSingleton = function () {
1540
+ var counter = 0;
1541
+ var stylesheet = null;
1542
+ return {
1543
+ add: function (style) {
1544
+ if (counter == 0) {
1545
+ if ((stylesheet = makeStyleTag())) {
1546
+ injectStyles(stylesheet, style);
1547
+ insertStyleTag(stylesheet);
1548
+ }
1549
+ }
1550
+ counter++;
1551
+ },
1552
+ remove: function () {
1553
+ counter--;
1554
+ if (!counter && stylesheet) {
1555
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
1556
+ stylesheet = null;
1557
+ }
1558
+ },
1559
+ };
1560
+ };
1561
+
1562
+ /**
1563
+ * creates a hook to control style singleton
1564
+ * @see {@link styleSingleton} for a safer component version
1565
+ * @example
1566
+ * ```tsx
1567
+ * const useStyle = styleHookSingleton();
1568
+ * ///
1569
+ * useStyle('body { overflow: hidden}');
1570
+ */
1571
+ var styleHookSingleton = function () {
1572
+ var sheet = stylesheetSingleton();
1573
+ return function (styles, isDynamic) {
1574
+ React__namespace.useEffect(function () {
1575
+ sheet.add(styles);
1576
+ return function () {
1577
+ sheet.remove();
1578
+ };
1579
+ }, [styles && isDynamic]);
1580
+ };
1581
+ };
1582
+
1583
+ /**
1584
+ * create a Component to add styles on demand
1585
+ * - styles are added when first instance is mounted
1586
+ * - styles are removed when the last instance is unmounted
1587
+ * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
1588
+ */
1589
+ var styleSingleton = function () {
1590
+ var useStyle = styleHookSingleton();
1591
+ var Sheet = function (_a) {
1592
+ var styles = _a.styles, dynamic = _a.dynamic;
1593
+ useStyle(styles, dynamic);
1594
+ return null;
1595
+ };
1596
+ return Sheet;
1597
+ };
1598
+
1599
+ var zeroGap = {
1600
+ left: 0,
1601
+ top: 0,
1602
+ right: 0,
1603
+ gap: 0,
1604
+ };
1605
+ var parse = function (x) { return parseInt(x || '', 10) || 0; };
1606
+ var getOffset = function (gapMode) {
1607
+ var cs = window.getComputedStyle(document.body);
1608
+ var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
1609
+ var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
1610
+ var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
1611
+ return [parse(left), parse(top), parse(right)];
1612
+ };
1613
+ var getGapWidth = function (gapMode) {
1614
+ if (gapMode === void 0) { gapMode = 'margin'; }
1615
+ if (typeof window === 'undefined') {
1616
+ return zeroGap;
1617
+ }
1618
+ var offsets = getOffset(gapMode);
1619
+ var documentWidth = document.documentElement.clientWidth;
1620
+ var windowWidth = window.innerWidth;
1621
+ return {
1622
+ left: offsets[0],
1623
+ top: offsets[1],
1624
+ right: offsets[2],
1625
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
1626
+ };
1627
+ };
1628
+
1629
+ var Style = styleSingleton();
1630
+ // important tip - once we measure scrollBar width and remove them
1631
+ // we could not repeat this operation
1632
+ // thus we are using style-singleton - only the first "yet correct" style will be applied.
1633
+ var getStyles = function (_a, allowRelative, gapMode, important) {
1634
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
1635
+ if (gapMode === void 0) { gapMode = 'margin'; }
1636
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
1637
+ allowRelative && "position: relative ".concat(important, ";"),
1638
+ gapMode === 'margin' &&
1639
+ "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
1640
+ gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
1641
+ ]
1642
+ .filter(Boolean)
1643
+ .join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
1644
+ };
1645
+ /**
1646
+ * Removes page scrollbar and blocks page scroll when mounted
1647
+ */
1648
+ var RemoveScrollBar = function (props) {
1649
+ var noRelative = props.noRelative, noImportant = props.noImportant, _a = props.gapMode, gapMode = _a === void 0 ? 'margin' : _a;
1650
+ /*
1651
+ gap will be measured on every component mount
1652
+ however it will be used only by the "first" invocation
1653
+ due to singleton nature of <Style
1654
+ */
1655
+ var gap = React__namespace.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
1656
+ return React__namespace.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
1657
+ };
1658
+
1659
+ var passiveSupported = false;
1660
+ if (typeof window !== 'undefined') {
1661
+ try {
1662
+ var options = Object.defineProperty({}, 'passive', {
1663
+ get: function () {
1664
+ passiveSupported = true;
1665
+ return true;
1666
+ },
1667
+ });
1668
+ // @ts-ignore
1669
+ window.addEventListener('test', options, options);
1670
+ // @ts-ignore
1671
+ window.removeEventListener('test', options, options);
1672
+ }
1673
+ catch (err) {
1674
+ passiveSupported = false;
1675
+ }
1676
+ }
1677
+ var nonPassive = passiveSupported ? { passive: false } : false;
1678
+
1679
+ var alwaysContainsScroll = function (node) {
1680
+ // textarea will always _contain_ scroll inside self. It only can be hidden
1681
+ return node.tagName === 'TEXTAREA';
1682
+ };
1683
+ var elementCanBeScrolled = function (node, overflow) {
1684
+ var styles = window.getComputedStyle(node);
1685
+ return (
1686
+ // not-not-scrollable
1687
+ styles[overflow] !== 'hidden' &&
1688
+ // contains scroll inside self
1689
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
1690
+ };
1691
+ var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
1692
+ var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
1693
+ var locationCouldBeScrolled = function (axis, node) {
1694
+ var current = node;
1695
+ do {
1696
+ // Skip over shadow root
1697
+ if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
1698
+ current = current.host;
1699
+ }
1700
+ var isScrollable = elementCouldBeScrolled(axis, current);
1701
+ if (isScrollable) {
1702
+ var _a = getScrollVariables(axis, current), s = _a[1], d = _a[2];
1703
+ if (s > d) {
1704
+ return true;
1705
+ }
1706
+ }
1707
+ current = current.parentNode;
1708
+ } while (current && current !== document.body);
1709
+ return false;
1710
+ };
1711
+ var getVScrollVariables = function (_a) {
1712
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
1713
+ return [
1714
+ scrollTop,
1715
+ scrollHeight,
1716
+ clientHeight,
1717
+ ];
1718
+ };
1719
+ var getHScrollVariables = function (_a) {
1720
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
1721
+ return [
1722
+ scrollLeft,
1723
+ scrollWidth,
1724
+ clientWidth,
1725
+ ];
1726
+ };
1727
+ var elementCouldBeScrolled = function (axis, node) {
1728
+ return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
1729
+ };
1730
+ var getScrollVariables = function (axis, node) {
1731
+ return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
1732
+ };
1733
+ var getDirectionFactor = function (axis, direction) {
1734
+ /**
1735
+ * If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
1736
+ * and then increasingly negative as you scroll towards the end of the content.
1737
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
1738
+ */
1739
+ return axis === 'h' && direction === 'rtl' ? -1 : 1;
1740
+ };
1741
+ var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
1742
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
1743
+ var delta = directionFactor * sourceDelta;
1744
+ // find scrollable target
1745
+ var target = event.target;
1746
+ var targetInLock = endTarget.contains(target);
1747
+ var shouldCancelScroll = false;
1748
+ var isDeltaPositive = delta > 0;
1749
+ var availableScroll = 0;
1750
+ var availableScrollTop = 0;
1751
+ do {
1752
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
1753
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
1754
+ if (position || elementScroll) {
1755
+ if (elementCouldBeScrolled(axis, target)) {
1756
+ availableScroll += elementScroll;
1757
+ availableScrollTop += position;
1758
+ }
1759
+ }
1760
+ target = target.parentNode;
1761
+ } while (
1762
+ // portaled content
1763
+ (!targetInLock && target !== document.body) ||
1764
+ // self content
1765
+ (targetInLock && (endTarget.contains(target) || endTarget === target)));
1766
+ if (isDeltaPositive && ((noOverscroll && availableScroll === 0) || (!noOverscroll && delta > availableScroll))) {
1767
+ shouldCancelScroll = true;
1768
+ }
1769
+ else if (!isDeltaPositive &&
1770
+ ((noOverscroll && availableScrollTop === 0) || (!noOverscroll && -delta > availableScrollTop))) {
1771
+ shouldCancelScroll = true;
1772
+ }
1773
+ return shouldCancelScroll;
1774
+ };
1775
+
1776
+ var getTouchXY = function (event) {
1777
+ return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
1778
+ };
1779
+ var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
1780
+ var extractRef = function (ref) {
1781
+ return ref && 'current' in ref ? ref.current : ref;
1782
+ };
1783
+ var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
1784
+ var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
1785
+ var idCounter = 0;
1786
+ var lockStack = [];
1787
+ function RemoveScrollSideCar(props) {
1788
+ var shouldPreventQueue = React__namespace.useRef([]);
1789
+ var touchStartRef = React__namespace.useRef([0, 0]);
1790
+ var activeAxis = React__namespace.useRef();
1791
+ var id = React__namespace.useState(idCounter++)[0];
1792
+ var Style = React__namespace.useState(function () { return styleSingleton(); })[0];
1793
+ var lastProps = React__namespace.useRef(props);
1794
+ React__namespace.useEffect(function () {
1795
+ lastProps.current = props;
1796
+ }, [props]);
1797
+ React__namespace.useEffect(function () {
1798
+ if (props.inert) {
1799
+ document.body.classList.add("block-interactivity-".concat(id));
1800
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
1801
+ allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
1802
+ return function () {
1803
+ document.body.classList.remove("block-interactivity-".concat(id));
1804
+ allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
1805
+ };
1806
+ }
1807
+ return;
1808
+ }, [props.inert, props.lockRef.current, props.shards]);
1809
+ var shouldCancelEvent = React__namespace.useCallback(function (event, parent) {
1810
+ if ('touches' in event && event.touches.length === 2) {
1811
+ return !lastProps.current.allowPinchZoom;
1812
+ }
1813
+ var touch = getTouchXY(event);
1814
+ var touchStart = touchStartRef.current;
1815
+ var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
1816
+ var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
1817
+ var currentAxis;
1818
+ var target = event.target;
1819
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
1820
+ // allow horizontal touch move on Range inputs. They will not cause any scroll
1821
+ if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
1822
+ return false;
1823
+ }
1824
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1825
+ if (!canBeScrolledInMainDirection) {
1826
+ return true;
1827
+ }
1828
+ if (canBeScrolledInMainDirection) {
1829
+ currentAxis = moveDirection;
1830
+ }
1831
+ else {
1832
+ currentAxis = moveDirection === 'v' ? 'h' : 'v';
1833
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1834
+ // other axis might be not scrollable
1835
+ }
1836
+ if (!canBeScrolledInMainDirection) {
1837
+ return false;
1838
+ }
1839
+ if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
1840
+ activeAxis.current = currentAxis;
1841
+ }
1842
+ if (!currentAxis) {
1843
+ return true;
1844
+ }
1845
+ var cancelingAxis = activeAxis.current || currentAxis;
1846
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY, true);
1847
+ }, []);
1848
+ var shouldPrevent = React__namespace.useCallback(function (_event) {
1849
+ var event = _event;
1850
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
1851
+ // not the last active
1852
+ return;
1853
+ }
1854
+ var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
1855
+ var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && e.target === event.target && deltaCompare(e.delta, delta); })[0];
1856
+ // self event, and should be canceled
1857
+ if (sourceEvent && sourceEvent.should) {
1858
+ if (event.cancelable) {
1859
+ event.preventDefault();
1860
+ }
1861
+ return;
1862
+ }
1863
+ // outside or shard event
1864
+ if (!sourceEvent) {
1865
+ var shardNodes = (lastProps.current.shards || [])
1866
+ .map(extractRef)
1867
+ .filter(Boolean)
1868
+ .filter(function (node) { return node.contains(event.target); });
1869
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
1870
+ if (shouldStop) {
1871
+ if (event.cancelable) {
1872
+ event.preventDefault();
1873
+ }
1874
+ }
1875
+ }
1876
+ }, []);
1877
+ var shouldCancel = React__namespace.useCallback(function (name, delta, target, should) {
1878
+ var event = { name: name, delta: delta, target: target, should: should };
1879
+ shouldPreventQueue.current.push(event);
1880
+ setTimeout(function () {
1881
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
1882
+ }, 1);
1883
+ }, []);
1884
+ var scrollTouchStart = React__namespace.useCallback(function (event) {
1885
+ touchStartRef.current = getTouchXY(event);
1886
+ activeAxis.current = undefined;
1887
+ }, []);
1888
+ var scrollWheel = React__namespace.useCallback(function (event) {
1889
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1890
+ }, []);
1891
+ var scrollTouchMove = React__namespace.useCallback(function (event) {
1892
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1893
+ }, []);
1894
+ React__namespace.useEffect(function () {
1895
+ lockStack.push(Style);
1896
+ props.setCallbacks({
1897
+ onScrollCapture: scrollWheel,
1898
+ onWheelCapture: scrollWheel,
1899
+ onTouchMoveCapture: scrollTouchMove,
1900
+ });
1901
+ document.addEventListener('wheel', shouldPrevent, nonPassive);
1902
+ document.addEventListener('touchmove', shouldPrevent, nonPassive);
1903
+ document.addEventListener('touchstart', scrollTouchStart, nonPassive);
1904
+ return function () {
1905
+ lockStack = lockStack.filter(function (inst) { return inst !== Style; });
1906
+ document.removeEventListener('wheel', shouldPrevent, nonPassive);
1907
+ document.removeEventListener('touchmove', shouldPrevent, nonPassive);
1908
+ document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
1909
+ };
1910
+ }, []);
1911
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
1912
+ return (React__namespace.createElement(React__namespace.Fragment, null,
1913
+ inert ? React__namespace.createElement(Style, { styles: generateStyle(id) }) : null,
1914
+ removeScrollBar ? React__namespace.createElement(RemoveScrollBar, { gapMode: "margin" }) : null));
1915
+ }
1916
+
1917
+ var SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
1918
+
1919
+ var ReactRemoveScroll = React__namespace.forwardRef(function (props, ref) { return (React__namespace.createElement(RemoveScroll, __assign$1({}, props, { ref: ref, sideCar: SideCar }))); });
1920
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
1921
+ var $01b9c$RemoveScroll = ReactRemoveScroll;
1922
+
1923
+ const $cc7e05a45900e73f$var$OPEN_KEYS = [
1924
+ ' ',
1925
+ 'Enter',
1926
+ 'ArrowUp',
1927
+ 'ArrowDown'
1928
+ ];
1929
+ const $cc7e05a45900e73f$var$SELECTION_KEYS = [
1930
+ ' ',
1931
+ 'Enter'
1932
+ ];
1933
+ /* -------------------------------------------------------------------------------------------------
1934
+ * Select
1935
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SELECT_NAME = 'Select';
1936
+ const [$cc7e05a45900e73f$var$Collection, $cc7e05a45900e73f$var$useCollection, $cc7e05a45900e73f$var$createCollectionScope] = $e02a7d9cb1dc128c$export$c74125a8e3af6bb2($cc7e05a45900e73f$var$SELECT_NAME);
1937
+ const [$cc7e05a45900e73f$var$createSelectContext, $cc7e05a45900e73f$export$286727a75dc039bd] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($cc7e05a45900e73f$var$SELECT_NAME, [
1938
+ $cc7e05a45900e73f$var$createCollectionScope
1939
+ ]);
1940
+ const [$cc7e05a45900e73f$var$SelectProvider, $cc7e05a45900e73f$var$useSelectContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
1941
+ const [$cc7e05a45900e73f$var$SelectNativeOptionsProvider, $cc7e05a45900e73f$var$useSelectNativeOptionsContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
1942
+ const $cc7e05a45900e73f$export$ef9b1a59e592288f = (props)=>{
1943
+ const { __scopeSelect: __scopeSelect , children: children , open: openProp , defaultOpen: defaultOpen , onOpenChange: onOpenChange , value: valueProp , defaultValue: defaultValue , onValueChange: onValueChange , dir: dir , name: name , autoComplete: autoComplete , disabled: disabled , required: required } = props;
1944
+ const [trigger, setTrigger] = React$2.useState(null);
1945
+ const [valueNode, setValueNode] = React$2.useState(null);
1946
+ const [valueNodeHasChildren, setValueNodeHasChildren] = React$2.useState(false);
1947
+ const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
1948
+ const [open = false, setOpen] = $71cd76cc60e0454e$export$6f32135080cb4c3({
1949
+ prop: openProp,
1950
+ defaultProp: defaultOpen,
1951
+ onChange: onOpenChange
1952
+ });
1953
+ const [value, setValue] = $71cd76cc60e0454e$export$6f32135080cb4c3({
1954
+ prop: valueProp,
1955
+ defaultProp: defaultValue,
1956
+ onChange: onValueChange
1957
+ });
1958
+ const triggerPointerDownPosRef = React$2.useRef(null); // We set this to true by default so that events bubble to forms without JS (SSR)
1959
+ const isFormControl = trigger ? Boolean(trigger.closest('form')) : true;
1960
+ const [nativeOptionsSet, setNativeOptionsSet] = React$2.useState(new Set()); // The native `select` only associates the correct default value if the corresponding
1961
+ // `option` is rendered as a child **at the same time** as itself.
1962
+ // Because it might take a few renders for our items to gather the information to build
1963
+ // the native `option`(s), we generate a key on the `select` to make sure React re-builds it
1964
+ // each time the options change.
1965
+ const nativeSelectKey = Array.from(nativeOptionsSet).map((option)=>option.props.value
1966
+ ).join(';');
1967
+ return /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectProvider, {
1968
+ required: required,
1969
+ scope: __scopeSelect,
1970
+ trigger: trigger,
1971
+ onTriggerChange: setTrigger,
1972
+ valueNode: valueNode,
1973
+ onValueNodeChange: setValueNode,
1974
+ valueNodeHasChildren: valueNodeHasChildren,
1975
+ onValueNodeHasChildrenChange: setValueNodeHasChildren,
1976
+ contentId: $1746a345f3d73bb7$export$f680877a34711e37(),
1977
+ value: value,
1978
+ onValueChange: setValue,
1979
+ open: open,
1980
+ onOpenChange: setOpen,
1981
+ dir: direction,
1982
+ triggerPointerDownPosRef: triggerPointerDownPosRef,
1983
+ disabled: disabled
1984
+ }, /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$Collection.Provider, {
1985
+ scope: __scopeSelect
1986
+ }, /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectNativeOptionsProvider, {
1987
+ scope: props.__scopeSelect,
1988
+ onNativeOptionAdd: React$2.useCallback((option)=>{
1989
+ setNativeOptionsSet((prev)=>new Set(prev).add(option)
1990
+ );
1991
+ }, []),
1992
+ onNativeOptionRemove: React$2.useCallback((option)=>{
1993
+ setNativeOptionsSet((prev)=>{
1994
+ const optionsSet = new Set(prev);
1995
+ optionsSet.delete(option);
1996
+ return optionsSet;
1997
+ });
1998
+ }, [])
1999
+ }, children)), isFormControl ? /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$BubbleSelect, {
2000
+ key: nativeSelectKey,
2001
+ "aria-hidden": true,
2002
+ required: required,
2003
+ tabIndex: -1,
2004
+ name: name,
2005
+ autoComplete: autoComplete,
2006
+ value: value // enable form autofill
2007
+ ,
2008
+ onChange: (event)=>setValue(event.target.value)
2009
+ ,
2010
+ disabled: disabled
2011
+ }, value === undefined ? /*#__PURE__*/ React$2.createElement("option", {
2012
+ value: ""
2013
+ }) : null, Array.from(nativeOptionsSet)) : null);
2014
+ };
2015
+ /* -------------------------------------------------------------------------------------------------
2016
+ * SelectTrigger
2017
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$TRIGGER_NAME = 'SelectTrigger';
2018
+ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2019
+ const { __scopeSelect: __scopeSelect , disabled: disabled = false , ...triggerProps } = props;
2020
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$TRIGGER_NAME, __scopeSelect);
2021
+ const isDisabled = context.disabled || disabled;
2022
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.onTriggerChange);
2023
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
2024
+ const [searchRef, handleTypeaheadSearch, resetTypeahead] = $cc7e05a45900e73f$var$useTypeaheadSearch((search)=>{
2025
+ const enabledItems = getItems().filter((item)=>!item.disabled
2026
+ );
2027
+ const currentItem = enabledItems.find((item)=>item.value === context.value
2028
+ );
2029
+ const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
2030
+ if (nextItem !== undefined) context.onValueChange(nextItem.value);
2031
+ });
2032
+ const handleOpen = ()=>{
2033
+ if (!isDisabled) {
2034
+ context.onOpenChange(true); // reset typeahead when we open
2035
+ resetTypeahead();
2036
+ }
2037
+ };
2038
+ return /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
2039
+ type: "button",
2040
+ role: "combobox",
2041
+ "aria-controls": context.contentId,
2042
+ "aria-expanded": context.open,
2043
+ "aria-required": context.required,
2044
+ "aria-autocomplete": "none",
2045
+ dir: context.dir,
2046
+ "data-state": context.open ? 'open' : 'closed',
2047
+ disabled: isDisabled,
2048
+ "data-disabled": isDisabled ? '' : undefined,
2049
+ "data-placeholder": context.value === undefined ? '' : undefined
2050
+ }, triggerProps, {
2051
+ ref: composedRefs // Enable compatibility with native label or custom `Label` "click" for Safari:
2052
+ ,
2053
+ onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onClick, (event)=>{
2054
+ // Whilst browsers generally have no issue focusing the trigger when clicking
2055
+ // on a label, Safari seems to struggle with the fact that there's no `onClick`.
2056
+ // We force `focus` in this case. Note: this doesn't create any other side-effect
2057
+ // because we are preventing default in `onPointerDown` so effectively
2058
+ // this only runs for a label "click"
2059
+ event.currentTarget.focus();
2060
+ }),
2061
+ onPointerDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onPointerDown, (event)=>{
2062
+ // prevent implicit pointer capture
2063
+ // https://www.w3.org/TR/pointerevents3/#implicit-pointer-capture
2064
+ const target = event.target;
2065
+ if (target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
2066
+ // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
2067
+ // but not when the control key is pressed (avoiding MacOS right click)
2068
+ if (event.button === 0 && event.ctrlKey === false) {
2069
+ handleOpen();
2070
+ context.triggerPointerDownPosRef.current = {
2071
+ x: Math.round(event.pageX),
2072
+ y: Math.round(event.pageY)
2073
+ }; // prevent trigger from stealing focus from the active item after opening.
2074
+ event.preventDefault();
2075
+ }
2076
+ }),
2077
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(triggerProps.onKeyDown, (event)=>{
2078
+ const isTypingAhead = searchRef.current !== '';
2079
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
2080
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
2081
+ if (isTypingAhead && event.key === ' ') return;
2082
+ if ($cc7e05a45900e73f$var$OPEN_KEYS.includes(event.key)) {
2083
+ handleOpen();
2084
+ event.preventDefault();
2085
+ }
2086
+ })
2087
+ }));
2088
+ });
2089
+ /* -------------------------------------------------------------------------------------------------
2090
+ * SelectValue
2091
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VALUE_NAME = 'SelectValue';
2092
+ const $cc7e05a45900e73f$export$e288731fd71264f0 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2093
+ // We ignore `className` and `style` as this part shouldn't be styled.
2094
+ const { __scopeSelect: __scopeSelect , className: className , style: style , children: children , placeholder: placeholder , ...valueProps } = props;
2095
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$VALUE_NAME, __scopeSelect);
2096
+ const { onValueNodeHasChildrenChange: onValueNodeHasChildrenChange } = context;
2097
+ const hasChildren = children !== undefined;
2098
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.onValueNodeChange);
2099
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2100
+ onValueNodeHasChildrenChange(hasChildren);
2101
+ }, [
2102
+ onValueNodeHasChildrenChange,
2103
+ hasChildren
2104
+ ]);
2105
+ return /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, valueProps, {
2106
+ ref: composedRefs // we don't want events from the portalled `SelectValue` children to bubble
2107
+ ,
2108
+ style: {
2109
+ pointerEvents: 'none'
2110
+ }
2111
+ }), context.value === undefined && placeholder !== undefined ? placeholder : children);
2112
+ });
2113
+ const $cc7e05a45900e73f$export$99b400cabb58c515 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2114
+ const { __scopeSelect: __scopeSelect , children: children , ...iconProps } = props;
2115
+ return /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
2116
+ "aria-hidden": true
2117
+ }, iconProps, {
2118
+ ref: forwardedRef
2119
+ }), children || '▼');
2120
+ });
2121
+ const $cc7e05a45900e73f$export$b2af6c9944296213 = (props)=>{
2122
+ return /*#__PURE__*/ React$2.createElement($f1701beae083dbae$export$602eac185826482c, _extends({
2123
+ asChild: true
2124
+ }, props));
2125
+ };
2126
+ /* -------------------------------------------------------------------------------------------------
2127
+ * SelectContent
2128
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$CONTENT_NAME = 'SelectContent';
2129
+ const $cc7e05a45900e73f$export$c973a4b3cb86a03d = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2130
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, props.__scopeSelect);
2131
+ const [fragment, setFragment] = React$2.useState(); // setting the fragment in `useLayoutEffect` as `DocumentFragment` doesn't exist on the server
2132
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2133
+ setFragment(new DocumentFragment());
2134
+ }, []);
2135
+ return /*#__PURE__*/ React$2.createElement(React$2.Fragment, null, context.open ? /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectContentImpl, _extends({}, props, {
2136
+ ref: forwardedRef
2137
+ })) : fragment ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(/*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectContentProvider, {
2138
+ scope: props.__scopeSelect
2139
+ }, /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$Collection.Slot, {
2140
+ scope: props.__scopeSelect
2141
+ }, /*#__PURE__*/ React$2.createElement("div", null, props.children))), fragment) : null);
2142
+ });
2143
+ const $cc7e05a45900e73f$var$CONTENT_MARGIN = 10;
2144
+ const [$cc7e05a45900e73f$var$SelectContentProvider, $cc7e05a45900e73f$var$useSelectContentContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME);
2145
+ const $cc7e05a45900e73f$var$SelectContentImpl = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2146
+ const { __scopeSelect: __scopeSelect , onCloseAutoFocus: onCloseAutoFocus , ...contentProps } = props;
2147
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
2148
+ const [contentWrapper, setContentWrapper] = React$2.useState(null);
2149
+ const [content, setContent] = React$2.useState(null);
2150
+ const [viewport, setViewport] = React$2.useState(null);
2151
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setContent(node)
2152
+ );
2153
+ const [selectedItem, setSelectedItem] = React$2.useState(null);
2154
+ const [selectedItemText, setSelectedItemText] = React$2.useState(null);
2155
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
2156
+ const [isPositioned, setIsPositioned] = React$2.useState(false);
2157
+ const shouldRepositionRef = React$2.useRef(true);
2158
+ const shouldExpandOnScrollRef = React$2.useRef(false);
2159
+ const firstValidItemFoundRef = React$2.useRef(false); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
2160
+ React$2.useEffect(()=>{
2161
+ if (content) return hideOthers(content);
2162
+ }, [
2163
+ content
2164
+ ]); // Make sure the whole tree has focus guards as our `Select` may be
2165
+ // the last element in the DOM (because of the `Portal`)
2166
+ $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
2167
+ const [contentZIndex, setContentZIndex] = React$2.useState();
2168
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2169
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
2170
+ }, [
2171
+ content
2172
+ ]);
2173
+ const focusFirst = React$2.useCallback((candidates)=>{
2174
+ const [firstItem, ...restItems] = getItems().map((item)=>item.ref.current
2175
+ );
2176
+ const [lastItem] = restItems.slice(-1);
2177
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
2178
+ for (const candidate of candidates){
2179
+ // if focus is already where we want to go, we don't want to keep going through the candidates
2180
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
2181
+ candidate === null || candidate === void 0 || candidate.scrollIntoView({
2182
+ block: 'nearest'
2183
+ }); // viewport might have padding so scroll to its edges when focusing first/last items.
2184
+ if (candidate === firstItem && viewport) viewport.scrollTop = 0;
2185
+ if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
2186
+ candidate === null || candidate === void 0 || candidate.focus();
2187
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
2188
+ }
2189
+ }, [
2190
+ getItems,
2191
+ viewport
2192
+ ]);
2193
+ const position = React$2.useCallback(()=>{
2194
+ if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
2195
+ const triggerRect = context.trigger.getBoundingClientRect(); // -----------------------------------------------------------------------------------------
2196
+ // Horizontal positioning
2197
+ // -----------------------------------------------------------------------------------------
2198
+ const contentRect = content.getBoundingClientRect();
2199
+ const valueNodeRect = context.valueNode.getBoundingClientRect();
2200
+ const itemTextRect = selectedItemText.getBoundingClientRect();
2201
+ if (context.dir !== 'rtl') {
2202
+ const itemTextOffset = itemTextRect.left - contentRect.left;
2203
+ const left = valueNodeRect.left - itemTextOffset;
2204
+ const leftDelta = triggerRect.left - left;
2205
+ const minContentWidth = triggerRect.width + leftDelta;
2206
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
2207
+ const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
2208
+ const clampedLeft = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(left, [
2209
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
2210
+ rightEdge - contentWidth
2211
+ ]);
2212
+ contentWrapper.style.minWidth = minContentWidth + 'px';
2213
+ contentWrapper.style.left = clampedLeft + 'px';
2214
+ } else {
2215
+ const itemTextOffset = contentRect.right - itemTextRect.right;
2216
+ const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
2217
+ const rightDelta = window.innerWidth - triggerRect.right - right;
2218
+ const minContentWidth = triggerRect.width + rightDelta;
2219
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
2220
+ const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
2221
+ const clampedRight = $ae6933e535247d3d$export$7d15b64cf5a3a4c4(right, [
2222
+ $cc7e05a45900e73f$var$CONTENT_MARGIN,
2223
+ leftEdge - contentWidth
2224
+ ]);
2225
+ contentWrapper.style.minWidth = minContentWidth + 'px';
2226
+ contentWrapper.style.right = clampedRight + 'px';
2227
+ } // -----------------------------------------------------------------------------------------
2228
+ // Vertical positioning
2229
+ // -----------------------------------------------------------------------------------------
2230
+ const items = getItems();
2231
+ const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
2232
+ const itemsHeight = viewport.scrollHeight;
2233
+ const contentStyles = window.getComputedStyle(content);
2234
+ const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
2235
+ const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
2236
+ const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
2237
+ const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
2238
+ const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth; // prettier-ignore
2239
+ const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
2240
+ const viewportStyles = window.getComputedStyle(viewport);
2241
+ const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
2242
+ const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
2243
+ const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
2244
+ const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
2245
+ const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
2246
+ const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
2247
+ const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
2248
+ const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
2249
+ const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
2250
+ if (willAlignWithoutTopOverflow) {
2251
+ const isLastItem = selectedItem === items[items.length - 1].ref.current;
2252
+ contentWrapper.style.bottom = "0px";
2253
+ const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
2254
+ const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
2255
+ const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
2256
+ contentWrapper.style.height = height + 'px';
2257
+ } else {
2258
+ const isFirstItem = selectedItem === items[0].ref.current;
2259
+ contentWrapper.style.top = "0px";
2260
+ const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
2261
+ const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
2262
+ contentWrapper.style.height = height + 'px';
2263
+ viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
2264
+ }
2265
+ contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
2266
+ contentWrapper.style.minHeight = minContentHeight + 'px';
2267
+ contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
2268
+ setIsPositioned(true); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
2269
+ // so we explicitly turn it on only after they've registered.
2270
+ requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
2271
+ );
2272
+ }
2273
+ }, [
2274
+ getItems,
2275
+ context.trigger,
2276
+ context.valueNode,
2277
+ contentWrapper,
2278
+ content,
2279
+ viewport,
2280
+ selectedItem,
2281
+ selectedItemText,
2282
+ context.dir
2283
+ ]);
2284
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>position()
2285
+ , [
2286
+ position
2287
+ ]);
2288
+ const focusSelectedItem = React$2.useCallback(()=>focusFirst([
2289
+ selectedItem,
2290
+ content
2291
+ ])
2292
+ , [
2293
+ focusFirst,
2294
+ selectedItem,
2295
+ content
2296
+ ]); // Since this is not dependent on layout, we want to ensure this runs at the same time as
2297
+ // other effects across components. Hence why we don't call `focusSelectedItem` inside `position`.
2298
+ React$2.useEffect(()=>{
2299
+ if (isPositioned) focusSelectedItem();
2300
+ }, [
2301
+ isPositioned,
2302
+ focusSelectedItem
2303
+ ]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
2304
+ // Because it is part of the normal flow, it will push down the viewport, thus throwing our
2305
+ // trigger => selectedItem alignment off by the amount the viewport was pushed down.
2306
+ // We wait for this to happen and then re-run the positining logic one more time to account for it.
2307
+ const handleScrollButtonChange = React$2.useCallback((node)=>{
2308
+ if (node && shouldRepositionRef.current === true) {
2309
+ position();
2310
+ focusSelectedItem();
2311
+ shouldRepositionRef.current = false;
2312
+ }
2313
+ }, [
2314
+ position,
2315
+ focusSelectedItem
2316
+ ]); // prevent selecting items on `pointerup` in some cases after opening from `pointerdown`
2317
+ // and close on `pointerup` outside.
2318
+ const { onOpenChange: onOpenChange , triggerPointerDownPosRef: triggerPointerDownPosRef } = context;
2319
+ React$2.useEffect(()=>{
2320
+ if (content) {
2321
+ let pointerMoveDelta = {
2322
+ x: 0,
2323
+ y: 0
2324
+ };
2325
+ const handlePointerMove = (event)=>{
2326
+ var _triggerPointerDownPo, _triggerPointerDownPo2, _triggerPointerDownPo3, _triggerPointerDownPo4;
2327
+ pointerMoveDelta = {
2328
+ x: Math.abs(Math.round(event.pageX) - ((_triggerPointerDownPo = (_triggerPointerDownPo2 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo2 === void 0 ? void 0 : _triggerPointerDownPo2.x) !== null && _triggerPointerDownPo !== void 0 ? _triggerPointerDownPo : 0)),
2329
+ y: Math.abs(Math.round(event.pageY) - ((_triggerPointerDownPo3 = (_triggerPointerDownPo4 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo4 === void 0 ? void 0 : _triggerPointerDownPo4.y) !== null && _triggerPointerDownPo3 !== void 0 ? _triggerPointerDownPo3 : 0))
2330
+ };
2331
+ };
2332
+ const handlePointerUp = (event)=>{
2333
+ // If the pointer hasn't moved by a certain threshold then we prevent selecting item on `pointerup`.
2334
+ if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) event.preventDefault();
2335
+ else // otherwise, if the event was outside the content, close.
2336
+ if (!content.contains(event.target)) onOpenChange(false);
2337
+ document.removeEventListener('pointermove', handlePointerMove);
2338
+ triggerPointerDownPosRef.current = null;
2339
+ };
2340
+ if (triggerPointerDownPosRef.current !== null) {
2341
+ document.addEventListener('pointermove', handlePointerMove);
2342
+ document.addEventListener('pointerup', handlePointerUp, {
2343
+ capture: true,
2344
+ once: true
2345
+ });
2346
+ }
2347
+ return ()=>{
2348
+ document.removeEventListener('pointermove', handlePointerMove);
2349
+ document.removeEventListener('pointerup', handlePointerUp, {
2350
+ capture: true
2351
+ });
2352
+ };
2353
+ }
2354
+ }, [
2355
+ content,
2356
+ onOpenChange,
2357
+ triggerPointerDownPosRef
2358
+ ]);
2359
+ React$2.useEffect(()=>{
2360
+ const close = ()=>onOpenChange(false)
2361
+ ;
2362
+ window.addEventListener('blur', close);
2363
+ window.addEventListener('resize', close);
2364
+ return ()=>{
2365
+ window.removeEventListener('blur', close);
2366
+ window.removeEventListener('resize', close);
2367
+ };
2368
+ }, [
2369
+ onOpenChange
2370
+ ]);
2371
+ const [searchRef, handleTypeaheadSearch] = $cc7e05a45900e73f$var$useTypeaheadSearch((search)=>{
2372
+ const enabledItems = getItems().filter((item)=>!item.disabled
2373
+ );
2374
+ const currentItem = enabledItems.find((item)=>item.ref.current === document.activeElement
2375
+ );
2376
+ const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
2377
+ if (nextItem) /**
2378
+ * Imperative focus during keydown is risky so we prevent React's batching updates
2379
+ * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
2380
+ */ setTimeout(()=>nextItem.ref.current.focus()
2381
+ );
2382
+ });
2383
+ const itemRefCallback = React$2.useCallback((node, value, disabled)=>{
2384
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
2385
+ const isSelectedItem = context.value !== undefined && context.value === value;
2386
+ if (isSelectedItem || isFirstValidItem) {
2387
+ setSelectedItem(node);
2388
+ if (isFirstValidItem) firstValidItemFoundRef.current = true;
2389
+ }
2390
+ }, [
2391
+ context.value
2392
+ ]);
2393
+ const handleItemLeave = React$2.useCallback(()=>content === null || content === void 0 ? void 0 : content.focus()
2394
+ , [
2395
+ content
2396
+ ]);
2397
+ const itemTextRefCallback = React$2.useCallback((node, value, disabled)=>{
2398
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
2399
+ const isSelectedItem = context.value !== undefined && context.value === value;
2400
+ if (isSelectedItem || isFirstValidItem) setSelectedItemText(node);
2401
+ }, [
2402
+ context.value
2403
+ ]);
2404
+ return /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectContentProvider, {
2405
+ scope: __scopeSelect,
2406
+ contentWrapper: contentWrapper,
2407
+ content: content,
2408
+ viewport: viewport,
2409
+ onViewportChange: setViewport,
2410
+ itemRefCallback: itemRefCallback,
2411
+ selectedItem: selectedItem,
2412
+ onItemLeave: handleItemLeave,
2413
+ itemTextRefCallback: itemTextRefCallback,
2414
+ selectedItemText: selectedItemText,
2415
+ onScrollButtonChange: handleScrollButtonChange,
2416
+ isPositioned: isPositioned,
2417
+ shouldExpandOnScrollRef: shouldExpandOnScrollRef,
2418
+ searchRef: searchRef
2419
+ }, /*#__PURE__*/ React$2.createElement($01b9c$RemoveScroll, {
2420
+ as: $5e63c961fc1ce211$export$8c6ed5c666ac1360,
2421
+ allowPinchZoom: true
2422
+ }, /*#__PURE__*/ React$2.createElement("div", {
2423
+ ref: setContentWrapper,
2424
+ style: {
2425
+ display: 'flex',
2426
+ flexDirection: 'column',
2427
+ position: 'fixed',
2428
+ zIndex: contentZIndex
2429
+ }
2430
+ }, /*#__PURE__*/ React$2.createElement($d3863c46a17e8a28$export$20e40289641fbbb6, {
2431
+ asChild: true // we make sure we're not trapping once it's been closed
2432
+ ,
2433
+ trapped: context.open,
2434
+ onMountAutoFocus: (event)=>{
2435
+ // we prevent open autofocus because we manually focus the selected item
2436
+ event.preventDefault();
2437
+ },
2438
+ onUnmountAutoFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(onCloseAutoFocus, (event)=>{
2439
+ var _context$trigger;
2440
+ (_context$trigger = context.trigger) === null || _context$trigger === void 0 || _context$trigger.focus({
2441
+ preventScroll: true
2442
+ });
2443
+ event.preventDefault();
2444
+ })
2445
+ }, /*#__PURE__*/ React$2.createElement($5cb92bef7577960e$export$177fb62ff3ec1f22, _extends({
2446
+ role: "listbox",
2447
+ id: context.contentId,
2448
+ "data-state": context.open ? 'open' : 'closed',
2449
+ dir: context.dir,
2450
+ onContextMenu: (event)=>event.preventDefault()
2451
+ }, contentProps, {
2452
+ ref: composedRefs,
2453
+ style: {
2454
+ display: 'flex',
2455
+ flexDirection: 'column',
2456
+ // When we get the height of the content, it includes borders. If we were to set
2457
+ // the height without having `boxSizing: 'border-box'` it would be too big.
2458
+ boxSizing: 'border-box',
2459
+ maxHeight: '100%',
2460
+ outline: 'none',
2461
+ ...contentProps.style
2462
+ },
2463
+ disableOutsidePointerEvents: true // When focus is trapped, a focusout event may still happen.
2464
+ ,
2465
+ onFocusOutside: (event)=>event.preventDefault()
2466
+ ,
2467
+ onDismiss: ()=>context.onOpenChange(false)
2468
+ ,
2469
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(contentProps.onKeyDown, (event)=>{
2470
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey; // select should not be navigated using tab key so we prevent it
2471
+ if (event.key === 'Tab') event.preventDefault();
2472
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
2473
+ if ([
2474
+ 'ArrowUp',
2475
+ 'ArrowDown',
2476
+ 'Home',
2477
+ 'End'
2478
+ ].includes(event.key)) {
2479
+ const items = getItems().filter((item)=>!item.disabled
2480
+ );
2481
+ let candidateNodes = items.map((item)=>item.ref.current
2482
+ );
2483
+ if ([
2484
+ 'ArrowUp',
2485
+ 'End'
2486
+ ].includes(event.key)) candidateNodes = candidateNodes.slice().reverse();
2487
+ if ([
2488
+ 'ArrowUp',
2489
+ 'ArrowDown'
2490
+ ].includes(event.key)) {
2491
+ const currentElement = event.target;
2492
+ const currentIndex = candidateNodes.indexOf(currentElement);
2493
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
2494
+ }
2495
+ /**
2496
+ * Imperative focus during keydown is risky so we prevent React's batching updates
2497
+ * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
2498
+ */ setTimeout(()=>focusFirst(candidateNodes)
2499
+ );
2500
+ event.preventDefault();
2501
+ }
2502
+ })
2503
+ }))))));
2504
+ });
2505
+ /* -------------------------------------------------------------------------------------------------
2506
+ * SelectViewport
2507
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VIEWPORT_NAME = 'SelectViewport';
2508
+ const $cc7e05a45900e73f$export$9ed6e7b40248d36d = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2509
+ const { __scopeSelect: __scopeSelect , ...viewportProps } = props;
2510
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$VIEWPORT_NAME, __scopeSelect);
2511
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onViewportChange);
2512
+ const prevScrollTopRef = React$2.useRef(0);
2513
+ return /*#__PURE__*/ React$2.createElement(React$2.Fragment, null, /*#__PURE__*/ React$2.createElement("style", {
2514
+ dangerouslySetInnerHTML: {
2515
+ __html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
2516
+ }
2517
+ }), /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$Collection.Slot, {
2518
+ scope: __scopeSelect
2519
+ }, /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2520
+ "data-radix-select-viewport": "",
2521
+ role: "presentation"
2522
+ }, viewportProps, {
2523
+ ref: composedRefs,
2524
+ style: {
2525
+ // we use position: 'relative' here on the `viewport` so that when we call
2526
+ // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
2527
+ // (independent of the scrollUpButton).
2528
+ position: 'relative',
2529
+ flex: 1,
2530
+ overflow: 'auto',
2531
+ ...viewportProps.style
2532
+ },
2533
+ onScroll: $e42e1063c40fb3ef$export$b9ecd428b558ff10(viewportProps.onScroll, (event)=>{
2534
+ const viewport = event.currentTarget;
2535
+ const { contentWrapper: contentWrapper , shouldExpandOnScrollRef: shouldExpandOnScrollRef } = contentContext;
2536
+ if (shouldExpandOnScrollRef !== null && shouldExpandOnScrollRef !== void 0 && shouldExpandOnScrollRef.current && contentWrapper) {
2537
+ const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
2538
+ if (scrolledBy > 0) {
2539
+ const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
2540
+ const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
2541
+ const cssHeight = parseFloat(contentWrapper.style.height);
2542
+ const prevHeight = Math.max(cssMinHeight, cssHeight);
2543
+ if (prevHeight < availableHeight) {
2544
+ const nextHeight = prevHeight + scrolledBy;
2545
+ const clampedNextHeight = Math.min(availableHeight, nextHeight);
2546
+ const heightDiff = nextHeight - clampedNextHeight;
2547
+ contentWrapper.style.height = clampedNextHeight + 'px';
2548
+ if (contentWrapper.style.bottom === '0px') {
2549
+ viewport.scrollTop = heightDiff > 0 ? heightDiff : 0; // ensure the content stays pinned to the bottom
2550
+ contentWrapper.style.justifyContent = 'flex-end';
2551
+ }
2552
+ }
2553
+ }
2554
+ }
2555
+ prevScrollTopRef.current = viewport.scrollTop;
2556
+ })
2557
+ }))));
2558
+ });
2559
+ /* -------------------------------------------------------------------------------------------------
2560
+ * SelectGroup
2561
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$GROUP_NAME = 'SelectGroup';
2562
+ $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$GROUP_NAME);
2563
+ /* -------------------------------------------------------------------------------------------------
2564
+ * SelectItem
2565
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_NAME = 'SelectItem';
2566
+ const [$cc7e05a45900e73f$var$SelectItemContextProvider, $cc7e05a45900e73f$var$useSelectItemContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$ITEM_NAME);
2567
+ const $cc7e05a45900e73f$export$13ef48a934230896 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2568
+ const { __scopeSelect: __scopeSelect , value: value , disabled: disabled = false , textValue: textValueProp , ...itemProps } = props;
2569
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
2570
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
2571
+ const isSelected = context.value === value;
2572
+ const [textValue, setTextValue] = React$2.useState(textValueProp !== null && textValueProp !== void 0 ? textValueProp : '');
2573
+ const [isFocused, setIsFocused] = React$2.useState(false);
2574
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>{
2575
+ var _contentContext$itemR;
2576
+ return (_contentContext$itemR = contentContext.itemRefCallback) === null || _contentContext$itemR === void 0 ? void 0 : _contentContext$itemR.call(contentContext, node, value, disabled);
2577
+ });
2578
+ const textId = $1746a345f3d73bb7$export$f680877a34711e37();
2579
+ const handleSelect = ()=>{
2580
+ if (!disabled) {
2581
+ context.onValueChange(value);
2582
+ context.onOpenChange(false);
2583
+ }
2584
+ };
2585
+ return /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectItemContextProvider, {
2586
+ scope: __scopeSelect,
2587
+ value: value,
2588
+ disabled: disabled,
2589
+ textId: textId,
2590
+ isSelected: isSelected,
2591
+ onItemTextChange: React$2.useCallback((node)=>{
2592
+ setTextValue((prevTextValue)=>{
2593
+ var _node$textContent;
2594
+ return prevTextValue || ((_node$textContent = node === null || node === void 0 ? void 0 : node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : '').trim();
2595
+ });
2596
+ }, [])
2597
+ }, /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$Collection.ItemSlot, {
2598
+ scope: __scopeSelect,
2599
+ value: value,
2600
+ disabled: disabled,
2601
+ textValue: textValue
2602
+ }, /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2603
+ role: "option",
2604
+ "aria-labelledby": textId,
2605
+ "data-highlighted": isFocused ? '' : undefined // `isFocused` caveat fixes stuttering in VoiceOver
2606
+ ,
2607
+ "aria-selected": isSelected && isFocused,
2608
+ "data-state": isSelected ? 'checked' : 'unchecked',
2609
+ "aria-disabled": disabled || undefined,
2610
+ "data-disabled": disabled ? '' : undefined,
2611
+ tabIndex: disabled ? undefined : -1
2612
+ }, itemProps, {
2613
+ ref: composedRefs,
2614
+ onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onFocus, ()=>setIsFocused(true)
2615
+ ),
2616
+ onBlur: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onBlur, ()=>setIsFocused(false)
2617
+ ),
2618
+ onPointerUp: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerUp, handleSelect),
2619
+ onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerMove, (event)=>{
2620
+ if (disabled) {
2621
+ var _contentContext$onIte;
2622
+ (_contentContext$onIte = contentContext.onItemLeave) === null || _contentContext$onIte === void 0 || _contentContext$onIte.call(contentContext);
2623
+ } else // even though safari doesn't support this option, it's acceptable
2624
+ // as it only means it might scroll a few pixels when using the pointer.
2625
+ event.currentTarget.focus({
2626
+ preventScroll: true
2627
+ });
2628
+ }),
2629
+ onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onPointerLeave, (event)=>{
2630
+ if (event.currentTarget === document.activeElement) {
2631
+ var _contentContext$onIte2;
2632
+ (_contentContext$onIte2 = contentContext.onItemLeave) === null || _contentContext$onIte2 === void 0 || _contentContext$onIte2.call(contentContext);
2633
+ }
2634
+ }),
2635
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(itemProps.onKeyDown, (event)=>{
2636
+ var _contentContext$searc;
2637
+ const isTypingAhead = ((_contentContext$searc = contentContext.searchRef) === null || _contentContext$searc === void 0 ? void 0 : _contentContext$searc.current) !== '';
2638
+ if (isTypingAhead && event.key === ' ') return;
2639
+ if ($cc7e05a45900e73f$var$SELECTION_KEYS.includes(event.key)) handleSelect(); // prevent page scroll if using the space key to select an item
2640
+ if (event.key === ' ') event.preventDefault();
2641
+ })
2642
+ }))));
2643
+ });
2644
+ /* -------------------------------------------------------------------------------------------------
2645
+ * SelectItemText
2646
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_TEXT_NAME = 'SelectItemText';
2647
+ const $cc7e05a45900e73f$export$3572fb0fb821ff49 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2648
+ // We ignore `className` and `style` as this part shouldn't be styled.
2649
+ const { __scopeSelect: __scopeSelect , className: className , style: style , ...itemTextProps } = props;
2650
+ const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2651
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2652
+ const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2653
+ const nativeOptionsContext = $cc7e05a45900e73f$var$useSelectNativeOptionsContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
2654
+ const [itemTextNode, setItemTextNode] = React$2.useState(null);
2655
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setItemTextNode(node)
2656
+ , itemContext.onItemTextChange, (node)=>{
2657
+ var _contentContext$itemT;
2658
+ return (_contentContext$itemT = contentContext.itemTextRefCallback) === null || _contentContext$itemT === void 0 ? void 0 : _contentContext$itemT.call(contentContext, node, itemContext.value, itemContext.disabled);
2659
+ });
2660
+ const textContent = itemTextNode === null || itemTextNode === void 0 ? void 0 : itemTextNode.textContent;
2661
+ const nativeOption = React$2.useMemo(()=>/*#__PURE__*/ React$2.createElement("option", {
2662
+ key: itemContext.value,
2663
+ value: itemContext.value,
2664
+ disabled: itemContext.disabled
2665
+ }, textContent)
2666
+ , [
2667
+ itemContext.disabled,
2668
+ itemContext.value,
2669
+ textContent
2670
+ ]);
2671
+ const { onNativeOptionAdd: onNativeOptionAdd , onNativeOptionRemove: onNativeOptionRemove } = nativeOptionsContext;
2672
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2673
+ onNativeOptionAdd(nativeOption);
2674
+ return ()=>onNativeOptionRemove(nativeOption)
2675
+ ;
2676
+ }, [
2677
+ onNativeOptionAdd,
2678
+ onNativeOptionRemove,
2679
+ nativeOption
2680
+ ]);
2681
+ return /*#__PURE__*/ React$2.createElement(React$2.Fragment, null, /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
2682
+ id: itemContext.textId
2683
+ }, itemTextProps, {
2684
+ ref: composedRefs
2685
+ })), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? /*#__PURE__*/ $7SXl2$reactdom.createPortal(itemTextProps.children, context.valueNode) : null);
2686
+ });
2687
+ /* -------------------------------------------------------------------------------------------------
2688
+ * SelectItemIndicator
2689
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$ITEM_INDICATOR_NAME = 'SelectItemIndicator';
2690
+ const $cc7e05a45900e73f$export$6b9198de19accfe6 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2691
+ const { __scopeSelect: __scopeSelect , ...itemIndicatorProps } = props;
2692
+ const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_INDICATOR_NAME, __scopeSelect);
2693
+ return itemContext.isSelected ? /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
2694
+ "aria-hidden": true
2695
+ }, itemIndicatorProps, {
2696
+ ref: forwardedRef
2697
+ })) : null;
2698
+ });
2699
+ /* -------------------------------------------------------------------------------------------------
2700
+ * SelectScrollUpButton
2701
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton';
2702
+ const $cc7e05a45900e73f$export$d8117927658af6d7 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2703
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
2704
+ const [canScrollUp1, setCanScrollUp] = React$2.useState(false);
2705
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
2706
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2707
+ if (contentContext.viewport && contentContext.isPositioned) {
2708
+ const viewport = contentContext.viewport;
2709
+ function handleScroll() {
2710
+ const canScrollUp = viewport.scrollTop > 0;
2711
+ setCanScrollUp(canScrollUp);
2712
+ }
2713
+ handleScroll();
2714
+ viewport.addEventListener('scroll', handleScroll);
2715
+ return ()=>viewport.removeEventListener('scroll', handleScroll)
2716
+ ;
2717
+ }
2718
+ }, [
2719
+ contentContext.viewport,
2720
+ contentContext.isPositioned
2721
+ ]);
2722
+ return canScrollUp1 ? /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, _extends({}, props, {
2723
+ ref: composedRefs,
2724
+ onAutoScroll: ()=>{
2725
+ const { viewport: viewport , selectedItem: selectedItem } = contentContext;
2726
+ if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
2727
+ }
2728
+ })) : null;
2729
+ });
2730
+ /* -------------------------------------------------------------------------------------------------
2731
+ * SelectScrollDownButton
2732
+ * -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton';
2733
+ const $cc7e05a45900e73f$export$ff951e476c12189 = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2734
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
2735
+ const [canScrollDown1, setCanScrollDown] = React$2.useState(false);
2736
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, contentContext.onScrollButtonChange);
2737
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2738
+ if (contentContext.viewport && contentContext.isPositioned) {
2739
+ const viewport = contentContext.viewport;
2740
+ function handleScroll() {
2741
+ const maxScroll = viewport.scrollHeight - viewport.clientHeight; // we use Math.ceil here because if the UI is zoomed-in
2742
+ // `scrollTop` is not always reported as an integer
2743
+ const canScrollDown = Math.ceil(viewport.scrollTop) < maxScroll;
2744
+ setCanScrollDown(canScrollDown);
2745
+ }
2746
+ handleScroll();
2747
+ viewport.addEventListener('scroll', handleScroll);
2748
+ return ()=>viewport.removeEventListener('scroll', handleScroll)
2749
+ ;
2750
+ }
2751
+ }, [
2752
+ contentContext.viewport,
2753
+ contentContext.isPositioned
2754
+ ]);
2755
+ return canScrollDown1 ? /*#__PURE__*/ React$2.createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, _extends({}, props, {
2756
+ ref: composedRefs,
2757
+ onAutoScroll: ()=>{
2758
+ const { viewport: viewport , selectedItem: selectedItem } = contentContext;
2759
+ if (viewport && selectedItem) viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
2760
+ }
2761
+ })) : null;
2762
+ });
2763
+ const $cc7e05a45900e73f$var$SelectScrollButtonImpl = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2764
+ const { __scopeSelect: __scopeSelect , onAutoScroll: onAutoScroll , ...scrollIndicatorProps } = props;
2765
+ const contentContext = $cc7e05a45900e73f$var$useSelectContentContext('SelectScrollButton', __scopeSelect);
2766
+ const autoScrollTimerRef = React$2.useRef(null);
2767
+ const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
2768
+ const clearAutoScrollTimer = React$2.useCallback(()=>{
2769
+ if (autoScrollTimerRef.current !== null) {
2770
+ window.clearInterval(autoScrollTimerRef.current);
2771
+ autoScrollTimerRef.current = null;
2772
+ }
2773
+ }, []);
2774
+ React$2.useEffect(()=>{
2775
+ return ()=>clearAutoScrollTimer()
2776
+ ;
2777
+ }, [
2778
+ clearAutoScrollTimer
2779
+ ]); // When the viewport becomes scrollable on either side, the relevant scroll button will mount.
2780
+ // Because it is part of the normal flow, it will push down (top button) or shrink (bottom button)
2781
+ // the viewport, potentially causing the active item to now be partially out of view.
2782
+ // We re-run the `scrollIntoView` logic to make sure it stays within the viewport.
2783
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
2784
+ var _activeItem$ref$curre;
2785
+ const activeItem = getItems().find((item)=>item.ref.current === document.activeElement
2786
+ );
2787
+ activeItem === null || activeItem === void 0 || (_activeItem$ref$curre = activeItem.ref.current) === null || _activeItem$ref$curre === void 0 || _activeItem$ref$curre.scrollIntoView({
2788
+ block: 'nearest'
2789
+ });
2790
+ }, [
2791
+ getItems
2792
+ ]);
2793
+ return /*#__PURE__*/ React$2.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
2794
+ "aria-hidden": true
2795
+ }, scrollIndicatorProps, {
2796
+ ref: forwardedRef,
2797
+ style: {
2798
+ flexShrink: 0,
2799
+ ...scrollIndicatorProps.style
2800
+ },
2801
+ onPointerMove: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerMove, ()=>{
2802
+ var _contentContext$onIte3;
2803
+ (_contentContext$onIte3 = contentContext.onItemLeave) === null || _contentContext$onIte3 === void 0 || _contentContext$onIte3.call(contentContext);
2804
+ if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
2805
+ }),
2806
+ onPointerLeave: $e42e1063c40fb3ef$export$b9ecd428b558ff10(scrollIndicatorProps.onPointerLeave, ()=>{
2807
+ clearAutoScrollTimer();
2808
+ })
2809
+ }));
2810
+ });
2811
+ /* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ React$2.forwardRef((props, forwardedRef)=>{
2812
+ const { value: value , ...selectProps } = props;
2813
+ const ref = React$2.useRef(null);
2814
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
2815
+ const prevValue = $010c2913dbd2fe3d$export$5cae361ad82dce8b(value); // Bubble value change to parents (e.g form change event)
2816
+ React$2.useEffect(()=>{
2817
+ const select = ref.current;
2818
+ const selectProto = window.HTMLSelectElement.prototype;
2819
+ const descriptor = Object.getOwnPropertyDescriptor(selectProto, 'value');
2820
+ const setValue = descriptor.set;
2821
+ if (prevValue !== value && setValue) {
2822
+ const event = new Event('change', {
2823
+ bubbles: true
2824
+ });
2825
+ setValue.call(select, value);
2826
+ select.dispatchEvent(event);
2827
+ }
2828
+ }, [
2829
+ prevValue,
2830
+ value
2831
+ ]);
2832
+ /**
2833
+ * We purposefully use a `select` here to support form autofill as much
2834
+ * as possible.
2835
+ *
2836
+ * We purposefully do not add the `value` attribute here to allow the value
2837
+ * to be set programatically and bubble to any parent form `onChange` event.
2838
+ * Adding the `value` will cause React to consider the programatic
2839
+ * dispatch a duplicate and it will get swallowed.
2840
+ *
2841
+ * We use `VisuallyHidden` rather than `display: "none"` because Safari autofill
2842
+ * won't work otherwise.
2843
+ */ return /*#__PURE__*/ React$2.createElement($ea1ef594cf570d83$export$439d29a4e110a164, {
2844
+ asChild: true
2845
+ }, /*#__PURE__*/ React$2.createElement("select", _extends({}, selectProps, {
2846
+ ref: composedRefs,
2847
+ defaultValue: value
2848
+ })));
2849
+ });
2850
+ $cc7e05a45900e73f$var$BubbleSelect.displayName = 'BubbleSelect';
2851
+ function $cc7e05a45900e73f$var$useTypeaheadSearch(onSearchChange) {
2852
+ const handleSearchChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onSearchChange);
2853
+ const searchRef = React$2.useRef('');
2854
+ const timerRef = React$2.useRef(0);
2855
+ const handleTypeaheadSearch = React$2.useCallback((key)=>{
2856
+ const search = searchRef.current + key;
2857
+ handleSearchChange(search);
2858
+ (function updateSearch(value) {
2859
+ searchRef.current = value;
2860
+ window.clearTimeout(timerRef.current); // Reset `searchRef` 1 second after it was last updated
2861
+ if (value !== '') timerRef.current = window.setTimeout(()=>updateSearch('')
2862
+ , 1000);
2863
+ })(search);
2864
+ }, [
2865
+ handleSearchChange
2866
+ ]);
2867
+ const resetTypeahead = React$2.useCallback(()=>{
2868
+ searchRef.current = '';
2869
+ window.clearTimeout(timerRef.current);
2870
+ }, []);
2871
+ React$2.useEffect(()=>{
2872
+ return ()=>window.clearTimeout(timerRef.current)
2873
+ ;
2874
+ }, []);
2875
+ return [
2876
+ searchRef,
2877
+ handleTypeaheadSearch,
2878
+ resetTypeahead
2879
+ ];
2880
+ }
2881
+ /**
2882
+ * This is the "meat" of the typeahead matching logic. It takes in a list of items,
2883
+ * the search and the current item, and returns the next item (or `undefined`).
2884
+ *
2885
+ * We normalize the search because if a user has repeatedly pressed a character,
2886
+ * we want the exact same behavior as if we only had that one character
2887
+ * (ie. cycle through items starting with that character)
2888
+ *
2889
+ * We also reorder the items by wrapping the array around the current item.
2890
+ * This is so we always look forward from the current item, and picking the first
2891
+ * item will always be the correct one.
2892
+ *
2893
+ * Finally, if the normalized search is exactly one character, we exclude the
2894
+ * current item from the values because otherwise it would be the first to match always
2895
+ * and focus would never move. This is as opposed to the regular case, where we
2896
+ * don't want focus to move if the current item still matches.
2897
+ */ function $cc7e05a45900e73f$var$findNextItem(items, search, currentItem) {
2898
+ const isRepeated = search.length > 1 && Array.from(search).every((char)=>char === search[0]
2899
+ );
2900
+ const normalizedSearch = isRepeated ? search[0] : search;
2901
+ const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
2902
+ let wrappedItems = $cc7e05a45900e73f$var$wrapArray(items, Math.max(currentItemIndex, 0));
2903
+ const excludeCurrentItem = normalizedSearch.length === 1;
2904
+ if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v)=>v !== currentItem
2905
+ );
2906
+ const nextItem = wrappedItems.find((item)=>item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
2907
+ );
2908
+ return nextItem !== currentItem ? nextItem : undefined;
2909
+ }
2910
+ /**
2911
+ * Wraps an array around itself at a given start index
2912
+ * Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
2913
+ */ function $cc7e05a45900e73f$var$wrapArray(array, startIndex) {
2914
+ return array.map((_, index)=>array[(startIndex + index) % array.length]
2915
+ );
2916
+ }
2917
+ const $cc7e05a45900e73f$export$be92b6f5f03c0fe9 = $cc7e05a45900e73f$export$ef9b1a59e592288f;
2918
+ const $cc7e05a45900e73f$export$41fb9f06171c75f4 = $cc7e05a45900e73f$export$3ac1e88a1c0b9f1;
2919
+ const $cc7e05a45900e73f$export$4c8d1a57a761ef94 = $cc7e05a45900e73f$export$e288731fd71264f0;
2920
+ const $cc7e05a45900e73f$export$f04a61298a47a40f = $cc7e05a45900e73f$export$99b400cabb58c515;
2921
+ const $cc7e05a45900e73f$export$602eac185826482c = $cc7e05a45900e73f$export$b2af6c9944296213;
2922
+ const $cc7e05a45900e73f$export$7c6e2c02157bb7d2 = $cc7e05a45900e73f$export$c973a4b3cb86a03d;
2923
+ const $cc7e05a45900e73f$export$d5c6c08dc2d3ca7 = $cc7e05a45900e73f$export$9ed6e7b40248d36d;
2924
+ const $cc7e05a45900e73f$export$6d08773d2e66f8f2 = $cc7e05a45900e73f$export$13ef48a934230896;
2925
+ const $cc7e05a45900e73f$export$d6e5bf9c43ea9319 = $cc7e05a45900e73f$export$3572fb0fb821ff49;
2926
+ const $cc7e05a45900e73f$export$c3468e2714d175fa = $cc7e05a45900e73f$export$6b9198de19accfe6;
2927
+ const $cc7e05a45900e73f$export$2f60d3ec9ad468f2 = $cc7e05a45900e73f$export$d8117927658af6d7;
2928
+ const $cc7e05a45900e73f$export$bf1aedc3039c8d63 = $cc7e05a45900e73f$export$ff951e476c12189;
2929
+
2930
+ const React$1 = React__default["default"];
2931
+ const BtIconChevronUp2Px = props =>
2932
+ /*#__PURE__*/ React$1.createElement(
2933
+ "svg",
2934
+ Object.assign(
2935
+ {
2936
+ xmlns: "http://www.w3.org/2000/svg",
2937
+ viewBox: "0 0 32 32"
2938
+ },
2939
+ props
2940
+ ),
2941
+ /*#__PURE__*/ React$1.createElement("defs", null),
2942
+ /*#__PURE__*/ React$1.createElement("path", {
2943
+ d:
2944
+ "M28.999,23.5a.99676.99676,0,0,1-.707-.293l-12.28515-12.293L3.708,23.207A.99989.99989,0,0,1,2.294,21.793l13.71289-13.707L29.70605,21.793a.99976.99976,0,0,1-.707,1.707Z",
2945
+ fill: "currentColor"
2946
+ })
2947
+ );
2948
+ var BtIconChevronUp2Px_2 = BtIconChevronUp2Px;
2949
+
2950
+ const React = React__default["default"];
2951
+ const BtIconTickAlt2Px = props =>
2952
+ /*#__PURE__*/ React.createElement(
2953
+ "svg",
2954
+ Object.assign(
2955
+ {
2956
+ xmlns: "http://www.w3.org/2000/svg",
2957
+ viewBox: "0 0 32 32"
2958
+ },
2959
+ props
2960
+ ),
2961
+ /*#__PURE__*/ React.createElement("defs", null),
2962
+ /*#__PURE__*/ React.createElement("path", {
2963
+ d:
2964
+ "M13.49963,21.91418l-4.707-4.707a1.0014,1.0014,0,0,1,0-1.41406,1.02353,1.02353,0,0,1,1.41406,0l3.293,3.293,8.293-8.293a.99989.99989,0,1,1,1.41406,1.41406Z",
2965
+ fill: "currentColor"
2966
+ })
2967
+ );
2968
+ var BtIconTickAlt2Px_2 = BtIconTickAlt2Px;
2969
+
2970
+ /** Use `Select` to choose from a dropdown list of options. */
2971
+ var Select = function (_a) {
2972
+ var isRequired = _a.isRequired, isDisabled = _a.isDisabled, placeholder = _a.placeholder, label = _a.label, options = _a.options, onOpenChange = _a.onOpenChange, isDefaultOpen = _a.isDefaultOpen, defaultValue = _a.defaultValue, errorMessage = _a.errorMessage, labelSize = _a.labelSize, helper = _a.helper, name = _a.name, isFluid = _a.isFluid, onBlur = _a.onBlur, onChange = _a.onChange, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure;
2973
+ var id = React$2.useId();
2974
+ var arcRootElement = React$2.useContext(Base.ArcRootElementContext);
2975
+ var surface = React$2.useContext(Surface.Context).surface;
2976
+ var _b = React$2.useState(defaultValue), selectedValue = _b[0], setSelectedValue = _b[1];
2977
+ var onValueChange = function (value) {
2978
+ onChange && onChange(value);
2979
+ setSelectedValue(value);
2980
+ };
2981
+ return (React__default["default"].createElement(FormControl.FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", isDisabled: isDisabled, disclosureText: disclosureText, disclosureTitle: disclosureTitle, onClickDisclosure: onClickDisclosure },
2982
+ React__default["default"].createElement($cc7e05a45900e73f$export$be92b6f5f03c0fe9, { name: name, required: isRequired, disabled: isDisabled, defaultOpen: isDefaultOpen, value: selectedValue, onOpenChange: onOpenChange, onValueChange: function (value) { return onValueChange(value); } },
2983
+ React__default["default"].createElement($cc7e05a45900e73f$export$41fb9f06171c75f4, { id: id, name: name, onBlur: onBlur, className: index.classNames("arc-Select-trigger", {
2984
+ "arc-Select-trigger--constrained": !isFluid,
2985
+ "arc-Select-trigger--onDarkSurface": surface === "dark",
2986
+ "arc-Select-trigger--invalid": errorMessage
2987
+ }) },
2988
+ React__default["default"].createElement($cc7e05a45900e73f$export$4c8d1a57a761ef94, { asChild: true, "aria-label": selectedValue }, !selectedValue ? (React__default["default"].createElement("span", { "aria-hidden": true, className: "arc-Select-placeHolder" }, placeholder)) : (React__default["default"].createElement("span", { className: "arc-Select-valueItem" }, selectedValue))),
2989
+ React__default["default"].createElement($cc7e05a45900e73f$export$f04a61298a47a40f, { className: "arc-Select-triggerIcon" },
2990
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronDown2Px.BtIconChevronDown2Px_2, size: 20 }))),
2991
+ React__default["default"].createElement($cc7e05a45900e73f$export$602eac185826482c, { container: arcRootElement },
2992
+ React__default["default"].createElement($cc7e05a45900e73f$export$7c6e2c02157bb7d2, { className: index.classNames("arc-Select-content", {
2993
+ "arc-Select-content--onDarkSurface": surface === "dark"
2994
+ }) },
2995
+ React__default["default"].createElement($cc7e05a45900e73f$export$2f60d3ec9ad468f2, { className: "arc-Select-scrollButton" },
2996
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronUp2Px_2, size: 16 })),
2997
+ React__default["default"].createElement($cc7e05a45900e73f$export$d5c6c08dc2d3ca7, null, options.map(function (_a, i) {
2998
+ var name = _a.name, value = _a.value;
2999
+ return (React__default["default"].createElement($cc7e05a45900e73f$export$6d08773d2e66f8f2, { className: "arc-Select-item", key: "select-item-".concat(i), value: value },
3000
+ React__default["default"].createElement("div", { className: "arc-Select-itemTextWrapper" },
3001
+ React__default["default"].createElement($cc7e05a45900e73f$export$d6e5bf9c43ea9319, { asChild: true },
3002
+ React__default["default"].createElement("span", { className: "arc-Select-itemText" }, name))),
3003
+ React__default["default"].createElement($cc7e05a45900e73f$export$c3468e2714d175fa, null,
3004
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconTickAlt2Px_2, size: 20 }))));
3005
+ })),
3006
+ React__default["default"].createElement($cc7e05a45900e73f$export$bf1aedc3039c8d63, { className: "arc-Select-scrollButton" },
3007
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconChevronDown2Px.BtIconChevronDown2Px_2, size: 16 })))))));
3008
+ };
3009
+
3010
+ exports.Select = Select;