react-tooltip 5.10.1-beta-7 → 5.10.1-beta-9

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.
@@ -0,0 +1,3097 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactTooltip = {}, global.React));
5
+ })(this, (function (exports, require$$0) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
10
+
11
+ var jsxRuntime = {exports: {}};
12
+
13
+ var reactJsxRuntime_development = {};
14
+
15
+ /** @license React v16.14.0
16
+ * react-jsx-runtime.development.js
17
+ *
18
+ * Copyright (c) Facebook, Inc. and its affiliates.
19
+ *
20
+ * This source code is licensed under the MIT license found in the
21
+ * LICENSE file in the root directory of this source tree.
22
+ */
23
+
24
+ (function (exports) {
25
+
26
+ {
27
+ (function() {
28
+
29
+ var React = require$$0__default["default"];
30
+
31
+ // ATTENTION
32
+ // When adding new symbols to this file,
33
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
34
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
35
+ // nor polyfill, then a plain number is used for performance.
36
+ var REACT_ELEMENT_TYPE = 0xeac7;
37
+ var REACT_PORTAL_TYPE = 0xeaca;
38
+ exports.Fragment = 0xeacb;
39
+ var REACT_STRICT_MODE_TYPE = 0xeacc;
40
+ var REACT_PROFILER_TYPE = 0xead2;
41
+ var REACT_PROVIDER_TYPE = 0xeacd;
42
+ var REACT_CONTEXT_TYPE = 0xeace;
43
+ var REACT_FORWARD_REF_TYPE = 0xead0;
44
+ var REACT_SUSPENSE_TYPE = 0xead1;
45
+ var REACT_SUSPENSE_LIST_TYPE = 0xead8;
46
+ var REACT_MEMO_TYPE = 0xead3;
47
+ var REACT_LAZY_TYPE = 0xead4;
48
+ var REACT_BLOCK_TYPE = 0xead9;
49
+ var REACT_SERVER_BLOCK_TYPE = 0xeada;
50
+ var REACT_FUNDAMENTAL_TYPE = 0xead5;
51
+ var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
52
+ var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
53
+
54
+ if (typeof Symbol === 'function' && Symbol.for) {
55
+ var symbolFor = Symbol.for;
56
+ REACT_ELEMENT_TYPE = symbolFor('react.element');
57
+ REACT_PORTAL_TYPE = symbolFor('react.portal');
58
+ exports.Fragment = symbolFor('react.fragment');
59
+ REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
60
+ REACT_PROFILER_TYPE = symbolFor('react.profiler');
61
+ REACT_PROVIDER_TYPE = symbolFor('react.provider');
62
+ REACT_CONTEXT_TYPE = symbolFor('react.context');
63
+ REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
64
+ REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
65
+ REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
66
+ REACT_MEMO_TYPE = symbolFor('react.memo');
67
+ REACT_LAZY_TYPE = symbolFor('react.lazy');
68
+ REACT_BLOCK_TYPE = symbolFor('react.block');
69
+ REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
70
+ REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
71
+ symbolFor('react.scope');
72
+ symbolFor('react.opaque.id');
73
+ REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
74
+ symbolFor('react.offscreen');
75
+ REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
76
+ }
77
+
78
+ var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
79
+ var FAUX_ITERATOR_SYMBOL = '@@iterator';
80
+ function getIteratorFn(maybeIterable) {
81
+ if (maybeIterable === null || typeof maybeIterable !== 'object') {
82
+ return null;
83
+ }
84
+
85
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
86
+
87
+ if (typeof maybeIterator === 'function') {
88
+ return maybeIterator;
89
+ }
90
+
91
+ return null;
92
+ }
93
+
94
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
95
+
96
+ function error(format) {
97
+ {
98
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
99
+ args[_key2 - 1] = arguments[_key2];
100
+ }
101
+
102
+ printWarning('error', format, args);
103
+ }
104
+ }
105
+
106
+ function printWarning(level, format, args) {
107
+ // When changing this logic, you might want to also
108
+ // update consoleWithStackDev.www.js as well.
109
+ {
110
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
111
+ var stack = '';
112
+
113
+ if (currentlyValidatingElement) {
114
+ var name = getComponentName(currentlyValidatingElement.type);
115
+ var owner = currentlyValidatingElement._owner;
116
+ stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
117
+ }
118
+
119
+ stack += ReactDebugCurrentFrame.getStackAddendum();
120
+
121
+ if (stack !== '') {
122
+ format += '%s';
123
+ args = args.concat([stack]);
124
+ }
125
+
126
+ var argsWithFormat = args.map(function (item) {
127
+ return '' + item;
128
+ }); // Careful: RN currently depends on this prefix
129
+
130
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
131
+ // breaks IE9: https://github.com/facebook/react/issues/13610
132
+ // eslint-disable-next-line react-internal/no-production-logging
133
+
134
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
135
+ }
136
+ }
137
+
138
+ // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
139
+
140
+ var enableScopeAPI = false; // Experimental Create Event Handle API.
141
+
142
+ function isValidElementType(type) {
143
+ if (typeof type === 'string' || typeof type === 'function') {
144
+ return true;
145
+ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
146
+
147
+
148
+ if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
149
+ return true;
150
+ }
151
+
152
+ if (typeof type === 'object' && type !== null) {
153
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
154
+ return true;
155
+ }
156
+ }
157
+
158
+ return false;
159
+ }
160
+
161
+
162
+ var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
163
+ function describeComponentFrame (name, source, ownerName) {
164
+ var sourceInfo = '';
165
+
166
+ if (source) {
167
+ var path = source.fileName;
168
+ var fileName = path.replace(BEFORE_SLASH_RE, '');
169
+
170
+ {
171
+ // In DEV, include code for a common special case:
172
+ // prefer "folder/index.js" instead of just "index.js".
173
+ if (/^index\./.test(fileName)) {
174
+ var match = path.match(BEFORE_SLASH_RE);
175
+
176
+ if (match) {
177
+ var pathBeforeSlash = match[1];
178
+
179
+ if (pathBeforeSlash) {
180
+ var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
181
+ fileName = folderName + '/' + fileName;
182
+ }
183
+ }
184
+ }
185
+ }
186
+
187
+ sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
188
+ } else if (ownerName) {
189
+ sourceInfo = ' (created by ' + ownerName + ')';
190
+ }
191
+
192
+ return '\n in ' + (name || 'Unknown') + sourceInfo;
193
+ }
194
+
195
+ var Resolved = 1;
196
+ function refineResolvedLazyComponent(lazyComponent) {
197
+ return lazyComponent._status === Resolved ? lazyComponent._result : null;
198
+ }
199
+
200
+ function getWrappedName(outerType, innerType, wrapperName) {
201
+ var functionName = innerType.displayName || innerType.name || '';
202
+ return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
203
+ }
204
+
205
+ function getComponentName(type) {
206
+ if (type == null) {
207
+ // Host root, text node or just invalid type.
208
+ return null;
209
+ }
210
+
211
+ {
212
+ if (typeof type.tag === 'number') {
213
+ error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
214
+ }
215
+ }
216
+
217
+ if (typeof type === 'function') {
218
+ return type.displayName || type.name || null;
219
+ }
220
+
221
+ if (typeof type === 'string') {
222
+ return type;
223
+ }
224
+
225
+ switch (type) {
226
+ case exports.Fragment:
227
+ return 'Fragment';
228
+
229
+ case REACT_PORTAL_TYPE:
230
+ return 'Portal';
231
+
232
+ case REACT_PROFILER_TYPE:
233
+ return "Profiler";
234
+
235
+ case REACT_STRICT_MODE_TYPE:
236
+ return 'StrictMode';
237
+
238
+ case REACT_SUSPENSE_TYPE:
239
+ return 'Suspense';
240
+
241
+ case REACT_SUSPENSE_LIST_TYPE:
242
+ return 'SuspenseList';
243
+ }
244
+
245
+ if (typeof type === 'object') {
246
+ switch (type.$$typeof) {
247
+ case REACT_CONTEXT_TYPE:
248
+ return 'Context.Consumer';
249
+
250
+ case REACT_PROVIDER_TYPE:
251
+ return 'Context.Provider';
252
+
253
+ case REACT_FORWARD_REF_TYPE:
254
+ return getWrappedName(type, type.render, 'ForwardRef');
255
+
256
+ case REACT_MEMO_TYPE:
257
+ return getComponentName(type.type);
258
+
259
+ case REACT_BLOCK_TYPE:
260
+ return getComponentName(type.render);
261
+
262
+ case REACT_LAZY_TYPE:
263
+ {
264
+ var thenable = type;
265
+ var resolvedThenable = refineResolvedLazyComponent(thenable);
266
+
267
+ if (resolvedThenable) {
268
+ return getComponentName(resolvedThenable);
269
+ }
270
+
271
+ break;
272
+ }
273
+ }
274
+ }
275
+
276
+ return null;
277
+ }
278
+
279
+ var loggedTypeFailures = {};
280
+ ReactSharedInternals.ReactDebugCurrentFrame;
281
+ var currentlyValidatingElement = null;
282
+
283
+ function setCurrentlyValidatingElement(element) {
284
+ {
285
+ currentlyValidatingElement = element;
286
+ }
287
+ }
288
+
289
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
290
+ {
291
+ // $FlowFixMe This is okay but Flow doesn't know it.
292
+ var has = Function.call.bind(Object.prototype.hasOwnProperty);
293
+
294
+ for (var typeSpecName in typeSpecs) {
295
+ if (has(typeSpecs, typeSpecName)) {
296
+ var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
297
+ // fail the render phase where it didn't fail before. So we log it.
298
+ // After these have been cleaned up, we'll let them throw.
299
+
300
+ try {
301
+ // This is intentionally an invariant that gets caught. It's the same
302
+ // behavior as without this statement except with a better message.
303
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
304
+ var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
305
+ err.name = 'Invariant Violation';
306
+ throw err;
307
+ }
308
+
309
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
310
+ } catch (ex) {
311
+ error$1 = ex;
312
+ }
313
+
314
+ if (error$1 && !(error$1 instanceof Error)) {
315
+ setCurrentlyValidatingElement(element);
316
+
317
+ error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
318
+
319
+ setCurrentlyValidatingElement(null);
320
+ }
321
+
322
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
323
+ // Only monitor this failure once because there tends to be a lot of the
324
+ // same error.
325
+ loggedTypeFailures[error$1.message] = true;
326
+ setCurrentlyValidatingElement(element);
327
+
328
+ error('Failed %s type: %s', location, error$1.message);
329
+
330
+ setCurrentlyValidatingElement(null);
331
+ }
332
+ }
333
+ }
334
+ }
335
+ }
336
+
337
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
338
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
339
+ var RESERVED_PROPS = {
340
+ key: true,
341
+ ref: true,
342
+ __self: true,
343
+ __source: true
344
+ };
345
+ var specialPropKeyWarningShown;
346
+ var specialPropRefWarningShown;
347
+ var didWarnAboutStringRefs;
348
+
349
+ {
350
+ didWarnAboutStringRefs = {};
351
+ }
352
+
353
+ function hasValidRef(config) {
354
+ {
355
+ if (hasOwnProperty.call(config, 'ref')) {
356
+ var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
357
+
358
+ if (getter && getter.isReactWarning) {
359
+ return false;
360
+ }
361
+ }
362
+ }
363
+
364
+ return config.ref !== undefined;
365
+ }
366
+
367
+ function hasValidKey(config) {
368
+ {
369
+ if (hasOwnProperty.call(config, 'key')) {
370
+ var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
371
+
372
+ if (getter && getter.isReactWarning) {
373
+ return false;
374
+ }
375
+ }
376
+ }
377
+
378
+ return config.key !== undefined;
379
+ }
380
+
381
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
382
+ {
383
+ if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
384
+ var componentName = getComponentName(ReactCurrentOwner.current.type);
385
+
386
+ if (!didWarnAboutStringRefs[componentName]) {
387
+ error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
388
+
389
+ didWarnAboutStringRefs[componentName] = true;
390
+ }
391
+ }
392
+ }
393
+ }
394
+
395
+ function defineKeyPropWarningGetter(props, displayName) {
396
+ {
397
+ var warnAboutAccessingKey = function () {
398
+ if (!specialPropKeyWarningShown) {
399
+ specialPropKeyWarningShown = true;
400
+
401
+ error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
402
+ }
403
+ };
404
+
405
+ warnAboutAccessingKey.isReactWarning = true;
406
+ Object.defineProperty(props, 'key', {
407
+ get: warnAboutAccessingKey,
408
+ configurable: true
409
+ });
410
+ }
411
+ }
412
+
413
+ function defineRefPropWarningGetter(props, displayName) {
414
+ {
415
+ var warnAboutAccessingRef = function () {
416
+ if (!specialPropRefWarningShown) {
417
+ specialPropRefWarningShown = true;
418
+
419
+ error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
420
+ }
421
+ };
422
+
423
+ warnAboutAccessingRef.isReactWarning = true;
424
+ Object.defineProperty(props, 'ref', {
425
+ get: warnAboutAccessingRef,
426
+ configurable: true
427
+ });
428
+ }
429
+ }
430
+ /**
431
+ * Factory method to create a new React element. This no longer adheres to
432
+ * the class pattern, so do not use new to call it. Also, instanceof check
433
+ * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
434
+ * if something is a React Element.
435
+ *
436
+ * @param {*} type
437
+ * @param {*} props
438
+ * @param {*} key
439
+ * @param {string|object} ref
440
+ * @param {*} owner
441
+ * @param {*} self A *temporary* helper to detect places where `this` is
442
+ * different from the `owner` when React.createElement is called, so that we
443
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
444
+ * functions, and as long as `this` and owner are the same, there will be no
445
+ * change in behavior.
446
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
447
+ * indicating filename, line number, and/or other information.
448
+ * @internal
449
+ */
450
+
451
+
452
+ var ReactElement = function (type, key, ref, self, source, owner, props) {
453
+ var element = {
454
+ // This tag allows us to uniquely identify this as a React Element
455
+ $$typeof: REACT_ELEMENT_TYPE,
456
+ // Built-in properties that belong on the element
457
+ type: type,
458
+ key: key,
459
+ ref: ref,
460
+ props: props,
461
+ // Record the component responsible for creating this element.
462
+ _owner: owner
463
+ };
464
+
465
+ {
466
+ // The validation flag is currently mutative. We put it on
467
+ // an external backing store so that we can freeze the whole object.
468
+ // This can be replaced with a WeakMap once they are implemented in
469
+ // commonly used development environments.
470
+ element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
471
+ // the validation flag non-enumerable (where possible, which should
472
+ // include every environment we run tests in), so the test framework
473
+ // ignores it.
474
+
475
+ Object.defineProperty(element._store, 'validated', {
476
+ configurable: false,
477
+ enumerable: false,
478
+ writable: true,
479
+ value: false
480
+ }); // self and source are DEV only properties.
481
+
482
+ Object.defineProperty(element, '_self', {
483
+ configurable: false,
484
+ enumerable: false,
485
+ writable: false,
486
+ value: self
487
+ }); // Two elements created in two different places should be considered
488
+ // equal for testing purposes and therefore we hide it from enumeration.
489
+
490
+ Object.defineProperty(element, '_source', {
491
+ configurable: false,
492
+ enumerable: false,
493
+ writable: false,
494
+ value: source
495
+ });
496
+
497
+ if (Object.freeze) {
498
+ Object.freeze(element.props);
499
+ Object.freeze(element);
500
+ }
501
+ }
502
+
503
+ return element;
504
+ };
505
+ /**
506
+ * https://github.com/reactjs/rfcs/pull/107
507
+ * @param {*} type
508
+ * @param {object} props
509
+ * @param {string} key
510
+ */
511
+
512
+ function jsxDEV(type, config, maybeKey, source, self) {
513
+ {
514
+ var propName; // Reserved names are extracted
515
+
516
+ var props = {};
517
+ var key = null;
518
+ var ref = null; // Currently, key can be spread in as a prop. This causes a potential
519
+ // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
520
+ // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
521
+ // but as an intermediary step, we will use jsxDEV for everything except
522
+ // <div {...props} key="Hi" />, because we aren't currently able to tell if
523
+ // key is explicitly declared to be undefined or not.
524
+
525
+ if (maybeKey !== undefined) {
526
+ key = '' + maybeKey;
527
+ }
528
+
529
+ if (hasValidKey(config)) {
530
+ key = '' + config.key;
531
+ }
532
+
533
+ if (hasValidRef(config)) {
534
+ ref = config.ref;
535
+ warnIfStringRefCannotBeAutoConverted(config, self);
536
+ } // Remaining properties are added to a new props object
537
+
538
+
539
+ for (propName in config) {
540
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
541
+ props[propName] = config[propName];
542
+ }
543
+ } // Resolve default props
544
+
545
+
546
+ if (type && type.defaultProps) {
547
+ var defaultProps = type.defaultProps;
548
+
549
+ for (propName in defaultProps) {
550
+ if (props[propName] === undefined) {
551
+ props[propName] = defaultProps[propName];
552
+ }
553
+ }
554
+ }
555
+
556
+ if (key || ref) {
557
+ var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
558
+
559
+ if (key) {
560
+ defineKeyPropWarningGetter(props, displayName);
561
+ }
562
+
563
+ if (ref) {
564
+ defineRefPropWarningGetter(props, displayName);
565
+ }
566
+ }
567
+
568
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
569
+ }
570
+ }
571
+
572
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
573
+ ReactSharedInternals.ReactDebugCurrentFrame;
574
+
575
+ function setCurrentlyValidatingElement$1(element) {
576
+ currentlyValidatingElement = element;
577
+ }
578
+
579
+ var propTypesMisspellWarningShown;
580
+
581
+ {
582
+ propTypesMisspellWarningShown = false;
583
+ }
584
+ /**
585
+ * Verifies the object is a ReactElement.
586
+ * See https://reactjs.org/docs/react-api.html#isvalidelement
587
+ * @param {?object} object
588
+ * @return {boolean} True if `object` is a ReactElement.
589
+ * @final
590
+ */
591
+
592
+ function isValidElement(object) {
593
+ {
594
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
595
+ }
596
+ }
597
+
598
+ function getDeclarationErrorAddendum() {
599
+ {
600
+ if (ReactCurrentOwner$1.current) {
601
+ var name = getComponentName(ReactCurrentOwner$1.current.type);
602
+
603
+ if (name) {
604
+ return '\n\nCheck the render method of `' + name + '`.';
605
+ }
606
+ }
607
+
608
+ return '';
609
+ }
610
+ }
611
+
612
+ function getSourceInfoErrorAddendum(source) {
613
+ {
614
+ if (source !== undefined) {
615
+ var fileName = source.fileName.replace(/^.*[\\\/]/, '');
616
+ var lineNumber = source.lineNumber;
617
+ return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
618
+ }
619
+
620
+ return '';
621
+ }
622
+ }
623
+ /**
624
+ * Warn if there's no key explicitly set on dynamic arrays of children or
625
+ * object keys are not valid. This allows us to keep track of children between
626
+ * updates.
627
+ */
628
+
629
+
630
+ var ownerHasKeyUseWarning = {};
631
+
632
+ function getCurrentComponentErrorInfo(parentType) {
633
+ {
634
+ var info = getDeclarationErrorAddendum();
635
+
636
+ if (!info) {
637
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
638
+
639
+ if (parentName) {
640
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
641
+ }
642
+ }
643
+
644
+ return info;
645
+ }
646
+ }
647
+ /**
648
+ * Warn if the element doesn't have an explicit key assigned to it.
649
+ * This element is in an array. The array could grow and shrink or be
650
+ * reordered. All children that haven't already been validated are required to
651
+ * have a "key" property assigned to it. Error statuses are cached so a warning
652
+ * will only be shown once.
653
+ *
654
+ * @internal
655
+ * @param {ReactElement} element Element that requires a key.
656
+ * @param {*} parentType element's parent's type.
657
+ */
658
+
659
+
660
+ function validateExplicitKey(element, parentType) {
661
+ {
662
+ if (!element._store || element._store.validated || element.key != null) {
663
+ return;
664
+ }
665
+
666
+ element._store.validated = true;
667
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
668
+
669
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
670
+ return;
671
+ }
672
+
673
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
674
+ // property, it may be the creator of the child that's responsible for
675
+ // assigning it a key.
676
+
677
+ var childOwner = '';
678
+
679
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
680
+ // Give the component that originally created this child.
681
+ childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
682
+ }
683
+
684
+ setCurrentlyValidatingElement$1(element);
685
+
686
+ error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
687
+
688
+ setCurrentlyValidatingElement$1(null);
689
+ }
690
+ }
691
+ /**
692
+ * Ensure that every element either is passed in a static location, in an
693
+ * array with an explicit keys property defined, or in an object literal
694
+ * with valid key property.
695
+ *
696
+ * @internal
697
+ * @param {ReactNode} node Statically passed child of any type.
698
+ * @param {*} parentType node's parent's type.
699
+ */
700
+
701
+
702
+ function validateChildKeys(node, parentType) {
703
+ {
704
+ if (typeof node !== 'object') {
705
+ return;
706
+ }
707
+
708
+ if (Array.isArray(node)) {
709
+ for (var i = 0; i < node.length; i++) {
710
+ var child = node[i];
711
+
712
+ if (isValidElement(child)) {
713
+ validateExplicitKey(child, parentType);
714
+ }
715
+ }
716
+ } else if (isValidElement(node)) {
717
+ // This element was passed in a valid location.
718
+ if (node._store) {
719
+ node._store.validated = true;
720
+ }
721
+ } else if (node) {
722
+ var iteratorFn = getIteratorFn(node);
723
+
724
+ if (typeof iteratorFn === 'function') {
725
+ // Entry iterators used to provide implicit keys,
726
+ // but now we print a separate warning for them later.
727
+ if (iteratorFn !== node.entries) {
728
+ var iterator = iteratorFn.call(node);
729
+ var step;
730
+
731
+ while (!(step = iterator.next()).done) {
732
+ if (isValidElement(step.value)) {
733
+ validateExplicitKey(step.value, parentType);
734
+ }
735
+ }
736
+ }
737
+ }
738
+ }
739
+ }
740
+ }
741
+ /**
742
+ * Given an element, validate that its props follow the propTypes definition,
743
+ * provided by the type.
744
+ *
745
+ * @param {ReactElement} element
746
+ */
747
+
748
+
749
+ function validatePropTypes(element) {
750
+ {
751
+ var type = element.type;
752
+
753
+ if (type === null || type === undefined || typeof type === 'string') {
754
+ return;
755
+ }
756
+
757
+ var propTypes;
758
+
759
+ if (typeof type === 'function') {
760
+ propTypes = type.propTypes;
761
+ } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
762
+ // Inner props are checked in the reconciler.
763
+ type.$$typeof === REACT_MEMO_TYPE)) {
764
+ propTypes = type.propTypes;
765
+ } else {
766
+ return;
767
+ }
768
+
769
+ if (propTypes) {
770
+ // Intentionally inside to avoid triggering lazy initializers:
771
+ var name = getComponentName(type);
772
+ checkPropTypes(propTypes, element.props, 'prop', name, element);
773
+ } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
774
+ propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
775
+
776
+ var _name = getComponentName(type);
777
+
778
+ error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
779
+ }
780
+
781
+ if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
782
+ error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
783
+ }
784
+ }
785
+ }
786
+ /**
787
+ * Given a fragment, validate that it can only be provided with fragment props
788
+ * @param {ReactElement} fragment
789
+ */
790
+
791
+
792
+ function validateFragmentProps(fragment) {
793
+ {
794
+ var keys = Object.keys(fragment.props);
795
+
796
+ for (var i = 0; i < keys.length; i++) {
797
+ var key = keys[i];
798
+
799
+ if (key !== 'children' && key !== 'key') {
800
+ setCurrentlyValidatingElement$1(fragment);
801
+
802
+ error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
803
+
804
+ setCurrentlyValidatingElement$1(null);
805
+ break;
806
+ }
807
+ }
808
+
809
+ if (fragment.ref !== null) {
810
+ setCurrentlyValidatingElement$1(fragment);
811
+
812
+ error('Invalid attribute `ref` supplied to `React.Fragment`.');
813
+
814
+ setCurrentlyValidatingElement$1(null);
815
+ }
816
+ }
817
+ }
818
+
819
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
820
+ {
821
+ var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
822
+ // succeed and there will likely be errors in render.
823
+
824
+ if (!validType) {
825
+ var info = '';
826
+
827
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
828
+ info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
829
+ }
830
+
831
+ var sourceInfo = getSourceInfoErrorAddendum(source);
832
+
833
+ if (sourceInfo) {
834
+ info += sourceInfo;
835
+ } else {
836
+ info += getDeclarationErrorAddendum();
837
+ }
838
+
839
+ var typeString;
840
+
841
+ if (type === null) {
842
+ typeString = 'null';
843
+ } else if (Array.isArray(type)) {
844
+ typeString = 'array';
845
+ } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
846
+ typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
847
+ info = ' Did you accidentally export a JSX literal instead of a component?';
848
+ } else {
849
+ typeString = typeof type;
850
+ }
851
+
852
+ error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
853
+ }
854
+
855
+ var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
856
+ // TODO: Drop this when these are no longer allowed as the type argument.
857
+
858
+ if (element == null) {
859
+ return element;
860
+ } // Skip key warning if the type isn't valid since our key validation logic
861
+ // doesn't expect a non-string/function type and can throw confusing errors.
862
+ // We don't want exception behavior to differ between dev and prod.
863
+ // (Rendering will throw with a helpful message and as soon as the type is
864
+ // fixed, the key warnings will appear.)
865
+
866
+
867
+ if (validType) {
868
+ var children = props.children;
869
+
870
+ if (children !== undefined) {
871
+ if (isStaticChildren) {
872
+ if (Array.isArray(children)) {
873
+ for (var i = 0; i < children.length; i++) {
874
+ validateChildKeys(children[i], type);
875
+ }
876
+
877
+ if (Object.freeze) {
878
+ Object.freeze(children);
879
+ }
880
+ } else {
881
+ error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
882
+ }
883
+ } else {
884
+ validateChildKeys(children, type);
885
+ }
886
+ }
887
+ }
888
+
889
+ if (type === exports.Fragment) {
890
+ validateFragmentProps(element);
891
+ } else {
892
+ validatePropTypes(element);
893
+ }
894
+
895
+ return element;
896
+ }
897
+ } // These two functions exist to still get child warnings in dev
898
+ // even with the prod transform. This means that jsxDEV is purely
899
+ // opt-in behavior for better messages but that we won't stop
900
+ // giving you warnings if you use production apis.
901
+
902
+ function jsxWithValidationStatic(type, props, key) {
903
+ {
904
+ return jsxWithValidation(type, props, key, true);
905
+ }
906
+ }
907
+ function jsxWithValidationDynamic(type, props, key) {
908
+ {
909
+ return jsxWithValidation(type, props, key, false);
910
+ }
911
+ }
912
+
913
+ var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
914
+ // for now we can ship identical prod functions
915
+
916
+ var jsxs = jsxWithValidationStatic ;
917
+
918
+ exports.jsx = jsx;
919
+ exports.jsxs = jsxs;
920
+ })();
921
+ }
922
+ } (reactJsxRuntime_development));
923
+
924
+ (function (module) {
925
+
926
+ {
927
+ module.exports = reactJsxRuntime_development;
928
+ }
929
+ } (jsxRuntime));
930
+
931
+ var classnames = {exports: {}};
932
+
933
+ /*!
934
+ Copyright (c) 2018 Jed Watson.
935
+ Licensed under the MIT License (MIT), see
936
+ http://jedwatson.github.io/classnames
937
+ */
938
+
939
+ (function (module) {
940
+ /* global define */
941
+
942
+ (function () {
943
+
944
+ var hasOwn = {}.hasOwnProperty;
945
+
946
+ function classNames() {
947
+ var classes = [];
948
+
949
+ for (var i = 0; i < arguments.length; i++) {
950
+ var arg = arguments[i];
951
+ if (!arg) continue;
952
+
953
+ var argType = typeof arg;
954
+
955
+ if (argType === 'string' || argType === 'number') {
956
+ classes.push(arg);
957
+ } else if (Array.isArray(arg)) {
958
+ if (arg.length) {
959
+ var inner = classNames.apply(null, arg);
960
+ if (inner) {
961
+ classes.push(inner);
962
+ }
963
+ }
964
+ } else if (argType === 'object') {
965
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
966
+ classes.push(arg.toString());
967
+ continue;
968
+ }
969
+
970
+ for (var key in arg) {
971
+ if (hasOwn.call(arg, key) && arg[key]) {
972
+ classes.push(key);
973
+ }
974
+ }
975
+ }
976
+ }
977
+
978
+ return classes.join(' ');
979
+ }
980
+
981
+ if (module.exports) {
982
+ classNames.default = classNames;
983
+ module.exports = classNames;
984
+ } else {
985
+ window.classNames = classNames;
986
+ }
987
+ }());
988
+ } (classnames));
989
+
990
+ var classNames = classnames.exports;
991
+
992
+ /* eslint-disable @typescript-eslint/no-explicit-any */
993
+ /**
994
+ * This function debounce the received function
995
+ * @param { function } func Function to be debounced
996
+ * @param { number } wait Time to wait before execut the function
997
+ * @param { boolean } immediate Param to define if the function will be executed immediately
998
+ */
999
+ const debounce = (func, wait, immediate) => {
1000
+ let timeout = null;
1001
+ return function debounced(...args) {
1002
+ const later = () => {
1003
+ timeout = null;
1004
+ if (!immediate) {
1005
+ func.apply(this, args);
1006
+ }
1007
+ };
1008
+ if (timeout) {
1009
+ clearTimeout(timeout);
1010
+ }
1011
+ timeout = setTimeout(later, wait);
1012
+ };
1013
+ };
1014
+
1015
+ const DEFAULT_TOOLTIP_ID = 'DEFAULT_TOOLTIP_ID';
1016
+ const DEFAULT_CONTEXT_DATA = {
1017
+ anchorRefs: new Set(),
1018
+ activeAnchor: { current: null },
1019
+ attach: () => {
1020
+ /* attach anchor element */
1021
+ },
1022
+ detach: () => {
1023
+ /* detach anchor element */
1024
+ },
1025
+ setActiveAnchor: () => {
1026
+ /* set active anchor */
1027
+ },
1028
+ };
1029
+ const DEFAULT_CONTEXT_DATA_WRAPPER = {
1030
+ getTooltipData: () => DEFAULT_CONTEXT_DATA,
1031
+ };
1032
+ const TooltipContext = require$$0.createContext(DEFAULT_CONTEXT_DATA_WRAPPER);
1033
+ /**
1034
+ * @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
1035
+ * See https://react-tooltip.com/docs/getting-started
1036
+ */
1037
+ const TooltipProvider = ({ children }) => {
1038
+ const [anchorRefMap, setAnchorRefMap] = require$$0.useState({
1039
+ [DEFAULT_TOOLTIP_ID]: new Set(),
1040
+ });
1041
+ const [activeAnchorMap, setActiveAnchorMap] = require$$0.useState({
1042
+ [DEFAULT_TOOLTIP_ID]: { current: null },
1043
+ });
1044
+ const attach = (tooltipId, ...refs) => {
1045
+ setAnchorRefMap((oldMap) => {
1046
+ var _a;
1047
+ const tooltipRefs = (_a = oldMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set();
1048
+ refs.forEach((ref) => tooltipRefs.add(ref));
1049
+ // create new object to trigger re-render
1050
+ return { ...oldMap, [tooltipId]: new Set(tooltipRefs) };
1051
+ });
1052
+ };
1053
+ const detach = (tooltipId, ...refs) => {
1054
+ setAnchorRefMap((oldMap) => {
1055
+ const tooltipRefs = oldMap[tooltipId];
1056
+ if (!tooltipRefs) {
1057
+ // tooltip not found
1058
+ // maybe thow error?
1059
+ return oldMap;
1060
+ }
1061
+ refs.forEach((ref) => tooltipRefs.delete(ref));
1062
+ // create new object to trigger re-render
1063
+ return { ...oldMap };
1064
+ });
1065
+ };
1066
+ const setActiveAnchor = (tooltipId, ref) => {
1067
+ setActiveAnchorMap((oldMap) => {
1068
+ var _a;
1069
+ if (((_a = oldMap[tooltipId]) === null || _a === void 0 ? void 0 : _a.current) === ref.current) {
1070
+ return oldMap;
1071
+ }
1072
+ // create new object to trigger re-render
1073
+ return { ...oldMap, [tooltipId]: ref };
1074
+ });
1075
+ };
1076
+ const getTooltipData = require$$0.useCallback((tooltipId = DEFAULT_TOOLTIP_ID) => {
1077
+ var _a, _b;
1078
+ return ({
1079
+ anchorRefs: (_a = anchorRefMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set(),
1080
+ activeAnchor: (_b = activeAnchorMap[tooltipId]) !== null && _b !== void 0 ? _b : { current: null },
1081
+ attach: (...refs) => attach(tooltipId, ...refs),
1082
+ detach: (...refs) => detach(tooltipId, ...refs),
1083
+ setActiveAnchor: (ref) => setActiveAnchor(tooltipId, ref),
1084
+ });
1085
+ }, [anchorRefMap, activeAnchorMap, attach, detach]);
1086
+ const context = require$$0.useMemo(() => {
1087
+ return {
1088
+ getTooltipData,
1089
+ };
1090
+ }, [getTooltipData]);
1091
+ return jsxRuntime.exports.jsx(TooltipContext.Provider, { value: context, children: children });
1092
+ };
1093
+ function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
1094
+ return require$$0.useContext(TooltipContext).getTooltipData(tooltipId);
1095
+ }
1096
+
1097
+ /**
1098
+ * @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
1099
+ * See https://react-tooltip.com/docs/getting-started
1100
+ */
1101
+ const TooltipWrapper = ({ tooltipId, children, className, place, content, html, variant, offset, wrapper, events, positionStrategy, delayShow, delayHide, }) => {
1102
+ const { attach, detach } = useTooltip(tooltipId);
1103
+ const anchorRef = require$$0.useRef(null);
1104
+ require$$0.useEffect(() => {
1105
+ attach(anchorRef);
1106
+ return () => {
1107
+ detach(anchorRef);
1108
+ };
1109
+ }, []);
1110
+ return (jsxRuntime.exports.jsx("span", { ref: anchorRef, className: classNames('react-tooltip-wrapper', className), "data-tooltip-place": place, "data-tooltip-content": content, "data-tooltip-html": html, "data-tooltip-variant": variant, "data-tooltip-offset": offset, "data-tooltip-wrapper": wrapper, "data-tooltip-events": events, "data-tooltip-position-strategy": positionStrategy, "data-tooltip-delay-show": delayShow, "data-tooltip-delay-hide": delayHide, children: children }));
1111
+ };
1112
+
1113
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? require$$0.useLayoutEffect : require$$0.useEffect;
1114
+
1115
+ function getAlignment(placement) {
1116
+ return placement.split('-')[1];
1117
+ }
1118
+
1119
+ function getLengthFromAxis(axis) {
1120
+ return axis === 'y' ? 'height' : 'width';
1121
+ }
1122
+
1123
+ function getSide(placement) {
1124
+ return placement.split('-')[0];
1125
+ }
1126
+
1127
+ function getMainAxisFromPlacement(placement) {
1128
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
1129
+ }
1130
+
1131
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1132
+ let {
1133
+ reference,
1134
+ floating
1135
+ } = _ref;
1136
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1137
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1138
+ const mainAxis = getMainAxisFromPlacement(placement);
1139
+ const length = getLengthFromAxis(mainAxis);
1140
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
1141
+ const side = getSide(placement);
1142
+ const isVertical = mainAxis === 'x';
1143
+ let coords;
1144
+ switch (side) {
1145
+ case 'top':
1146
+ coords = {
1147
+ x: commonX,
1148
+ y: reference.y - floating.height
1149
+ };
1150
+ break;
1151
+ case 'bottom':
1152
+ coords = {
1153
+ x: commonX,
1154
+ y: reference.y + reference.height
1155
+ };
1156
+ break;
1157
+ case 'right':
1158
+ coords = {
1159
+ x: reference.x + reference.width,
1160
+ y: commonY
1161
+ };
1162
+ break;
1163
+ case 'left':
1164
+ coords = {
1165
+ x: reference.x - floating.width,
1166
+ y: commonY
1167
+ };
1168
+ break;
1169
+ default:
1170
+ coords = {
1171
+ x: reference.x,
1172
+ y: reference.y
1173
+ };
1174
+ }
1175
+ switch (getAlignment(placement)) {
1176
+ case 'start':
1177
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1178
+ break;
1179
+ case 'end':
1180
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1181
+ break;
1182
+ }
1183
+ return coords;
1184
+ }
1185
+
1186
+ /**
1187
+ * Computes the `x` and `y` coordinates that will place the floating element
1188
+ * next to a reference element when it is given a certain positioning strategy.
1189
+ *
1190
+ * This export does not have any `platform` interface logic. You will need to
1191
+ * write one for the platform you are using Floating UI with.
1192
+ */
1193
+ const computePosition$1 = async (reference, floating, config) => {
1194
+ const {
1195
+ placement = 'bottom',
1196
+ strategy = 'absolute',
1197
+ middleware = [],
1198
+ platform
1199
+ } = config;
1200
+ const validMiddleware = middleware.filter(Boolean);
1201
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1202
+ {
1203
+ if (platform == null) {
1204
+ console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
1205
+ }
1206
+ if (validMiddleware.filter(_ref => {
1207
+ let {
1208
+ name
1209
+ } = _ref;
1210
+ return name === 'autoPlacement' || name === 'flip';
1211
+ }).length > 1) {
1212
+ throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement` middleware', 'detected. This will lead to an infinite loop. Ensure only one of', 'either has been passed to the `middleware` array.'].join(' '));
1213
+ }
1214
+ if (!reference || !floating) {
1215
+ console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));
1216
+ }
1217
+ }
1218
+ let rects = await platform.getElementRects({
1219
+ reference,
1220
+ floating,
1221
+ strategy
1222
+ });
1223
+ let {
1224
+ x,
1225
+ y
1226
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1227
+ let statefulPlacement = placement;
1228
+ let middlewareData = {};
1229
+ let resetCount = 0;
1230
+ for (let i = 0; i < validMiddleware.length; i++) {
1231
+ const {
1232
+ name,
1233
+ fn
1234
+ } = validMiddleware[i];
1235
+ const {
1236
+ x: nextX,
1237
+ y: nextY,
1238
+ data,
1239
+ reset
1240
+ } = await fn({
1241
+ x,
1242
+ y,
1243
+ initialPlacement: placement,
1244
+ placement: statefulPlacement,
1245
+ strategy,
1246
+ middlewareData,
1247
+ rects,
1248
+ platform,
1249
+ elements: {
1250
+ reference,
1251
+ floating
1252
+ }
1253
+ });
1254
+ x = nextX != null ? nextX : x;
1255
+ y = nextY != null ? nextY : y;
1256
+ middlewareData = {
1257
+ ...middlewareData,
1258
+ [name]: {
1259
+ ...middlewareData[name],
1260
+ ...data
1261
+ }
1262
+ };
1263
+ {
1264
+ if (resetCount > 50) {
1265
+ console.warn(['Floating UI: The middleware lifecycle appears to be running in an', 'infinite loop. This is usually caused by a `reset` continually', 'being returned without a break condition.'].join(' '));
1266
+ }
1267
+ }
1268
+ if (reset && resetCount <= 50) {
1269
+ resetCount++;
1270
+ if (typeof reset === 'object') {
1271
+ if (reset.placement) {
1272
+ statefulPlacement = reset.placement;
1273
+ }
1274
+ if (reset.rects) {
1275
+ rects = reset.rects === true ? await platform.getElementRects({
1276
+ reference,
1277
+ floating,
1278
+ strategy
1279
+ }) : reset.rects;
1280
+ }
1281
+ ({
1282
+ x,
1283
+ y
1284
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1285
+ }
1286
+ i = -1;
1287
+ continue;
1288
+ }
1289
+ }
1290
+ return {
1291
+ x,
1292
+ y,
1293
+ placement: statefulPlacement,
1294
+ strategy,
1295
+ middlewareData
1296
+ };
1297
+ };
1298
+
1299
+ function expandPaddingObject(padding) {
1300
+ return {
1301
+ top: 0,
1302
+ right: 0,
1303
+ bottom: 0,
1304
+ left: 0,
1305
+ ...padding
1306
+ };
1307
+ }
1308
+
1309
+ function getSideObjectFromPadding(padding) {
1310
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
1311
+ top: padding,
1312
+ right: padding,
1313
+ bottom: padding,
1314
+ left: padding
1315
+ };
1316
+ }
1317
+
1318
+ function rectToClientRect(rect) {
1319
+ return {
1320
+ ...rect,
1321
+ top: rect.y,
1322
+ left: rect.x,
1323
+ right: rect.x + rect.width,
1324
+ bottom: rect.y + rect.height
1325
+ };
1326
+ }
1327
+
1328
+ /**
1329
+ * Resolves with an object of overflow side offsets that determine how much the
1330
+ * element is overflowing a given clipping boundary on each side.
1331
+ * - positive = overflowing the boundary by that number of pixels
1332
+ * - negative = how many pixels left before it will overflow
1333
+ * - 0 = lies flush with the boundary
1334
+ * @see https://floating-ui.com/docs/detectOverflow
1335
+ */
1336
+ async function detectOverflow(state, options) {
1337
+ var _await$platform$isEle;
1338
+ if (options === void 0) {
1339
+ options = {};
1340
+ }
1341
+ const {
1342
+ x,
1343
+ y,
1344
+ platform,
1345
+ rects,
1346
+ elements,
1347
+ strategy
1348
+ } = state;
1349
+ const {
1350
+ boundary = 'clippingAncestors',
1351
+ rootBoundary = 'viewport',
1352
+ elementContext = 'floating',
1353
+ altBoundary = false,
1354
+ padding = 0
1355
+ } = options;
1356
+ const paddingObject = getSideObjectFromPadding(padding);
1357
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1358
+ const element = elements[altBoundary ? altContext : elementContext];
1359
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1360
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1361
+ boundary,
1362
+ rootBoundary,
1363
+ strategy
1364
+ }));
1365
+ const rect = elementContext === 'floating' ? {
1366
+ ...rects.floating,
1367
+ x,
1368
+ y
1369
+ } : rects.reference;
1370
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1371
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1372
+ x: 1,
1373
+ y: 1
1374
+ } : {
1375
+ x: 1,
1376
+ y: 1
1377
+ };
1378
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1379
+ rect,
1380
+ offsetParent,
1381
+ strategy
1382
+ }) : rect);
1383
+ return {
1384
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1385
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1386
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1387
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1388
+ };
1389
+ }
1390
+
1391
+ const min$1 = Math.min;
1392
+ const max$1 = Math.max;
1393
+
1394
+ function within(min$1$1, value, max$1$1) {
1395
+ return max$1(min$1$1, min$1(value, max$1$1));
1396
+ }
1397
+
1398
+ /**
1399
+ * Provides data to position an inner element of the floating element so that it
1400
+ * appears centered to the reference element.
1401
+ * @see https://floating-ui.com/docs/arrow
1402
+ */
1403
+ const arrow = options => ({
1404
+ name: 'arrow',
1405
+ options,
1406
+ async fn(state) {
1407
+ // Since `element` is required, we don't Partial<> the type.
1408
+ const {
1409
+ element,
1410
+ padding = 0
1411
+ } = options || {};
1412
+ const {
1413
+ x,
1414
+ y,
1415
+ placement,
1416
+ rects,
1417
+ platform,
1418
+ elements
1419
+ } = state;
1420
+ if (element == null) {
1421
+ {
1422
+ console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
1423
+ }
1424
+ return {};
1425
+ }
1426
+ const paddingObject = getSideObjectFromPadding(padding);
1427
+ const coords = {
1428
+ x,
1429
+ y
1430
+ };
1431
+ const axis = getMainAxisFromPlacement(placement);
1432
+ const length = getLengthFromAxis(axis);
1433
+ const arrowDimensions = await platform.getDimensions(element);
1434
+ const isYAxis = axis === 'y';
1435
+ const minProp = isYAxis ? 'top' : 'left';
1436
+ const maxProp = isYAxis ? 'bottom' : 'right';
1437
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1438
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1439
+ const startDiff = coords[axis] - rects.reference[axis];
1440
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1441
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1442
+
1443
+ // DOM platform can return `window` as the `offsetParent`.
1444
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1445
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1446
+ }
1447
+ const centerToReference = endDiff / 2 - startDiff / 2;
1448
+
1449
+ // Make sure the arrow doesn't overflow the floating element if the center
1450
+ // point is outside the floating element's bounds.
1451
+ const min = paddingObject[minProp];
1452
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
1453
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1454
+ const offset = within(min, center, max);
1455
+
1456
+ // If the reference is small enough that the arrow's padding causes it to
1457
+ // to point to nothing for an aligned placement, adjust the offset of the
1458
+ // floating element itself. This stops `shift()` from taking action, but can
1459
+ // be worked around by calling it again after the `arrow()` if desired.
1460
+ const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
1461
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
1462
+ return {
1463
+ [axis]: coords[axis] - alignmentOffset,
1464
+ data: {
1465
+ [axis]: offset,
1466
+ centerOffset: center - offset
1467
+ }
1468
+ };
1469
+ }
1470
+ });
1471
+
1472
+ const oppositeSideMap = {
1473
+ left: 'right',
1474
+ right: 'left',
1475
+ bottom: 'top',
1476
+ top: 'bottom'
1477
+ };
1478
+ function getOppositePlacement(placement) {
1479
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
1480
+ }
1481
+
1482
+ function getAlignmentSides(placement, rects, rtl) {
1483
+ if (rtl === void 0) {
1484
+ rtl = false;
1485
+ }
1486
+ const alignment = getAlignment(placement);
1487
+ const mainAxis = getMainAxisFromPlacement(placement);
1488
+ const length = getLengthFromAxis(mainAxis);
1489
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
1490
+ if (rects.reference[length] > rects.floating[length]) {
1491
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1492
+ }
1493
+ return {
1494
+ main: mainAlignmentSide,
1495
+ cross: getOppositePlacement(mainAlignmentSide)
1496
+ };
1497
+ }
1498
+
1499
+ const oppositeAlignmentMap = {
1500
+ start: 'end',
1501
+ end: 'start'
1502
+ };
1503
+ function getOppositeAlignmentPlacement(placement) {
1504
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
1505
+ }
1506
+
1507
+ function getExpandedPlacements(placement) {
1508
+ const oppositePlacement = getOppositePlacement(placement);
1509
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1510
+ }
1511
+
1512
+ function getSideList(side, isStart, rtl) {
1513
+ const lr = ['left', 'right'];
1514
+ const rl = ['right', 'left'];
1515
+ const tb = ['top', 'bottom'];
1516
+ const bt = ['bottom', 'top'];
1517
+ switch (side) {
1518
+ case 'top':
1519
+ case 'bottom':
1520
+ if (rtl) return isStart ? rl : lr;
1521
+ return isStart ? lr : rl;
1522
+ case 'left':
1523
+ case 'right':
1524
+ return isStart ? tb : bt;
1525
+ default:
1526
+ return [];
1527
+ }
1528
+ }
1529
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1530
+ const alignment = getAlignment(placement);
1531
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
1532
+ if (alignment) {
1533
+ list = list.map(side => side + "-" + alignment);
1534
+ if (flipAlignment) {
1535
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1536
+ }
1537
+ }
1538
+ return list;
1539
+ }
1540
+
1541
+ /**
1542
+ * Optimizes the visibility of the floating element by flipping the `placement`
1543
+ * in order to keep it in view when the preferred placement(s) will overflow the
1544
+ * clipping boundary. Alternative to `autoPlacement`.
1545
+ * @see https://floating-ui.com/docs/flip
1546
+ */
1547
+ const flip = function (options) {
1548
+ if (options === void 0) {
1549
+ options = {};
1550
+ }
1551
+ return {
1552
+ name: 'flip',
1553
+ options,
1554
+ async fn(state) {
1555
+ var _middlewareData$flip;
1556
+ const {
1557
+ placement,
1558
+ middlewareData,
1559
+ rects,
1560
+ initialPlacement,
1561
+ platform,
1562
+ elements
1563
+ } = state;
1564
+ const {
1565
+ mainAxis: checkMainAxis = true,
1566
+ crossAxis: checkCrossAxis = true,
1567
+ fallbackPlacements: specifiedFallbackPlacements,
1568
+ fallbackStrategy = 'bestFit',
1569
+ fallbackAxisSideDirection = 'none',
1570
+ flipAlignment = true,
1571
+ ...detectOverflowOptions
1572
+ } = options;
1573
+ const side = getSide(placement);
1574
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1575
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1576
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1577
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
1578
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1579
+ }
1580
+ const placements = [initialPlacement, ...fallbackPlacements];
1581
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1582
+ const overflows = [];
1583
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1584
+ if (checkMainAxis) {
1585
+ overflows.push(overflow[side]);
1586
+ }
1587
+ if (checkCrossAxis) {
1588
+ const {
1589
+ main,
1590
+ cross
1591
+ } = getAlignmentSides(placement, rects, rtl);
1592
+ overflows.push(overflow[main], overflow[cross]);
1593
+ }
1594
+ overflowsData = [...overflowsData, {
1595
+ placement,
1596
+ overflows
1597
+ }];
1598
+
1599
+ // One or more sides is overflowing.
1600
+ if (!overflows.every(side => side <= 0)) {
1601
+ var _middlewareData$flip2, _overflowsData$filter;
1602
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1603
+ const nextPlacement = placements[nextIndex];
1604
+ if (nextPlacement) {
1605
+ // Try next placement and re-run the lifecycle.
1606
+ return {
1607
+ data: {
1608
+ index: nextIndex,
1609
+ overflows: overflowsData
1610
+ },
1611
+ reset: {
1612
+ placement: nextPlacement
1613
+ }
1614
+ };
1615
+ }
1616
+
1617
+ // First, find the candidates that fit on the mainAxis side of overflow,
1618
+ // then find the placement that fits the best on the main crossAxis side.
1619
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1620
+
1621
+ // Otherwise fallback.
1622
+ if (!resetPlacement) {
1623
+ switch (fallbackStrategy) {
1624
+ case 'bestFit':
1625
+ {
1626
+ var _overflowsData$map$so;
1627
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
1628
+ if (placement) {
1629
+ resetPlacement = placement;
1630
+ }
1631
+ break;
1632
+ }
1633
+ case 'initialPlacement':
1634
+ resetPlacement = initialPlacement;
1635
+ break;
1636
+ }
1637
+ }
1638
+ if (placement !== resetPlacement) {
1639
+ return {
1640
+ reset: {
1641
+ placement: resetPlacement
1642
+ }
1643
+ };
1644
+ }
1645
+ }
1646
+ return {};
1647
+ }
1648
+ };
1649
+ };
1650
+
1651
+ async function convertValueToCoords(state, value) {
1652
+ const {
1653
+ placement,
1654
+ platform,
1655
+ elements
1656
+ } = state;
1657
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1658
+ const side = getSide(placement);
1659
+ const alignment = getAlignment(placement);
1660
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
1661
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1662
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1663
+ const rawValue = typeof value === 'function' ? value(state) : value;
1664
+
1665
+ // eslint-disable-next-line prefer-const
1666
+ let {
1667
+ mainAxis,
1668
+ crossAxis,
1669
+ alignmentAxis
1670
+ } = typeof rawValue === 'number' ? {
1671
+ mainAxis: rawValue,
1672
+ crossAxis: 0,
1673
+ alignmentAxis: null
1674
+ } : {
1675
+ mainAxis: 0,
1676
+ crossAxis: 0,
1677
+ alignmentAxis: null,
1678
+ ...rawValue
1679
+ };
1680
+ if (alignment && typeof alignmentAxis === 'number') {
1681
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1682
+ }
1683
+ return isVertical ? {
1684
+ x: crossAxis * crossAxisMulti,
1685
+ y: mainAxis * mainAxisMulti
1686
+ } : {
1687
+ x: mainAxis * mainAxisMulti,
1688
+ y: crossAxis * crossAxisMulti
1689
+ };
1690
+ }
1691
+
1692
+ /**
1693
+ * Modifies the placement by translating the floating element along the
1694
+ * specified axes.
1695
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1696
+ * object may be passed.
1697
+ * @see https://floating-ui.com/docs/offset
1698
+ */
1699
+ const offset = function (value) {
1700
+ if (value === void 0) {
1701
+ value = 0;
1702
+ }
1703
+ return {
1704
+ name: 'offset',
1705
+ options: value,
1706
+ async fn(state) {
1707
+ const {
1708
+ x,
1709
+ y
1710
+ } = state;
1711
+ const diffCoords = await convertValueToCoords(state, value);
1712
+ return {
1713
+ x: x + diffCoords.x,
1714
+ y: y + diffCoords.y,
1715
+ data: diffCoords
1716
+ };
1717
+ }
1718
+ };
1719
+ };
1720
+
1721
+ function getCrossAxis(axis) {
1722
+ return axis === 'x' ? 'y' : 'x';
1723
+ }
1724
+
1725
+ /**
1726
+ * Optimizes the visibility of the floating element by shifting it in order to
1727
+ * keep it in view when it will overflow the clipping boundary.
1728
+ * @see https://floating-ui.com/docs/shift
1729
+ */
1730
+ const shift = function (options) {
1731
+ if (options === void 0) {
1732
+ options = {};
1733
+ }
1734
+ return {
1735
+ name: 'shift',
1736
+ options,
1737
+ async fn(state) {
1738
+ const {
1739
+ x,
1740
+ y,
1741
+ placement
1742
+ } = state;
1743
+ const {
1744
+ mainAxis: checkMainAxis = true,
1745
+ crossAxis: checkCrossAxis = false,
1746
+ limiter = {
1747
+ fn: _ref => {
1748
+ let {
1749
+ x,
1750
+ y
1751
+ } = _ref;
1752
+ return {
1753
+ x,
1754
+ y
1755
+ };
1756
+ }
1757
+ },
1758
+ ...detectOverflowOptions
1759
+ } = options;
1760
+ const coords = {
1761
+ x,
1762
+ y
1763
+ };
1764
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1765
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
1766
+ const crossAxis = getCrossAxis(mainAxis);
1767
+ let mainAxisCoord = coords[mainAxis];
1768
+ let crossAxisCoord = coords[crossAxis];
1769
+ if (checkMainAxis) {
1770
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
1771
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1772
+ const min = mainAxisCoord + overflow[minSide];
1773
+ const max = mainAxisCoord - overflow[maxSide];
1774
+ mainAxisCoord = within(min, mainAxisCoord, max);
1775
+ }
1776
+ if (checkCrossAxis) {
1777
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
1778
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1779
+ const min = crossAxisCoord + overflow[minSide];
1780
+ const max = crossAxisCoord - overflow[maxSide];
1781
+ crossAxisCoord = within(min, crossAxisCoord, max);
1782
+ }
1783
+ const limitedCoords = limiter.fn({
1784
+ ...state,
1785
+ [mainAxis]: mainAxisCoord,
1786
+ [crossAxis]: crossAxisCoord
1787
+ });
1788
+ return {
1789
+ ...limitedCoords,
1790
+ data: {
1791
+ x: limitedCoords.x - x,
1792
+ y: limitedCoords.y - y
1793
+ }
1794
+ };
1795
+ }
1796
+ };
1797
+ };
1798
+
1799
+ function getWindow(node) {
1800
+ var _node$ownerDocument;
1801
+ return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1802
+ }
1803
+
1804
+ function getComputedStyle$1(element) {
1805
+ return getWindow(element).getComputedStyle(element);
1806
+ }
1807
+
1808
+ const min = Math.min;
1809
+ const max = Math.max;
1810
+ const round = Math.round;
1811
+
1812
+ function getCssDimensions(element) {
1813
+ const css = getComputedStyle$1(element);
1814
+ let width = parseFloat(css.width);
1815
+ let height = parseFloat(css.height);
1816
+ const offsetWidth = element.offsetWidth;
1817
+ const offsetHeight = element.offsetHeight;
1818
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1819
+ if (shouldFallback) {
1820
+ width = offsetWidth;
1821
+ height = offsetHeight;
1822
+ }
1823
+ return {
1824
+ width,
1825
+ height,
1826
+ fallback: shouldFallback
1827
+ };
1828
+ }
1829
+
1830
+ function getNodeName(node) {
1831
+ return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
1832
+ }
1833
+
1834
+ let uaString;
1835
+ function getUAString() {
1836
+ if (uaString) {
1837
+ return uaString;
1838
+ }
1839
+ const uaData = navigator.userAgentData;
1840
+ if (uaData && Array.isArray(uaData.brands)) {
1841
+ uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
1842
+ return uaString;
1843
+ }
1844
+ return navigator.userAgent;
1845
+ }
1846
+
1847
+ function isHTMLElement(value) {
1848
+ return value instanceof getWindow(value).HTMLElement;
1849
+ }
1850
+ function isElement(value) {
1851
+ return value instanceof getWindow(value).Element;
1852
+ }
1853
+ function isNode(value) {
1854
+ return value instanceof getWindow(value).Node;
1855
+ }
1856
+ function isShadowRoot(node) {
1857
+ // Browsers without `ShadowRoot` support.
1858
+ if (typeof ShadowRoot === 'undefined') {
1859
+ return false;
1860
+ }
1861
+ const OwnElement = getWindow(node).ShadowRoot;
1862
+ return node instanceof OwnElement || node instanceof ShadowRoot;
1863
+ }
1864
+ function isOverflowElement(element) {
1865
+ const {
1866
+ overflow,
1867
+ overflowX,
1868
+ overflowY,
1869
+ display
1870
+ } = getComputedStyle$1(element);
1871
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1872
+ }
1873
+ function isTableElement(element) {
1874
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1875
+ }
1876
+ function isContainingBlock(element) {
1877
+ // TODO: Try to use feature detection here instead.
1878
+ const isFirefox = /firefox/i.test(getUAString());
1879
+ const css = getComputedStyle$1(element);
1880
+ const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
1881
+
1882
+ // This is non-exhaustive but covers the most common CSS properties that
1883
+ // create a containing block.
1884
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1885
+ return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
1886
+ // Add type check for old browsers.
1887
+ const contain = css.contain;
1888
+ return contain != null ? contain.includes(value) : false;
1889
+ });
1890
+ }
1891
+
1892
+ /**
1893
+ * Determines whether or not `.getBoundingClientRect()` is affected by visual
1894
+ * viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
1895
+ * visual viewport, while in other engines, they are values relative to the
1896
+ * layout viewport.
1897
+ */
1898
+ function isClientRectVisualViewportBased() {
1899
+ // TODO: Try to use feature detection here instead. Feature detection for
1900
+ // this can fail in various ways, making the userAgent check the most
1901
+ // reliable:
1902
+ // • Always-visible scrollbar or not
1903
+ // • Width of <html>
1904
+
1905
+ // Is Safari.
1906
+ return /^((?!chrome|android).)*safari/i.test(getUAString());
1907
+ }
1908
+ function isLastTraversableNode(node) {
1909
+ return ['html', 'body', '#document'].includes(getNodeName(node));
1910
+ }
1911
+
1912
+ function unwrapElement(element) {
1913
+ return !isElement(element) ? element.contextElement : element;
1914
+ }
1915
+
1916
+ const FALLBACK_SCALE = {
1917
+ x: 1,
1918
+ y: 1
1919
+ };
1920
+ function getScale(element) {
1921
+ const domElement = unwrapElement(element);
1922
+ if (!isHTMLElement(domElement)) {
1923
+ return FALLBACK_SCALE;
1924
+ }
1925
+ const rect = domElement.getBoundingClientRect();
1926
+ const {
1927
+ width,
1928
+ height,
1929
+ fallback
1930
+ } = getCssDimensions(domElement);
1931
+ let x = (fallback ? round(rect.width) : rect.width) / width;
1932
+ let y = (fallback ? round(rect.height) : rect.height) / height;
1933
+
1934
+ // 0, NaN, or Infinity should always fallback to 1.
1935
+
1936
+ if (!x || !Number.isFinite(x)) {
1937
+ x = 1;
1938
+ }
1939
+ if (!y || !Number.isFinite(y)) {
1940
+ y = 1;
1941
+ }
1942
+ return {
1943
+ x,
1944
+ y
1945
+ };
1946
+ }
1947
+
1948
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1949
+ var _win$visualViewport, _win$visualViewport2;
1950
+ if (includeScale === void 0) {
1951
+ includeScale = false;
1952
+ }
1953
+ if (isFixedStrategy === void 0) {
1954
+ isFixedStrategy = false;
1955
+ }
1956
+ const clientRect = element.getBoundingClientRect();
1957
+ const domElement = unwrapElement(element);
1958
+ let scale = FALLBACK_SCALE;
1959
+ if (includeScale) {
1960
+ if (offsetParent) {
1961
+ if (isElement(offsetParent)) {
1962
+ scale = getScale(offsetParent);
1963
+ }
1964
+ } else {
1965
+ scale = getScale(element);
1966
+ }
1967
+ }
1968
+ const win = domElement ? getWindow(domElement) : window;
1969
+ const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy;
1970
+ let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
1971
+ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
1972
+ let width = clientRect.width / scale.x;
1973
+ let height = clientRect.height / scale.y;
1974
+ if (domElement) {
1975
+ const win = getWindow(domElement);
1976
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1977
+ let currentIFrame = win.frameElement;
1978
+ while (currentIFrame && offsetParent && offsetWin !== win) {
1979
+ const iframeScale = getScale(currentIFrame);
1980
+ const iframeRect = currentIFrame.getBoundingClientRect();
1981
+ const css = getComputedStyle(currentIFrame);
1982
+ iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1983
+ iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1984
+ x *= iframeScale.x;
1985
+ y *= iframeScale.y;
1986
+ width *= iframeScale.x;
1987
+ height *= iframeScale.y;
1988
+ x += iframeRect.x;
1989
+ y += iframeRect.y;
1990
+ currentIFrame = getWindow(currentIFrame).frameElement;
1991
+ }
1992
+ }
1993
+ return rectToClientRect({
1994
+ width,
1995
+ height,
1996
+ x,
1997
+ y
1998
+ });
1999
+ }
2000
+
2001
+ function getDocumentElement(node) {
2002
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
2003
+ }
2004
+
2005
+ function getNodeScroll(element) {
2006
+ if (isElement(element)) {
2007
+ return {
2008
+ scrollLeft: element.scrollLeft,
2009
+ scrollTop: element.scrollTop
2010
+ };
2011
+ }
2012
+ return {
2013
+ scrollLeft: element.pageXOffset,
2014
+ scrollTop: element.pageYOffset
2015
+ };
2016
+ }
2017
+
2018
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2019
+ let {
2020
+ rect,
2021
+ offsetParent,
2022
+ strategy
2023
+ } = _ref;
2024
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2025
+ const documentElement = getDocumentElement(offsetParent);
2026
+ if (offsetParent === documentElement) {
2027
+ return rect;
2028
+ }
2029
+ let scroll = {
2030
+ scrollLeft: 0,
2031
+ scrollTop: 0
2032
+ };
2033
+ let scale = {
2034
+ x: 1,
2035
+ y: 1
2036
+ };
2037
+ const offsets = {
2038
+ x: 0,
2039
+ y: 0
2040
+ };
2041
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
2042
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2043
+ scroll = getNodeScroll(offsetParent);
2044
+ }
2045
+ if (isHTMLElement(offsetParent)) {
2046
+ const offsetRect = getBoundingClientRect(offsetParent);
2047
+ scale = getScale(offsetParent);
2048
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2049
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2050
+ }
2051
+ }
2052
+ return {
2053
+ width: rect.width * scale.x,
2054
+ height: rect.height * scale.y,
2055
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2056
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2057
+ };
2058
+ }
2059
+
2060
+ function getWindowScrollBarX(element) {
2061
+ // If <html> has a CSS width greater than the viewport, then this will be
2062
+ // incorrect for RTL.
2063
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
2064
+ }
2065
+
2066
+ // Gets the entire size of the scrollable document area, even extending outside
2067
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2068
+ function getDocumentRect(element) {
2069
+ const html = getDocumentElement(element);
2070
+ const scroll = getNodeScroll(element);
2071
+ const body = element.ownerDocument.body;
2072
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2073
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2074
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2075
+ const y = -scroll.scrollTop;
2076
+ if (getComputedStyle$1(body).direction === 'rtl') {
2077
+ x += max(html.clientWidth, body.clientWidth) - width;
2078
+ }
2079
+ return {
2080
+ width,
2081
+ height,
2082
+ x,
2083
+ y
2084
+ };
2085
+ }
2086
+
2087
+ function getParentNode(node) {
2088
+ if (getNodeName(node) === 'html') {
2089
+ return node;
2090
+ }
2091
+ const result =
2092
+ // Step into the shadow DOM of the parent of a slotted node.
2093
+ node.assignedSlot ||
2094
+ // DOM Element detected.
2095
+ node.parentNode ||
2096
+ // ShadowRoot detected.
2097
+ isShadowRoot(node) && node.host ||
2098
+ // Fallback.
2099
+ getDocumentElement(node);
2100
+ return isShadowRoot(result) ? result.host : result;
2101
+ }
2102
+
2103
+ function getNearestOverflowAncestor(node) {
2104
+ const parentNode = getParentNode(node);
2105
+ if (isLastTraversableNode(parentNode)) {
2106
+ // `getParentNode` will never return a `Document` due to the fallback
2107
+ // check, so it's either the <html> or <body> element.
2108
+ return parentNode.ownerDocument.body;
2109
+ }
2110
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2111
+ return parentNode;
2112
+ }
2113
+ return getNearestOverflowAncestor(parentNode);
2114
+ }
2115
+
2116
+ function getOverflowAncestors(node, list) {
2117
+ var _node$ownerDocument;
2118
+ if (list === void 0) {
2119
+ list = [];
2120
+ }
2121
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2122
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
2123
+ const win = getWindow(scrollableAncestor);
2124
+ if (isBody) {
2125
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
2126
+ }
2127
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
2128
+ }
2129
+
2130
+ function getViewportRect(element, strategy) {
2131
+ const win = getWindow(element);
2132
+ const html = getDocumentElement(element);
2133
+ const visualViewport = win.visualViewport;
2134
+ let width = html.clientWidth;
2135
+ let height = html.clientHeight;
2136
+ let x = 0;
2137
+ let y = 0;
2138
+ if (visualViewport) {
2139
+ width = visualViewport.width;
2140
+ height = visualViewport.height;
2141
+ const visualViewportBased = isClientRectVisualViewportBased();
2142
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
2143
+ x = visualViewport.offsetLeft;
2144
+ y = visualViewport.offsetTop;
2145
+ }
2146
+ }
2147
+ return {
2148
+ width,
2149
+ height,
2150
+ x,
2151
+ y
2152
+ };
2153
+ }
2154
+
2155
+ // Returns the inner client rect, subtracting scrollbars if present.
2156
+ function getInnerBoundingClientRect(element, strategy) {
2157
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
2158
+ const top = clientRect.top + element.clientTop;
2159
+ const left = clientRect.left + element.clientLeft;
2160
+ const scale = isHTMLElement(element) ? getScale(element) : {
2161
+ x: 1,
2162
+ y: 1
2163
+ };
2164
+ const width = element.clientWidth * scale.x;
2165
+ const height = element.clientHeight * scale.y;
2166
+ const x = left * scale.x;
2167
+ const y = top * scale.y;
2168
+ return {
2169
+ width,
2170
+ height,
2171
+ x,
2172
+ y
2173
+ };
2174
+ }
2175
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2176
+ let rect;
2177
+ if (clippingAncestor === 'viewport') {
2178
+ rect = getViewportRect(element, strategy);
2179
+ } else if (clippingAncestor === 'document') {
2180
+ rect = getDocumentRect(getDocumentElement(element));
2181
+ } else if (isElement(clippingAncestor)) {
2182
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2183
+ } else {
2184
+ const mutableRect = {
2185
+ ...clippingAncestor
2186
+ };
2187
+ if (isClientRectVisualViewportBased()) {
2188
+ var _win$visualViewport, _win$visualViewport2;
2189
+ const win = getWindow(element);
2190
+ mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
2191
+ mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
2192
+ }
2193
+ rect = mutableRect;
2194
+ }
2195
+ return rectToClientRect(rect);
2196
+ }
2197
+
2198
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
2199
+ // clipping (or hiding) child elements. This returns all clipping ancestors
2200
+ // of the given element up the tree.
2201
+ function getClippingElementAncestors(element, cache) {
2202
+ const cachedResult = cache.get(element);
2203
+ if (cachedResult) {
2204
+ return cachedResult;
2205
+ }
2206
+ let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
2207
+ let currentContainingBlockComputedStyle = null;
2208
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
2209
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2210
+
2211
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2212
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2213
+ const computedStyle = getComputedStyle$1(currentNode);
2214
+ const containingBlock = isContainingBlock(currentNode);
2215
+ const shouldIgnoreCurrentNode = computedStyle.position === 'fixed';
2216
+ if (shouldIgnoreCurrentNode) {
2217
+ currentContainingBlockComputedStyle = null;
2218
+ } else {
2219
+ const shouldDropCurrentNode = elementIsFixed ? !containingBlock && !currentContainingBlockComputedStyle : !containingBlock && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position);
2220
+ if (shouldDropCurrentNode) {
2221
+ // Drop non-containing blocks.
2222
+ result = result.filter(ancestor => ancestor !== currentNode);
2223
+ } else {
2224
+ // Record last containing block for next iteration.
2225
+ currentContainingBlockComputedStyle = computedStyle;
2226
+ }
2227
+ }
2228
+ currentNode = getParentNode(currentNode);
2229
+ }
2230
+ cache.set(element, result);
2231
+ return result;
2232
+ }
2233
+
2234
+ // Gets the maximum area that the element is visible in due to any number of
2235
+ // clipping ancestors.
2236
+ function getClippingRect(_ref) {
2237
+ let {
2238
+ element,
2239
+ boundary,
2240
+ rootBoundary,
2241
+ strategy
2242
+ } = _ref;
2243
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
2244
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2245
+ const firstClippingAncestor = clippingAncestors[0];
2246
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2247
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2248
+ accRect.top = max(rect.top, accRect.top);
2249
+ accRect.right = min(rect.right, accRect.right);
2250
+ accRect.bottom = min(rect.bottom, accRect.bottom);
2251
+ accRect.left = max(rect.left, accRect.left);
2252
+ return accRect;
2253
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2254
+ return {
2255
+ width: clippingRect.right - clippingRect.left,
2256
+ height: clippingRect.bottom - clippingRect.top,
2257
+ x: clippingRect.left,
2258
+ y: clippingRect.top
2259
+ };
2260
+ }
2261
+
2262
+ function getDimensions(element) {
2263
+ if (isHTMLElement(element)) {
2264
+ return getCssDimensions(element);
2265
+ }
2266
+ return element.getBoundingClientRect();
2267
+ }
2268
+
2269
+ function getTrueOffsetParent(element, polyfill) {
2270
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
2271
+ return null;
2272
+ }
2273
+ if (polyfill) {
2274
+ return polyfill(element);
2275
+ }
2276
+ return element.offsetParent;
2277
+ }
2278
+ function getContainingBlock(element) {
2279
+ let currentNode = getParentNode(element);
2280
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2281
+ if (isContainingBlock(currentNode)) {
2282
+ return currentNode;
2283
+ } else {
2284
+ currentNode = getParentNode(currentNode);
2285
+ }
2286
+ }
2287
+ return null;
2288
+ }
2289
+
2290
+ // Gets the closest ancestor positioned element. Handles some edge cases,
2291
+ // such as table ancestors and cross browser bugs.
2292
+ function getOffsetParent(element, polyfill) {
2293
+ const window = getWindow(element);
2294
+ if (!isHTMLElement(element)) {
2295
+ return window;
2296
+ }
2297
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2298
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
2299
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2300
+ }
2301
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
2302
+ return window;
2303
+ }
2304
+ return offsetParent || getContainingBlock(element) || window;
2305
+ }
2306
+
2307
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2308
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2309
+ const documentElement = getDocumentElement(offsetParent);
2310
+ const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
2311
+ let scroll = {
2312
+ scrollLeft: 0,
2313
+ scrollTop: 0
2314
+ };
2315
+ const offsets = {
2316
+ x: 0,
2317
+ y: 0
2318
+ };
2319
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
2320
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2321
+ scroll = getNodeScroll(offsetParent);
2322
+ }
2323
+ if (isHTMLElement(offsetParent)) {
2324
+ const offsetRect = getBoundingClientRect(offsetParent, true);
2325
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2326
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2327
+ } else if (documentElement) {
2328
+ offsets.x = getWindowScrollBarX(documentElement);
2329
+ }
2330
+ }
2331
+ return {
2332
+ x: rect.left + scroll.scrollLeft - offsets.x,
2333
+ y: rect.top + scroll.scrollTop - offsets.y,
2334
+ width: rect.width,
2335
+ height: rect.height
2336
+ };
2337
+ }
2338
+
2339
+ const platform = {
2340
+ getClippingRect,
2341
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2342
+ isElement,
2343
+ getDimensions,
2344
+ getOffsetParent,
2345
+ getDocumentElement,
2346
+ getScale,
2347
+ async getElementRects(_ref) {
2348
+ let {
2349
+ reference,
2350
+ floating,
2351
+ strategy
2352
+ } = _ref;
2353
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2354
+ const getDimensionsFn = this.getDimensions;
2355
+ return {
2356
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
2357
+ floating: {
2358
+ x: 0,
2359
+ y: 0,
2360
+ ...(await getDimensionsFn(floating))
2361
+ }
2362
+ };
2363
+ },
2364
+ getClientRects: element => Array.from(element.getClientRects()),
2365
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
2366
+ };
2367
+
2368
+ /**
2369
+ * Computes the `x` and `y` coordinates that will place the floating element
2370
+ * next to a reference element when it is given a certain CSS positioning
2371
+ * strategy.
2372
+ */
2373
+ const computePosition = (reference, floating, options) => {
2374
+ // This caches the expensive `getClippingElementAncestors` function so that
2375
+ // multiple lifecycle resets re-use the same result. It only lives for a
2376
+ // single call. If other functions become expensive, we can add them as well.
2377
+ const cache = new Map();
2378
+ const mergedOptions = {
2379
+ platform,
2380
+ ...options
2381
+ };
2382
+ const platformWithCache = {
2383
+ ...mergedOptions.platform,
2384
+ _c: cache
2385
+ };
2386
+ return computePosition$1(reference, floating, {
2387
+ ...mergedOptions,
2388
+ platform: platformWithCache
2389
+ });
2390
+ };
2391
+
2392
+ const computeTooltipPosition = async ({ elementReference = null, tooltipReference = null, tooltipArrowReference = null, place = 'top', offset: offsetValue = 10, strategy = 'absolute', middlewares = [offset(Number(offsetValue)), flip(), shift({ padding: 5 })], }) => {
2393
+ if (!elementReference) {
2394
+ // elementReference can be null or undefined and we will not compute the position
2395
+ // eslint-disable-next-line no-console
2396
+ // console.error('The reference element for tooltip was not defined: ', elementReference)
2397
+ return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
2398
+ }
2399
+ if (tooltipReference === null) {
2400
+ return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
2401
+ }
2402
+ const middleware = middlewares;
2403
+ if (tooltipArrowReference) {
2404
+ middleware.push(arrow({ element: tooltipArrowReference, padding: 5 }));
2405
+ return computePosition(elementReference, tooltipReference, {
2406
+ placement: place,
2407
+ strategy,
2408
+ middleware,
2409
+ }).then(({ x, y, placement, middlewareData }) => {
2410
+ var _a, _b;
2411
+ const styles = { left: `${x}px`, top: `${y}px` };
2412
+ const { x: arrowX, y: arrowY } = (_a = middlewareData.arrow) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
2413
+ const staticSide = (_b = {
2414
+ top: 'bottom',
2415
+ right: 'left',
2416
+ bottom: 'top',
2417
+ left: 'right',
2418
+ }[placement.split('-')[0]]) !== null && _b !== void 0 ? _b : 'bottom';
2419
+ const arrowStyle = {
2420
+ left: arrowX != null ? `${arrowX}px` : '',
2421
+ top: arrowY != null ? `${arrowY}px` : '',
2422
+ right: '',
2423
+ bottom: '',
2424
+ [staticSide]: '-4px',
2425
+ };
2426
+ return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
2427
+ });
2428
+ }
2429
+ return computePosition(elementReference, tooltipReference, {
2430
+ placement: 'bottom',
2431
+ strategy,
2432
+ middleware,
2433
+ }).then(({ x, y, placement }) => {
2434
+ const styles = { left: `${x}px`, top: `${y}px` };
2435
+ return { tooltipStyles: styles, tooltipArrowStyles: {}, place: placement };
2436
+ });
2437
+ };
2438
+
2439
+ var styles = {"tooltip":"styles-module_tooltip__mnnfp","fixed":"styles-module_fixed__7ciUi","arrow":"styles-module_arrow__K0L3T","no-arrow":"styles-module_no-arrow__KcFZN","clickable":"styles-module_clickable__Bv9o7","show":"styles-module_show__2NboJ","dark":"styles-module_dark__xNqje","light":"styles-module_light__Z6W-X","success":"styles-module_success__A2AKt","warning":"styles-module_warning__SCK0X","error":"styles-module_error__JvumD","info":"styles-module_info__BWdHW"};
2440
+
2441
+ const Tooltip = ({
2442
+ // props
2443
+ id, className, classNameArrow, variant = 'dark', anchorId, anchorSelect, place = 'top', offset = 10, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, wrapper: WrapperElement, delayShow = 0, delayHide = 0, float = false, noArrow = false, clickable = false, closeOnEsc = false, style: externalStyles, position, afterShow, afterHide,
2444
+ // props handled by controller
2445
+ content, isOpen, setIsOpen, activeAnchor, setActiveAnchor, }) => {
2446
+ const tooltipRef = require$$0.useRef(null);
2447
+ const tooltipArrowRef = require$$0.useRef(null);
2448
+ const tooltipShowDelayTimerRef = require$$0.useRef(null);
2449
+ const tooltipHideDelayTimerRef = require$$0.useRef(null);
2450
+ const [actualPlacement, setActualPlacement] = require$$0.useState(place);
2451
+ const [inlineStyles, setInlineStyles] = require$$0.useState({});
2452
+ const [inlineArrowStyles, setInlineArrowStyles] = require$$0.useState({});
2453
+ const [show, setShow] = require$$0.useState(false);
2454
+ const [rendered, setRendered] = require$$0.useState(false);
2455
+ const wasShowing = require$$0.useRef(false);
2456
+ const lastFloatPosition = require$$0.useRef(null);
2457
+ /**
2458
+ * @todo Remove this in a future version (provider/wrapper method is deprecated)
2459
+ */
2460
+ const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip(id);
2461
+ const hoveringTooltip = require$$0.useRef(false);
2462
+ const [anchorsBySelect, setAnchorsBySelect] = require$$0.useState([]);
2463
+ const mounted = require$$0.useRef(false);
2464
+ const shouldOpenOnClick = openOnClick || events.includes('click');
2465
+ /**
2466
+ * useLayoutEffect runs before useEffect,
2467
+ * but should be used carefully because of caveats
2468
+ * https://beta.reactjs.org/reference/react/useLayoutEffect#caveats
2469
+ */
2470
+ useIsomorphicLayoutEffect(() => {
2471
+ mounted.current = true;
2472
+ return () => {
2473
+ mounted.current = false;
2474
+ };
2475
+ }, []);
2476
+ require$$0.useEffect(() => {
2477
+ if (!show) {
2478
+ /**
2479
+ * this fixes weird behavior when switching between two anchor elements very quickly
2480
+ * remove the timeout and switch quickly between two adjancent anchor elements to see it
2481
+ *
2482
+ * in practice, this means the tooltip is not immediately removed from the DOM on hide
2483
+ */
2484
+ const timeout = setTimeout(() => {
2485
+ setRendered(false);
2486
+ }, 150);
2487
+ return () => {
2488
+ clearTimeout(timeout);
2489
+ };
2490
+ }
2491
+ return () => null;
2492
+ }, [show]);
2493
+ const handleShow = (value) => {
2494
+ if (!mounted.current) {
2495
+ return;
2496
+ }
2497
+ if (value) {
2498
+ setRendered(true);
2499
+ }
2500
+ /**
2501
+ * wait for the component to render and calculate position
2502
+ * before actually showing
2503
+ */
2504
+ setTimeout(() => {
2505
+ if (!mounted.current) {
2506
+ return;
2507
+ }
2508
+ setIsOpen === null || setIsOpen === void 0 ? void 0 : setIsOpen(value);
2509
+ if (isOpen === undefined) {
2510
+ setShow(value);
2511
+ }
2512
+ }, 10);
2513
+ };
2514
+ /**
2515
+ * this replicates the effect from `handleShow()`
2516
+ * when `isOpen` is changed from outside
2517
+ */
2518
+ require$$0.useEffect(() => {
2519
+ if (isOpen === undefined) {
2520
+ return () => null;
2521
+ }
2522
+ if (isOpen) {
2523
+ setRendered(true);
2524
+ }
2525
+ const timeout = setTimeout(() => {
2526
+ setShow(isOpen);
2527
+ }, 10);
2528
+ return () => {
2529
+ clearTimeout(timeout);
2530
+ };
2531
+ }, [isOpen]);
2532
+ require$$0.useEffect(() => {
2533
+ if (show === wasShowing.current) {
2534
+ return;
2535
+ }
2536
+ wasShowing.current = show;
2537
+ if (show) {
2538
+ afterShow === null || afterShow === void 0 ? void 0 : afterShow();
2539
+ }
2540
+ else {
2541
+ afterHide === null || afterHide === void 0 ? void 0 : afterHide();
2542
+ }
2543
+ }, [show]);
2544
+ const handleShowTooltipDelayed = () => {
2545
+ if (tooltipShowDelayTimerRef.current) {
2546
+ clearTimeout(tooltipShowDelayTimerRef.current);
2547
+ }
2548
+ tooltipShowDelayTimerRef.current = setTimeout(() => {
2549
+ handleShow(true);
2550
+ }, delayShow);
2551
+ };
2552
+ const handleHideTooltipDelayed = (delay = delayHide) => {
2553
+ if (tooltipHideDelayTimerRef.current) {
2554
+ clearTimeout(tooltipHideDelayTimerRef.current);
2555
+ }
2556
+ tooltipHideDelayTimerRef.current = setTimeout(() => {
2557
+ if (hoveringTooltip.current) {
2558
+ return;
2559
+ }
2560
+ handleShow(false);
2561
+ }, delay);
2562
+ };
2563
+ const handleShowTooltip = (event) => {
2564
+ var _a;
2565
+ if (!event) {
2566
+ return;
2567
+ }
2568
+ if (delayShow) {
2569
+ handleShowTooltipDelayed();
2570
+ }
2571
+ else {
2572
+ handleShow(true);
2573
+ }
2574
+ const target = (_a = event.currentTarget) !== null && _a !== void 0 ? _a : event.target;
2575
+ setActiveAnchor(target);
2576
+ setProviderActiveAnchor({ current: target });
2577
+ if (tooltipHideDelayTimerRef.current) {
2578
+ clearTimeout(tooltipHideDelayTimerRef.current);
2579
+ }
2580
+ };
2581
+ const handleHideTooltip = () => {
2582
+ if (clickable) {
2583
+ // allow time for the mouse to reach the tooltip, in case there's a gap
2584
+ handleHideTooltipDelayed(delayHide || 100);
2585
+ }
2586
+ else if (delayHide) {
2587
+ handleHideTooltipDelayed();
2588
+ }
2589
+ else {
2590
+ handleShow(false);
2591
+ }
2592
+ if (tooltipShowDelayTimerRef.current) {
2593
+ clearTimeout(tooltipShowDelayTimerRef.current);
2594
+ }
2595
+ };
2596
+ const handleTooltipPosition = ({ x, y }) => {
2597
+ const virtualElement = {
2598
+ getBoundingClientRect() {
2599
+ return {
2600
+ x,
2601
+ y,
2602
+ width: 0,
2603
+ height: 0,
2604
+ top: y,
2605
+ left: x,
2606
+ right: x,
2607
+ bottom: y,
2608
+ };
2609
+ },
2610
+ };
2611
+ computeTooltipPosition({
2612
+ place,
2613
+ offset,
2614
+ elementReference: virtualElement,
2615
+ tooltipReference: tooltipRef.current,
2616
+ tooltipArrowReference: tooltipArrowRef.current,
2617
+ strategy: positionStrategy,
2618
+ middlewares,
2619
+ }).then((computedStylesData) => {
2620
+ if (Object.keys(computedStylesData.tooltipStyles).length) {
2621
+ setInlineStyles(computedStylesData.tooltipStyles);
2622
+ }
2623
+ if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
2624
+ setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
2625
+ }
2626
+ setActualPlacement(computedStylesData.place);
2627
+ });
2628
+ };
2629
+ const handleMouseMove = (event) => {
2630
+ if (!event) {
2631
+ return;
2632
+ }
2633
+ const mouseEvent = event;
2634
+ const mousePosition = {
2635
+ x: mouseEvent.clientX,
2636
+ y: mouseEvent.clientY,
2637
+ };
2638
+ handleTooltipPosition(mousePosition);
2639
+ lastFloatPosition.current = mousePosition;
2640
+ };
2641
+ const handleClickTooltipAnchor = (event) => {
2642
+ handleShowTooltip(event);
2643
+ if (delayHide) {
2644
+ handleHideTooltipDelayed();
2645
+ }
2646
+ };
2647
+ const handleClickOutsideAnchors = (event) => {
2648
+ var _a;
2649
+ const anchorById = document.querySelector(`[id='${anchorId}']`);
2650
+ const anchors = [anchorById, ...anchorsBySelect];
2651
+ if (anchors.some((anchor) => anchor === null || anchor === void 0 ? void 0 : anchor.contains(event.target))) {
2652
+ return;
2653
+ }
2654
+ if ((_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) {
2655
+ return;
2656
+ }
2657
+ handleShow(false);
2658
+ };
2659
+ const handleEsc = (event) => {
2660
+ if (event.key !== 'Escape') {
2661
+ return;
2662
+ }
2663
+ handleShow(false);
2664
+ };
2665
+ // debounce handler to prevent call twice when
2666
+ // mouse enter and focus events being triggered toggether
2667
+ const debouncedHandleShowTooltip = debounce(handleShowTooltip, 50);
2668
+ const debouncedHandleHideTooltip = debounce(handleHideTooltip, 50);
2669
+ require$$0.useEffect(() => {
2670
+ var _a, _b;
2671
+ const elementRefs = new Set(anchorRefs);
2672
+ anchorsBySelect.forEach((anchor) => {
2673
+ elementRefs.add({ current: anchor });
2674
+ });
2675
+ const anchorById = document.querySelector(`[id='${anchorId}']`);
2676
+ if (anchorById) {
2677
+ elementRefs.add({ current: anchorById });
2678
+ }
2679
+ if (closeOnEsc) {
2680
+ window.addEventListener('keydown', handleEsc);
2681
+ }
2682
+ const enabledEvents = [];
2683
+ if (shouldOpenOnClick) {
2684
+ window.addEventListener('click', handleClickOutsideAnchors);
2685
+ enabledEvents.push({ event: 'click', listener: handleClickTooltipAnchor });
2686
+ }
2687
+ else {
2688
+ enabledEvents.push({ event: 'mouseenter', listener: debouncedHandleShowTooltip }, { event: 'mouseleave', listener: debouncedHandleHideTooltip }, { event: 'focus', listener: debouncedHandleShowTooltip }, { event: 'blur', listener: debouncedHandleHideTooltip });
2689
+ if (float) {
2690
+ enabledEvents.push({
2691
+ event: 'mousemove',
2692
+ listener: handleMouseMove,
2693
+ });
2694
+ }
2695
+ }
2696
+ const handleMouseEnterTooltip = () => {
2697
+ hoveringTooltip.current = true;
2698
+ };
2699
+ const handleMouseLeaveTooltip = () => {
2700
+ hoveringTooltip.current = false;
2701
+ handleHideTooltip();
2702
+ };
2703
+ if (clickable && !shouldOpenOnClick) {
2704
+ (_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', handleMouseEnterTooltip);
2705
+ (_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', handleMouseLeaveTooltip);
2706
+ }
2707
+ enabledEvents.forEach(({ event, listener }) => {
2708
+ elementRefs.forEach((ref) => {
2709
+ var _a;
2710
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener(event, listener);
2711
+ });
2712
+ });
2713
+ return () => {
2714
+ var _a, _b;
2715
+ if (shouldOpenOnClick) {
2716
+ window.removeEventListener('click', handleClickOutsideAnchors);
2717
+ }
2718
+ if (closeOnEsc) {
2719
+ window.removeEventListener('keydown', handleEsc);
2720
+ }
2721
+ if (clickable && !shouldOpenOnClick) {
2722
+ (_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', handleMouseEnterTooltip);
2723
+ (_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', handleMouseLeaveTooltip);
2724
+ }
2725
+ enabledEvents.forEach(({ event, listener }) => {
2726
+ elementRefs.forEach((ref) => {
2727
+ var _a;
2728
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener(event, listener);
2729
+ });
2730
+ });
2731
+ };
2732
+ /**
2733
+ * rendered is also a dependency to ensure anchor observers are re-registered
2734
+ * since `tooltipRef` becomes stale after removing/adding the tooltip to the DOM
2735
+ */
2736
+ }, [rendered, anchorRefs, anchorsBySelect, closeOnEsc, events]);
2737
+ require$$0.useEffect(() => {
2738
+ let selector = anchorSelect !== null && anchorSelect !== void 0 ? anchorSelect : '';
2739
+ if (!selector && id) {
2740
+ selector = `[data-tooltip-id='${id}']`;
2741
+ }
2742
+ const documentObserverCallback = (mutationList) => {
2743
+ const newAnchors = [];
2744
+ mutationList.forEach((mutation) => {
2745
+ if (mutation.type === 'attributes' && mutation.attributeName === 'data-tooltip-id') {
2746
+ const newId = mutation.target.getAttribute('data-tooltip-id');
2747
+ if (newId === id) {
2748
+ newAnchors.push(mutation.target);
2749
+ }
2750
+ }
2751
+ if (mutation.type !== 'childList') {
2752
+ return;
2753
+ }
2754
+ if (activeAnchor) {
2755
+ [...mutation.removedNodes].some((node) => {
2756
+ if (node.contains(activeAnchor)) {
2757
+ setRendered(false);
2758
+ handleShow(false);
2759
+ setActiveAnchor(null);
2760
+ return true;
2761
+ }
2762
+ return false;
2763
+ });
2764
+ }
2765
+ if (!selector) {
2766
+ return;
2767
+ }
2768
+ try {
2769
+ const elements = [...mutation.addedNodes].filter((node) => node.nodeType === 1);
2770
+ newAnchors.push(
2771
+ // the element itself is an anchor
2772
+ ...elements.filter((element) => element.matches(selector)));
2773
+ newAnchors.push(
2774
+ // the element has children which are anchors
2775
+ ...elements.flatMap((element) => [...element.querySelectorAll(selector)]));
2776
+ }
2777
+ catch (_a) {
2778
+ /**
2779
+ * invalid CSS selector.
2780
+ * already warned on tooltip controller
2781
+ */
2782
+ }
2783
+ });
2784
+ if (newAnchors.length) {
2785
+ setAnchorsBySelect((anchors) => [...anchors, ...newAnchors]);
2786
+ }
2787
+ };
2788
+ const documentObserver = new MutationObserver(documentObserverCallback);
2789
+ // watch for anchor being removed from the DOM
2790
+ documentObserver.observe(document.body, {
2791
+ childList: true,
2792
+ subtree: true,
2793
+ attributes: true,
2794
+ attributeFilter: ['data-tooltip-id'],
2795
+ });
2796
+ return () => {
2797
+ documentObserver.disconnect();
2798
+ };
2799
+ }, [id, anchorSelect, activeAnchor]);
2800
+ require$$0.useEffect(() => {
2801
+ if (position) {
2802
+ // if `position` is set, override regular and `float` positioning
2803
+ handleTooltipPosition(position);
2804
+ return;
2805
+ }
2806
+ if (float) {
2807
+ if (lastFloatPosition.current) {
2808
+ /*
2809
+ Without this, changes to `content`, `place`, `offset`, ..., will only
2810
+ trigger a position calculation after a `mousemove` event.
2811
+
2812
+ To see why this matters, comment this line, run `yarn dev` and click the
2813
+ "Hover me!" anchor.
2814
+ */
2815
+ handleTooltipPosition(lastFloatPosition.current);
2816
+ }
2817
+ // if `float` is set, override regular positioning
2818
+ return;
2819
+ }
2820
+ computeTooltipPosition({
2821
+ place,
2822
+ offset,
2823
+ elementReference: activeAnchor,
2824
+ tooltipReference: tooltipRef.current,
2825
+ tooltipArrowReference: tooltipArrowRef.current,
2826
+ strategy: positionStrategy,
2827
+ middlewares,
2828
+ }).then((computedStylesData) => {
2829
+ if (!mounted.current) {
2830
+ // invalidate computed positions after remount
2831
+ return;
2832
+ }
2833
+ if (Object.keys(computedStylesData.tooltipStyles).length) {
2834
+ setInlineStyles(computedStylesData.tooltipStyles);
2835
+ }
2836
+ if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
2837
+ setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
2838
+ }
2839
+ setActualPlacement(computedStylesData.place);
2840
+ });
2841
+ }, [show, activeAnchor, content, place, offset, positionStrategy, position]);
2842
+ require$$0.useEffect(() => {
2843
+ var _a;
2844
+ const anchorById = document.querySelector(`[id='${anchorId}']`);
2845
+ const anchors = [...anchorsBySelect, anchorById];
2846
+ if (!activeAnchor || !anchors.includes(activeAnchor)) {
2847
+ /**
2848
+ * if there is no active anchor,
2849
+ * or if the current active anchor is not amongst the allowed ones,
2850
+ * reset it
2851
+ */
2852
+ setActiveAnchor((_a = anchorsBySelect[0]) !== null && _a !== void 0 ? _a : anchorById);
2853
+ }
2854
+ }, [anchorId, anchorsBySelect, activeAnchor]);
2855
+ require$$0.useEffect(() => {
2856
+ return () => {
2857
+ if (tooltipShowDelayTimerRef.current) {
2858
+ clearTimeout(tooltipShowDelayTimerRef.current);
2859
+ }
2860
+ if (tooltipHideDelayTimerRef.current) {
2861
+ clearTimeout(tooltipHideDelayTimerRef.current);
2862
+ }
2863
+ };
2864
+ }, []);
2865
+ require$$0.useEffect(() => {
2866
+ let selector = anchorSelect;
2867
+ if (!selector && id) {
2868
+ selector = `[data-tooltip-id='${id}']`;
2869
+ }
2870
+ if (!selector) {
2871
+ return;
2872
+ }
2873
+ try {
2874
+ const anchors = Array.from(document.querySelectorAll(selector));
2875
+ setAnchorsBySelect(anchors);
2876
+ }
2877
+ catch (_a) {
2878
+ // warning was already issued in the controller
2879
+ setAnchorsBySelect([]);
2880
+ }
2881
+ }, [id, anchorSelect]);
2882
+ const canShow = content && show && Object.keys(inlineStyles).length > 0;
2883
+ return rendered ? (jsxRuntime.exports.jsxs(WrapperElement, { id: id, role: "tooltip", className: classNames('react-tooltip', styles['tooltip'], styles[variant], className, `react-tooltip__place-${actualPlacement}`, {
2884
+ [styles['show']]: canShow,
2885
+ [styles['fixed']]: positionStrategy === 'fixed',
2886
+ [styles['clickable']]: clickable,
2887
+ }), style: { ...externalStyles, ...inlineStyles }, ref: tooltipRef, children: [content, jsxRuntime.exports.jsx(WrapperElement, { className: classNames('react-tooltip-arrow', styles['arrow'], classNameArrow, {
2888
+ /**
2889
+ * changed from dash `no-arrow` to camelcase because of:
2890
+ * https://github.com/indooorsman/esbuild-css-modules-plugin/issues/42
2891
+ */
2892
+ [styles['noArrow']]: noArrow,
2893
+ }), style: inlineArrowStyles, ref: tooltipArrowRef })] })) : null;
2894
+ };
2895
+
2896
+ const TooltipContent = ({ content }) => {
2897
+ return jsxRuntime.exports.jsx("span", { dangerouslySetInnerHTML: { __html: content } });
2898
+ };
2899
+
2900
+ const TooltipController = ({ id, anchorId, anchorSelect, content, html, render, className, classNameArrow, variant = 'dark', place = 'top', offset = 10, wrapper = 'div', children = null, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, delayShow = 0, delayHide = 0, float = false, noArrow = false, clickable = false, closeOnEsc = false, style, position, isOpen, setIsOpen, afterShow, afterHide, }) => {
2901
+ const [tooltipContent, setTooltipContent] = require$$0.useState(content);
2902
+ const [tooltipHtml, setTooltipHtml] = require$$0.useState(html);
2903
+ const [tooltipPlace, setTooltipPlace] = require$$0.useState(place);
2904
+ const [tooltipVariant, setTooltipVariant] = require$$0.useState(variant);
2905
+ const [tooltipOffset, setTooltipOffset] = require$$0.useState(offset);
2906
+ const [tooltipDelayShow, setTooltipDelayShow] = require$$0.useState(delayShow);
2907
+ const [tooltipDelayHide, setTooltipDelayHide] = require$$0.useState(delayHide);
2908
+ const [tooltipFloat, setTooltipFloat] = require$$0.useState(float);
2909
+ const [tooltipWrapper, setTooltipWrapper] = require$$0.useState(wrapper);
2910
+ const [tooltipEvents, setTooltipEvents] = require$$0.useState(events);
2911
+ const [tooltipPositionStrategy, setTooltipPositionStrategy] = require$$0.useState(positionStrategy);
2912
+ const [activeAnchor, setActiveAnchor] = require$$0.useState(null);
2913
+ /**
2914
+ * @todo Remove this in a future version (provider/wrapper method is deprecated)
2915
+ */
2916
+ const { anchorRefs, activeAnchor: providerActiveAnchor } = useTooltip(id);
2917
+ const getDataAttributesFromAnchorElement = (elementReference) => {
2918
+ const dataAttributes = elementReference === null || elementReference === void 0 ? void 0 : elementReference.getAttributeNames().reduce((acc, name) => {
2919
+ var _a;
2920
+ if (name.startsWith('data-tooltip-')) {
2921
+ const parsedAttribute = name.replace(/^data-tooltip-/, '');
2922
+ acc[parsedAttribute] = (_a = elementReference === null || elementReference === void 0 ? void 0 : elementReference.getAttribute(name)) !== null && _a !== void 0 ? _a : null;
2923
+ }
2924
+ return acc;
2925
+ }, {});
2926
+ return dataAttributes;
2927
+ };
2928
+ const applyAllDataAttributesFromAnchorElement = (dataAttributes) => {
2929
+ const handleDataAttributes = {
2930
+ place: (value) => {
2931
+ var _a;
2932
+ setTooltipPlace((_a = value) !== null && _a !== void 0 ? _a : place);
2933
+ },
2934
+ content: (value) => {
2935
+ setTooltipContent(value !== null && value !== void 0 ? value : content);
2936
+ },
2937
+ html: (value) => {
2938
+ setTooltipHtml(value !== null && value !== void 0 ? value : html);
2939
+ },
2940
+ variant: (value) => {
2941
+ var _a;
2942
+ setTooltipVariant((_a = value) !== null && _a !== void 0 ? _a : variant);
2943
+ },
2944
+ offset: (value) => {
2945
+ setTooltipOffset(value === null ? offset : Number(value));
2946
+ },
2947
+ wrapper: (value) => {
2948
+ var _a;
2949
+ setTooltipWrapper((_a = value) !== null && _a !== void 0 ? _a : wrapper);
2950
+ },
2951
+ events: (value) => {
2952
+ const parsed = value === null || value === void 0 ? void 0 : value.split(' ');
2953
+ setTooltipEvents(parsed !== null && parsed !== void 0 ? parsed : events);
2954
+ },
2955
+ 'position-strategy': (value) => {
2956
+ var _a;
2957
+ setTooltipPositionStrategy((_a = value) !== null && _a !== void 0 ? _a : positionStrategy);
2958
+ },
2959
+ 'delay-show': (value) => {
2960
+ setTooltipDelayShow(value === null ? delayShow : Number(value));
2961
+ },
2962
+ 'delay-hide': (value) => {
2963
+ setTooltipDelayHide(value === null ? delayHide : Number(value));
2964
+ },
2965
+ float: (value) => {
2966
+ setTooltipFloat(value === null ? float : value === 'true');
2967
+ },
2968
+ };
2969
+ // reset unset data attributes to default values
2970
+ // without this, data attributes from the last active anchor will still be used
2971
+ Object.values(handleDataAttributes).forEach((handler) => handler(null));
2972
+ Object.entries(dataAttributes).forEach(([key, value]) => {
2973
+ var _a;
2974
+ (_a = handleDataAttributes[key]) === null || _a === void 0 ? void 0 : _a.call(handleDataAttributes, value);
2975
+ });
2976
+ };
2977
+ require$$0.useEffect(() => {
2978
+ setTooltipContent(content);
2979
+ }, [content]);
2980
+ require$$0.useEffect(() => {
2981
+ setTooltipHtml(html);
2982
+ }, [html]);
2983
+ require$$0.useEffect(() => {
2984
+ setTooltipPlace(place);
2985
+ }, [place]);
2986
+ require$$0.useEffect(() => {
2987
+ var _a;
2988
+ const elementRefs = new Set(anchorRefs);
2989
+ let selector = anchorSelect;
2990
+ if (!selector && id) {
2991
+ selector = `[data-tooltip-id='${id}']`;
2992
+ }
2993
+ if (selector) {
2994
+ try {
2995
+ const anchorsBySelect = document.querySelectorAll(selector);
2996
+ anchorsBySelect.forEach((anchor) => {
2997
+ elementRefs.add({ current: anchor });
2998
+ });
2999
+ }
3000
+ catch (_b) {
3001
+ {
3002
+ // eslint-disable-next-line no-console
3003
+ console.warn(`[react-tooltip] "${anchorSelect}" is not a valid CSS selector`);
3004
+ }
3005
+ }
3006
+ }
3007
+ const anchorById = document.querySelector(`[id='${anchorId}']`);
3008
+ if (anchorById) {
3009
+ elementRefs.add({ current: anchorById });
3010
+ }
3011
+ if (!elementRefs.size) {
3012
+ return () => null;
3013
+ }
3014
+ const anchorElement = (_a = activeAnchor !== null && activeAnchor !== void 0 ? activeAnchor : anchorById) !== null && _a !== void 0 ? _a : providerActiveAnchor.current;
3015
+ const observerCallback = (mutationList) => {
3016
+ mutationList.forEach((mutation) => {
3017
+ var _a;
3018
+ if (!anchorElement ||
3019
+ mutation.type !== 'attributes' ||
3020
+ !((_a = mutation.attributeName) === null || _a === void 0 ? void 0 : _a.startsWith('data-tooltip-'))) {
3021
+ return;
3022
+ }
3023
+ // make sure to get all set attributes, since all unset attributes are reset
3024
+ const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
3025
+ applyAllDataAttributesFromAnchorElement(dataAttributes);
3026
+ });
3027
+ };
3028
+ // Create an observer instance linked to the callback function
3029
+ const observer = new MutationObserver(observerCallback);
3030
+ // do not check for subtree and childrens, we only want to know attribute changes
3031
+ // to stay watching `data-attributes-*` from anchor element
3032
+ const observerConfig = { attributes: true, childList: false, subtree: false };
3033
+ if (anchorElement) {
3034
+ const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
3035
+ applyAllDataAttributesFromAnchorElement(dataAttributes);
3036
+ // Start observing the target node for configured mutations
3037
+ observer.observe(anchorElement, observerConfig);
3038
+ }
3039
+ return () => {
3040
+ // Remove the observer when the tooltip is destroyed
3041
+ observer.disconnect();
3042
+ };
3043
+ }, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
3044
+ /**
3045
+ * content priority: children < renderContent or content < html
3046
+ * children should be lower priority so that it can be used as the "default" content
3047
+ */
3048
+ let renderedContent = children;
3049
+ if (render) {
3050
+ renderedContent = render({ content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : null, activeAnchor });
3051
+ }
3052
+ else if (tooltipContent) {
3053
+ renderedContent = tooltipContent;
3054
+ }
3055
+ if (tooltipHtml) {
3056
+ renderedContent = jsxRuntime.exports.jsx(TooltipContent, { content: tooltipHtml });
3057
+ }
3058
+ const props = {
3059
+ id,
3060
+ anchorId,
3061
+ anchorSelect,
3062
+ className,
3063
+ classNameArrow,
3064
+ content: renderedContent,
3065
+ place: tooltipPlace,
3066
+ variant: tooltipVariant,
3067
+ offset: tooltipOffset,
3068
+ wrapper: tooltipWrapper,
3069
+ events: tooltipEvents,
3070
+ openOnClick,
3071
+ positionStrategy: tooltipPositionStrategy,
3072
+ middlewares,
3073
+ delayShow: tooltipDelayShow,
3074
+ delayHide: tooltipDelayHide,
3075
+ float: tooltipFloat,
3076
+ noArrow,
3077
+ clickable,
3078
+ closeOnEsc,
3079
+ style,
3080
+ position,
3081
+ isOpen,
3082
+ setIsOpen,
3083
+ afterShow,
3084
+ afterHide,
3085
+ activeAnchor,
3086
+ setActiveAnchor: (anchor) => setActiveAnchor(anchor),
3087
+ };
3088
+ return jsxRuntime.exports.jsx(Tooltip, { ...props });
3089
+ };
3090
+
3091
+ exports.Tooltip = TooltipController;
3092
+ exports.TooltipProvider = TooltipProvider;
3093
+ exports.TooltipWrapper = TooltipWrapper;
3094
+
3095
+ Object.defineProperty(exports, '__esModule', { value: true });
3096
+
3097
+ }));