@atawi/react-popover 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js ADDED
@@ -0,0 +1,1429 @@
1
+ import require$$0, { useEffect, useRef, useState, useCallback } from "react";
2
+ import { createPortal } from "react-dom";
3
+ var jsxRuntime = { exports: {} };
4
+ var reactJsxRuntime_production_min = {};
5
+ /**
6
+ * @license React
7
+ * react-jsx-runtime.production.min.js
8
+ *
9
+ * Copyright (c) Facebook, Inc. and its affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ var hasRequiredReactJsxRuntime_production_min;
15
+ function requireReactJsxRuntime_production_min() {
16
+ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
17
+ hasRequiredReactJsxRuntime_production_min = 1;
18
+ var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
19
+ function q(c, a, g) {
20
+ var b, d = {}, e = null, h = null;
21
+ void 0 !== g && (e = "" + g);
22
+ void 0 !== a.key && (e = "" + a.key);
23
+ void 0 !== a.ref && (h = a.ref);
24
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
25
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
26
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
27
+ }
28
+ reactJsxRuntime_production_min.Fragment = l;
29
+ reactJsxRuntime_production_min.jsx = q;
30
+ reactJsxRuntime_production_min.jsxs = q;
31
+ return reactJsxRuntime_production_min;
32
+ }
33
+ var reactJsxRuntime_development = {};
34
+ /**
35
+ * @license React
36
+ * react-jsx-runtime.development.js
37
+ *
38
+ * Copyright (c) Facebook, Inc. and its affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */
43
+ var hasRequiredReactJsxRuntime_development;
44
+ function requireReactJsxRuntime_development() {
45
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
46
+ hasRequiredReactJsxRuntime_development = 1;
47
+ if (process.env.NODE_ENV !== "production") {
48
+ (function() {
49
+ var React = require$$0;
50
+ var REACT_ELEMENT_TYPE = Symbol.for("react.element");
51
+ var REACT_PORTAL_TYPE = Symbol.for("react.portal");
52
+ var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
53
+ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
54
+ var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
55
+ var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
56
+ var REACT_CONTEXT_TYPE = Symbol.for("react.context");
57
+ var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
58
+ var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
59
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
60
+ var REACT_MEMO_TYPE = Symbol.for("react.memo");
61
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
62
+ var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
63
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
64
+ var FAUX_ITERATOR_SYMBOL = "@@iterator";
65
+ function getIteratorFn(maybeIterable) {
66
+ if (maybeIterable === null || typeof maybeIterable !== "object") {
67
+ return null;
68
+ }
69
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
70
+ if (typeof maybeIterator === "function") {
71
+ return maybeIterator;
72
+ }
73
+ return null;
74
+ }
75
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
76
+ function error(format) {
77
+ {
78
+ {
79
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
80
+ args[_key2 - 1] = arguments[_key2];
81
+ }
82
+ printWarning("error", format, args);
83
+ }
84
+ }
85
+ }
86
+ function printWarning(level, format, args) {
87
+ {
88
+ var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
89
+ var stack = ReactDebugCurrentFrame2.getStackAddendum();
90
+ if (stack !== "") {
91
+ format += "%s";
92
+ args = args.concat([stack]);
93
+ }
94
+ var argsWithFormat = args.map(function(item) {
95
+ return String(item);
96
+ });
97
+ argsWithFormat.unshift("Warning: " + format);
98
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
99
+ }
100
+ }
101
+ var enableScopeAPI = false;
102
+ var enableCacheElement = false;
103
+ var enableTransitionTracing = false;
104
+ var enableLegacyHidden = false;
105
+ var enableDebugTracing = false;
106
+ var REACT_MODULE_REFERENCE;
107
+ {
108
+ REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
109
+ }
110
+ function isValidElementType(type) {
111
+ if (typeof type === "string" || typeof type === "function") {
112
+ return true;
113
+ }
114
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
115
+ return true;
116
+ }
117
+ if (typeof type === "object" && type !== null) {
118
+ 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 || // This needs to include all possible module reference object
119
+ // types supported by any Flight configuration anywhere since
120
+ // we don't know which Flight build this will end up being used
121
+ // with.
122
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
123
+ return true;
124
+ }
125
+ }
126
+ return false;
127
+ }
128
+ function getWrappedName(outerType, innerType, wrapperName) {
129
+ var displayName = outerType.displayName;
130
+ if (displayName) {
131
+ return displayName;
132
+ }
133
+ var functionName = innerType.displayName || innerType.name || "";
134
+ return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
135
+ }
136
+ function getContextName(type) {
137
+ return type.displayName || "Context";
138
+ }
139
+ function getComponentNameFromType(type) {
140
+ if (type == null) {
141
+ return null;
142
+ }
143
+ {
144
+ if (typeof type.tag === "number") {
145
+ error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
146
+ }
147
+ }
148
+ if (typeof type === "function") {
149
+ return type.displayName || type.name || null;
150
+ }
151
+ if (typeof type === "string") {
152
+ return type;
153
+ }
154
+ switch (type) {
155
+ case REACT_FRAGMENT_TYPE:
156
+ return "Fragment";
157
+ case REACT_PORTAL_TYPE:
158
+ return "Portal";
159
+ case REACT_PROFILER_TYPE:
160
+ return "Profiler";
161
+ case REACT_STRICT_MODE_TYPE:
162
+ return "StrictMode";
163
+ case REACT_SUSPENSE_TYPE:
164
+ return "Suspense";
165
+ case REACT_SUSPENSE_LIST_TYPE:
166
+ return "SuspenseList";
167
+ }
168
+ if (typeof type === "object") {
169
+ switch (type.$$typeof) {
170
+ case REACT_CONTEXT_TYPE:
171
+ var context = type;
172
+ return getContextName(context) + ".Consumer";
173
+ case REACT_PROVIDER_TYPE:
174
+ var provider = type;
175
+ return getContextName(provider._context) + ".Provider";
176
+ case REACT_FORWARD_REF_TYPE:
177
+ return getWrappedName(type, type.render, "ForwardRef");
178
+ case REACT_MEMO_TYPE:
179
+ var outerName = type.displayName || null;
180
+ if (outerName !== null) {
181
+ return outerName;
182
+ }
183
+ return getComponentNameFromType(type.type) || "Memo";
184
+ case REACT_LAZY_TYPE: {
185
+ var lazyComponent = type;
186
+ var payload = lazyComponent._payload;
187
+ var init = lazyComponent._init;
188
+ try {
189
+ return getComponentNameFromType(init(payload));
190
+ } catch (x) {
191
+ return null;
192
+ }
193
+ }
194
+ }
195
+ }
196
+ return null;
197
+ }
198
+ var assign = Object.assign;
199
+ var disabledDepth = 0;
200
+ var prevLog;
201
+ var prevInfo;
202
+ var prevWarn;
203
+ var prevError;
204
+ var prevGroup;
205
+ var prevGroupCollapsed;
206
+ var prevGroupEnd;
207
+ function disabledLog() {
208
+ }
209
+ disabledLog.__reactDisabledLog = true;
210
+ function disableLogs() {
211
+ {
212
+ if (disabledDepth === 0) {
213
+ prevLog = console.log;
214
+ prevInfo = console.info;
215
+ prevWarn = console.warn;
216
+ prevError = console.error;
217
+ prevGroup = console.group;
218
+ prevGroupCollapsed = console.groupCollapsed;
219
+ prevGroupEnd = console.groupEnd;
220
+ var props = {
221
+ configurable: true,
222
+ enumerable: true,
223
+ value: disabledLog,
224
+ writable: true
225
+ };
226
+ Object.defineProperties(console, {
227
+ info: props,
228
+ log: props,
229
+ warn: props,
230
+ error: props,
231
+ group: props,
232
+ groupCollapsed: props,
233
+ groupEnd: props
234
+ });
235
+ }
236
+ disabledDepth++;
237
+ }
238
+ }
239
+ function reenableLogs() {
240
+ {
241
+ disabledDepth--;
242
+ if (disabledDepth === 0) {
243
+ var props = {
244
+ configurable: true,
245
+ enumerable: true,
246
+ writable: true
247
+ };
248
+ Object.defineProperties(console, {
249
+ log: assign({}, props, {
250
+ value: prevLog
251
+ }),
252
+ info: assign({}, props, {
253
+ value: prevInfo
254
+ }),
255
+ warn: assign({}, props, {
256
+ value: prevWarn
257
+ }),
258
+ error: assign({}, props, {
259
+ value: prevError
260
+ }),
261
+ group: assign({}, props, {
262
+ value: prevGroup
263
+ }),
264
+ groupCollapsed: assign({}, props, {
265
+ value: prevGroupCollapsed
266
+ }),
267
+ groupEnd: assign({}, props, {
268
+ value: prevGroupEnd
269
+ })
270
+ });
271
+ }
272
+ if (disabledDepth < 0) {
273
+ error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
274
+ }
275
+ }
276
+ }
277
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
278
+ var prefix;
279
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
280
+ {
281
+ if (prefix === void 0) {
282
+ try {
283
+ throw Error();
284
+ } catch (x) {
285
+ var match = x.stack.trim().match(/\n( *(at )?)/);
286
+ prefix = match && match[1] || "";
287
+ }
288
+ }
289
+ return "\n" + prefix + name;
290
+ }
291
+ }
292
+ var reentry = false;
293
+ var componentFrameCache;
294
+ {
295
+ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
296
+ componentFrameCache = new PossiblyWeakMap();
297
+ }
298
+ function describeNativeComponentFrame(fn, construct) {
299
+ if (!fn || reentry) {
300
+ return "";
301
+ }
302
+ {
303
+ var frame = componentFrameCache.get(fn);
304
+ if (frame !== void 0) {
305
+ return frame;
306
+ }
307
+ }
308
+ var control;
309
+ reentry = true;
310
+ var previousPrepareStackTrace = Error.prepareStackTrace;
311
+ Error.prepareStackTrace = void 0;
312
+ var previousDispatcher;
313
+ {
314
+ previousDispatcher = ReactCurrentDispatcher.current;
315
+ ReactCurrentDispatcher.current = null;
316
+ disableLogs();
317
+ }
318
+ try {
319
+ if (construct) {
320
+ var Fake = function() {
321
+ throw Error();
322
+ };
323
+ Object.defineProperty(Fake.prototype, "props", {
324
+ set: function() {
325
+ throw Error();
326
+ }
327
+ });
328
+ if (typeof Reflect === "object" && Reflect.construct) {
329
+ try {
330
+ Reflect.construct(Fake, []);
331
+ } catch (x) {
332
+ control = x;
333
+ }
334
+ Reflect.construct(fn, [], Fake);
335
+ } else {
336
+ try {
337
+ Fake.call();
338
+ } catch (x) {
339
+ control = x;
340
+ }
341
+ fn.call(Fake.prototype);
342
+ }
343
+ } else {
344
+ try {
345
+ throw Error();
346
+ } catch (x) {
347
+ control = x;
348
+ }
349
+ fn();
350
+ }
351
+ } catch (sample) {
352
+ if (sample && control && typeof sample.stack === "string") {
353
+ var sampleLines = sample.stack.split("\n");
354
+ var controlLines = control.stack.split("\n");
355
+ var s = sampleLines.length - 1;
356
+ var c = controlLines.length - 1;
357
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
358
+ c--;
359
+ }
360
+ for (; s >= 1 && c >= 0; s--, c--) {
361
+ if (sampleLines[s] !== controlLines[c]) {
362
+ if (s !== 1 || c !== 1) {
363
+ do {
364
+ s--;
365
+ c--;
366
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
367
+ var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
368
+ if (fn.displayName && _frame.includes("<anonymous>")) {
369
+ _frame = _frame.replace("<anonymous>", fn.displayName);
370
+ }
371
+ {
372
+ if (typeof fn === "function") {
373
+ componentFrameCache.set(fn, _frame);
374
+ }
375
+ }
376
+ return _frame;
377
+ }
378
+ } while (s >= 1 && c >= 0);
379
+ }
380
+ break;
381
+ }
382
+ }
383
+ }
384
+ } finally {
385
+ reentry = false;
386
+ {
387
+ ReactCurrentDispatcher.current = previousDispatcher;
388
+ reenableLogs();
389
+ }
390
+ Error.prepareStackTrace = previousPrepareStackTrace;
391
+ }
392
+ var name = fn ? fn.displayName || fn.name : "";
393
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
394
+ {
395
+ if (typeof fn === "function") {
396
+ componentFrameCache.set(fn, syntheticFrame);
397
+ }
398
+ }
399
+ return syntheticFrame;
400
+ }
401
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
402
+ {
403
+ return describeNativeComponentFrame(fn, false);
404
+ }
405
+ }
406
+ function shouldConstruct(Component) {
407
+ var prototype = Component.prototype;
408
+ return !!(prototype && prototype.isReactComponent);
409
+ }
410
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
411
+ if (type == null) {
412
+ return "";
413
+ }
414
+ if (typeof type === "function") {
415
+ {
416
+ return describeNativeComponentFrame(type, shouldConstruct(type));
417
+ }
418
+ }
419
+ if (typeof type === "string") {
420
+ return describeBuiltInComponentFrame(type);
421
+ }
422
+ switch (type) {
423
+ case REACT_SUSPENSE_TYPE:
424
+ return describeBuiltInComponentFrame("Suspense");
425
+ case REACT_SUSPENSE_LIST_TYPE:
426
+ return describeBuiltInComponentFrame("SuspenseList");
427
+ }
428
+ if (typeof type === "object") {
429
+ switch (type.$$typeof) {
430
+ case REACT_FORWARD_REF_TYPE:
431
+ return describeFunctionComponentFrame(type.render);
432
+ case REACT_MEMO_TYPE:
433
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
434
+ case REACT_LAZY_TYPE: {
435
+ var lazyComponent = type;
436
+ var payload = lazyComponent._payload;
437
+ var init = lazyComponent._init;
438
+ try {
439
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
440
+ } catch (x) {
441
+ }
442
+ }
443
+ }
444
+ }
445
+ return "";
446
+ }
447
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
448
+ var loggedTypeFailures = {};
449
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
450
+ function setCurrentlyValidatingElement(element) {
451
+ {
452
+ if (element) {
453
+ var owner = element._owner;
454
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
455
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
456
+ } else {
457
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
458
+ }
459
+ }
460
+ }
461
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
462
+ {
463
+ var has = Function.call.bind(hasOwnProperty);
464
+ for (var typeSpecName in typeSpecs) {
465
+ if (has(typeSpecs, typeSpecName)) {
466
+ var error$1 = void 0;
467
+ try {
468
+ if (typeof typeSpecs[typeSpecName] !== "function") {
469
+ 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`.");
470
+ err.name = "Invariant Violation";
471
+ throw err;
472
+ }
473
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
474
+ } catch (ex) {
475
+ error$1 = ex;
476
+ }
477
+ if (error$1 && !(error$1 instanceof Error)) {
478
+ setCurrentlyValidatingElement(element);
479
+ 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);
480
+ setCurrentlyValidatingElement(null);
481
+ }
482
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
483
+ loggedTypeFailures[error$1.message] = true;
484
+ setCurrentlyValidatingElement(element);
485
+ error("Failed %s type: %s", location, error$1.message);
486
+ setCurrentlyValidatingElement(null);
487
+ }
488
+ }
489
+ }
490
+ }
491
+ }
492
+ var isArrayImpl = Array.isArray;
493
+ function isArray(a) {
494
+ return isArrayImpl(a);
495
+ }
496
+ function typeName(value) {
497
+ {
498
+ var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
499
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
500
+ return type;
501
+ }
502
+ }
503
+ function willCoercionThrow(value) {
504
+ {
505
+ try {
506
+ testStringCoercion(value);
507
+ return false;
508
+ } catch (e) {
509
+ return true;
510
+ }
511
+ }
512
+ }
513
+ function testStringCoercion(value) {
514
+ return "" + value;
515
+ }
516
+ function checkKeyStringCoercion(value) {
517
+ {
518
+ if (willCoercionThrow(value)) {
519
+ error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
520
+ return testStringCoercion(value);
521
+ }
522
+ }
523
+ }
524
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
525
+ var RESERVED_PROPS = {
526
+ key: true,
527
+ ref: true,
528
+ __self: true,
529
+ __source: true
530
+ };
531
+ var specialPropKeyWarningShown;
532
+ var specialPropRefWarningShown;
533
+ var didWarnAboutStringRefs;
534
+ {
535
+ didWarnAboutStringRefs = {};
536
+ }
537
+ function hasValidRef(config) {
538
+ {
539
+ if (hasOwnProperty.call(config, "ref")) {
540
+ var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
541
+ if (getter && getter.isReactWarning) {
542
+ return false;
543
+ }
544
+ }
545
+ }
546
+ return config.ref !== void 0;
547
+ }
548
+ function hasValidKey(config) {
549
+ {
550
+ if (hasOwnProperty.call(config, "key")) {
551
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
552
+ if (getter && getter.isReactWarning) {
553
+ return false;
554
+ }
555
+ }
556
+ }
557
+ return config.key !== void 0;
558
+ }
559
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
560
+ {
561
+ if (typeof config.ref === "string" && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
562
+ var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
563
+ if (!didWarnAboutStringRefs[componentName]) {
564
+ 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', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
565
+ didWarnAboutStringRefs[componentName] = true;
566
+ }
567
+ }
568
+ }
569
+ }
570
+ function defineKeyPropWarningGetter(props, displayName) {
571
+ {
572
+ var warnAboutAccessingKey = function() {
573
+ if (!specialPropKeyWarningShown) {
574
+ specialPropKeyWarningShown = true;
575
+ 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);
576
+ }
577
+ };
578
+ warnAboutAccessingKey.isReactWarning = true;
579
+ Object.defineProperty(props, "key", {
580
+ get: warnAboutAccessingKey,
581
+ configurable: true
582
+ });
583
+ }
584
+ }
585
+ function defineRefPropWarningGetter(props, displayName) {
586
+ {
587
+ var warnAboutAccessingRef = function() {
588
+ if (!specialPropRefWarningShown) {
589
+ specialPropRefWarningShown = true;
590
+ 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);
591
+ }
592
+ };
593
+ warnAboutAccessingRef.isReactWarning = true;
594
+ Object.defineProperty(props, "ref", {
595
+ get: warnAboutAccessingRef,
596
+ configurable: true
597
+ });
598
+ }
599
+ }
600
+ var ReactElement = function(type, key, ref, self, source, owner, props) {
601
+ var element = {
602
+ // This tag allows us to uniquely identify this as a React Element
603
+ $$typeof: REACT_ELEMENT_TYPE,
604
+ // Built-in properties that belong on the element
605
+ type,
606
+ key,
607
+ ref,
608
+ props,
609
+ // Record the component responsible for creating this element.
610
+ _owner: owner
611
+ };
612
+ {
613
+ element._store = {};
614
+ Object.defineProperty(element._store, "validated", {
615
+ configurable: false,
616
+ enumerable: false,
617
+ writable: true,
618
+ value: false
619
+ });
620
+ Object.defineProperty(element, "_self", {
621
+ configurable: false,
622
+ enumerable: false,
623
+ writable: false,
624
+ value: self
625
+ });
626
+ Object.defineProperty(element, "_source", {
627
+ configurable: false,
628
+ enumerable: false,
629
+ writable: false,
630
+ value: source
631
+ });
632
+ if (Object.freeze) {
633
+ Object.freeze(element.props);
634
+ Object.freeze(element);
635
+ }
636
+ }
637
+ return element;
638
+ };
639
+ function jsxDEV(type, config, maybeKey, source, self) {
640
+ {
641
+ var propName;
642
+ var props = {};
643
+ var key = null;
644
+ var ref = null;
645
+ if (maybeKey !== void 0) {
646
+ {
647
+ checkKeyStringCoercion(maybeKey);
648
+ }
649
+ key = "" + maybeKey;
650
+ }
651
+ if (hasValidKey(config)) {
652
+ {
653
+ checkKeyStringCoercion(config.key);
654
+ }
655
+ key = "" + config.key;
656
+ }
657
+ if (hasValidRef(config)) {
658
+ ref = config.ref;
659
+ warnIfStringRefCannotBeAutoConverted(config, self);
660
+ }
661
+ for (propName in config) {
662
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
663
+ props[propName] = config[propName];
664
+ }
665
+ }
666
+ if (type && type.defaultProps) {
667
+ var defaultProps = type.defaultProps;
668
+ for (propName in defaultProps) {
669
+ if (props[propName] === void 0) {
670
+ props[propName] = defaultProps[propName];
671
+ }
672
+ }
673
+ }
674
+ if (key || ref) {
675
+ var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
676
+ if (key) {
677
+ defineKeyPropWarningGetter(props, displayName);
678
+ }
679
+ if (ref) {
680
+ defineRefPropWarningGetter(props, displayName);
681
+ }
682
+ }
683
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
684
+ }
685
+ }
686
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
687
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
688
+ function setCurrentlyValidatingElement$1(element) {
689
+ {
690
+ if (element) {
691
+ var owner = element._owner;
692
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
693
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
694
+ } else {
695
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
696
+ }
697
+ }
698
+ }
699
+ var propTypesMisspellWarningShown;
700
+ {
701
+ propTypesMisspellWarningShown = false;
702
+ }
703
+ function isValidElement(object) {
704
+ {
705
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
706
+ }
707
+ }
708
+ function getDeclarationErrorAddendum() {
709
+ {
710
+ if (ReactCurrentOwner$1.current) {
711
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
712
+ if (name) {
713
+ return "\n\nCheck the render method of `" + name + "`.";
714
+ }
715
+ }
716
+ return "";
717
+ }
718
+ }
719
+ function getSourceInfoErrorAddendum(source) {
720
+ {
721
+ return "";
722
+ }
723
+ }
724
+ var ownerHasKeyUseWarning = {};
725
+ function getCurrentComponentErrorInfo(parentType) {
726
+ {
727
+ var info = getDeclarationErrorAddendum();
728
+ if (!info) {
729
+ var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
730
+ if (parentName) {
731
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
732
+ }
733
+ }
734
+ return info;
735
+ }
736
+ }
737
+ function validateExplicitKey(element, parentType) {
738
+ {
739
+ if (!element._store || element._store.validated || element.key != null) {
740
+ return;
741
+ }
742
+ element._store.validated = true;
743
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
744
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
745
+ return;
746
+ }
747
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
748
+ var childOwner = "";
749
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
750
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
751
+ }
752
+ setCurrentlyValidatingElement$1(element);
753
+ 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);
754
+ setCurrentlyValidatingElement$1(null);
755
+ }
756
+ }
757
+ function validateChildKeys(node, parentType) {
758
+ {
759
+ if (typeof node !== "object") {
760
+ return;
761
+ }
762
+ if (isArray(node)) {
763
+ for (var i = 0; i < node.length; i++) {
764
+ var child = node[i];
765
+ if (isValidElement(child)) {
766
+ validateExplicitKey(child, parentType);
767
+ }
768
+ }
769
+ } else if (isValidElement(node)) {
770
+ if (node._store) {
771
+ node._store.validated = true;
772
+ }
773
+ } else if (node) {
774
+ var iteratorFn = getIteratorFn(node);
775
+ if (typeof iteratorFn === "function") {
776
+ if (iteratorFn !== node.entries) {
777
+ var iterator = iteratorFn.call(node);
778
+ var step;
779
+ while (!(step = iterator.next()).done) {
780
+ if (isValidElement(step.value)) {
781
+ validateExplicitKey(step.value, parentType);
782
+ }
783
+ }
784
+ }
785
+ }
786
+ }
787
+ }
788
+ }
789
+ function validatePropTypes(element) {
790
+ {
791
+ var type = element.type;
792
+ if (type === null || type === void 0 || typeof type === "string") {
793
+ return;
794
+ }
795
+ var propTypes;
796
+ if (typeof type === "function") {
797
+ propTypes = type.propTypes;
798
+ } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
799
+ // Inner props are checked in the reconciler.
800
+ type.$$typeof === REACT_MEMO_TYPE)) {
801
+ propTypes = type.propTypes;
802
+ } else {
803
+ return;
804
+ }
805
+ if (propTypes) {
806
+ var name = getComponentNameFromType(type);
807
+ checkPropTypes(propTypes, element.props, "prop", name, element);
808
+ } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
809
+ propTypesMisspellWarningShown = true;
810
+ var _name = getComponentNameFromType(type);
811
+ error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
812
+ }
813
+ if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
814
+ error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
815
+ }
816
+ }
817
+ }
818
+ function validateFragmentProps(fragment) {
819
+ {
820
+ var keys = Object.keys(fragment.props);
821
+ for (var i = 0; i < keys.length; i++) {
822
+ var key = keys[i];
823
+ if (key !== "children" && key !== "key") {
824
+ setCurrentlyValidatingElement$1(fragment);
825
+ error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
826
+ setCurrentlyValidatingElement$1(null);
827
+ break;
828
+ }
829
+ }
830
+ if (fragment.ref !== null) {
831
+ setCurrentlyValidatingElement$1(fragment);
832
+ error("Invalid attribute `ref` supplied to `React.Fragment`.");
833
+ setCurrentlyValidatingElement$1(null);
834
+ }
835
+ }
836
+ }
837
+ var didWarnAboutKeySpread = {};
838
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
839
+ {
840
+ var validType = isValidElementType(type);
841
+ if (!validType) {
842
+ var info = "";
843
+ if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
844
+ 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.";
845
+ }
846
+ var sourceInfo = getSourceInfoErrorAddendum();
847
+ if (sourceInfo) {
848
+ info += sourceInfo;
849
+ } else {
850
+ info += getDeclarationErrorAddendum();
851
+ }
852
+ var typeString;
853
+ if (type === null) {
854
+ typeString = "null";
855
+ } else if (isArray(type)) {
856
+ typeString = "array";
857
+ } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
858
+ typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
859
+ info = " Did you accidentally export a JSX literal instead of a component?";
860
+ } else {
861
+ typeString = typeof type;
862
+ }
863
+ 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);
864
+ }
865
+ var element = jsxDEV(type, props, key, source, self);
866
+ if (element == null) {
867
+ return element;
868
+ }
869
+ if (validType) {
870
+ var children = props.children;
871
+ if (children !== void 0) {
872
+ if (isStaticChildren) {
873
+ if (isArray(children)) {
874
+ for (var i = 0; i < children.length; i++) {
875
+ validateChildKeys(children[i], type);
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 (hasOwnProperty.call(props, "key")) {
890
+ var componentName = getComponentNameFromType(type);
891
+ var keys = Object.keys(props).filter(function(k) {
892
+ return k !== "key";
893
+ });
894
+ var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
895
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
896
+ var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
897
+ error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
898
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
899
+ }
900
+ }
901
+ }
902
+ if (type === REACT_FRAGMENT_TYPE) {
903
+ validateFragmentProps(element);
904
+ } else {
905
+ validatePropTypes(element);
906
+ }
907
+ return element;
908
+ }
909
+ }
910
+ function jsxWithValidationStatic(type, props, key) {
911
+ {
912
+ return jsxWithValidation(type, props, key, true);
913
+ }
914
+ }
915
+ function jsxWithValidationDynamic(type, props, key) {
916
+ {
917
+ return jsxWithValidation(type, props, key, false);
918
+ }
919
+ }
920
+ var jsx = jsxWithValidationDynamic;
921
+ var jsxs = jsxWithValidationStatic;
922
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
923
+ reactJsxRuntime_development.jsx = jsx;
924
+ reactJsxRuntime_development.jsxs = jsxs;
925
+ })();
926
+ }
927
+ return reactJsxRuntime_development;
928
+ }
929
+ if (process.env.NODE_ENV === "production") {
930
+ jsxRuntime.exports = requireReactJsxRuntime_production_min();
931
+ } else {
932
+ jsxRuntime.exports = requireReactJsxRuntime_development();
933
+ }
934
+ var jsxRuntimeExports = jsxRuntime.exports;
935
+ const useClickOutside = (refs, handler, enabled = true) => {
936
+ useEffect(() => {
937
+ if (!enabled) return;
938
+ const handleClickOutside = (event) => {
939
+ if (!event.target) return;
940
+ const isOutside = refs.every((ref) => {
941
+ const element = ref.current;
942
+ if (!element) return true;
943
+ return !element.contains(event.target);
944
+ });
945
+ if (isOutside) {
946
+ handler();
947
+ }
948
+ };
949
+ document.addEventListener("mousedown", handleClickOutside, true);
950
+ const handleEscape = (event) => {
951
+ if (event.key === "Escape") {
952
+ handler();
953
+ }
954
+ };
955
+ document.addEventListener("keydown", handleEscape, true);
956
+ return () => {
957
+ document.removeEventListener("mousedown", handleClickOutside, true);
958
+ document.removeEventListener("keydown", handleEscape, true);
959
+ };
960
+ }, [refs, handler, enabled]);
961
+ };
962
+ const WINDOW_PADDING = 8;
963
+ const SCROLL_BOUNDARY = 20;
964
+ const getViewportBoundaries = () => {
965
+ return {
966
+ top: WINDOW_PADDING,
967
+ right: window.innerWidth - WINDOW_PADDING,
968
+ bottom: window.innerHeight - WINDOW_PADDING,
969
+ left: WINDOW_PADDING
970
+ };
971
+ };
972
+ const getPreferredPlacements = (placement) => {
973
+ const basePlacements = {
974
+ top: ["top", "bottom", "right", "left"],
975
+ "top-start": ["top-start", "bottom-start", "right-start", "left-start"],
976
+ "top-end": ["top-end", "bottom-end", "right-end", "left-end"],
977
+ bottom: ["bottom", "top", "right", "left"],
978
+ "bottom-start": ["bottom-start", "top-start", "right-start", "left-start"],
979
+ "bottom-end": ["bottom-end", "top-end", "right-end", "left-end"],
980
+ left: ["left", "right", "top", "bottom"],
981
+ "left-start": ["left-start", "right-start", "top-start", "bottom-start"],
982
+ "left-end": ["left-end", "right-end", "top-end", "bottom-end"],
983
+ right: ["right", "left", "top", "bottom"],
984
+ "right-start": ["right-start", "left-start", "top-start", "bottom-start"],
985
+ "right-end": ["right-end", "left-end", "top-end", "bottom-end"]
986
+ };
987
+ return basePlacements[placement] || [placement];
988
+ };
989
+ const isOutOfBounds = (position, contentRect) => {
990
+ const boundaries = getViewportBoundaries();
991
+ return position.x < boundaries.left || position.y < boundaries.top || position.x + contentRect.width > boundaries.right || position.y + contentRect.height > boundaries.bottom;
992
+ };
993
+ const isNearViewportEdge = (position, contentRect) => {
994
+ const boundaries = getViewportBoundaries();
995
+ return position.x < boundaries.left + SCROLL_BOUNDARY || position.y < boundaries.top + SCROLL_BOUNDARY || position.x + contentRect.width > boundaries.right - SCROLL_BOUNDARY || position.y + contentRect.height > boundaries.bottom - SCROLL_BOUNDARY;
996
+ };
997
+ const calculateSinglePosition = (triggerRect, contentRect, placement, offset) => {
998
+ const positions = {
999
+ top: {
1000
+ x: triggerRect.left + triggerRect.width / 2 - contentRect.width / 2,
1001
+ y: triggerRect.top - contentRect.height - offset
1002
+ },
1003
+ "top-start": {
1004
+ x: triggerRect.left,
1005
+ y: triggerRect.top - contentRect.height - offset
1006
+ },
1007
+ "top-end": {
1008
+ x: triggerRect.left + triggerRect.width - contentRect.width,
1009
+ y: triggerRect.top - contentRect.height - offset
1010
+ },
1011
+ bottom: {
1012
+ x: triggerRect.left + triggerRect.width / 2 - contentRect.width / 2,
1013
+ y: triggerRect.top + triggerRect.height + offset
1014
+ },
1015
+ "bottom-start": {
1016
+ x: triggerRect.left,
1017
+ y: triggerRect.top + triggerRect.height + offset
1018
+ },
1019
+ "bottom-end": {
1020
+ x: triggerRect.left + triggerRect.width - contentRect.width,
1021
+ y: triggerRect.top + triggerRect.height + offset
1022
+ },
1023
+ left: {
1024
+ x: triggerRect.left - contentRect.width - offset,
1025
+ y: triggerRect.top + triggerRect.height / 2 - contentRect.height / 2
1026
+ },
1027
+ "left-start": {
1028
+ x: triggerRect.left - contentRect.width - offset,
1029
+ y: triggerRect.top
1030
+ },
1031
+ "left-end": {
1032
+ x: triggerRect.left - contentRect.width - offset,
1033
+ y: triggerRect.top + triggerRect.height - contentRect.height
1034
+ },
1035
+ right: {
1036
+ x: triggerRect.left + triggerRect.width + offset,
1037
+ y: triggerRect.top + triggerRect.height / 2 - contentRect.height / 2
1038
+ },
1039
+ "right-start": {
1040
+ x: triggerRect.left + triggerRect.width + offset,
1041
+ y: triggerRect.top
1042
+ },
1043
+ "right-end": {
1044
+ x: triggerRect.left + triggerRect.width + offset,
1045
+ y: triggerRect.top + triggerRect.height - contentRect.height
1046
+ }
1047
+ };
1048
+ return positions[placement];
1049
+ };
1050
+ const calculatePosition = (triggerRect, contentRect, placement, offset = 8, autoPlacement = false) => {
1051
+ let position = calculateSinglePosition(
1052
+ triggerRect,
1053
+ contentRect,
1054
+ placement,
1055
+ offset
1056
+ );
1057
+ let finalPlacement = placement;
1058
+ if (autoPlacement) {
1059
+ const preferredPlacements = getPreferredPlacements(placement);
1060
+ for (const testPlacement of preferredPlacements) {
1061
+ const testPosition = calculateSinglePosition(
1062
+ triggerRect,
1063
+ contentRect,
1064
+ testPlacement,
1065
+ offset
1066
+ );
1067
+ if (!isOutOfBounds(testPosition, contentRect) && !isNearViewportEdge(testPosition, contentRect)) {
1068
+ position = testPosition;
1069
+ finalPlacement = testPlacement;
1070
+ break;
1071
+ }
1072
+ }
1073
+ }
1074
+ const boundaries = getViewportBoundaries();
1075
+ position.x = Math.max(
1076
+ boundaries.left,
1077
+ Math.min(position.x, boundaries.right - contentRect.width)
1078
+ );
1079
+ position.y = Math.max(
1080
+ boundaries.top,
1081
+ Math.min(position.y, boundaries.bottom - contentRect.height)
1082
+ );
1083
+ return { position, finalPlacement };
1084
+ };
1085
+ const container = "_container_1w2r4_1";
1086
+ const trigger = "_trigger_1w2r4_6";
1087
+ const content = "_content_1w2r4_12";
1088
+ const animated = "_animated_1w2r4_17";
1089
+ const enter = "_enter_1w2r4_20";
1090
+ const exit = "_exit_1w2r4_24";
1091
+ const contentInner = "_contentInner_1w2r4_30";
1092
+ const menuItem = "_menuItem_1w2r4_115";
1093
+ const notification = "_notification_1w2r4_137";
1094
+ const title = "_title_1w2r4_145";
1095
+ const time = "_time_1w2r4_150";
1096
+ const styles = {
1097
+ container,
1098
+ trigger,
1099
+ content,
1100
+ animated,
1101
+ enter,
1102
+ exit,
1103
+ contentInner,
1104
+ menuItem,
1105
+ notification,
1106
+ title,
1107
+ time
1108
+ };
1109
+ const PopoverContent = ({
1110
+ content: content2,
1111
+ placement = "top",
1112
+ offset = 8,
1113
+ className = "",
1114
+ contentClassName = "",
1115
+ triggerRef,
1116
+ contentRef,
1117
+ isOpen,
1118
+ style,
1119
+ autoPlacement = false,
1120
+ animated: animated2 = false
1121
+ }) => {
1122
+ const localContentRef = useRef(null);
1123
+ const [position, setPosition] = useState({ x: 0, y: 0 });
1124
+ const [currentPlacement, setCurrentPlacement] = useState(placement);
1125
+ const [isVisible, setIsVisible] = useState(false);
1126
+ const [isPositioned, setIsPositioned] = useState(false);
1127
+ const animationFrameRef = useRef();
1128
+ const hiddenContentRef = useRef(null);
1129
+ const setRefs = useCallback(
1130
+ (element) => {
1131
+ localContentRef.current = element;
1132
+ if (contentRef) {
1133
+ contentRef.current = element;
1134
+ }
1135
+ },
1136
+ [contentRef]
1137
+ );
1138
+ const calculateInitialPosition = useCallback(() => {
1139
+ if (!triggerRef.current || !hiddenContentRef.current) return false;
1140
+ const triggerRect = triggerRef.current.getBoundingClientRect();
1141
+ const contentRect = hiddenContentRef.current.getBoundingClientRect();
1142
+ const { position: newPosition, finalPlacement } = calculatePosition(
1143
+ triggerRect,
1144
+ contentRect,
1145
+ placement,
1146
+ offset,
1147
+ autoPlacement
1148
+ );
1149
+ setPosition(newPosition);
1150
+ setCurrentPlacement(finalPlacement);
1151
+ return true;
1152
+ }, [placement, offset, autoPlacement]);
1153
+ useEffect(() => {
1154
+ if (isOpen && !isPositioned) {
1155
+ const positioned = calculateInitialPosition();
1156
+ if (positioned) {
1157
+ setIsPositioned(true);
1158
+ requestAnimationFrame(() => {
1159
+ setIsVisible(true);
1160
+ });
1161
+ }
1162
+ } else if (!isOpen) {
1163
+ setIsVisible(false);
1164
+ setIsPositioned(false);
1165
+ const timer = setTimeout(() => {
1166
+ setPosition({ x: 0, y: 0 });
1167
+ }, 200);
1168
+ return () => clearTimeout(timer);
1169
+ }
1170
+ }, [isOpen, isPositioned, calculateInitialPosition]);
1171
+ const updatePosition = useCallback(() => {
1172
+ if (isOpen && triggerRef.current && localContentRef.current) {
1173
+ const triggerRect = triggerRef.current.getBoundingClientRect();
1174
+ const contentRect = localContentRef.current.getBoundingClientRect();
1175
+ const { position: newPosition, finalPlacement } = calculatePosition(
1176
+ triggerRect,
1177
+ contentRect,
1178
+ placement,
1179
+ offset,
1180
+ autoPlacement
1181
+ );
1182
+ setPosition(newPosition);
1183
+ setCurrentPlacement(finalPlacement);
1184
+ }
1185
+ }, [isOpen, placement, offset, autoPlacement]);
1186
+ useEffect(() => {
1187
+ const handleScroll = () => {
1188
+ if (animationFrameRef.current) {
1189
+ cancelAnimationFrame(animationFrameRef.current);
1190
+ }
1191
+ animationFrameRef.current = requestAnimationFrame(updatePosition);
1192
+ };
1193
+ const handleResize = () => {
1194
+ if (animationFrameRef.current) {
1195
+ cancelAnimationFrame(animationFrameRef.current);
1196
+ }
1197
+ animationFrameRef.current = requestAnimationFrame(updatePosition);
1198
+ };
1199
+ if (isOpen && isPositioned) {
1200
+ window.addEventListener("scroll", handleScroll, true);
1201
+ window.addEventListener("resize", handleResize);
1202
+ }
1203
+ return () => {
1204
+ if (animationFrameRef.current) {
1205
+ cancelAnimationFrame(animationFrameRef.current);
1206
+ }
1207
+ window.removeEventListener("scroll", handleScroll, true);
1208
+ window.removeEventListener("resize", handleResize);
1209
+ };
1210
+ }, [isOpen, isPositioned, updatePosition]);
1211
+ const hiddenContent = /* @__PURE__ */ jsxRuntimeExports.jsx(
1212
+ "div",
1213
+ {
1214
+ ref: hiddenContentRef,
1215
+ style: {
1216
+ position: "fixed",
1217
+ visibility: "hidden",
1218
+ pointerEvents: "none",
1219
+ top: 0,
1220
+ left: 0
1221
+ },
1222
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.contentInner, children: content2 })
1223
+ }
1224
+ );
1225
+ const contentClasses = [
1226
+ styles.content,
1227
+ animated2 && styles.animated,
1228
+ animated2 && (isVisible ? styles.enter : styles.exit),
1229
+ className
1230
+ ].filter(Boolean).join(" ");
1231
+ const contentInnerClasses = [styles.contentInner, contentClassName].filter(Boolean).join(" ");
1232
+ return createPortal(
1233
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1234
+ isOpen && !isPositioned && hiddenContent,
1235
+ (isOpen || isVisible) && /* @__PURE__ */ jsxRuntimeExports.jsx(
1236
+ "div",
1237
+ {
1238
+ ref: setRefs,
1239
+ className: contentClasses,
1240
+ style: {
1241
+ ...style,
1242
+ position: "fixed",
1243
+ left: position.x,
1244
+ top: position.y,
1245
+ zIndex: 50,
1246
+ opacity: isPositioned ? void 0 : 0,
1247
+ pointerEvents: isPositioned ? void 0 : "none",
1248
+ willChange: "transform, opacity"
1249
+ },
1250
+ "data-testid": "popover-content",
1251
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1252
+ "div",
1253
+ {
1254
+ className: contentInnerClasses,
1255
+ "data-placement": currentPlacement,
1256
+ children: content2
1257
+ }
1258
+ )
1259
+ }
1260
+ )
1261
+ ] }),
1262
+ document.body
1263
+ );
1264
+ };
1265
+ const Popover = ({
1266
+ trigger: trigger2,
1267
+ content: content2,
1268
+ placement = "top",
1269
+ offset,
1270
+ className = "",
1271
+ containerClassName = "",
1272
+ contentClassName = "",
1273
+ open,
1274
+ onOpenChange,
1275
+ style,
1276
+ autoPlacement = false,
1277
+ animated: animated2 = false,
1278
+ triggerType = "click",
1279
+ hoverDelay = 200,
1280
+ closeDelay = 400,
1281
+ closeOnScroll = false,
1282
+ closeOnResize = false
1283
+ }) => {
1284
+ const [internalOpen, setInternalOpen] = useState(false);
1285
+ const triggerRef = useRef(null);
1286
+ const contentRef = useRef(null);
1287
+ const timeoutRef = useRef();
1288
+ const hoverTimeoutRef = useRef();
1289
+ const triggers = Array.isArray(triggerType) ? triggerType : [triggerType];
1290
+ const isControlled = open !== void 0;
1291
+ const isOpen = isControlled ? open : internalOpen;
1292
+ const isHoverEnabled = triggers.includes("hover");
1293
+ const clearTimeouts = useCallback(() => {
1294
+ if (timeoutRef.current) {
1295
+ clearTimeout(timeoutRef.current);
1296
+ timeoutRef.current = void 0;
1297
+ }
1298
+ if (hoverTimeoutRef.current) {
1299
+ clearTimeout(hoverTimeoutRef.current);
1300
+ hoverTimeoutRef.current = void 0;
1301
+ }
1302
+ }, []);
1303
+ const handleOpen = useCallback(() => {
1304
+ clearTimeouts();
1305
+ if (isControlled) {
1306
+ onOpenChange == null ? void 0 : onOpenChange(true);
1307
+ } else {
1308
+ setInternalOpen(true);
1309
+ }
1310
+ }, [isControlled, onOpenChange, clearTimeouts]);
1311
+ const handleClose = useCallback(() => {
1312
+ clearTimeouts();
1313
+ if (isHoverEnabled) {
1314
+ timeoutRef.current = setTimeout(() => {
1315
+ if (isControlled) {
1316
+ onOpenChange == null ? void 0 : onOpenChange(false);
1317
+ } else {
1318
+ setInternalOpen(false);
1319
+ }
1320
+ }, closeDelay);
1321
+ } else {
1322
+ if (isControlled) {
1323
+ onOpenChange == null ? void 0 : onOpenChange(false);
1324
+ } else {
1325
+ setInternalOpen(false);
1326
+ }
1327
+ }
1328
+ }, [isControlled, onOpenChange, closeDelay, clearTimeouts, isHoverEnabled]);
1329
+ const handleToggle = useCallback(
1330
+ (event) => {
1331
+ event.stopPropagation();
1332
+ if (isOpen) {
1333
+ handleClose();
1334
+ } else {
1335
+ handleOpen();
1336
+ }
1337
+ },
1338
+ [isOpen, handleOpen, handleClose]
1339
+ );
1340
+ useClickOutside(
1341
+ [triggerRef, contentRef],
1342
+ handleClose,
1343
+ isOpen && triggers.includes("click")
1344
+ );
1345
+ useEffect(() => {
1346
+ const handleScroll = () => {
1347
+ if (closeOnScroll && isOpen) {
1348
+ handleClose();
1349
+ }
1350
+ };
1351
+ const handleResize = () => {
1352
+ if (closeOnResize && isOpen) {
1353
+ handleClose();
1354
+ }
1355
+ };
1356
+ if (closeOnScroll) {
1357
+ window.addEventListener("scroll", handleScroll, true);
1358
+ }
1359
+ if (closeOnResize) {
1360
+ window.addEventListener("resize", handleResize);
1361
+ }
1362
+ return () => {
1363
+ if (closeOnScroll) {
1364
+ window.removeEventListener("scroll", handleScroll, true);
1365
+ }
1366
+ if (closeOnResize) {
1367
+ window.removeEventListener("resize", handleResize);
1368
+ }
1369
+ clearTimeouts();
1370
+ };
1371
+ }, [closeOnScroll, closeOnResize, isOpen, handleClose, clearTimeouts]);
1372
+ const triggerProps = {
1373
+ //@ts-expect-error ignore
1374
+ ref: triggerRef,
1375
+ className: styles.trigger,
1376
+ "data-testid": "popover-trigger"
1377
+ };
1378
+ if (triggers.includes("click")) {
1379
+ triggerProps.onClick = handleToggle;
1380
+ }
1381
+ if (isHoverEnabled) {
1382
+ triggerProps.onMouseEnter = () => {
1383
+ clearTimeouts();
1384
+ hoverTimeoutRef.current = setTimeout(handleOpen, hoverDelay);
1385
+ };
1386
+ triggerProps.onMouseLeave = handleClose;
1387
+ }
1388
+ if (triggers.includes("focus")) {
1389
+ triggerProps.onFocus = handleOpen;
1390
+ triggerProps.onBlur = handleClose;
1391
+ triggerProps.tabIndex = 0;
1392
+ }
1393
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
1394
+ "div",
1395
+ {
1396
+ className: `${styles.container} ${containerClassName}`,
1397
+ "data-testid": "popover-container",
1398
+ onMouseEnter: isHoverEnabled ? () => {
1399
+ if (isOpen) {
1400
+ clearTimeouts();
1401
+ }
1402
+ } : void 0,
1403
+ onMouseLeave: isHoverEnabled ? handleClose : void 0,
1404
+ children: [
1405
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ...triggerProps, children: trigger2 }),
1406
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1407
+ PopoverContent,
1408
+ {
1409
+ content: content2,
1410
+ placement,
1411
+ offset,
1412
+ className,
1413
+ contentClassName,
1414
+ triggerRef,
1415
+ contentRef,
1416
+ isOpen,
1417
+ style,
1418
+ autoPlacement,
1419
+ animated: animated2
1420
+ }
1421
+ )
1422
+ ]
1423
+ }
1424
+ );
1425
+ };
1426
+ export {
1427
+ Popover
1428
+ };
1429
+ //# sourceMappingURL=index.js.map