@reactuses/core 5.0.16 → 5.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,10 +5,11 @@ var lodashEs = require('lodash-es');
5
5
  var Cookies = require('js-cookie');
6
6
  var screenfull = require('screenfull');
7
7
  var index_js = require('use-sync-external-store/shim/index.js');
8
- var indexClient = require('./index-client-DSNqfa2q.cjs');
8
+ var indexClient = require('./index-client-DJgtg2U_.cjs');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
+ var React__default = /*#__PURE__*/_interopDefault(React);
12
13
  var Cookies__default = /*#__PURE__*/_interopDefault(Cookies);
13
14
  var screenfull__default = /*#__PURE__*/_interopDefault(screenfull);
14
15
 
@@ -19,13 +20,17 @@ const useLatest = (value)=>{
19
20
  };
20
21
 
21
22
  var _window_navigator, _window;
22
- const isFunction = (val)=>typeof val === "function";
23
- const isString = (val)=>typeof val === "string";
24
- const isDev = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
25
- const isBrowser = typeof window !== "undefined";
26
- const isNavigator = typeof navigator !== "undefined";
27
- const noop = ()=>{};
28
- const isIOS = isBrowser && ((_window = window) == null ? void 0 : (_window_navigator = _window.navigator) == null ? void 0 : _window_navigator.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
23
+ function isFunction(val) {
24
+ return typeof val === 'function';
25
+ }
26
+ function isString(val) {
27
+ return typeof val === 'string';
28
+ }
29
+ const isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
30
+ const isBrowser = typeof window !== 'undefined';
31
+ const isNavigator = typeof navigator !== 'undefined';
32
+ function noop() {}
33
+ const isIOS = isBrowser && ((_window = window) == null ? void 0 : (_window_navigator = _window.navigator) == null ? void 0 : _window_navigator.userAgent) && /iP(?:ad|hone|od)/.test(window.navigator.userAgent);
29
34
 
30
35
  function on(obj, ...args) {
31
36
  if (obj && obj.addEventListener) {
@@ -40,9 +45,9 @@ function off(obj, ...args) {
40
45
  const defaultWindow = isBrowser ? window : undefined;
41
46
 
42
47
  const defaultOptions$1 = {};
43
- const defaultOnError = (e)=>{
48
+ function defaultOnError(e) {
44
49
  console.error(e);
45
- };
50
+ }
46
51
 
47
52
  function getTargetElement(target, defaultElement) {
48
53
  if (!isBrowser) {
@@ -54,7 +59,7 @@ function getTargetElement(target, defaultElement) {
54
59
  let targetElement;
55
60
  if (isFunction(target)) {
56
61
  targetElement = target();
57
- } else if ("current" in target) {
62
+ } else if ('current' in target) {
58
63
  targetElement = target.current;
59
64
  } else {
60
65
  targetElement = target;
@@ -63,12 +68,12 @@ function getTargetElement(target, defaultElement) {
63
68
  }
64
69
 
65
70
  const useCustomCompareEffect = (effect, deps, depsEqual)=>{
66
- if (process.env.NODE_ENV !== "production") {
71
+ if (process.env.NODE_ENV !== 'production') {
67
72
  if (!Array.isArray(deps) || !deps.length) {
68
- console.warn("`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead.");
73
+ console.warn('`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
69
74
  }
70
- if (typeof depsEqual !== "function") {
71
- console.warn("`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list");
75
+ if (typeof depsEqual !== 'function') {
76
+ console.warn('`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list');
72
77
  }
73
78
  }
74
79
  const ref = React.useRef(undefined);
@@ -80,9 +85,9 @@ const useCustomCompareEffect = (effect, deps, depsEqual)=>{
80
85
  };
81
86
 
82
87
  const useDeepCompareEffect = (effect, deps)=>{
83
- if (process.env.NODE_ENV !== "production") {
88
+ if (process.env.NODE_ENV !== 'production') {
84
89
  if (!Array.isArray(deps) || !deps.length) {
85
- console.warn("`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead.");
90
+ console.warn('`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
86
91
  }
87
92
  }
88
93
  useCustomCompareEffect(effect, deps, lodashEs.isEqual);
@@ -116,12 +121,12 @@ const useActiveElement = ()=>{
116
121
  var _window;
117
122
  setActive((_window = window) == null ? void 0 : _window.document.activeElement);
118
123
  }, []);
119
- useEventListener("blur", listener, ()=>window, true);
120
- useEventListener("focus", listener, ()=>window, true);
124
+ useEventListener('blur', listener, ()=>window, true);
125
+ useEventListener('focus', listener, ()=>window, true);
121
126
  return active;
122
127
  };
123
128
 
124
- const useMountedState = ()=>{
129
+ function useMountedState() {
125
130
  const mountedRef = React.useRef(false);
126
131
  const get = React.useCallback(()=>mountedRef.current, []);
127
132
  React.useEffect(()=>{
@@ -131,7 +136,7 @@ const useMountedState = ()=>{
131
136
  };
132
137
  }, []);
133
138
  return get;
134
- };
139
+ }
135
140
 
136
141
  function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
137
142
  try {
@@ -198,11 +203,11 @@ const useClickOutside = (target, handler, enabled = true)=>{
198
203
  }
199
204
  savedHandler.current(event);
200
205
  };
201
- useEventListener("mousedown", listener, defaultWindow, listerOptions);
202
- useEventListener("touchstart", listener, defaultWindow, listerOptions);
206
+ useEventListener('mousedown', listener, defaultWindow, listerOptions);
207
+ useEventListener('touchstart', listener, defaultWindow, listerOptions);
203
208
  };
204
209
 
205
- const getInitialState$4 = (key, defaultValue)=>{
210
+ function getInitialState$4(key, defaultValue) {
206
211
  // Prevent a React hydration mismatch when a default value is provided.
207
212
  if (defaultValue !== undefined) {
208
213
  return defaultValue;
@@ -210,11 +215,11 @@ const getInitialState$4 = (key, defaultValue)=>{
210
215
  if (isBrowser) {
211
216
  return Cookies__default.default.get(key);
212
217
  }
213
- if (process.env.NODE_ENV !== "production") {
214
- console.warn("`useCookie` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
218
+ if (process.env.NODE_ENV !== 'production') {
219
+ console.warn('`useCookie` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
215
220
  }
216
- return "";
217
- };
221
+ return '';
222
+ }
218
223
  const useCookie = (key, options = defaultOptions$1, defaultValue)=>{
219
224
  const [cookieValue, setCookieValue] = React.useState(getInitialState$4(key, defaultValue));
220
225
  React.useEffect(()=>{
@@ -331,22 +336,22 @@ const useInterval = (callback, delay, options = defaultOptions$1)=>{
331
336
  };
332
337
  };
333
338
 
334
- const padZero = (time)=>{
339
+ function padZero(time) {
335
340
  return `${time}`.length < 2 ? `0${time}` : `${time}`;
336
- };
337
- const getHMSTime = (timeDiff)=>{
341
+ }
342
+ function getHMSTime(timeDiff) {
338
343
  if (timeDiff <= 0) {
339
344
  return [
340
- "00",
341
- "00",
342
- "00"
345
+ '00',
346
+ '00',
347
+ '00'
343
348
  ];
344
349
  }
345
350
  if (timeDiff > 100 * 3600) {
346
351
  return [
347
- "99",
348
- "59",
349
- "59"
352
+ '99',
353
+ '59',
354
+ '59'
350
355
  ];
351
356
  }
352
357
  const hour = Math.floor(timeDiff / 3600);
@@ -357,7 +362,7 @@ const getHMSTime = (timeDiff)=>{
357
362
  padZero(minute),
358
363
  padZero(second)
359
364
  ];
360
- };
365
+ }
361
366
  const useCountDown = (time, format = getHMSTime, callback)=>{
362
367
  const [remainTime, setRemainTime] = React.useState(time);
363
368
  const [delay, setDelay] = React.useState(1000);
@@ -388,14 +393,14 @@ const useCountDown = (time, format = getHMSTime, callback)=>{
388
393
  const useCounter = (initialValue = 0, max = null, min = null)=>{
389
394
  // avoid exec init code every render
390
395
  const initFunc = ()=>{
391
- let init = typeof initialValue === "function" ? initialValue() : initialValue;
392
- typeof init !== "number" && console.error(`initialValue has to be a number, got ${typeof initialValue}`);
393
- if (typeof min === "number") {
396
+ let init = typeof initialValue === 'function' ? initialValue() : initialValue;
397
+ typeof init !== 'number' && console.error(`initialValue has to be a number, got ${typeof initialValue}`);
398
+ if (typeof min === 'number') {
394
399
  init = Math.max(init, min);
395
400
  } else if (min !== null) {
396
401
  console.error(`min has to be a number, got ${typeof min}`);
397
402
  }
398
- if (typeof max === "number") {
403
+ if (typeof max === 'number') {
399
404
  init = Math.min(init, max);
400
405
  } else if (max !== null) {
401
406
  console.error(`max has to be a number, got ${typeof max}`);
@@ -405,11 +410,11 @@ const useCounter = (initialValue = 0, max = null, min = null)=>{
405
410
  const [value, setValue] = React.useState(initFunc);
406
411
  const set = useEvent((newState)=>{
407
412
  setValue((v)=>{
408
- let nextValue = typeof newState === "function" ? newState(v) : newState;
409
- if (typeof min === "number") {
413
+ let nextValue = typeof newState === 'function' ? newState(v) : newState;
414
+ if (typeof min === 'number') {
410
415
  nextValue = Math.max(nextValue, min);
411
416
  }
412
- if (typeof max === "number") {
417
+ if (typeof max === 'number') {
413
418
  nextValue = Math.min(nextValue, max);
414
419
  }
415
420
  return nextValue;
@@ -437,19 +442,19 @@ const defaultOptions = {
437
442
  observe: false
438
443
  };
439
444
 
440
- const getInitialState$3 = (defaultValue)=>{
445
+ function getInitialState$3(defaultValue) {
441
446
  // Prevent a React hydration mismatch when a default value is provided.
442
447
  if (defaultValue !== undefined) {
443
448
  return defaultValue;
444
449
  }
445
450
  if (isBrowser) {
446
- return "";
451
+ return '';
447
452
  }
448
- if (process.env.NODE_ENV !== "production") {
449
- console.warn("`useCssVar` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
453
+ if (process.env.NODE_ENV !== 'production') {
454
+ console.warn('`useCssVar` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
450
455
  }
451
- return "";
452
- };
456
+ return '';
457
+ }
453
458
  const useCssVar = (prop, target, defaultValue, options = defaultOptions)=>{
454
459
  const { observe } = options;
455
460
  const [variable, setVariable] = React.useState(getInitialState$3(defaultValue));
@@ -493,8 +498,8 @@ const useCssVar = (prop, target, defaultValue, options = defaultOptions)=>{
493
498
  observerRef.current = new MutationObserver(updateCssVar);
494
499
  observerRef.current.observe(element, {
495
500
  attributeFilter: [
496
- "style",
497
- "class"
501
+ 'style',
502
+ 'class'
498
503
  ]
499
504
  });
500
505
  return ()=>{
@@ -537,12 +542,12 @@ const useCycleList = (list, i = 0)=>{
537
542
  };
538
543
 
539
544
  function guessSerializerType(rawInit) {
540
- return rawInit == null || rawInit === undefined ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : Array.isArray(rawInit) ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
545
+ return rawInit == null || rawInit === undefined ? 'any' : rawInit instanceof Set ? 'set' : rawInit instanceof Map ? 'map' : rawInit instanceof Date ? 'date' : typeof rawInit === 'boolean' ? 'boolean' : typeof rawInit === 'string' ? 'string' : typeof rawInit === 'object' ? 'object' : Array.isArray(rawInit) ? 'object' : !Number.isNaN(rawInit) ? 'number' : 'any';
541
546
  }
542
547
 
543
548
  const StorageSerializers = {
544
549
  boolean: {
545
- read: (v)=>v === "true",
550
+ read: (v)=>v === 'true',
546
551
  write: (v)=>String(v)
547
552
  },
548
553
  object: {
@@ -574,7 +579,7 @@ const StorageSerializers = {
574
579
  write: (v)=>v.toISOString()
575
580
  }
576
581
  };
577
- const getInitialState$2 = (key, defaultValue, storage, serializer, onError)=>{
582
+ function getInitialState$2(key, defaultValue, storage, serializer, onError) {
578
583
  // Prevent a React hydration mismatch when a default value is provided.
579
584
  if (defaultValue !== undefined) {
580
585
  return defaultValue;
@@ -591,11 +596,11 @@ const getInitialState$2 = (key, defaultValue, storage, serializer, onError)=>{
591
596
  }
592
597
  }
593
598
  // A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
594
- if (process.env.NODE_ENV !== "production") {
595
- console.warn("`createStorage` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
599
+ if (process.env.NODE_ENV !== 'production') {
600
+ console.warn('`createStorage` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
596
601
  }
597
602
  return null;
598
- };
603
+ }
599
604
  function useStorage(key, defaultValue, getStorage = ()=>isBrowser ? sessionStorage : undefined, options = defaultOptions$1) {
600
605
  let storage;
601
606
  const { onError = defaultOnError, effectStorageValue } = options;
@@ -652,9 +657,9 @@ function useStorage(key, defaultValue, getStorage = ()=>isBrowser ? sessionStora
652
657
  }
653
658
 
654
659
  const useDarkMode = (options)=>{
655
- const { selector = "html", attribute = "class", classNameDark = "", classNameLight = "", storageKey = "reactuses-color-scheme", storage = ()=>isBrowser ? localStorage : undefined, defaultValue = false } = options;
660
+ const { selector = 'html', attribute = 'class', classNameDark = '', classNameLight = '', storageKey = 'reactuses-color-scheme', storage = ()=>isBrowser ? localStorage : undefined, defaultValue = false } = options;
656
661
  const value = ()=>{
657
- return window.matchMedia("(prefers-color-scheme: dark)").matches;
662
+ return window.matchMedia('(prefers-color-scheme: dark)').matches;
658
663
  };
659
664
  const [dark, setDark] = useStorage(storageKey, defaultValue, storage, {
660
665
  effectStorageValue: value
@@ -665,7 +670,7 @@ const useDarkMode = (options)=>{
665
670
  if (!element) {
666
671
  return;
667
672
  }
668
- if (attribute === "class") {
673
+ if (attribute === 'class') {
669
674
  dark && classNameDark && element.classList.add(classNameDark);
670
675
  !dark && classNameLight && element.classList.add(classNameLight);
671
676
  } else {
@@ -676,7 +681,7 @@ const useDarkMode = (options)=>{
676
681
  if (!element) {
677
682
  return;
678
683
  }
679
- if (attribute === "class") {
684
+ if (attribute === 'class') {
680
685
  dark && classNameDark && element.classList.remove(classNameDark);
681
686
  !dark && classNameLight && element.classList.remove(classNameLight);
682
687
  } else {
@@ -698,7 +703,7 @@ const useDarkMode = (options)=>{
698
703
  ];
699
704
  };
700
705
 
701
- const useUnmount = (fn)=>{
706
+ function useUnmount(fn) {
702
707
  if (isDev) {
703
708
  if (!isFunction(fn)) {
704
709
  console.error(`useUnmount expected parameter is a function, got ${typeof fn}`);
@@ -710,7 +715,7 @@ const useUnmount = (fn)=>{
710
715
  }, [
711
716
  fnRef
712
717
  ]);
713
- };
718
+ }
714
719
 
715
720
  const useDebounceFn = (fn, wait, options)=>{
716
721
  if (isDev) {
@@ -750,7 +755,7 @@ const useDebounce = (value, wait, options)=>{
750
755
  return debounced;
751
756
  };
752
757
 
753
- const getInitialState$1 = (defaultValue)=>{
758
+ function getInitialState$1(defaultValue) {
754
759
  // Prevent a React hydration mismatch when a default value is provided.
755
760
  if (defaultValue !== undefined) {
756
761
  return defaultValue;
@@ -758,28 +763,28 @@ const getInitialState$1 = (defaultValue)=>{
758
763
  if (isBrowser) {
759
764
  return document.visibilityState;
760
765
  }
761
- if (process.env.NODE_ENV !== "production") {
762
- console.warn("`useDocumentVisibility` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
766
+ if (process.env.NODE_ENV !== 'production') {
767
+ console.warn('`useDocumentVisibility` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
763
768
  }
764
- return "visible";
765
- };
766
- const useDocumentVisibility = (defaultValue)=>{
769
+ return 'visible';
770
+ }
771
+ function useDocumentVisibility(defaultValue) {
767
772
  const [visible, setVisible] = React.useState(getInitialState$1(defaultValue));
768
- useEventListener("visibilitychange", ()=>{
773
+ useEventListener('visibilitychange', ()=>{
769
774
  setVisible(document.visibilityState);
770
775
  }, ()=>document);
771
776
  React.useEffect(()=>{
772
777
  setVisible(document.visibilityState);
773
778
  }, []);
774
779
  return visible;
775
- };
780
+ }
776
781
 
777
782
  const useDoubleClick = ({ target, latency = 300, onSingleClick = ()=>{}, onDoubleClick = ()=>{} })=>{
778
783
  const handle = React.useCallback((onSingleClick, onDoubleClick)=>{
779
784
  let count = 0;
780
785
  return (e)=>{
781
786
  // prevent ios double click slide
782
- if (e.type === "touchend") {
787
+ if (e.type === 'touchend') {
783
788
  e.stopPropagation();
784
789
  e.preventDefault();
785
790
  }
@@ -798,24 +803,24 @@ const useDoubleClick = ({ target, latency = 300, onSingleClick = ()=>{}, onDoubl
798
803
  ]);
799
804
  const handleClick = handle(onSingleClick, onDoubleClick);
800
805
  const handleTouchEnd = handle(onSingleClick, onDoubleClick);
801
- useEventListener("click", handleClick, target);
802
- useEventListener("touchend", handleTouchEnd, target, {
806
+ useEventListener('click', handleClick, target);
807
+ useEventListener('touchend', handleTouchEnd, target, {
803
808
  passive: false
804
809
  });
805
810
  };
806
811
 
807
- const isScrollX = (node)=>{
812
+ function isScrollX(node) {
808
813
  if (!node) {
809
814
  return false;
810
815
  }
811
- return getComputedStyle(node).overflowX === "auto" || getComputedStyle(node).overflowX === "scroll";
812
- };
813
- const isScrollY = (node)=>{
816
+ return getComputedStyle(node).overflowX === 'auto' || getComputedStyle(node).overflowX === 'scroll';
817
+ }
818
+ function isScrollY(node) {
814
819
  if (!node) {
815
820
  return false;
816
821
  }
817
- return getComputedStyle(node).overflowY === "auto" || getComputedStyle(node).overflowY === "scroll";
818
- };
822
+ return getComputedStyle(node).overflowY === 'auto' || getComputedStyle(node).overflowY === 'scroll';
823
+ }
819
824
  const useDraggable = (target, options = {})=>{
820
825
  const { draggingElement, containerElement } = options;
821
826
  var _options_handle;
@@ -908,9 +913,9 @@ const useDraggable = (target, options = {})=>{
908
913
  options.onEnd == null ? void 0 : options.onEnd.call(options, position, e);
909
914
  handleEvent(e);
910
915
  };
911
- useEventListener("pointerdown", start, draggingHandle, true);
912
- useEventListener("pointermove", move, draggingElement, true);
913
- useEventListener("pointerup", end, draggingElement, true);
916
+ useEventListener('pointerdown', start, draggingHandle, true);
917
+ useEventListener('pointermove', move, draggingElement, true);
918
+ useEventListener('pointerup', end, draggingElement, true);
914
919
  return [
915
920
  position.x,
916
921
  position.y,
@@ -922,22 +927,22 @@ const useDraggable = (target, options = {})=>{
922
927
  const useDropZone = (target, onDrop)=>{
923
928
  const [over, setOver] = React.useState(false);
924
929
  const counter = React.useRef(0);
925
- useEventListener("dragenter", (event)=>{
930
+ useEventListener('dragenter', (event)=>{
926
931
  event.preventDefault();
927
932
  counter.current += 1;
928
933
  setOver(true);
929
934
  }, target);
930
- useEventListener("dragover", (event)=>{
935
+ useEventListener('dragover', (event)=>{
931
936
  event.preventDefault();
932
937
  }, target);
933
- useEventListener("dragleave", (event)=>{
938
+ useEventListener('dragleave', (event)=>{
934
939
  event.preventDefault();
935
940
  counter.current -= 1;
936
941
  if (counter.current === 0) {
937
942
  setOver(false);
938
943
  }
939
944
  }, target);
940
- useEventListener("drop", (event)=>{
945
+ useEventListener('drop', (event)=>{
941
946
  var _event_dataTransfer;
942
947
  event.preventDefault();
943
948
  counter.current = 0;
@@ -1020,21 +1025,21 @@ const useElementBounding = (target, options = defaultOptions$1)=>{
1020
1025
  ]);
1021
1026
  React.useEffect(()=>{
1022
1027
  if (windowScroll) {
1023
- window.addEventListener("scroll", update, {
1028
+ window.addEventListener('scroll', update, {
1024
1029
  passive: true
1025
1030
  });
1026
1031
  }
1027
1032
  if (windowResize) {
1028
- window.addEventListener("resize", update, {
1033
+ window.addEventListener('resize', update, {
1029
1034
  passive: true
1030
1035
  });
1031
1036
  }
1032
1037
  return ()=>{
1033
1038
  if (windowScroll) {
1034
- window.removeEventListener("scroll", update);
1039
+ window.removeEventListener('scroll', update);
1035
1040
  }
1036
1041
  if (windowResize) {
1037
- window.removeEventListener("resize", update);
1042
+ window.removeEventListener('resize', update);
1038
1043
  }
1039
1044
  };
1040
1045
  }, [
@@ -1056,11 +1061,11 @@ const useElementBounding = (target, options = defaultOptions$1)=>{
1056
1061
  };
1057
1062
 
1058
1063
  const useElementSize = (target, options = defaultOptions$1)=>{
1059
- const { box = "content-box" } = options;
1064
+ const { box = 'content-box' } = options;
1060
1065
  const [width, setWidth] = React.useState(0);
1061
1066
  const [height, setHeight] = React.useState(0);
1062
1067
  useResizeObserver(target, ([entry])=>{
1063
- const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
1068
+ const boxSize = box === 'border-box' ? entry.borderBoxSize : box === 'content-box' ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
1064
1069
  if (boxSize) {
1065
1070
  setWidth(boxSize.reduce((acc, { inlineSize })=>acc + inlineSize, 0));
1066
1071
  setHeight(boxSize.reduce((acc, { blockSize })=>acc + blockSize, 0));
@@ -1111,7 +1116,7 @@ const useElementVisibility = (target, options = defaultOptions$1)=>{
1111
1116
  ];
1112
1117
  };
1113
1118
 
1114
- const useEventEmitter = ()=>{
1119
+ function useEventEmitter() {
1115
1120
  const listeners = React.useRef([]);
1116
1121
  const _disposed = React.useRef(false);
1117
1122
  const _event = React.useRef((listener)=>{
@@ -1150,16 +1155,16 @@ const useEventEmitter = ()=>{
1150
1155
  fire,
1151
1156
  dispose
1152
1157
  ];
1153
- };
1158
+ }
1154
1159
 
1155
- const useSupported = (callback, sync = false)=>{
1160
+ function useSupported(callback, sync = false) {
1156
1161
  const [supported, setSupported] = React.useState(false);
1157
1162
  const effect = sync ? useIsomorphicLayoutEffect : React.useEffect;
1158
1163
  effect(()=>{
1159
1164
  setSupported(Boolean(callback()));
1160
1165
  }, []);
1161
1166
  return supported;
1162
- };
1167
+ }
1163
1168
 
1164
1169
  function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
1165
1170
  try {
@@ -1191,11 +1196,11 @@ function _async_to_generator$5(fn) {
1191
1196
  };
1192
1197
  }
1193
1198
  const useEyeDropper = ()=>{
1194
- const isSupported = useSupported(()=>typeof window !== "undefined" && "EyeDropper" in window, true);
1199
+ const isSupported = useSupported(()=>typeof window !== 'undefined' && 'EyeDropper' in window, true);
1195
1200
  const open = React.useCallback(/*#__PURE__*/ _async_to_generator$5(function*(options = {}) {
1196
1201
  if (!isSupported) {
1197
1202
  return {
1198
- sRGBHex: ""
1203
+ sRGBHex: ''
1199
1204
  };
1200
1205
  }
1201
1206
  const eyeDropper = new window.EyeDropper();
@@ -1209,23 +1214,23 @@ const useEyeDropper = ()=>{
1209
1214
  ];
1210
1215
  };
1211
1216
 
1212
- const useFavicon = (href, baseUrl = "", rel = "icon")=>{
1217
+ function useFavicon(href, baseUrl = '', rel = 'icon') {
1213
1218
  React.useEffect(()=>{
1214
1219
  const url = `${baseUrl}${href}`;
1215
1220
  const element = document.head.querySelectorAll(`link[rel*="${rel}"]`);
1216
1221
  element.forEach((el)=>el.href = url);
1217
1222
  if (element.length === 0) {
1218
- const link = document.createElement("link");
1223
+ const link = document.createElement('link');
1219
1224
  link.rel = rel;
1220
1225
  link.href = url;
1221
- document.getElementsByTagName("head")[0].appendChild(link);
1226
+ document.getElementsByTagName('head')[0].appendChild(link);
1222
1227
  }
1223
1228
  }, [
1224
1229
  baseUrl,
1225
1230
  href,
1226
1231
  rel
1227
1232
  ]);
1228
- };
1233
+ }
1229
1234
 
1230
1235
  function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
1231
1236
  try {
@@ -1272,7 +1277,7 @@ function _extends$2() {
1272
1277
  }
1273
1278
  const DEFAULT_OPTIONS = {
1274
1279
  multiple: true,
1275
- accept: "*"
1280
+ accept: '*'
1276
1281
  };
1277
1282
  const useFileDialog = (options = defaultOptions$1)=>{
1278
1283
  const [files, setFiles] = React.useState(null);
@@ -1280,11 +1285,11 @@ const useFileDialog = (options = defaultOptions$1)=>{
1280
1285
  const fileOpenPromiseRef = React.useRef(null);
1281
1286
  const resolveFileOpenPromiseRef = React.useRef();
1282
1287
  const initFn = React.useCallback(()=>{
1283
- if (typeof document === "undefined") {
1288
+ if (typeof document === 'undefined') {
1284
1289
  return undefined;
1285
1290
  }
1286
- const input = document.createElement("input");
1287
- input.type = "file";
1291
+ const input = document.createElement('input');
1292
+ input.type = 'file';
1288
1293
  input.onchange = (event)=>{
1289
1294
  const result = event.target;
1290
1295
  setFiles(result.files);
@@ -1311,7 +1316,7 @@ const useFileDialog = (options = defaultOptions$1)=>{
1311
1316
  setFiles(null);
1312
1317
  resolveFileOpenPromiseRef.current == null ? void 0 : resolveFileOpenPromiseRef.current.call(resolveFileOpenPromiseRef, null);
1313
1318
  if (inputRef.current) {
1314
- inputRef.current.value = "";
1319
+ inputRef.current.value = '';
1315
1320
  }
1316
1321
  };
1317
1322
  return [
@@ -1344,8 +1349,8 @@ const useMount = (fn)=>{
1344
1349
 
1345
1350
  const useFocus = (target, initialValue = false)=>{
1346
1351
  const [focus, innerSetFocus] = React.useState(initialValue);
1347
- useEventListener("focus", ()=>innerSetFocus(true), target);
1348
- useEventListener("blur", ()=>innerSetFocus(false), target);
1352
+ useEventListener('focus', ()=>innerSetFocus(true), target);
1353
+ useEventListener('blur', ()=>innerSetFocus(false), target);
1349
1354
  const setFocus = (value)=>{
1350
1355
  const element = getTargetElement(target);
1351
1356
  if (!element) {
@@ -1409,7 +1414,7 @@ const useRafFn = (callback, initiallyActive = true)=>{
1409
1414
  return result;
1410
1415
  };
1411
1416
 
1412
- const useFps = (options = defaultOptions$1)=>{
1417
+ function useFps(options = defaultOptions$1) {
1413
1418
  const [fps, setFps] = React.useState(0);
1414
1419
  var _options_every;
1415
1420
  const every = (_options_every = options.every) != null ? _options_every : 10;
@@ -1426,7 +1431,7 @@ const useFps = (options = defaultOptions$1)=>{
1426
1431
  }
1427
1432
  });
1428
1433
  return fps;
1429
- };
1434
+ }
1430
1435
 
1431
1436
  const useFullscreen = (target, options = defaultOptions$1)=>{
1432
1437
  const { onExit, onEnter } = options;
@@ -1437,7 +1442,7 @@ const useFullscreen = (target, options = defaultOptions$1)=>{
1437
1442
  if (isFullscreen) {
1438
1443
  onEnter == null ? void 0 : onEnter();
1439
1444
  } else {
1440
- screenfull__default.default.off("change", onChange);
1445
+ screenfull__default.default.off('change', onChange);
1441
1446
  onExit == null ? void 0 : onExit();
1442
1447
  }
1443
1448
  setState(isFullscreen);
@@ -1451,7 +1456,7 @@ const useFullscreen = (target, options = defaultOptions$1)=>{
1451
1456
  if (screenfull__default.default.isEnabled) {
1452
1457
  try {
1453
1458
  screenfull__default.default.request(el);
1454
- screenfull__default.default.on("change", onChange);
1459
+ screenfull__default.default.on('change', onChange);
1455
1460
  } catch (error) {
1456
1461
  console.error(error);
1457
1462
  }
@@ -1471,7 +1476,7 @@ const useFullscreen = (target, options = defaultOptions$1)=>{
1471
1476
  };
1472
1477
  useUnmount(()=>{
1473
1478
  if (screenfull__default.default.isEnabled) {
1474
- screenfull__default.default.off("change", onChange);
1479
+ screenfull__default.default.off('change', onChange);
1475
1480
  }
1476
1481
  });
1477
1482
  return [
@@ -1496,6 +1501,7 @@ const initCoord = {
1496
1501
  };
1497
1502
  const useGeolocation = (options = defaultOptions$1)=>{
1498
1503
  const { enableHighAccuracy = true, maximumAge = 30000, timeout = 27000 } = options;
1504
+ const isSupported = useSupported(()=>navigator && 'geolocation' in navigator);
1499
1505
  const [coordinates, setCoordinates] = React.useState(initCoord);
1500
1506
  const [locatedAt, setLocatedAt] = React.useState(null);
1501
1507
  const [error, setError] = React.useState(null);
@@ -1510,6 +1516,9 @@ const useGeolocation = (options = defaultOptions$1)=>{
1510
1516
  setError(err);
1511
1517
  }, []);
1512
1518
  React.useEffect(()=>{
1519
+ if (!isSupported) {
1520
+ return;
1521
+ }
1513
1522
  navigator.geolocation.getCurrentPosition(updatePosition, updateError);
1514
1523
  const watchId = navigator.geolocation.watchPosition(updatePosition, updateError, {
1515
1524
  enableHighAccuracy,
@@ -1523,6 +1532,7 @@ const useGeolocation = (options = defaultOptions$1)=>{
1523
1532
  };
1524
1533
  }, [
1525
1534
  enableHighAccuracy,
1535
+ isSupported,
1526
1536
  maximumAge,
1527
1537
  timeout,
1528
1538
  updateError,
@@ -1531,7 +1541,8 @@ const useGeolocation = (options = defaultOptions$1)=>{
1531
1541
  return {
1532
1542
  coordinates,
1533
1543
  locatedAt,
1534
- error
1544
+ error,
1545
+ isSupported
1535
1546
  };
1536
1547
  };
1537
1548
 
@@ -1539,18 +1550,18 @@ const useHover = (target)=>{
1539
1550
  const [hovered, setHovered] = React.useState(false);
1540
1551
  const onMouseEnter = React.useCallback(()=>setHovered(true), []);
1541
1552
  const onMouseLeave = React.useCallback(()=>setHovered(false), []);
1542
- useEventListener("mouseenter", onMouseEnter, target);
1543
- useEventListener("mouseleave", onMouseLeave, target);
1553
+ useEventListener('mouseenter', onMouseEnter, target);
1554
+ useEventListener('mouseleave', onMouseLeave, target);
1544
1555
  return hovered;
1545
1556
  };
1546
1557
 
1547
1558
  const defaultEvents$1 = [
1548
- "mousemove",
1549
- "mousedown",
1550
- "resize",
1551
- "keydown",
1552
- "touchstart",
1553
- "wheel"
1559
+ 'mousemove',
1560
+ 'mousedown',
1561
+ 'resize',
1562
+ 'keydown',
1563
+ 'touchstart',
1564
+ 'wheel'
1554
1565
  ];
1555
1566
  const oneMinute = 60e3;
1556
1567
  const useIdle = (ms = oneMinute, initialState = false, events = defaultEvents$1)=>{
@@ -1580,14 +1591,14 @@ const useIdle = (ms = oneMinute, initialState = false, events = defaultEvents$1)
1580
1591
  for(let i = 0; i < events.length; i++){
1581
1592
  on(window, events[i], onEvent);
1582
1593
  }
1583
- on(document, "visibilitychange", onVisibility);
1594
+ on(document, 'visibilitychange', onVisibility);
1584
1595
  timeout = setTimeout(()=>set(true), ms);
1585
1596
  return ()=>{
1586
1597
  mounted = false;
1587
1598
  for(let i = 0; i < events.length; i++){
1588
1599
  off(window, events[i], onEvent);
1589
1600
  }
1590
- off(document, "visibilitychange", onVisibility);
1601
+ off(document, 'visibilitychange', onVisibility);
1591
1602
  };
1592
1603
  // eslint-disable-next-line react-hooks/exhaustive-deps
1593
1604
  }, [
@@ -1597,7 +1608,7 @@ const useIdle = (ms = oneMinute, initialState = false, events = defaultEvents$1)
1597
1608
  return state;
1598
1609
  };
1599
1610
 
1600
- const useThrottleFn = (fn, wait, options)=>{
1611
+ function useThrottleFn(fn, wait, options) {
1601
1612
  if (isDev) {
1602
1613
  if (!isFunction(fn)) {
1603
1614
  console.error(`useThrottleFn expected parameter is a function, got ${typeof fn}`);
@@ -1619,7 +1630,7 @@ const useThrottleFn = (fn, wait, options)=>{
1619
1630
  cancel: throttled.cancel,
1620
1631
  flush: throttled.flush
1621
1632
  };
1622
- };
1633
+ }
1623
1634
 
1624
1635
  /**
1625
1636
  * We have to check if the scroll amount is close enough to some threshold in order to
@@ -1688,7 +1699,7 @@ const useScroll = (target, options = defaultOptions$1)=>{
1688
1699
  onScroll(e);
1689
1700
  });
1690
1701
  const { run: throttleOnScroll } = useThrottleFn(onScrollHandler, throttle);
1691
- useEventListener("scroll", throttle ? throttleOnScroll : onScrollHandler, target, eventListenerOptions);
1702
+ useEventListener('scroll', throttle ? throttleOnScroll : onScrollHandler, target, eventListenerOptions);
1692
1703
  return [
1693
1704
  x,
1694
1705
  y,
@@ -1755,7 +1766,7 @@ function _extends$1() {
1755
1766
  const useInfiniteScroll = (target, onLoadMore, options = defaultOptions$1)=>{
1756
1767
  const savedLoadMore = useLatest(onLoadMore);
1757
1768
  var _options_direction;
1758
- const direction = (_options_direction = options.direction) != null ? _options_direction : "bottom";
1769
+ const direction = (_options_direction = options.direction) != null ? _options_direction : 'bottom';
1759
1770
  var _options_distance;
1760
1771
  const state = useScroll(target, _extends$1({}, options, {
1761
1772
  offset: _extends$1({
@@ -1788,10 +1799,10 @@ const useInfiniteScroll = (target, onLoadMore, options = defaultOptions$1)=>{
1788
1799
  };
1789
1800
 
1790
1801
  const defaultEvents = [
1791
- "mousedown",
1792
- "mouseup",
1793
- "keydown",
1794
- "keyup"
1802
+ 'mousedown',
1803
+ 'mouseup',
1804
+ 'keydown',
1805
+ 'keyup'
1795
1806
  ];
1796
1807
  const useKeyModifier = (modifier, options = defaultOptions$1)=>{
1797
1808
  const { events = defaultEvents, initial = false } = options;
@@ -1799,7 +1810,7 @@ const useKeyModifier = (modifier, options = defaultOptions$1)=>{
1799
1810
  useMount(()=>{
1800
1811
  events.forEach((listenEvent)=>{
1801
1812
  on(document, listenEvent, (evt)=>{
1802
- if (typeof evt.getModifierState === "function") {
1813
+ if (typeof evt.getModifierState === 'function') {
1803
1814
  setState(evt.getModifierState(modifier));
1804
1815
  }
1805
1816
  });
@@ -1807,7 +1818,7 @@ const useKeyModifier = (modifier, options = defaultOptions$1)=>{
1807
1818
  return ()=>{
1808
1819
  events.forEach((listenerEvent)=>{
1809
1820
  off(document, listenerEvent, (evt)=>{
1810
- if (typeof evt.getModifierState === "function") {
1821
+ if (typeof evt.getModifierState === 'function') {
1811
1822
  setState(evt.getModifierState(modifier));
1812
1823
  }
1813
1824
  });
@@ -1822,11 +1833,11 @@ function useLocalStorage(key, defaultValue, options = defaultOptions$1) {
1822
1833
  }
1823
1834
 
1824
1835
  function subscribe$1(callback) {
1825
- window.addEventListener("popstate", callback);
1826
- window.addEventListener("hashchange", callback);
1836
+ window.addEventListener('popstate', callback);
1837
+ window.addEventListener('hashchange', callback);
1827
1838
  return ()=>{
1828
- window.removeEventListener("popstate", callback);
1829
- window.removeEventListener("hashchange", callback);
1839
+ window.removeEventListener('popstate', callback);
1840
+ window.removeEventListener('hashchange', callback);
1830
1841
  };
1831
1842
  }
1832
1843
  const useLocationSelector = (selector, /**
@@ -1836,24 +1847,24 @@ const useLocationSelector = (selector, /**
1836
1847
  return index_js.useSyncExternalStore(subscribe$1, ()=>selector(location), ()=>fallback);
1837
1848
  };
1838
1849
 
1839
- const isTouchEvent = (ev)=>{
1840
- return "touches" in ev;
1841
- };
1842
- const preventDefault$1 = (ev)=>{
1850
+ function isTouchEvent(ev) {
1851
+ return 'touches' in ev;
1852
+ }
1853
+ function preventDefault$1(ev) {
1843
1854
  if (!isTouchEvent(ev)) {
1844
1855
  return;
1845
1856
  }
1846
1857
  if (ev.touches.length < 2 && ev.preventDefault) {
1847
1858
  ev.preventDefault();
1848
1859
  }
1849
- };
1860
+ }
1850
1861
  const useLongPress = (callback, { isPreventDefault = true, delay = 300 } = defaultOptions$1)=>{
1851
1862
  const timeout = React.useRef();
1852
1863
  const target = React.useRef();
1853
1864
  const start = React.useCallback((event)=>{
1854
1865
  // prevent ghost click on mobile devices
1855
1866
  if (isPreventDefault && event.target) {
1856
- on(event.target, "touchend", preventDefault$1, {
1867
+ on(event.target, 'touchend', preventDefault$1, {
1857
1868
  passive: false
1858
1869
  });
1859
1870
  target.current = event.target;
@@ -1868,7 +1879,7 @@ const useLongPress = (callback, { isPreventDefault = true, delay = 300 } = defau
1868
1879
  // clearTimeout and removeEventListener
1869
1880
  timeout.current && clearTimeout(timeout.current);
1870
1881
  if (isPreventDefault && target.current) {
1871
- off(target.current, "touchend", preventDefault$1);
1882
+ off(target.current, 'touchend', preventDefault$1);
1872
1883
  }
1873
1884
  }, [
1874
1885
  isPreventDefault
@@ -1982,12 +1993,12 @@ const useMediaDevices = (options = {})=>{
1982
1993
  let state;
1983
1994
  try {
1984
1995
  state = (yield navigator.permissions.query({
1985
- name: "camera"
1996
+ name: 'camera'
1986
1997
  })).state;
1987
1998
  } catch (error) {
1988
- state = "prompt";
1999
+ state = 'prompt';
1989
2000
  }
1990
- if (state !== "granted") {
2001
+ if (state !== 'granted') {
1991
2002
  stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
1992
2003
  onChange();
1993
2004
  permissionGranted.current = true;
@@ -2007,10 +2018,10 @@ const useMediaDevices = (options = {})=>{
2007
2018
  if (requestPermissions) {
2008
2019
  ensurePermissions();
2009
2020
  }
2010
- on(navigator.mediaDevices, "devicechange", onChange);
2021
+ on(navigator.mediaDevices, 'devicechange', onChange);
2011
2022
  onChange();
2012
2023
  return ()=>{
2013
- off(navigator.mediaDevices, "devicechange", onChange);
2024
+ off(navigator.mediaDevices, 'devicechange', onChange);
2014
2025
  };
2015
2026
  }, [
2016
2027
  onChange,
@@ -2024,7 +2035,7 @@ const useMediaDevices = (options = {})=>{
2024
2035
  ];
2025
2036
  };
2026
2037
 
2027
- const getInitialState = (query, defaultState)=>{
2038
+ function getInitialState(query, defaultState) {
2028
2039
  // Prevent a React hydration mismatch when a default value is provided by not defaulting to window.matchMedia(query).matches.
2029
2040
  if (defaultState !== undefined) {
2030
2041
  return defaultState;
@@ -2033,11 +2044,11 @@ const getInitialState = (query, defaultState)=>{
2033
2044
  return window.matchMedia(query).matches;
2034
2045
  }
2035
2046
  // A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
2036
- if (process.env.NODE_ENV !== "production") {
2037
- console.warn("`useMediaQuery` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
2047
+ if (process.env.NODE_ENV !== 'production') {
2048
+ console.warn('`useMediaQuery` When server side rendering, defaultState should be defined to prevent a hydration mismatches.');
2038
2049
  }
2039
2050
  return false;
2040
- };
2051
+ }
2041
2052
  const useMediaQuery = (query, defaultState)=>{
2042
2053
  const [state, setState] = React.useState(getInitialState(query, defaultState));
2043
2054
  React.useEffect(()=>{
@@ -2049,16 +2060,16 @@ const useMediaQuery = (query, defaultState)=>{
2049
2060
  }
2050
2061
  setState(!!mql.matches);
2051
2062
  };
2052
- if ("addEventListener" in mql) {
2053
- mql.addEventListener("change", onChange);
2063
+ if ('addEventListener' in mql) {
2064
+ mql.addEventListener('change', onChange);
2054
2065
  } else {
2055
2066
  mql.addListener == null ? void 0 : mql.addListener.call(mql, onChange);
2056
2067
  }
2057
2068
  setState(mql.matches);
2058
2069
  return ()=>{
2059
2070
  mounted = false;
2060
- if ("removeEventListener" in mql) {
2061
- mql.removeEventListener("change", onChange);
2071
+ if ('removeEventListener' in mql) {
2072
+ mql.removeEventListener('change', onChange);
2062
2073
  } else {
2063
2074
  mql.removeListener == null ? void 0 : mql.removeListener.call(mql, onChange);
2064
2075
  }
@@ -2069,7 +2080,7 @@ const useMediaQuery = (query, defaultState)=>{
2069
2080
  return state;
2070
2081
  };
2071
2082
 
2072
- const useRafState = (initialState)=>{
2083
+ function useRafState(initialState) {
2073
2084
  const frame = React.useRef(0);
2074
2085
  const [state, setState] = React.useState(initialState);
2075
2086
  const setRafState = React.useCallback((value)=>{
@@ -2085,7 +2096,7 @@ const useRafState = (initialState)=>{
2085
2096
  state,
2086
2097
  setRafState
2087
2098
  ];
2088
- };
2099
+ }
2089
2100
 
2090
2101
  const initState = {
2091
2102
  screenX: Number.NaN,
@@ -2103,7 +2114,7 @@ const initState = {
2103
2114
  };
2104
2115
  const useMouse = (target)=>{
2105
2116
  const [state, setState] = useRafState(initState);
2106
- useEventListener("mousemove", (event)=>{
2117
+ useEventListener('mousemove', (event)=>{
2107
2118
  const { screenX, screenY, clientX, clientY, pageX, pageY } = event;
2108
2119
  const newState = {
2109
2120
  screenX,
@@ -2150,30 +2161,30 @@ const useMousePressed = (target, options = defaultOptions$1)=>{
2150
2161
  setPressed(false);
2151
2162
  setSourceType(null);
2152
2163
  }, []);
2153
- useEventListener("mousedown", onPressed("mouse"), target, listenerOptions$2);
2154
- useEventListener("mouseleave", onReleased, ()=>window, listenerOptions$2);
2155
- useEventListener("mouseup", onReleased, ()=>window, listenerOptions$2);
2164
+ useEventListener('mousedown', onPressed('mouse'), target, listenerOptions$2);
2165
+ useEventListener('mouseleave', onReleased, ()=>window, listenerOptions$2);
2166
+ useEventListener('mouseup', onReleased, ()=>window, listenerOptions$2);
2156
2167
  React.useEffect(()=>{
2157
2168
  if (drag) {
2158
- element == null ? void 0 : element.addEventListener("dragstart", onPressed("mouse"), listenerOptions$2);
2159
- element == null ? void 0 : element.addEventListener("drop", onReleased, listenerOptions$2);
2160
- element == null ? void 0 : element.addEventListener("dragend", onReleased, listenerOptions$2);
2169
+ element == null ? void 0 : element.addEventListener('dragstart', onPressed('mouse'), listenerOptions$2);
2170
+ element == null ? void 0 : element.addEventListener('drop', onReleased, listenerOptions$2);
2171
+ element == null ? void 0 : element.addEventListener('dragend', onReleased, listenerOptions$2);
2161
2172
  }
2162
2173
  if (touch) {
2163
- element == null ? void 0 : element.addEventListener("touchstart", onPressed("touch"), listenerOptions$2);
2164
- element == null ? void 0 : element.addEventListener("touchend", onReleased, listenerOptions$2);
2165
- element == null ? void 0 : element.addEventListener("touchcancel", onReleased, listenerOptions$2);
2174
+ element == null ? void 0 : element.addEventListener('touchstart', onPressed('touch'), listenerOptions$2);
2175
+ element == null ? void 0 : element.addEventListener('touchend', onReleased, listenerOptions$2);
2176
+ element == null ? void 0 : element.addEventListener('touchcancel', onReleased, listenerOptions$2);
2166
2177
  }
2167
2178
  return ()=>{
2168
2179
  if (drag) {
2169
- element == null ? void 0 : element.removeEventListener("dragstart", onPressed("mouse"));
2170
- element == null ? void 0 : element.removeEventListener("drop", onReleased);
2171
- element == null ? void 0 : element.removeEventListener("dragend", onReleased);
2180
+ element == null ? void 0 : element.removeEventListener('dragstart', onPressed('mouse'));
2181
+ element == null ? void 0 : element.removeEventListener('drop', onReleased);
2182
+ element == null ? void 0 : element.removeEventListener('dragend', onReleased);
2172
2183
  }
2173
2184
  if (touch) {
2174
- element == null ? void 0 : element.removeEventListener("touchstart", onPressed("touch"));
2175
- element == null ? void 0 : element.removeEventListener("touchend", onReleased);
2176
- element == null ? void 0 : element.removeEventListener("touchcancel", onReleased);
2185
+ element == null ? void 0 : element.removeEventListener('touchstart', onPressed('touch'));
2186
+ element == null ? void 0 : element.removeEventListener('touchend', onReleased);
2187
+ element == null ? void 0 : element.removeEventListener('touchcancel', onReleased);
2177
2188
  }
2178
2189
  };
2179
2190
  }, [
@@ -2234,22 +2245,22 @@ const useNetwork = ()=>{
2234
2245
  const handleStateChange = ()=>{
2235
2246
  setState(getConnectionState);
2236
2247
  };
2237
- on(window, "online", handleStateChange, {
2248
+ on(window, 'online', handleStateChange, {
2238
2249
  passive: true
2239
2250
  });
2240
- on(window, "offline", handleStateChange, {
2251
+ on(window, 'offline', handleStateChange, {
2241
2252
  passive: true
2242
2253
  });
2243
2254
  if (conn) {
2244
- on(conn, "change", handleStateChange, {
2255
+ on(conn, 'change', handleStateChange, {
2245
2256
  passive: true
2246
2257
  });
2247
2258
  }
2248
2259
  return ()=>{
2249
- off(window, "online", handleStateChange);
2250
- off(window, "offline", handleStateChange);
2260
+ off(window, 'online', handleStateChange);
2261
+ off(window, 'offline', handleStateChange);
2251
2262
  if (conn) {
2252
- off(conn, "change", handleStateChange);
2263
+ off(conn, 'change', handleStateChange);
2253
2264
  }
2254
2265
  };
2255
2266
  }, []);
@@ -2299,7 +2310,7 @@ const useOnline = ()=>{
2299
2310
 
2300
2311
  const defaultState = {
2301
2312
  angle: 0,
2302
- type: "landscape-primary"
2313
+ type: 'landscape-primary'
2303
2314
  };
2304
2315
  const useOrientation = (initialState = defaultState)=>{
2305
2316
  const [state, setState] = React.useState(initialState);
@@ -2317,25 +2328,25 @@ const useOrientation = (initialState = defaultState)=>{
2317
2328
  });
2318
2329
  } else if (window.orientation !== undefined) {
2319
2330
  setState({
2320
- angle: typeof window.orientation === "number" ? window.orientation : 0,
2331
+ angle: typeof window.orientation === 'number' ? window.orientation : 0,
2321
2332
  type: void 0
2322
2333
  });
2323
2334
  }
2324
2335
  }
2325
2336
  };
2326
- on(window, "orientationchange", onChange);
2337
+ on(window, 'orientationchange', onChange);
2327
2338
  onChange();
2328
2339
  return ()=>{
2329
2340
  mounted = false;
2330
- off(window, "orientationchange", onChange);
2341
+ off(window, 'orientationchange', onChange);
2331
2342
  };
2332
2343
  }, []);
2333
2344
  const lockOrientation = (type)=>{
2334
2345
  if (isBrowser) {
2335
2346
  return;
2336
2347
  }
2337
- if (!(window && "screen" in window && "orientation" in window.screen)) {
2338
- return Promise.reject(new Error("Not supported"));
2348
+ if (!(window && 'screen' in window && 'orientation' in window.screen)) {
2349
+ return Promise.reject(new Error('Not supported'));
2339
2350
  }
2340
2351
  return window.screen.orientation.lock(type);
2341
2352
  };
@@ -2343,7 +2354,7 @@ const useOrientation = (initialState = defaultState)=>{
2343
2354
  if (isBrowser) {
2344
2355
  return;
2345
2356
  }
2346
- if (!(window && "screen" in window && "orientation" in window.screen)) {
2357
+ if (!(window && 'screen' in window && 'orientation' in window.screen)) {
2347
2358
  return;
2348
2359
  }
2349
2360
  return window.screen.orientation.unlock();
@@ -2355,7 +2366,7 @@ const useOrientation = (initialState = defaultState)=>{
2355
2366
  ];
2356
2367
  };
2357
2368
 
2358
- const usePageLeave = ()=>{
2369
+ function usePageLeave() {
2359
2370
  const [isLeft, setIsLeft] = React.useState(false);
2360
2371
  const handler = (event)=>{
2361
2372
  if (!window) return;
@@ -2364,23 +2375,23 @@ const usePageLeave = ()=>{
2364
2375
  const from = event.relatedTarget || event.toElement;
2365
2376
  setIsLeft(!from);
2366
2377
  };
2367
- useEventListener("mouseout", handler, ()=>window, {
2378
+ useEventListener('mouseout', handler, ()=>window, {
2368
2379
  passive: true
2369
2380
  });
2370
- useEventListener("mouseleave", handler, ()=>document, {
2381
+ useEventListener('mouseleave', handler, ()=>document, {
2371
2382
  passive: true
2372
2383
  });
2373
- useEventListener("mouseenter", handler, ()=>document, {
2384
+ useEventListener('mouseenter', handler, ()=>document, {
2374
2385
  passive: true
2375
2386
  });
2376
2387
  return isLeft;
2377
- };
2388
+ }
2378
2389
 
2379
2390
  const usePermission = (permissionDesc)=>{
2380
- const [state, setState] = React.useState("");
2391
+ const [state, setState] = React.useState('');
2381
2392
  React.useEffect(()=>{
2382
2393
  var _navigator_permissions;
2383
- const desc = typeof permissionDesc === "string" ? {
2394
+ const desc = typeof permissionDesc === 'string' ? {
2384
2395
  name: permissionDesc
2385
2396
  } : permissionDesc;
2386
2397
  let mounted = true;
@@ -2391,16 +2402,16 @@ const usePermission = (permissionDesc)=>{
2391
2402
  }
2392
2403
  setState(()=>{
2393
2404
  var _permissionStatus_state;
2394
- return (_permissionStatus_state = permissionStatus == null ? void 0 : permissionStatus.state) != null ? _permissionStatus_state : "";
2405
+ return (_permissionStatus_state = permissionStatus == null ? void 0 : permissionStatus.state) != null ? _permissionStatus_state : '';
2395
2406
  });
2396
2407
  };
2397
2408
  (_navigator_permissions = navigator.permissions) == null ? void 0 : _navigator_permissions.query(desc).then((status)=>{
2398
2409
  permissionStatus = status;
2399
- on(permissionStatus, "change", onChange);
2410
+ on(permissionStatus, 'change', onChange);
2400
2411
  onChange();
2401
2412
  }).catch(noop);
2402
2413
  return ()=>{
2403
- permissionStatus && off(permissionStatus, "change", onChange);
2414
+ permissionStatus && off(permissionStatus, 'change', onChange);
2404
2415
  mounted = false;
2405
2416
  permissionStatus = null;
2406
2417
  };
@@ -2410,56 +2421,56 @@ const usePermission = (permissionDesc)=>{
2410
2421
  return state;
2411
2422
  };
2412
2423
 
2413
- const usePreferredColorScheme = (defaultState = "no-preference")=>{
2414
- const isLight = useMediaQuery("(prefers-color-scheme: light)", false);
2415
- const isDark = useMediaQuery("(prefers-color-scheme: dark)", false);
2416
- return isDark ? "dark" : isLight ? "light" : defaultState;
2424
+ const usePreferredColorScheme = (defaultState = 'no-preference')=>{
2425
+ const isLight = useMediaQuery('(prefers-color-scheme: light)', false);
2426
+ const isDark = useMediaQuery('(prefers-color-scheme: dark)', false);
2427
+ return isDark ? 'dark' : isLight ? 'light' : defaultState;
2417
2428
  };
2418
2429
 
2419
- const usePreferredContrast = (defaultState = "no-preference")=>{
2420
- const isMore = useMediaQuery("(prefexrs-contrast: more)", false);
2421
- const isLess = useMediaQuery("(prefers-contrast: less)", false);
2422
- const isCustom = useMediaQuery("(prefers-contrast: custom)", false);
2423
- return isMore ? "more" : isLess ? "less" : isCustom ? "custom" : defaultState;
2430
+ const usePreferredContrast = (defaultState = 'no-preference')=>{
2431
+ const isMore = useMediaQuery('(prefexrs-contrast: more)', false);
2432
+ const isLess = useMediaQuery('(prefers-contrast: less)', false);
2433
+ const isCustom = useMediaQuery('(prefers-contrast: custom)', false);
2434
+ return isMore ? 'more' : isLess ? 'less' : isCustom ? 'custom' : defaultState;
2424
2435
  };
2425
2436
 
2426
- const usePreferredDark = (defaultState)=>{
2427
- return useMediaQuery("(prefers-color-scheme: dark)", defaultState);
2428
- };
2437
+ function usePreferredDark(defaultState) {
2438
+ return useMediaQuery('(prefers-color-scheme: dark)', defaultState);
2439
+ }
2429
2440
 
2430
- const usePrevious = (state)=>{
2441
+ function usePrevious(state) {
2431
2442
  const ref = React.useRef();
2432
2443
  React.useEffect(()=>{
2433
2444
  ref.current = state;
2434
2445
  });
2435
2446
  return ref.current;
2436
- };
2447
+ }
2437
2448
 
2438
- const useReducedMotion = (defaultState)=>{
2439
- return useMediaQuery("(prefers-reduced-motion: reduce)", defaultState);
2440
- };
2449
+ function useReducedMotion(defaultState) {
2450
+ return useMediaQuery('(prefers-reduced-motion: reduce)', defaultState);
2451
+ }
2441
2452
 
2442
2453
  const updateReducer = (num)=>(num + 1) % 1000000;
2443
- const useUpdate = ()=>{
2454
+ function useUpdate() {
2444
2455
  const [, update] = React.useReducer(updateReducer, 0);
2445
2456
  return update;
2446
- };
2457
+ }
2447
2458
 
2448
- const topVarName = "--reactuse-safe-area-top";
2449
- const rightVarName = "--reactuse-safe-area-right";
2450
- const bottomVarName = "--reactuse-safe-area-bottom";
2451
- const leftVarName = "--reactuse-safe-area-left";
2459
+ const topVarName = '--reactuse-safe-area-top';
2460
+ const rightVarName = '--reactuse-safe-area-right';
2461
+ const bottomVarName = '--reactuse-safe-area-bottom';
2462
+ const leftVarName = '--reactuse-safe-area-left';
2452
2463
  const defaultElement = ()=>document.documentElement;
2453
- const useScreenSafeArea = ()=>{
2454
- const top = React.useRef("");
2455
- const right = React.useRef("");
2456
- const bottom = React.useRef("");
2457
- const left = React.useRef("");
2464
+ function useScreenSafeArea() {
2465
+ const top = React.useRef('');
2466
+ const right = React.useRef('');
2467
+ const bottom = React.useRef('');
2468
+ const left = React.useRef('');
2458
2469
  const forceUpdate = useUpdate();
2459
- useCssVar(topVarName, defaultElement, "env(safe-area-inset-top, 0px)");
2460
- useCssVar(rightVarName, defaultElement, "env(safe-area-inset-right, 0px)");
2461
- useCssVar(bottomVarName, defaultElement, "env(safe-area-inset-bottom, 0px)");
2462
- useCssVar(leftVarName, defaultElement, "env(safe-area-inset-left, 0px)");
2470
+ useCssVar(topVarName, defaultElement, 'env(safe-area-inset-top, 0px)');
2471
+ useCssVar(rightVarName, defaultElement, 'env(safe-area-inset-right, 0px)');
2472
+ useCssVar(bottomVarName, defaultElement, 'env(safe-area-inset-bottom, 0px)');
2473
+ useCssVar(leftVarName, defaultElement, 'env(safe-area-inset-left, 0px)');
2463
2474
  const { run: update } = useDebounceFn(()=>{
2464
2475
  top.current = getValue(topVarName);
2465
2476
  right.current = getValue(rightVarName);
@@ -2472,7 +2483,7 @@ const useScreenSafeArea = ()=>{
2472
2483
  }, [
2473
2484
  update
2474
2485
  ]);
2475
- useEventListener("resize", update);
2486
+ useEventListener('resize', update);
2476
2487
  return [
2477
2488
  top.current,
2478
2489
  right.current,
@@ -2480,16 +2491,16 @@ const useScreenSafeArea = ()=>{
2480
2491
  left.current,
2481
2492
  update
2482
2493
  ];
2483
- };
2494
+ }
2484
2495
  function getValue(position) {
2485
2496
  return getComputedStyle(document.documentElement).getPropertyValue(position);
2486
2497
  }
2487
2498
 
2488
2499
  const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2489
- const { immediate = true, manual = false, type = "text/javascript", async = true, crossOrigin, referrerPolicy, noModule, defer, attrs = {} } = options;
2500
+ const { immediate = true, manual = false, type = 'text/javascript', async = true, crossOrigin, referrerPolicy, noModule, defer, attrs = {} } = options;
2490
2501
  const scriptTag = React.useRef(null);
2491
2502
  const _promise = React.useRef(null);
2492
- const [status, setStatus] = React.useState(src ? "loading" : "idle");
2503
+ const [status, setStatus] = React.useState(src ? 'loading' : 'idle');
2493
2504
  /**
2494
2505
  * Load the script specified via `src`.
2495
2506
  *
@@ -2508,7 +2519,7 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2508
2519
  return;
2509
2520
  }
2510
2521
  if (!src) {
2511
- setStatus("idle");
2522
+ setStatus('idle');
2512
2523
  resolve(false);
2513
2524
  return;
2514
2525
  }
@@ -2517,7 +2528,7 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2517
2528
  let el = document.querySelector(`script[src="${src}"]`);
2518
2529
  // Script tag not found, preparing the element for appending
2519
2530
  if (!el) {
2520
- el = document.createElement("script");
2531
+ el = document.createElement('script');
2521
2532
  el.type = type;
2522
2533
  el.async = async;
2523
2534
  el.src = src;
@@ -2537,22 +2548,22 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2537
2548
  Object.entries(attrs).forEach(([name, value])=>el == null ? void 0 : el.setAttribute(name, value));
2538
2549
  // Enables shouldAppend
2539
2550
  shouldAppend = true;
2540
- } else if (el.hasAttribute("data-loaded")) {
2541
- setStatus(el.getAttribute("data-status"));
2551
+ } else if (el.hasAttribute('data-loaded')) {
2552
+ setStatus(el.getAttribute('data-status'));
2542
2553
  resolveWithElement(el);
2543
2554
  }
2544
2555
  // Event listeners
2545
- el.addEventListener("error", (event)=>{
2546
- setStatus(event.type === "load" ? "ready" : "error");
2556
+ el.addEventListener('error', (event)=>{
2557
+ setStatus(event.type === 'load' ? 'ready' : 'error');
2547
2558
  return reject(event);
2548
2559
  });
2549
- el.addEventListener("abort", (event)=>{
2550
- setStatus(event.type === "load" ? "ready" : "error");
2560
+ el.addEventListener('abort', (event)=>{
2561
+ setStatus(event.type === 'load' ? 'ready' : 'error');
2551
2562
  return reject(event);
2552
2563
  });
2553
- el.addEventListener("load", (event)=>{
2554
- setStatus(event.type === "load" ? "ready" : "error");
2555
- el.setAttribute("data-loaded", "true");
2564
+ el.addEventListener('load', (event)=>{
2565
+ setStatus(event.type === 'load' ? 'ready' : 'error');
2566
+ el.setAttribute('data-loaded', 'true');
2556
2567
  onLoaded(el);
2557
2568
  resolveWithElement(el);
2558
2569
  });
@@ -2609,11 +2620,11 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2609
2620
  ];
2610
2621
  };
2611
2622
 
2612
- const setScrollParam = ({ axis, parent, distance })=>{
2613
- if (!parent && typeof document === "undefined") {
2623
+ function setScrollParam({ axis, parent, distance }) {
2624
+ if (!parent && typeof document === 'undefined') {
2614
2625
  return;
2615
2626
  }
2616
- const method = axis === "y" ? "scrollTop" : "scrollLeft";
2627
+ const method = axis === 'y' ? 'scrollTop' : 'scrollLeft';
2617
2628
  if (parent) {
2618
2629
  parent[method] = distance;
2619
2630
  } else {
@@ -2621,16 +2632,16 @@ const setScrollParam = ({ axis, parent, distance })=>{
2621
2632
  body[method] = distance;
2622
2633
  documentElement[method] = distance;
2623
2634
  }
2624
- };
2625
- const isScrollElement = (axis, node)=>{
2635
+ }
2636
+ function isScrollElement(axis, node) {
2626
2637
  if (!node) {
2627
2638
  return false;
2628
2639
  }
2629
- const AXIS = axis === "x" ? "X" : "Y";
2630
- return getComputedStyle(node)[`overflow${AXIS}`] === "auto" || getComputedStyle(node)[`overflow${AXIS}`] === "scroll";
2631
- };
2640
+ const AXIS = axis === 'x' ? 'X' : 'Y';
2641
+ return getComputedStyle(node)[`overflow${AXIS}`] === 'auto' || getComputedStyle(node)[`overflow${AXIS}`] === 'scroll';
2642
+ }
2632
2643
  const cache = new Map();
2633
- const getScrollParent = (axis, node)=>{
2644
+ function getScrollParent(axis, node) {
2634
2645
  if (!node || !node.parentElement) {
2635
2646
  return null;
2636
2647
  }
@@ -2645,24 +2656,26 @@ const getScrollParent = (axis, node)=>{
2645
2656
  cache.set(node, parent);
2646
2657
  }
2647
2658
  return parent;
2648
- };
2649
- const getScrollStart = ({ axis, parent })=>{
2650
- if (!parent && typeof document === "undefined") {
2659
+ }
2660
+ function getScrollStart({ axis, parent }) {
2661
+ if (!parent && typeof document === 'undefined') {
2651
2662
  return 0;
2652
2663
  }
2653
- const method = axis === "y" ? "scrollTop" : "scrollLeft";
2664
+ const method = axis === 'y' ? 'scrollTop' : 'scrollLeft';
2654
2665
  if (parent) {
2655
2666
  return parent[method];
2656
2667
  }
2657
2668
  const { body, documentElement } = document;
2658
2669
  // while one of it has a value the second is equal 0
2659
2670
  return body[method] + documentElement[method];
2660
- };
2671
+ }
2661
2672
 
2662
- const easeInOutQuad = (t)=>t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
2673
+ function easeInOutQuad(t) {
2674
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
2675
+ }
2663
2676
 
2664
- const getRelativePosition = ({ axis, target, parent, alignment, offset, isList })=>{
2665
- if (!target || !parent && typeof document === "undefined") {
2677
+ function getRelativePosition({ axis, target, parent, alignment, offset, isList }) {
2678
+ if (!target || !parent && typeof document === 'undefined') {
2666
2679
  return 0;
2667
2680
  }
2668
2681
  const isCustomParent = !!parent;
@@ -2670,55 +2683,55 @@ const getRelativePosition = ({ axis, target, parent, alignment, offset, isList }
2670
2683
  const parentPosition = parentElement.getBoundingClientRect();
2671
2684
  const targetPosition = target.getBoundingClientRect();
2672
2685
  const getDiff = (property)=>targetPosition[property] - parentPosition[property];
2673
- if (axis === "y") {
2674
- const diff = getDiff("top");
2686
+ if (axis === 'y') {
2687
+ const diff = getDiff('top');
2675
2688
  if (diff === 0) {
2676
2689
  return 0;
2677
2690
  }
2678
- if (alignment === "start") {
2691
+ if (alignment === 'start') {
2679
2692
  const distance = diff - offset;
2680
2693
  const shouldScroll = distance <= targetPosition.height * (isList ? 0 : 1) || !isList;
2681
2694
  return shouldScroll ? distance : 0;
2682
2695
  }
2683
2696
  const parentHeight = isCustomParent ? parentPosition.height : window.innerHeight;
2684
- if (alignment === "end") {
2697
+ if (alignment === 'end') {
2685
2698
  const distance = diff + offset - parentHeight + targetPosition.height;
2686
2699
  const shouldScroll = distance >= -targetPosition.height * (isList ? 0 : 1) || !isList;
2687
2700
  return shouldScroll ? distance : 0;
2688
2701
  }
2689
- if (alignment === "center") {
2702
+ if (alignment === 'center') {
2690
2703
  return diff - parentHeight / 2 + targetPosition.height / 2;
2691
2704
  }
2692
2705
  return 0;
2693
2706
  }
2694
- if (axis === "x") {
2695
- const diff = getDiff("left");
2707
+ if (axis === 'x') {
2708
+ const diff = getDiff('left');
2696
2709
  if (diff === 0) {
2697
2710
  return 0;
2698
2711
  }
2699
- if (alignment === "start") {
2712
+ if (alignment === 'start') {
2700
2713
  const distance = diff - offset;
2701
2714
  const shouldScroll = distance <= targetPosition.width || !isList;
2702
2715
  return shouldScroll ? distance : 0;
2703
2716
  }
2704
2717
  const parentWidth = isCustomParent ? parentPosition.width : window.innerWidth;
2705
- if (alignment === "end") {
2718
+ if (alignment === 'end') {
2706
2719
  const distance = diff + offset - parentWidth + targetPosition.width;
2707
2720
  const shouldScroll = distance >= -targetPosition.width || !isList;
2708
2721
  return shouldScroll ? distance : 0;
2709
2722
  }
2710
- if (alignment === "center") {
2723
+ if (alignment === 'center') {
2711
2724
  return diff - parentWidth / 2 + targetPosition.width / 2;
2712
2725
  }
2713
2726
  return 0;
2714
2727
  }
2715
2728
  return 0;
2716
- };
2729
+ }
2717
2730
 
2718
2731
  const listenerOptions$1 = {
2719
2732
  passive: true
2720
2733
  };
2721
- const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrollFinish, easing = easeInOutQuad, offset = 0, cancelable = true, isList = false } = defaultOptions$1, scrollElement)=>{
2734
+ const useScrollIntoView = (targetElement, { duration = 1250, axis = 'y', onScrollFinish, easing = easeInOutQuad, offset = 0, cancelable = true, isList = false } = defaultOptions$1, scrollElement)=>{
2722
2735
  const frameID = React.useRef(0);
2723
2736
  const startTime = React.useRef(0);
2724
2737
  const shouldStop = React.useRef(false);
@@ -2729,7 +2742,7 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrol
2729
2742
  }
2730
2743
  };
2731
2744
  const element = getTargetElement(targetElement);
2732
- const scrollIntoView = ({ alignment = "start" } = {})=>{
2745
+ const scrollIntoView = ({ alignment = 'start' } = {})=>{
2733
2746
  const parent = getTargetElement(scrollElement) || getScrollParent(axis, element);
2734
2747
  shouldStop.current = false;
2735
2748
  if (frameID.current) {
@@ -2765,7 +2778,7 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrol
2765
2778
  if (!shouldStop.current && t < 1) {
2766
2779
  frameID.current = requestAnimationFrame(animateScroll);
2767
2780
  } else {
2768
- typeof onScrollFinish === "function" && onScrollFinish();
2781
+ typeof onScrollFinish === 'function' && onScrollFinish();
2769
2782
  startTime.current = 0;
2770
2783
  frameID.current = 0;
2771
2784
  cancel();
@@ -2778,8 +2791,8 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrol
2778
2791
  shouldStop.current = true;
2779
2792
  }
2780
2793
  };
2781
- useEventListener("wheel", handleStop, null, listenerOptions$1);
2782
- useEventListener("touchmove", handleStop, null, listenerOptions$1);
2794
+ useEventListener('wheel', handleStop, null, listenerOptions$1);
2795
+ useEventListener('touchmove', handleStop, null, listenerOptions$1);
2783
2796
  React.useEffect(()=>cancel, []);
2784
2797
  return {
2785
2798
  scrollIntoView,
@@ -2800,13 +2813,13 @@ function preventDefault(rawEvent) {
2800
2813
  }
2801
2814
  const useScrollLock = (target, initialState = false)=>{
2802
2815
  const [locked, setLocked] = React.useState(initialState);
2803
- const initialOverflowRef = React.useRef("scroll");
2816
+ const initialOverflowRef = React.useRef('scroll');
2804
2817
  React.useEffect(()=>{
2805
2818
  const element = getTargetElement(target);
2806
2819
  if (element) {
2807
2820
  initialOverflowRef.current = element.style.overflow;
2808
2821
  if (locked) {
2809
- element.style.overflow = "hidden";
2822
+ element.style.overflow = 'hidden';
2810
2823
  }
2811
2824
  }
2812
2825
  }, [
@@ -2819,7 +2832,7 @@ const useScrollLock = (target, initialState = false)=>{
2819
2832
  return;
2820
2833
  }
2821
2834
  if (isIOS) {
2822
- element.addEventListener("touchmove", preventDefault, {
2835
+ element.addEventListener('touchmove', preventDefault, {
2823
2836
  passive: false
2824
2837
  });
2825
2838
  }
@@ -2831,7 +2844,7 @@ const useScrollLock = (target, initialState = false)=>{
2831
2844
  return;
2832
2845
  }
2833
2846
  if (isIOS) {
2834
- element.removeEventListener("touchmove", preventDefault);
2847
+ element.removeEventListener('touchmove', preventDefault);
2835
2848
  }
2836
2849
  element.style.overflow = initialOverflowRef.current;
2837
2850
  setLocked(false);
@@ -2869,14 +2882,14 @@ function _extends() {
2869
2882
  }
2870
2883
  const useSetState = (initialState)=>{
2871
2884
  const [state, _setState] = React.useState(initialState);
2872
- const setState = React.useCallback((statePartial)=>_setState((current)=>_extends({}, current, typeof statePartial === "function" ? statePartial(current) : statePartial)), []);
2885
+ const setState = React.useCallback((statePartial)=>_setState((current)=>_extends({}, current, typeof statePartial === 'function' ? statePartial(current) : statePartial)), []);
2873
2886
  return [
2874
2887
  state,
2875
2888
  setState
2876
2889
  ];
2877
2890
  };
2878
2891
 
2879
- const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2892
+ function useSticky(targetElement, { axis = 'y', nav = 0 }, scrollElement) {
2880
2893
  const [isSticky, setSticky] = React.useState(false);
2881
2894
  const { run: scrollHandler } = useThrottleFn(()=>{
2882
2895
  const element = getTargetElement(targetElement);
@@ -2884,7 +2897,7 @@ const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2884
2897
  return;
2885
2898
  }
2886
2899
  const rect = element.getBoundingClientRect();
2887
- if (axis === "y") {
2900
+ if (axis === 'y') {
2888
2901
  setSticky((rect == null ? void 0 : rect.top) <= nav);
2889
2902
  } else {
2890
2903
  setSticky((rect == null ? void 0 : rect.left) <= nav);
@@ -2896,10 +2909,10 @@ const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2896
2909
  if (!element || !scrollParent) {
2897
2910
  return;
2898
2911
  }
2899
- scrollParent.addEventListener("scroll", scrollHandler);
2912
+ scrollParent.addEventListener('scroll', scrollHandler);
2900
2913
  scrollHandler();
2901
2914
  return ()=>{
2902
- scrollParent.removeEventListener("scroll", scrollHandler);
2915
+ scrollParent.removeEventListener('scroll', scrollHandler);
2903
2916
  };
2904
2917
  }, [
2905
2918
  axis,
@@ -2911,10 +2924,10 @@ const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2911
2924
  isSticky,
2912
2925
  setSticky
2913
2926
  ];
2914
- };
2927
+ }
2915
2928
 
2916
2929
  const useTextDirection = (options = defaultOptions$1)=>{
2917
- const { selector = "html", initialValue = "ltr" } = options;
2930
+ const { selector = 'html', initialValue = 'ltr' } = options;
2918
2931
  const getValue = ()=>{
2919
2932
  if (initialValue !== undefined) {
2920
2933
  return initialValue;
@@ -2922,11 +2935,11 @@ const useTextDirection = (options = defaultOptions$1)=>{
2922
2935
  if (isBrowser) {
2923
2936
  var _document_querySelector, _document;
2924
2937
  var _document_querySelector_getAttribute;
2925
- return (_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute("dir")) != null ? _document_querySelector_getAttribute : initialValue;
2938
+ return (_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute('dir')) != null ? _document_querySelector_getAttribute : initialValue;
2926
2939
  }
2927
2940
  // A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
2928
- if (process.env.NODE_ENV !== "production") {
2929
- console.warn("`useTextDirection` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
2941
+ if (process.env.NODE_ENV !== 'production') {
2942
+ console.warn('`useTextDirection` When server side rendering, defaultState should be defined to prevent a hydration mismatches.');
2930
2943
  }
2931
2944
  return initialValue;
2932
2945
  };
@@ -2934,7 +2947,7 @@ const useTextDirection = (options = defaultOptions$1)=>{
2934
2947
  React.useEffect(()=>{
2935
2948
  var _document_querySelector, _document;
2936
2949
  var _document_querySelector_getAttribute;
2937
- setValue((_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute("dir")) != null ? _document_querySelector_getAttribute : initialValue);
2950
+ setValue((_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute('dir')) != null ? _document_querySelector_getAttribute : initialValue);
2938
2951
  }, [
2939
2952
  initialValue,
2940
2953
  selector
@@ -2945,10 +2958,10 @@ const useTextDirection = (options = defaultOptions$1)=>{
2945
2958
  }
2946
2959
  if (value !== null) {
2947
2960
  var _document_querySelector;
2948
- (_document_querySelector = document.querySelector(selector)) == null ? void 0 : _document_querySelector.setAttribute("dir", value);
2961
+ (_document_querySelector = document.querySelector(selector)) == null ? void 0 : _document_querySelector.setAttribute('dir', value);
2949
2962
  } else {
2950
2963
  var _document_querySelector1;
2951
- (_document_querySelector1 = document.querySelector(selector)) == null ? void 0 : _document_querySelector1.removeAttribute("dir");
2964
+ (_document_querySelector1 = document.querySelector(selector)) == null ? void 0 : _document_querySelector1.removeAttribute('dir');
2952
2965
  }
2953
2966
  setValue(value);
2954
2967
  };
@@ -2966,7 +2979,7 @@ const useTextSelection = ()=>{
2966
2979
  // this is because `document.getSelection` will always return the same object
2967
2980
  forceUpdate();
2968
2981
  };
2969
- useEventListener("selectionchange", handleSelectionChange, ()=>document);
2982
+ useEventListener('selectionchange', handleSelectionChange, ()=>document);
2970
2983
  React.useEffect(()=>{
2971
2984
  setSelection(document.getSelection());
2972
2985
  }, []);
@@ -3046,7 +3059,9 @@ const useTitle = (title)=>{
3046
3059
  ]);
3047
3060
  };
3048
3061
 
3049
- const toggleReducer = (state, nextValue)=>typeof nextValue === "boolean" ? nextValue : !state;
3062
+ function toggleReducer(state, nextValue) {
3063
+ return typeof nextValue === 'boolean' ? nextValue : !state;
3064
+ }
3050
3065
  const useToggle = (initialValue)=>{
3051
3066
  return React.useReducer(toggleReducer, initialValue);
3052
3067
  };
@@ -3083,7 +3098,7 @@ function _async_to_generator$1(fn) {
3083
3098
  };
3084
3099
  }
3085
3100
  const useWebNotification = (requestPermissions = false)=>{
3086
- const isSupported = useSupported(()=>!!window && "Notification" in window);
3101
+ const isSupported = useSupported(()=>!!window && 'Notification' in window);
3087
3102
  const permissionGranted = React.useRef(false);
3088
3103
  const notificationRef = React.useRef(null);
3089
3104
  const show = (title, options = defaultOptions$1)=>{
@@ -3092,7 +3107,7 @@ const useWebNotification = (requestPermissions = false)=>{
3092
3107
  if (!isSupported && !permissionGranted.current) {
3093
3108
  return;
3094
3109
  }
3095
- notificationRef.current = new Notification(title || "", options);
3110
+ notificationRef.current = new Notification(title || '', options);
3096
3111
  return notificationRef.current;
3097
3112
  };
3098
3113
  const close = React.useCallback(()=>{
@@ -3102,15 +3117,15 @@ const useWebNotification = (requestPermissions = false)=>{
3102
3117
  notificationRef.current = null;
3103
3118
  }, []);
3104
3119
  React.useEffect(()=>{
3105
- permissionGranted.current = isSupported && "permission" in Notification && Notification.permission === "granted";
3120
+ permissionGranted.current = isSupported && 'permission' in Notification && Notification.permission === 'granted';
3106
3121
  }, [
3107
3122
  isSupported
3108
3123
  ]);
3109
3124
  const ensurePermissions = React.useCallback(/*#__PURE__*/ _async_to_generator$1(function*() {
3110
3125
  if (!isSupported) return;
3111
- if (!permissionGranted.current && Notification.permission !== "denied") {
3126
+ if (!permissionGranted.current && Notification.permission !== 'denied') {
3112
3127
  const result = yield Notification.requestPermission();
3113
- if (result === "granted") permissionGranted.current = true;
3128
+ if (result === 'granted') permissionGranted.current = true;
3114
3129
  }
3115
3130
  return permissionGranted.current;
3116
3131
  }), [
@@ -3134,25 +3149,25 @@ const useWebNotification = (requestPermissions = false)=>{
3134
3149
  };
3135
3150
  };
3136
3151
 
3137
- const useWindowsFocus = (defauleValue = false)=>{
3152
+ function useWindowsFocus(defauleValue = false) {
3138
3153
  const [focused, setFocused] = React.useState(defauleValue);
3139
3154
  React.useEffect(()=>{
3140
3155
  setFocused(window.document.hasFocus());
3141
3156
  }, []);
3142
- useEventListener("blur", ()=>{
3157
+ useEventListener('blur', ()=>{
3143
3158
  setFocused(false);
3144
3159
  });
3145
- useEventListener("focus", ()=>{
3160
+ useEventListener('focus', ()=>{
3146
3161
  setFocused(true);
3147
3162
  });
3148
3163
  return focused;
3149
- };
3164
+ }
3150
3165
 
3151
3166
  const listenerOptions = {
3152
3167
  capture: false,
3153
3168
  passive: true
3154
3169
  };
3155
- const useWindowScroll = ()=>{
3170
+ function useWindowScroll() {
3156
3171
  const [state, setState] = useRafState(()=>({
3157
3172
  x: 0,
3158
3173
  y: 0
@@ -3163,20 +3178,20 @@ const useWindowScroll = ()=>{
3163
3178
  y: window.scrollY
3164
3179
  });
3165
3180
  };
3166
- useEventListener("scroll", handleScroll, defaultWindow, listenerOptions);
3181
+ useEventListener('scroll', handleScroll, defaultWindow, listenerOptions);
3167
3182
  // Set scroll at the first client-side load
3168
3183
  useIsomorphicLayoutEffect(()=>{
3169
3184
  handleScroll();
3170
3185
  }, []);
3171
3186
  return state;
3172
- };
3187
+ }
3173
3188
 
3174
- const subscribe = (callback)=>{
3175
- window.addEventListener("resize", callback);
3189
+ function subscribe(callback) {
3190
+ window.addEventListener('resize', callback);
3176
3191
  return ()=>{
3177
- window.removeEventListener("resize", callback);
3192
+ window.removeEventListener('resize', callback);
3178
3193
  };
3179
- };
3194
+ }
3180
3195
  const useWindowSize = ()=>{
3181
3196
  const stateDependencies = React.useRef({}).current;
3182
3197
  const previous = React.useRef({
@@ -3247,14 +3262,14 @@ function _async_to_generator(fn) {
3247
3262
  };
3248
3263
  }
3249
3264
  const useClipboard = ()=>{
3250
- const [text, setText] = React.useState("");
3265
+ const [text, setText] = React.useState('');
3251
3266
  const updateText = React.useCallback(()=>{
3252
3267
  window.navigator.clipboard.readText().then((value)=>{
3253
3268
  setText(value);
3254
3269
  });
3255
3270
  }, []);
3256
- useEventListener("copy", updateText);
3257
- useEventListener("cut", updateText);
3271
+ useEventListener('copy', updateText);
3272
+ useEventListener('cut', updateText);
3258
3273
  const copy = React.useCallback(/*#__PURE__*/ _async_to_generator(function*(txt) {
3259
3274
  setText(txt);
3260
3275
  yield window.navigator.clipboard.writeText(txt);
@@ -3265,24 +3280,24 @@ const useClipboard = ()=>{
3265
3280
  ];
3266
3281
  };
3267
3282
 
3268
- const getPlatform = (userAgent)=>{
3283
+ function getPlatform(userAgent) {
3269
3284
  if (/iPad|iPhone|iPod|ios/i.test(userAgent)) {
3270
- return "ios";
3285
+ return 'ios';
3271
3286
  } else if (/android/i.test(userAgent)) {
3272
- return "android";
3287
+ return 'android';
3273
3288
  } else {
3274
- return "unknown";
3289
+ return 'unknown';
3275
3290
  }
3276
- };
3291
+ }
3277
3292
  const usePlatform = ({ userAgent } = {
3278
- userAgent: ""
3293
+ userAgent: ''
3279
3294
  })=>{
3280
- const [ua, setUa] = React.useState(userAgent || "");
3295
+ const [ua, setUa] = React.useState(userAgent || '');
3281
3296
  const [platform, setPlatform] = React.useState(()=>{
3282
3297
  if (userAgent) {
3283
3298
  return getPlatform(userAgent);
3284
3299
  }
3285
- return "unknown";
3300
+ return 'unknown';
3286
3301
  });
3287
3302
  React.useEffect(()=>{
3288
3303
  setPlatform(getPlatform(navigator.userAgent));
@@ -3311,18 +3326,18 @@ const usePlatform = ({ userAgent } = {
3311
3326
  };
3312
3327
  };
3313
3328
 
3314
- const useMobileLandscape = ()=>{
3329
+ function useMobileLandscape() {
3315
3330
  const [isMobileLandscape, setIsMobileLandscape] = React.useState(false);
3316
3331
  const [orientation] = useOrientation();
3317
3332
  React.useEffect(()=>{
3318
3333
  const userAgent = window.navigator.userAgent;
3319
3334
  const isMobile = /Mobi|Android|iphone/i.test(userAgent);
3320
- setIsMobileLandscape(isMobile && orientation.type === "landscape-primary");
3335
+ setIsMobileLandscape(isMobile && orientation.type === 'landscape-primary');
3321
3336
  }, [
3322
3337
  orientation.type
3323
3338
  ]);
3324
3339
  return isMobileLandscape;
3325
- };
3340
+ }
3326
3341
 
3327
3342
  const useControlled = (value, defaultValue, onChange)=>{
3328
3343
  const [stateValue, setStateValue] = React.useState(value !== undefined ? value : defaultValue);
@@ -3343,7 +3358,7 @@ const useControlled = (value, defaultValue, onChange)=>{
3343
3358
  ];
3344
3359
  };
3345
3360
 
3346
- const useDisclosure = (props = {})=>{
3361
+ function useDisclosure(props = {}) {
3347
3362
  const { defaultOpen, isOpen: isOpenProp, onClose: onCloseProp, onOpen: onOpenProp, onChange = ()=>{} } = props;
3348
3363
  const onOpenPropRef = useLatest(onOpenProp);
3349
3364
  const onClosePropRef = useLatest(onCloseProp);
@@ -3384,12 +3399,12 @@ const useDisclosure = (props = {})=>{
3384
3399
  onOpenChange,
3385
3400
  isControlled
3386
3401
  };
3387
- };
3402
+ }
3388
3403
 
3389
3404
  const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3390
3405
  const [data, setData] = React.useState(null);
3391
3406
  const [error, setError] = React.useState(null);
3392
- const [status, setStatus] = React.useState("DISCONNECTED");
3407
+ const [status, setStatus] = React.useState('DISCONNECTED');
3393
3408
  const [event, setEvent] = React.useState(null);
3394
3409
  const [lastEventId, setLastEventId] = React.useState(null);
3395
3410
  const retries = React.useRef(0);
@@ -3411,7 +3426,7 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3411
3426
  });
3412
3427
  const close = React.useCallback(()=>{
3413
3428
  var _eventSourceRef_current;
3414
- setStatus("DISCONNECTED");
3429
+ setStatus('DISCONNECTED');
3415
3430
  clean();
3416
3431
  (_eventSourceRef_current = eventSourceRef.current) == null ? void 0 : _eventSourceRef_current.close();
3417
3432
  eventSourceRef.current = null;
@@ -3430,21 +3445,21 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3430
3445
  }
3431
3446
  const es = eventSourceRef.current;
3432
3447
  es.onopen = ()=>{
3433
- setStatus("CONNECTED");
3448
+ setStatus('CONNECTED');
3434
3449
  setError(null);
3435
3450
  };
3436
3451
  es.onmessage = (ev)=>{
3437
3452
  setData(ev.data);
3438
3453
  setLastEventId(ev.lastEventId);
3439
- setStatus("CONNECTED");
3454
+ setStatus('CONNECTED');
3440
3455
  };
3441
3456
  es.onerror = (err)=>{
3442
3457
  setError(err);
3443
- setStatus("DISCONNECTED");
3458
+ setStatus('DISCONNECTED');
3444
3459
  if (options.autoReconnect && !explicitlyClosed.current) {
3445
3460
  const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3446
3461
  retries.current += 1;
3447
- if (typeof maxRetries === "number" && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === "function" && maxRetries()) {
3462
+ if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3448
3463
  setTimeout(open, delay);
3449
3464
  } else {
3450
3465
  onFailed == null ? void 0 : onFailed();
@@ -3487,10 +3502,34 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3487
3502
  };
3488
3503
  };
3489
3504
 
3505
+ /**
3506
+ * @description copy from swr
3507
+ */ const use = React__default.default.use || ((thenable)=>{
3508
+ switch(thenable.status){
3509
+ case 'pending':
3510
+ throw thenable;
3511
+ case 'fulfilled':
3512
+ return thenable.value;
3513
+ case 'rejected':
3514
+ throw thenable.reason;
3515
+ default:
3516
+ thenable.status = 'pending';
3517
+ thenable.then((v)=>{
3518
+ thenable.status = 'fulfilled';
3519
+ thenable.value = v;
3520
+ }, (e)=>{
3521
+ thenable.status = 'rejected';
3522
+ thenable.reason = e;
3523
+ });
3524
+ throw thenable;
3525
+ }
3526
+ });
3527
+
3490
3528
  exports.assignRef = indexClient.assignRef;
3491
3529
  exports.mergeRefs = indexClient.mergeRefs;
3492
3530
  exports.useMergedRefs = indexClient.useMergedRefs;
3493
3531
  exports.defaultOptions = defaultOptions;
3532
+ exports.use = use;
3494
3533
  exports.useActiveElement = useActiveElement;
3495
3534
  exports.useAsyncEffect = useAsyncEffect;
3496
3535
  exports.useClickOutside = useClickOutside;