@redsift/dashboard 6.1.0-alpha.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.
package/index.js ADDED
@@ -0,0 +1,4832 @@
1
+ import React, { forwardRef, useRef, useReducer, useMemo, useContext, useState, useLayoutEffect, useCallback, useEffect, useId } from 'react';
2
+ import crossfilter from 'crossfilter2';
3
+ import { DataGrid as DataGrid$1 } from '@redsift/table';
4
+ import { redrawAll, config, rowChart, filterAll, pieChart } from 'dc';
5
+ import 'd3-shape';
6
+ import { scheme, successDangerScheme, neutral, PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartVariant, StyledPieChartTitle, StyledPieChartCenterText, StyledPieChartLabel, StyledPieChartCaption } from '@redsift/charts';
7
+ export { PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartVariant } from '@redsift/charts';
8
+ import styled, { css } from 'styled-components';
9
+
10
+ function ownKeys(object, enumerableOnly) {
11
+ var keys = Object.keys(object);
12
+ if (Object.getOwnPropertySymbols) {
13
+ var symbols = Object.getOwnPropertySymbols(object);
14
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
15
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
16
+ })), keys.push.apply(keys, symbols);
17
+ }
18
+ return keys;
19
+ }
20
+ function _objectSpread2(target) {
21
+ for (var i = 1; i < arguments.length; i++) {
22
+ var source = null != arguments[i] ? arguments[i] : {};
23
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
24
+ _defineProperty(target, key, source[key]);
25
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
26
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
27
+ });
28
+ }
29
+ return target;
30
+ }
31
+ function _defineProperty(obj, key, value) {
32
+ if (key in obj) {
33
+ Object.defineProperty(obj, key, {
34
+ value: value,
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true
38
+ });
39
+ } else {
40
+ obj[key] = value;
41
+ }
42
+ return obj;
43
+ }
44
+ function _extends() {
45
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
46
+ for (var i = 1; i < arguments.length; i++) {
47
+ var source = arguments[i];
48
+ for (var key in source) {
49
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
50
+ target[key] = source[key];
51
+ }
52
+ }
53
+ }
54
+ return target;
55
+ };
56
+ return _extends.apply(this, arguments);
57
+ }
58
+ function _objectWithoutPropertiesLoose(source, excluded) {
59
+ if (source == null) return {};
60
+ var target = {};
61
+ var sourceKeys = Object.keys(source);
62
+ var key, i;
63
+ for (i = 0; i < sourceKeys.length; i++) {
64
+ key = sourceKeys[i];
65
+ if (excluded.indexOf(key) >= 0) continue;
66
+ target[key] = source[key];
67
+ }
68
+ return target;
69
+ }
70
+ function _objectWithoutProperties(source, excluded) {
71
+ if (source == null) return {};
72
+ var target = _objectWithoutPropertiesLoose(source, excluded);
73
+ var key, i;
74
+ if (Object.getOwnPropertySymbols) {
75
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
76
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
77
+ key = sourceSymbolKeys[i];
78
+ if (excluded.indexOf(key) >= 0) continue;
79
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
80
+ target[key] = source[key];
81
+ }
82
+ }
83
+ return target;
84
+ }
85
+
86
+ var classnames = {exports: {}};
87
+
88
+ /*!
89
+ Copyright (c) 2018 Jed Watson.
90
+ Licensed under the MIT License (MIT), see
91
+ http://jedwatson.github.io/classnames
92
+ */
93
+
94
+ (function (module) {
95
+ /* global define */
96
+
97
+ (function () {
98
+
99
+ var hasOwn = {}.hasOwnProperty;
100
+
101
+ function classNames() {
102
+ var classes = [];
103
+
104
+ for (var i = 0; i < arguments.length; i++) {
105
+ var arg = arguments[i];
106
+ if (!arg) continue;
107
+
108
+ var argType = typeof arg;
109
+
110
+ if (argType === 'string' || argType === 'number') {
111
+ classes.push(arg);
112
+ } else if (Array.isArray(arg)) {
113
+ if (arg.length) {
114
+ var inner = classNames.apply(null, arg);
115
+ if (inner) {
116
+ classes.push(inner);
117
+ }
118
+ }
119
+ } else if (argType === 'object') {
120
+ if (arg.toString === Object.prototype.toString) {
121
+ for (var key in arg) {
122
+ if (hasOwn.call(arg, key) && arg[key]) {
123
+ classes.push(key);
124
+ }
125
+ }
126
+ } else {
127
+ classes.push(arg.toString());
128
+ }
129
+ }
130
+ }
131
+
132
+ return classes.join(' ');
133
+ }
134
+
135
+ if (module.exports) {
136
+ classNames.default = classNames;
137
+ module.exports = classNames;
138
+ } else {
139
+ window.classNames = classNames;
140
+ }
141
+ }());
142
+ } (classnames));
143
+
144
+ var classNames = classnames.exports;
145
+
146
+ const initialState = {
147
+ tableFilters: []
148
+ };
149
+ const DashboardContext = /*#__PURE__*/React.createContext({
150
+ state: initialState
151
+ });
152
+
153
+ /**
154
+ * Context props.
155
+ */
156
+
157
+ /**
158
+ * Reducer props.
159
+ */
160
+
161
+ let DashboardReducerActionType;
162
+ (function (DashboardReducerActionType) {
163
+ DashboardReducerActionType["FilterTable"] = "filter-table";
164
+ DashboardReducerActionType["FilterTableBatch"] = "filter-table-batch";
165
+ })(DashboardReducerActionType || (DashboardReducerActionType = {}));
166
+
167
+ const getFilter = (tableFilter, actionFilter) => {
168
+ return tableFilter.columnField === actionFilter.columnField && tableFilter.operatorValue === actionFilter.operatorValue;
169
+ };
170
+ const DashboardReducer = (state, action) => {
171
+ switch (action.type) {
172
+ case DashboardReducerActionType.FilterTable:
173
+ return _objectSpread2(_objectSpread2({}, state), {}, {
174
+ tableFilters: state.tableFilters.find(filter => getFilter(filter, action.filter)) ? state.tableFilters.map(filter => getFilter(filter, action.filter) ? action.filter : filter) : [...state.tableFilters, action.filter]
175
+ });
176
+ case DashboardReducerActionType.FilterTableBatch:
177
+ return _objectSpread2(_objectSpread2({}, state), {}, {
178
+ tableFilters: action.filter
179
+ });
180
+ }
181
+ };
182
+
183
+ const _excluded$5 = ["children", "className", "data"];
184
+ const COMPONENT_NAME$5 = 'RedSiftDashboard';
185
+ const CLASSNAME$5 = 'redsift-dashboard-container';
186
+ const DEFAULT_PROPS$4 = {};
187
+ const Dashboard = /*#__PURE__*/forwardRef((props, ref) => {
188
+ const providerRef = ref || useRef();
189
+ const {
190
+ children,
191
+ className,
192
+ data
193
+ } = props,
194
+ forwardedProps = _objectWithoutProperties(props, _excluded$5);
195
+ const [state, dispatch] = useReducer(DashboardReducer, {
196
+ tableFilters: []
197
+ });
198
+ const value = useMemo(() => ({
199
+ state,
200
+ dispatch,
201
+ ndx: crossfilter(data),
202
+ data
203
+ }), [state, data]);
204
+ return /*#__PURE__*/React.createElement("div", _extends({}, forwardedProps, {
205
+ className: classNames(Dashboard.className, className),
206
+ ref: providerRef
207
+ }), /*#__PURE__*/React.createElement(DashboardContext.Provider, {
208
+ value: value
209
+ }, children));
210
+ });
211
+ Dashboard.className = CLASSNAME$5;
212
+ Dashboard.defaultProps = DEFAULT_PROPS$4;
213
+ Dashboard.displayName = COMPONENT_NAME$5;
214
+
215
+ const _excluded$4 = ["rows"];
216
+ const DataGrid = _ref => {
217
+ let {
218
+ rows
219
+ } = _ref,
220
+ props = _objectWithoutProperties(_ref, _excluded$4);
221
+ const {
222
+ state,
223
+ data,
224
+ dispatch
225
+ } = useContext(DashboardContext);
226
+ const {
227
+ tableFilters
228
+ } = state;
229
+ const updateChartFilters = filterModel => {
230
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch({
231
+ type: DashboardReducerActionType.FilterTableBatch,
232
+ filter: filterModel.items
233
+ });
234
+ };
235
+ return /*#__PURE__*/React.createElement(DataGrid$1, _extends({
236
+ rows: data || rows || []
237
+ }, props, {
238
+ filterModel: {
239
+ items: tableFilters
240
+ },
241
+ onFilterModelChange: updateChartFilters
242
+ }));
243
+ };
244
+
245
+ function sum(values, valueof) {
246
+ let sum = 0;
247
+ if (valueof === undefined) {
248
+ for (let value of values) {
249
+ if (value = +value) {
250
+ sum += value;
251
+ }
252
+ }
253
+ } else {
254
+ let index = -1;
255
+ for (let value of values) {
256
+ if (value = +valueof(value, ++index, values)) {
257
+ sum += value;
258
+ }
259
+ }
260
+ }
261
+ return sum;
262
+ }
263
+
264
+ class InternMap extends Map {
265
+ constructor(entries, key = keyof) {
266
+ super();
267
+ Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
268
+ if (entries != null) for (const [key, value] of entries) this.set(key, value);
269
+ }
270
+ get(key) {
271
+ return super.get(intern_get(this, key));
272
+ }
273
+ has(key) {
274
+ return super.has(intern_get(this, key));
275
+ }
276
+ set(key, value) {
277
+ return super.set(intern_set(this, key), value);
278
+ }
279
+ delete(key) {
280
+ return super.delete(intern_delete(this, key));
281
+ }
282
+ }
283
+
284
+ function intern_get({_intern, _key}, value) {
285
+ const key = _key(value);
286
+ return _intern.has(key) ? _intern.get(key) : value;
287
+ }
288
+
289
+ function intern_set({_intern, _key}, value) {
290
+ const key = _key(value);
291
+ if (_intern.has(key)) return _intern.get(key);
292
+ _intern.set(key, value);
293
+ return value;
294
+ }
295
+
296
+ function intern_delete({_intern, _key}, value) {
297
+ const key = _key(value);
298
+ if (_intern.has(key)) {
299
+ value = _intern.get(key);
300
+ _intern.delete(key);
301
+ }
302
+ return value;
303
+ }
304
+
305
+ function keyof(value) {
306
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
307
+ }
308
+
309
+ function initRange(domain, range) {
310
+ switch (arguments.length) {
311
+ case 0: break;
312
+ case 1: this.range(domain); break;
313
+ default: this.range(range).domain(domain); break;
314
+ }
315
+ return this;
316
+ }
317
+
318
+ const implicit = Symbol("implicit");
319
+
320
+ function ordinal() {
321
+ var index = new InternMap(),
322
+ domain = [],
323
+ range = [],
324
+ unknown = implicit;
325
+
326
+ function scale(d) {
327
+ let i = index.get(d);
328
+ if (i === undefined) {
329
+ if (unknown !== implicit) return unknown;
330
+ index.set(d, i = domain.push(d) - 1);
331
+ }
332
+ return range[i % range.length];
333
+ }
334
+
335
+ scale.domain = function(_) {
336
+ if (!arguments.length) return domain.slice();
337
+ domain = [], index = new InternMap();
338
+ for (const value of _) {
339
+ if (index.has(value)) continue;
340
+ index.set(value, domain.push(value) - 1);
341
+ }
342
+ return scale;
343
+ };
344
+
345
+ scale.range = function(_) {
346
+ return arguments.length ? (range = Array.from(_), scale) : range.slice();
347
+ };
348
+
349
+ scale.unknown = function(_) {
350
+ return arguments.length ? (unknown = _, scale) : unknown;
351
+ };
352
+
353
+ scale.copy = function() {
354
+ return ordinal(domain, range).unknown(unknown);
355
+ };
356
+
357
+ initRange.apply(scale, arguments);
358
+
359
+ return scale;
360
+ }
361
+
362
+ function Transform(k, x, y) {
363
+ this.k = k;
364
+ this.x = x;
365
+ this.y = y;
366
+ }
367
+
368
+ Transform.prototype = {
369
+ constructor: Transform,
370
+ scale: function(k) {
371
+ return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
372
+ },
373
+ translate: function(x, y) {
374
+ return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y);
375
+ },
376
+ apply: function(point) {
377
+ return [point[0] * this.k + this.x, point[1] * this.k + this.y];
378
+ },
379
+ applyX: function(x) {
380
+ return x * this.k + this.x;
381
+ },
382
+ applyY: function(y) {
383
+ return y * this.k + this.y;
384
+ },
385
+ invert: function(location) {
386
+ return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
387
+ },
388
+ invertX: function(x) {
389
+ return (x - this.x) / this.k;
390
+ },
391
+ invertY: function(y) {
392
+ return (y - this.y) / this.k;
393
+ },
394
+ rescaleX: function(x) {
395
+ return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x));
396
+ },
397
+ rescaleY: function(y) {
398
+ return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y));
399
+ },
400
+ toString: function() {
401
+ return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
402
+ }
403
+ };
404
+
405
+ new Transform(1, 0, 0);
406
+
407
+ Transform.prototype;
408
+
409
+ /** Component Type. */
410
+
411
+ /**
412
+ * JS falsy values.
413
+ * (excluding `NaN` as it can't be distinguished from `number`)
414
+ */
415
+
416
+ /** Get types of the values of a record. */
417
+
418
+ /**
419
+ * Color palette.
420
+ */
421
+ const ColorPalette = {
422
+ primary: 'primary',
423
+ secondary: 'secondary',
424
+ error: 'error',
425
+ warning: 'warning',
426
+ info: 'info',
427
+ success: 'success'
428
+ };
429
+
430
+ // Material Design Icons v7.0.96
431
+ var mdiRefresh = "M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z";
432
+
433
+ function $parcel$export$5(e, n, v, s) {
434
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
435
+ }
436
+ var $704cf1d3b684cc5c$exports = {};
437
+
438
+ $parcel$export$5($704cf1d3b684cc5c$exports, "SSRProvider", () => $704cf1d3b684cc5c$export$9f8ac96af4b1b2ae);
439
+ $parcel$export$5($704cf1d3b684cc5c$exports, "useSSRSafeId", () => $704cf1d3b684cc5c$export$619500959fc48b26);
440
+ $parcel$export$5($704cf1d3b684cc5c$exports, "useIsSSR", () => $704cf1d3b684cc5c$export$535bd6ca7f90a273);
441
+
442
+ // Default context value to use in case there is no SSRProvider. This is fine for
443
+ // client-only apps. In order to support multiple copies of React Aria potentially
444
+ // being on the page at once, the prefix is set to a random number. SSRProvider
445
+ // will reset this to zero for consistency between server and client, so in the
446
+ // SSR case multiple copies of React Aria is not supported.
447
+ const $704cf1d3b684cc5c$var$defaultContext = {
448
+ prefix: String(Math.round(Math.random() * 10000000000)),
449
+ current: 0
450
+ };
451
+ const $704cf1d3b684cc5c$var$SSRContext = /*#__PURE__*/ React.createContext($704cf1d3b684cc5c$var$defaultContext);
452
+ function $704cf1d3b684cc5c$export$9f8ac96af4b1b2ae(props) {
453
+ let cur = useContext($704cf1d3b684cc5c$var$SSRContext);
454
+ let value = useMemo(()=>({
455
+ // If this is the first SSRProvider, start with an empty string prefix, otherwise
456
+ // append and increment the counter.
457
+ prefix: cur === $704cf1d3b684cc5c$var$defaultContext ? '' : `${cur.prefix}-${++cur.current}`,
458
+ current: 0
459
+ })
460
+ , [
461
+ cur
462
+ ]);
463
+ return(/*#__PURE__*/ React.createElement($704cf1d3b684cc5c$var$SSRContext.Provider, {
464
+ value: value
465
+ }, props.children));
466
+ }
467
+ let $704cf1d3b684cc5c$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
468
+ function $704cf1d3b684cc5c$export$619500959fc48b26(defaultId) {
469
+ let ctx = useContext($704cf1d3b684cc5c$var$SSRContext);
470
+ // If we are rendering in a non-DOM environment, and there's no SSRProvider,
471
+ // provide a warning to hint to the developer to add one.
472
+ if (ctx === $704cf1d3b684cc5c$var$defaultContext && !$704cf1d3b684cc5c$var$canUseDOM) console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
473
+ return useMemo(()=>defaultId || `react-aria${ctx.prefix}-${++ctx.current}`
474
+ , [
475
+ defaultId
476
+ ]);
477
+ }
478
+ function $704cf1d3b684cc5c$export$535bd6ca7f90a273() {
479
+ let cur = useContext($704cf1d3b684cc5c$var$SSRContext);
480
+ let isInSSRContext = cur !== $704cf1d3b684cc5c$var$defaultContext;
481
+ let [isSSR, setIsSSR] = useState(isInSSRContext);
482
+ // If on the client, and the component was initially server rendered,
483
+ // then schedule a layout effect to update the component after hydration.
484
+ if (typeof window !== 'undefined' && isInSSRContext) // This if statement technically breaks the rules of hooks, but is safe
485
+ // because the condition never changes after mounting.
486
+ // eslint-disable-next-line react-hooks/rules-of-hooks
487
+ useLayoutEffect(()=>{
488
+ setIsSSR(false);
489
+ }, []);
490
+ return isSSR;
491
+ }
492
+
493
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
494
+
495
+ function $parcel$export$4(e, n, v, s) {
496
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
497
+ }
498
+ var $458b0a5536c1a7cf$exports = {};
499
+
500
+ $parcel$export$4($458b0a5536c1a7cf$exports, "useControlledState", () => $458b0a5536c1a7cf$export$40bfa8c7b0832715);
501
+
502
+ function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value1, defaultValue, onChange) {
503
+ let [stateValue, setStateValue] = useState(value1 || defaultValue);
504
+ let ref = useRef(value1 !== undefined);
505
+ let wasControlled = ref.current;
506
+ let isControlled = value1 !== undefined;
507
+ // Internal state reference for useCallback
508
+ let stateRef = useRef(stateValue);
509
+ if (wasControlled !== isControlled) console.warn(`WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`);
510
+ ref.current = isControlled;
511
+ let setValue = useCallback((value2, ...args)=>{
512
+ let onChangeCaller = (value, ...onChangeArgs)=>{
513
+ if (onChange) {
514
+ if (!Object.is(stateRef.current, value)) onChange(value, ...onChangeArgs);
515
+ }
516
+ if (!isControlled) stateRef.current = value;
517
+ };
518
+ if (typeof value2 === 'function') {
519
+ console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
520
+ // this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates
521
+ // when someone using useControlledState calls setControlledState(myFunc)
522
+ // this will call our useState setState with a function as well which invokes myFunc and calls onChange with the value from myFunc
523
+ // if we're in an uncontrolled state, then we also return the value of myFunc which to setState looks as though it was just called with myFunc from the beginning
524
+ // otherwise we just return the controlled value, which won't cause a rerender because React knows to bail out when the value is the same
525
+ let updateFunction = (oldValue, ...functionArgs)=>{
526
+ let interceptedValue = value2(isControlled ? stateRef.current : oldValue, ...functionArgs);
527
+ onChangeCaller(interceptedValue, ...args);
528
+ if (!isControlled) return interceptedValue;
529
+ return oldValue;
530
+ };
531
+ setStateValue(updateFunction);
532
+ } else {
533
+ if (!isControlled) setStateValue(value2);
534
+ onChangeCaller(value2, ...args);
535
+ }
536
+ }, [
537
+ isControlled,
538
+ onChange
539
+ ]);
540
+ // If a controlled component's value prop changes, we need to update stateRef
541
+ if (isControlled) stateRef.current = value1;
542
+ else value1 = stateValue;
543
+ return [
544
+ value1,
545
+ setValue
546
+ ];
547
+ }
548
+
549
+
550
+ var $9446cca9a3875146$exports = {};
551
+
552
+ $parcel$export$4($9446cca9a3875146$exports, "clamp", () => $9446cca9a3875146$export$7d15b64cf5a3a4c4);
553
+ $parcel$export$4($9446cca9a3875146$exports, "snapValueToStep", () => $9446cca9a3875146$export$cb6e0bb50bc19463);
554
+ $parcel$export$4($9446cca9a3875146$exports, "toFixedNumber", () => $9446cca9a3875146$export$b6268554fba451f);
555
+ function $9446cca9a3875146$export$7d15b64cf5a3a4c4(value, min = -Infinity, max = Infinity) {
556
+ let newValue = Math.min(Math.max(value, min), max);
557
+ return newValue;
558
+ }
559
+ function $9446cca9a3875146$export$cb6e0bb50bc19463(value, min, max, step) {
560
+ let remainder = (value - (isNaN(min) ? 0 : min)) % step;
561
+ let snappedValue = Math.abs(remainder) * 2 >= step ? value + Math.sign(remainder) * (step - Math.abs(remainder)) : value - remainder;
562
+ if (!isNaN(min)) {
563
+ if (snappedValue < min) snappedValue = min;
564
+ else if (!isNaN(max) && snappedValue > max) snappedValue = min + Math.floor((max - min) / step) * step;
565
+ } else if (!isNaN(max) && snappedValue > max) snappedValue = Math.floor(max / step) * step;
566
+ // correct floating point behavior by rounding to step precision
567
+ let string = step.toString();
568
+ let index = string.indexOf('.');
569
+ let precision = index >= 0 ? string.length - index : 0;
570
+ if (precision > 0) {
571
+ let pow = Math.pow(10, precision);
572
+ snappedValue = Math.round(snappedValue * pow) / pow;
573
+ }
574
+ return snappedValue;
575
+ }
576
+ function $9446cca9a3875146$export$b6268554fba451f(value, digits, base = 10) {
577
+ const pow = Math.pow(base, digits);
578
+ return Math.round(value * pow) / pow;
579
+ }
580
+
581
+ function $parcel$export$3(e, n, v, s) {
582
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
583
+ }
584
+ var $bdb11010cef70236$exports = {};
585
+
586
+ $parcel$export$3($bdb11010cef70236$exports, "useId", () => $bdb11010cef70236$export$f680877a34711e37);
587
+ $parcel$export$3($bdb11010cef70236$exports, "mergeIds", () => $bdb11010cef70236$export$cd8c9cb68f842629);
588
+ $parcel$export$3($bdb11010cef70236$exports, "useSlotId", () => $bdb11010cef70236$export$b4cc09c592e8fdb8);
589
+
590
+ var $f0a04ccd8dbdd83b$exports = {};
591
+
592
+ $parcel$export$3($f0a04ccd8dbdd83b$exports, "useLayoutEffect", () => $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c);
593
+
594
+ const $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof window !== 'undefined' ? React.useLayoutEffect : ()=>{
595
+ };
596
+
597
+
598
+
599
+
600
+ let $bdb11010cef70236$var$idsUpdaterMap = new Map();
601
+ function $bdb11010cef70236$export$f680877a34711e37(defaultId) {
602
+ let [value, setValue] = useState(defaultId);
603
+ let nextId = useRef(null);
604
+ let res = $704cf1d3b684cc5c$export$619500959fc48b26(value);
605
+ let updateValue = useCallback((val)=>{
606
+ nextId.current = val;
607
+ }, []);
608
+ $bdb11010cef70236$var$idsUpdaterMap.set(res, updateValue);
609
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
610
+ let r = res;
611
+ return ()=>{
612
+ $bdb11010cef70236$var$idsUpdaterMap.delete(r);
613
+ };
614
+ }, [
615
+ res
616
+ ]);
617
+ // This cannot cause an infinite loop because the ref is updated first.
618
+ // eslint-disable-next-line
619
+ useEffect(()=>{
620
+ let newId = nextId.current;
621
+ if (newId) {
622
+ nextId.current = null;
623
+ setValue(newId);
624
+ }
625
+ });
626
+ return res;
627
+ }
628
+ function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
629
+ if (idA === idB) return idA;
630
+ let setIdA = $bdb11010cef70236$var$idsUpdaterMap.get(idA);
631
+ if (setIdA) {
632
+ setIdA(idB);
633
+ return idB;
634
+ }
635
+ let setIdB = $bdb11010cef70236$var$idsUpdaterMap.get(idB);
636
+ if (setIdB) {
637
+ setIdB(idA);
638
+ return idA;
639
+ }
640
+ return idB;
641
+ }
642
+ function $bdb11010cef70236$export$b4cc09c592e8fdb8(depArray = []) {
643
+ let id = $bdb11010cef70236$export$f680877a34711e37();
644
+ let [resolvedId, setResolvedId] = $1dbecbe27a04f9af$export$14d238f342723f25(id);
645
+ let updateId = useCallback(()=>{
646
+ setResolvedId(function*() {
647
+ yield id;
648
+ yield document.getElementById(id) ? id : null;
649
+ });
650
+ }, [
651
+ id,
652
+ setResolvedId
653
+ ]);
654
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(updateId, [
655
+ id,
656
+ updateId,
657
+ ...depArray
658
+ ]);
659
+ return resolvedId;
660
+ }
661
+
662
+
663
+ var $ff5963eb1fccf552$exports = {};
664
+
665
+ $parcel$export$3($ff5963eb1fccf552$exports, "chain", () => $ff5963eb1fccf552$export$e08e3b67e392101e);
666
+ function $ff5963eb1fccf552$export$e08e3b67e392101e(...callbacks) {
667
+ return (...args)=>{
668
+ for (let callback of callbacks)if (typeof callback === 'function') callback(...args);
669
+ };
670
+ }
671
+
672
+
673
+ var $3ef42575df84b30b$exports = {};
674
+
675
+ $parcel$export$3($3ef42575df84b30b$exports, "mergeProps", () => $3ef42575df84b30b$export$9d1611c77c2fe928);
676
+
677
+
678
+
679
+ function $3ef42575df84b30b$export$9d1611c77c2fe928(...args) {
680
+ // Start with a base clone of the first argument. This is a lot faster than starting
681
+ // with an empty object and adding properties as we go.
682
+ let result = {
683
+ ...args[0]
684
+ };
685
+ for(let i = 1; i < args.length; i++){
686
+ let props = args[i];
687
+ for(let key in props){
688
+ let a = result[key];
689
+ let b = props[key];
690
+ // Chain events
691
+ if (typeof a === 'function' && typeof b === 'function' && // This is a lot faster than a regex.
692
+ key[0] === 'o' && key[1] === 'n' && key.charCodeAt(2) >= /* 'A' */ 65 && key.charCodeAt(2) <= /* 'Z' */ 90) result[key] = $ff5963eb1fccf552$export$e08e3b67e392101e(a, b);
693
+ else if ((key === 'className' || key === 'UNSAFE_className') && typeof a === 'string' && typeof b === 'string') result[key] = clsx(a, b);
694
+ else if (key === 'id' && a && b) result.id = $bdb11010cef70236$export$cd8c9cb68f842629(a, b);
695
+ else result[key] = b !== undefined ? b : a;
696
+ }
697
+ }
698
+ return result;
699
+ }
700
+
701
+
702
+ var $5dc95899b306f630$exports = {};
703
+
704
+ $parcel$export$3($5dc95899b306f630$exports, "mergeRefs", () => $5dc95899b306f630$export$c9058316764c140e);
705
+ function $5dc95899b306f630$export$c9058316764c140e(...refs) {
706
+ return (value)=>{
707
+ for (let ref of refs){
708
+ if (typeof ref === 'function') ref(value);
709
+ else if (ref != null) ref.current = value;
710
+ }
711
+ };
712
+ }
713
+
714
+
715
+ var $65484d02dcb7eb3e$exports = {};
716
+
717
+ $parcel$export$3($65484d02dcb7eb3e$exports, "filterDOMProps", () => $65484d02dcb7eb3e$export$457c3d6518dd4c6f);
718
+ const $65484d02dcb7eb3e$var$DOMPropNames = new Set([
719
+ 'id'
720
+ ]);
721
+ const $65484d02dcb7eb3e$var$labelablePropNames = new Set([
722
+ 'aria-label',
723
+ 'aria-labelledby',
724
+ 'aria-describedby',
725
+ 'aria-details'
726
+ ]);
727
+ const $65484d02dcb7eb3e$var$propRe = /^(data-.*)$/;
728
+ function $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, opts = {
729
+ }) {
730
+ let { labelable: labelable , propNames: propNames } = opts;
731
+ let filteredProps = {
732
+ };
733
+ for(const prop in props)if (Object.prototype.hasOwnProperty.call(props, prop) && ($65484d02dcb7eb3e$var$DOMPropNames.has(prop) || labelable && $65484d02dcb7eb3e$var$labelablePropNames.has(prop) || (propNames === null || propNames === void 0 ? void 0 : propNames.has(prop)) || $65484d02dcb7eb3e$var$propRe.test(prop))) filteredProps[prop] = props[prop];
734
+ return filteredProps;
735
+ }
736
+
737
+
738
+ var $7215afc6de606d6b$exports = {};
739
+
740
+ $parcel$export$3($7215afc6de606d6b$exports, "focusWithoutScrolling", () => $7215afc6de606d6b$export$de79e2c695e052f3);
741
+ function $7215afc6de606d6b$export$de79e2c695e052f3(element) {
742
+ if ($7215afc6de606d6b$var$supportsPreventScroll()) element.focus({
743
+ preventScroll: true
744
+ });
745
+ else {
746
+ let scrollableElements = $7215afc6de606d6b$var$getScrollableElements(element);
747
+ element.focus();
748
+ $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements);
749
+ }
750
+ }
751
+ let $7215afc6de606d6b$var$supportsPreventScrollCached = null;
752
+ function $7215afc6de606d6b$var$supportsPreventScroll() {
753
+ if ($7215afc6de606d6b$var$supportsPreventScrollCached == null) {
754
+ $7215afc6de606d6b$var$supportsPreventScrollCached = false;
755
+ try {
756
+ var focusElem = document.createElement('div');
757
+ focusElem.focus({
758
+ get preventScroll () {
759
+ $7215afc6de606d6b$var$supportsPreventScrollCached = true;
760
+ return true;
761
+ }
762
+ });
763
+ } catch (e) {
764
+ // Ignore
765
+ }
766
+ }
767
+ return $7215afc6de606d6b$var$supportsPreventScrollCached;
768
+ }
769
+ function $7215afc6de606d6b$var$getScrollableElements(element) {
770
+ var parent = element.parentNode;
771
+ var scrollableElements = [];
772
+ var rootScrollingElement = document.scrollingElement || document.documentElement;
773
+ while(parent instanceof HTMLElement && parent !== rootScrollingElement){
774
+ if (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) scrollableElements.push({
775
+ element: parent,
776
+ scrollTop: parent.scrollTop,
777
+ scrollLeft: parent.scrollLeft
778
+ });
779
+ parent = parent.parentNode;
780
+ }
781
+ if (rootScrollingElement instanceof HTMLElement) scrollableElements.push({
782
+ element: rootScrollingElement,
783
+ scrollTop: rootScrollingElement.scrollTop,
784
+ scrollLeft: rootScrollingElement.scrollLeft
785
+ });
786
+ return scrollableElements;
787
+ }
788
+ function $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements) {
789
+ for (let { element: element , scrollTop: scrollTop , scrollLeft: scrollLeft } of scrollableElements){
790
+ element.scrollTop = scrollTop;
791
+ element.scrollLeft = scrollLeft;
792
+ }
793
+ }
794
+
795
+
796
+ var $ab71dadb03a6fb2e$exports = {};
797
+
798
+ $parcel$export$3($ab71dadb03a6fb2e$exports, "getOffset", () => $ab71dadb03a6fb2e$export$622cea445a1c5b7d);
799
+ function $ab71dadb03a6fb2e$export$622cea445a1c5b7d(element, reverse, orientation = 'horizontal') {
800
+ let rect = element.getBoundingClientRect();
801
+ if (reverse) return orientation === 'horizontal' ? rect.right : rect.bottom;
802
+ return orientation === 'horizontal' ? rect.left : rect.top;
803
+ }
804
+
805
+
806
+ var $103b0e103f1b5952$exports = {};
807
+
808
+ $parcel$export$3($103b0e103f1b5952$exports, "clamp", () => $9446cca9a3875146$export$7d15b64cf5a3a4c4);
809
+ $parcel$export$3($103b0e103f1b5952$exports, "snapValueToStep", () => $9446cca9a3875146$export$cb6e0bb50bc19463);
810
+
811
+
812
+
813
+ var $bbed8b41f857bcc0$exports = {};
814
+
815
+ $parcel$export$3($bbed8b41f857bcc0$exports, "runAfterTransition", () => $bbed8b41f857bcc0$export$24490316f764c430);
816
+ /*
817
+ * Copyright 2020 Adobe. All rights reserved.
818
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
819
+ * you may not use this file except in compliance with the License. You may obtain a copy
820
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
821
+ *
822
+ * Unless required by applicable law or agreed to in writing, software distributed under
823
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
824
+ * OF ANY KIND, either express or implied. See the License for the specific language
825
+ * governing permissions and limitations under the License.
826
+ */ // We store a global list of elements that are currently transitioning,
827
+ // mapped to a set of CSS properties that are transitioning for that element.
828
+ // This is necessary rather than a simple count of transitions because of browser
829
+ // bugs, e.g. Chrome sometimes fires both transitionend and transitioncancel rather
830
+ // than one or the other. So we need to track what's actually transitioning so that
831
+ // we can ignore these duplicate events.
832
+ let $bbed8b41f857bcc0$var$transitionsByElement = new Map();
833
+ // A list of callbacks to call once there are no transitioning elements.
834
+ let $bbed8b41f857bcc0$var$transitionCallbacks = new Set();
835
+ function $bbed8b41f857bcc0$var$setupGlobalEvents() {
836
+ if (typeof window === 'undefined') return;
837
+ let onTransitionStart = (e)=>{
838
+ // Add the transitioning property to the list for this element.
839
+ let transitions = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
840
+ if (!transitions) {
841
+ transitions = new Set();
842
+ $bbed8b41f857bcc0$var$transitionsByElement.set(e.target, transitions);
843
+ // The transitioncancel event must be registered on the element itself, rather than as a global
844
+ // event. This enables us to handle when the node is deleted from the document while it is transitioning.
845
+ // In that case, the cancel event would have nowhere to bubble to so we need to handle it directly.
846
+ e.target.addEventListener('transitioncancel', onTransitionEnd);
847
+ }
848
+ transitions.add(e.propertyName);
849
+ };
850
+ let onTransitionEnd = (e)=>{
851
+ // Remove property from list of transitioning properties.
852
+ let properties = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
853
+ if (!properties) return;
854
+ properties.delete(e.propertyName);
855
+ // If empty, remove transitioncancel event, and remove the element from the list of transitioning elements.
856
+ if (properties.size === 0) {
857
+ e.target.removeEventListener('transitioncancel', onTransitionEnd);
858
+ $bbed8b41f857bcc0$var$transitionsByElement.delete(e.target);
859
+ }
860
+ // If no transitioning elements, call all of the queued callbacks.
861
+ if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) {
862
+ for (let cb of $bbed8b41f857bcc0$var$transitionCallbacks)cb();
863
+ $bbed8b41f857bcc0$var$transitionCallbacks.clear();
864
+ }
865
+ };
866
+ document.body.addEventListener('transitionrun', onTransitionStart);
867
+ document.body.addEventListener('transitionend', onTransitionEnd);
868
+ }
869
+ if (typeof document !== 'undefined') {
870
+ if (document.readyState !== 'loading') $bbed8b41f857bcc0$var$setupGlobalEvents();
871
+ else document.addEventListener('DOMContentLoaded', $bbed8b41f857bcc0$var$setupGlobalEvents);
872
+ }
873
+ function $bbed8b41f857bcc0$export$24490316f764c430(fn) {
874
+ // Wait one frame to see if an animation starts, e.g. a transition on mount.
875
+ requestAnimationFrame(()=>{
876
+ // If no transitions are running, call the function immediately.
877
+ // Otherwise, add it to a list of callbacks to run at the end of the animation.
878
+ if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) fn();
879
+ else $bbed8b41f857bcc0$var$transitionCallbacks.add(fn);
880
+ });
881
+ }
882
+
883
+
884
+ var $9cc09df9fd7676be$exports = {};
885
+
886
+ $parcel$export$3($9cc09df9fd7676be$exports, "useDrag1D", () => $9cc09df9fd7676be$export$7bbed75feba39706);
887
+
888
+
889
+ // Keep track of elements that we are currently handling dragging for via useDrag1D.
890
+ // If there's an ancestor and a descendant both using useDrag1D(), and the user starts
891
+ // dragging the descendant, we don't want useDrag1D events to fire for the ancestor.
892
+ const $9cc09df9fd7676be$var$draggingElements = [];
893
+ function $9cc09df9fd7676be$export$7bbed75feba39706(props) {
894
+ console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');
895
+ let { containerRef: containerRef , reverse: reverse , orientation: orientation , onHover: onHover , onDrag: onDrag , onPositionChange: onPositionChange , onIncrement: onIncrement , onDecrement: onDecrement , onIncrementToMax: onIncrementToMax , onDecrementToMin: onDecrementToMin , onCollapseToggle: onCollapseToggle } = props;
896
+ let getPosition = (e)=>orientation === 'horizontal' ? e.clientX : e.clientY
897
+ ;
898
+ let getNextOffset = (e)=>{
899
+ let containerOffset = $ab71dadb03a6fb2e$export$622cea445a1c5b7d(containerRef.current, reverse, orientation);
900
+ let mouseOffset = getPosition(e);
901
+ let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;
902
+ return nextOffset;
903
+ };
904
+ let dragging = useRef(false);
905
+ let prevPosition = useRef(0);
906
+ // Keep track of the current handlers in a ref so that the events can access them.
907
+ let handlers = useRef({
908
+ onPositionChange: onPositionChange,
909
+ onDrag: onDrag
910
+ });
911
+ handlers.current.onDrag = onDrag;
912
+ handlers.current.onPositionChange = onPositionChange;
913
+ let onMouseDragged = (e)=>{
914
+ e.preventDefault();
915
+ let nextOffset = getNextOffset(e);
916
+ if (!dragging.current) {
917
+ dragging.current = true;
918
+ if (handlers.current.onDrag) handlers.current.onDrag(true);
919
+ if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
920
+ }
921
+ if (prevPosition.current === nextOffset) return;
922
+ prevPosition.current = nextOffset;
923
+ if (onPositionChange) onPositionChange(nextOffset);
924
+ };
925
+ let onMouseUp = (e)=>{
926
+ const target = e.target;
927
+ dragging.current = false;
928
+ let nextOffset = getNextOffset(e);
929
+ if (handlers.current.onDrag) handlers.current.onDrag(false);
930
+ if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
931
+ $9cc09df9fd7676be$var$draggingElements.splice($9cc09df9fd7676be$var$draggingElements.indexOf(target), 1);
932
+ window.removeEventListener('mouseup', onMouseUp, false);
933
+ window.removeEventListener('mousemove', onMouseDragged, false);
934
+ };
935
+ let onMouseDown = (e)=>{
936
+ const target = e.currentTarget;
937
+ // If we're already handling dragging on a descendant with useDrag1D, then
938
+ // we don't want to handle the drag motion on this target as well.
939
+ if ($9cc09df9fd7676be$var$draggingElements.some((elt)=>target.contains(elt)
940
+ )) return;
941
+ $9cc09df9fd7676be$var$draggingElements.push(target);
942
+ window.addEventListener('mousemove', onMouseDragged, false);
943
+ window.addEventListener('mouseup', onMouseUp, false);
944
+ };
945
+ let onMouseEnter = ()=>{
946
+ if (onHover) onHover(true);
947
+ };
948
+ let onMouseOut = ()=>{
949
+ if (onHover) onHover(false);
950
+ };
951
+ let onKeyDown = (e)=>{
952
+ switch(e.key){
953
+ case 'Left':
954
+ case 'ArrowLeft':
955
+ if (orientation === 'horizontal') {
956
+ e.preventDefault();
957
+ if (onDecrement && !reverse) onDecrement();
958
+ else if (onIncrement && reverse) onIncrement();
959
+ }
960
+ break;
961
+ case 'Up':
962
+ case 'ArrowUp':
963
+ if (orientation === 'vertical') {
964
+ e.preventDefault();
965
+ if (onDecrement && !reverse) onDecrement();
966
+ else if (onIncrement && reverse) onIncrement();
967
+ }
968
+ break;
969
+ case 'Right':
970
+ case 'ArrowRight':
971
+ if (orientation === 'horizontal') {
972
+ e.preventDefault();
973
+ if (onIncrement && !reverse) onIncrement();
974
+ else if (onDecrement && reverse) onDecrement();
975
+ }
976
+ break;
977
+ case 'Down':
978
+ case 'ArrowDown':
979
+ if (orientation === 'vertical') {
980
+ e.preventDefault();
981
+ if (onIncrement && !reverse) onIncrement();
982
+ else if (onDecrement && reverse) onDecrement();
983
+ }
984
+ break;
985
+ case 'Home':
986
+ e.preventDefault();
987
+ if (onDecrementToMin) onDecrementToMin();
988
+ break;
989
+ case 'End':
990
+ e.preventDefault();
991
+ if (onIncrementToMax) onIncrementToMax();
992
+ break;
993
+ case 'Enter':
994
+ e.preventDefault();
995
+ if (onCollapseToggle) onCollapseToggle();
996
+ break;
997
+ }
998
+ };
999
+ return {
1000
+ onMouseDown: onMouseDown,
1001
+ onMouseEnter: onMouseEnter,
1002
+ onMouseOut: onMouseOut,
1003
+ onKeyDown: onKeyDown
1004
+ };
1005
+ }
1006
+
1007
+
1008
+ var $03deb23ff14920c4$exports = {};
1009
+
1010
+ $parcel$export$3($03deb23ff14920c4$exports, "useGlobalListeners", () => $03deb23ff14920c4$export$4eaf04e54aa8eed6);
1011
+
1012
+ function $03deb23ff14920c4$export$4eaf04e54aa8eed6() {
1013
+ let globalListeners = useRef(new Map());
1014
+ let addGlobalListener = useCallback((eventTarget, type, listener, options)=>{
1015
+ // Make sure we remove the listener after it is called with the `once` option.
1016
+ let fn = (options === null || options === void 0 ? void 0 : options.once) ? (...args)=>{
1017
+ globalListeners.current.delete(listener);
1018
+ listener(...args);
1019
+ } : listener;
1020
+ globalListeners.current.set(listener, {
1021
+ type: type,
1022
+ eventTarget: eventTarget,
1023
+ fn: fn,
1024
+ options: options
1025
+ });
1026
+ eventTarget.addEventListener(type, listener, options);
1027
+ }, []);
1028
+ let removeGlobalListener = useCallback((eventTarget, type, listener, options)=>{
1029
+ var ref;
1030
+ let fn = ((ref = globalListeners.current.get(listener)) === null || ref === void 0 ? void 0 : ref.fn) || listener;
1031
+ eventTarget.removeEventListener(type, fn, options);
1032
+ globalListeners.current.delete(listener);
1033
+ }, []);
1034
+ let removeAllGlobalListeners = useCallback(()=>{
1035
+ globalListeners.current.forEach((value, key)=>{
1036
+ removeGlobalListener(value.eventTarget, value.type, key, value.options);
1037
+ });
1038
+ }, [
1039
+ removeGlobalListener
1040
+ ]);
1041
+ // eslint-disable-next-line arrow-body-style
1042
+ useEffect(()=>{
1043
+ return removeAllGlobalListeners;
1044
+ }, [
1045
+ removeAllGlobalListeners
1046
+ ]);
1047
+ return {
1048
+ addGlobalListener: addGlobalListener,
1049
+ removeGlobalListener: removeGlobalListener,
1050
+ removeAllGlobalListeners: removeAllGlobalListeners
1051
+ };
1052
+ }
1053
+
1054
+
1055
+ var $313b98861ee5dd6c$exports = {};
1056
+
1057
+ $parcel$export$3($313b98861ee5dd6c$exports, "useLabels", () => $313b98861ee5dd6c$export$d6875122194c7b44);
1058
+
1059
+ function $313b98861ee5dd6c$export$d6875122194c7b44(props, defaultLabel) {
1060
+ let { id: id , 'aria-label': label , 'aria-labelledby': labelledBy } = props;
1061
+ // If there is both an aria-label and aria-labelledby,
1062
+ // combine them by pointing to the element itself.
1063
+ id = $bdb11010cef70236$export$f680877a34711e37(id);
1064
+ if (labelledBy && label) {
1065
+ let ids = new Set([
1066
+ ...labelledBy.trim().split(/\s+/),
1067
+ id
1068
+ ]);
1069
+ labelledBy = [
1070
+ ...ids
1071
+ ].join(' ');
1072
+ } else if (labelledBy) labelledBy = labelledBy.trim().split(/\s+/).join(' ');
1073
+ // If no labels are provided, use the default
1074
+ if (!label && !labelledBy && defaultLabel) label = defaultLabel;
1075
+ return {
1076
+ id: id,
1077
+ 'aria-label': label,
1078
+ 'aria-labelledby': labelledBy
1079
+ };
1080
+ }
1081
+
1082
+
1083
+ var $df56164dff5785e2$exports = {};
1084
+
1085
+ $parcel$export$3($df56164dff5785e2$exports, "useObjectRef", () => $df56164dff5785e2$export$4338b53315abf666);
1086
+
1087
+
1088
+ function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) {
1089
+ const objRef = useRef();
1090
+ /**
1091
+ * We're using `useLayoutEffect` here instead of `useEffect` because we want
1092
+ * to make sure that the `ref` value is up to date before other places in the
1093
+ * the execution cycle try to read it.
1094
+ */ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
1095
+ if (!forwardedRef) return;
1096
+ if (typeof forwardedRef === 'function') forwardedRef(objRef.current);
1097
+ else forwardedRef.current = objRef.current;
1098
+ }, [
1099
+ forwardedRef
1100
+ ]);
1101
+ return objRef;
1102
+ }
1103
+
1104
+
1105
+ var $4f58c5f72bcf79f7$exports = {};
1106
+
1107
+ $parcel$export$3($4f58c5f72bcf79f7$exports, "useUpdateEffect", () => $4f58c5f72bcf79f7$export$496315a1608d9602);
1108
+
1109
+ function $4f58c5f72bcf79f7$export$496315a1608d9602(effect, dependencies) {
1110
+ const isInitialMount = useRef(true);
1111
+ useEffect(()=>{
1112
+ if (isInitialMount.current) isInitialMount.current = false;
1113
+ else effect();
1114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1115
+ }, dependencies);
1116
+ }
1117
+
1118
+
1119
+
1120
+ var $9daab02d461809db$exports = {};
1121
+
1122
+ $parcel$export$3($9daab02d461809db$exports, "useResizeObserver", () => $9daab02d461809db$export$683480f191c0e3ea);
1123
+
1124
+ function $9daab02d461809db$var$hasResizeObserver() {
1125
+ return typeof window.ResizeObserver !== 'undefined';
1126
+ }
1127
+ function $9daab02d461809db$export$683480f191c0e3ea(options) {
1128
+ const { ref: ref , onResize: onResize } = options;
1129
+ useEffect(()=>{
1130
+ let element = ref === null || ref === void 0 ? void 0 : ref.current;
1131
+ if (!element) return;
1132
+ if (!$9daab02d461809db$var$hasResizeObserver()) {
1133
+ window.addEventListener('resize', onResize, false);
1134
+ return ()=>{
1135
+ window.removeEventListener('resize', onResize, false);
1136
+ };
1137
+ } else {
1138
+ const resizeObserverInstance = new window.ResizeObserver((entries)=>{
1139
+ if (!entries.length) return;
1140
+ onResize();
1141
+ });
1142
+ resizeObserverInstance.observe(element);
1143
+ return ()=>{
1144
+ if (element) resizeObserverInstance.unobserve(element);
1145
+ };
1146
+ }
1147
+ }, [
1148
+ onResize,
1149
+ ref
1150
+ ]);
1151
+ }
1152
+
1153
+
1154
+ var $e7801be82b4b2a53$exports = {};
1155
+
1156
+ $parcel$export$3($e7801be82b4b2a53$exports, "useSyncRef", () => $e7801be82b4b2a53$export$4debdb1a3f0fa79e);
1157
+
1158
+ function $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, ref) {
1159
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
1160
+ if (context && context.ref && ref) {
1161
+ context.ref.current = ref.current;
1162
+ return ()=>{
1163
+ context.ref.current = null;
1164
+ };
1165
+ }
1166
+ }, [
1167
+ context,
1168
+ ref
1169
+ ]);
1170
+ }
1171
+
1172
+
1173
+ var $62d8ded9296f3872$exports = {};
1174
+
1175
+ $parcel$export$3($62d8ded9296f3872$exports, "getScrollParent", () => $62d8ded9296f3872$export$cfa2225e87938781);
1176
+ function $62d8ded9296f3872$export$cfa2225e87938781(node) {
1177
+ while(node && !$62d8ded9296f3872$var$isScrollable(node))node = node.parentElement;
1178
+ return node || document.scrollingElement || document.documentElement;
1179
+ }
1180
+ function $62d8ded9296f3872$var$isScrollable(node) {
1181
+ let style = window.getComputedStyle(node);
1182
+ return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
1183
+ }
1184
+
1185
+
1186
+ var $5df64b3807dc15ee$exports = {};
1187
+
1188
+ $parcel$export$3($5df64b3807dc15ee$exports, "useViewportSize", () => $5df64b3807dc15ee$export$d699905dd57c73ca);
1189
+
1190
+ // @ts-ignore
1191
+ let $5df64b3807dc15ee$var$visualViewport = typeof window !== 'undefined' && window.visualViewport;
1192
+ function $5df64b3807dc15ee$export$d699905dd57c73ca() {
1193
+ let [size1, setSize] = useState(()=>$5df64b3807dc15ee$var$getViewportSize()
1194
+ );
1195
+ useEffect(()=>{
1196
+ // Use visualViewport api to track available height even on iOS virtual keyboard opening
1197
+ let onResize = ()=>{
1198
+ setSize((size)=>{
1199
+ let newSize = $5df64b3807dc15ee$var$getViewportSize();
1200
+ if (newSize.width === size.width && newSize.height === size.height) return size;
1201
+ return newSize;
1202
+ });
1203
+ };
1204
+ if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener('resize', onResize);
1205
+ else $5df64b3807dc15ee$var$visualViewport.addEventListener('resize', onResize);
1206
+ return ()=>{
1207
+ if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener('resize', onResize);
1208
+ else $5df64b3807dc15ee$var$visualViewport.removeEventListener('resize', onResize);
1209
+ };
1210
+ }, []);
1211
+ return size1;
1212
+ }
1213
+ function $5df64b3807dc15ee$var$getViewportSize() {
1214
+ return {
1215
+ width: ($5df64b3807dc15ee$var$visualViewport === null || $5df64b3807dc15ee$var$visualViewport === void 0 ? void 0 : $5df64b3807dc15ee$var$visualViewport.width) || window.innerWidth,
1216
+ height: ($5df64b3807dc15ee$var$visualViewport === null || $5df64b3807dc15ee$var$visualViewport === void 0 ? void 0 : $5df64b3807dc15ee$var$visualViewport.height) || window.innerHeight
1217
+ };
1218
+ }
1219
+
1220
+
1221
+ var $ef06256079686ba0$exports = {};
1222
+
1223
+ $parcel$export$3($ef06256079686ba0$exports, "useDescription", () => $ef06256079686ba0$export$f8aeda7b10753fa1);
1224
+
1225
+
1226
+ let $ef06256079686ba0$var$descriptionId = 0;
1227
+ const $ef06256079686ba0$var$descriptionNodes = new Map();
1228
+ function $ef06256079686ba0$export$f8aeda7b10753fa1(description) {
1229
+ let [id1, setId] = useState(null);
1230
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
1231
+ if (!description) return;
1232
+ let desc = $ef06256079686ba0$var$descriptionNodes.get(description);
1233
+ if (!desc) {
1234
+ let id = `react-aria-description-${$ef06256079686ba0$var$descriptionId++}`;
1235
+ setId(id);
1236
+ let node = document.createElement('div');
1237
+ node.id = id;
1238
+ node.style.display = 'none';
1239
+ node.textContent = description;
1240
+ document.body.appendChild(node);
1241
+ desc = {
1242
+ refCount: 0,
1243
+ element: node
1244
+ };
1245
+ $ef06256079686ba0$var$descriptionNodes.set(description, desc);
1246
+ } else setId(desc.element.id);
1247
+ desc.refCount++;
1248
+ return ()=>{
1249
+ if (--desc.refCount === 0) {
1250
+ desc.element.remove();
1251
+ $ef06256079686ba0$var$descriptionNodes.delete(description);
1252
+ }
1253
+ };
1254
+ }, [
1255
+ description
1256
+ ]);
1257
+ return {
1258
+ 'aria-describedby': description ? id1 : undefined
1259
+ };
1260
+ }
1261
+
1262
+
1263
+ var $c87311424ea30a05$exports = {};
1264
+
1265
+ $parcel$export$3($c87311424ea30a05$exports, "isMac", () => $c87311424ea30a05$export$9ac100e40613ea10);
1266
+ $parcel$export$3($c87311424ea30a05$exports, "isIPhone", () => $c87311424ea30a05$export$186c6964ca17d99);
1267
+ $parcel$export$3($c87311424ea30a05$exports, "isIPad", () => $c87311424ea30a05$export$7bef049ce92e4224);
1268
+ $parcel$export$3($c87311424ea30a05$exports, "isIOS", () => $c87311424ea30a05$export$fedb369cb70207f1);
1269
+ $parcel$export$3($c87311424ea30a05$exports, "isAppleDevice", () => $c87311424ea30a05$export$e1865c3bedcd822b);
1270
+ $parcel$export$3($c87311424ea30a05$exports, "isWebKit", () => $c87311424ea30a05$export$78551043582a6a98);
1271
+ $parcel$export$3($c87311424ea30a05$exports, "isChrome", () => $c87311424ea30a05$export$6446a186d09e379e);
1272
+ $parcel$export$3($c87311424ea30a05$exports, "isAndroid", () => $c87311424ea30a05$export$a11b0059900ceec8);
1273
+ /*
1274
+ * Copyright 2020 Adobe. All rights reserved.
1275
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1276
+ * you may not use this file except in compliance with the License. You may obtain a copy
1277
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
1278
+ *
1279
+ * Unless required by applicable law or agreed to in writing, software distributed under
1280
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1281
+ * OF ANY KIND, either express or implied. See the License for the specific language
1282
+ * governing permissions and limitations under the License.
1283
+ */ function $c87311424ea30a05$var$testUserAgent(re) {
1284
+ var ref;
1285
+ if (typeof window === 'undefined' || window.navigator == null) return false;
1286
+ return ((ref = window.navigator['userAgentData']) === null || ref === void 0 ? void 0 : ref.brands.some((brand)=>re.test(brand.brand)
1287
+ )) || re.test(window.navigator.userAgent);
1288
+ }
1289
+ function $c87311424ea30a05$var$testPlatform(re) {
1290
+ return typeof window !== 'undefined' && window.navigator != null ? re.test((window.navigator['userAgentData'] || window.navigator).platform) : false;
1291
+ }
1292
+ function $c87311424ea30a05$export$9ac100e40613ea10() {
1293
+ return $c87311424ea30a05$var$testPlatform(/^Mac/i);
1294
+ }
1295
+ function $c87311424ea30a05$export$186c6964ca17d99() {
1296
+ return $c87311424ea30a05$var$testPlatform(/^iPhone/i);
1297
+ }
1298
+ function $c87311424ea30a05$export$7bef049ce92e4224() {
1299
+ return $c87311424ea30a05$var$testPlatform(/^iPad/i) || $c87311424ea30a05$export$9ac100e40613ea10() && navigator.maxTouchPoints > 1;
1300
+ }
1301
+ function $c87311424ea30a05$export$fedb369cb70207f1() {
1302
+ return $c87311424ea30a05$export$186c6964ca17d99() || $c87311424ea30a05$export$7bef049ce92e4224();
1303
+ }
1304
+ function $c87311424ea30a05$export$e1865c3bedcd822b() {
1305
+ return $c87311424ea30a05$export$9ac100e40613ea10() || $c87311424ea30a05$export$fedb369cb70207f1();
1306
+ }
1307
+ function $c87311424ea30a05$export$78551043582a6a98() {
1308
+ return $c87311424ea30a05$var$testUserAgent(/AppleWebKit/i) && !$c87311424ea30a05$export$6446a186d09e379e();
1309
+ }
1310
+ function $c87311424ea30a05$export$6446a186d09e379e() {
1311
+ return $c87311424ea30a05$var$testUserAgent(/Chrome/i);
1312
+ }
1313
+ function $c87311424ea30a05$export$a11b0059900ceec8() {
1314
+ return $c87311424ea30a05$var$testUserAgent(/Android/i);
1315
+ }
1316
+
1317
+
1318
+ var $e9faafb641e167db$exports = {};
1319
+
1320
+ $parcel$export$3($e9faafb641e167db$exports, "useEvent", () => $e9faafb641e167db$export$90fc3a17d93f704c);
1321
+
1322
+ function $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler1, options) {
1323
+ let handlerRef = useRef(handler1);
1324
+ handlerRef.current = handler1;
1325
+ let isDisabled = handler1 == null;
1326
+ useEffect(()=>{
1327
+ if (isDisabled) return;
1328
+ let element = ref.current;
1329
+ let handler = (e)=>handlerRef.current.call(this, e)
1330
+ ;
1331
+ element.addEventListener(event, handler, options);
1332
+ return ()=>{
1333
+ element.removeEventListener(event, handler, options);
1334
+ };
1335
+ }, [
1336
+ ref,
1337
+ event,
1338
+ options,
1339
+ isDisabled
1340
+ ]);
1341
+ }
1342
+
1343
+
1344
+ var $1dbecbe27a04f9af$exports = {};
1345
+
1346
+ $parcel$export$3($1dbecbe27a04f9af$exports, "useValueEffect", () => $1dbecbe27a04f9af$export$14d238f342723f25);
1347
+
1348
+
1349
+ function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
1350
+ let [value, setValue] = useState(defaultValue);
1351
+ let valueRef = useRef(value);
1352
+ let effect = useRef(null);
1353
+ valueRef.current = value;
1354
+ // Store the function in a ref so we can always access the current version
1355
+ // which has the proper `value` in scope.
1356
+ let nextRef = useRef(null);
1357
+ nextRef.current = ()=>{
1358
+ // Run the generator to the next yield.
1359
+ let newValue = effect.current.next();
1360
+ // If the generator is done, reset the effect.
1361
+ if (newValue.done) {
1362
+ effect.current = null;
1363
+ return;
1364
+ }
1365
+ // If the value is the same as the current value,
1366
+ // then continue to the next yield. Otherwise,
1367
+ // set the value in state and wait for the next layout effect.
1368
+ if (value === newValue.value) nextRef.current();
1369
+ else setValue(newValue.value);
1370
+ };
1371
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
1372
+ // If there is an effect currently running, continue to the next yield.
1373
+ if (effect.current) nextRef.current();
1374
+ });
1375
+ let queue = useCallback((fn)=>{
1376
+ effect.current = fn(valueRef.current);
1377
+ nextRef.current();
1378
+ }, [
1379
+ effect,
1380
+ nextRef
1381
+ ]);
1382
+ return [
1383
+ value,
1384
+ queue
1385
+ ];
1386
+ }
1387
+
1388
+
1389
+ var $2f04cbc44ee30ce0$exports = {};
1390
+
1391
+ $parcel$export$3($2f04cbc44ee30ce0$exports, "scrollIntoView", () => $2f04cbc44ee30ce0$export$53a0910f038337bd);
1392
+ function $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollView, element) {
1393
+ let offsetX = $2f04cbc44ee30ce0$var$relativeOffset(scrollView, element, 'left');
1394
+ let offsetY = $2f04cbc44ee30ce0$var$relativeOffset(scrollView, element, 'top');
1395
+ let width = element.offsetWidth;
1396
+ let height = element.offsetHeight;
1397
+ let x = scrollView.scrollLeft;
1398
+ let y = scrollView.scrollTop;
1399
+ let maxX = x + scrollView.offsetWidth;
1400
+ let maxY = y + scrollView.offsetHeight;
1401
+ if (offsetX <= x) x = offsetX;
1402
+ else if (offsetX + width > maxX) x += offsetX + width - maxX;
1403
+ if (offsetY <= y) y = offsetY;
1404
+ else if (offsetY + height > maxY) y += offsetY + height - maxY;
1405
+ scrollView.scrollLeft = x;
1406
+ scrollView.scrollTop = y;
1407
+ }
1408
+ /**
1409
+ * Computes the offset left or top from child to ancestor by accumulating
1410
+ * offsetLeft or offsetTop through intervening offsetParents.
1411
+ */ function $2f04cbc44ee30ce0$var$relativeOffset(ancestor, child, axis) {
1412
+ const prop = axis === 'left' ? 'offsetLeft' : 'offsetTop';
1413
+ let sum = 0;
1414
+ while(child.offsetParent){
1415
+ sum += child[prop];
1416
+ if (child.offsetParent === ancestor) break;
1417
+ else if (child.offsetParent.contains(ancestor)) {
1418
+ // If the ancestor is not `position:relative`, then we stop at
1419
+ // _its_ offset parent, and we subtract off _its_ offset, so that
1420
+ // we end up with the proper offset from child to ancestor.
1421
+ sum -= ancestor[prop];
1422
+ break;
1423
+ }
1424
+ child = child.offsetParent;
1425
+ }
1426
+ return sum;
1427
+ }
1428
+
1429
+ function $parcel$export$2(e, n, v, s) {
1430
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
1431
+ }
1432
+ var $3b117e43dc0ca95d$exports = {};
1433
+
1434
+ $parcel$export$2($3b117e43dc0ca95d$exports, "Pressable", () => $3b117e43dc0ca95d$export$27c701ed9e449e99);
1435
+
1436
+ var $f6c31cce2adf654f$exports = {};
1437
+
1438
+ $parcel$export$2($f6c31cce2adf654f$exports, "usePress", () => $f6c31cce2adf654f$export$45712eceda6fad21);
1439
+
1440
+ // Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
1441
+ // rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
1442
+ let $14c0b72509d70225$var$state = 'default';
1443
+ let $14c0b72509d70225$var$savedUserSelect = '';
1444
+ let $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
1445
+ function $14c0b72509d70225$export$16a4697467175487(target) {
1446
+ if ($c87311424ea30a05$export$fedb369cb70207f1()) {
1447
+ if ($14c0b72509d70225$var$state === 'default') {
1448
+ $14c0b72509d70225$var$savedUserSelect = document.documentElement.style.webkitUserSelect;
1449
+ document.documentElement.style.webkitUserSelect = 'none';
1450
+ }
1451
+ $14c0b72509d70225$var$state = 'disabled';
1452
+ } else if (target) {
1453
+ // If not iOS, store the target's original user-select and change to user-select: none
1454
+ // Ignore state since it doesn't apply for non iOS
1455
+ $14c0b72509d70225$var$modifiedElementMap.set(target, target.style.userSelect);
1456
+ target.style.userSelect = 'none';
1457
+ }
1458
+ }
1459
+ function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
1460
+ if ($c87311424ea30a05$export$fedb369cb70207f1()) {
1461
+ // If the state is already default, there's nothing to do.
1462
+ // If it is restoring, then there's no need to queue a second restore.
1463
+ if ($14c0b72509d70225$var$state !== 'disabled') return;
1464
+ $14c0b72509d70225$var$state = 'restoring';
1465
+ // There appears to be a delay on iOS where selection still might occur
1466
+ // after pointer up, so wait a bit before removing user-select.
1467
+ setTimeout(()=>{
1468
+ // Wait for any CSS transitions to complete so we don't recompute style
1469
+ // for the whole page in the middle of the animation and cause jank.
1470
+ $bbed8b41f857bcc0$export$24490316f764c430(()=>{
1471
+ // Avoid race conditions
1472
+ if ($14c0b72509d70225$var$state === 'restoring') {
1473
+ if (document.documentElement.style.webkitUserSelect === 'none') document.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || '';
1474
+ $14c0b72509d70225$var$savedUserSelect = '';
1475
+ $14c0b72509d70225$var$state = 'default';
1476
+ }
1477
+ });
1478
+ }, 300);
1479
+ } else // If not iOS, restore the target's original user-select if any
1480
+ // Ignore state since it doesn't apply for non iOS
1481
+ if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
1482
+ let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
1483
+ if (target.style.userSelect === 'none') target.style.userSelect = targetOldUserSelect;
1484
+ if (target.getAttribute('style') === '') target.removeAttribute('style');
1485
+ $14c0b72509d70225$var$modifiedElementMap.delete(target);
1486
+ }
1487
+ }
1488
+
1489
+
1490
+
1491
+
1492
+
1493
+
1494
+ function $8a9cb279dc87e130$export$60278871457622de(event) {
1495
+ // JAWS/NVDA with Firefox.
1496
+ if (event.mozInputSource === 0 && event.isTrusted) return true;
1497
+ return event.detail === 0 && !event.pointerType;
1498
+ }
1499
+ class $8a9cb279dc87e130$export$905e7fc544a71f36 {
1500
+ isDefaultPrevented() {
1501
+ return this.nativeEvent.defaultPrevented;
1502
+ }
1503
+ preventDefault() {
1504
+ this.defaultPrevented = true;
1505
+ this.nativeEvent.preventDefault();
1506
+ }
1507
+ stopPropagation() {
1508
+ this.nativeEvent.stopPropagation();
1509
+ this.isPropagationStopped = ()=>true
1510
+ ;
1511
+ }
1512
+ isPropagationStopped() {
1513
+ return false;
1514
+ }
1515
+ persist() {
1516
+ }
1517
+ constructor(type, nativeEvent){
1518
+ this.nativeEvent = nativeEvent;
1519
+ this.target = nativeEvent.target;
1520
+ this.currentTarget = nativeEvent.currentTarget;
1521
+ this.relatedTarget = nativeEvent.relatedTarget;
1522
+ this.bubbles = nativeEvent.bubbles;
1523
+ this.cancelable = nativeEvent.cancelable;
1524
+ this.defaultPrevented = nativeEvent.defaultPrevented;
1525
+ this.eventPhase = nativeEvent.eventPhase;
1526
+ this.isTrusted = nativeEvent.isTrusted;
1527
+ this.timeStamp = nativeEvent.timeStamp;
1528
+ this.type = type;
1529
+ }
1530
+ }
1531
+ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
1532
+ let stateRef = useRef({
1533
+ isFocused: false,
1534
+ onBlur: onBlur,
1535
+ observer: null
1536
+ });
1537
+ stateRef.current.onBlur = onBlur;
1538
+ // Clean up MutationObserver on unmount. See below.
1539
+ // eslint-disable-next-line arrow-body-style
1540
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
1541
+ const state = stateRef.current;
1542
+ return ()=>{
1543
+ if (state.observer) {
1544
+ state.observer.disconnect();
1545
+ state.observer = null;
1546
+ }
1547
+ };
1548
+ }, []);
1549
+ // This function is called during a React onFocus event.
1550
+ return useCallback((e1)=>{
1551
+ // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
1552
+ // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
1553
+ // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
1554
+ // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
1555
+ if (e1.target instanceof HTMLButtonElement || e1.target instanceof HTMLInputElement || e1.target instanceof HTMLTextAreaElement || e1.target instanceof HTMLSelectElement) {
1556
+ stateRef.current.isFocused = true;
1557
+ let target = e1.target;
1558
+ let onBlurHandler = (e)=>{
1559
+ var // For backward compatibility, dispatch a (fake) React synthetic event.
1560
+ _current, ref;
1561
+ stateRef.current.isFocused = false;
1562
+ if (target.disabled) (ref = (_current = stateRef.current).onBlur) === null || ref === void 0 ? void 0 : ref.call(_current, new $8a9cb279dc87e130$export$905e7fc544a71f36('blur', e));
1563
+ // We no longer need the MutationObserver once the target is blurred.
1564
+ if (stateRef.current.observer) {
1565
+ stateRef.current.observer.disconnect();
1566
+ stateRef.current.observer = null;
1567
+ }
1568
+ };
1569
+ target.addEventListener('focusout', onBlurHandler, {
1570
+ once: true
1571
+ });
1572
+ stateRef.current.observer = new MutationObserver(()=>{
1573
+ if (stateRef.current.isFocused && target.disabled) {
1574
+ stateRef.current.observer.disconnect();
1575
+ target.dispatchEvent(new FocusEvent('blur'));
1576
+ target.dispatchEvent(new FocusEvent('focusout', {
1577
+ bubbles: true
1578
+ }));
1579
+ }
1580
+ });
1581
+ stateRef.current.observer.observe(target, {
1582
+ attributes: true,
1583
+ attributeFilter: [
1584
+ 'disabled'
1585
+ ]
1586
+ });
1587
+ }
1588
+ }, []);
1589
+ }
1590
+
1591
+
1592
+
1593
+ const $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = React.createContext(null);
1594
+ $ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = 'PressResponderContext';
1595
+
1596
+
1597
+ function $f6c31cce2adf654f$var$usePressResponderContext(props) {
1598
+ // Consume context from <PressResponder> and merge with props.
1599
+ let context = useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
1600
+ if (context) {
1601
+ let { register: register , ...contextProps } = context;
1602
+ props = $3ef42575df84b30b$export$9d1611c77c2fe928(contextProps, props);
1603
+ register();
1604
+ }
1605
+ $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, props.ref);
1606
+ return props;
1607
+ }
1608
+ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
1609
+ let { onPress: onPress1 , onPressChange: onPressChange1 , onPressStart: onPressStart1 , onPressEnd: onPressEnd1 , onPressUp: onPressUp1 , isDisabled: isDisabled1 , isPressed: isPressedProp , preventFocusOnPress: preventFocusOnPress , shouldCancelOnPointerExit: shouldCancelOnPointerExit , allowTextSelectionOnPress: allowTextSelectionOnPress , // eslint-disable-next-line @typescript-eslint/no-unused-vars
1610
+ ref: _ , ...domProps } = $f6c31cce2adf654f$var$usePressResponderContext(props);
1611
+ let propsRef = useRef(null);
1612
+ propsRef.current = {
1613
+ onPress: onPress1,
1614
+ onPressChange: onPressChange1,
1615
+ onPressStart: onPressStart1,
1616
+ onPressEnd: onPressEnd1,
1617
+ onPressUp: onPressUp1,
1618
+ isDisabled: isDisabled1,
1619
+ shouldCancelOnPointerExit: shouldCancelOnPointerExit
1620
+ };
1621
+ let [isPressed, setPressed] = useState(false);
1622
+ let ref = useRef({
1623
+ isPressed: false,
1624
+ ignoreEmulatedMouseEvents: false,
1625
+ ignoreClickAfterPress: false,
1626
+ didFirePressStart: false,
1627
+ activePointerId: null,
1628
+ target: null,
1629
+ isOverTarget: false,
1630
+ pointerType: null
1631
+ });
1632
+ let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
1633
+ let pressProps1 = useMemo(()=>{
1634
+ let state = ref.current;
1635
+ let triggerPressStart = (originalEvent, pointerType)=>{
1636
+ let { onPressStart: onPressStart , onPressChange: onPressChange , isDisabled: isDisabled } = propsRef.current;
1637
+ if (isDisabled || state.didFirePressStart) return;
1638
+ if (onPressStart) onPressStart({
1639
+ type: 'pressstart',
1640
+ pointerType: pointerType,
1641
+ target: originalEvent.currentTarget,
1642
+ shiftKey: originalEvent.shiftKey,
1643
+ metaKey: originalEvent.metaKey,
1644
+ ctrlKey: originalEvent.ctrlKey,
1645
+ altKey: originalEvent.altKey
1646
+ });
1647
+ if (onPressChange) onPressChange(true);
1648
+ state.didFirePressStart = true;
1649
+ setPressed(true);
1650
+ };
1651
+ let triggerPressEnd = (originalEvent, pointerType, wasPressed = true)=>{
1652
+ let { onPressEnd: onPressEnd , onPressChange: onPressChange , onPress: onPress , isDisabled: isDisabled } = propsRef.current;
1653
+ if (!state.didFirePressStart) return;
1654
+ state.ignoreClickAfterPress = true;
1655
+ state.didFirePressStart = false;
1656
+ if (onPressEnd) onPressEnd({
1657
+ type: 'pressend',
1658
+ pointerType: pointerType,
1659
+ target: originalEvent.currentTarget,
1660
+ shiftKey: originalEvent.shiftKey,
1661
+ metaKey: originalEvent.metaKey,
1662
+ ctrlKey: originalEvent.ctrlKey,
1663
+ altKey: originalEvent.altKey
1664
+ });
1665
+ if (onPressChange) onPressChange(false);
1666
+ setPressed(false);
1667
+ if (onPress && wasPressed && !isDisabled) onPress({
1668
+ type: 'press',
1669
+ pointerType: pointerType,
1670
+ target: originalEvent.currentTarget,
1671
+ shiftKey: originalEvent.shiftKey,
1672
+ metaKey: originalEvent.metaKey,
1673
+ ctrlKey: originalEvent.ctrlKey,
1674
+ altKey: originalEvent.altKey
1675
+ });
1676
+ };
1677
+ let triggerPressUp = (originalEvent, pointerType)=>{
1678
+ let { onPressUp: onPressUp , isDisabled: isDisabled } = propsRef.current;
1679
+ if (isDisabled) return;
1680
+ if (onPressUp) onPressUp({
1681
+ type: 'pressup',
1682
+ pointerType: pointerType,
1683
+ target: originalEvent.currentTarget,
1684
+ shiftKey: originalEvent.shiftKey,
1685
+ metaKey: originalEvent.metaKey,
1686
+ ctrlKey: originalEvent.ctrlKey,
1687
+ altKey: originalEvent.altKey
1688
+ });
1689
+ };
1690
+ let cancel = (e)=>{
1691
+ if (state.isPressed) {
1692
+ if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
1693
+ state.isPressed = false;
1694
+ state.isOverTarget = false;
1695
+ state.activePointerId = null;
1696
+ state.pointerType = null;
1697
+ removeAllGlobalListeners();
1698
+ if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
1699
+ }
1700
+ };
1701
+ let pressProps = {
1702
+ onKeyDown (e) {
1703
+ if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent) && e.currentTarget.contains(e.target)) {
1704
+ if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
1705
+ e.stopPropagation();
1706
+ // If the event is repeating, it may have started on a different element
1707
+ // after which focus moved to the current element. Ignore these events and
1708
+ // only handle the first key down event.
1709
+ if (!state.isPressed && !e.repeat) {
1710
+ state.target = e.currentTarget;
1711
+ state.isPressed = true;
1712
+ triggerPressStart(e, 'keyboard');
1713
+ // Focus may move before the key up event, so register the event on the document
1714
+ // instead of the same element where the key down event occurred.
1715
+ addGlobalListener(document, 'keyup', onKeyUp, false);
1716
+ }
1717
+ }
1718
+ },
1719
+ onKeyUp (e) {
1720
+ if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent) && !e.repeat && e.currentTarget.contains(e.target)) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e), 'keyboard');
1721
+ },
1722
+ onClick (e) {
1723
+ if (e && !e.currentTarget.contains(e.target)) return;
1724
+ if (e && e.button === 0) {
1725
+ e.stopPropagation();
1726
+ if (isDisabled1) e.preventDefault();
1727
+ // If triggered from a screen reader or by using element.click(),
1728
+ // trigger as if it were a keyboard click.
1729
+ if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $8a9cb279dc87e130$export$60278871457622de(e.nativeEvent))) {
1730
+ // Ensure the element receives focus (VoiceOver on iOS does not do this)
1731
+ if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
1732
+ triggerPressStart(e, 'virtual');
1733
+ triggerPressUp(e, 'virtual');
1734
+ triggerPressEnd(e, 'virtual');
1735
+ }
1736
+ state.ignoreEmulatedMouseEvents = false;
1737
+ state.ignoreClickAfterPress = false;
1738
+ }
1739
+ }
1740
+ };
1741
+ let onKeyUp = (e)=>{
1742
+ if (state.isPressed && $f6c31cce2adf654f$var$isValidKeyboardEvent(e)) {
1743
+ if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
1744
+ e.stopPropagation();
1745
+ state.isPressed = false;
1746
+ let target = e.target;
1747
+ triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), 'keyboard', state.target.contains(target));
1748
+ removeAllGlobalListeners();
1749
+ // If the target is a link, trigger the click method to open the URL,
1750
+ // but defer triggering pressEnd until onClick event handler.
1751
+ if (state.target.contains(target) && $f6c31cce2adf654f$var$isHTMLAnchorLink(state.target) || state.target.getAttribute('role') === 'link') state.target.click();
1752
+ }
1753
+ };
1754
+ if (typeof PointerEvent !== 'undefined') {
1755
+ pressProps.onPointerDown = (e)=>{
1756
+ // Only handle left clicks, and ignore events that bubbled through portals.
1757
+ if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
1758
+ // iOS safari fires pointer events from VoiceOver with incorrect coordinates/target.
1759
+ // Ignore and let the onClick handler take care of it instead.
1760
+ // https://bugs.webkit.org/show_bug.cgi?id=222627
1761
+ // https://bugs.webkit.org/show_bug.cgi?id=223202
1762
+ if ($f6c31cce2adf654f$var$isVirtualPointerEvent(e.nativeEvent)) {
1763
+ state.pointerType = 'virtual';
1764
+ return;
1765
+ }
1766
+ // Due to browser inconsistencies, especially on mobile browsers, we prevent
1767
+ // default on pointer down and handle focusing the pressable element ourselves.
1768
+ if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
1769
+ state.pointerType = e.pointerType;
1770
+ e.stopPropagation();
1771
+ if (!state.isPressed) {
1772
+ state.isPressed = true;
1773
+ state.isOverTarget = true;
1774
+ state.activePointerId = e.pointerId;
1775
+ state.target = e.currentTarget;
1776
+ if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
1777
+ if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
1778
+ triggerPressStart(e, state.pointerType);
1779
+ addGlobalListener(document, 'pointermove', onPointerMove, false);
1780
+ addGlobalListener(document, 'pointerup', onPointerUp, false);
1781
+ addGlobalListener(document, 'pointercancel', onPointerCancel, false);
1782
+ }
1783
+ };
1784
+ pressProps.onMouseDown = (e)=>{
1785
+ if (!e.currentTarget.contains(e.target)) return;
1786
+ if (e.button === 0) {
1787
+ // Chrome and Firefox on touch Windows devices require mouse down events
1788
+ // to be canceled in addition to pointer events, or an extra asynchronous
1789
+ // focus event will be fired.
1790
+ if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
1791
+ e.stopPropagation();
1792
+ }
1793
+ };
1794
+ pressProps.onPointerUp = (e)=>{
1795
+ // iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.
1796
+ if (!e.currentTarget.contains(e.target) || state.pointerType === 'virtual') return;
1797
+ // Only handle left clicks
1798
+ // Safari on iOS sometimes fires pointerup events, even
1799
+ // when the touch isn't over the target, so double check.
1800
+ if (e.button === 0 && $f6c31cce2adf654f$var$isOverTarget(e, e.currentTarget)) triggerPressUp(e, state.pointerType || e.pointerType);
1801
+ };
1802
+ // Safari on iOS < 13.2 does not implement pointerenter/pointerleave events correctly.
1803
+ // Use pointer move events instead to implement our own hit testing.
1804
+ // See https://bugs.webkit.org/show_bug.cgi?id=199803
1805
+ let onPointerMove = (e)=>{
1806
+ if (e.pointerId !== state.activePointerId) return;
1807
+ if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) {
1808
+ if (!state.isOverTarget) {
1809
+ state.isOverTarget = true;
1810
+ triggerPressStart($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
1811
+ }
1812
+ } else if (state.isOverTarget) {
1813
+ state.isOverTarget = false;
1814
+ triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
1815
+ if (propsRef.current.shouldCancelOnPointerExit) cancel(e);
1816
+ }
1817
+ };
1818
+ let onPointerUp = (e)=>{
1819
+ if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0) {
1820
+ if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
1821
+ else if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
1822
+ state.isPressed = false;
1823
+ state.isOverTarget = false;
1824
+ state.activePointerId = null;
1825
+ state.pointerType = null;
1826
+ removeAllGlobalListeners();
1827
+ if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
1828
+ }
1829
+ };
1830
+ let onPointerCancel = (e)=>{
1831
+ cancel(e);
1832
+ };
1833
+ pressProps.onDragStart = (e)=>{
1834
+ if (!e.currentTarget.contains(e.target)) return;
1835
+ // Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.
1836
+ cancel(e);
1837
+ };
1838
+ } else {
1839
+ pressProps.onMouseDown = (e)=>{
1840
+ // Only handle left clicks
1841
+ if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
1842
+ // Due to browser inconsistencies, especially on mobile browsers, we prevent
1843
+ // default on mouse down and handle focusing the pressable element ourselves.
1844
+ if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
1845
+ e.stopPropagation();
1846
+ if (state.ignoreEmulatedMouseEvents) return;
1847
+ state.isPressed = true;
1848
+ state.isOverTarget = true;
1849
+ state.target = e.currentTarget;
1850
+ state.pointerType = $8a9cb279dc87e130$export$60278871457622de(e.nativeEvent) ? 'virtual' : 'mouse';
1851
+ if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
1852
+ triggerPressStart(e, state.pointerType);
1853
+ addGlobalListener(document, 'mouseup', onMouseUp, false);
1854
+ };
1855
+ pressProps.onMouseEnter = (e)=>{
1856
+ if (!e.currentTarget.contains(e.target)) return;
1857
+ e.stopPropagation();
1858
+ if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
1859
+ state.isOverTarget = true;
1860
+ triggerPressStart(e, state.pointerType);
1861
+ }
1862
+ };
1863
+ pressProps.onMouseLeave = (e)=>{
1864
+ if (!e.currentTarget.contains(e.target)) return;
1865
+ e.stopPropagation();
1866
+ if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
1867
+ state.isOverTarget = false;
1868
+ triggerPressEnd(e, state.pointerType, false);
1869
+ if (propsRef.current.shouldCancelOnPointerExit) cancel(e);
1870
+ }
1871
+ };
1872
+ pressProps.onMouseUp = (e)=>{
1873
+ if (!e.currentTarget.contains(e.target)) return;
1874
+ if (!state.ignoreEmulatedMouseEvents && e.button === 0) triggerPressUp(e, state.pointerType);
1875
+ };
1876
+ let onMouseUp = (e)=>{
1877
+ // Only handle left clicks
1878
+ if (e.button !== 0) return;
1879
+ state.isPressed = false;
1880
+ removeAllGlobalListeners();
1881
+ if (state.ignoreEmulatedMouseEvents) {
1882
+ state.ignoreEmulatedMouseEvents = false;
1883
+ return;
1884
+ }
1885
+ if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
1886
+ else if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
1887
+ state.isOverTarget = false;
1888
+ };
1889
+ pressProps.onTouchStart = (e)=>{
1890
+ if (!e.currentTarget.contains(e.target)) return;
1891
+ e.stopPropagation();
1892
+ let touch = $f6c31cce2adf654f$var$getTouchFromEvent(e.nativeEvent);
1893
+ if (!touch) return;
1894
+ state.activePointerId = touch.identifier;
1895
+ state.ignoreEmulatedMouseEvents = true;
1896
+ state.isOverTarget = true;
1897
+ state.isPressed = true;
1898
+ state.target = e.currentTarget;
1899
+ state.pointerType = 'touch';
1900
+ // Due to browser inconsistencies, especially on mobile browsers, we prevent default
1901
+ // on the emulated mouse event and handle focusing the pressable element ourselves.
1902
+ if (!isDisabled1 && !preventFocusOnPress) $7215afc6de606d6b$export$de79e2c695e052f3(e.currentTarget);
1903
+ if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
1904
+ triggerPressStart(e, state.pointerType);
1905
+ addGlobalListener(window, 'scroll', onScroll, true);
1906
+ };
1907
+ pressProps.onTouchMove = (e)=>{
1908
+ if (!e.currentTarget.contains(e.target)) return;
1909
+ e.stopPropagation();
1910
+ if (!state.isPressed) return;
1911
+ let touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
1912
+ if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget)) {
1913
+ if (!state.isOverTarget) {
1914
+ state.isOverTarget = true;
1915
+ triggerPressStart(e, state.pointerType);
1916
+ }
1917
+ } else if (state.isOverTarget) {
1918
+ state.isOverTarget = false;
1919
+ triggerPressEnd(e, state.pointerType, false);
1920
+ if (propsRef.current.shouldCancelOnPointerExit) cancel(e);
1921
+ }
1922
+ };
1923
+ pressProps.onTouchEnd = (e)=>{
1924
+ if (!e.currentTarget.contains(e.target)) return;
1925
+ e.stopPropagation();
1926
+ if (!state.isPressed) return;
1927
+ let touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
1928
+ if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget)) {
1929
+ triggerPressUp(e, state.pointerType);
1930
+ triggerPressEnd(e, state.pointerType);
1931
+ } else if (state.isOverTarget) triggerPressEnd(e, state.pointerType, false);
1932
+ state.isPressed = false;
1933
+ state.activePointerId = null;
1934
+ state.isOverTarget = false;
1935
+ state.ignoreEmulatedMouseEvents = true;
1936
+ if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
1937
+ removeAllGlobalListeners();
1938
+ };
1939
+ pressProps.onTouchCancel = (e)=>{
1940
+ if (!e.currentTarget.contains(e.target)) return;
1941
+ e.stopPropagation();
1942
+ if (state.isPressed) cancel(e);
1943
+ };
1944
+ let onScroll = (e)=>{
1945
+ if (state.isPressed && e.target.contains(state.target)) cancel({
1946
+ currentTarget: state.target,
1947
+ shiftKey: false,
1948
+ ctrlKey: false,
1949
+ metaKey: false,
1950
+ altKey: false
1951
+ });
1952
+ };
1953
+ pressProps.onDragStart = (e)=>{
1954
+ if (!e.currentTarget.contains(e.target)) return;
1955
+ cancel(e);
1956
+ };
1957
+ }
1958
+ return pressProps;
1959
+ }, [
1960
+ addGlobalListener,
1961
+ isDisabled1,
1962
+ preventFocusOnPress,
1963
+ removeAllGlobalListeners,
1964
+ allowTextSelectionOnPress
1965
+ ]);
1966
+ // Remove user-select: none in case component unmounts immediately after pressStart
1967
+ // eslint-disable-next-line arrow-body-style
1968
+ useEffect(()=>{
1969
+ return ()=>{
1970
+ if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(ref.current.target);
1971
+ };
1972
+ }, [
1973
+ allowTextSelectionOnPress
1974
+ ]);
1975
+ return {
1976
+ isPressed: isPressedProp || isPressed,
1977
+ pressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, pressProps1)
1978
+ };
1979
+ }
1980
+ function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
1981
+ return target.tagName === 'A' && target.hasAttribute('href');
1982
+ }
1983
+ function $f6c31cce2adf654f$var$isValidKeyboardEvent(event) {
1984
+ const { key: key , code: code , target: target } = event;
1985
+ const element = target;
1986
+ const { tagName: tagName , isContentEditable: isContentEditable } = element;
1987
+ const role = element.getAttribute('role');
1988
+ // Accessibility for keyboards. Space and Enter only.
1989
+ // "Spacebar" is for IE 11
1990
+ return (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') && tagName !== 'INPUT' && tagName !== 'TEXTAREA' && isContentEditable !== true && (!$f6c31cce2adf654f$var$isHTMLAnchorLink(element) || role === 'button' && key !== 'Enter') && // An element with role='link' should only trigger with Enter key
1991
+ !(role === 'link' && key !== 'Enter');
1992
+ }
1993
+ function $f6c31cce2adf654f$var$getTouchFromEvent(event) {
1994
+ const { targetTouches: targetTouches } = event;
1995
+ if (targetTouches.length > 0) return targetTouches[0];
1996
+ return null;
1997
+ }
1998
+ function $f6c31cce2adf654f$var$getTouchById(event, pointerId) {
1999
+ const changedTouches = event.changedTouches;
2000
+ for(let i = 0; i < changedTouches.length; i++){
2001
+ const touch = changedTouches[i];
2002
+ if (touch.identifier === pointerId) return touch;
2003
+ }
2004
+ return null;
2005
+ }
2006
+ function $f6c31cce2adf654f$var$createEvent(target, e) {
2007
+ return {
2008
+ currentTarget: target,
2009
+ shiftKey: e.shiftKey,
2010
+ ctrlKey: e.ctrlKey,
2011
+ metaKey: e.metaKey,
2012
+ altKey: e.altKey
2013
+ };
2014
+ }
2015
+ function $f6c31cce2adf654f$var$getPointClientRect(point) {
2016
+ let offsetX = point.width / 2 || point.radiusX || 0;
2017
+ let offsetY = point.height / 2 || point.radiusY || 0;
2018
+ return {
2019
+ top: point.clientY - offsetY,
2020
+ right: point.clientX + offsetX,
2021
+ bottom: point.clientY + offsetY,
2022
+ left: point.clientX - offsetX
2023
+ };
2024
+ }
2025
+ function $f6c31cce2adf654f$var$areRectanglesOverlapping(a, b) {
2026
+ // check if they cannot overlap on x axis
2027
+ if (a.left > b.right || b.left > a.right) return false;
2028
+ // check if they cannot overlap on y axis
2029
+ if (a.top > b.bottom || b.top > a.bottom) return false;
2030
+ return true;
2031
+ }
2032
+ function $f6c31cce2adf654f$var$isOverTarget(point, target) {
2033
+ let rect = target.getBoundingClientRect();
2034
+ let pointRect = $f6c31cce2adf654f$var$getPointClientRect(point);
2035
+ return $f6c31cce2adf654f$var$areRectanglesOverlapping(rect, pointRect);
2036
+ }
2037
+ function $f6c31cce2adf654f$var$shouldPreventDefault(target) {
2038
+ // We cannot prevent default if the target is a draggable element.
2039
+ return !target.draggable;
2040
+ }
2041
+ function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target) {
2042
+ return !((target.tagName === 'INPUT' || target.tagName === 'BUTTON') && target.type === 'submit');
2043
+ }
2044
+ function $f6c31cce2adf654f$var$isVirtualPointerEvent(event) {
2045
+ // If the pointer size is zero, then we assume it's from a screen reader.
2046
+ // Android TalkBack double tap will sometimes return a event with width and height of 1
2047
+ // and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
2048
+ // Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
2049
+ // instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216. event.pointerType === 'mouse' is to distingush
2050
+ // Talkback double tap from Windows Firefox touch screen press
2051
+ return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'mouse';
2052
+ }
2053
+
2054
+
2055
+
2056
+ const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ React.forwardRef(({ children: children , ...props }, ref)=>{
2057
+ let newRef = useRef();
2058
+ ref = ref !== null && ref !== void 0 ? ref : newRef;
2059
+ let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
2060
+ ...props,
2061
+ ref: ref
2062
+ });
2063
+ let child = React.Children.only(children);
2064
+ return(/*#__PURE__*/ React.cloneElement(child, // @ts-ignore
2065
+ {
2066
+ ref: ref,
2067
+ ...$3ef42575df84b30b$export$9d1611c77c2fe928(child.props, pressProps)
2068
+ }));
2069
+ });
2070
+
2071
+
2072
+ var $f1ab8c75478c6f73$exports = {};
2073
+
2074
+ $parcel$export$2($f1ab8c75478c6f73$exports, "PressResponder", () => $f1ab8c75478c6f73$export$3351871ee4b288b8);
2075
+
2076
+
2077
+
2078
+ const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ React.forwardRef(({ children: children , ...props }, ref)=>{
2079
+ let isRegistered = useRef(false);
2080
+ let prevContext = useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
2081
+ let context = $3ef42575df84b30b$export$9d1611c77c2fe928(prevContext || {
2082
+ }, {
2083
+ ...props,
2084
+ ref: ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref),
2085
+ register () {
2086
+ isRegistered.current = true;
2087
+ if (prevContext) prevContext.register();
2088
+ }
2089
+ });
2090
+ $e7801be82b4b2a53$export$4debdb1a3f0fa79e(prevContext, ref);
2091
+ useEffect(()=>{
2092
+ if (!isRegistered.current) console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component.");
2093
+ }, []);
2094
+ return(/*#__PURE__*/ React.createElement($ae1eeba8b9eafd08$export$5165eccb35aaadb5.Provider, {
2095
+ value: context
2096
+ }, children));
2097
+ });
2098
+
2099
+
2100
+ var $a1ea59d68270f0dd$exports = {};
2101
+
2102
+ $parcel$export$2($a1ea59d68270f0dd$exports, "useFocus", () => $a1ea59d68270f0dd$export$f8168d8dd8fd66e6);
2103
+
2104
+
2105
+ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
2106
+ let { isDisabled: isDisabled , onFocus: onFocusProp , onBlur: onBlurProp , onFocusChange: onFocusChange } = props;
2107
+ const onBlur = useCallback((e)=>{
2108
+ if (e.target === e.currentTarget) {
2109
+ if (onBlurProp) onBlurProp(e);
2110
+ if (onFocusChange) onFocusChange(false);
2111
+ return true;
2112
+ }
2113
+ }, [
2114
+ onBlurProp,
2115
+ onFocusChange
2116
+ ]);
2117
+ const onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
2118
+ const onFocus = useCallback((e)=>{
2119
+ if (e.target === e.currentTarget) {
2120
+ if (onFocusProp) onFocusProp(e);
2121
+ if (onFocusChange) onFocusChange(true);
2122
+ onSyntheticFocus(e);
2123
+ }
2124
+ }, [
2125
+ onFocusChange,
2126
+ onFocusProp,
2127
+ onSyntheticFocus
2128
+ ]);
2129
+ return {
2130
+ focusProps: {
2131
+ onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
2132
+ onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : null
2133
+ }
2134
+ };
2135
+ }
2136
+
2137
+
2138
+ var $507fabe10e71c6fb$exports = {};
2139
+
2140
+ $parcel$export$2($507fabe10e71c6fb$exports, "isFocusVisible", () => $507fabe10e71c6fb$export$b9b3dfddab17db27);
2141
+ $parcel$export$2($507fabe10e71c6fb$exports, "getInteractionModality", () => $507fabe10e71c6fb$export$630ff653c5ada6a9);
2142
+ $parcel$export$2($507fabe10e71c6fb$exports, "setInteractionModality", () => $507fabe10e71c6fb$export$8397ddfc504fdb9a);
2143
+ $parcel$export$2($507fabe10e71c6fb$exports, "useInteractionModality", () => $507fabe10e71c6fb$export$98e20ec92f614cfe);
2144
+ $parcel$export$2($507fabe10e71c6fb$exports, "useFocusVisible", () => $507fabe10e71c6fb$export$ffd9e5021c1fb2d6);
2145
+ $parcel$export$2($507fabe10e71c6fb$exports, "useFocusVisibleListener", () => $507fabe10e71c6fb$export$ec71b4b83ac08ec3);
2146
+
2147
+
2148
+
2149
+ let $507fabe10e71c6fb$var$currentModality = null;
2150
+ let $507fabe10e71c6fb$var$changeHandlers = new Set();
2151
+ let $507fabe10e71c6fb$var$hasSetupGlobalListeners = false;
2152
+ let $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
2153
+ let $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
2154
+ // Only Tab or Esc keys will make focus visible on text input elements
2155
+ const $507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS = {
2156
+ Tab: true,
2157
+ Escape: true
2158
+ };
2159
+ function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
2160
+ for (let handler of $507fabe10e71c6fb$var$changeHandlers)handler(modality, e);
2161
+ }
2162
+ /**
2163
+ * Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
2164
+ */ function $507fabe10e71c6fb$var$isValidKey(e) {
2165
+ // Control and Shift keys trigger when navigating back to the tab with keyboard.
2166
+ return !(e.metaKey || !$c87311424ea30a05$export$9ac100e40613ea10() && e.altKey || e.ctrlKey || e.key === 'Control' || e.key === 'Shift' || e.key === 'Meta');
2167
+ }
2168
+ function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
2169
+ $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2170
+ if ($507fabe10e71c6fb$var$isValidKey(e)) {
2171
+ $507fabe10e71c6fb$var$currentModality = 'keyboard';
2172
+ $507fabe10e71c6fb$var$triggerChangeHandlers('keyboard', e);
2173
+ }
2174
+ }
2175
+ function $507fabe10e71c6fb$var$handlePointerEvent(e) {
2176
+ $507fabe10e71c6fb$var$currentModality = 'pointer';
2177
+ if (e.type === 'mousedown' || e.type === 'pointerdown') {
2178
+ $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2179
+ $507fabe10e71c6fb$var$triggerChangeHandlers('pointer', e);
2180
+ }
2181
+ }
2182
+ function $507fabe10e71c6fb$var$handleClickEvent(e) {
2183
+ if ($8a9cb279dc87e130$export$60278871457622de(e)) {
2184
+ $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2185
+ $507fabe10e71c6fb$var$currentModality = 'virtual';
2186
+ }
2187
+ }
2188
+ function $507fabe10e71c6fb$var$handleFocusEvent(e) {
2189
+ // Firefox fires two extra focus events when the user first clicks into an iframe:
2190
+ // first on the window, then on the document. We ignore these events so they don't
2191
+ // cause keyboard focus rings to appear.
2192
+ if (e.target === window || e.target === document) return;
2193
+ // If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
2194
+ // This occurs, for example, when navigating a form with the next/previous buttons on iOS.
2195
+ if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
2196
+ $507fabe10e71c6fb$var$currentModality = 'virtual';
2197
+ $507fabe10e71c6fb$var$triggerChangeHandlers('virtual', e);
2198
+ }
2199
+ $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
2200
+ $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
2201
+ }
2202
+ function $507fabe10e71c6fb$var$handleWindowBlur() {
2203
+ // When the window is blurred, reset state. This is necessary when tabbing out of the window,
2204
+ // for example, since a subsequent focus event won't be fired.
2205
+ $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
2206
+ $507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
2207
+ }
2208
+ /**
2209
+ * Setup global event listeners to control when keyboard focus style should be visible.
2210
+ */ function $507fabe10e71c6fb$var$setupGlobalFocusEvents() {
2211
+ if (typeof window === 'undefined' || $507fabe10e71c6fb$var$hasSetupGlobalListeners) return;
2212
+ // Programmatic focus() calls shouldn't affect the current input modality.
2213
+ // However, we need to detect other cases when a focus event occurs without
2214
+ // a preceding user event (e.g. screen reader focus). Overriding the focus
2215
+ // method on HTMLElement.prototype is a bit hacky, but works.
2216
+ let focus = HTMLElement.prototype.focus;
2217
+ HTMLElement.prototype.focus = function() {
2218
+ $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
2219
+ focus.apply(this, arguments);
2220
+ };
2221
+ document.addEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
2222
+ document.addEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
2223
+ document.addEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
2224
+ // Register focus events on the window so they are sure to happen
2225
+ // before React's event listeners (registered on the document).
2226
+ window.addEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
2227
+ window.addEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
2228
+ if (typeof PointerEvent !== 'undefined') {
2229
+ document.addEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
2230
+ document.addEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
2231
+ document.addEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
2232
+ } else {
2233
+ document.addEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
2234
+ document.addEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
2235
+ document.addEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
2236
+ }
2237
+ $507fabe10e71c6fb$var$hasSetupGlobalListeners = true;
2238
+ }
2239
+ if (typeof document !== 'undefined') {
2240
+ if (document.readyState !== 'loading') $507fabe10e71c6fb$var$setupGlobalFocusEvents();
2241
+ else document.addEventListener('DOMContentLoaded', $507fabe10e71c6fb$var$setupGlobalFocusEvents);
2242
+ }
2243
+ function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
2244
+ return $507fabe10e71c6fb$var$currentModality !== 'pointer';
2245
+ }
2246
+ function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
2247
+ return $507fabe10e71c6fb$var$currentModality;
2248
+ }
2249
+ function $507fabe10e71c6fb$export$8397ddfc504fdb9a(modality) {
2250
+ $507fabe10e71c6fb$var$currentModality = modality;
2251
+ $507fabe10e71c6fb$var$triggerChangeHandlers(modality, null);
2252
+ }
2253
+ function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
2254
+ $507fabe10e71c6fb$var$setupGlobalFocusEvents();
2255
+ let [modality, setModality] = useState($507fabe10e71c6fb$var$currentModality);
2256
+ useEffect(()=>{
2257
+ let handler = ()=>{
2258
+ setModality($507fabe10e71c6fb$var$currentModality);
2259
+ };
2260
+ $507fabe10e71c6fb$var$changeHandlers.add(handler);
2261
+ return ()=>{
2262
+ $507fabe10e71c6fb$var$changeHandlers.delete(handler);
2263
+ };
2264
+ }, []);
2265
+ return modality;
2266
+ }
2267
+ /**
2268
+ * If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
2269
+ * focus visible style can be properly set.
2270
+ */ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
2271
+ return !(isTextInput && modality === 'keyboard' && e instanceof KeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
2272
+ }
2273
+ function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {
2274
+ }) {
2275
+ let { isTextInput: isTextInput , autoFocus: autoFocus } = props;
2276
+ let [isFocusVisibleState, setFocusVisible] = useState(autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27());
2277
+ $507fabe10e71c6fb$export$ec71b4b83ac08ec3(($507fabe10e71c6fb$export$b9b3dfddab17db27)=>{
2278
+ setFocusVisible($507fabe10e71c6fb$export$b9b3dfddab17db27);
2279
+ }, [
2280
+ isTextInput
2281
+ ], {
2282
+ isTextInput: isTextInput
2283
+ });
2284
+ return {
2285
+ isFocusVisible: isFocusVisibleState
2286
+ };
2287
+ }
2288
+ function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
2289
+ $507fabe10e71c6fb$var$setupGlobalFocusEvents();
2290
+ useEffect(()=>{
2291
+ let handler = (modality, e)=>{
2292
+ if (!$507fabe10e71c6fb$var$isKeyboardFocusEvent(opts === null || opts === void 0 ? void 0 : opts.isTextInput, modality, e)) return;
2293
+ fn($507fabe10e71c6fb$export$b9b3dfddab17db27());
2294
+ };
2295
+ $507fabe10e71c6fb$var$changeHandlers.add(handler);
2296
+ return ()=>{
2297
+ $507fabe10e71c6fb$var$changeHandlers.delete(handler);
2298
+ };
2299
+ }, deps);
2300
+ }
2301
+
2302
+
2303
+ var $9ab94262bd0047c7$exports = {};
2304
+
2305
+ $parcel$export$2($9ab94262bd0047c7$exports, "useFocusWithin", () => $9ab94262bd0047c7$export$420e68273165f4ec);
2306
+
2307
+
2308
+ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
2309
+ let { isDisabled: isDisabled , onBlurWithin: onBlurWithin , onFocusWithin: onFocusWithin , onFocusWithinChange: onFocusWithinChange } = props;
2310
+ let state = useRef({
2311
+ isFocusWithin: false
2312
+ });
2313
+ let onBlur = useCallback((e)=>{
2314
+ // We don't want to trigger onBlurWithin and then immediately onFocusWithin again
2315
+ // when moving focus inside the element. Only trigger if the currentTarget doesn't
2316
+ // include the relatedTarget (where focus is moving).
2317
+ if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
2318
+ state.current.isFocusWithin = false;
2319
+ if (onBlurWithin) onBlurWithin(e);
2320
+ if (onFocusWithinChange) onFocusWithinChange(false);
2321
+ }
2322
+ }, [
2323
+ onBlurWithin,
2324
+ onFocusWithinChange,
2325
+ state
2326
+ ]);
2327
+ let onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
2328
+ let onFocus = useCallback((e)=>{
2329
+ if (!state.current.isFocusWithin) {
2330
+ if (onFocusWithin) onFocusWithin(e);
2331
+ if (onFocusWithinChange) onFocusWithinChange(true);
2332
+ state.current.isFocusWithin = true;
2333
+ onSyntheticFocus(e);
2334
+ }
2335
+ }, [
2336
+ onFocusWithin,
2337
+ onFocusWithinChange,
2338
+ onSyntheticFocus
2339
+ ]);
2340
+ if (isDisabled) return {
2341
+ focusWithinProps: {
2342
+ onFocus: null,
2343
+ onBlur: null
2344
+ }
2345
+ };
2346
+ return {
2347
+ focusWithinProps: {
2348
+ onFocus: onFocus,
2349
+ onBlur: onBlur
2350
+ }
2351
+ };
2352
+ }
2353
+
2354
+
2355
+ var $6179b936705e76d3$exports = {};
2356
+
2357
+ $parcel$export$2($6179b936705e76d3$exports, "useHover", () => $6179b936705e76d3$export$ae780daf29e6d456);
2358
+
2359
+ // iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
2360
+ // We want to ignore these emulated events so they do not trigger hover behavior.
2361
+ // See https://bugs.webkit.org/show_bug.cgi?id=214609.
2362
+ let $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
2363
+ let $6179b936705e76d3$var$hoverCount = 0;
2364
+ function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
2365
+ $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = true;
2366
+ // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter
2367
+ // with pointerType="mouse" immediately after onPointerUp and before onFocus. On other
2368
+ // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in
2369
+ // the distant future because a user previously touched the element.
2370
+ setTimeout(()=>{
2371
+ $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
2372
+ }, 50);
2373
+ }
2374
+ function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
2375
+ if (e.pointerType === 'touch') $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
2376
+ }
2377
+ function $6179b936705e76d3$var$setupGlobalTouchEvents() {
2378
+ if (typeof document === 'undefined') return;
2379
+ if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
2380
+ else document.addEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
2381
+ $6179b936705e76d3$var$hoverCount++;
2382
+ return ()=>{
2383
+ $6179b936705e76d3$var$hoverCount--;
2384
+ if ($6179b936705e76d3$var$hoverCount > 0) return;
2385
+ if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
2386
+ else document.removeEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
2387
+ };
2388
+ }
2389
+ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
2390
+ let { onHoverStart: onHoverStart , onHoverChange: onHoverChange , onHoverEnd: onHoverEnd , isDisabled: isDisabled } = props;
2391
+ let [isHovered, setHovered] = useState(false);
2392
+ let state = useRef({
2393
+ isHovered: false,
2394
+ ignoreEmulatedMouseEvents: false,
2395
+ pointerType: '',
2396
+ target: null
2397
+ }).current;
2398
+ useEffect($6179b936705e76d3$var$setupGlobalTouchEvents, []);
2399
+ let { hoverProps: hoverProps1 , triggerHoverEnd: triggerHoverEnd1 } = useMemo(()=>{
2400
+ let triggerHoverStart = (event, pointerType)=>{
2401
+ state.pointerType = pointerType;
2402
+ if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
2403
+ state.isHovered = true;
2404
+ let target = event.currentTarget;
2405
+ state.target = target;
2406
+ if (onHoverStart) onHoverStart({
2407
+ type: 'hoverstart',
2408
+ target: target,
2409
+ pointerType: pointerType
2410
+ });
2411
+ if (onHoverChange) onHoverChange(true);
2412
+ setHovered(true);
2413
+ };
2414
+ let triggerHoverEnd = (event, pointerType)=>{
2415
+ state.pointerType = '';
2416
+ state.target = null;
2417
+ if (pointerType === 'touch' || !state.isHovered) return;
2418
+ state.isHovered = false;
2419
+ let target = event.currentTarget;
2420
+ if (onHoverEnd) onHoverEnd({
2421
+ type: 'hoverend',
2422
+ target: target,
2423
+ pointerType: pointerType
2424
+ });
2425
+ if (onHoverChange) onHoverChange(false);
2426
+ setHovered(false);
2427
+ };
2428
+ let hoverProps = {
2429
+ };
2430
+ if (typeof PointerEvent !== 'undefined') {
2431
+ hoverProps.onPointerEnter = (e)=>{
2432
+ if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') return;
2433
+ triggerHoverStart(e, e.pointerType);
2434
+ };
2435
+ hoverProps.onPointerLeave = (e)=>{
2436
+ if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, e.pointerType);
2437
+ };
2438
+ } else {
2439
+ hoverProps.onTouchStart = ()=>{
2440
+ state.ignoreEmulatedMouseEvents = true;
2441
+ };
2442
+ hoverProps.onMouseEnter = (e)=>{
2443
+ if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, 'mouse');
2444
+ state.ignoreEmulatedMouseEvents = false;
2445
+ };
2446
+ hoverProps.onMouseLeave = (e)=>{
2447
+ if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, 'mouse');
2448
+ };
2449
+ }
2450
+ return {
2451
+ hoverProps: hoverProps,
2452
+ triggerHoverEnd: triggerHoverEnd
2453
+ };
2454
+ }, [
2455
+ onHoverStart,
2456
+ onHoverChange,
2457
+ onHoverEnd,
2458
+ isDisabled,
2459
+ state
2460
+ ]);
2461
+ useEffect(()=>{
2462
+ // Call the triggerHoverEnd as soon as isDisabled changes to true
2463
+ // Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
2464
+ if (isDisabled) triggerHoverEnd1({
2465
+ currentTarget: state.target
2466
+ }, state.pointerType);
2467
+ }, [
2468
+ isDisabled
2469
+ ]);
2470
+ return {
2471
+ hoverProps: hoverProps1,
2472
+ isHovered: isHovered
2473
+ };
2474
+ }
2475
+
2476
+
2477
+ var $e0b6e0b68ec7f50f$exports = {};
2478
+
2479
+ $parcel$export$2($e0b6e0b68ec7f50f$exports, "useInteractOutside", () => $e0b6e0b68ec7f50f$export$872b660ac5a1ff98);
2480
+
2481
+ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
2482
+ let { ref: ref , onInteractOutside: onInteractOutside , isDisabled: isDisabled , onInteractOutsideStart: onInteractOutsideStart } = props;
2483
+ let stateRef = useRef({
2484
+ isPointerDown: false,
2485
+ ignoreEmulatedMouseEvents: false,
2486
+ onInteractOutside: onInteractOutside,
2487
+ onInteractOutsideStart: onInteractOutsideStart
2488
+ });
2489
+ let state = stateRef.current;
2490
+ state.onInteractOutside = onInteractOutside;
2491
+ state.onInteractOutsideStart = onInteractOutsideStart;
2492
+ useEffect(()=>{
2493
+ if (isDisabled) return;
2494
+ let onPointerDown = (e)=>{
2495
+ if ($e0b6e0b68ec7f50f$var$isValidEvent(e, ref) && state.onInteractOutside) {
2496
+ if (state.onInteractOutsideStart) state.onInteractOutsideStart(e);
2497
+ state.isPointerDown = true;
2498
+ }
2499
+ };
2500
+ // Use pointer events if available. Otherwise, fall back to mouse and touch events.
2501
+ if (typeof PointerEvent !== 'undefined') {
2502
+ let onPointerUp = (e)=>{
2503
+ if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
2504
+ state.isPointerDown = false;
2505
+ state.onInteractOutside(e);
2506
+ }
2507
+ };
2508
+ // changing these to capture phase fixed combobox
2509
+ document.addEventListener('pointerdown', onPointerDown, true);
2510
+ document.addEventListener('pointerup', onPointerUp, true);
2511
+ return ()=>{
2512
+ document.removeEventListener('pointerdown', onPointerDown, true);
2513
+ document.removeEventListener('pointerup', onPointerUp, true);
2514
+ };
2515
+ } else {
2516
+ let onMouseUp = (e)=>{
2517
+ if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
2518
+ else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
2519
+ state.isPointerDown = false;
2520
+ state.onInteractOutside(e);
2521
+ }
2522
+ };
2523
+ let onTouchEnd = (e)=>{
2524
+ state.ignoreEmulatedMouseEvents = true;
2525
+ if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
2526
+ state.isPointerDown = false;
2527
+ state.onInteractOutside(e);
2528
+ }
2529
+ };
2530
+ document.addEventListener('mousedown', onPointerDown, true);
2531
+ document.addEventListener('mouseup', onMouseUp, true);
2532
+ document.addEventListener('touchstart', onPointerDown, true);
2533
+ document.addEventListener('touchend', onTouchEnd, true);
2534
+ return ()=>{
2535
+ document.removeEventListener('mousedown', onPointerDown, true);
2536
+ document.removeEventListener('mouseup', onMouseUp, true);
2537
+ document.removeEventListener('touchstart', onPointerDown, true);
2538
+ document.removeEventListener('touchend', onTouchEnd, true);
2539
+ };
2540
+ }
2541
+ }, [
2542
+ ref,
2543
+ state,
2544
+ isDisabled
2545
+ ]);
2546
+ }
2547
+ function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
2548
+ if (event.button > 0) return false;
2549
+ // if the event target is no longer in the document
2550
+ if (event.target) {
2551
+ const ownerDocument = event.target.ownerDocument;
2552
+ if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
2553
+ }
2554
+ return ref.current && !ref.current.contains(event.target);
2555
+ }
2556
+
2557
+
2558
+ var $46d819fcbaf35654$exports = {};
2559
+
2560
+ $parcel$export$2($46d819fcbaf35654$exports, "useKeyboard", () => $46d819fcbaf35654$export$8f71654801c2f7cd);
2561
+ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
2562
+ if (!handler) return;
2563
+ let shouldStopPropagation = true;
2564
+ return (e)=>{
2565
+ let event = {
2566
+ ...e,
2567
+ preventDefault () {
2568
+ e.preventDefault();
2569
+ },
2570
+ isDefaultPrevented () {
2571
+ return e.isDefaultPrevented();
2572
+ },
2573
+ stopPropagation () {
2574
+ console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
2575
+ },
2576
+ continuePropagation () {
2577
+ shouldStopPropagation = false;
2578
+ }
2579
+ };
2580
+ handler(event);
2581
+ if (shouldStopPropagation) e.stopPropagation();
2582
+ };
2583
+ }
2584
+
2585
+
2586
+ function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
2587
+ return {
2588
+ keyboardProps: props.isDisabled ? {
2589
+ } : {
2590
+ onKeyDown: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyDown),
2591
+ onKeyUp: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyUp)
2592
+ }
2593
+ };
2594
+ }
2595
+
2596
+
2597
+ var $e8a7022cf87cba2a$exports = {};
2598
+
2599
+ $parcel$export$2($e8a7022cf87cba2a$exports, "useMove", () => $e8a7022cf87cba2a$export$36da96379f79f245);
2600
+
2601
+
2602
+
2603
+ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
2604
+ let { onMoveStart: onMoveStart , onMove: onMove , onMoveEnd: onMoveEnd } = props;
2605
+ let state = useRef({
2606
+ didMove: false,
2607
+ lastPosition: null,
2608
+ id: null
2609
+ });
2610
+ let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
2611
+ let moveProps1 = useMemo(()=>{
2612
+ let moveProps = {
2613
+ };
2614
+ let start = ()=>{
2615
+ $14c0b72509d70225$export$16a4697467175487();
2616
+ state.current.didMove = false;
2617
+ };
2618
+ let move = (originalEvent, pointerType, deltaX, deltaY)=>{
2619
+ if (deltaX === 0 && deltaY === 0) return;
2620
+ if (!state.current.didMove) {
2621
+ state.current.didMove = true;
2622
+ onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
2623
+ type: 'movestart',
2624
+ pointerType: pointerType,
2625
+ shiftKey: originalEvent.shiftKey,
2626
+ metaKey: originalEvent.metaKey,
2627
+ ctrlKey: originalEvent.ctrlKey,
2628
+ altKey: originalEvent.altKey
2629
+ });
2630
+ }
2631
+ onMove({
2632
+ type: 'move',
2633
+ pointerType: pointerType,
2634
+ deltaX: deltaX,
2635
+ deltaY: deltaY,
2636
+ shiftKey: originalEvent.shiftKey,
2637
+ metaKey: originalEvent.metaKey,
2638
+ ctrlKey: originalEvent.ctrlKey,
2639
+ altKey: originalEvent.altKey
2640
+ });
2641
+ };
2642
+ let end = (originalEvent, pointerType)=>{
2643
+ $14c0b72509d70225$export$b0d6fa1ab32e3295();
2644
+ if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
2645
+ type: 'moveend',
2646
+ pointerType: pointerType,
2647
+ shiftKey: originalEvent.shiftKey,
2648
+ metaKey: originalEvent.metaKey,
2649
+ ctrlKey: originalEvent.ctrlKey,
2650
+ altKey: originalEvent.altKey
2651
+ });
2652
+ };
2653
+ if (typeof PointerEvent === 'undefined') {
2654
+ let onMouseMove = (e)=>{
2655
+ if (e.button === 0) {
2656
+ move(e, 'mouse', e.pageX - state.current.lastPosition.pageX, e.pageY - state.current.lastPosition.pageY);
2657
+ state.current.lastPosition = {
2658
+ pageX: e.pageX,
2659
+ pageY: e.pageY
2660
+ };
2661
+ }
2662
+ };
2663
+ let onMouseUp = (e)=>{
2664
+ if (e.button === 0) {
2665
+ end(e, 'mouse');
2666
+ removeGlobalListener(window, 'mousemove', onMouseMove, false);
2667
+ removeGlobalListener(window, 'mouseup', onMouseUp, false);
2668
+ }
2669
+ };
2670
+ moveProps.onMouseDown = (e)=>{
2671
+ if (e.button === 0) {
2672
+ start();
2673
+ e.stopPropagation();
2674
+ e.preventDefault();
2675
+ state.current.lastPosition = {
2676
+ pageX: e.pageX,
2677
+ pageY: e.pageY
2678
+ };
2679
+ addGlobalListener(window, 'mousemove', onMouseMove, false);
2680
+ addGlobalListener(window, 'mouseup', onMouseUp, false);
2681
+ }
2682
+ };
2683
+ let onTouchMove = (e)=>{
2684
+ let touch = [
2685
+ ...e.changedTouches
2686
+ ].findIndex(({ identifier: identifier })=>identifier === state.current.id
2687
+ );
2688
+ if (touch >= 0) {
2689
+ let { pageX: pageX , pageY: pageY } = e.changedTouches[touch];
2690
+ move(e, 'touch', pageX - state.current.lastPosition.pageX, pageY - state.current.lastPosition.pageY);
2691
+ state.current.lastPosition = {
2692
+ pageX: pageX,
2693
+ pageY: pageY
2694
+ };
2695
+ }
2696
+ };
2697
+ let onTouchEnd = (e)=>{
2698
+ let touch = [
2699
+ ...e.changedTouches
2700
+ ].findIndex(({ identifier: identifier })=>identifier === state.current.id
2701
+ );
2702
+ if (touch >= 0) {
2703
+ end(e, 'touch');
2704
+ state.current.id = null;
2705
+ removeGlobalListener(window, 'touchmove', onTouchMove);
2706
+ removeGlobalListener(window, 'touchend', onTouchEnd);
2707
+ removeGlobalListener(window, 'touchcancel', onTouchEnd);
2708
+ }
2709
+ };
2710
+ moveProps.onTouchStart = (e)=>{
2711
+ if (e.changedTouches.length === 0 || state.current.id != null) return;
2712
+ let { pageX: pageX , pageY: pageY , identifier: identifier } = e.changedTouches[0];
2713
+ start();
2714
+ e.stopPropagation();
2715
+ e.preventDefault();
2716
+ state.current.lastPosition = {
2717
+ pageX: pageX,
2718
+ pageY: pageY
2719
+ };
2720
+ state.current.id = identifier;
2721
+ addGlobalListener(window, 'touchmove', onTouchMove, false);
2722
+ addGlobalListener(window, 'touchend', onTouchEnd, false);
2723
+ addGlobalListener(window, 'touchcancel', onTouchEnd, false);
2724
+ };
2725
+ } else {
2726
+ let onPointerMove = (e)=>{
2727
+ if (e.pointerId === state.current.id) {
2728
+ let pointerType = e.pointerType || 'mouse';
2729
+ // Problems with PointerEvent#movementX/movementY:
2730
+ // 1. it is always 0 on macOS Safari.
2731
+ // 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
2732
+ move(e, pointerType, e.pageX - state.current.lastPosition.pageX, e.pageY - state.current.lastPosition.pageY);
2733
+ state.current.lastPosition = {
2734
+ pageX: e.pageX,
2735
+ pageY: e.pageY
2736
+ };
2737
+ }
2738
+ };
2739
+ let onPointerUp = (e)=>{
2740
+ if (e.pointerId === state.current.id) {
2741
+ let pointerType = e.pointerType || 'mouse';
2742
+ end(e, pointerType);
2743
+ state.current.id = null;
2744
+ removeGlobalListener(window, 'pointermove', onPointerMove, false);
2745
+ removeGlobalListener(window, 'pointerup', onPointerUp, false);
2746
+ removeGlobalListener(window, 'pointercancel', onPointerUp, false);
2747
+ }
2748
+ };
2749
+ moveProps.onPointerDown = (e)=>{
2750
+ if (e.button === 0 && state.current.id == null) {
2751
+ start();
2752
+ e.stopPropagation();
2753
+ e.preventDefault();
2754
+ state.current.lastPosition = {
2755
+ pageX: e.pageX,
2756
+ pageY: e.pageY
2757
+ };
2758
+ state.current.id = e.pointerId;
2759
+ addGlobalListener(window, 'pointermove', onPointerMove, false);
2760
+ addGlobalListener(window, 'pointerup', onPointerUp, false);
2761
+ addGlobalListener(window, 'pointercancel', onPointerUp, false);
2762
+ }
2763
+ };
2764
+ }
2765
+ let triggerKeyboardMove = (e, deltaX, deltaY)=>{
2766
+ start();
2767
+ move(e, 'keyboard', deltaX, deltaY);
2768
+ end(e, 'keyboard');
2769
+ };
2770
+ moveProps.onKeyDown = (e)=>{
2771
+ switch(e.key){
2772
+ case 'Left':
2773
+ case 'ArrowLeft':
2774
+ e.preventDefault();
2775
+ e.stopPropagation();
2776
+ triggerKeyboardMove(e, -1, 0);
2777
+ break;
2778
+ case 'Right':
2779
+ case 'ArrowRight':
2780
+ e.preventDefault();
2781
+ e.stopPropagation();
2782
+ triggerKeyboardMove(e, 1, 0);
2783
+ break;
2784
+ case 'Up':
2785
+ case 'ArrowUp':
2786
+ e.preventDefault();
2787
+ e.stopPropagation();
2788
+ triggerKeyboardMove(e, 0, -1);
2789
+ break;
2790
+ case 'Down':
2791
+ case 'ArrowDown':
2792
+ e.preventDefault();
2793
+ e.stopPropagation();
2794
+ triggerKeyboardMove(e, 0, 1);
2795
+ break;
2796
+ }
2797
+ };
2798
+ return moveProps;
2799
+ }, [
2800
+ state,
2801
+ onMoveStart,
2802
+ onMove,
2803
+ onMoveEnd,
2804
+ addGlobalListener,
2805
+ removeGlobalListener
2806
+ ]);
2807
+ return {
2808
+ moveProps: moveProps1
2809
+ };
2810
+ }
2811
+
2812
+
2813
+
2814
+ var $7d0a636d7a4dcefd$exports = {};
2815
+
2816
+ $parcel$export$2($7d0a636d7a4dcefd$exports, "useScrollWheel", () => $7d0a636d7a4dcefd$export$2123ff2b87c81ca);
2817
+
2818
+
2819
+ function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
2820
+ let { onScroll: onScroll , isDisabled: isDisabled } = props;
2821
+ let onScrollHandler = useCallback((e)=>{
2822
+ // If the ctrlKey is pressed, this is a zoom event, do nothing.
2823
+ if (e.ctrlKey) return;
2824
+ // stop scrolling the page
2825
+ e.preventDefault();
2826
+ e.stopPropagation();
2827
+ if (onScroll) onScroll({
2828
+ deltaX: e.deltaX,
2829
+ deltaY: e.deltaY
2830
+ });
2831
+ }, [
2832
+ onScroll
2833
+ ]);
2834
+ $e9faafb641e167db$export$90fc3a17d93f704c(ref, 'wheel', isDisabled ? null : onScrollHandler);
2835
+ }
2836
+
2837
+
2838
+ var $8a26561d2877236e$exports = {};
2839
+
2840
+ $parcel$export$2($8a26561d2877236e$exports, "useLongPress", () => $8a26561d2877236e$export$c24ed0104d07eab9);
2841
+
2842
+
2843
+
2844
+ const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
2845
+ function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
2846
+ let { isDisabled: isDisabled , onLongPressStart: onLongPressStart , onLongPressEnd: onLongPressEnd , onLongPress: onLongPress , threshold: threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD , accessibilityDescription: accessibilityDescription } = props;
2847
+ const timeRef = useRef(null);
2848
+ let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
2849
+ let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
2850
+ isDisabled: isDisabled,
2851
+ onPressStart (e1) {
2852
+ if (e1.pointerType === 'mouse' || e1.pointerType === 'touch') {
2853
+ if (onLongPressStart) onLongPressStart({
2854
+ ...e1,
2855
+ type: 'longpressstart'
2856
+ });
2857
+ timeRef.current = setTimeout(()=>{
2858
+ // Prevent other usePress handlers from also handling this event.
2859
+ e1.target.dispatchEvent(new PointerEvent('pointercancel', {
2860
+ bubbles: true
2861
+ }));
2862
+ if (onLongPress) onLongPress({
2863
+ ...e1,
2864
+ type: 'longpress'
2865
+ });
2866
+ timeRef.current = null;
2867
+ }, threshold);
2868
+ // Prevent context menu, which may be opened on long press on touch devices
2869
+ if (e1.pointerType === 'touch') {
2870
+ let onContextMenu = (e)=>{
2871
+ e.preventDefault();
2872
+ };
2873
+ addGlobalListener(e1.target, 'contextmenu', onContextMenu, {
2874
+ once: true
2875
+ });
2876
+ addGlobalListener(window, 'pointerup', ()=>{
2877
+ // If no contextmenu event is fired quickly after pointerup, remove the handler
2878
+ // so future context menu events outside a long press are not prevented.
2879
+ setTimeout(()=>{
2880
+ removeGlobalListener(e1.target, 'contextmenu', onContextMenu);
2881
+ }, 30);
2882
+ }, {
2883
+ once: true
2884
+ });
2885
+ }
2886
+ }
2887
+ },
2888
+ onPressEnd (e) {
2889
+ if (timeRef.current) clearTimeout(timeRef.current);
2890
+ if (onLongPressEnd && (e.pointerType === 'mouse' || e.pointerType === 'touch')) onLongPressEnd({
2891
+ ...e,
2892
+ type: 'longpressend'
2893
+ });
2894
+ }
2895
+ });
2896
+ let descriptionProps = $ef06256079686ba0$export$f8aeda7b10753fa1(onLongPress && !isDisabled ? accessibilityDescription : null);
2897
+ return {
2898
+ longPressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, descriptionProps)
2899
+ };
2900
+ }
2901
+
2902
+ function $parcel$export$1(e, n, v, s) {
2903
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
2904
+ }
2905
+ var $9bf71ea28793e738$exports = {};
2906
+
2907
+ $parcel$export$1($9bf71ea28793e738$exports, "FocusScope", () => $9bf71ea28793e738$export$20e40289641fbbb6);
2908
+ $parcel$export$1($9bf71ea28793e738$exports, "useFocusManager", () => $9bf71ea28793e738$export$10c5169755ce7bd7);
2909
+ $parcel$export$1($9bf71ea28793e738$exports, "getFocusableTreeWalker", () => $9bf71ea28793e738$export$2d6ec8fc375ceafa);
2910
+ $parcel$export$1($9bf71ea28793e738$exports, "createFocusManager", () => $9bf71ea28793e738$export$c5251b9e124bf29);
2911
+ var $6a99195332edec8b$exports = {};
2912
+
2913
+ $parcel$export$1($6a99195332edec8b$exports, "focusSafely", () => $6a99195332edec8b$export$80f3e147d781571c);
2914
+
2915
+
2916
+ function $6a99195332edec8b$export$80f3e147d781571c(element) {
2917
+ // If the user is interacting with a virtual cursor, e.g. screen reader, then
2918
+ // wait until after any animated transitions that are currently occurring on
2919
+ // the page before shifting focus. This avoids issues with VoiceOver on iOS
2920
+ // causing the page to scroll when moving focus if the element is transitioning
2921
+ // from off the screen.
2922
+ if ($507fabe10e71c6fb$export$630ff653c5ada6a9() === 'virtual') {
2923
+ let lastFocusedElement = document.activeElement;
2924
+ $bbed8b41f857bcc0$export$24490316f764c430(()=>{
2925
+ // If focus did not move and the element is still in the document, focus it.
2926
+ if (document.activeElement === lastFocusedElement && document.contains(element)) $7215afc6de606d6b$export$de79e2c695e052f3(element);
2927
+ });
2928
+ } else $7215afc6de606d6b$export$de79e2c695e052f3(element);
2929
+ }
2930
+
2931
+
2932
+ /*
2933
+ * Copyright 2021 Adobe. All rights reserved.
2934
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
2935
+ * you may not use this file except in compliance with the License. You may obtain a copy
2936
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
2937
+ *
2938
+ * Unless required by applicable law or agreed to in writing, software distributed under
2939
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
2940
+ * OF ANY KIND, either express or implied. See the License for the specific language
2941
+ * governing permissions and limitations under the License.
2942
+ */ function $645f2e67b85a24c9$var$isStyleVisible(element) {
2943
+ if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false;
2944
+ let { display: display , visibility: visibility } = element.style;
2945
+ let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
2946
+ if (isVisible) {
2947
+ const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
2948
+ let { display: computedDisplay , visibility: computedVisibility } = getComputedStyle(element);
2949
+ isVisible = computedDisplay !== 'none' && computedVisibility !== 'hidden' && computedVisibility !== 'collapse';
2950
+ }
2951
+ return isVisible;
2952
+ }
2953
+ function $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) {
2954
+ return !element.hasAttribute('hidden') && (element.nodeName === 'DETAILS' && childElement && childElement.nodeName !== 'SUMMARY' ? element.hasAttribute('open') : true);
2955
+ }
2956
+ function $645f2e67b85a24c9$export$e989c0fffaa6b27a(element, childElement) {
2957
+ return element.nodeName !== '#comment' && $645f2e67b85a24c9$var$isStyleVisible(element) && $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) && (!element.parentElement || $645f2e67b85a24c9$export$e989c0fffaa6b27a(element.parentElement, element));
2958
+ }
2959
+
2960
+
2961
+
2962
+
2963
+ const $9bf71ea28793e738$var$FocusContext = /*#__PURE__*/ React.createContext(null);
2964
+ let $9bf71ea28793e738$var$activeScope = null;
2965
+ let $9bf71ea28793e738$var$scopes = new Map();
2966
+ function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
2967
+ let { children: children , contain: contain , restoreFocus: restoreFocus , autoFocus: autoFocus } = props;
2968
+ let startRef = useRef();
2969
+ let endRef = useRef();
2970
+ let scopeRef = useRef([]);
2971
+ let ctx = useContext($9bf71ea28793e738$var$FocusContext);
2972
+ let parentScope = ctx === null || ctx === void 0 ? void 0 : ctx.scopeRef;
2973
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
2974
+ // Find all rendered nodes between the sentinels and add them to the scope.
2975
+ let node = startRef.current.nextSibling;
2976
+ let nodes = [];
2977
+ while(node && node !== endRef.current){
2978
+ nodes.push(node);
2979
+ node = node.nextSibling;
2980
+ }
2981
+ scopeRef.current = nodes;
2982
+ }, [
2983
+ children,
2984
+ parentScope
2985
+ ]);
2986
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
2987
+ $9bf71ea28793e738$var$scopes.set(scopeRef, parentScope);
2988
+ return ()=>{
2989
+ // Restore the active scope on unmount if this scope or a descendant scope is active.
2990
+ // Parent effect cleanups run before children, so we need to check if the
2991
+ // parent scope actually still exists before restoring the active scope to it.
2992
+ if ((scopeRef === $9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope(scopeRef, $9bf71ea28793e738$var$activeScope)) && (!parentScope || $9bf71ea28793e738$var$scopes.has(parentScope))) $9bf71ea28793e738$var$activeScope = parentScope;
2993
+ $9bf71ea28793e738$var$scopes.delete(scopeRef);
2994
+ };
2995
+ }, [
2996
+ scopeRef,
2997
+ parentScope
2998
+ ]);
2999
+ $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain);
3000
+ $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain);
3001
+ $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus);
3002
+ let focusManager = $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef);
3003
+ return(/*#__PURE__*/ React.createElement($9bf71ea28793e738$var$FocusContext.Provider, {
3004
+ value: {
3005
+ scopeRef: scopeRef,
3006
+ focusManager: focusManager
3007
+ }
3008
+ }, /*#__PURE__*/ React.createElement("span", {
3009
+ "data-focus-scope-start": true,
3010
+ hidden: true,
3011
+ ref: startRef
3012
+ }), children, /*#__PURE__*/ React.createElement("span", {
3013
+ "data-focus-scope-end": true,
3014
+ hidden: true,
3015
+ ref: endRef
3016
+ })));
3017
+ }
3018
+ function $9bf71ea28793e738$export$10c5169755ce7bd7() {
3019
+ var ref;
3020
+ return (ref = useContext($9bf71ea28793e738$var$FocusContext)) === null || ref === void 0 ? void 0 : ref.focusManager;
3021
+ }
3022
+ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
3023
+ return {
3024
+ focusNext (opts = {
3025
+ }) {
3026
+ let scope = scopeRef.current;
3027
+ let { from: from , tabbable: tabbable , wrap: wrap } = opts;
3028
+ let node = from || document.activeElement;
3029
+ let sentinel = scope[0].previousElementSibling;
3030
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
3031
+ tabbable: tabbable
3032
+ }, scope);
3033
+ walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
3034
+ let nextNode = walker.nextNode();
3035
+ if (!nextNode && wrap) {
3036
+ walker.currentNode = sentinel;
3037
+ nextNode = walker.nextNode();
3038
+ }
3039
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
3040
+ return nextNode;
3041
+ },
3042
+ focusPrevious (opts = {
3043
+ }) {
3044
+ let scope = scopeRef.current;
3045
+ let { from: from , tabbable: tabbable , wrap: wrap } = opts;
3046
+ let node = from || document.activeElement;
3047
+ let sentinel = scope[scope.length - 1].nextElementSibling;
3048
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
3049
+ tabbable: tabbable
3050
+ }, scope);
3051
+ walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
3052
+ let previousNode = walker.previousNode();
3053
+ if (!previousNode && wrap) {
3054
+ walker.currentNode = sentinel;
3055
+ previousNode = walker.previousNode();
3056
+ }
3057
+ if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
3058
+ return previousNode;
3059
+ },
3060
+ focusFirst (opts = {
3061
+ }) {
3062
+ let scope = scopeRef.current;
3063
+ let { tabbable: tabbable } = opts;
3064
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
3065
+ tabbable: tabbable
3066
+ }, scope);
3067
+ walker.currentNode = scope[0].previousElementSibling;
3068
+ let nextNode = walker.nextNode();
3069
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
3070
+ return nextNode;
3071
+ },
3072
+ focusLast (opts = {
3073
+ }) {
3074
+ let scope = scopeRef.current;
3075
+ let { tabbable: tabbable } = opts;
3076
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
3077
+ tabbable: tabbable
3078
+ }, scope);
3079
+ walker.currentNode = scope[scope.length - 1].nextElementSibling;
3080
+ let previousNode = walker.previousNode();
3081
+ if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
3082
+ return previousNode;
3083
+ }
3084
+ };
3085
+ }
3086
+ const $9bf71ea28793e738$var$focusableElements = [
3087
+ 'input:not([disabled]):not([type=hidden])',
3088
+ 'select:not([disabled])',
3089
+ 'textarea:not([disabled])',
3090
+ 'button:not([disabled])',
3091
+ 'a[href]',
3092
+ 'area[href]',
3093
+ 'summary',
3094
+ 'iframe',
3095
+ 'object',
3096
+ 'embed',
3097
+ 'audio[controls]',
3098
+ 'video[controls]',
3099
+ '[contenteditable]'
3100
+ ];
3101
+ const $9bf71ea28793e738$var$FOCUSABLE_ELEMENT_SELECTOR = $9bf71ea28793e738$var$focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';
3102
+ $9bf71ea28793e738$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
3103
+ const $9bf71ea28793e738$var$TABBABLE_ELEMENT_SELECTOR = $9bf71ea28793e738$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
3104
+ function $9bf71ea28793e738$var$getScopeRoot(scope) {
3105
+ return scope[0].parentElement;
3106
+ }
3107
+ function $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain) {
3108
+ let focusedNode = useRef();
3109
+ let raf = useRef(null);
3110
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
3111
+ let scope1 = scopeRef.current;
3112
+ if (!contain) return;
3113
+ // Handle the Tab key to contain focus within the scope
3114
+ let onKeyDown = (e)=>{
3115
+ if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || scopeRef !== $9bf71ea28793e738$var$activeScope) return;
3116
+ let focusedElement = document.activeElement;
3117
+ let scope = scopeRef.current;
3118
+ if (!$9bf71ea28793e738$var$isElementInScope(focusedElement, scope)) return;
3119
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
3120
+ tabbable: true
3121
+ }, scope);
3122
+ walker.currentNode = focusedElement;
3123
+ let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
3124
+ if (!nextElement) {
3125
+ walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;
3126
+ nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
3127
+ }
3128
+ e.preventDefault();
3129
+ if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
3130
+ };
3131
+ let onFocus = (e)=>{
3132
+ // If focusing an element in a child scope of the currently active scope, the child becomes active.
3133
+ // Moving out of the active scope to an ancestor is not allowed.
3134
+ if (!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) {
3135
+ $9bf71ea28793e738$var$activeScope = scopeRef;
3136
+ focusedNode.current = e.target;
3137
+ } else if (scopeRef === $9bf71ea28793e738$var$activeScope && !$9bf71ea28793e738$var$isElementInChildScope(e.target, scopeRef)) {
3138
+ // If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),
3139
+ // restore focus to the previously focused node or the first tabbable element in the active scope.
3140
+ if (focusedNode.current) focusedNode.current.focus();
3141
+ else if ($9bf71ea28793e738$var$activeScope) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
3142
+ } else if (scopeRef === $9bf71ea28793e738$var$activeScope) focusedNode.current = e.target;
3143
+ };
3144
+ let onBlur = (e)=>{
3145
+ // Firefox doesn't shift focus back to the Dialog properly without this
3146
+ raf.current = requestAnimationFrame(()=>{
3147
+ // Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe
3148
+ if (scopeRef === $9bf71ea28793e738$var$activeScope && !$9bf71ea28793e738$var$isElementInChildScope(document.activeElement, scopeRef)) {
3149
+ $9bf71ea28793e738$var$activeScope = scopeRef;
3150
+ focusedNode.current = e.target;
3151
+ focusedNode.current.focus();
3152
+ }
3153
+ });
3154
+ };
3155
+ document.addEventListener('keydown', onKeyDown, false);
3156
+ document.addEventListener('focusin', onFocus, false);
3157
+ scope1.forEach((element)=>element.addEventListener('focusin', onFocus, false)
3158
+ );
3159
+ scope1.forEach((element)=>element.addEventListener('focusout', onBlur, false)
3160
+ );
3161
+ return ()=>{
3162
+ document.removeEventListener('keydown', onKeyDown, false);
3163
+ document.removeEventListener('focusin', onFocus, false);
3164
+ scope1.forEach((element)=>element.removeEventListener('focusin', onFocus, false)
3165
+ );
3166
+ scope1.forEach((element)=>element.removeEventListener('focusout', onBlur, false)
3167
+ );
3168
+ };
3169
+ }, [
3170
+ scopeRef,
3171
+ contain
3172
+ ]);
3173
+ // eslint-disable-next-line arrow-body-style
3174
+ useEffect(()=>{
3175
+ return ()=>cancelAnimationFrame(raf.current)
3176
+ ;
3177
+ }, [
3178
+ raf
3179
+ ]);
3180
+ }
3181
+ function $9bf71ea28793e738$var$isElementInAnyScope(element) {
3182
+ for (let scope of $9bf71ea28793e738$var$scopes.keys()){
3183
+ if ($9bf71ea28793e738$var$isElementInScope(element, scope.current)) return true;
3184
+ }
3185
+ return false;
3186
+ }
3187
+ function $9bf71ea28793e738$var$isElementInScope(element, scope) {
3188
+ return scope.some((node)=>node.contains(element)
3189
+ );
3190
+ }
3191
+ function $9bf71ea28793e738$var$isElementInChildScope(element, scope) {
3192
+ // node.contains in isElementInScope covers child scopes that are also DOM children,
3193
+ // but does not cover child scopes in portals.
3194
+ for (let s of $9bf71ea28793e738$var$scopes.keys()){
3195
+ if ((s === scope || $9bf71ea28793e738$var$isAncestorScope(scope, s)) && $9bf71ea28793e738$var$isElementInScope(element, s.current)) return true;
3196
+ }
3197
+ return false;
3198
+ }
3199
+ function $9bf71ea28793e738$var$isAncestorScope(ancestor, scope) {
3200
+ let parent = $9bf71ea28793e738$var$scopes.get(scope);
3201
+ if (!parent) return false;
3202
+ if (parent === ancestor) return true;
3203
+ return $9bf71ea28793e738$var$isAncestorScope(ancestor, parent);
3204
+ }
3205
+ function $9bf71ea28793e738$var$focusElement(element, scroll = false) {
3206
+ if (element != null && !scroll) try {
3207
+ $6a99195332edec8b$export$80f3e147d781571c(element);
3208
+ } catch (err) {
3209
+ // ignore
3210
+ }
3211
+ else if (element != null) try {
3212
+ element.focus();
3213
+ } catch (err1) {
3214
+ // ignore
3215
+ }
3216
+ }
3217
+ function $9bf71ea28793e738$var$focusFirstInScope(scope) {
3218
+ let sentinel = scope[0].previousElementSibling;
3219
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
3220
+ tabbable: true
3221
+ }, scope);
3222
+ walker.currentNode = sentinel;
3223
+ $9bf71ea28793e738$var$focusElement(walker.nextNode());
3224
+ }
3225
+ function $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus) {
3226
+ const autoFocusRef = React.useRef(autoFocus);
3227
+ useEffect(()=>{
3228
+ if (autoFocusRef.current) {
3229
+ $9bf71ea28793e738$var$activeScope = scopeRef;
3230
+ if (!$9bf71ea28793e738$var$isElementInScope(document.activeElement, $9bf71ea28793e738$var$activeScope.current)) $9bf71ea28793e738$var$focusFirstInScope(scopeRef.current);
3231
+ }
3232
+ autoFocusRef.current = false;
3233
+ }, []);
3234
+ }
3235
+ function $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
3236
+ // create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.
3237
+ const nodeToRestoreRef = useRef(typeof document !== 'undefined' ? document.activeElement : null);
3238
+ // useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.
3239
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(()=>{
3240
+ let nodeToRestore = nodeToRestoreRef.current;
3241
+ if (!restoreFocus) return;
3242
+ // Handle the Tab key so that tabbing out of the scope goes to the next element
3243
+ // after the node that had focus when the scope mounted. This is important when
3244
+ // using portals for overlays, so that focus goes to the expected element when
3245
+ // tabbing out of the overlay.
3246
+ let onKeyDown = (e)=>{
3247
+ if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey) return;
3248
+ let focusedElement = document.activeElement;
3249
+ if (!$9bf71ea28793e738$var$isElementInScope(focusedElement, scopeRef.current)) return;
3250
+ // Create a DOM tree walker that matches all tabbable elements
3251
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(document.body, {
3252
+ tabbable: true
3253
+ });
3254
+ // Find the next tabbable element after the currently focused element
3255
+ walker.currentNode = focusedElement;
3256
+ let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
3257
+ if (!document.body.contains(nodeToRestore) || nodeToRestore === document.body) nodeToRestore = null;
3258
+ // If there is no next element, or it is outside the current scope, move focus to the
3259
+ // next element after the node to restore to instead.
3260
+ if ((!nextElement || !$9bf71ea28793e738$var$isElementInScope(nextElement, scopeRef.current)) && nodeToRestore) {
3261
+ walker.currentNode = nodeToRestore;
3262
+ // Skip over elements within the scope, in case the scope immediately follows the node to restore.
3263
+ do nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
3264
+ while ($9bf71ea28793e738$var$isElementInScope(nextElement, scopeRef.current))
3265
+ e.preventDefault();
3266
+ e.stopPropagation();
3267
+ if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
3268
+ else // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)
3269
+ // then move focus to the body.
3270
+ // Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)
3271
+ if (!$9bf71ea28793e738$var$isElementInAnyScope(nodeToRestore)) focusedElement.blur();
3272
+ else $9bf71ea28793e738$var$focusElement(nodeToRestore, true);
3273
+ }
3274
+ };
3275
+ if (!contain) document.addEventListener('keydown', onKeyDown, true);
3276
+ return ()=>{
3277
+ if (!contain) document.removeEventListener('keydown', onKeyDown, true);
3278
+ if (restoreFocus && nodeToRestore && $9bf71ea28793e738$var$isElementInScope(document.activeElement, scopeRef.current)) requestAnimationFrame(()=>{
3279
+ if (document.body.contains(nodeToRestore)) $9bf71ea28793e738$var$focusElement(nodeToRestore);
3280
+ });
3281
+ };
3282
+ }, [
3283
+ scopeRef,
3284
+ restoreFocus,
3285
+ contain
3286
+ ]);
3287
+ }
3288
+ function $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, opts, scope) {
3289
+ let selector = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? $9bf71ea28793e738$var$TABBABLE_ELEMENT_SELECTOR : $9bf71ea28793e738$var$FOCUSABLE_ELEMENT_SELECTOR;
3290
+ let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
3291
+ acceptNode (node) {
3292
+ var ref;
3293
+ // Skip nodes inside the starting node.
3294
+ if (opts === null || opts === void 0 ? void 0 : (ref = opts.from) === null || ref === void 0 ? void 0 : ref.contains(node)) return NodeFilter.FILTER_REJECT;
3295
+ if (node.matches(selector) && $645f2e67b85a24c9$export$e989c0fffaa6b27a(node) && (!scope || $9bf71ea28793e738$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
3296
+ return NodeFilter.FILTER_SKIP;
3297
+ }
3298
+ });
3299
+ if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
3300
+ return walker;
3301
+ }
3302
+ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {
3303
+ }) {
3304
+ return {
3305
+ focusNext (opts = {
3306
+ }) {
3307
+ let root = ref.current;
3308
+ if (!root) return;
3309
+ let { from: from , tabbable: tabbable = defaultOptions.tabbable , wrap: wrap = defaultOptions.wrap , accept: accept = defaultOptions.accept } = opts;
3310
+ let node = from || document.activeElement;
3311
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
3312
+ tabbable: tabbable,
3313
+ accept: accept
3314
+ });
3315
+ if (root.contains(node)) walker.currentNode = node;
3316
+ let nextNode = walker.nextNode();
3317
+ if (!nextNode && wrap) {
3318
+ walker.currentNode = root;
3319
+ nextNode = walker.nextNode();
3320
+ }
3321
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
3322
+ return nextNode;
3323
+ },
3324
+ focusPrevious (opts = defaultOptions) {
3325
+ let root = ref.current;
3326
+ if (!root) return;
3327
+ let { from: from , tabbable: tabbable = defaultOptions.tabbable , wrap: wrap = defaultOptions.wrap , accept: accept = defaultOptions.accept } = opts;
3328
+ let node = from || document.activeElement;
3329
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
3330
+ tabbable: tabbable,
3331
+ accept: accept
3332
+ });
3333
+ if (root.contains(node)) walker.currentNode = node;
3334
+ else {
3335
+ let next = $9bf71ea28793e738$var$last(walker);
3336
+ if (next) $9bf71ea28793e738$var$focusElement(next, true);
3337
+ return next;
3338
+ }
3339
+ let previousNode = walker.previousNode();
3340
+ if (!previousNode && wrap) {
3341
+ walker.currentNode = root;
3342
+ previousNode = $9bf71ea28793e738$var$last(walker);
3343
+ }
3344
+ if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
3345
+ return previousNode;
3346
+ },
3347
+ focusFirst (opts = defaultOptions) {
3348
+ let root = ref.current;
3349
+ if (!root) return;
3350
+ let { tabbable: tabbable = defaultOptions.tabbable , accept: accept = defaultOptions.accept } = opts;
3351
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
3352
+ tabbable: tabbable,
3353
+ accept: accept
3354
+ });
3355
+ let nextNode = walker.nextNode();
3356
+ if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
3357
+ return nextNode;
3358
+ },
3359
+ focusLast (opts = defaultOptions) {
3360
+ let root = ref.current;
3361
+ if (!root) return;
3362
+ let { tabbable: tabbable = defaultOptions.tabbable , accept: accept = defaultOptions.accept } = opts;
3363
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
3364
+ tabbable: tabbable,
3365
+ accept: accept
3366
+ });
3367
+ let next = $9bf71ea28793e738$var$last(walker);
3368
+ if (next) $9bf71ea28793e738$var$focusElement(next, true);
3369
+ return next;
3370
+ }
3371
+ };
3372
+ }
3373
+ function $9bf71ea28793e738$var$last(walker) {
3374
+ let next;
3375
+ let last;
3376
+ do {
3377
+ last = walker.lastChild();
3378
+ if (last) next = last;
3379
+ }while (last)
3380
+ return next;
3381
+ }
3382
+
3383
+
3384
+ var $907718708eab68af$exports = {};
3385
+
3386
+ $parcel$export$1($907718708eab68af$exports, "FocusRing", () => $907718708eab68af$export$1a38b4ad7f578e1d);
3387
+
3388
+
3389
+
3390
+ var $f7dceffc5ad7768b$exports = {};
3391
+
3392
+ $parcel$export$1($f7dceffc5ad7768b$exports, "useFocusRing", () => $f7dceffc5ad7768b$export$4e328f61c538687f);
3393
+
3394
+
3395
+
3396
+ function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {
3397
+ }) {
3398
+ let { autoFocus: autoFocus = false , isTextInput: isTextInput , within: within } = props;
3399
+ let state = useRef({
3400
+ isFocused: false,
3401
+ isFocusVisible: autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27()
3402
+ });
3403
+ let [isFocused1, setFocused] = useState(false);
3404
+ let [isFocusVisibleState, setFocusVisible] = useState(()=>state.current.isFocused && state.current.isFocusVisible
3405
+ );
3406
+ let updateState = useCallback(()=>setFocusVisible(state.current.isFocused && state.current.isFocusVisible)
3407
+ , []);
3408
+ let onFocusChange = useCallback((isFocused)=>{
3409
+ state.current.isFocused = isFocused;
3410
+ setFocused(isFocused);
3411
+ updateState();
3412
+ }, [
3413
+ updateState
3414
+ ]);
3415
+ $507fabe10e71c6fb$export$ec71b4b83ac08ec3((isFocusVisible)=>{
3416
+ state.current.isFocusVisible = isFocusVisible;
3417
+ updateState();
3418
+ }, [], {
3419
+ isTextInput: isTextInput
3420
+ });
3421
+ let { focusProps: focusProps } = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6({
3422
+ isDisabled: within,
3423
+ onFocusChange: onFocusChange
3424
+ });
3425
+ let { focusWithinProps: focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
3426
+ isDisabled: !within,
3427
+ onFocusWithinChange: onFocusChange
3428
+ });
3429
+ return {
3430
+ isFocused: isFocused1,
3431
+ isFocusVisible: state.current.isFocused && isFocusVisibleState,
3432
+ focusProps: within ? focusWithinProps : focusProps
3433
+ };
3434
+ }
3435
+
3436
+
3437
+ function $907718708eab68af$export$1a38b4ad7f578e1d(props) {
3438
+ let { children: children , focusClass: focusClass , focusRingClass: focusRingClass } = props;
3439
+ let { isFocused: isFocused , isFocusVisible: isFocusVisible , focusProps: focusProps } = $f7dceffc5ad7768b$export$4e328f61c538687f(props);
3440
+ let child = React.Children.only(children);
3441
+ return(/*#__PURE__*/ React.cloneElement(child, $3ef42575df84b30b$export$9d1611c77c2fe928(child.props, {
3442
+ ...focusProps,
3443
+ className: clsx({
3444
+ [focusClass || '']: isFocused,
3445
+ [focusRingClass || '']: isFocusVisible
3446
+ })
3447
+ })));
3448
+ }
3449
+
3450
+
3451
+ var $e6afbd83fe6ebbd2$exports = {};
3452
+
3453
+ $parcel$export$1($e6afbd83fe6ebbd2$exports, "FocusableProvider", () => $e6afbd83fe6ebbd2$export$13f3202a3e5ddd5);
3454
+ $parcel$export$1($e6afbd83fe6ebbd2$exports, "useFocusable", () => $e6afbd83fe6ebbd2$export$4c014de7c8940b4c);
3455
+
3456
+
3457
+
3458
+
3459
+ let $e6afbd83fe6ebbd2$var$FocusableContext = /*#__PURE__*/ React.createContext(null);
3460
+ function $e6afbd83fe6ebbd2$var$useFocusableContext(ref) {
3461
+ let context = useContext($e6afbd83fe6ebbd2$var$FocusableContext) || {
3462
+ };
3463
+ $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, ref);
3464
+ // eslint-disable-next-line
3465
+ let { ref: _ , ...otherProps } = context;
3466
+ return otherProps;
3467
+ }
3468
+ /**
3469
+ * Provides DOM props to the nearest focusable child.
3470
+ */ function $e6afbd83fe6ebbd2$var$FocusableProvider(props, ref) {
3471
+ let { children: children , ...otherProps } = props;
3472
+ let context = {
3473
+ ...otherProps,
3474
+ ref: ref
3475
+ };
3476
+ return(/*#__PURE__*/ React.createElement($e6afbd83fe6ebbd2$var$FocusableContext.Provider, {
3477
+ value: context
3478
+ }, children));
3479
+ }
3480
+ let $e6afbd83fe6ebbd2$export$13f3202a3e5ddd5 = /*#__PURE__*/ React.forwardRef($e6afbd83fe6ebbd2$var$FocusableProvider);
3481
+ function $e6afbd83fe6ebbd2$export$4c014de7c8940b4c(props, domRef) {
3482
+ let { focusProps: focusProps } = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props);
3483
+ let { keyboardProps: keyboardProps } = $46d819fcbaf35654$export$8f71654801c2f7cd(props);
3484
+ let interactions = $3ef42575df84b30b$export$9d1611c77c2fe928(focusProps, keyboardProps);
3485
+ let domProps = $e6afbd83fe6ebbd2$var$useFocusableContext(domRef);
3486
+ let interactionProps = props.isDisabled ? {
3487
+ } : domProps;
3488
+ let autoFocusRef = useRef(props.autoFocus);
3489
+ useEffect(()=>{
3490
+ if (autoFocusRef.current && domRef.current) $6a99195332edec8b$export$80f3e147d781571c(domRef.current);
3491
+ autoFocusRef.current = false;
3492
+ }, [
3493
+ domRef
3494
+ ]);
3495
+ return {
3496
+ focusableProps: $3ef42575df84b30b$export$9d1611c77c2fe928({
3497
+ ...interactions,
3498
+ tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined
3499
+ }, interactionProps)
3500
+ };
3501
+ }
3502
+
3503
+ function $parcel$export(e, n, v, s) {
3504
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3505
+ }
3506
+ var $701a24aa0da5b062$exports = {};
3507
+
3508
+ $parcel$export($701a24aa0da5b062$exports, "useButton", () => $701a24aa0da5b062$export$ea18c227d4417cc3);
3509
+
3510
+
3511
+
3512
+
3513
+ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
3514
+ let { elementType: elementType = 'button' , isDisabled: isDisabled , onPress: onPress , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressChange: onPressChange , preventFocusOnPress: // @ts-ignore - undocumented
3515
+ preventFocusOnPress , allowFocusWhenDisabled: // @ts-ignore - undocumented
3516
+ allowFocusWhenDisabled , // @ts-ignore
3517
+ onClick: deprecatedOnClick , href: href , target: target , rel: rel , type: type = 'button' } = props;
3518
+ let additionalProps;
3519
+ if (elementType === 'button') additionalProps = {
3520
+ type: type,
3521
+ disabled: isDisabled
3522
+ };
3523
+ else additionalProps = {
3524
+ role: 'button',
3525
+ tabIndex: isDisabled ? undefined : 0,
3526
+ href: elementType === 'a' && isDisabled ? undefined : href,
3527
+ target: elementType === 'a' ? target : undefined,
3528
+ type: elementType === 'input' ? type : undefined,
3529
+ disabled: elementType === 'input' ? isDisabled : undefined,
3530
+ 'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,
3531
+ rel: elementType === 'a' ? rel : undefined
3532
+ };
3533
+ let { pressProps: pressProps , isPressed: isPressed } = $f6c31cce2adf654f$export$45712eceda6fad21({
3534
+ onPressStart: onPressStart,
3535
+ onPressEnd: onPressEnd,
3536
+ onPressChange: onPressChange,
3537
+ onPress: onPress,
3538
+ isDisabled: isDisabled,
3539
+ preventFocusOnPress: preventFocusOnPress,
3540
+ ref: ref
3541
+ });
3542
+ let { focusableProps: focusableProps } = $e6afbd83fe6ebbd2$export$4c014de7c8940b4c(props, ref);
3543
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
3544
+ let buttonProps = $3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, pressProps, $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
3545
+ labelable: true
3546
+ }));
3547
+ return {
3548
+ isPressed: isPressed,
3549
+ buttonProps: $3ef42575df84b30b$export$9d1611c77c2fe928(additionalProps, buttonProps, {
3550
+ 'aria-haspopup': props['aria-haspopup'],
3551
+ 'aria-expanded': props['aria-expanded'],
3552
+ 'aria-controls': props['aria-controls'],
3553
+ 'aria-pressed': props['aria-pressed'],
3554
+ onClick: (e)=>{
3555
+ if (deprecatedOnClick) {
3556
+ deprecatedOnClick(e);
3557
+ console.warn('onClick is deprecated, please use onPress');
3558
+ }
3559
+ }
3560
+ })
3561
+ };
3562
+ }
3563
+
3564
+
3565
+ var $55f54f7887471b58$exports = {};
3566
+
3567
+ $parcel$export($55f54f7887471b58$exports, "useToggleButton", () => $55f54f7887471b58$export$51e84d46ca0bc451);
3568
+
3569
+
3570
+
3571
+ function $55f54f7887471b58$export$51e84d46ca0bc451(props, state, ref) {
3572
+ const { isSelected: isSelected } = state;
3573
+ const { isPressed: isPressed , buttonProps: buttonProps } = $701a24aa0da5b062$export$ea18c227d4417cc3({
3574
+ ...props,
3575
+ onPress: $ff5963eb1fccf552$export$e08e3b67e392101e(state.toggle, props.onPress)
3576
+ }, ref);
3577
+ return {
3578
+ isPressed: isPressed,
3579
+ buttonProps: $3ef42575df84b30b$export$9d1611c77c2fe928(buttonProps, {
3580
+ 'aria-pressed': isSelected
3581
+ })
3582
+ };
3583
+ }
3584
+
3585
+ /**
3586
+ * Component size.
3587
+ */
3588
+ const IconSize = {
3589
+ large: 'large',
3590
+ medium: 'medium',
3591
+ small: 'small'
3592
+ };
3593
+
3594
+ /**
3595
+ * Component style.
3596
+ */
3597
+ const StyledIcon = styled.span`
3598
+ font-style: normal;
3599
+ position: relative;
3600
+
3601
+ ${_ref => {
3602
+ let {
3603
+ $color
3604
+ } = _ref;
3605
+ return $color && Object.keys(ColorPalette).indexOf($color) !== -1 ? css`
3606
+ color: var(--redsift-color-${$color}-main);
3607
+ ` : css`
3608
+ color: ${$color || css`var(--redsift-color-action-active)`};
3609
+ `;
3610
+ }}
3611
+
3612
+ ${_ref2 => {
3613
+ let {
3614
+ $size
3615
+ } = _ref2;
3616
+ switch ($size) {
3617
+ case IconSize.large:
3618
+ return css`
3619
+ font-size: 35px;
3620
+ height: 35px;
3621
+ line-height: 35px;
3622
+ width: 35px;
3623
+
3624
+ & .redsift-badge-standard {
3625
+ position: absolute;
3626
+ right: -23px;
3627
+ top: 0px;
3628
+ }
3629
+
3630
+ & .redsift-badge-dot {
3631
+ position: absolute;
3632
+ right: -7px;
3633
+ top: 4px;
3634
+ }
3635
+ `;
3636
+ case IconSize.small:
3637
+ return css`
3638
+ font-size: 20px;
3639
+ height: 20px;
3640
+ line-height: 20px;
3641
+ width: 20px;
3642
+
3643
+ & .redsift-badge-standard {
3644
+ position: absolute;
3645
+ right: -24px;
3646
+ top: -8px;
3647
+ }
3648
+
3649
+ & .redsift-badge-dot {
3650
+ position: absolute;
3651
+ right: -8px;
3652
+ top: 1px;
3653
+ }
3654
+ `;
3655
+ case IconSize.medium:
3656
+ default:
3657
+ return css`
3658
+ font-size: 24px;
3659
+ height: 24px;
3660
+ line-height: 24px;
3661
+ width: 24px;
3662
+
3663
+ & .redsift-badge-standard {
3664
+ position: absolute;
3665
+ right: -24px;
3666
+ top: -6px;
3667
+ }
3668
+
3669
+ & .redsift-badge-dot {
3670
+ position: absolute;
3671
+ right: -8px;
3672
+ top: 2px;
3673
+ }
3674
+ `;
3675
+ }
3676
+ }}
3677
+ `;
3678
+
3679
+ const _excluded$3 = ["aria-hidden", "aria-label", "badge", "className", "color", "icon", "size", "svgProps"];
3680
+ const COMPONENT_NAME$4 = 'RedSiftIcon';
3681
+ const CLASSNAME$4 = 'redsift-icon';
3682
+ const DEFAULT_PROPS$3 = {
3683
+ size: IconSize.medium
3684
+ };
3685
+
3686
+ /**
3687
+ * The Icon component.
3688
+ */
3689
+ const Icon = /*#__PURE__*/forwardRef((props, ref) => {
3690
+ const iconRef = ref || useRef();
3691
+ let {
3692
+ 'aria-hidden': ariaHidden,
3693
+ 'aria-label': ariaLabel,
3694
+ badge,
3695
+ className,
3696
+ color,
3697
+ icon,
3698
+ size,
3699
+ svgProps
3700
+ } = props,
3701
+ forwardedProps = _objectWithoutProperties(props, _excluded$3);
3702
+ if (!ariaHidden) {
3703
+ ariaHidden = undefined;
3704
+ }
3705
+ return /*#__PURE__*/React.createElement(StyledIcon, _extends({}, forwardedProps, {
3706
+ $color: color,
3707
+ $size: size,
3708
+ "aria-hidden": ariaLabel ? ariaHidden || undefined : true,
3709
+ "aria-label": ariaLabel,
3710
+ className: classNames(Icon.className, className),
3711
+ ref: iconRef
3712
+ }), /*#__PURE__*/React.createElement("svg", _extends({}, svgProps, {
3713
+ "aria-hidden": ariaLabel ? ariaHidden || undefined : true,
3714
+ "aria-label": ariaLabel,
3715
+ focusable: "false",
3716
+ height: "1em",
3717
+ preserveAspectRatio: "xMidYMid meet",
3718
+ role: "img",
3719
+ style: {
3720
+ verticalAlign: '-0.125em'
3721
+ },
3722
+ viewBox: "0 0 24 24",
3723
+ width: "1em"
3724
+ }), /*#__PURE__*/React.createElement("path", {
3725
+ d: icon,
3726
+ fill: "currentColor"
3727
+ })), badge ? badge : null);
3728
+ });
3729
+ Icon.className = CLASSNAME$4;
3730
+ Icon.defaultProps = DEFAULT_PROPS$3;
3731
+ Icon.displayName = COMPONENT_NAME$4;
3732
+
3733
+ /**
3734
+ * Component variant.
3735
+ */
3736
+ const ButtonVariant = {
3737
+ contained: 'contained',
3738
+ outlined: 'outlined',
3739
+ text: 'text'
3740
+ };
3741
+ /**
3742
+ * Component size.
3743
+ */
3744
+ const ButtonSize = {
3745
+ large: 'large',
3746
+ medium: 'medium',
3747
+ small: 'small'
3748
+ };
3749
+
3750
+ /**
3751
+ * Component style.
3752
+ */
3753
+ const StyledButton = styled.button`
3754
+ display: flex;
3755
+ align-items: center;
3756
+ justify-content: center;
3757
+ text-decoration: none;
3758
+
3759
+ ${_ref => {
3760
+ let {
3761
+ $variant,
3762
+ $color,
3763
+ $size,
3764
+ $isDisabled
3765
+ } = _ref;
3766
+ switch ($variant) {
3767
+ case ButtonVariant.outlined:
3768
+ return css`
3769
+ border: 1px solid ${$isDisabled ? 'var(--redsift-color-action-disabled-background)' : `var(--redsift-color-${$color}-outlined-resting)`};
3770
+ background-color: transparent;
3771
+ &, .redsift-icon {
3772
+ color: ${$isDisabled ? 'var(--redsift-color-action-disabled)' : `var(--redsift-color-${$color}-main)`};
3773
+ }
3774
+
3775
+ padding: ${$size === ButtonSize.small ? '4px 8px' : $size === ButtonSize.medium ? '6px 16px' : '8px 24px'};
3776
+ `;
3777
+ case ButtonVariant.text:
3778
+ return css`
3779
+ border: none;
3780
+ background-color: transparent;
3781
+ &, .redsift-icon {
3782
+ color: ${$isDisabled ? 'var(--redsift-color-action-disabled)' : `var(--redsift-color-${$color}-main)`};
3783
+ }
3784
+
3785
+ padding: ${$size === ButtonSize.small ? '4px 4px' : $size === ButtonSize.medium ? '6px 8px' : '8px 8px'};
3786
+ `;
3787
+ case ButtonVariant.contained:
3788
+ default:
3789
+ return css`
3790
+ border: none;
3791
+ background-color: ${$isDisabled ? 'var(--redsift-color-action-disabled-background)' : `var(--redsift-color-${$color}-main)`};
3792
+ &, .redsift-icon {
3793
+ color: ${$isDisabled ? 'var(--redsift-color-action-disabled)' : `var(--redsift-color-${$color}-contrast)`};
3794
+ }
3795
+
3796
+ padding: ${$size === ButtonSize.small ? '4px 8px' : $size === ButtonSize.medium ? '6px 16px' : '8px 24px'};
3797
+ `;
3798
+ }
3799
+ }}
3800
+
3801
+ font-family: ${_ref2 => {
3802
+ let {
3803
+ $size
3804
+ } = _ref2;
3805
+ return `var(--redsift-typography-button-${$size}-font-family)`;
3806
+ }};
3807
+ font-weight: ${_ref3 => {
3808
+ let {
3809
+ $size
3810
+ } = _ref3;
3811
+ return `var(--redsift-typography-button-${$size}-font-weight)`;
3812
+ }};
3813
+ font-size: ${_ref4 => {
3814
+ let {
3815
+ $size
3816
+ } = _ref4;
3817
+ return `var(--redsift-typography-button-${$size}-font-size)`;
3818
+ }};
3819
+ line-height: ${_ref5 => {
3820
+ let {
3821
+ $size
3822
+ } = _ref5;
3823
+ return `var(--redsift-typography-button-${$size}-line-height)`;
3824
+ }};
3825
+ text-transform: ${_ref6 => {
3826
+ let {
3827
+ $size
3828
+ } = _ref6;
3829
+ return `var(--redsift-typography-button-${$size}-text-transform)`;
3830
+ }};
3831
+
3832
+ .redsift-icon {
3833
+ ${_ref7 => {
3834
+ let {
3835
+ $size
3836
+ } = _ref7;
3837
+ return $size === ButtonSize.large ? `
3838
+ height: 24px;
3839
+ width: 24px;
3840
+ font-size: 24px;
3841
+ line-height: 24px;
3842
+ ` : '';
3843
+ }}
3844
+
3845
+ ${_ref8 => {
3846
+ let {
3847
+ $size
3848
+ } = _ref8;
3849
+ return $size === ButtonSize.medium ? `
3850
+ height: 20px;
3851
+ width: 20px;
3852
+ font-size: 20px;
3853
+ line-height: 20px;
3854
+ ` : '';
3855
+ }}
3856
+
3857
+ ${_ref9 => {
3858
+ let {
3859
+ $size
3860
+ } = _ref9;
3861
+ return $size === ButtonSize.small ? `
3862
+ height: 18px;
3863
+ width: 18px;
3864
+ font-size: 18px;
3865
+ line-height: 18px;
3866
+ ` : '';
3867
+ }}
3868
+ }
3869
+
3870
+ .redsift-icon.left {
3871
+ margin-right: 8px;
3872
+ }
3873
+
3874
+ .redsift-icon.right {
3875
+ margin-left: 8px;
3876
+ }
3877
+
3878
+ &:hover,
3879
+ &:focus-visible {
3880
+ outline: none;
3881
+
3882
+ ${_ref10 => {
3883
+ let {
3884
+ $isDisabled,
3885
+ $variant,
3886
+ $color
3887
+ } = _ref10;
3888
+ return !$isDisabled ? css`
3889
+ cursor: pointer;
3890
+
3891
+ ${$variant === ButtonVariant.contained ? css`
3892
+ background-color: var(--redsift-color-${$color}-contained-hover);
3893
+ ` : ''}
3894
+
3895
+ ${$variant === ButtonVariant.outlined ? css`
3896
+ background-color: var(--redsift-color-${$color}-outlined-hover);
3897
+ ` : ''}
3898
+
3899
+ ${$variant === ButtonVariant.text ? css`
3900
+ background-color: var(--redsift-color-${$color}-outlined-hover);
3901
+ ` : ''}
3902
+ ` : '';
3903
+ }}
3904
+ }
3905
+
3906
+ ${_ref11 => {
3907
+ let {
3908
+ $fullWidth
3909
+ } = _ref11;
3910
+ return $fullWidth ? `
3911
+ width: 100%;
3912
+ flex-grow: 1;
3913
+
3914
+ .redsift-icon.left {
3915
+ margin-right: unset;
3916
+ }
3917
+
3918
+ .redsift-icon.right {
3919
+ margin-left: unset;
3920
+ }
3921
+
3922
+ span {
3923
+ margin-right: 8px;
3924
+ margin-left: 8px;
3925
+ }
3926
+ ` : '';
3927
+ }}
3928
+ `;
3929
+
3930
+ const _excluded$2 = ["children", "className", "color", "disabled", "fullWidth", "isDisabled", "leftIcon", "onPress", "rightIcon", "size", "variant"];
3931
+ const COMPONENT_NAME$3 = 'RedSiftButton';
3932
+ const CLASSNAME$3 = 'redsift-button';
3933
+ const DEFAULT_PROPS$2 = {
3934
+ color: ColorPalette.primary,
3935
+ size: ButtonSize.large,
3936
+ variant: ButtonVariant.contained
3937
+ };
3938
+
3939
+ /**
3940
+ * The Button is a semantic button that looks like a button.
3941
+ *
3942
+ * For a semantic link that looks like a button, please use the ButtonLink component.
3943
+ * For a semantic link that looks like a link, please use the Link component.
3944
+ * For a semantic button that looks like a link, please use the LinkButton component.
3945
+ */
3946
+ const Button = /*#__PURE__*/forwardRef((props, ref) => {
3947
+ const buttonRef = ref || useRef();
3948
+ const {
3949
+ buttonProps
3950
+ } = $701a24aa0da5b062$export$ea18c227d4417cc3(_objectSpread2(_objectSpread2({}, props), {}, {
3951
+ preventFocusOnPress: true
3952
+ }), buttonRef);
3953
+ const {
3954
+ children,
3955
+ className,
3956
+ color,
3957
+ disabled,
3958
+ fullWidth,
3959
+ isDisabled,
3960
+ leftIcon,
3961
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3962
+ onPress,
3963
+ rightIcon,
3964
+ size,
3965
+ variant
3966
+ } = props,
3967
+ forwardedProps = _objectWithoutProperties(props, _excluded$2);
3968
+ return /*#__PURE__*/React.createElement(StyledButton, _extends({}, forwardedProps, buttonProps, {
3969
+ $color: color,
3970
+ $fullWidth: fullWidth,
3971
+ $isDisabled: isDisabled || disabled,
3972
+ $size: size,
3973
+ $variant: variant,
3974
+ "aria-disabled": isDisabled || disabled,
3975
+ className: classNames(Button.className, className),
3976
+ disabled: isDisabled || disabled,
3977
+ ref: buttonRef
3978
+ }), leftIcon ? /*#__PURE__*/React.createElement(Icon, {
3979
+ icon: leftIcon,
3980
+ "aria-hidden": "true",
3981
+ className: "left"
3982
+ }) : null, children && /*#__PURE__*/React.createElement("span", null, children), rightIcon ? /*#__PURE__*/React.createElement(Icon, {
3983
+ icon: rightIcon,
3984
+ "aria-hidden": "true",
3985
+ className: "right"
3986
+ }) : null);
3987
+ });
3988
+ Button.className = CLASSNAME$3;
3989
+ Button.defaultProps = DEFAULT_PROPS$2;
3990
+ Button.displayName = COMPONENT_NAME$3;
3991
+
3992
+ const ResetButton = /*#__PURE__*/forwardRef((props, ref) => {
3993
+ const {
3994
+ chart,
3995
+ children
3996
+ } = props;
3997
+ return /*#__PURE__*/React.createElement(Button, {
3998
+ ref: ref,
3999
+ variant: "text",
4000
+ size: "small",
4001
+ color: "primary",
4002
+ onPress: () => {
4003
+ chart === null || chart === void 0 ? void 0 : chart.filter(null);
4004
+ redrawAll();
4005
+ }
4006
+ }, children);
4007
+ });
4008
+
4009
+ /**
4010
+ * Component size.
4011
+ */
4012
+ const HorizontalBarChartSize = {
4013
+ large: 'large',
4014
+ medium: 'medium',
4015
+ small: 'small'
4016
+ };
4017
+ /**
4018
+ * Component theme.
4019
+ */
4020
+ const HorizontalBarChartTheme = {
4021
+ default: 'default',
4022
+ dark: 'dark',
4023
+ darker: 'darker',
4024
+ monochrome: 'monochrome'
4025
+ };
4026
+
4027
+ /**
4028
+ * Component style.
4029
+ */
4030
+ const StyledHorizontalBarChart = styled.div`
4031
+ margin: 16px;
4032
+ padding: 16px;
4033
+ color: var(--redsift-color-text-primary);
4034
+
4035
+ .redsift-horizontal-barchart__chart {
4036
+ display: flex;
4037
+ font-family: var(--redsift-typography-font-family-source-code-pro);
4038
+ font-size: 12px;
4039
+ justify-content: center;
4040
+ margin: 8px 0;
4041
+ }
4042
+
4043
+ svg > g {
4044
+ margin: 8px;
4045
+ }
4046
+
4047
+ g.row {
4048
+ text {
4049
+ cursor: pointer;
4050
+ }
4051
+
4052
+ rect {
4053
+ fill-opacity: 0.9;
4054
+ cursor: pointer;
4055
+ }
4056
+
4057
+ rect.deselected {
4058
+ stroke: none;
4059
+ fill: var(--redsift-color-text-disabled);
4060
+ }
4061
+ }
4062
+
4063
+ g.row.focused,
4064
+ g.row:hover {
4065
+ rect {
4066
+ fill-opacity: 0.7;
4067
+ }
4068
+ }
4069
+
4070
+ g.pie-slice.focused rect.deselected {
4071
+ fill-opacity: 0.3;
4072
+ }
4073
+
4074
+ svg:hover,
4075
+ svg:focus {
4076
+ outline: none;
4077
+ }
4078
+
4079
+ svg:focus-visible {
4080
+ outline: auto;
4081
+ }
4082
+
4083
+ .axis {
4084
+ line.grid-line {
4085
+ fill: none;
4086
+ stroke: #ccc;
4087
+ shape-rendering: crispEdges;
4088
+ }
4089
+
4090
+ text {
4091
+ font-family: var(--redsift-typography-font-family-source-code-pro);
4092
+ font-size: 10px;
4093
+ }
4094
+ }
4095
+ `;
4096
+ const StyledHorizontalBarChartTitle = styled.div`
4097
+ align-items: center;
4098
+ display: flex;
4099
+ flex-direction: row;
4100
+ font-family: var(--redsift-typography-h4-font-family);
4101
+ font-size: var(--redsift-typography-h4-font-size);
4102
+ font-weight: var(--redsift-typography-h4-font-weight);
4103
+ gap: 16px;
4104
+ line-height: var(--redsift-typography-h4-line-height);
4105
+ `;
4106
+ const StyledHorizontalBarChartCaption = styled.p`
4107
+ font-family: var(--redsift-typography-caption-font-family);
4108
+ font-size: var(--redsift-typography-caption-font-size);
4109
+ font-weight: var(--redsift-typography-caption-font-weight);
4110
+ line-height: var(--redsift-typography-caption-line-height);
4111
+ `;
4112
+
4113
+ /**
4114
+ * .
4115
+ */
4116
+ const useChartAsListbox = _ref => {
4117
+ let {
4118
+ id,
4119
+ querySelector,
4120
+ numberOfGroups,
4121
+ chartRef,
4122
+ chart,
4123
+ orientation = 'horizontal'
4124
+ } = _ref;
4125
+ const currentIndexRef = useRef(0);
4126
+ useEffect(() => {
4127
+ if (numberOfGroups && chartRef) {
4128
+ // Create utils to manipulate focus on options
4129
+ const getAllOptions = () => chartRef.querySelectorAll(querySelector);
4130
+ const getCurrentOption = () => chartRef.querySelector(`${querySelector}._${currentIndexRef.current}`);
4131
+ const next = () => {
4132
+ getCurrentOption().classList.remove('focused');
4133
+ const index = currentIndexRef.current === numberOfGroups - 1 ? 0 : currentIndexRef.current + 1;
4134
+ currentIndexRef.current = index;
4135
+ chartRef.setAttribute('aria-activedescendant', `id${id}__option-${currentIndexRef.current}`);
4136
+ getCurrentOption().classList.add('focused');
4137
+ };
4138
+ const previous = () => {
4139
+ getCurrentOption().classList.remove('focused');
4140
+ const index = currentIndexRef.current === 0 ? numberOfGroups - 1 : currentIndexRef.current - 1;
4141
+ currentIndexRef.current = index;
4142
+ chartRef.setAttribute('aria-activedescendant', `id${id}__option-${currentIndexRef.current}`);
4143
+ getCurrentOption().classList.add('focused');
4144
+ };
4145
+ const focus = () => {
4146
+ chartRef.setAttribute('aria-activedescendant', `id${id}__option-0`);
4147
+ getCurrentOption().classList.add('focused');
4148
+ };
4149
+ const blur = () => {
4150
+ getCurrentOption().classList.remove('focused');
4151
+ currentIndexRef.current = 0;
4152
+ chartRef.setAttribute('aria-activedescendant', '');
4153
+ };
4154
+ const keydown = e => {
4155
+ e.stopPropagation();
4156
+ switch (e.code) {
4157
+ case 'ArrowRight':
4158
+ if (orientation === 'horizontal') {
4159
+ e.preventDefault();
4160
+ next();
4161
+ }
4162
+ break;
4163
+ case 'ArrowLeft':
4164
+ if (orientation === 'horizontal') {
4165
+ e.preventDefault();
4166
+ previous();
4167
+ }
4168
+ break;
4169
+ case 'ArrowDown':
4170
+ if (orientation === 'vertical') {
4171
+ e.preventDefault();
4172
+ next();
4173
+ }
4174
+ break;
4175
+ case 'ArrowUp':
4176
+ if (orientation === 'vertical') {
4177
+ e.preventDefault();
4178
+ previous();
4179
+ }
4180
+ break;
4181
+ case 'Enter':
4182
+ case 'Space':
4183
+ e.preventDefault();
4184
+ chart.selectAll(`${querySelector}._${currentIndexRef.current}`).each(d => {
4185
+ if (d.data && d.data.key) {
4186
+ chart.onClick(d.data);
4187
+ } else if (d.key) {
4188
+ chart.onClick(d);
4189
+ }
4190
+ });
4191
+ break;
4192
+ }
4193
+ };
4194
+ chart.on('postRender', chart => {
4195
+ // Add role and aria attributes to the each option.
4196
+ chart.selectAll(`${querySelector} > title`).attr('id', (d, index) => `id${id}__option-${index}-title`);
4197
+ chart.selectAll(`${querySelector} > text`).attr('aria-hidden', 'true');
4198
+ chart.selectAll(querySelector).attr('id', (_, index) => `id${id}__option-${index}`).attr('role', 'option').attr('aria-labelledby', (_, index) => `id${id}__option-${index}-title`);
4199
+
4200
+ // Add role, aria attributes and keyboard events to the group of options.
4201
+ chartRef.setAttribute('tabIndex', '0');
4202
+ chartRef.setAttribute('role', 'listbox');
4203
+ chartRef.setAttribute('aria-labelledby', `id${id}__title`);
4204
+ chartRef.setAttribute('aria-multiselectable', 'true');
4205
+ chartRef.setAttribute('aria-orientation', orientation);
4206
+ chartRef.setAttribute('aria-activedescendant', `id${id}__option-0`);
4207
+ chartRef.addEventListener('focus', focus);
4208
+ chartRef.addEventListener('blur', blur);
4209
+ chartRef.addEventListener('mouseout', blur);
4210
+ chartRef.addEventListener('keydown', keydown);
4211
+ });
4212
+ chart.on('renderlet', () => {
4213
+ // Add role and aria attributes to the each option.
4214
+ chart.selectAll(`${querySelector} > title`).attr('id', (_, index) => `id${id}__option-${index}-title`);
4215
+ chart.selectAll(`${querySelector} > text`).attr('aria-hidden', 'true');
4216
+
4217
+ // Set aria-selected on each option based on the selection.
4218
+ getAllOptions().forEach(element => {
4219
+ if (element.classList.contains('selected') || element.getElementsByClassName('selected').length) {
4220
+ element.setAttribute('aria-selected', 'true');
4221
+ } else {
4222
+ element.setAttribute('aria-selected', 'false');
4223
+ }
4224
+ });
4225
+ });
4226
+ }
4227
+ }, [chart]);
4228
+ };
4229
+
4230
+ const _excluded$1 = ["areXLabelsRotated", "caping", "caption", "className", "columnToFilter", "data", "dimension", "group", "isResetable", "localeText", "others", "size", "theme", "title"];
4231
+ const COMPONENT_NAME$2 = 'RedSiftHorizontalBarChart';
4232
+ const CLASSNAME$2 = 'redsift-horizontal-barchart';
4233
+ const DEFAULT_PROPS$1 = {
4234
+ isResetable: true,
4235
+ localeText: {
4236
+ resetLabel: 'Reset'
4237
+ },
4238
+ others: true,
4239
+ size: HorizontalBarChartSize.medium,
4240
+ theme: HorizontalBarChartTheme.default,
4241
+ title: 'Horizontal Bar Chart'
4242
+ };
4243
+ const sizeToDimension$1 = size => {
4244
+ switch (size) {
4245
+ case HorizontalBarChartSize.small:
4246
+ return {
4247
+ width: 300,
4248
+ height: 200
4249
+ };
4250
+ case HorizontalBarChartSize.large:
4251
+ return {
4252
+ width: 500,
4253
+ height: 400
4254
+ };
4255
+ case HorizontalBarChartSize.medium:
4256
+ default:
4257
+ return {
4258
+ width: 400,
4259
+ height: 300
4260
+ };
4261
+ }
4262
+ };
4263
+ const HorizontalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
4264
+ const containerRef = ref || useRef();
4265
+ const chartRef = useRef();
4266
+ const id = useId();
4267
+ const [chart, setChart] = useState();
4268
+ const [groups, setGroups] = useState();
4269
+ const {
4270
+ areXLabelsRotated,
4271
+ caping,
4272
+ caption,
4273
+ className,
4274
+ columnToFilter,
4275
+ data,
4276
+ dimension,
4277
+ group,
4278
+ isResetable,
4279
+ localeText,
4280
+ others = DEFAULT_PROPS$1.others,
4281
+ size = DEFAULT_PROPS$1.size,
4282
+ theme,
4283
+ title
4284
+ } = props,
4285
+ forwardedProps = _objectWithoutProperties(props, _excluded$1);
4286
+
4287
+ // Get overriden labels and texts.
4288
+ const {
4289
+ resetLabel
4290
+ } = _objectSpread2(_objectSpread2({}, DEFAULT_PROPS$1.localeText), localeText);
4291
+
4292
+ // Get charts dimensions based on the selected size.
4293
+ const chartDimensions = sizeToDimension$1(size);
4294
+
4295
+ // Get ndx from context or initialize it.
4296
+ const {
4297
+ ndx = crossfilter(data),
4298
+ dispatch,
4299
+ state
4300
+ } = useContext(DashboardContext);
4301
+ const {
4302
+ tableFilters
4303
+ } = state;
4304
+
4305
+ // Set color scheme.
4306
+ let d3colors = ordinal(scheme.default);
4307
+ if (typeof theme === 'string') {
4308
+ d3colors = ordinal(scheme[theme]);
4309
+ } else if (typeof theme === 'object') {
4310
+ d3colors = ordinal().domain([theme.success, theme.warning, theme.danger]).range([successDangerScheme.success, successDangerScheme.warning, successDangerScheme.danger]).unknown(neutral);
4311
+ }
4312
+
4313
+ // useEffect called only once to initialize the chart.
4314
+ useEffect(() => {
4315
+ if (chartRef.current) {
4316
+ config.defaultColors(scheme.default);
4317
+ const rowChart$1 = rowChart(chartRef.current);
4318
+
4319
+ // Compute dimension and group.
4320
+ const computedDimension = ndx.dimension(dimension);
4321
+ const computedGroup = group(computedDimension.group());
4322
+
4323
+ // Initialize the chart.
4324
+ rowChart$1.width(chartDimensions.width - 16).height(chartDimensions.height - (areXLabelsRotated ? 30 : 0)).margins({
4325
+ top: 16,
4326
+ left: 16,
4327
+ right: 16,
4328
+ bottom: 32
4329
+ }).dimension(computedDimension).group(computedGroup).colors(d3colors);
4330
+ rowChart$1.xAxis().ticks(5);
4331
+ if (caping) {
4332
+ rowChart$1.cap(caping);
4333
+ if (others && typeof others === 'string') {
4334
+ rowChart$1.othersLabel(others);
4335
+ } else if (!others) {
4336
+ rowChart$1.othersGrouper(d => d);
4337
+ }
4338
+ }
4339
+
4340
+ // Rotate labels and reset the height, if asked for.
4341
+ if (areXLabelsRotated) {
4342
+ rowChart$1.on('pretransition', rowChart => {
4343
+ rowChart.select('.axis').attr('text-anchor', 'end').selectAll('text').attr('transform', 'translate(-6,5) rotate(-45)');
4344
+ rowChart.select('svg').attr('height', chartDimensions.height);
4345
+ });
4346
+ }
4347
+
4348
+ // Dispatch filters to datagrid when a value is selected or unselected.
4349
+ if (columnToFilter) {
4350
+ rowChart$1.on('filtered', () => {
4351
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch({
4352
+ type: DashboardReducerActionType.FilterTable,
4353
+ filter: {
4354
+ id: rowChart$1.anchorName(),
4355
+ columnField: columnToFilter,
4356
+ operatorValue: 'isAnyOf',
4357
+ value: rowChart$1.filters()
4358
+ }
4359
+ });
4360
+ });
4361
+ }
4362
+
4363
+ // Render the chart.
4364
+ rowChart$1.render();
4365
+
4366
+ // Store chart and number of groups for further use.
4367
+ setChart(rowChart$1);
4368
+ setGroups(computedGroup);
4369
+ }
4370
+ }, []);
4371
+
4372
+ // Filter chart if context is updated by an external component.
4373
+ const filter = tableFilters.find(filter => filter.columnField === columnToFilter && filter.operatorValue === 'isAnyOf');
4374
+ useEffect(() => {
4375
+ if (chart && filter && filter.value && chart.filters() !== filter.value) {
4376
+ const filterValues = filter.value.map(val => {
4377
+ var _groups$all$find;
4378
+ const value = groups === null || groups === void 0 ? void 0 : (_groups$all$find = groups.all().find(_ref => {
4379
+ let {
4380
+ key
4381
+ } = _ref;
4382
+ return key.toLowerCase() === val.toLowerCase();
4383
+ })) === null || _groups$all$find === void 0 ? void 0 : _groups$all$find.key;
4384
+ if (value) {
4385
+ return value;
4386
+ }
4387
+ return val;
4388
+ });
4389
+ if (filterValues) {
4390
+ chart.filter(null);
4391
+ chart.filter([filterValues]);
4392
+ redrawAll();
4393
+ }
4394
+ }
4395
+ }, [filter]);
4396
+
4397
+ // Apply Listbox a11y pattern to the generated dc.js chart.
4398
+ useChartAsListbox({
4399
+ id,
4400
+ querySelector: 'g.row',
4401
+ numberOfGroups: groups === null || groups === void 0 ? void 0 : groups.size(),
4402
+ chartRef: chartRef.current,
4403
+ chart: chart,
4404
+ orientation: 'vertical'
4405
+ });
4406
+ return /*#__PURE__*/React.createElement(StyledHorizontalBarChart, _extends({}, forwardedProps, {
4407
+ className: classNames(HorizontalBarChart.className, className),
4408
+ ref: containerRef
4409
+ }), /*#__PURE__*/React.createElement(StyledHorizontalBarChartTitle, {
4410
+ className: `${HorizontalBarChart.className}__title`,
4411
+ id: `id${id}__title`
4412
+ }, title, chart && isResetable ? /*#__PURE__*/React.createElement(ResetButton, {
4413
+ chart: chart
4414
+ }, resetLabel) : null), /*#__PURE__*/React.createElement("div", {
4415
+ className: `${HorizontalBarChart.className}__chart`,
4416
+ ref: chartRef
4417
+ }), caption ? /*#__PURE__*/React.createElement(StyledHorizontalBarChartCaption, {
4418
+ className: `${HorizontalBarChart.className}__caption`,
4419
+ id: `id${id}__caption`
4420
+ }, caption) : null);
4421
+ });
4422
+ HorizontalBarChart.className = CLASSNAME$2;
4423
+ HorizontalBarChart.defaultProps = DEFAULT_PROPS$1;
4424
+ HorizontalBarChart.displayName = COMPONENT_NAME$2;
4425
+
4426
+ /**
4427
+ * Component style.
4428
+ */
4429
+ const StyledEmptyChart = styled.div`
4430
+ display: flex;
4431
+ flex-direction: column;
4432
+ justify-content: center;
4433
+ align-items: center;
4434
+ width: 100%;
4435
+ height: 100%;
4436
+
4437
+ .redsift-emptychart-container__img {
4438
+ display: flex;
4439
+ align-items: center;
4440
+ height: 180px;
4441
+ }
4442
+
4443
+ .redsift-emptychart__img {
4444
+ position: relative;
4445
+ width: 150px;
4446
+ height: 150px;
4447
+ border-radius: 150px;
4448
+ background: blueviolet;
4449
+ }
4450
+
4451
+ .redsift-emptychart__title {
4452
+ font-family: var(--redsift-typography-h4-font-family);
4453
+ font-size: var(--redsift-typography-h4-font-size);
4454
+ font-weight: var(--redsift-typography-h4-font-weight);
4455
+ line-height: var(--redsift-typography-h4-line-height);
4456
+ }
4457
+
4458
+ .redsift-emptychart__subtitle {
4459
+ font-family: var(--redsift-typography-body-font-family);
4460
+ font-size: var(--redsift-typography-body-font-size);
4461
+ font-weight: var(--redsift-typography-body-font-weight);
4462
+ line-height: var(--redsift-typography-body-line-height);
4463
+ margin-top: 8px;
4464
+ text-align: center;
4465
+ }
4466
+ `;
4467
+ const StyledResetButton = styled(Button)`
4468
+ margin-top: 8px;
4469
+ `;
4470
+ styled.img`
4471
+ max-width: 80%;
4472
+ `;
4473
+
4474
+ const COMPONENT_NAME$1 = 'RedSiftEmptyChart';
4475
+ const CLASSNAME$1 = 'redsift-emptychart';
4476
+ const EmptyChart = /*#__PURE__*/forwardRef((props, ref) => {
4477
+ const {
4478
+ resetButtonLabel,
4479
+ subtitle,
4480
+ title
4481
+ } = props;
4482
+ return /*#__PURE__*/React.createElement(StyledEmptyChart, {
4483
+ ref: ref,
4484
+ className: "redsift-emptychart"
4485
+ }, /*#__PURE__*/React.createElement("div", {
4486
+ className: `${EmptyChart.className}-container__img`
4487
+ }, /*#__PURE__*/React.createElement("div", {
4488
+ className: `${EmptyChart.className}__img`
4489
+ })), /*#__PURE__*/React.createElement("div", {
4490
+ className: `${EmptyChart.className}__title`
4491
+ }, title), subtitle ? /*#__PURE__*/React.createElement("div", {
4492
+ className: `${EmptyChart.className}__subtitle`
4493
+ }, subtitle) : null, resetButtonLabel ? /*#__PURE__*/React.createElement(StyledResetButton, {
4494
+ variant: "text",
4495
+ size: "small",
4496
+ color: "primary",
4497
+ leftIcon: mdiRefresh,
4498
+ onPress: () => {
4499
+ filterAll();
4500
+ redrawAll();
4501
+ }
4502
+ }, resetButtonLabel) : null);
4503
+ });
4504
+ EmptyChart.className = CLASSNAME$1;
4505
+ EmptyChart.displayName = COMPONENT_NAME$1;
4506
+
4507
+ /**
4508
+ * Component style.
4509
+ */
4510
+ const StyledPieChart = styled.div`
4511
+ margin: 8px;
4512
+ padding: 8px;
4513
+ color: var(--redsift-color-text-primary);
4514
+
4515
+ .redsift-piechart__title {
4516
+ display: flex;
4517
+ flex-direction: row;
4518
+ align-items: center;
4519
+ gap: 16px;
4520
+ }
4521
+
4522
+ ${_ref => {
4523
+ let {
4524
+ $showLabels
4525
+ } = _ref;
4526
+ return !$showLabels ? css`
4527
+ g.pie-label-group text {
4528
+ display: none;
4529
+ }
4530
+ ` : '';
4531
+ }}
4532
+
4533
+ g.pie-slice {
4534
+ text {
4535
+ cursor: pointer;
4536
+ }
4537
+
4538
+ path {
4539
+ cursor: pointer;
4540
+ ${_ref2 => {
4541
+ let {
4542
+ $spaced
4543
+ } = _ref2;
4544
+ return $spaced ? css`
4545
+ stroke-width: 2px;
4546
+ stroke: #fff;
4547
+ ` : '';
4548
+ }}
4549
+ }
4550
+ }
4551
+
4552
+ g.pie-slice.deselected {
4553
+ path {
4554
+ fill-opacity: 0.5;
4555
+ fill: var(--redsift-color-text-disabled);
4556
+ }
4557
+ }
4558
+
4559
+ g.pie-slice.focused,
4560
+ g.pie-slice:hover {
4561
+ path {
4562
+ fill-opacity: 0.8;
4563
+ }
4564
+ }
4565
+
4566
+ g.pie-slice.deselected.focused {
4567
+ path {
4568
+ fill-opacity: 0.3;
4569
+ }
4570
+ }
4571
+
4572
+ svg:hover,
4573
+ svg:focus {
4574
+ outline: none;
4575
+ }
4576
+
4577
+ svg:focus-visible {
4578
+ outline: auto;
4579
+ }
4580
+ `;
4581
+ const StyledPieChartContainer = styled.div`
4582
+ display: flex;
4583
+ align-items: center;
4584
+ gap: 16px;
4585
+ font-family: var(--redsift-typography-font-family-source-code-pro);
4586
+ font-size: 11px;
4587
+ justify-content: center;
4588
+ margin: 8px 0;
4589
+ position: relative;
4590
+
4591
+ .redsift-piechart-container__chart {
4592
+ position: relative;
4593
+ ${_ref3 => {
4594
+ let {
4595
+ $isEmpty
4596
+ } = _ref3;
4597
+ return $isEmpty ? css`
4598
+ display: none;
4599
+ ` : '';
4600
+ }};
4601
+ }
4602
+ `;
4603
+
4604
+ const _excluded = ["caping", "caption", "className", "columnToFilter", "data", "isResetable", "labelVariant", "dimension", "group", "localeText", "others", "size", "subtext", "text", "theme", "title", "variant"];
4605
+ const COMPONENT_NAME = 'RedSiftPieChart';
4606
+ const CLASSNAME = 'redsift-piechart';
4607
+ const DEFAULT_PROPS = {
4608
+ isResetable: true,
4609
+ labelVariant: PieChartLabelVariant.internal,
4610
+ localeText: {
4611
+ emptyChartTitle: 'No Data Available',
4612
+ emptyChartSubtitle: 'Please check the applied filters',
4613
+ emptyChartResetLabel: 'Reset all filters',
4614
+ resetLabel: 'Reset'
4615
+ },
4616
+ others: true,
4617
+ size: PieChartSize.medium,
4618
+ theme: PieChartTheme.default,
4619
+ title: 'Pie Chart',
4620
+ variant: PieChartVariant.plain
4621
+ };
4622
+ const sizeToDimension = size => {
4623
+ switch (size) {
4624
+ case PieChartSize.small:
4625
+ return {
4626
+ width: 200,
4627
+ height: 200
4628
+ };
4629
+ case PieChartSize.large:
4630
+ return {
4631
+ width: 300,
4632
+ height: 300
4633
+ };
4634
+ case PieChartSize.medium:
4635
+ default:
4636
+ return {
4637
+ width: 250,
4638
+ height: 250
4639
+ };
4640
+ }
4641
+ };
4642
+ const sizeToInnerRadius = size => {
4643
+ switch (size) {
4644
+ case PieChartSize.small:
4645
+ return 50;
4646
+ case PieChartSize.large:
4647
+ return 75;
4648
+ case PieChartSize.medium:
4649
+ default:
4650
+ return 66;
4651
+ }
4652
+ };
4653
+ const PieChart = /*#__PURE__*/forwardRef((props, ref) => {
4654
+ const chartRef = useRef();
4655
+ const id = useId();
4656
+ const [chart, setChart] = useState();
4657
+ const [groups, setGroups] = useState();
4658
+ const [dimensions, setDimensions] = useState();
4659
+ const {
4660
+ caping,
4661
+ caption,
4662
+ className,
4663
+ columnToFilter,
4664
+ data,
4665
+ isResetable,
4666
+ labelVariant,
4667
+ dimension,
4668
+ group,
4669
+ localeText,
4670
+ others,
4671
+ size,
4672
+ subtext,
4673
+ text,
4674
+ theme,
4675
+ title,
4676
+ variant
4677
+ } = props,
4678
+ forwardedProps = _objectWithoutProperties(props, _excluded);
4679
+
4680
+ // Get overriden labels and texts.
4681
+ const {
4682
+ emptyChartTitle,
4683
+ emptyChartSubtitle,
4684
+ emptyChartResetLabel,
4685
+ resetLabel
4686
+ } = _objectSpread2(_objectSpread2({}, DEFAULT_PROPS.localeText), localeText);
4687
+
4688
+ // Get charts dimensions based on the selected size.
4689
+ const chartDimensions = sizeToDimension(size);
4690
+ const externalRadiusPadding = 8;
4691
+ const innerRadius = sizeToInnerRadius(size);
4692
+
4693
+ // Get ndx from context or initialize it.
4694
+ const {
4695
+ ndx = crossfilter(data),
4696
+ dispatch,
4697
+ state
4698
+ } = useContext(DashboardContext);
4699
+ const {
4700
+ tableFilters
4701
+ } = state;
4702
+
4703
+ // Set color scheme.
4704
+ let d3colors = ordinal(scheme.default);
4705
+ if (typeof theme === 'string') {
4706
+ d3colors = ordinal(scheme[theme]);
4707
+ } else if (typeof theme === 'object') {
4708
+ d3colors = ordinal().domain([theme.success, theme.warning, theme.danger]).range([successDangerScheme.success, successDangerScheme.warning, successDangerScheme.danger]).unknown(neutral);
4709
+ }
4710
+
4711
+ // useEffect called only once to initialize the chart.
4712
+ useEffect(() => {
4713
+ if (chartRef.current) {
4714
+ config.defaultColors(scheme.default);
4715
+ const pieChart$1 = pieChart(chartRef.current);
4716
+
4717
+ // Compute dimension and group.
4718
+ const computedDimension = ndx.dimension(dimension);
4719
+ const computedGroup = group(computedDimension.group());
4720
+
4721
+ // Initialize the chart.
4722
+ pieChart$1.width(chartDimensions.width).height(chartDimensions.height).dimension(computedDimension).group(computedGroup).externalRadiusPadding(externalRadiusPadding).innerRadius(variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut ? innerRadius : 0).colors(d3colors);
4723
+ if (caping) {
4724
+ pieChart$1.cap(caping);
4725
+ if (others && typeof others === 'string') {
4726
+ pieChart$1.othersLabel(others);
4727
+ } else if (!others) {
4728
+ pieChart$1.othersGrouper(d => d);
4729
+ }
4730
+ }
4731
+
4732
+ // Dispatch filters to datagrid when a value is selected or unselected.
4733
+ if (columnToFilter) {
4734
+ pieChart$1.on('filtered', () => {
4735
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch({
4736
+ type: DashboardReducerActionType.FilterTable,
4737
+ filter: {
4738
+ id: pieChart$1.anchorName(),
4739
+ columnField: columnToFilter,
4740
+ operatorValue: 'isAnyOf',
4741
+ value: pieChart$1.filters()
4742
+ }
4743
+ });
4744
+ });
4745
+ }
4746
+
4747
+ // Render the chart.
4748
+ pieChart$1.render();
4749
+
4750
+ // Store chart and number of groups for further use.
4751
+ setChart(pieChart$1);
4752
+ setDimensions(computedDimension);
4753
+ setGroups(computedGroup);
4754
+ }
4755
+ }, []);
4756
+
4757
+ // Filter chart if context is updated by an external component.
4758
+ const filter = tableFilters.find(filter => filter.columnField === columnToFilter && filter.operatorValue === 'isAnyOf');
4759
+ useEffect(() => {
4760
+ if (chart && filter && filter.value && chart.filters() !== filter.value) {
4761
+ const filterValues = filter.value.map(val => {
4762
+ var _groups$all$find;
4763
+ const value = groups === null || groups === void 0 ? void 0 : (_groups$all$find = groups.all().find(_ref => {
4764
+ let {
4765
+ key
4766
+ } = _ref;
4767
+ return key.toLowerCase() === val.toLowerCase();
4768
+ })) === null || _groups$all$find === void 0 ? void 0 : _groups$all$find.key;
4769
+ if (value) {
4770
+ return value;
4771
+ }
4772
+ return val;
4773
+ });
4774
+ if (filterValues) {
4775
+ chart.filter(null);
4776
+ chart.filter([filterValues]);
4777
+ redrawAll();
4778
+ }
4779
+ }
4780
+ }, [filter]);
4781
+
4782
+ // Apply Listbox a11y pattern to the generated dc.js chart.
4783
+ useChartAsListbox({
4784
+ id,
4785
+ querySelector: 'g.pie-slice',
4786
+ numberOfGroups: groups === null || groups === void 0 ? void 0 : groups.size(),
4787
+ chartRef: chartRef.current,
4788
+ chart: chart
4789
+ });
4790
+ return /*#__PURE__*/React.createElement(StyledPieChart, _extends({}, forwardedProps, {
4791
+ id: id,
4792
+ className: classNames(PieChart.className, className),
4793
+ ref: ref,
4794
+ $spaced: variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut,
4795
+ $showLabels: labelVariant === PieChartLabelVariant.internal
4796
+ }), /*#__PURE__*/React.createElement(StyledPieChartTitle, {
4797
+ className: `${PieChart.className}__title`,
4798
+ id: `id${id}__title`
4799
+ }, title, chart && isResetable ? /*#__PURE__*/React.createElement(ResetButton, {
4800
+ chart: chart
4801
+ }, resetLabel) : null), /*#__PURE__*/React.createElement(StyledPieChartContainer, {
4802
+ className: `${PieChart.className}__container`,
4803
+ $isEmpty: (dimensions === null || dimensions === void 0 ? void 0 : dimensions.top(1).length) === 0
4804
+ }, /*#__PURE__*/React.createElement("div", {
4805
+ className: `${PieChart.className}-container__chart`,
4806
+ ref: chartRef
4807
+ }, text ? /*#__PURE__*/React.createElement(StyledPieChartCenterText, {
4808
+ $maxWidth: innerRadius * 2
4809
+ }, /*#__PURE__*/React.createElement("b", null, text), /*#__PURE__*/React.createElement("span", null, subtext)) : null), (dimensions === null || dimensions === void 0 ? void 0 : dimensions.top(1).length) === 0 ? /*#__PURE__*/React.createElement(EmptyChart, {
4810
+ title: emptyChartTitle,
4811
+ subtitle: emptyChartSubtitle,
4812
+ resetButtonLabel: emptyChartResetLabel
4813
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, labelVariant !== PieChartLabelVariant.none && labelVariant !== PieChartLabelVariant.internal ? /*#__PURE__*/React.createElement("ul", null, chart === null || chart === void 0 ? void 0 : chart.data().map((_ref2, index) => {
4814
+ let {
4815
+ key,
4816
+ value
4817
+ } = _ref2;
4818
+ return /*#__PURE__*/React.createElement(StyledPieChartLabel, {
4819
+ key: `pie-external-label _${index}`,
4820
+ $color: d3colors(key)
4821
+ }, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("span", null, key), labelVariant === PieChartLabelVariant.externalLabelValue ? /*#__PURE__*/React.createElement("b", null, value) : labelVariant === PieChartLabelVariant.externalLabelPercent ? /*#__PURE__*/React.createElement("b", null, `${(value * 100 / sum(chart.data(), d => d.value)).toFixed(2)}%`) : null);
4822
+ })) : null)), caption ? /*#__PURE__*/React.createElement(StyledPieChartCaption, {
4823
+ className: `${PieChart.className}__caption`,
4824
+ id: `id${id}__caption`
4825
+ }, caption) : null);
4826
+ });
4827
+ PieChart.className = CLASSNAME;
4828
+ PieChart.defaultProps = DEFAULT_PROPS;
4829
+ PieChart.displayName = COMPONENT_NAME;
4830
+
4831
+ export { Dashboard, DashboardContext, DashboardReducer, DashboardReducerActionType, DataGrid, HorizontalBarChart, HorizontalBarChartSize, HorizontalBarChartTheme, PieChart, initialState };
4832
+ //# sourceMappingURL=index.js.map