abrplus-ui-kit 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +159 -0
  2. package/dist/antOverrides.cjs.js +127 -0
  3. package/dist/antOverrides.es.js +127 -0
  4. package/dist/atoms.cjs.js +391 -0
  5. package/dist/atoms.es.js +392 -0
  6. package/dist/colors-CztsZ6e_.js +2213 -0
  7. package/dist/colors-TPZkyKI4.cjs +2212 -0
  8. package/dist/deepMerge-CG1he8ZD.js +20 -0
  9. package/dist/deepMerge-Cn27K7-s.cjs +19 -0
  10. package/dist/index-2Q5IExhU.cjs +89 -0
  11. package/dist/index-BOfdgXvN.cjs +265 -0
  12. package/dist/index-BnnlMHRY.cjs +27 -0
  13. package/dist/index-BzahloOb.js +28 -0
  14. package/dist/index-C24zbKLS.js +350 -0
  15. package/dist/index-CCvWoynu.cjs +12 -0
  16. package/dist/index-CQKRmQkW.js +543 -0
  17. package/dist/index-CW9vyiq6.cjs +349 -0
  18. package/dist/index-D8BknfUe.js +266 -0
  19. package/dist/index-DCP3xelB.cjs +1629 -0
  20. package/dist/index-DCojd1ld.js +90 -0
  21. package/dist/index-DLUd_0LP.js +13 -0
  22. package/dist/index-WgcaHHjH.js +1630 -0
  23. package/dist/index-keKfh9ZW.cjs +542 -0
  24. package/dist/index.cjs.js +109 -0
  25. package/dist/index.css +1519 -0
  26. package/dist/index.es.js +109 -0
  27. package/dist/index2.css +3 -0
  28. package/dist/molecules.cjs.js +7823 -0
  29. package/dist/molecules.es.js +7825 -0
  30. package/dist/organisms.cjs.js +940 -0
  31. package/dist/organisms.es.js +940 -0
  32. package/dist/provider.cjs.js +48 -0
  33. package/dist/provider.es.js +48 -0
  34. package/dist/sortable.esm-CwrpjqII.cjs +3872 -0
  35. package/dist/sortable.esm-DfJu5xWT.js +3873 -0
  36. package/dist/theme.css +102 -0
  37. package/dist/types/antOverrides.d.ts +2 -0
  38. package/dist/types/assets/fonts/icomoon/selection.json.d.ts +3 -0
  39. package/dist/types/atoms.d.ts +2 -0
  40. package/dist/types/components/antOverrides/alert/index.d.ts +2 -0
  41. package/dist/types/components/antOverrides/avatar/index.d.ts +15 -0
  42. package/dist/types/components/antOverrides/breadcrumb/index.d.ts +4 -0
  43. package/dist/types/components/antOverrides/dropdown/index.d.ts +4 -0
  44. package/dist/types/components/antOverrides/flex/index.d.ts +4 -0
  45. package/dist/types/components/antOverrides/image/index.d.ts +7 -0
  46. package/dist/types/components/antOverrides/index.d.ts +18 -0
  47. package/dist/types/components/antOverrides/infiniteLoader/index.d.ts +12 -0
  48. package/dist/types/components/antOverrides/loading/index.d.ts +14 -0
  49. package/dist/types/components/antOverrides/menu/index.d.ts +8 -0
  50. package/dist/types/components/antOverrides/pagination/index.d.ts +3 -0
  51. package/dist/types/components/antOverrides/progress/index.d.ts +3 -0
  52. package/dist/types/components/antOverrides/segmented/index.d.ts +4 -0
  53. package/dist/types/components/antOverrides/skeleton/index.d.ts +10 -0
  54. package/dist/types/components/antOverrides/slider/index.d.ts +5 -0
  55. package/dist/types/components/antOverrides/steps/index.d.ts +11 -0
  56. package/dist/types/components/antOverrides/switch/index.d.ts +3 -0
  57. package/dist/types/components/antOverrides/text/index.d.ts +31 -0
  58. package/dist/types/components/antOverrides/timeline/index.d.ts +4 -0
  59. package/dist/types/components/antOverrides/tooltip/index.d.ts +8 -0
  60. package/dist/types/components/antOverrides/upload/index.d.ts +7 -0
  61. package/dist/types/components/atoms/badge/index.d.ts +3 -0
  62. package/dist/types/components/atoms/behavioralAtoms/index.d.ts +2 -0
  63. package/dist/types/components/atoms/behavioralAtoms/portalContainer/index.d.ts +7 -0
  64. package/dist/types/components/atoms/behavioralAtoms/render/index.d.ts +14 -0
  65. package/dist/types/components/atoms/borderedTitle/index.d.ts +9 -0
  66. package/dist/types/components/atoms/box/index.d.ts +7 -0
  67. package/dist/types/components/atoms/breadcrumbs/index.d.ts +5 -0
  68. package/dist/types/components/atoms/card/index.d.ts +5 -0
  69. package/dist/types/components/atoms/checkbox/index.d.ts +7 -0
  70. package/dist/types/components/atoms/clickAwayListener/index.d.ts +11 -0
  71. package/dist/types/components/atoms/collapse/index.d.ts +6 -0
  72. package/dist/types/components/atoms/datePicker/index.d.ts +16 -0
  73. package/dist/types/components/atoms/empty/index.d.ts +5 -0
  74. package/dist/types/components/atoms/fallback/index.d.ts +4 -0
  75. package/dist/types/components/atoms/horizontalLine/index.d.ts +9 -0
  76. package/dist/types/components/atoms/icon/constants/iconNames.d.ts +1 -0
  77. package/dist/types/components/atoms/icon/constants/iconsContent.d.ts +808 -0
  78. package/dist/types/components/atoms/icon/iconPack/index.d.ts +2 -0
  79. package/dist/types/components/atoms/icon/index.d.ts +26 -0
  80. package/dist/types/components/atoms/index.d.ts +24 -0
  81. package/dist/types/components/atoms/navigationTabs/index.d.ts +35 -0
  82. package/dist/types/components/atoms/popover/index.d.ts +14 -0
  83. package/dist/types/components/atoms/popover/link.d.ts +6 -0
  84. package/dist/types/components/atoms/radio/index.d.ts +7 -0
  85. package/dist/types/components/atoms/rangePicker/index.d.ts +14 -0
  86. package/dist/types/components/atoms/separator/index.d.ts +5 -0
  87. package/dist/types/components/atoms/tab/index.d.ts +9 -0
  88. package/dist/types/components/atoms/tooltip/index.d.ts +7 -0
  89. package/dist/types/components/atoms/tooltip/titleTooltip.d.ts +5 -0
  90. package/dist/types/components/atoms/upload/index.d.ts +11 -0
  91. package/dist/types/components/atoms/verticalLine/index.d.ts +7 -0
  92. package/dist/types/components/atoms/view/helper.d.ts +20 -0
  93. package/dist/types/components/atoms/view/index.d.ts +26 -0
  94. package/dist/types/components/index.d.ts +4 -0
  95. package/dist/types/components/molecules/accordion/index.d.ts +20 -0
  96. package/dist/types/components/molecules/actionHeader/index.d.ts +11 -0
  97. package/dist/types/components/molecules/audioVisualizer/index.d.ts +15 -0
  98. package/dist/types/components/molecules/avatarUpload/index.d.ts +15 -0
  99. package/dist/types/components/molecules/button/action/index.d.ts +5 -0
  100. package/dist/types/components/molecules/button/icon/index.d.ts +11 -0
  101. package/dist/types/components/molecules/button/index.d.ts +18 -0
  102. package/dist/types/components/molecules/button/negative/index.d.ts +5 -0
  103. package/dist/types/components/molecules/button/primary/index.d.ts +3 -0
  104. package/dist/types/components/molecules/button/secondary/index.d.ts +3 -0
  105. package/dist/types/components/molecules/button/secondaryQuiet/index.d.ts +3 -0
  106. package/dist/types/components/molecules/button/shared.d.ts +23 -0
  107. package/dist/types/components/molecules/button/tertiary/index.d.ts +3 -0
  108. package/dist/types/components/molecules/button/text/index.d.ts +10 -0
  109. package/dist/types/components/molecules/catch/index.d.ts +9 -0
  110. package/dist/types/components/molecules/chevronIcon/index.d.ts +6 -0
  111. package/dist/types/components/molecules/copyButton/index.d.ts +8 -0
  112. package/dist/types/components/molecules/index.d.ts +24 -0
  113. package/dist/types/components/molecules/input/TextArea/index.d.ts +25 -0
  114. package/dist/types/components/molecules/input/default/index.d.ts +23 -0
  115. package/dist/types/components/molecules/input/emojiPicker/index.d.ts +21 -0
  116. package/dist/types/components/molecules/input/ghost/index.d.ts +25 -0
  117. package/dist/types/components/molecules/input/index.d.ts +19 -0
  118. package/dist/types/components/molecules/input/number/index.d.ts +28 -0
  119. package/dist/types/components/molecules/input/search/index.d.ts +7 -0
  120. package/dist/types/components/molecules/input/tag/index.d.ts +13 -0
  121. package/dist/types/components/molecules/inputDatePicker/index.d.ts +17 -0
  122. package/dist/types/components/molecules/inputErrorMessage/index.d.ts +9 -0
  123. package/dist/types/components/molecules/inputRangePicker/index.d.ts +16 -0
  124. package/dist/types/components/molecules/logo/index.d.ts +25 -0
  125. package/dist/types/components/molecules/noResult/index.d.ts +8 -0
  126. package/dist/types/components/molecules/notification/index.d.ts +13 -0
  127. package/dist/types/components/molecules/select/components/clearIcon.d.ts +2 -0
  128. package/dist/types/components/molecules/select/components/index.d.ts +5 -0
  129. package/dist/types/components/molecules/select/components/label.d.ts +6 -0
  130. package/dist/types/components/molecules/select/components/notFound.d.ts +5 -0
  131. package/dist/types/components/molecules/select/components/placeholder.d.ts +7 -0
  132. package/dist/types/components/molecules/select/components/suffix.d.ts +10 -0
  133. package/dist/types/components/molecules/select/index.d.ts +13 -0
  134. package/dist/types/components/molecules/select/multiple/index.d.ts +5 -0
  135. package/dist/types/components/molecules/select/single/index.d.ts +5 -0
  136. package/dist/types/components/molecules/select/style.d.ts +8 -0
  137. package/dist/types/components/molecules/select/treeSelect/index.d.ts +2 -0
  138. package/dist/types/components/molecules/select/types.d.ts +108 -0
  139. package/dist/types/components/molecules/sortableList/index.d.ts +19 -0
  140. package/dist/types/components/molecules/spliter/index.d.ts +8 -0
  141. package/dist/types/components/molecules/tag/index.d.ts +17 -0
  142. package/dist/types/components/molecules/tagCollectionView/index.d.ts +14 -0
  143. package/dist/types/components/molecules/tagInput/components/notFoundAddItem.d.ts +4 -0
  144. package/dist/types/components/molecules/tagInput/index.d.ts +6 -0
  145. package/dist/types/components/molecules/tagInput/style.d.ts +9 -0
  146. package/dist/types/components/molecules/tagInput/types.d.ts +66 -0
  147. package/dist/types/components/molecules/timePicker/index.d.ts +6 -0
  148. package/dist/types/components/molecules/titleBox/index.d.ts +8 -0
  149. package/dist/types/components/molecules/titleBox/status.d.ts +5 -0
  150. package/dist/types/components/molecules/titleBox/title.d.ts +7 -0
  151. package/dist/types/components/molecules/tree/index.d.ts +29 -0
  152. package/dist/types/components/molecules/tree/searchBar/index.d.ts +7 -0
  153. package/dist/types/components/molecules/verticalTabs/index.d.ts +19 -0
  154. package/dist/types/components/organisms/avatarGroup/index.d.ts +25 -0
  155. package/dist/types/components/organisms/drawer/components/footer.d.ts +3 -0
  156. package/dist/types/components/organisms/drawer/components/headerTitle.d.ts +8 -0
  157. package/dist/types/components/organisms/drawer/index.d.ts +24 -0
  158. package/dist/types/components/organisms/index.d.ts +4 -0
  159. package/dist/types/components/organisms/modal/base.d.ts +6 -0
  160. package/dist/types/components/organisms/modal/confirm.d.ts +6 -0
  161. package/dist/types/components/organisms/modal/delete.d.ts +4 -0
  162. package/dist/types/components/organisms/modal/error.d.ts +4 -0
  163. package/dist/types/components/organisms/modal/index.d.ts +14 -0
  164. package/dist/types/components/organisms/modal/info.d.ts +4 -0
  165. package/dist/types/components/organisms/modal/type.d.ts +11 -0
  166. package/dist/types/components/organisms/table/column.d.ts +20 -0
  167. package/dist/types/components/organisms/table/components/cell/currencyCell.d.ts +7 -0
  168. package/dist/types/components/organisms/table/components/cell/dateCell.d.ts +6 -0
  169. package/dist/types/components/organisms/table/components/cell/index.d.ts +10 -0
  170. package/dist/types/components/organisms/table/components/cell/status.d.ts +8 -0
  171. package/dist/types/components/organisms/table/components/expandIcon.d.ts +7 -0
  172. package/dist/types/components/organisms/table/components/headerTitle.d.ts +10 -0
  173. package/dist/types/components/organisms/table/config.d.ts +8 -0
  174. package/dist/types/components/organisms/table/dndSort/context.d.ts +6 -0
  175. package/dist/types/components/organisms/table/dndSort/dragHandle.d.ts +1 -0
  176. package/dist/types/components/organisms/table/dndSort/index.d.ts +3 -0
  177. package/dist/types/components/organisms/table/dndSort/provider.d.ts +10 -0
  178. package/dist/types/components/organisms/table/dndSort/row.d.ts +6 -0
  179. package/dist/types/components/organisms/table/index.d.ts +30 -0
  180. package/dist/types/components/organisms/table/pagination/components.d.ts +18 -0
  181. package/dist/types/components/organisms/table/pagination/usePagination.d.ts +22 -0
  182. package/dist/types/configs/constructors/AbrplusUIKit.d.ts +17 -0
  183. package/dist/types/configs/constructors/index.d.ts +1 -0
  184. package/dist/types/configs/index.d.ts +6 -0
  185. package/dist/types/configs/locales/en.d.ts +1030 -0
  186. package/dist/types/configs/locales/fa.d.ts +1031 -0
  187. package/dist/types/configs/locales/i18nextTFunction.d.ts +5 -0
  188. package/dist/types/configs/locales/index.d.ts +10 -0
  189. package/dist/types/configs/providers/AbrplusUIKitProvider.d.ts +11 -0
  190. package/dist/types/configs/providers/index.d.ts +1 -0
  191. package/dist/types/configs/tailwindcss/index.d.ts +103 -0
  192. package/dist/types/configs/theme/colors.d.ts +114 -0
  193. package/dist/types/configs/theme/index.d.ts +1 -0
  194. package/dist/types/configs/types/index.d.ts +98 -0
  195. package/dist/types/constants/chartColors.d.ts +1 -0
  196. package/dist/types/constants/datepickerColors.d.ts +2 -0
  197. package/dist/types/constants/dimantions.d.ts +12 -0
  198. package/dist/types/constants/enum.d.ts +5 -0
  199. package/dist/types/constants/index.d.ts +3 -0
  200. package/dist/types/constants/variables.d.ts +2 -0
  201. package/dist/types/hooks/index.d.ts +6 -0
  202. package/dist/types/hooks/useAntConfig.d.ts +24 -0
  203. package/dist/types/hooks/useDebounce.d.ts +1 -0
  204. package/dist/types/hooks/useInteractions.d.ts +15 -0
  205. package/dist/types/hooks/useLocalStorageState.d.ts +3 -0
  206. package/dist/types/hooks/useObserveWindow.d.ts +9 -0
  207. package/dist/types/hooks/useWindowDimensions.d.ts +16 -0
  208. package/dist/types/index.d.ts +2 -0
  209. package/dist/types/main.d.ts +3 -0
  210. package/dist/types/molecules.d.ts +2 -0
  211. package/dist/types/organisms.d.ts +2 -0
  212. package/dist/types/provider.d.ts +2 -0
  213. package/dist/types/theme.d.ts +1 -0
  214. package/dist/types/utilities/batch.d.ts +9 -0
  215. package/dist/types/utilities/createIcomoonIconSet.d.ts +9 -0
  216. package/dist/types/utilities/deepMerge.d.ts +1 -0
  217. package/dist/types/utilities/getErrorMessage.d.ts +1 -0
  218. package/dist/types/utilities/index.d.ts +7 -0
  219. package/dist/types/utilities/isPersian.d.ts +1 -0
  220. package/dist/types/utilities/mmss.d.ts +1 -0
  221. package/dist/types/utilities/testUtils/index.d.ts +3 -0
  222. package/dist/types/utilities/testUtils/withReactQuery.d.ts +2 -0
  223. package/dist/types/utilities/testUtils/withReactRouter.d.ts +2 -0
  224. package/package.json +195 -0
@@ -0,0 +1,3872 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const React = require("react");
4
+ const tailwindMerge = require("tailwind-merge");
5
+ const index = require("./index-keKfh9ZW.cjs");
6
+ const index$1 = require("./index-CW9vyiq6.cjs");
7
+ const index$2 = require("./index-CCvWoynu.cjs");
8
+ const require$$2 = require("react-dom");
9
+ class InternalRequestError extends Error {
10
+ constructor(message, status, response) {
11
+ super(message);
12
+ this.message = message;
13
+ this.status = status;
14
+ this.response = response;
15
+ }
16
+ isApiException = true;
17
+ static isRequestError(error) {
18
+ return error.isApiException;
19
+ }
20
+ }
21
+ var LogoIconNameType = /* @__PURE__ */ ((LogoIconNameType2) => {
22
+ LogoIconNameType2["User"] = "User";
23
+ LogoIconNameType2["SecurityGroup"] = "SecurityGroup";
24
+ LogoIconNameType2["Department"] = "Department";
25
+ LogoIconNameType2["Office"] = "Office";
26
+ LogoIconNameType2["Position"] = "Position";
27
+ LogoIconNameType2["SecurityCustomer"] = "SecurityCustomer";
28
+ LogoIconNameType2["SecurityAgent"] = "SecurityAgent";
29
+ LogoIconNameType2["SecurityOperator"] = "SecurityOperator";
30
+ return LogoIconNameType2;
31
+ })(LogoIconNameType || {});
32
+ const icon = {
33
+ User: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User" }),
34
+ SecurityGroup: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User_Group" }),
35
+ Position: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User" }),
36
+ Department: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User" }),
37
+ Office: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User" }),
38
+ SecurityAgent: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User" }),
39
+ SecurityCustomer: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User" }),
40
+ SecurityOperator: /* @__PURE__ */ jsxRuntime.jsx(index$1.Icon, { name: "User" })
41
+ };
42
+ const Logo = ({
43
+ style,
44
+ shape,
45
+ className,
46
+ toolTipTitle,
47
+ imageSrc,
48
+ iconName,
49
+ badgeStatus = "default",
50
+ badgePosition = "left",
51
+ badgeColor,
52
+ badged,
53
+ hasAnimation = false,
54
+ iconSize = 24,
55
+ isFullSizeLogo = false,
56
+ onClick,
57
+ ...rest
58
+ }) => {
59
+ const badgeColorStatus = {
60
+ default: "bg-onsurface-disabled",
61
+ error: "bg-negative",
62
+ success: "bg-primary",
63
+ warn: "bg-warn"
64
+ };
65
+ const Wrapper = rest.hasToolTip && toolTipTitle ? ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(
66
+ index.Tooltip,
67
+ {
68
+ className: tailwindMerge.twMerge(!rest.hasToolTip && "pointer-events-none"),
69
+ variant: "default",
70
+ title: toolTipTitle,
71
+ placement: "top",
72
+ ...rest.tooltipProps,
73
+ children
74
+ }
75
+ ) : React.Fragment;
76
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { children: /* @__PURE__ */ jsxRuntime.jsxs(
77
+ index$1.Flex,
78
+ {
79
+ onClick,
80
+ className: tailwindMerge.twMerge(isFullSizeLogo && "!h-full !w-full", "relative"),
81
+ children: [
82
+ /* @__PURE__ */ jsxRuntime.jsx(
83
+ index$2.Avatar,
84
+ {
85
+ shape: shape || "circle",
86
+ style,
87
+ size: iconSize,
88
+ className: tailwindMerge.twMerge(
89
+ hasAnimation && "border-2 transition-all hover:z-50 hover:scale-125 hover:border-black/60",
90
+ className
91
+ ),
92
+ ...imageSrc ? { src: imageSrc } : {
93
+ icon: icon[iconName ?? LogoIconNameType.User],
94
+ className: tailwindMerge.twMerge(isFullSizeLogo && "!w-full !h-full")
95
+ }
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsxRuntime.jsx(index$1.Render, { when: badged, children: /* @__PURE__ */ jsxRuntime.jsx(
99
+ "div",
100
+ {
101
+ style: { backgroundColor: badgeColor },
102
+ className: tailwindMerge.twMerge(
103
+ "outline-surface absolute bottom-0 h-2 w-2 rounded-full outline outline-1",
104
+ badgePosition === "left" ? "left-0" : "right-0",
105
+ badgeColorStatus[badgeStatus]
106
+ )
107
+ }
108
+ ) })
109
+ ]
110
+ }
111
+ ) }) });
112
+ };
113
+ function useCombinedRefs() {
114
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
115
+ refs[_key] = arguments[_key];
116
+ }
117
+ return React.useMemo(
118
+ () => (node) => {
119
+ refs.forEach((ref) => ref(node));
120
+ },
121
+ // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ refs
123
+ );
124
+ }
125
+ const canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
126
+ function isWindow(element) {
127
+ const elementString = Object.prototype.toString.call(element);
128
+ return elementString === "[object Window]" || // In Electron context the Window object serializes to [object global]
129
+ elementString === "[object global]";
130
+ }
131
+ function isNode(node) {
132
+ return "nodeType" in node;
133
+ }
134
+ function getWindow(target) {
135
+ var _target$ownerDocument, _target$ownerDocument2;
136
+ if (!target) {
137
+ return window;
138
+ }
139
+ if (isWindow(target)) {
140
+ return target;
141
+ }
142
+ if (!isNode(target)) {
143
+ return window;
144
+ }
145
+ return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window;
146
+ }
147
+ function isDocument(node) {
148
+ const {
149
+ Document
150
+ } = getWindow(node);
151
+ return node instanceof Document;
152
+ }
153
+ function isHTMLElement(node) {
154
+ if (isWindow(node)) {
155
+ return false;
156
+ }
157
+ return node instanceof getWindow(node).HTMLElement;
158
+ }
159
+ function isSVGElement(node) {
160
+ return node instanceof getWindow(node).SVGElement;
161
+ }
162
+ function getOwnerDocument(target) {
163
+ if (!target) {
164
+ return document;
165
+ }
166
+ if (isWindow(target)) {
167
+ return target.document;
168
+ }
169
+ if (!isNode(target)) {
170
+ return document;
171
+ }
172
+ if (isDocument(target)) {
173
+ return target;
174
+ }
175
+ if (isHTMLElement(target) || isSVGElement(target)) {
176
+ return target.ownerDocument;
177
+ }
178
+ return document;
179
+ }
180
+ const useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect;
181
+ function useEvent(handler) {
182
+ const handlerRef = React.useRef(handler);
183
+ useIsomorphicLayoutEffect(() => {
184
+ handlerRef.current = handler;
185
+ });
186
+ return React.useCallback(function() {
187
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
188
+ args[_key] = arguments[_key];
189
+ }
190
+ return handlerRef.current == null ? void 0 : handlerRef.current(...args);
191
+ }, []);
192
+ }
193
+ function useInterval() {
194
+ const intervalRef = React.useRef(null);
195
+ const set = React.useCallback((listener, duration) => {
196
+ intervalRef.current = setInterval(listener, duration);
197
+ }, []);
198
+ const clear = React.useCallback(() => {
199
+ if (intervalRef.current !== null) {
200
+ clearInterval(intervalRef.current);
201
+ intervalRef.current = null;
202
+ }
203
+ }, []);
204
+ return [set, clear];
205
+ }
206
+ function useLatestValue(value, dependencies) {
207
+ if (dependencies === void 0) {
208
+ dependencies = [value];
209
+ }
210
+ const valueRef = React.useRef(value);
211
+ useIsomorphicLayoutEffect(() => {
212
+ if (valueRef.current !== value) {
213
+ valueRef.current = value;
214
+ }
215
+ }, dependencies);
216
+ return valueRef;
217
+ }
218
+ function useLazyMemo(callback, dependencies) {
219
+ const valueRef = React.useRef();
220
+ return React.useMemo(
221
+ () => {
222
+ const newValue = callback(valueRef.current);
223
+ valueRef.current = newValue;
224
+ return newValue;
225
+ },
226
+ // eslint-disable-next-line react-hooks/exhaustive-deps
227
+ [...dependencies]
228
+ );
229
+ }
230
+ function useNodeRef(onChange) {
231
+ const onChangeHandler = useEvent(onChange);
232
+ const node = React.useRef(null);
233
+ const setNodeRef = React.useCallback(
234
+ (element) => {
235
+ if (element !== node.current) {
236
+ onChangeHandler == null ? void 0 : onChangeHandler(element, node.current);
237
+ }
238
+ node.current = element;
239
+ },
240
+ //eslint-disable-next-line
241
+ []
242
+ );
243
+ return [node, setNodeRef];
244
+ }
245
+ function usePrevious(value) {
246
+ const ref = React.useRef();
247
+ React.useEffect(() => {
248
+ ref.current = value;
249
+ }, [value]);
250
+ return ref.current;
251
+ }
252
+ let ids = {};
253
+ function useUniqueId(prefix, value) {
254
+ return React.useMemo(() => {
255
+ if (value) {
256
+ return value;
257
+ }
258
+ const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
259
+ ids[prefix] = id;
260
+ return prefix + "-" + id;
261
+ }, [prefix, value]);
262
+ }
263
+ function createAdjustmentFn(modifier) {
264
+ return function(object) {
265
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
266
+ adjustments[_key - 1] = arguments[_key];
267
+ }
268
+ return adjustments.reduce((accumulator, adjustment) => {
269
+ const entries = Object.entries(adjustment);
270
+ for (const [key, valueAdjustment] of entries) {
271
+ const value = accumulator[key];
272
+ if (value != null) {
273
+ accumulator[key] = value + modifier * valueAdjustment;
274
+ }
275
+ }
276
+ return accumulator;
277
+ }, {
278
+ ...object
279
+ });
280
+ };
281
+ }
282
+ const add = /* @__PURE__ */ createAdjustmentFn(1);
283
+ const subtract = /* @__PURE__ */ createAdjustmentFn(-1);
284
+ function hasViewportRelativeCoordinates(event) {
285
+ return "clientX" in event && "clientY" in event;
286
+ }
287
+ function isKeyboardEvent(event) {
288
+ if (!event) {
289
+ return false;
290
+ }
291
+ const {
292
+ KeyboardEvent
293
+ } = getWindow(event.target);
294
+ return KeyboardEvent && event instanceof KeyboardEvent;
295
+ }
296
+ function isTouchEvent(event) {
297
+ if (!event) {
298
+ return false;
299
+ }
300
+ const {
301
+ TouchEvent
302
+ } = getWindow(event.target);
303
+ return TouchEvent && event instanceof TouchEvent;
304
+ }
305
+ function getEventCoordinates(event) {
306
+ if (isTouchEvent(event)) {
307
+ if (event.touches && event.touches.length) {
308
+ const {
309
+ clientX: x,
310
+ clientY: y
311
+ } = event.touches[0];
312
+ return {
313
+ x,
314
+ y
315
+ };
316
+ } else if (event.changedTouches && event.changedTouches.length) {
317
+ const {
318
+ clientX: x,
319
+ clientY: y
320
+ } = event.changedTouches[0];
321
+ return {
322
+ x,
323
+ y
324
+ };
325
+ }
326
+ }
327
+ if (hasViewportRelativeCoordinates(event)) {
328
+ return {
329
+ x: event.clientX,
330
+ y: event.clientY
331
+ };
332
+ }
333
+ return null;
334
+ }
335
+ const CSS = /* @__PURE__ */ Object.freeze({
336
+ Translate: {
337
+ toString(transform) {
338
+ if (!transform) {
339
+ return;
340
+ }
341
+ const {
342
+ x,
343
+ y
344
+ } = transform;
345
+ return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
346
+ }
347
+ },
348
+ Scale: {
349
+ toString(transform) {
350
+ if (!transform) {
351
+ return;
352
+ }
353
+ const {
354
+ scaleX,
355
+ scaleY
356
+ } = transform;
357
+ return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
358
+ }
359
+ },
360
+ Transform: {
361
+ toString(transform) {
362
+ if (!transform) {
363
+ return;
364
+ }
365
+ return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(" ");
366
+ }
367
+ },
368
+ Transition: {
369
+ toString(_ref) {
370
+ let {
371
+ property,
372
+ duration,
373
+ easing
374
+ } = _ref;
375
+ return property + " " + duration + "ms " + easing;
376
+ }
377
+ }
378
+ });
379
+ const SELECTOR = "a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";
380
+ function findFirstFocusableNode(element) {
381
+ if (element.matches(SELECTOR)) {
382
+ return element;
383
+ }
384
+ return element.querySelector(SELECTOR);
385
+ }
386
+ const hiddenStyles = {
387
+ display: "none"
388
+ };
389
+ function HiddenText(_ref) {
390
+ let {
391
+ id,
392
+ value
393
+ } = _ref;
394
+ return React.createElement("div", {
395
+ id,
396
+ style: hiddenStyles
397
+ }, value);
398
+ }
399
+ function LiveRegion(_ref) {
400
+ let {
401
+ id,
402
+ announcement,
403
+ ariaLiveType = "assertive"
404
+ } = _ref;
405
+ const visuallyHidden = {
406
+ position: "fixed",
407
+ top: 0,
408
+ left: 0,
409
+ width: 1,
410
+ height: 1,
411
+ margin: -1,
412
+ border: 0,
413
+ padding: 0,
414
+ overflow: "hidden",
415
+ clip: "rect(0 0 0 0)",
416
+ clipPath: "inset(100%)",
417
+ whiteSpace: "nowrap"
418
+ };
419
+ return React.createElement("div", {
420
+ id,
421
+ style: visuallyHidden,
422
+ role: "status",
423
+ "aria-live": ariaLiveType,
424
+ "aria-atomic": true
425
+ }, announcement);
426
+ }
427
+ function useAnnouncement() {
428
+ const [announcement, setAnnouncement] = React.useState("");
429
+ const announce = React.useCallback((value) => {
430
+ if (value != null) {
431
+ setAnnouncement(value);
432
+ }
433
+ }, []);
434
+ return {
435
+ announce,
436
+ announcement
437
+ };
438
+ }
439
+ const DndMonitorContext = /* @__PURE__ */ React.createContext(null);
440
+ function useDndMonitor(listener) {
441
+ const registerListener = React.useContext(DndMonitorContext);
442
+ React.useEffect(() => {
443
+ if (!registerListener) {
444
+ throw new Error("useDndMonitor must be used within a children of <DndContext>");
445
+ }
446
+ const unsubscribe = registerListener(listener);
447
+ return unsubscribe;
448
+ }, [listener, registerListener]);
449
+ }
450
+ function useDndMonitorProvider() {
451
+ const [listeners] = React.useState(() => /* @__PURE__ */ new Set());
452
+ const registerListener = React.useCallback((listener) => {
453
+ listeners.add(listener);
454
+ return () => listeners.delete(listener);
455
+ }, [listeners]);
456
+ const dispatch = React.useCallback((_ref) => {
457
+ let {
458
+ type,
459
+ event
460
+ } = _ref;
461
+ listeners.forEach((listener) => {
462
+ var _listener$type;
463
+ return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
464
+ });
465
+ }, [listeners]);
466
+ return [dispatch, registerListener];
467
+ }
468
+ const defaultScreenReaderInstructions = {
469
+ draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
470
+ };
471
+ const defaultAnnouncements = {
472
+ onDragStart(_ref) {
473
+ let {
474
+ active
475
+ } = _ref;
476
+ return "Picked up draggable item " + active.id + ".";
477
+ },
478
+ onDragOver(_ref2) {
479
+ let {
480
+ active,
481
+ over
482
+ } = _ref2;
483
+ if (over) {
484
+ return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
485
+ }
486
+ return "Draggable item " + active.id + " is no longer over a droppable area.";
487
+ },
488
+ onDragEnd(_ref3) {
489
+ let {
490
+ active,
491
+ over
492
+ } = _ref3;
493
+ if (over) {
494
+ return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
495
+ }
496
+ return "Draggable item " + active.id + " was dropped.";
497
+ },
498
+ onDragCancel(_ref4) {
499
+ let {
500
+ active
501
+ } = _ref4;
502
+ return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
503
+ }
504
+ };
505
+ function Accessibility(_ref) {
506
+ let {
507
+ announcements = defaultAnnouncements,
508
+ container,
509
+ hiddenTextDescribedById,
510
+ screenReaderInstructions = defaultScreenReaderInstructions
511
+ } = _ref;
512
+ const {
513
+ announce,
514
+ announcement
515
+ } = useAnnouncement();
516
+ const liveRegionId = useUniqueId("DndLiveRegion");
517
+ const [mounted, setMounted] = React.useState(false);
518
+ React.useEffect(() => {
519
+ setMounted(true);
520
+ }, []);
521
+ useDndMonitor(React.useMemo(() => ({
522
+ onDragStart(_ref2) {
523
+ let {
524
+ active
525
+ } = _ref2;
526
+ announce(announcements.onDragStart({
527
+ active
528
+ }));
529
+ },
530
+ onDragMove(_ref3) {
531
+ let {
532
+ active,
533
+ over
534
+ } = _ref3;
535
+ if (announcements.onDragMove) {
536
+ announce(announcements.onDragMove({
537
+ active,
538
+ over
539
+ }));
540
+ }
541
+ },
542
+ onDragOver(_ref4) {
543
+ let {
544
+ active,
545
+ over
546
+ } = _ref4;
547
+ announce(announcements.onDragOver({
548
+ active,
549
+ over
550
+ }));
551
+ },
552
+ onDragEnd(_ref5) {
553
+ let {
554
+ active,
555
+ over
556
+ } = _ref5;
557
+ announce(announcements.onDragEnd({
558
+ active,
559
+ over
560
+ }));
561
+ },
562
+ onDragCancel(_ref6) {
563
+ let {
564
+ active,
565
+ over
566
+ } = _ref6;
567
+ announce(announcements.onDragCancel({
568
+ active,
569
+ over
570
+ }));
571
+ }
572
+ }), [announce, announcements]));
573
+ if (!mounted) {
574
+ return null;
575
+ }
576
+ const markup = React.createElement(React.Fragment, null, React.createElement(HiddenText, {
577
+ id: hiddenTextDescribedById,
578
+ value: screenReaderInstructions.draggable
579
+ }), React.createElement(LiveRegion, {
580
+ id: liveRegionId,
581
+ announcement
582
+ }));
583
+ return container ? require$$2.createPortal(markup, container) : markup;
584
+ }
585
+ var Action;
586
+ (function(Action2) {
587
+ Action2["DragStart"] = "dragStart";
588
+ Action2["DragMove"] = "dragMove";
589
+ Action2["DragEnd"] = "dragEnd";
590
+ Action2["DragCancel"] = "dragCancel";
591
+ Action2["DragOver"] = "dragOver";
592
+ Action2["RegisterDroppable"] = "registerDroppable";
593
+ Action2["SetDroppableDisabled"] = "setDroppableDisabled";
594
+ Action2["UnregisterDroppable"] = "unregisterDroppable";
595
+ })(Action || (Action = {}));
596
+ function noop() {
597
+ }
598
+ function useSensor(sensor, options) {
599
+ return React.useMemo(
600
+ () => ({
601
+ sensor,
602
+ options: options != null ? options : {}
603
+ }),
604
+ // eslint-disable-next-line react-hooks/exhaustive-deps
605
+ [sensor, options]
606
+ );
607
+ }
608
+ function useSensors() {
609
+ for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
610
+ sensors[_key] = arguments[_key];
611
+ }
612
+ return React.useMemo(
613
+ () => [...sensors].filter((sensor) => sensor != null),
614
+ // eslint-disable-next-line react-hooks/exhaustive-deps
615
+ [...sensors]
616
+ );
617
+ }
618
+ const defaultCoordinates = /* @__PURE__ */ Object.freeze({
619
+ x: 0,
620
+ y: 0
621
+ });
622
+ function sortCollisionsDesc(_ref3, _ref4) {
623
+ let {
624
+ data: {
625
+ value: a
626
+ }
627
+ } = _ref3;
628
+ let {
629
+ data: {
630
+ value: b
631
+ }
632
+ } = _ref4;
633
+ return b - a;
634
+ }
635
+ function getFirstCollision(collisions, property) {
636
+ if (!collisions || collisions.length === 0) {
637
+ return null;
638
+ }
639
+ const [firstCollision] = collisions;
640
+ return firstCollision[property];
641
+ }
642
+ function getIntersectionRatio(entry, target) {
643
+ const top = Math.max(target.top, entry.top);
644
+ const left = Math.max(target.left, entry.left);
645
+ const right = Math.min(target.left + target.width, entry.left + entry.width);
646
+ const bottom = Math.min(target.top + target.height, entry.top + entry.height);
647
+ const width = right - left;
648
+ const height = bottom - top;
649
+ if (left < right && top < bottom) {
650
+ const targetArea = target.width * target.height;
651
+ const entryArea = entry.width * entry.height;
652
+ const intersectionArea = width * height;
653
+ const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
654
+ return Number(intersectionRatio.toFixed(4));
655
+ }
656
+ return 0;
657
+ }
658
+ const rectIntersection = (_ref) => {
659
+ let {
660
+ collisionRect,
661
+ droppableRects,
662
+ droppableContainers
663
+ } = _ref;
664
+ const collisions = [];
665
+ for (const droppableContainer of droppableContainers) {
666
+ const {
667
+ id
668
+ } = droppableContainer;
669
+ const rect = droppableRects.get(id);
670
+ if (rect) {
671
+ const intersectionRatio = getIntersectionRatio(rect, collisionRect);
672
+ if (intersectionRatio > 0) {
673
+ collisions.push({
674
+ id,
675
+ data: {
676
+ droppableContainer,
677
+ value: intersectionRatio
678
+ }
679
+ });
680
+ }
681
+ }
682
+ }
683
+ return collisions.sort(sortCollisionsDesc);
684
+ };
685
+ function adjustScale(transform, rect1, rect2) {
686
+ return {
687
+ ...transform,
688
+ scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
689
+ scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
690
+ };
691
+ }
692
+ function getRectDelta(rect1, rect2) {
693
+ return rect1 && rect2 ? {
694
+ x: rect1.left - rect2.left,
695
+ y: rect1.top - rect2.top
696
+ } : defaultCoordinates;
697
+ }
698
+ function createRectAdjustmentFn(modifier) {
699
+ return function adjustClientRect(rect) {
700
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
701
+ adjustments[_key - 1] = arguments[_key];
702
+ }
703
+ return adjustments.reduce((acc, adjustment) => ({
704
+ ...acc,
705
+ top: acc.top + modifier * adjustment.y,
706
+ bottom: acc.bottom + modifier * adjustment.y,
707
+ left: acc.left + modifier * adjustment.x,
708
+ right: acc.right + modifier * adjustment.x
709
+ }), {
710
+ ...rect
711
+ });
712
+ };
713
+ }
714
+ const getAdjustedRect = /* @__PURE__ */ createRectAdjustmentFn(1);
715
+ function parseTransform(transform) {
716
+ if (transform.startsWith("matrix3d(")) {
717
+ const transformArray = transform.slice(9, -1).split(/, /);
718
+ return {
719
+ x: +transformArray[12],
720
+ y: +transformArray[13],
721
+ scaleX: +transformArray[0],
722
+ scaleY: +transformArray[5]
723
+ };
724
+ } else if (transform.startsWith("matrix(")) {
725
+ const transformArray = transform.slice(7, -1).split(/, /);
726
+ return {
727
+ x: +transformArray[4],
728
+ y: +transformArray[5],
729
+ scaleX: +transformArray[0],
730
+ scaleY: +transformArray[3]
731
+ };
732
+ }
733
+ return null;
734
+ }
735
+ function inverseTransform(rect, transform, transformOrigin) {
736
+ const parsedTransform = parseTransform(transform);
737
+ if (!parsedTransform) {
738
+ return rect;
739
+ }
740
+ const {
741
+ scaleX,
742
+ scaleY,
743
+ x: translateX,
744
+ y: translateY
745
+ } = parsedTransform;
746
+ const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
747
+ const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(" ") + 1));
748
+ const w = scaleX ? rect.width / scaleX : rect.width;
749
+ const h = scaleY ? rect.height / scaleY : rect.height;
750
+ return {
751
+ width: w,
752
+ height: h,
753
+ top: y,
754
+ right: x + w,
755
+ bottom: y + h,
756
+ left: x
757
+ };
758
+ }
759
+ const defaultOptions = {
760
+ ignoreTransform: false
761
+ };
762
+ function getClientRect(element, options) {
763
+ if (options === void 0) {
764
+ options = defaultOptions;
765
+ }
766
+ let rect = element.getBoundingClientRect();
767
+ if (options.ignoreTransform) {
768
+ const {
769
+ transform,
770
+ transformOrigin
771
+ } = getWindow(element).getComputedStyle(element);
772
+ if (transform) {
773
+ rect = inverseTransform(rect, transform, transformOrigin);
774
+ }
775
+ }
776
+ const {
777
+ top,
778
+ left,
779
+ width,
780
+ height,
781
+ bottom,
782
+ right
783
+ } = rect;
784
+ return {
785
+ top,
786
+ left,
787
+ width,
788
+ height,
789
+ bottom,
790
+ right
791
+ };
792
+ }
793
+ function getTransformAgnosticClientRect(element) {
794
+ return getClientRect(element, {
795
+ ignoreTransform: true
796
+ });
797
+ }
798
+ function getWindowClientRect(element) {
799
+ const width = element.innerWidth;
800
+ const height = element.innerHeight;
801
+ return {
802
+ top: 0,
803
+ left: 0,
804
+ right: width,
805
+ bottom: height,
806
+ width,
807
+ height
808
+ };
809
+ }
810
+ function isFixed(node, computedStyle) {
811
+ if (computedStyle === void 0) {
812
+ computedStyle = getWindow(node).getComputedStyle(node);
813
+ }
814
+ return computedStyle.position === "fixed";
815
+ }
816
+ function isScrollable(element, computedStyle) {
817
+ if (computedStyle === void 0) {
818
+ computedStyle = getWindow(element).getComputedStyle(element);
819
+ }
820
+ const overflowRegex = /(auto|scroll|overlay)/;
821
+ const properties2 = ["overflow", "overflowX", "overflowY"];
822
+ return properties2.some((property) => {
823
+ const value = computedStyle[property];
824
+ return typeof value === "string" ? overflowRegex.test(value) : false;
825
+ });
826
+ }
827
+ function getScrollableAncestors(element, limit) {
828
+ const scrollParents = [];
829
+ function findScrollableAncestors(node) {
830
+ if (limit != null && scrollParents.length >= limit) {
831
+ return scrollParents;
832
+ }
833
+ if (!node) {
834
+ return scrollParents;
835
+ }
836
+ if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
837
+ scrollParents.push(node.scrollingElement);
838
+ return scrollParents;
839
+ }
840
+ if (!isHTMLElement(node) || isSVGElement(node)) {
841
+ return scrollParents;
842
+ }
843
+ if (scrollParents.includes(node)) {
844
+ return scrollParents;
845
+ }
846
+ const computedStyle = getWindow(element).getComputedStyle(node);
847
+ if (node !== element) {
848
+ if (isScrollable(node, computedStyle)) {
849
+ scrollParents.push(node);
850
+ }
851
+ }
852
+ if (isFixed(node, computedStyle)) {
853
+ return scrollParents;
854
+ }
855
+ return findScrollableAncestors(node.parentNode);
856
+ }
857
+ if (!element) {
858
+ return scrollParents;
859
+ }
860
+ return findScrollableAncestors(element);
861
+ }
862
+ function getFirstScrollableAncestor(node) {
863
+ const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
864
+ return firstScrollableAncestor != null ? firstScrollableAncestor : null;
865
+ }
866
+ function getScrollableElement(element) {
867
+ if (!canUseDOM || !element) {
868
+ return null;
869
+ }
870
+ if (isWindow(element)) {
871
+ return element;
872
+ }
873
+ if (!isNode(element)) {
874
+ return null;
875
+ }
876
+ if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
877
+ return window;
878
+ }
879
+ if (isHTMLElement(element)) {
880
+ return element;
881
+ }
882
+ return null;
883
+ }
884
+ function getScrollXCoordinate(element) {
885
+ if (isWindow(element)) {
886
+ return element.scrollX;
887
+ }
888
+ return element.scrollLeft;
889
+ }
890
+ function getScrollYCoordinate(element) {
891
+ if (isWindow(element)) {
892
+ return element.scrollY;
893
+ }
894
+ return element.scrollTop;
895
+ }
896
+ function getScrollCoordinates(element) {
897
+ return {
898
+ x: getScrollXCoordinate(element),
899
+ y: getScrollYCoordinate(element)
900
+ };
901
+ }
902
+ var Direction;
903
+ (function(Direction2) {
904
+ Direction2[Direction2["Forward"] = 1] = "Forward";
905
+ Direction2[Direction2["Backward"] = -1] = "Backward";
906
+ })(Direction || (Direction = {}));
907
+ function isDocumentScrollingElement(element) {
908
+ if (!canUseDOM || !element) {
909
+ return false;
910
+ }
911
+ return element === document.scrollingElement;
912
+ }
913
+ function getScrollPosition(scrollingContainer) {
914
+ const minScroll = {
915
+ x: 0,
916
+ y: 0
917
+ };
918
+ const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
919
+ height: window.innerHeight,
920
+ width: window.innerWidth
921
+ } : {
922
+ height: scrollingContainer.clientHeight,
923
+ width: scrollingContainer.clientWidth
924
+ };
925
+ const maxScroll = {
926
+ x: scrollingContainer.scrollWidth - dimensions.width,
927
+ y: scrollingContainer.scrollHeight - dimensions.height
928
+ };
929
+ const isTop = scrollingContainer.scrollTop <= minScroll.y;
930
+ const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
931
+ const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
932
+ const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
933
+ return {
934
+ isTop,
935
+ isLeft,
936
+ isBottom,
937
+ isRight,
938
+ maxScroll,
939
+ minScroll
940
+ };
941
+ }
942
+ const defaultThreshold = {
943
+ x: 0.2,
944
+ y: 0.2
945
+ };
946
+ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
947
+ let {
948
+ top,
949
+ left,
950
+ right,
951
+ bottom
952
+ } = _ref;
953
+ if (acceleration === void 0) {
954
+ acceleration = 10;
955
+ }
956
+ if (thresholdPercentage === void 0) {
957
+ thresholdPercentage = defaultThreshold;
958
+ }
959
+ const {
960
+ isTop,
961
+ isBottom,
962
+ isLeft,
963
+ isRight
964
+ } = getScrollPosition(scrollContainer);
965
+ const direction = {
966
+ x: 0,
967
+ y: 0
968
+ };
969
+ const speed = {
970
+ x: 0,
971
+ y: 0
972
+ };
973
+ const threshold = {
974
+ height: scrollContainerRect.height * thresholdPercentage.y,
975
+ width: scrollContainerRect.width * thresholdPercentage.x
976
+ };
977
+ if (!isTop && top <= scrollContainerRect.top + threshold.height) {
978
+ direction.y = Direction.Backward;
979
+ speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
980
+ } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
981
+ direction.y = Direction.Forward;
982
+ speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
983
+ }
984
+ if (!isRight && right >= scrollContainerRect.right - threshold.width) {
985
+ direction.x = Direction.Forward;
986
+ speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
987
+ } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
988
+ direction.x = Direction.Backward;
989
+ speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
990
+ }
991
+ return {
992
+ direction,
993
+ speed
994
+ };
995
+ }
996
+ function getScrollElementRect(element) {
997
+ if (element === document.scrollingElement) {
998
+ const {
999
+ innerWidth,
1000
+ innerHeight
1001
+ } = window;
1002
+ return {
1003
+ top: 0,
1004
+ left: 0,
1005
+ right: innerWidth,
1006
+ bottom: innerHeight,
1007
+ width: innerWidth,
1008
+ height: innerHeight
1009
+ };
1010
+ }
1011
+ const {
1012
+ top,
1013
+ left,
1014
+ right,
1015
+ bottom
1016
+ } = element.getBoundingClientRect();
1017
+ return {
1018
+ top,
1019
+ left,
1020
+ right,
1021
+ bottom,
1022
+ width: element.clientWidth,
1023
+ height: element.clientHeight
1024
+ };
1025
+ }
1026
+ function getScrollOffsets(scrollableAncestors) {
1027
+ return scrollableAncestors.reduce((acc, node) => {
1028
+ return add(acc, getScrollCoordinates(node));
1029
+ }, defaultCoordinates);
1030
+ }
1031
+ function getScrollXOffset(scrollableAncestors) {
1032
+ return scrollableAncestors.reduce((acc, node) => {
1033
+ return acc + getScrollXCoordinate(node);
1034
+ }, 0);
1035
+ }
1036
+ function getScrollYOffset(scrollableAncestors) {
1037
+ return scrollableAncestors.reduce((acc, node) => {
1038
+ return acc + getScrollYCoordinate(node);
1039
+ }, 0);
1040
+ }
1041
+ function scrollIntoViewIfNeeded(element, measure) {
1042
+ if (measure === void 0) {
1043
+ measure = getClientRect;
1044
+ }
1045
+ if (!element) {
1046
+ return;
1047
+ }
1048
+ const {
1049
+ top,
1050
+ left,
1051
+ bottom,
1052
+ right
1053
+ } = measure(element);
1054
+ const firstScrollableAncestor = getFirstScrollableAncestor(element);
1055
+ if (!firstScrollableAncestor) {
1056
+ return;
1057
+ }
1058
+ if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
1059
+ element.scrollIntoView({
1060
+ block: "center",
1061
+ inline: "center"
1062
+ });
1063
+ }
1064
+ }
1065
+ const properties = [["x", ["left", "right"], getScrollXOffset], ["y", ["top", "bottom"], getScrollYOffset]];
1066
+ class Rect {
1067
+ constructor(rect, element) {
1068
+ this.rect = void 0;
1069
+ this.width = void 0;
1070
+ this.height = void 0;
1071
+ this.top = void 0;
1072
+ this.bottom = void 0;
1073
+ this.right = void 0;
1074
+ this.left = void 0;
1075
+ const scrollableAncestors = getScrollableAncestors(element);
1076
+ const scrollOffsets = getScrollOffsets(scrollableAncestors);
1077
+ this.rect = {
1078
+ ...rect
1079
+ };
1080
+ this.width = rect.width;
1081
+ this.height = rect.height;
1082
+ for (const [axis, keys, getScrollOffset] of properties) {
1083
+ for (const key of keys) {
1084
+ Object.defineProperty(this, key, {
1085
+ get: () => {
1086
+ const currentOffsets = getScrollOffset(scrollableAncestors);
1087
+ const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
1088
+ return this.rect[key] + scrollOffsetsDeltla;
1089
+ },
1090
+ enumerable: true
1091
+ });
1092
+ }
1093
+ }
1094
+ Object.defineProperty(this, "rect", {
1095
+ enumerable: false
1096
+ });
1097
+ }
1098
+ }
1099
+ class Listeners {
1100
+ constructor(target) {
1101
+ this.target = void 0;
1102
+ this.listeners = [];
1103
+ this.removeAll = () => {
1104
+ this.listeners.forEach((listener) => {
1105
+ var _this$target;
1106
+ return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
1107
+ });
1108
+ };
1109
+ this.target = target;
1110
+ }
1111
+ add(eventName, handler, options) {
1112
+ var _this$target2;
1113
+ (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
1114
+ this.listeners.push([eventName, handler, options]);
1115
+ }
1116
+ }
1117
+ function getEventListenerTarget(target) {
1118
+ const {
1119
+ EventTarget
1120
+ } = getWindow(target);
1121
+ return target instanceof EventTarget ? target : getOwnerDocument(target);
1122
+ }
1123
+ function hasExceededDistance(delta, measurement) {
1124
+ const dx = Math.abs(delta.x);
1125
+ const dy = Math.abs(delta.y);
1126
+ if (typeof measurement === "number") {
1127
+ return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
1128
+ }
1129
+ if ("x" in measurement && "y" in measurement) {
1130
+ return dx > measurement.x && dy > measurement.y;
1131
+ }
1132
+ if ("x" in measurement) {
1133
+ return dx > measurement.x;
1134
+ }
1135
+ if ("y" in measurement) {
1136
+ return dy > measurement.y;
1137
+ }
1138
+ return false;
1139
+ }
1140
+ var EventName;
1141
+ (function(EventName2) {
1142
+ EventName2["Click"] = "click";
1143
+ EventName2["DragStart"] = "dragstart";
1144
+ EventName2["Keydown"] = "keydown";
1145
+ EventName2["ContextMenu"] = "contextmenu";
1146
+ EventName2["Resize"] = "resize";
1147
+ EventName2["SelectionChange"] = "selectionchange";
1148
+ EventName2["VisibilityChange"] = "visibilitychange";
1149
+ })(EventName || (EventName = {}));
1150
+ function preventDefault(event) {
1151
+ event.preventDefault();
1152
+ }
1153
+ function stopPropagation(event) {
1154
+ event.stopPropagation();
1155
+ }
1156
+ var KeyboardCode;
1157
+ (function(KeyboardCode2) {
1158
+ KeyboardCode2["Space"] = "Space";
1159
+ KeyboardCode2["Down"] = "ArrowDown";
1160
+ KeyboardCode2["Right"] = "ArrowRight";
1161
+ KeyboardCode2["Left"] = "ArrowLeft";
1162
+ KeyboardCode2["Up"] = "ArrowUp";
1163
+ KeyboardCode2["Esc"] = "Escape";
1164
+ KeyboardCode2["Enter"] = "Enter";
1165
+ KeyboardCode2["Tab"] = "Tab";
1166
+ })(KeyboardCode || (KeyboardCode = {}));
1167
+ const defaultKeyboardCodes = {
1168
+ start: [KeyboardCode.Space, KeyboardCode.Enter],
1169
+ cancel: [KeyboardCode.Esc],
1170
+ end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
1171
+ };
1172
+ const defaultKeyboardCoordinateGetter = (event, _ref) => {
1173
+ let {
1174
+ currentCoordinates
1175
+ } = _ref;
1176
+ switch (event.code) {
1177
+ case KeyboardCode.Right:
1178
+ return {
1179
+ ...currentCoordinates,
1180
+ x: currentCoordinates.x + 25
1181
+ };
1182
+ case KeyboardCode.Left:
1183
+ return {
1184
+ ...currentCoordinates,
1185
+ x: currentCoordinates.x - 25
1186
+ };
1187
+ case KeyboardCode.Down:
1188
+ return {
1189
+ ...currentCoordinates,
1190
+ y: currentCoordinates.y + 25
1191
+ };
1192
+ case KeyboardCode.Up:
1193
+ return {
1194
+ ...currentCoordinates,
1195
+ y: currentCoordinates.y - 25
1196
+ };
1197
+ }
1198
+ return void 0;
1199
+ };
1200
+ class KeyboardSensor {
1201
+ constructor(props) {
1202
+ this.props = void 0;
1203
+ this.autoScrollEnabled = false;
1204
+ this.referenceCoordinates = void 0;
1205
+ this.listeners = void 0;
1206
+ this.windowListeners = void 0;
1207
+ this.props = props;
1208
+ const {
1209
+ event: {
1210
+ target
1211
+ }
1212
+ } = props;
1213
+ this.props = props;
1214
+ this.listeners = new Listeners(getOwnerDocument(target));
1215
+ this.windowListeners = new Listeners(getWindow(target));
1216
+ this.handleKeyDown = this.handleKeyDown.bind(this);
1217
+ this.handleCancel = this.handleCancel.bind(this);
1218
+ this.attach();
1219
+ }
1220
+ attach() {
1221
+ this.handleStart();
1222
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1223
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1224
+ setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
1225
+ }
1226
+ handleStart() {
1227
+ const {
1228
+ activeNode,
1229
+ onStart
1230
+ } = this.props;
1231
+ const node = activeNode.node.current;
1232
+ if (node) {
1233
+ scrollIntoViewIfNeeded(node);
1234
+ }
1235
+ onStart(defaultCoordinates);
1236
+ }
1237
+ handleKeyDown(event) {
1238
+ if (isKeyboardEvent(event)) {
1239
+ const {
1240
+ active,
1241
+ context,
1242
+ options
1243
+ } = this.props;
1244
+ const {
1245
+ keyboardCodes = defaultKeyboardCodes,
1246
+ coordinateGetter = defaultKeyboardCoordinateGetter,
1247
+ scrollBehavior = "smooth"
1248
+ } = options;
1249
+ const {
1250
+ code
1251
+ } = event;
1252
+ if (keyboardCodes.end.includes(code)) {
1253
+ this.handleEnd(event);
1254
+ return;
1255
+ }
1256
+ if (keyboardCodes.cancel.includes(code)) {
1257
+ this.handleCancel(event);
1258
+ return;
1259
+ }
1260
+ const {
1261
+ collisionRect
1262
+ } = context.current;
1263
+ const currentCoordinates = collisionRect ? {
1264
+ x: collisionRect.left,
1265
+ y: collisionRect.top
1266
+ } : defaultCoordinates;
1267
+ if (!this.referenceCoordinates) {
1268
+ this.referenceCoordinates = currentCoordinates;
1269
+ }
1270
+ const newCoordinates = coordinateGetter(event, {
1271
+ active,
1272
+ context: context.current,
1273
+ currentCoordinates
1274
+ });
1275
+ if (newCoordinates) {
1276
+ const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
1277
+ const scrollDelta = {
1278
+ x: 0,
1279
+ y: 0
1280
+ };
1281
+ const {
1282
+ scrollableAncestors
1283
+ } = context.current;
1284
+ for (const scrollContainer of scrollableAncestors) {
1285
+ const direction = event.code;
1286
+ const {
1287
+ isTop,
1288
+ isRight,
1289
+ isLeft,
1290
+ isBottom,
1291
+ maxScroll,
1292
+ minScroll
1293
+ } = getScrollPosition(scrollContainer);
1294
+ const scrollElementRect = getScrollElementRect(scrollContainer);
1295
+ const clampedCoordinates = {
1296
+ x: Math.min(direction === KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)),
1297
+ y: Math.min(direction === KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y))
1298
+ };
1299
+ const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
1300
+ const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
1301
+ if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
1302
+ const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
1303
+ const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
1304
+ if (canScrollToNewCoordinates && !coordinatesDelta.y) {
1305
+ scrollContainer.scrollTo({
1306
+ left: newScrollCoordinates,
1307
+ behavior: scrollBehavior
1308
+ });
1309
+ return;
1310
+ }
1311
+ if (canScrollToNewCoordinates) {
1312
+ scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
1313
+ } else {
1314
+ scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
1315
+ }
1316
+ if (scrollDelta.x) {
1317
+ scrollContainer.scrollBy({
1318
+ left: -scrollDelta.x,
1319
+ behavior: scrollBehavior
1320
+ });
1321
+ }
1322
+ break;
1323
+ } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
1324
+ const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
1325
+ const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
1326
+ if (canScrollToNewCoordinates && !coordinatesDelta.x) {
1327
+ scrollContainer.scrollTo({
1328
+ top: newScrollCoordinates,
1329
+ behavior: scrollBehavior
1330
+ });
1331
+ return;
1332
+ }
1333
+ if (canScrollToNewCoordinates) {
1334
+ scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
1335
+ } else {
1336
+ scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
1337
+ }
1338
+ if (scrollDelta.y) {
1339
+ scrollContainer.scrollBy({
1340
+ top: -scrollDelta.y,
1341
+ behavior: scrollBehavior
1342
+ });
1343
+ }
1344
+ break;
1345
+ }
1346
+ }
1347
+ this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
1348
+ }
1349
+ }
1350
+ }
1351
+ handleMove(event, coordinates) {
1352
+ const {
1353
+ onMove
1354
+ } = this.props;
1355
+ event.preventDefault();
1356
+ onMove(coordinates);
1357
+ }
1358
+ handleEnd(event) {
1359
+ const {
1360
+ onEnd
1361
+ } = this.props;
1362
+ event.preventDefault();
1363
+ this.detach();
1364
+ onEnd();
1365
+ }
1366
+ handleCancel(event) {
1367
+ const {
1368
+ onCancel
1369
+ } = this.props;
1370
+ event.preventDefault();
1371
+ this.detach();
1372
+ onCancel();
1373
+ }
1374
+ detach() {
1375
+ this.listeners.removeAll();
1376
+ this.windowListeners.removeAll();
1377
+ }
1378
+ }
1379
+ KeyboardSensor.activators = [{
1380
+ eventName: "onKeyDown",
1381
+ handler: (event, _ref, _ref2) => {
1382
+ let {
1383
+ keyboardCodes = defaultKeyboardCodes,
1384
+ onActivation
1385
+ } = _ref;
1386
+ let {
1387
+ active
1388
+ } = _ref2;
1389
+ const {
1390
+ code
1391
+ } = event.nativeEvent;
1392
+ if (keyboardCodes.start.includes(code)) {
1393
+ const activator = active.activatorNode.current;
1394
+ if (activator && event.target !== activator) {
1395
+ return false;
1396
+ }
1397
+ event.preventDefault();
1398
+ onActivation == null ? void 0 : onActivation({
1399
+ event: event.nativeEvent
1400
+ });
1401
+ return true;
1402
+ }
1403
+ return false;
1404
+ }
1405
+ }];
1406
+ function isDistanceConstraint(constraint) {
1407
+ return Boolean(constraint && "distance" in constraint);
1408
+ }
1409
+ function isDelayConstraint(constraint) {
1410
+ return Boolean(constraint && "delay" in constraint);
1411
+ }
1412
+ class AbstractPointerSensor {
1413
+ constructor(props, events2, listenerTarget) {
1414
+ var _getEventCoordinates;
1415
+ if (listenerTarget === void 0) {
1416
+ listenerTarget = getEventListenerTarget(props.event.target);
1417
+ }
1418
+ this.props = void 0;
1419
+ this.events = void 0;
1420
+ this.autoScrollEnabled = true;
1421
+ this.document = void 0;
1422
+ this.activated = false;
1423
+ this.initialCoordinates = void 0;
1424
+ this.timeoutId = null;
1425
+ this.listeners = void 0;
1426
+ this.documentListeners = void 0;
1427
+ this.windowListeners = void 0;
1428
+ this.props = props;
1429
+ this.events = events2;
1430
+ const {
1431
+ event
1432
+ } = props;
1433
+ const {
1434
+ target
1435
+ } = event;
1436
+ this.props = props;
1437
+ this.events = events2;
1438
+ this.document = getOwnerDocument(target);
1439
+ this.documentListeners = new Listeners(this.document);
1440
+ this.listeners = new Listeners(listenerTarget);
1441
+ this.windowListeners = new Listeners(getWindow(target));
1442
+ this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
1443
+ this.handleStart = this.handleStart.bind(this);
1444
+ this.handleMove = this.handleMove.bind(this);
1445
+ this.handleEnd = this.handleEnd.bind(this);
1446
+ this.handleCancel = this.handleCancel.bind(this);
1447
+ this.handleKeydown = this.handleKeydown.bind(this);
1448
+ this.removeTextSelection = this.removeTextSelection.bind(this);
1449
+ this.attach();
1450
+ }
1451
+ attach() {
1452
+ const {
1453
+ events: events2,
1454
+ props: {
1455
+ options: {
1456
+ activationConstraint,
1457
+ bypassActivationConstraint
1458
+ }
1459
+ }
1460
+ } = this;
1461
+ this.listeners.add(events2.move.name, this.handleMove, {
1462
+ passive: false
1463
+ });
1464
+ this.listeners.add(events2.end.name, this.handleEnd);
1465
+ if (events2.cancel) {
1466
+ this.listeners.add(events2.cancel.name, this.handleCancel);
1467
+ }
1468
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1469
+ this.windowListeners.add(EventName.DragStart, preventDefault);
1470
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1471
+ this.windowListeners.add(EventName.ContextMenu, preventDefault);
1472
+ this.documentListeners.add(EventName.Keydown, this.handleKeydown);
1473
+ if (activationConstraint) {
1474
+ if (bypassActivationConstraint != null && bypassActivationConstraint({
1475
+ event: this.props.event,
1476
+ activeNode: this.props.activeNode,
1477
+ options: this.props.options
1478
+ })) {
1479
+ return this.handleStart();
1480
+ }
1481
+ if (isDelayConstraint(activationConstraint)) {
1482
+ this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
1483
+ this.handlePending(activationConstraint);
1484
+ return;
1485
+ }
1486
+ if (isDistanceConstraint(activationConstraint)) {
1487
+ this.handlePending(activationConstraint);
1488
+ return;
1489
+ }
1490
+ }
1491
+ this.handleStart();
1492
+ }
1493
+ detach() {
1494
+ this.listeners.removeAll();
1495
+ this.windowListeners.removeAll();
1496
+ setTimeout(this.documentListeners.removeAll, 50);
1497
+ if (this.timeoutId !== null) {
1498
+ clearTimeout(this.timeoutId);
1499
+ this.timeoutId = null;
1500
+ }
1501
+ }
1502
+ handlePending(constraint, offset) {
1503
+ const {
1504
+ active,
1505
+ onPending
1506
+ } = this.props;
1507
+ onPending(active, constraint, this.initialCoordinates, offset);
1508
+ }
1509
+ handleStart() {
1510
+ const {
1511
+ initialCoordinates
1512
+ } = this;
1513
+ const {
1514
+ onStart
1515
+ } = this.props;
1516
+ if (initialCoordinates) {
1517
+ this.activated = true;
1518
+ this.documentListeners.add(EventName.Click, stopPropagation, {
1519
+ capture: true
1520
+ });
1521
+ this.removeTextSelection();
1522
+ this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
1523
+ onStart(initialCoordinates);
1524
+ }
1525
+ }
1526
+ handleMove(event) {
1527
+ var _getEventCoordinates2;
1528
+ const {
1529
+ activated,
1530
+ initialCoordinates,
1531
+ props
1532
+ } = this;
1533
+ const {
1534
+ onMove,
1535
+ options: {
1536
+ activationConstraint
1537
+ }
1538
+ } = props;
1539
+ if (!initialCoordinates) {
1540
+ return;
1541
+ }
1542
+ const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
1543
+ const delta = subtract(initialCoordinates, coordinates);
1544
+ if (!activated && activationConstraint) {
1545
+ if (isDistanceConstraint(activationConstraint)) {
1546
+ if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
1547
+ return this.handleCancel();
1548
+ }
1549
+ if (hasExceededDistance(delta, activationConstraint.distance)) {
1550
+ return this.handleStart();
1551
+ }
1552
+ }
1553
+ if (isDelayConstraint(activationConstraint)) {
1554
+ if (hasExceededDistance(delta, activationConstraint.tolerance)) {
1555
+ return this.handleCancel();
1556
+ }
1557
+ }
1558
+ this.handlePending(activationConstraint, delta);
1559
+ return;
1560
+ }
1561
+ if (event.cancelable) {
1562
+ event.preventDefault();
1563
+ }
1564
+ onMove(coordinates);
1565
+ }
1566
+ handleEnd() {
1567
+ const {
1568
+ onAbort,
1569
+ onEnd
1570
+ } = this.props;
1571
+ this.detach();
1572
+ if (!this.activated) {
1573
+ onAbort(this.props.active);
1574
+ }
1575
+ onEnd();
1576
+ }
1577
+ handleCancel() {
1578
+ const {
1579
+ onAbort,
1580
+ onCancel
1581
+ } = this.props;
1582
+ this.detach();
1583
+ if (!this.activated) {
1584
+ onAbort(this.props.active);
1585
+ }
1586
+ onCancel();
1587
+ }
1588
+ handleKeydown(event) {
1589
+ if (event.code === KeyboardCode.Esc) {
1590
+ this.handleCancel();
1591
+ }
1592
+ }
1593
+ removeTextSelection() {
1594
+ var _this$document$getSel;
1595
+ (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
1596
+ }
1597
+ }
1598
+ const events = {
1599
+ cancel: {
1600
+ name: "pointercancel"
1601
+ },
1602
+ move: {
1603
+ name: "pointermove"
1604
+ },
1605
+ end: {
1606
+ name: "pointerup"
1607
+ }
1608
+ };
1609
+ class PointerSensor extends AbstractPointerSensor {
1610
+ constructor(props) {
1611
+ const {
1612
+ event
1613
+ } = props;
1614
+ const listenerTarget = getOwnerDocument(event.target);
1615
+ super(props, events, listenerTarget);
1616
+ }
1617
+ }
1618
+ PointerSensor.activators = [{
1619
+ eventName: "onPointerDown",
1620
+ handler: (_ref, _ref2) => {
1621
+ let {
1622
+ nativeEvent: event
1623
+ } = _ref;
1624
+ let {
1625
+ onActivation
1626
+ } = _ref2;
1627
+ if (!event.isPrimary || event.button !== 0) {
1628
+ return false;
1629
+ }
1630
+ onActivation == null ? void 0 : onActivation({
1631
+ event
1632
+ });
1633
+ return true;
1634
+ }
1635
+ }];
1636
+ const events$1 = {
1637
+ move: {
1638
+ name: "mousemove"
1639
+ },
1640
+ end: {
1641
+ name: "mouseup"
1642
+ }
1643
+ };
1644
+ var MouseButton;
1645
+ (function(MouseButton2) {
1646
+ MouseButton2[MouseButton2["RightClick"] = 2] = "RightClick";
1647
+ })(MouseButton || (MouseButton = {}));
1648
+ class MouseSensor extends AbstractPointerSensor {
1649
+ constructor(props) {
1650
+ super(props, events$1, getOwnerDocument(props.event.target));
1651
+ }
1652
+ }
1653
+ MouseSensor.activators = [{
1654
+ eventName: "onMouseDown",
1655
+ handler: (_ref, _ref2) => {
1656
+ let {
1657
+ nativeEvent: event
1658
+ } = _ref;
1659
+ let {
1660
+ onActivation
1661
+ } = _ref2;
1662
+ if (event.button === MouseButton.RightClick) {
1663
+ return false;
1664
+ }
1665
+ onActivation == null ? void 0 : onActivation({
1666
+ event
1667
+ });
1668
+ return true;
1669
+ }
1670
+ }];
1671
+ const events$2 = {
1672
+ cancel: {
1673
+ name: "touchcancel"
1674
+ },
1675
+ move: {
1676
+ name: "touchmove"
1677
+ },
1678
+ end: {
1679
+ name: "touchend"
1680
+ }
1681
+ };
1682
+ class TouchSensor extends AbstractPointerSensor {
1683
+ constructor(props) {
1684
+ super(props, events$2);
1685
+ }
1686
+ static setup() {
1687
+ window.addEventListener(events$2.move.name, noop2, {
1688
+ capture: false,
1689
+ passive: false
1690
+ });
1691
+ return function teardown() {
1692
+ window.removeEventListener(events$2.move.name, noop2);
1693
+ };
1694
+ function noop2() {
1695
+ }
1696
+ }
1697
+ }
1698
+ TouchSensor.activators = [{
1699
+ eventName: "onTouchStart",
1700
+ handler: (_ref, _ref2) => {
1701
+ let {
1702
+ nativeEvent: event
1703
+ } = _ref;
1704
+ let {
1705
+ onActivation
1706
+ } = _ref2;
1707
+ const {
1708
+ touches
1709
+ } = event;
1710
+ if (touches.length > 1) {
1711
+ return false;
1712
+ }
1713
+ onActivation == null ? void 0 : onActivation({
1714
+ event
1715
+ });
1716
+ return true;
1717
+ }
1718
+ }];
1719
+ var AutoScrollActivator;
1720
+ (function(AutoScrollActivator2) {
1721
+ AutoScrollActivator2[AutoScrollActivator2["Pointer"] = 0] = "Pointer";
1722
+ AutoScrollActivator2[AutoScrollActivator2["DraggableRect"] = 1] = "DraggableRect";
1723
+ })(AutoScrollActivator || (AutoScrollActivator = {}));
1724
+ var TraversalOrder;
1725
+ (function(TraversalOrder2) {
1726
+ TraversalOrder2[TraversalOrder2["TreeOrder"] = 0] = "TreeOrder";
1727
+ TraversalOrder2[TraversalOrder2["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
1728
+ })(TraversalOrder || (TraversalOrder = {}));
1729
+ function useAutoScroller(_ref) {
1730
+ let {
1731
+ acceleration,
1732
+ activator = AutoScrollActivator.Pointer,
1733
+ canScroll,
1734
+ draggingRect,
1735
+ enabled,
1736
+ interval = 5,
1737
+ order = TraversalOrder.TreeOrder,
1738
+ pointerCoordinates,
1739
+ scrollableAncestors,
1740
+ scrollableAncestorRects,
1741
+ delta,
1742
+ threshold
1743
+ } = _ref;
1744
+ const scrollIntent = useScrollIntent({
1745
+ delta,
1746
+ disabled: !enabled
1747
+ });
1748
+ const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
1749
+ const scrollSpeed = React.useRef({
1750
+ x: 0,
1751
+ y: 0
1752
+ });
1753
+ const scrollDirection = React.useRef({
1754
+ x: 0,
1755
+ y: 0
1756
+ });
1757
+ const rect = React.useMemo(() => {
1758
+ switch (activator) {
1759
+ case AutoScrollActivator.Pointer:
1760
+ return pointerCoordinates ? {
1761
+ top: pointerCoordinates.y,
1762
+ bottom: pointerCoordinates.y,
1763
+ left: pointerCoordinates.x,
1764
+ right: pointerCoordinates.x
1765
+ } : null;
1766
+ case AutoScrollActivator.DraggableRect:
1767
+ return draggingRect;
1768
+ }
1769
+ }, [activator, draggingRect, pointerCoordinates]);
1770
+ const scrollContainerRef = React.useRef(null);
1771
+ const autoScroll = React.useCallback(() => {
1772
+ const scrollContainer = scrollContainerRef.current;
1773
+ if (!scrollContainer) {
1774
+ return;
1775
+ }
1776
+ const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
1777
+ const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
1778
+ scrollContainer.scrollBy(scrollLeft, scrollTop);
1779
+ }, []);
1780
+ const sortedScrollableAncestors = React.useMemo(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
1781
+ React.useEffect(
1782
+ () => {
1783
+ if (!enabled || !scrollableAncestors.length || !rect) {
1784
+ clearAutoScrollInterval();
1785
+ return;
1786
+ }
1787
+ for (const scrollContainer of sortedScrollableAncestors) {
1788
+ if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
1789
+ continue;
1790
+ }
1791
+ const index2 = scrollableAncestors.indexOf(scrollContainer);
1792
+ const scrollContainerRect = scrollableAncestorRects[index2];
1793
+ if (!scrollContainerRect) {
1794
+ continue;
1795
+ }
1796
+ const {
1797
+ direction,
1798
+ speed
1799
+ } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
1800
+ for (const axis of ["x", "y"]) {
1801
+ if (!scrollIntent[axis][direction[axis]]) {
1802
+ speed[axis] = 0;
1803
+ direction[axis] = 0;
1804
+ }
1805
+ }
1806
+ if (speed.x > 0 || speed.y > 0) {
1807
+ clearAutoScrollInterval();
1808
+ scrollContainerRef.current = scrollContainer;
1809
+ setAutoScrollInterval(autoScroll, interval);
1810
+ scrollSpeed.current = speed;
1811
+ scrollDirection.current = direction;
1812
+ return;
1813
+ }
1814
+ }
1815
+ scrollSpeed.current = {
1816
+ x: 0,
1817
+ y: 0
1818
+ };
1819
+ scrollDirection.current = {
1820
+ x: 0,
1821
+ y: 0
1822
+ };
1823
+ clearAutoScrollInterval();
1824
+ },
1825
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1826
+ [
1827
+ acceleration,
1828
+ autoScroll,
1829
+ canScroll,
1830
+ clearAutoScrollInterval,
1831
+ enabled,
1832
+ interval,
1833
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1834
+ JSON.stringify(rect),
1835
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1836
+ JSON.stringify(scrollIntent),
1837
+ setAutoScrollInterval,
1838
+ scrollableAncestors,
1839
+ sortedScrollableAncestors,
1840
+ scrollableAncestorRects,
1841
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1842
+ JSON.stringify(threshold)
1843
+ ]
1844
+ );
1845
+ }
1846
+ const defaultScrollIntent = {
1847
+ x: {
1848
+ [Direction.Backward]: false,
1849
+ [Direction.Forward]: false
1850
+ },
1851
+ y: {
1852
+ [Direction.Backward]: false,
1853
+ [Direction.Forward]: false
1854
+ }
1855
+ };
1856
+ function useScrollIntent(_ref2) {
1857
+ let {
1858
+ delta,
1859
+ disabled
1860
+ } = _ref2;
1861
+ const previousDelta = usePrevious(delta);
1862
+ return useLazyMemo((previousIntent) => {
1863
+ if (disabled || !previousDelta || !previousIntent) {
1864
+ return defaultScrollIntent;
1865
+ }
1866
+ const direction = {
1867
+ x: Math.sign(delta.x - previousDelta.x),
1868
+ y: Math.sign(delta.y - previousDelta.y)
1869
+ };
1870
+ return {
1871
+ x: {
1872
+ [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
1873
+ [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
1874
+ },
1875
+ y: {
1876
+ [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
1877
+ [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
1878
+ }
1879
+ };
1880
+ }, [disabled, delta, previousDelta]);
1881
+ }
1882
+ function useCachedNode(draggableNodes, id) {
1883
+ const draggableNode = id != null ? draggableNodes.get(id) : void 0;
1884
+ const node = draggableNode ? draggableNode.node.current : null;
1885
+ return useLazyMemo((cachedNode) => {
1886
+ var _ref;
1887
+ if (id == null) {
1888
+ return null;
1889
+ }
1890
+ return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
1891
+ }, [node, id]);
1892
+ }
1893
+ function useCombineActivators(sensors, getSyntheticHandler) {
1894
+ return React.useMemo(() => sensors.reduce((accumulator, sensor) => {
1895
+ const {
1896
+ sensor: Sensor
1897
+ } = sensor;
1898
+ const sensorActivators = Sensor.activators.map((activator) => ({
1899
+ eventName: activator.eventName,
1900
+ handler: getSyntheticHandler(activator.handler, sensor)
1901
+ }));
1902
+ return [...accumulator, ...sensorActivators];
1903
+ }, []), [sensors, getSyntheticHandler]);
1904
+ }
1905
+ var MeasuringStrategy;
1906
+ (function(MeasuringStrategy2) {
1907
+ MeasuringStrategy2[MeasuringStrategy2["Always"] = 0] = "Always";
1908
+ MeasuringStrategy2[MeasuringStrategy2["BeforeDragging"] = 1] = "BeforeDragging";
1909
+ MeasuringStrategy2[MeasuringStrategy2["WhileDragging"] = 2] = "WhileDragging";
1910
+ })(MeasuringStrategy || (MeasuringStrategy = {}));
1911
+ var MeasuringFrequency;
1912
+ (function(MeasuringFrequency2) {
1913
+ MeasuringFrequency2["Optimized"] = "optimized";
1914
+ })(MeasuringFrequency || (MeasuringFrequency = {}));
1915
+ const defaultValue = /* @__PURE__ */ new Map();
1916
+ function useDroppableMeasuring(containers, _ref) {
1917
+ let {
1918
+ dragging,
1919
+ dependencies,
1920
+ config
1921
+ } = _ref;
1922
+ const [queue, setQueue] = React.useState(null);
1923
+ const {
1924
+ frequency,
1925
+ measure,
1926
+ strategy
1927
+ } = config;
1928
+ const containersRef = React.useRef(containers);
1929
+ const disabled = isDisabled();
1930
+ const disabledRef = useLatestValue(disabled);
1931
+ const measureDroppableContainers = React.useCallback(function(ids2) {
1932
+ if (ids2 === void 0) {
1933
+ ids2 = [];
1934
+ }
1935
+ if (disabledRef.current) {
1936
+ return;
1937
+ }
1938
+ setQueue((value) => {
1939
+ if (value === null) {
1940
+ return ids2;
1941
+ }
1942
+ return value.concat(ids2.filter((id) => !value.includes(id)));
1943
+ });
1944
+ }, [disabledRef]);
1945
+ const timeoutId = React.useRef(null);
1946
+ const droppableRects = useLazyMemo((previousValue) => {
1947
+ if (disabled && !dragging) {
1948
+ return defaultValue;
1949
+ }
1950
+ if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
1951
+ const map = /* @__PURE__ */ new Map();
1952
+ for (let container of containers) {
1953
+ if (!container) {
1954
+ continue;
1955
+ }
1956
+ if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
1957
+ map.set(container.id, container.rect.current);
1958
+ continue;
1959
+ }
1960
+ const node = container.node.current;
1961
+ const rect = node ? new Rect(measure(node), node) : null;
1962
+ container.rect.current = rect;
1963
+ if (rect) {
1964
+ map.set(container.id, rect);
1965
+ }
1966
+ }
1967
+ return map;
1968
+ }
1969
+ return previousValue;
1970
+ }, [containers, queue, dragging, disabled, measure]);
1971
+ React.useEffect(() => {
1972
+ containersRef.current = containers;
1973
+ }, [containers]);
1974
+ React.useEffect(
1975
+ () => {
1976
+ if (disabled) {
1977
+ return;
1978
+ }
1979
+ measureDroppableContainers();
1980
+ },
1981
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1982
+ [dragging, disabled]
1983
+ );
1984
+ React.useEffect(
1985
+ () => {
1986
+ if (queue && queue.length > 0) {
1987
+ setQueue(null);
1988
+ }
1989
+ },
1990
+ //eslint-disable-next-line react-hooks/exhaustive-deps
1991
+ [JSON.stringify(queue)]
1992
+ );
1993
+ React.useEffect(
1994
+ () => {
1995
+ if (disabled || typeof frequency !== "number" || timeoutId.current !== null) {
1996
+ return;
1997
+ }
1998
+ timeoutId.current = setTimeout(() => {
1999
+ measureDroppableContainers();
2000
+ timeoutId.current = null;
2001
+ }, frequency);
2002
+ },
2003
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2004
+ [frequency, disabled, measureDroppableContainers, ...dependencies]
2005
+ );
2006
+ return {
2007
+ droppableRects,
2008
+ measureDroppableContainers,
2009
+ measuringScheduled: queue != null
2010
+ };
2011
+ function isDisabled() {
2012
+ switch (strategy) {
2013
+ case MeasuringStrategy.Always:
2014
+ return false;
2015
+ case MeasuringStrategy.BeforeDragging:
2016
+ return dragging;
2017
+ default:
2018
+ return !dragging;
2019
+ }
2020
+ }
2021
+ }
2022
+ function useInitialValue(value, computeFn) {
2023
+ return useLazyMemo((previousValue) => {
2024
+ if (!value) {
2025
+ return null;
2026
+ }
2027
+ if (previousValue) {
2028
+ return previousValue;
2029
+ }
2030
+ return typeof computeFn === "function" ? computeFn(value) : value;
2031
+ }, [computeFn, value]);
2032
+ }
2033
+ function useInitialRect(node, measure) {
2034
+ return useInitialValue(node, measure);
2035
+ }
2036
+ function useMutationObserver(_ref) {
2037
+ let {
2038
+ callback,
2039
+ disabled
2040
+ } = _ref;
2041
+ const handleMutations = useEvent(callback);
2042
+ const mutationObserver = React.useMemo(() => {
2043
+ if (disabled || typeof window === "undefined" || typeof window.MutationObserver === "undefined") {
2044
+ return void 0;
2045
+ }
2046
+ const {
2047
+ MutationObserver
2048
+ } = window;
2049
+ return new MutationObserver(handleMutations);
2050
+ }, [handleMutations, disabled]);
2051
+ React.useEffect(() => {
2052
+ return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
2053
+ }, [mutationObserver]);
2054
+ return mutationObserver;
2055
+ }
2056
+ function useResizeObserver(_ref) {
2057
+ let {
2058
+ callback,
2059
+ disabled
2060
+ } = _ref;
2061
+ const handleResize = useEvent(callback);
2062
+ const resizeObserver = React.useMemo(
2063
+ () => {
2064
+ if (disabled || typeof window === "undefined" || typeof window.ResizeObserver === "undefined") {
2065
+ return void 0;
2066
+ }
2067
+ const {
2068
+ ResizeObserver
2069
+ } = window;
2070
+ return new ResizeObserver(handleResize);
2071
+ },
2072
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2073
+ [disabled]
2074
+ );
2075
+ React.useEffect(() => {
2076
+ return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
2077
+ }, [resizeObserver]);
2078
+ return resizeObserver;
2079
+ }
2080
+ function defaultMeasure(element) {
2081
+ return new Rect(getClientRect(element), element);
2082
+ }
2083
+ function useRect(element, measure, fallbackRect) {
2084
+ if (measure === void 0) {
2085
+ measure = defaultMeasure;
2086
+ }
2087
+ const [rect, setRect] = React.useState(null);
2088
+ function measureRect() {
2089
+ setRect((currentRect) => {
2090
+ if (!element) {
2091
+ return null;
2092
+ }
2093
+ if (element.isConnected === false) {
2094
+ var _ref;
2095
+ return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
2096
+ }
2097
+ const newRect = measure(element);
2098
+ if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
2099
+ return currentRect;
2100
+ }
2101
+ return newRect;
2102
+ });
2103
+ }
2104
+ const mutationObserver = useMutationObserver({
2105
+ callback(records) {
2106
+ if (!element) {
2107
+ return;
2108
+ }
2109
+ for (const record of records) {
2110
+ const {
2111
+ type,
2112
+ target
2113
+ } = record;
2114
+ if (type === "childList" && target instanceof HTMLElement && target.contains(element)) {
2115
+ measureRect();
2116
+ break;
2117
+ }
2118
+ }
2119
+ }
2120
+ });
2121
+ const resizeObserver = useResizeObserver({
2122
+ callback: measureRect
2123
+ });
2124
+ useIsomorphicLayoutEffect(() => {
2125
+ measureRect();
2126
+ if (element) {
2127
+ resizeObserver == null ? void 0 : resizeObserver.observe(element);
2128
+ mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
2129
+ childList: true,
2130
+ subtree: true
2131
+ });
2132
+ } else {
2133
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2134
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
2135
+ }
2136
+ }, [element]);
2137
+ return rect;
2138
+ }
2139
+ function useRectDelta(rect) {
2140
+ const initialRect = useInitialValue(rect);
2141
+ return getRectDelta(rect, initialRect);
2142
+ }
2143
+ const defaultValue$1 = [];
2144
+ function useScrollableAncestors(node) {
2145
+ const previousNode = React.useRef(node);
2146
+ const ancestors = useLazyMemo((previousValue) => {
2147
+ if (!node) {
2148
+ return defaultValue$1;
2149
+ }
2150
+ if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
2151
+ return previousValue;
2152
+ }
2153
+ return getScrollableAncestors(node);
2154
+ }, [node]);
2155
+ React.useEffect(() => {
2156
+ previousNode.current = node;
2157
+ }, [node]);
2158
+ return ancestors;
2159
+ }
2160
+ function useScrollOffsets(elements) {
2161
+ const [scrollCoordinates, setScrollCoordinates] = React.useState(null);
2162
+ const prevElements = React.useRef(elements);
2163
+ const handleScroll = React.useCallback((event) => {
2164
+ const scrollingElement = getScrollableElement(event.target);
2165
+ if (!scrollingElement) {
2166
+ return;
2167
+ }
2168
+ setScrollCoordinates((scrollCoordinates2) => {
2169
+ if (!scrollCoordinates2) {
2170
+ return null;
2171
+ }
2172
+ scrollCoordinates2.set(scrollingElement, getScrollCoordinates(scrollingElement));
2173
+ return new Map(scrollCoordinates2);
2174
+ });
2175
+ }, []);
2176
+ React.useEffect(() => {
2177
+ const previousElements = prevElements.current;
2178
+ if (elements !== previousElements) {
2179
+ cleanup(previousElements);
2180
+ const entries = elements.map((element) => {
2181
+ const scrollableElement = getScrollableElement(element);
2182
+ if (scrollableElement) {
2183
+ scrollableElement.addEventListener("scroll", handleScroll, {
2184
+ passive: true
2185
+ });
2186
+ return [scrollableElement, getScrollCoordinates(scrollableElement)];
2187
+ }
2188
+ return null;
2189
+ }).filter((entry) => entry != null);
2190
+ setScrollCoordinates(entries.length ? new Map(entries) : null);
2191
+ prevElements.current = elements;
2192
+ }
2193
+ return () => {
2194
+ cleanup(elements);
2195
+ cleanup(previousElements);
2196
+ };
2197
+ function cleanup(elements2) {
2198
+ elements2.forEach((element) => {
2199
+ const scrollableElement = getScrollableElement(element);
2200
+ scrollableElement == null ? void 0 : scrollableElement.removeEventListener("scroll", handleScroll);
2201
+ });
2202
+ }
2203
+ }, [handleScroll, elements]);
2204
+ return React.useMemo(() => {
2205
+ if (elements.length) {
2206
+ return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
2207
+ }
2208
+ return defaultCoordinates;
2209
+ }, [elements, scrollCoordinates]);
2210
+ }
2211
+ function useScrollOffsetsDelta(scrollOffsets, dependencies) {
2212
+ if (dependencies === void 0) {
2213
+ dependencies = [];
2214
+ }
2215
+ const initialScrollOffsets = React.useRef(null);
2216
+ React.useEffect(
2217
+ () => {
2218
+ initialScrollOffsets.current = null;
2219
+ },
2220
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2221
+ dependencies
2222
+ );
2223
+ React.useEffect(() => {
2224
+ const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
2225
+ if (hasScrollOffsets && !initialScrollOffsets.current) {
2226
+ initialScrollOffsets.current = scrollOffsets;
2227
+ }
2228
+ if (!hasScrollOffsets && initialScrollOffsets.current) {
2229
+ initialScrollOffsets.current = null;
2230
+ }
2231
+ }, [scrollOffsets]);
2232
+ return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
2233
+ }
2234
+ function useSensorSetup(sensors) {
2235
+ React.useEffect(
2236
+ () => {
2237
+ if (!canUseDOM) {
2238
+ return;
2239
+ }
2240
+ const teardownFns = sensors.map((_ref) => {
2241
+ let {
2242
+ sensor
2243
+ } = _ref;
2244
+ return sensor.setup == null ? void 0 : sensor.setup();
2245
+ });
2246
+ return () => {
2247
+ for (const teardown of teardownFns) {
2248
+ teardown == null ? void 0 : teardown();
2249
+ }
2250
+ };
2251
+ },
2252
+ // TO-DO: Sensors length could theoretically change which would not be a valid dependency
2253
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2254
+ sensors.map((_ref2) => {
2255
+ let {
2256
+ sensor
2257
+ } = _ref2;
2258
+ return sensor;
2259
+ })
2260
+ );
2261
+ }
2262
+ function useSyntheticListeners(listeners, id) {
2263
+ return React.useMemo(() => {
2264
+ return listeners.reduce((acc, _ref) => {
2265
+ let {
2266
+ eventName,
2267
+ handler
2268
+ } = _ref;
2269
+ acc[eventName] = (event) => {
2270
+ handler(event, id);
2271
+ };
2272
+ return acc;
2273
+ }, {});
2274
+ }, [listeners, id]);
2275
+ }
2276
+ function useWindowRect(element) {
2277
+ return React.useMemo(() => element ? getWindowClientRect(element) : null, [element]);
2278
+ }
2279
+ const defaultValue$2 = [];
2280
+ function useRects(elements, measure) {
2281
+ if (measure === void 0) {
2282
+ measure = getClientRect;
2283
+ }
2284
+ const [firstElement] = elements;
2285
+ const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
2286
+ const [rects, setRects] = React.useState(defaultValue$2);
2287
+ function measureRects() {
2288
+ setRects(() => {
2289
+ if (!elements.length) {
2290
+ return defaultValue$2;
2291
+ }
2292
+ return elements.map((element) => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
2293
+ });
2294
+ }
2295
+ const resizeObserver = useResizeObserver({
2296
+ callback: measureRects
2297
+ });
2298
+ useIsomorphicLayoutEffect(() => {
2299
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2300
+ measureRects();
2301
+ elements.forEach((element) => resizeObserver == null ? void 0 : resizeObserver.observe(element));
2302
+ }, [elements]);
2303
+ return rects;
2304
+ }
2305
+ function getMeasurableNode(node) {
2306
+ if (!node) {
2307
+ return null;
2308
+ }
2309
+ if (node.children.length > 1) {
2310
+ return node;
2311
+ }
2312
+ const firstChild = node.children[0];
2313
+ return isHTMLElement(firstChild) ? firstChild : node;
2314
+ }
2315
+ function useDragOverlayMeasuring(_ref) {
2316
+ let {
2317
+ measure
2318
+ } = _ref;
2319
+ const [rect, setRect] = React.useState(null);
2320
+ const handleResize = React.useCallback((entries) => {
2321
+ for (const {
2322
+ target
2323
+ } of entries) {
2324
+ if (isHTMLElement(target)) {
2325
+ setRect((rect2) => {
2326
+ const newRect = measure(target);
2327
+ return rect2 ? {
2328
+ ...rect2,
2329
+ width: newRect.width,
2330
+ height: newRect.height
2331
+ } : newRect;
2332
+ });
2333
+ break;
2334
+ }
2335
+ }
2336
+ }, [measure]);
2337
+ const resizeObserver = useResizeObserver({
2338
+ callback: handleResize
2339
+ });
2340
+ const handleNodeChange = React.useCallback((element) => {
2341
+ const node = getMeasurableNode(element);
2342
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2343
+ if (node) {
2344
+ resizeObserver == null ? void 0 : resizeObserver.observe(node);
2345
+ }
2346
+ setRect(node ? measure(node) : null);
2347
+ }, [measure, resizeObserver]);
2348
+ const [nodeRef, setRef] = useNodeRef(handleNodeChange);
2349
+ return React.useMemo(() => ({
2350
+ nodeRef,
2351
+ rect,
2352
+ setRef
2353
+ }), [rect, nodeRef, setRef]);
2354
+ }
2355
+ const defaultSensors = [{
2356
+ sensor: PointerSensor,
2357
+ options: {}
2358
+ }, {
2359
+ sensor: KeyboardSensor,
2360
+ options: {}
2361
+ }];
2362
+ const defaultData = {
2363
+ current: {}
2364
+ };
2365
+ const defaultMeasuringConfiguration = {
2366
+ draggable: {
2367
+ measure: getTransformAgnosticClientRect
2368
+ },
2369
+ droppable: {
2370
+ measure: getTransformAgnosticClientRect,
2371
+ strategy: MeasuringStrategy.WhileDragging,
2372
+ frequency: MeasuringFrequency.Optimized
2373
+ },
2374
+ dragOverlay: {
2375
+ measure: getClientRect
2376
+ }
2377
+ };
2378
+ class DroppableContainersMap extends Map {
2379
+ get(id) {
2380
+ var _super$get;
2381
+ return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
2382
+ }
2383
+ toArray() {
2384
+ return Array.from(this.values());
2385
+ }
2386
+ getEnabled() {
2387
+ return this.toArray().filter((_ref) => {
2388
+ let {
2389
+ disabled
2390
+ } = _ref;
2391
+ return !disabled;
2392
+ });
2393
+ }
2394
+ getNodeFor(id) {
2395
+ var _this$get$node$curren, _this$get;
2396
+ return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
2397
+ }
2398
+ }
2399
+ const defaultPublicContext = {
2400
+ activatorEvent: null,
2401
+ active: null,
2402
+ activeNode: null,
2403
+ activeNodeRect: null,
2404
+ collisions: null,
2405
+ containerNodeRect: null,
2406
+ draggableNodes: /* @__PURE__ */ new Map(),
2407
+ droppableRects: /* @__PURE__ */ new Map(),
2408
+ droppableContainers: /* @__PURE__ */ new DroppableContainersMap(),
2409
+ over: null,
2410
+ dragOverlay: {
2411
+ nodeRef: {
2412
+ current: null
2413
+ },
2414
+ rect: null,
2415
+ setRef: noop
2416
+ },
2417
+ scrollableAncestors: [],
2418
+ scrollableAncestorRects: [],
2419
+ measuringConfiguration: defaultMeasuringConfiguration,
2420
+ measureDroppableContainers: noop,
2421
+ windowRect: null,
2422
+ measuringScheduled: false
2423
+ };
2424
+ const defaultInternalContext = {
2425
+ activatorEvent: null,
2426
+ activators: [],
2427
+ active: null,
2428
+ activeNodeRect: null,
2429
+ ariaDescribedById: {
2430
+ draggable: ""
2431
+ },
2432
+ dispatch: noop,
2433
+ draggableNodes: /* @__PURE__ */ new Map(),
2434
+ over: null,
2435
+ measureDroppableContainers: noop
2436
+ };
2437
+ const InternalContext = /* @__PURE__ */ React.createContext(defaultInternalContext);
2438
+ const PublicContext = /* @__PURE__ */ React.createContext(defaultPublicContext);
2439
+ function getInitialState() {
2440
+ return {
2441
+ draggable: {
2442
+ active: null,
2443
+ initialCoordinates: {
2444
+ x: 0,
2445
+ y: 0
2446
+ },
2447
+ nodes: /* @__PURE__ */ new Map(),
2448
+ translate: {
2449
+ x: 0,
2450
+ y: 0
2451
+ }
2452
+ },
2453
+ droppable: {
2454
+ containers: new DroppableContainersMap()
2455
+ }
2456
+ };
2457
+ }
2458
+ function reducer(state, action) {
2459
+ switch (action.type) {
2460
+ case Action.DragStart:
2461
+ return {
2462
+ ...state,
2463
+ draggable: {
2464
+ ...state.draggable,
2465
+ initialCoordinates: action.initialCoordinates,
2466
+ active: action.active
2467
+ }
2468
+ };
2469
+ case Action.DragMove:
2470
+ if (state.draggable.active == null) {
2471
+ return state;
2472
+ }
2473
+ return {
2474
+ ...state,
2475
+ draggable: {
2476
+ ...state.draggable,
2477
+ translate: {
2478
+ x: action.coordinates.x - state.draggable.initialCoordinates.x,
2479
+ y: action.coordinates.y - state.draggable.initialCoordinates.y
2480
+ }
2481
+ }
2482
+ };
2483
+ case Action.DragEnd:
2484
+ case Action.DragCancel:
2485
+ return {
2486
+ ...state,
2487
+ draggable: {
2488
+ ...state.draggable,
2489
+ active: null,
2490
+ initialCoordinates: {
2491
+ x: 0,
2492
+ y: 0
2493
+ },
2494
+ translate: {
2495
+ x: 0,
2496
+ y: 0
2497
+ }
2498
+ }
2499
+ };
2500
+ case Action.RegisterDroppable: {
2501
+ const {
2502
+ element
2503
+ } = action;
2504
+ const {
2505
+ id
2506
+ } = element;
2507
+ const containers = new DroppableContainersMap(state.droppable.containers);
2508
+ containers.set(id, element);
2509
+ return {
2510
+ ...state,
2511
+ droppable: {
2512
+ ...state.droppable,
2513
+ containers
2514
+ }
2515
+ };
2516
+ }
2517
+ case Action.SetDroppableDisabled: {
2518
+ const {
2519
+ id,
2520
+ key,
2521
+ disabled
2522
+ } = action;
2523
+ const element = state.droppable.containers.get(id);
2524
+ if (!element || key !== element.key) {
2525
+ return state;
2526
+ }
2527
+ const containers = new DroppableContainersMap(state.droppable.containers);
2528
+ containers.set(id, {
2529
+ ...element,
2530
+ disabled
2531
+ });
2532
+ return {
2533
+ ...state,
2534
+ droppable: {
2535
+ ...state.droppable,
2536
+ containers
2537
+ }
2538
+ };
2539
+ }
2540
+ case Action.UnregisterDroppable: {
2541
+ const {
2542
+ id,
2543
+ key
2544
+ } = action;
2545
+ const element = state.droppable.containers.get(id);
2546
+ if (!element || key !== element.key) {
2547
+ return state;
2548
+ }
2549
+ const containers = new DroppableContainersMap(state.droppable.containers);
2550
+ containers.delete(id);
2551
+ return {
2552
+ ...state,
2553
+ droppable: {
2554
+ ...state.droppable,
2555
+ containers
2556
+ }
2557
+ };
2558
+ }
2559
+ default: {
2560
+ return state;
2561
+ }
2562
+ }
2563
+ }
2564
+ function RestoreFocus(_ref) {
2565
+ let {
2566
+ disabled
2567
+ } = _ref;
2568
+ const {
2569
+ active,
2570
+ activatorEvent,
2571
+ draggableNodes
2572
+ } = React.useContext(InternalContext);
2573
+ const previousActivatorEvent = usePrevious(activatorEvent);
2574
+ const previousActiveId = usePrevious(active == null ? void 0 : active.id);
2575
+ React.useEffect(() => {
2576
+ if (disabled) {
2577
+ return;
2578
+ }
2579
+ if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
2580
+ if (!isKeyboardEvent(previousActivatorEvent)) {
2581
+ return;
2582
+ }
2583
+ if (document.activeElement === previousActivatorEvent.target) {
2584
+ return;
2585
+ }
2586
+ const draggableNode = draggableNodes.get(previousActiveId);
2587
+ if (!draggableNode) {
2588
+ return;
2589
+ }
2590
+ const {
2591
+ activatorNode,
2592
+ node
2593
+ } = draggableNode;
2594
+ if (!activatorNode.current && !node.current) {
2595
+ return;
2596
+ }
2597
+ requestAnimationFrame(() => {
2598
+ for (const element of [activatorNode.current, node.current]) {
2599
+ if (!element) {
2600
+ continue;
2601
+ }
2602
+ const focusableNode = findFirstFocusableNode(element);
2603
+ if (focusableNode) {
2604
+ focusableNode.focus();
2605
+ break;
2606
+ }
2607
+ }
2608
+ });
2609
+ }
2610
+ }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
2611
+ return null;
2612
+ }
2613
+ function applyModifiers(modifiers, _ref) {
2614
+ let {
2615
+ transform,
2616
+ ...args
2617
+ } = _ref;
2618
+ return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
2619
+ return modifier({
2620
+ transform: accumulator,
2621
+ ...args
2622
+ });
2623
+ }, transform) : transform;
2624
+ }
2625
+ function useMeasuringConfiguration(config) {
2626
+ return React.useMemo(
2627
+ () => ({
2628
+ draggable: {
2629
+ ...defaultMeasuringConfiguration.draggable,
2630
+ ...config == null ? void 0 : config.draggable
2631
+ },
2632
+ droppable: {
2633
+ ...defaultMeasuringConfiguration.droppable,
2634
+ ...config == null ? void 0 : config.droppable
2635
+ },
2636
+ dragOverlay: {
2637
+ ...defaultMeasuringConfiguration.dragOverlay,
2638
+ ...config == null ? void 0 : config.dragOverlay
2639
+ }
2640
+ }),
2641
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2642
+ [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]
2643
+ );
2644
+ }
2645
+ function useLayoutShiftScrollCompensation(_ref) {
2646
+ let {
2647
+ activeNode,
2648
+ measure,
2649
+ initialRect,
2650
+ config = true
2651
+ } = _ref;
2652
+ const initialized = React.useRef(false);
2653
+ const {
2654
+ x,
2655
+ y
2656
+ } = typeof config === "boolean" ? {
2657
+ x: config,
2658
+ y: config
2659
+ } : config;
2660
+ useIsomorphicLayoutEffect(() => {
2661
+ const disabled = !x && !y;
2662
+ if (disabled || !activeNode) {
2663
+ initialized.current = false;
2664
+ return;
2665
+ }
2666
+ if (initialized.current || !initialRect) {
2667
+ return;
2668
+ }
2669
+ const node = activeNode == null ? void 0 : activeNode.node.current;
2670
+ if (!node || node.isConnected === false) {
2671
+ return;
2672
+ }
2673
+ const rect = measure(node);
2674
+ const rectDelta = getRectDelta(rect, initialRect);
2675
+ if (!x) {
2676
+ rectDelta.x = 0;
2677
+ }
2678
+ if (!y) {
2679
+ rectDelta.y = 0;
2680
+ }
2681
+ initialized.current = true;
2682
+ if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
2683
+ const firstScrollableAncestor = getFirstScrollableAncestor(node);
2684
+ if (firstScrollableAncestor) {
2685
+ firstScrollableAncestor.scrollBy({
2686
+ top: rectDelta.y,
2687
+ left: rectDelta.x
2688
+ });
2689
+ }
2690
+ }
2691
+ }, [activeNode, x, y, initialRect, measure]);
2692
+ }
2693
+ const ActiveDraggableContext = /* @__PURE__ */ React.createContext({
2694
+ ...defaultCoordinates,
2695
+ scaleX: 1,
2696
+ scaleY: 1
2697
+ });
2698
+ var Status;
2699
+ (function(Status2) {
2700
+ Status2[Status2["Uninitialized"] = 0] = "Uninitialized";
2701
+ Status2[Status2["Initializing"] = 1] = "Initializing";
2702
+ Status2[Status2["Initialized"] = 2] = "Initialized";
2703
+ })(Status || (Status = {}));
2704
+ const DndContext = /* @__PURE__ */ React.memo(function DndContext2(_ref) {
2705
+ var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
2706
+ let {
2707
+ id,
2708
+ accessibility,
2709
+ autoScroll = true,
2710
+ children,
2711
+ sensors = defaultSensors,
2712
+ collisionDetection = rectIntersection,
2713
+ measuring,
2714
+ modifiers,
2715
+ ...props
2716
+ } = _ref;
2717
+ const store = React.useReducer(reducer, void 0, getInitialState);
2718
+ const [state, dispatch] = store;
2719
+ const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
2720
+ const [status, setStatus] = React.useState(Status.Uninitialized);
2721
+ const isInitialized = status === Status.Initialized;
2722
+ const {
2723
+ draggable: {
2724
+ active: activeId,
2725
+ nodes: draggableNodes,
2726
+ translate
2727
+ },
2728
+ droppable: {
2729
+ containers: droppableContainers
2730
+ }
2731
+ } = state;
2732
+ const node = activeId != null ? draggableNodes.get(activeId) : null;
2733
+ const activeRects = React.useRef({
2734
+ initial: null,
2735
+ translated: null
2736
+ });
2737
+ const active = React.useMemo(() => {
2738
+ var _node$data;
2739
+ return activeId != null ? {
2740
+ id: activeId,
2741
+ // It's possible for the active node to unmount while dragging
2742
+ data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
2743
+ rect: activeRects
2744
+ } : null;
2745
+ }, [activeId, node]);
2746
+ const activeRef = React.useRef(null);
2747
+ const [activeSensor, setActiveSensor] = React.useState(null);
2748
+ const [activatorEvent, setActivatorEvent] = React.useState(null);
2749
+ const latestProps = useLatestValue(props, Object.values(props));
2750
+ const draggableDescribedById = useUniqueId("DndDescribedBy", id);
2751
+ const enabledDroppableContainers = React.useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
2752
+ const measuringConfiguration = useMeasuringConfiguration(measuring);
2753
+ const {
2754
+ droppableRects,
2755
+ measureDroppableContainers,
2756
+ measuringScheduled
2757
+ } = useDroppableMeasuring(enabledDroppableContainers, {
2758
+ dragging: isInitialized,
2759
+ dependencies: [translate.x, translate.y],
2760
+ config: measuringConfiguration.droppable
2761
+ });
2762
+ const activeNode = useCachedNode(draggableNodes, activeId);
2763
+ const activationCoordinates = React.useMemo(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
2764
+ const autoScrollOptions = getAutoScrollerOptions();
2765
+ const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
2766
+ useLayoutShiftScrollCompensation({
2767
+ activeNode: activeId != null ? draggableNodes.get(activeId) : null,
2768
+ config: autoScrollOptions.layoutShiftCompensation,
2769
+ initialRect: initialActiveNodeRect,
2770
+ measure: measuringConfiguration.draggable.measure
2771
+ });
2772
+ const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
2773
+ const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
2774
+ const sensorContext = React.useRef({
2775
+ activatorEvent: null,
2776
+ active: null,
2777
+ activeNode,
2778
+ collisionRect: null,
2779
+ collisions: null,
2780
+ droppableRects,
2781
+ draggableNodes,
2782
+ draggingNode: null,
2783
+ draggingNodeRect: null,
2784
+ droppableContainers,
2785
+ over: null,
2786
+ scrollableAncestors: [],
2787
+ scrollAdjustedTranslate: null
2788
+ });
2789
+ const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
2790
+ const dragOverlay = useDragOverlayMeasuring({
2791
+ measure: measuringConfiguration.dragOverlay.measure
2792
+ });
2793
+ const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
2794
+ const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
2795
+ const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect);
2796
+ const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect);
2797
+ const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null);
2798
+ const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
2799
+ const scrollableAncestorRects = useRects(scrollableAncestors);
2800
+ const modifiedTranslate = applyModifiers(modifiers, {
2801
+ transform: {
2802
+ x: translate.x - nodeRectDelta.x,
2803
+ y: translate.y - nodeRectDelta.y,
2804
+ scaleX: 1,
2805
+ scaleY: 1
2806
+ },
2807
+ activatorEvent,
2808
+ active,
2809
+ activeNodeRect,
2810
+ containerNodeRect,
2811
+ draggingNodeRect,
2812
+ over: sensorContext.current.over,
2813
+ overlayNodeRect: dragOverlay.rect,
2814
+ scrollableAncestors,
2815
+ scrollableAncestorRects,
2816
+ windowRect
2817
+ });
2818
+ const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
2819
+ const scrollOffsets = useScrollOffsets(scrollableAncestors);
2820
+ const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);
2821
+ const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
2822
+ const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
2823
+ const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
2824
+ const collisions = active && collisionRect ? collisionDetection({
2825
+ active,
2826
+ collisionRect,
2827
+ droppableRects,
2828
+ droppableContainers: enabledDroppableContainers,
2829
+ pointerCoordinates
2830
+ }) : null;
2831
+ const overId = getFirstCollision(collisions, "id");
2832
+ const [over, setOver] = React.useState(null);
2833
+ const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
2834
+ const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
2835
+ const activeSensorRef = React.useRef(null);
2836
+ const instantiateSensor = React.useCallback(
2837
+ (event, _ref2) => {
2838
+ let {
2839
+ sensor: Sensor,
2840
+ options
2841
+ } = _ref2;
2842
+ if (activeRef.current == null) {
2843
+ return;
2844
+ }
2845
+ const activeNode2 = draggableNodes.get(activeRef.current);
2846
+ if (!activeNode2) {
2847
+ return;
2848
+ }
2849
+ const activatorEvent2 = event.nativeEvent;
2850
+ const sensorInstance = new Sensor({
2851
+ active: activeRef.current,
2852
+ activeNode: activeNode2,
2853
+ event: activatorEvent2,
2854
+ options,
2855
+ // Sensors need to be instantiated with refs for arguments that change over time
2856
+ // otherwise they are frozen in time with the stale arguments
2857
+ context: sensorContext,
2858
+ onAbort(id2) {
2859
+ const draggableNode = draggableNodes.get(id2);
2860
+ if (!draggableNode) {
2861
+ return;
2862
+ }
2863
+ const {
2864
+ onDragAbort
2865
+ } = latestProps.current;
2866
+ const event2 = {
2867
+ id: id2
2868
+ };
2869
+ onDragAbort == null ? void 0 : onDragAbort(event2);
2870
+ dispatchMonitorEvent({
2871
+ type: "onDragAbort",
2872
+ event: event2
2873
+ });
2874
+ },
2875
+ onPending(id2, constraint, initialCoordinates, offset) {
2876
+ const draggableNode = draggableNodes.get(id2);
2877
+ if (!draggableNode) {
2878
+ return;
2879
+ }
2880
+ const {
2881
+ onDragPending
2882
+ } = latestProps.current;
2883
+ const event2 = {
2884
+ id: id2,
2885
+ constraint,
2886
+ initialCoordinates,
2887
+ offset
2888
+ };
2889
+ onDragPending == null ? void 0 : onDragPending(event2);
2890
+ dispatchMonitorEvent({
2891
+ type: "onDragPending",
2892
+ event: event2
2893
+ });
2894
+ },
2895
+ onStart(initialCoordinates) {
2896
+ const id2 = activeRef.current;
2897
+ if (id2 == null) {
2898
+ return;
2899
+ }
2900
+ const draggableNode = draggableNodes.get(id2);
2901
+ if (!draggableNode) {
2902
+ return;
2903
+ }
2904
+ const {
2905
+ onDragStart
2906
+ } = latestProps.current;
2907
+ const event2 = {
2908
+ activatorEvent: activatorEvent2,
2909
+ active: {
2910
+ id: id2,
2911
+ data: draggableNode.data,
2912
+ rect: activeRects
2913
+ }
2914
+ };
2915
+ require$$2.unstable_batchedUpdates(() => {
2916
+ onDragStart == null ? void 0 : onDragStart(event2);
2917
+ setStatus(Status.Initializing);
2918
+ dispatch({
2919
+ type: Action.DragStart,
2920
+ initialCoordinates,
2921
+ active: id2
2922
+ });
2923
+ dispatchMonitorEvent({
2924
+ type: "onDragStart",
2925
+ event: event2
2926
+ });
2927
+ setActiveSensor(activeSensorRef.current);
2928
+ setActivatorEvent(activatorEvent2);
2929
+ });
2930
+ },
2931
+ onMove(coordinates) {
2932
+ dispatch({
2933
+ type: Action.DragMove,
2934
+ coordinates
2935
+ });
2936
+ },
2937
+ onEnd: createHandler(Action.DragEnd),
2938
+ onCancel: createHandler(Action.DragCancel)
2939
+ });
2940
+ activeSensorRef.current = sensorInstance;
2941
+ function createHandler(type) {
2942
+ return async function handler() {
2943
+ const {
2944
+ active: active2,
2945
+ collisions: collisions2,
2946
+ over: over2,
2947
+ scrollAdjustedTranslate: scrollAdjustedTranslate2
2948
+ } = sensorContext.current;
2949
+ let event2 = null;
2950
+ if (active2 && scrollAdjustedTranslate2) {
2951
+ const {
2952
+ cancelDrop
2953
+ } = latestProps.current;
2954
+ event2 = {
2955
+ activatorEvent: activatorEvent2,
2956
+ active: active2,
2957
+ collisions: collisions2,
2958
+ delta: scrollAdjustedTranslate2,
2959
+ over: over2
2960
+ };
2961
+ if (type === Action.DragEnd && typeof cancelDrop === "function") {
2962
+ const shouldCancel = await Promise.resolve(cancelDrop(event2));
2963
+ if (shouldCancel) {
2964
+ type = Action.DragCancel;
2965
+ }
2966
+ }
2967
+ }
2968
+ activeRef.current = null;
2969
+ require$$2.unstable_batchedUpdates(() => {
2970
+ dispatch({
2971
+ type
2972
+ });
2973
+ setStatus(Status.Uninitialized);
2974
+ setOver(null);
2975
+ setActiveSensor(null);
2976
+ setActivatorEvent(null);
2977
+ activeSensorRef.current = null;
2978
+ const eventName = type === Action.DragEnd ? "onDragEnd" : "onDragCancel";
2979
+ if (event2) {
2980
+ const handler2 = latestProps.current[eventName];
2981
+ handler2 == null ? void 0 : handler2(event2);
2982
+ dispatchMonitorEvent({
2983
+ type: eventName,
2984
+ event: event2
2985
+ });
2986
+ }
2987
+ });
2988
+ };
2989
+ }
2990
+ },
2991
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2992
+ [draggableNodes]
2993
+ );
2994
+ const bindActivatorToSensorInstantiator = React.useCallback((handler, sensor) => {
2995
+ return (event, active2) => {
2996
+ const nativeEvent = event.nativeEvent;
2997
+ const activeDraggableNode = draggableNodes.get(active2);
2998
+ if (
2999
+ // Another sensor is already instantiating
3000
+ activeRef.current !== null || // No active draggable
3001
+ !activeDraggableNode || // Event has already been captured
3002
+ nativeEvent.dndKit || nativeEvent.defaultPrevented
3003
+ ) {
3004
+ return;
3005
+ }
3006
+ const activationContext = {
3007
+ active: activeDraggableNode
3008
+ };
3009
+ const shouldActivate = handler(event, sensor.options, activationContext);
3010
+ if (shouldActivate === true) {
3011
+ nativeEvent.dndKit = {
3012
+ capturedBy: sensor.sensor
3013
+ };
3014
+ activeRef.current = active2;
3015
+ instantiateSensor(event, sensor);
3016
+ }
3017
+ };
3018
+ }, [draggableNodes, instantiateSensor]);
3019
+ const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
3020
+ useSensorSetup(sensors);
3021
+ useIsomorphicLayoutEffect(() => {
3022
+ if (activeNodeRect && status === Status.Initializing) {
3023
+ setStatus(Status.Initialized);
3024
+ }
3025
+ }, [activeNodeRect, status]);
3026
+ React.useEffect(
3027
+ () => {
3028
+ const {
3029
+ onDragMove
3030
+ } = latestProps.current;
3031
+ const {
3032
+ active: active2,
3033
+ activatorEvent: activatorEvent2,
3034
+ collisions: collisions2,
3035
+ over: over2
3036
+ } = sensorContext.current;
3037
+ if (!active2 || !activatorEvent2) {
3038
+ return;
3039
+ }
3040
+ const event = {
3041
+ active: active2,
3042
+ activatorEvent: activatorEvent2,
3043
+ collisions: collisions2,
3044
+ delta: {
3045
+ x: scrollAdjustedTranslate.x,
3046
+ y: scrollAdjustedTranslate.y
3047
+ },
3048
+ over: over2
3049
+ };
3050
+ require$$2.unstable_batchedUpdates(() => {
3051
+ onDragMove == null ? void 0 : onDragMove(event);
3052
+ dispatchMonitorEvent({
3053
+ type: "onDragMove",
3054
+ event
3055
+ });
3056
+ });
3057
+ },
3058
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3059
+ [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]
3060
+ );
3061
+ React.useEffect(
3062
+ () => {
3063
+ const {
3064
+ active: active2,
3065
+ activatorEvent: activatorEvent2,
3066
+ collisions: collisions2,
3067
+ droppableContainers: droppableContainers2,
3068
+ scrollAdjustedTranslate: scrollAdjustedTranslate2
3069
+ } = sensorContext.current;
3070
+ if (!active2 || activeRef.current == null || !activatorEvent2 || !scrollAdjustedTranslate2) {
3071
+ return;
3072
+ }
3073
+ const {
3074
+ onDragOver
3075
+ } = latestProps.current;
3076
+ const overContainer = droppableContainers2.get(overId);
3077
+ const over2 = overContainer && overContainer.rect.current ? {
3078
+ id: overContainer.id,
3079
+ rect: overContainer.rect.current,
3080
+ data: overContainer.data,
3081
+ disabled: overContainer.disabled
3082
+ } : null;
3083
+ const event = {
3084
+ active: active2,
3085
+ activatorEvent: activatorEvent2,
3086
+ collisions: collisions2,
3087
+ delta: {
3088
+ x: scrollAdjustedTranslate2.x,
3089
+ y: scrollAdjustedTranslate2.y
3090
+ },
3091
+ over: over2
3092
+ };
3093
+ require$$2.unstable_batchedUpdates(() => {
3094
+ setOver(over2);
3095
+ onDragOver == null ? void 0 : onDragOver(event);
3096
+ dispatchMonitorEvent({
3097
+ type: "onDragOver",
3098
+ event
3099
+ });
3100
+ });
3101
+ },
3102
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3103
+ [overId]
3104
+ );
3105
+ useIsomorphicLayoutEffect(() => {
3106
+ sensorContext.current = {
3107
+ activatorEvent,
3108
+ active,
3109
+ activeNode,
3110
+ collisionRect,
3111
+ collisions,
3112
+ droppableRects,
3113
+ draggableNodes,
3114
+ draggingNode,
3115
+ draggingNodeRect,
3116
+ droppableContainers,
3117
+ over,
3118
+ scrollableAncestors,
3119
+ scrollAdjustedTranslate
3120
+ };
3121
+ activeRects.current = {
3122
+ initial: draggingNodeRect,
3123
+ translated: collisionRect
3124
+ };
3125
+ }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
3126
+ useAutoScroller({
3127
+ ...autoScrollOptions,
3128
+ delta: translate,
3129
+ draggingRect: collisionRect,
3130
+ pointerCoordinates,
3131
+ scrollableAncestors,
3132
+ scrollableAncestorRects
3133
+ });
3134
+ const publicContext = React.useMemo(() => {
3135
+ const context = {
3136
+ active,
3137
+ activeNode,
3138
+ activeNodeRect,
3139
+ activatorEvent,
3140
+ collisions,
3141
+ containerNodeRect,
3142
+ dragOverlay,
3143
+ draggableNodes,
3144
+ droppableContainers,
3145
+ droppableRects,
3146
+ over,
3147
+ measureDroppableContainers,
3148
+ scrollableAncestors,
3149
+ scrollableAncestorRects,
3150
+ measuringConfiguration,
3151
+ measuringScheduled,
3152
+ windowRect
3153
+ };
3154
+ return context;
3155
+ }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
3156
+ const internalContext = React.useMemo(() => {
3157
+ const context = {
3158
+ activatorEvent,
3159
+ activators,
3160
+ active,
3161
+ activeNodeRect,
3162
+ ariaDescribedById: {
3163
+ draggable: draggableDescribedById
3164
+ },
3165
+ dispatch,
3166
+ draggableNodes,
3167
+ over,
3168
+ measureDroppableContainers
3169
+ };
3170
+ return context;
3171
+ }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
3172
+ return React.createElement(DndMonitorContext.Provider, {
3173
+ value: registerMonitorListener
3174
+ }, React.createElement(InternalContext.Provider, {
3175
+ value: internalContext
3176
+ }, React.createElement(PublicContext.Provider, {
3177
+ value: publicContext
3178
+ }, React.createElement(ActiveDraggableContext.Provider, {
3179
+ value: transform
3180
+ }, children)), React.createElement(RestoreFocus, {
3181
+ disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
3182
+ })), React.createElement(Accessibility, {
3183
+ ...accessibility,
3184
+ hiddenTextDescribedById: draggableDescribedById
3185
+ }));
3186
+ function getAutoScrollerOptions() {
3187
+ const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
3188
+ const autoScrollGloballyDisabled = typeof autoScroll === "object" ? autoScroll.enabled === false : autoScroll === false;
3189
+ const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
3190
+ if (typeof autoScroll === "object") {
3191
+ return {
3192
+ ...autoScroll,
3193
+ enabled
3194
+ };
3195
+ }
3196
+ return {
3197
+ enabled
3198
+ };
3199
+ }
3200
+ });
3201
+ const NullContext = /* @__PURE__ */ React.createContext(null);
3202
+ const defaultRole = "button";
3203
+ const ID_PREFIX$1 = "Draggable";
3204
+ function useDraggable(_ref) {
3205
+ let {
3206
+ id,
3207
+ data,
3208
+ disabled = false,
3209
+ attributes
3210
+ } = _ref;
3211
+ const key = useUniqueId(ID_PREFIX$1);
3212
+ const {
3213
+ activators,
3214
+ activatorEvent,
3215
+ active,
3216
+ activeNodeRect,
3217
+ ariaDescribedById,
3218
+ draggableNodes,
3219
+ over
3220
+ } = React.useContext(InternalContext);
3221
+ const {
3222
+ role = defaultRole,
3223
+ roleDescription = "draggable",
3224
+ tabIndex = 0
3225
+ } = attributes != null ? attributes : {};
3226
+ const isDragging = (active == null ? void 0 : active.id) === id;
3227
+ const transform = React.useContext(isDragging ? ActiveDraggableContext : NullContext);
3228
+ const [node, setNodeRef] = useNodeRef();
3229
+ const [activatorNode, setActivatorNodeRef] = useNodeRef();
3230
+ const listeners = useSyntheticListeners(activators, id);
3231
+ const dataRef = useLatestValue(data);
3232
+ useIsomorphicLayoutEffect(
3233
+ () => {
3234
+ draggableNodes.set(id, {
3235
+ id,
3236
+ key,
3237
+ node,
3238
+ activatorNode,
3239
+ data: dataRef
3240
+ });
3241
+ return () => {
3242
+ const node2 = draggableNodes.get(id);
3243
+ if (node2 && node2.key === key) {
3244
+ draggableNodes.delete(id);
3245
+ }
3246
+ };
3247
+ },
3248
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3249
+ [draggableNodes, id]
3250
+ );
3251
+ const memoizedAttributes = React.useMemo(() => ({
3252
+ role,
3253
+ tabIndex,
3254
+ "aria-disabled": disabled,
3255
+ "aria-pressed": isDragging && role === defaultRole ? true : void 0,
3256
+ "aria-roledescription": roleDescription,
3257
+ "aria-describedby": ariaDescribedById.draggable
3258
+ }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
3259
+ return {
3260
+ active,
3261
+ activatorEvent,
3262
+ activeNodeRect,
3263
+ attributes: memoizedAttributes,
3264
+ isDragging,
3265
+ listeners: disabled ? void 0 : listeners,
3266
+ node,
3267
+ over,
3268
+ setNodeRef,
3269
+ setActivatorNodeRef,
3270
+ transform
3271
+ };
3272
+ }
3273
+ function useDndContext() {
3274
+ return React.useContext(PublicContext);
3275
+ }
3276
+ const ID_PREFIX$1$1 = "Droppable";
3277
+ const defaultResizeObserverConfig = {
3278
+ timeout: 25
3279
+ };
3280
+ function useDroppable(_ref) {
3281
+ let {
3282
+ data,
3283
+ disabled = false,
3284
+ id,
3285
+ resizeObserverConfig
3286
+ } = _ref;
3287
+ const key = useUniqueId(ID_PREFIX$1$1);
3288
+ const {
3289
+ active,
3290
+ dispatch,
3291
+ over,
3292
+ measureDroppableContainers
3293
+ } = React.useContext(InternalContext);
3294
+ const previous = React.useRef({
3295
+ disabled
3296
+ });
3297
+ const resizeObserverConnected = React.useRef(false);
3298
+ const rect = React.useRef(null);
3299
+ const callbackId = React.useRef(null);
3300
+ const {
3301
+ disabled: resizeObserverDisabled,
3302
+ updateMeasurementsFor,
3303
+ timeout: resizeObserverTimeout
3304
+ } = {
3305
+ ...defaultResizeObserverConfig,
3306
+ ...resizeObserverConfig
3307
+ };
3308
+ const ids2 = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
3309
+ const handleResize = React.useCallback(
3310
+ () => {
3311
+ if (!resizeObserverConnected.current) {
3312
+ resizeObserverConnected.current = true;
3313
+ return;
3314
+ }
3315
+ if (callbackId.current != null) {
3316
+ clearTimeout(callbackId.current);
3317
+ }
3318
+ callbackId.current = setTimeout(() => {
3319
+ measureDroppableContainers(Array.isArray(ids2.current) ? ids2.current : [ids2.current]);
3320
+ callbackId.current = null;
3321
+ }, resizeObserverTimeout);
3322
+ },
3323
+ //eslint-disable-next-line react-hooks/exhaustive-deps
3324
+ [resizeObserverTimeout]
3325
+ );
3326
+ const resizeObserver = useResizeObserver({
3327
+ callback: handleResize,
3328
+ disabled: resizeObserverDisabled || !active
3329
+ });
3330
+ const handleNodeChange = React.useCallback((newElement, previousElement) => {
3331
+ if (!resizeObserver) {
3332
+ return;
3333
+ }
3334
+ if (previousElement) {
3335
+ resizeObserver.unobserve(previousElement);
3336
+ resizeObserverConnected.current = false;
3337
+ }
3338
+ if (newElement) {
3339
+ resizeObserver.observe(newElement);
3340
+ }
3341
+ }, [resizeObserver]);
3342
+ const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
3343
+ const dataRef = useLatestValue(data);
3344
+ React.useEffect(() => {
3345
+ if (!resizeObserver || !nodeRef.current) {
3346
+ return;
3347
+ }
3348
+ resizeObserver.disconnect();
3349
+ resizeObserverConnected.current = false;
3350
+ resizeObserver.observe(nodeRef.current);
3351
+ }, [nodeRef, resizeObserver]);
3352
+ React.useEffect(
3353
+ () => {
3354
+ dispatch({
3355
+ type: Action.RegisterDroppable,
3356
+ element: {
3357
+ id,
3358
+ key,
3359
+ disabled,
3360
+ node: nodeRef,
3361
+ rect,
3362
+ data: dataRef
3363
+ }
3364
+ });
3365
+ return () => dispatch({
3366
+ type: Action.UnregisterDroppable,
3367
+ key,
3368
+ id
3369
+ });
3370
+ },
3371
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3372
+ [id]
3373
+ );
3374
+ React.useEffect(() => {
3375
+ if (disabled !== previous.current.disabled) {
3376
+ dispatch({
3377
+ type: Action.SetDroppableDisabled,
3378
+ id,
3379
+ key,
3380
+ disabled
3381
+ });
3382
+ previous.current.disabled = disabled;
3383
+ }
3384
+ }, [id, key, disabled, dispatch]);
3385
+ return {
3386
+ active,
3387
+ rect,
3388
+ isOver: (over == null ? void 0 : over.id) === id,
3389
+ node: nodeRef,
3390
+ over,
3391
+ setNodeRef
3392
+ };
3393
+ }
3394
+ function arrayMove(array, from, to) {
3395
+ const newArray = array.slice();
3396
+ newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
3397
+ return newArray;
3398
+ }
3399
+ function getSortedRects(items, rects) {
3400
+ return items.reduce((accumulator, id, index2) => {
3401
+ const rect = rects.get(id);
3402
+ if (rect) {
3403
+ accumulator[index2] = rect;
3404
+ }
3405
+ return accumulator;
3406
+ }, Array(items.length));
3407
+ }
3408
+ function isValidIndex(index2) {
3409
+ return index2 !== null && index2 >= 0;
3410
+ }
3411
+ function itemsEqual(a, b) {
3412
+ if (a === b) {
3413
+ return true;
3414
+ }
3415
+ if (a.length !== b.length) {
3416
+ return false;
3417
+ }
3418
+ for (let i = 0; i < a.length; i++) {
3419
+ if (a[i] !== b[i]) {
3420
+ return false;
3421
+ }
3422
+ }
3423
+ return true;
3424
+ }
3425
+ function normalizeDisabled(disabled) {
3426
+ if (typeof disabled === "boolean") {
3427
+ return {
3428
+ draggable: disabled,
3429
+ droppable: disabled
3430
+ };
3431
+ }
3432
+ return disabled;
3433
+ }
3434
+ const rectSortingStrategy = (_ref) => {
3435
+ let {
3436
+ rects,
3437
+ activeIndex,
3438
+ overIndex,
3439
+ index: index2
3440
+ } = _ref;
3441
+ const newRects = arrayMove(rects, overIndex, activeIndex);
3442
+ const oldRect = rects[index2];
3443
+ const newRect = newRects[index2];
3444
+ if (!newRect || !oldRect) {
3445
+ return null;
3446
+ }
3447
+ return {
3448
+ x: newRect.left - oldRect.left,
3449
+ y: newRect.top - oldRect.top,
3450
+ scaleX: newRect.width / oldRect.width,
3451
+ scaleY: newRect.height / oldRect.height
3452
+ };
3453
+ };
3454
+ const defaultScale$1 = {
3455
+ scaleX: 1,
3456
+ scaleY: 1
3457
+ };
3458
+ const verticalListSortingStrategy = (_ref) => {
3459
+ var _rects$activeIndex;
3460
+ let {
3461
+ activeIndex,
3462
+ activeNodeRect: fallbackActiveRect,
3463
+ index: index2,
3464
+ rects,
3465
+ overIndex
3466
+ } = _ref;
3467
+ const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect;
3468
+ if (!activeNodeRect) {
3469
+ return null;
3470
+ }
3471
+ if (index2 === activeIndex) {
3472
+ const overIndexRect = rects[overIndex];
3473
+ if (!overIndexRect) {
3474
+ return null;
3475
+ }
3476
+ return {
3477
+ x: 0,
3478
+ y: activeIndex < overIndex ? overIndexRect.top + overIndexRect.height - (activeNodeRect.top + activeNodeRect.height) : overIndexRect.top - activeNodeRect.top,
3479
+ ...defaultScale$1
3480
+ };
3481
+ }
3482
+ const itemGap = getItemGap$1(rects, index2, activeIndex);
3483
+ if (index2 > activeIndex && index2 <= overIndex) {
3484
+ return {
3485
+ x: 0,
3486
+ y: -activeNodeRect.height - itemGap,
3487
+ ...defaultScale$1
3488
+ };
3489
+ }
3490
+ if (index2 < activeIndex && index2 >= overIndex) {
3491
+ return {
3492
+ x: 0,
3493
+ y: activeNodeRect.height + itemGap,
3494
+ ...defaultScale$1
3495
+ };
3496
+ }
3497
+ return {
3498
+ x: 0,
3499
+ y: 0,
3500
+ ...defaultScale$1
3501
+ };
3502
+ };
3503
+ function getItemGap$1(clientRects, index2, activeIndex) {
3504
+ const currentRect = clientRects[index2];
3505
+ const previousRect = clientRects[index2 - 1];
3506
+ const nextRect = clientRects[index2 + 1];
3507
+ if (!currentRect) {
3508
+ return 0;
3509
+ }
3510
+ if (activeIndex < index2) {
3511
+ return previousRect ? currentRect.top - (previousRect.top + previousRect.height) : nextRect ? nextRect.top - (currentRect.top + currentRect.height) : 0;
3512
+ }
3513
+ return nextRect ? nextRect.top - (currentRect.top + currentRect.height) : previousRect ? currentRect.top - (previousRect.top + previousRect.height) : 0;
3514
+ }
3515
+ const ID_PREFIX = "Sortable";
3516
+ const Context = /* @__PURE__ */ React.createContext({
3517
+ activeIndex: -1,
3518
+ containerId: ID_PREFIX,
3519
+ disableTransforms: false,
3520
+ items: [],
3521
+ overIndex: -1,
3522
+ useDragOverlay: false,
3523
+ sortedRects: [],
3524
+ strategy: rectSortingStrategy,
3525
+ disabled: {
3526
+ draggable: false,
3527
+ droppable: false
3528
+ }
3529
+ });
3530
+ function SortableContext(_ref) {
3531
+ let {
3532
+ children,
3533
+ id,
3534
+ items: userDefinedItems,
3535
+ strategy = rectSortingStrategy,
3536
+ disabled: disabledProp = false
3537
+ } = _ref;
3538
+ const {
3539
+ active,
3540
+ dragOverlay,
3541
+ droppableRects,
3542
+ over,
3543
+ measureDroppableContainers
3544
+ } = useDndContext();
3545
+ const containerId = useUniqueId(ID_PREFIX, id);
3546
+ const useDragOverlay = Boolean(dragOverlay.rect !== null);
3547
+ const items = React.useMemo(() => userDefinedItems.map((item) => typeof item === "object" && "id" in item ? item.id : item), [userDefinedItems]);
3548
+ const isDragging = active != null;
3549
+ const activeIndex = active ? items.indexOf(active.id) : -1;
3550
+ const overIndex = over ? items.indexOf(over.id) : -1;
3551
+ const previousItemsRef = React.useRef(items);
3552
+ const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
3553
+ const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
3554
+ const disabled = normalizeDisabled(disabledProp);
3555
+ useIsomorphicLayoutEffect(() => {
3556
+ if (itemsHaveChanged && isDragging) {
3557
+ measureDroppableContainers(items);
3558
+ }
3559
+ }, [itemsHaveChanged, items, isDragging, measureDroppableContainers]);
3560
+ React.useEffect(() => {
3561
+ previousItemsRef.current = items;
3562
+ }, [items]);
3563
+ const contextValue = React.useMemo(
3564
+ () => ({
3565
+ activeIndex,
3566
+ containerId,
3567
+ disabled,
3568
+ disableTransforms,
3569
+ items,
3570
+ overIndex,
3571
+ useDragOverlay,
3572
+ sortedRects: getSortedRects(items, droppableRects),
3573
+ strategy
3574
+ }),
3575
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3576
+ [activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]
3577
+ );
3578
+ return React.createElement(Context.Provider, {
3579
+ value: contextValue
3580
+ }, children);
3581
+ }
3582
+ const defaultNewIndexGetter = (_ref) => {
3583
+ let {
3584
+ id,
3585
+ items,
3586
+ activeIndex,
3587
+ overIndex
3588
+ } = _ref;
3589
+ return arrayMove(items, activeIndex, overIndex).indexOf(id);
3590
+ };
3591
+ const defaultAnimateLayoutChanges = (_ref2) => {
3592
+ let {
3593
+ containerId,
3594
+ isSorting,
3595
+ wasDragging,
3596
+ index: index2,
3597
+ items,
3598
+ newIndex,
3599
+ previousItems,
3600
+ previousContainerId,
3601
+ transition
3602
+ } = _ref2;
3603
+ if (!transition || !wasDragging) {
3604
+ return false;
3605
+ }
3606
+ if (previousItems !== items && index2 === newIndex) {
3607
+ return false;
3608
+ }
3609
+ if (isSorting) {
3610
+ return true;
3611
+ }
3612
+ return newIndex !== index2 && containerId === previousContainerId;
3613
+ };
3614
+ const defaultTransition = {
3615
+ duration: 200,
3616
+ easing: "ease"
3617
+ };
3618
+ const transitionProperty = "transform";
3619
+ const disabledTransition = /* @__PURE__ */ CSS.Transition.toString({
3620
+ property: transitionProperty,
3621
+ duration: 0,
3622
+ easing: "linear"
3623
+ });
3624
+ const defaultAttributes = {
3625
+ roleDescription: "sortable"
3626
+ };
3627
+ function useDerivedTransform(_ref) {
3628
+ let {
3629
+ disabled,
3630
+ index: index2,
3631
+ node,
3632
+ rect
3633
+ } = _ref;
3634
+ const [derivedTransform, setDerivedtransform] = React.useState(null);
3635
+ const previousIndex = React.useRef(index2);
3636
+ useIsomorphicLayoutEffect(() => {
3637
+ if (!disabled && index2 !== previousIndex.current && node.current) {
3638
+ const initial = rect.current;
3639
+ if (initial) {
3640
+ const current = getClientRect(node.current, {
3641
+ ignoreTransform: true
3642
+ });
3643
+ const delta = {
3644
+ x: initial.left - current.left,
3645
+ y: initial.top - current.top,
3646
+ scaleX: initial.width / current.width,
3647
+ scaleY: initial.height / current.height
3648
+ };
3649
+ if (delta.x || delta.y) {
3650
+ setDerivedtransform(delta);
3651
+ }
3652
+ }
3653
+ }
3654
+ if (index2 !== previousIndex.current) {
3655
+ previousIndex.current = index2;
3656
+ }
3657
+ }, [disabled, index2, node, rect]);
3658
+ React.useEffect(() => {
3659
+ if (derivedTransform) {
3660
+ setDerivedtransform(null);
3661
+ }
3662
+ }, [derivedTransform]);
3663
+ return derivedTransform;
3664
+ }
3665
+ function useSortable(_ref) {
3666
+ let {
3667
+ animateLayoutChanges = defaultAnimateLayoutChanges,
3668
+ attributes: userDefinedAttributes,
3669
+ disabled: localDisabled,
3670
+ data: customData,
3671
+ getNewIndex = defaultNewIndexGetter,
3672
+ id,
3673
+ strategy: localStrategy,
3674
+ resizeObserverConfig,
3675
+ transition = defaultTransition
3676
+ } = _ref;
3677
+ const {
3678
+ items,
3679
+ containerId,
3680
+ activeIndex,
3681
+ disabled: globalDisabled,
3682
+ disableTransforms,
3683
+ sortedRects,
3684
+ overIndex,
3685
+ useDragOverlay,
3686
+ strategy: globalStrategy
3687
+ } = React.useContext(Context);
3688
+ const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
3689
+ const index2 = items.indexOf(id);
3690
+ const data = React.useMemo(() => ({
3691
+ sortable: {
3692
+ containerId,
3693
+ index: index2,
3694
+ items
3695
+ },
3696
+ ...customData
3697
+ }), [containerId, customData, index2, items]);
3698
+ const itemsAfterCurrentSortable = React.useMemo(() => items.slice(items.indexOf(id)), [items, id]);
3699
+ const {
3700
+ rect,
3701
+ node,
3702
+ isOver,
3703
+ setNodeRef: setDroppableNodeRef
3704
+ } = useDroppable({
3705
+ id,
3706
+ data,
3707
+ disabled: disabled.droppable,
3708
+ resizeObserverConfig: {
3709
+ updateMeasurementsFor: itemsAfterCurrentSortable,
3710
+ ...resizeObserverConfig
3711
+ }
3712
+ });
3713
+ const {
3714
+ active,
3715
+ activatorEvent,
3716
+ activeNodeRect,
3717
+ attributes,
3718
+ setNodeRef: setDraggableNodeRef,
3719
+ listeners,
3720
+ isDragging,
3721
+ over,
3722
+ setActivatorNodeRef,
3723
+ transform
3724
+ } = useDraggable({
3725
+ id,
3726
+ data,
3727
+ attributes: {
3728
+ ...defaultAttributes,
3729
+ ...userDefinedAttributes
3730
+ },
3731
+ disabled: disabled.draggable
3732
+ });
3733
+ const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
3734
+ const isSorting = Boolean(active);
3735
+ const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex);
3736
+ const shouldDisplaceDragSource = !useDragOverlay && isDragging;
3737
+ const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null;
3738
+ const strategy = localStrategy != null ? localStrategy : globalStrategy;
3739
+ const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : strategy({
3740
+ rects: sortedRects,
3741
+ activeNodeRect,
3742
+ activeIndex,
3743
+ overIndex,
3744
+ index: index2
3745
+ }) : null;
3746
+ const newIndex = isValidIndex(activeIndex) && isValidIndex(overIndex) ? getNewIndex({
3747
+ id,
3748
+ items,
3749
+ activeIndex,
3750
+ overIndex
3751
+ }) : index2;
3752
+ const activeId = active == null ? void 0 : active.id;
3753
+ const previous = React.useRef({
3754
+ activeId,
3755
+ items,
3756
+ newIndex,
3757
+ containerId
3758
+ });
3759
+ const itemsHaveChanged = items !== previous.current.items;
3760
+ const shouldAnimateLayoutChanges = animateLayoutChanges({
3761
+ active,
3762
+ containerId,
3763
+ isDragging,
3764
+ isSorting,
3765
+ id,
3766
+ index: index2,
3767
+ items,
3768
+ newIndex: previous.current.newIndex,
3769
+ previousItems: previous.current.items,
3770
+ previousContainerId: previous.current.containerId,
3771
+ transition,
3772
+ wasDragging: previous.current.activeId != null
3773
+ });
3774
+ const derivedTransform = useDerivedTransform({
3775
+ disabled: !shouldAnimateLayoutChanges,
3776
+ index: index2,
3777
+ node,
3778
+ rect
3779
+ });
3780
+ React.useEffect(() => {
3781
+ if (isSorting && previous.current.newIndex !== newIndex) {
3782
+ previous.current.newIndex = newIndex;
3783
+ }
3784
+ if (containerId !== previous.current.containerId) {
3785
+ previous.current.containerId = containerId;
3786
+ }
3787
+ if (items !== previous.current.items) {
3788
+ previous.current.items = items;
3789
+ }
3790
+ }, [isSorting, newIndex, containerId, items]);
3791
+ React.useEffect(() => {
3792
+ if (activeId === previous.current.activeId) {
3793
+ return;
3794
+ }
3795
+ if (activeId != null && previous.current.activeId == null) {
3796
+ previous.current.activeId = activeId;
3797
+ return;
3798
+ }
3799
+ const timeoutId = setTimeout(() => {
3800
+ previous.current.activeId = activeId;
3801
+ }, 50);
3802
+ return () => clearTimeout(timeoutId);
3803
+ }, [activeId]);
3804
+ return {
3805
+ active,
3806
+ activeIndex,
3807
+ attributes,
3808
+ data,
3809
+ rect,
3810
+ index: index2,
3811
+ newIndex,
3812
+ items,
3813
+ isOver,
3814
+ isSorting,
3815
+ isDragging,
3816
+ listeners,
3817
+ node,
3818
+ overIndex,
3819
+ over,
3820
+ setNodeRef,
3821
+ setActivatorNodeRef,
3822
+ setDroppableNodeRef,
3823
+ setDraggableNodeRef,
3824
+ transform: derivedTransform != null ? derivedTransform : finalTransform,
3825
+ transition: getTransition()
3826
+ };
3827
+ function getTransition() {
3828
+ if (
3829
+ // Temporarily disable transitions for a single frame to set up derived transforms
3830
+ derivedTransform || // Or to prevent items jumping to back to their "new" position when items change
3831
+ itemsHaveChanged && previous.current.newIndex === index2
3832
+ ) {
3833
+ return disabledTransition;
3834
+ }
3835
+ if (shouldDisplaceDragSource && !isKeyboardEvent(activatorEvent) || !transition) {
3836
+ return void 0;
3837
+ }
3838
+ if (isSorting || shouldAnimateLayoutChanges) {
3839
+ return CSS.Transition.toString({
3840
+ ...transition,
3841
+ property: transitionProperty
3842
+ });
3843
+ }
3844
+ return void 0;
3845
+ }
3846
+ }
3847
+ function normalizeLocalDisabled(localDisabled, globalDisabled) {
3848
+ var _localDisabled$dragga, _localDisabled$droppa;
3849
+ if (typeof localDisabled === "boolean") {
3850
+ return {
3851
+ draggable: localDisabled,
3852
+ // Backwards compatibility
3853
+ droppable: false
3854
+ };
3855
+ }
3856
+ return {
3857
+ draggable: (_localDisabled$dragga = localDisabled == null ? void 0 : localDisabled.draggable) != null ? _localDisabled$dragga : globalDisabled.draggable,
3858
+ droppable: (_localDisabled$droppa = localDisabled == null ? void 0 : localDisabled.droppable) != null ? _localDisabled$droppa : globalDisabled.droppable
3859
+ };
3860
+ }
3861
+ [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
3862
+ exports.CSS = CSS;
3863
+ exports.DndContext = DndContext;
3864
+ exports.InternalRequestError = InternalRequestError;
3865
+ exports.Logo = Logo;
3866
+ exports.MouseSensor = MouseSensor;
3867
+ exports.SortableContext = SortableContext;
3868
+ exports.arrayMove = arrayMove;
3869
+ exports.useSensor = useSensor;
3870
+ exports.useSensors = useSensors;
3871
+ exports.useSortable = useSortable;
3872
+ exports.verticalListSortingStrategy = verticalListSortingStrategy;