@aws-amplify/ui-react 5.3.2 → 6.0.1

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 (478) hide show
  1. package/dist/Field-6c0e096a.js +1174 -0
  2. package/dist/esm/PrimitiveCatalog.mjs +16255 -1
  3. package/dist/esm/components/AccountSettings/AccountSettings.mjs +6 -1
  4. package/dist/esm/components/AccountSettings/ChangePassword/ChangePassword.mjs +209 -1
  5. package/dist/esm/components/AccountSettings/ChangePassword/defaults.mjs +77 -1
  6. package/dist/esm/components/AccountSettings/DeleteUser/DeleteUser.mjs +156 -1
  7. package/dist/esm/components/AccountSettings/DeleteUser/defaults.mjs +85 -1
  8. package/dist/esm/components/AccountSettings/constants.mjs +7 -1
  9. package/dist/esm/components/AccountSettings/shared/Defaults.mjs +66 -1
  10. package/dist/esm/components/AccountSettings/utils/displayText.mjs +14 -0
  11. package/dist/esm/components/Authenticator/Authenticator.mjs +74 -1
  12. package/dist/esm/components/Authenticator/ConfirmSignIn/ConfirmSignIn.mjs +42 -1
  13. package/dist/esm/components/Authenticator/ConfirmSignUp/ConfirmSignUp.mjs +51 -1
  14. package/dist/esm/components/Authenticator/FederatedSignIn/FederatedSignIn.mjs +34 -1
  15. package/dist/esm/components/Authenticator/FederatedSignIn/FederatedSignInButtons/FederatedSignInButton.mjs +54 -1
  16. package/dist/esm/components/Authenticator/ForceNewPassword/ForceNewPassword.mjs +43 -1
  17. package/dist/esm/components/Authenticator/ForgotPassword/ConfirmResetPassword.mjs +39 -0
  18. package/dist/esm/components/Authenticator/ForgotPassword/ForgotPassword.mjs +40 -0
  19. package/dist/esm/components/Authenticator/RouteContainer/RouteContainer.mjs +26 -1
  20. package/dist/esm/components/Authenticator/Router/Router.mjs +63 -1
  21. package/dist/esm/components/Authenticator/SetupTotp/SetupTotp.mjs +76 -0
  22. package/dist/esm/components/Authenticator/SignIn/SignIn.mjs +47 -1
  23. package/dist/esm/components/Authenticator/SignUp/SignUp.mjs +46 -1
  24. package/dist/esm/components/Authenticator/VerifyUser/ConfirmVerifyUser.mjs +37 -1
  25. package/dist/esm/components/Authenticator/VerifyUser/VerifyUser.mjs +59 -1
  26. package/dist/esm/components/Authenticator/hooks/useCustomComponents/defaultComponents.mjs +62 -1
  27. package/dist/esm/components/Authenticator/hooks/useCustomComponents/useCustomComponents.mjs +14 -1
  28. package/dist/esm/components/Authenticator/hooks/useFormHandlers/useFormHandlers.mjs +30 -1
  29. package/dist/esm/components/Authenticator/shared/ConfirmSignInFooter.mjs +18 -1
  30. package/dist/esm/components/Authenticator/shared/FormField.mjs +35 -1
  31. package/dist/esm/components/Authenticator/shared/FormFields.mjs +15 -1
  32. package/dist/esm/components/Authenticator/shared/RemoteErrorMessage.mjs +11 -1
  33. package/dist/esm/components/Authenticator/shared/SignInSignUpTabs.mjs +27 -1
  34. package/dist/esm/components/Authenticator/shared/TwoButtonSubmitFooter.mjs +35 -1
  35. package/dist/esm/components/Authenticator/utils.mjs +3 -1
  36. package/dist/esm/components/Authenticator/withAuthenticator.mjs +14 -1
  37. package/dist/esm/components/ThemeProvider/ThemeContext.mjs +8 -0
  38. package/dist/esm/components/ThemeProvider/ThemeProvider.mjs +23 -1
  39. package/dist/esm/components/index.mjs +5 -1
  40. package/dist/esm/components/shared/ValidationErrors.mjs +15 -1
  41. package/dist/esm/helpers/utils.mjs +6 -1
  42. package/dist/esm/hooks/useAuth.mjs +73 -1
  43. package/dist/esm/hooks/useBreakpointValue.mjs +29 -1
  44. package/dist/esm/hooks/useComposeRefsCallback.mjs +20 -1
  45. package/dist/esm/hooks/useDeprecationWarning.mjs +15 -1
  46. package/dist/esm/hooks/useStorageURL.mjs +40 -1
  47. package/dist/esm/hooks/useTheme.mjs +23 -1
  48. package/dist/esm/hooks/useThemeBreakpoint.mjs +19 -1
  49. package/dist/esm/index.mjs +71 -1
  50. package/dist/esm/internal.mjs +32 -1
  51. package/dist/esm/primitives/Accordion/Accordion.mjs +28 -0
  52. package/dist/esm/primitives/Accordion/AccordionContainer.mjs +49 -0
  53. package/dist/esm/primitives/Accordion/AccordionContent.mjs +15 -0
  54. package/dist/esm/primitives/Accordion/AccordionContext.mjs +6 -0
  55. package/dist/esm/primitives/Accordion/AccordionIcon.mjs +20 -0
  56. package/dist/esm/primitives/Accordion/AccordionItem.mjs +19 -0
  57. package/dist/esm/primitives/Accordion/AccordionTrigger.mjs +27 -0
  58. package/dist/esm/primitives/Alert/Alert.mjs +36 -1
  59. package/dist/esm/primitives/Alert/AlertIcon.mjs +36 -1
  60. package/dist/esm/primitives/Autocomplete/Autocomplete.mjs +67 -1
  61. package/dist/esm/primitives/Autocomplete/AutocompleteMenu.mjs +36 -1
  62. package/dist/esm/primitives/Autocomplete/AutocompleteOption.mjs +12 -1
  63. package/dist/esm/primitives/Autocomplete/useAutocomplete.mjs +188 -1
  64. package/dist/esm/primitives/Badge/Badge.mjs +16 -1
  65. package/dist/esm/primitives/Breadcrumbs/BreadcrumbContainer.mjs +18 -1
  66. package/dist/esm/primitives/Breadcrumbs/BreadcrumbItem.mjs +16 -1
  67. package/dist/esm/primitives/Breadcrumbs/BreadcrumbLink.mjs +24 -1
  68. package/dist/esm/primitives/Breadcrumbs/BreadcrumbSeparator.mjs +16 -1
  69. package/dist/esm/primitives/Breadcrumbs/Breadcrumbs.mjs +28 -1
  70. package/dist/esm/primitives/Button/Button.mjs +33 -1
  71. package/dist/esm/primitives/ButtonGroup/ButtonGroup.mjs +19 -1
  72. package/dist/esm/primitives/Card/Card.mjs +15 -1
  73. package/dist/esm/primitives/Checkbox/Checkbox.mjs +84 -1
  74. package/dist/esm/primitives/CheckboxField/CheckboxField.mjs +24 -1
  75. package/dist/esm/primitives/Collection/Collection.mjs +58 -1
  76. package/dist/esm/primitives/Collection/utils.mjs +30 -1
  77. package/dist/esm/primitives/Divider/Divider.mjs +16 -1
  78. package/dist/esm/primitives/DropZone/DropZone.mjs +27 -1
  79. package/dist/esm/primitives/DropZone/DropZoneChildren.mjs +39 -1
  80. package/dist/esm/primitives/DropZone/DropZoneContainer.mjs +18 -1
  81. package/dist/esm/primitives/DropZone/DropZoneProvider.mjs +8 -1
  82. package/dist/esm/primitives/DropZone/filterAllowedFiles.mjs +34 -1
  83. package/dist/esm/primitives/DropZone/useDropZone.mjs +65 -1
  84. package/dist/esm/primitives/Field/Field.mjs +20 -1
  85. package/dist/esm/primitives/Field/FieldClearButton.mjs +21 -1
  86. package/dist/esm/primitives/Field/FieldDescription.mjs +11 -1
  87. package/dist/esm/primitives/Field/FieldErrorMessage.mjs +10 -1
  88. package/dist/esm/primitives/FieldGroup/FieldGroup.mjs +29 -1
  89. package/dist/esm/primitives/FieldGroupIcon/FieldGroupIcon.mjs +12 -1
  90. package/dist/esm/primitives/FieldGroupIcon/FieldGroupIconButton.mjs +11 -1
  91. package/dist/esm/primitives/Fieldset/Fieldset.mjs +33 -1
  92. package/dist/esm/primitives/Fieldset/useFieldset.mjs +13 -1
  93. package/dist/esm/primitives/Flex/Flex.mjs +13 -1
  94. package/dist/esm/primitives/Grid/Grid.mjs +13 -1
  95. package/dist/esm/primitives/Heading/Heading.mjs +21 -1
  96. package/dist/esm/primitives/HighlightMatch/HighlightMatch.mjs +28 -1
  97. package/dist/esm/primitives/Icon/Icon.mjs +36 -1
  98. package/dist/esm/primitives/Icon/context/IconsContext.mjs +5 -1
  99. package/dist/esm/primitives/Icon/context/IconsProvider.mjs +8 -1
  100. package/dist/esm/primitives/Icon/context/useIcons.mjs +12 -1
  101. package/dist/esm/primitives/Icon/icons/IconAdd.mjs +15 -1
  102. package/dist/esm/primitives/Icon/icons/IconCheck.mjs +15 -1
  103. package/dist/esm/primitives/Icon/icons/IconCheckCircle.mjs +15 -1
  104. package/dist/esm/primitives/Icon/icons/IconCheckCircleOutline.mjs +13 -1
  105. package/dist/esm/primitives/Icon/icons/IconChevronLeft.mjs +15 -1
  106. package/dist/esm/primitives/Icon/icons/IconChevronRight.mjs +15 -1
  107. package/dist/esm/primitives/Icon/icons/IconClose.mjs +15 -1
  108. package/dist/esm/primitives/Icon/icons/IconEdit.mjs +15 -1
  109. package/dist/esm/primitives/Icon/icons/IconError.mjs +15 -1
  110. package/dist/esm/primitives/Icon/icons/IconExpandMore.mjs +15 -1
  111. package/dist/esm/primitives/Icon/icons/IconFile.mjs +15 -1
  112. package/dist/esm/primitives/Icon/icons/IconIndeterminate.mjs +15 -1
  113. package/dist/esm/primitives/Icon/icons/IconInfo.mjs +15 -1
  114. package/dist/esm/primitives/Icon/icons/IconMenu.mjs +15 -1
  115. package/dist/esm/primitives/Icon/icons/IconRemove.mjs +15 -1
  116. package/dist/esm/primitives/Icon/icons/IconSearch.mjs +15 -1
  117. package/dist/esm/primitives/Icon/icons/IconStar.mjs +15 -1
  118. package/dist/esm/primitives/Icon/icons/IconUpload.mjs +15 -1
  119. package/dist/esm/primitives/Icon/icons/IconVisibility.mjs +15 -1
  120. package/dist/esm/primitives/Icon/icons/IconVisibilityOff.mjs +15 -1
  121. package/dist/esm/primitives/Icon/icons/IconWarning.mjs +15 -1
  122. package/dist/esm/primitives/Image/Image.mjs +13 -1
  123. package/dist/esm/primitives/Input/Input.mjs +15 -1
  124. package/dist/esm/primitives/Label/Label.mjs +14 -1
  125. package/dist/esm/primitives/Link/Link.mjs +15 -1
  126. package/dist/esm/primitives/Loader/Loader.mjs +56 -1
  127. package/dist/esm/primitives/Menu/Menu.mjs +31 -1
  128. package/dist/esm/primitives/Menu/MenuButton.mjs +18 -1
  129. package/dist/esm/primitives/Menu/MenuItem.mjs +22 -1
  130. package/dist/esm/primitives/Message/Message.mjs +23 -1
  131. package/dist/esm/primitives/Message/MessageContainer.mjs +19 -1
  132. package/dist/esm/primitives/Message/MessageContent.mjs +12 -1
  133. package/dist/esm/primitives/Message/MessageDismiss.mjs +28 -1
  134. package/dist/esm/primitives/Message/MessageHeading.mjs +12 -1
  135. package/dist/esm/primitives/Message/MessageIcon.mjs +35 -1
  136. package/dist/esm/primitives/Message/useMessage.mjs +9 -1
  137. package/dist/esm/primitives/Pagination/Pagination.mjs +31 -1
  138. package/dist/esm/primitives/Pagination/PaginationItem.mjs +48 -1
  139. package/dist/esm/primitives/Pagination/usePagination.mjs +41 -1
  140. package/dist/esm/primitives/Pagination/usePaginationItems.mjs +39 -1
  141. package/dist/esm/primitives/Pagination/useRange.mjs +72 -1
  142. package/dist/esm/primitives/PasswordField/PasswordField.mjs +25 -1
  143. package/dist/esm/primitives/PasswordField/ShowPasswordButton.mjs +30 -1
  144. package/dist/esm/primitives/PhoneNumberField/DialCodeSelect.mjs +21 -0
  145. package/dist/esm/primitives/PhoneNumberField/PhoneNumberField.mjs +17 -1
  146. package/dist/esm/primitives/Placeholder/Placeholder.mjs +18 -1
  147. package/dist/esm/primitives/Radio/Radio.mjs +31 -1
  148. package/dist/esm/primitives/RadioGroupField/RadioGroupField.mjs +55 -1
  149. package/dist/esm/primitives/RadioGroupField/context.mjs +9 -1
  150. package/dist/esm/primitives/Rating/Rating.mjs +44 -1
  151. package/dist/esm/primitives/Rating/RatingIcon.mjs +11 -1
  152. package/dist/esm/primitives/Rating/RatingMixedIcon.mjs +13 -1
  153. package/dist/esm/primitives/Rating/utils.mjs +18 -1
  154. package/dist/esm/primitives/ScrollView/ScrollView.mjs +13 -1
  155. package/dist/esm/primitives/SearchField/SearchField.mjs +38 -1
  156. package/dist/esm/primitives/SearchField/SearchFieldButton.mjs +21 -1
  157. package/dist/esm/primitives/SearchField/useSearchField.mjs +64 -1
  158. package/dist/esm/primitives/Select/Select.mjs +31 -1
  159. package/dist/esm/primitives/SelectField/SelectField.mjs +42 -1
  160. package/dist/esm/primitives/SliderField/SliderField.mjs +77 -1
  161. package/dist/esm/primitives/StepperField/StepperField.mjs +60 -1
  162. package/dist/esm/primitives/StepperField/useStepper.mjs +113 -1
  163. package/dist/esm/primitives/SwitchField/SwitchField.mjs +48 -1
  164. package/dist/esm/primitives/SwitchField/useSwitch.mjs +30 -1
  165. package/dist/esm/primitives/Table/Table.mjs +18 -1
  166. package/dist/esm/primitives/Table/TableBody.mjs +10 -1
  167. package/dist/esm/primitives/Table/TableCell.mjs +12 -1
  168. package/dist/esm/primitives/Table/TableFoot.mjs +10 -1
  169. package/dist/esm/primitives/Table/TableHead.mjs +10 -1
  170. package/dist/esm/primitives/Table/TableRow.mjs +10 -1
  171. package/dist/esm/primitives/Tabs/Tabs.mjs +24 -1
  172. package/dist/esm/primitives/Tabs/TabsContainer.mjs +35 -0
  173. package/dist/esm/primitives/Tabs/TabsContext.mjs +8 -0
  174. package/dist/esm/primitives/Tabs/TabsItem.mjs +24 -0
  175. package/dist/esm/primitives/Tabs/TabsList.mjs +85 -0
  176. package/dist/esm/primitives/Tabs/TabsPanel.mjs +19 -0
  177. package/dist/esm/primitives/Text/Text.mjs +16 -1
  178. package/dist/esm/primitives/TextArea/TextArea.mjs +15 -1
  179. package/dist/esm/primitives/TextAreaField/TextAreaField.mjs +36 -1
  180. package/dist/esm/primitives/TextField/TextField.mjs +34 -1
  181. package/dist/esm/primitives/ToggleButton/ToggleButton.mjs +24 -1
  182. package/dist/esm/primitives/ToggleButton/useToggleButton.mjs +23 -1
  183. package/dist/esm/primitives/ToggleButtonGroup/ToggleButtonGroup.mjs +35 -1
  184. package/dist/esm/primitives/ToggleButtonGroup/useToggleButtonGroup.mjs +36 -1
  185. package/dist/esm/primitives/View/View.mjs +23 -1
  186. package/dist/esm/primitives/VisuallyHidden/VisuallyHidden.mjs +13 -1
  187. package/dist/esm/primitives/index.mjs +63 -1
  188. package/dist/esm/primitives/shared/constants.mjs +98 -1
  189. package/dist/esm/primitives/shared/getStyleValue.mjs +25 -1
  190. package/dist/esm/primitives/shared/responsive/getMediaQueries.mjs +29 -1
  191. package/dist/esm/primitives/shared/responsive/useBreakpoint.mjs +39 -1
  192. package/dist/esm/primitives/shared/responsive/utils.mjs +51 -1
  193. package/dist/esm/primitives/shared/styleUtils.mjs +122 -1
  194. package/dist/esm/primitives/shared/utils.mjs +60 -1
  195. package/dist/esm/primitives/types/style.mjs +104 -1
  196. package/dist/esm/primitives/types/theme.mjs +7 -1
  197. package/dist/esm/primitives/utils/getTestId.mjs +3 -1
  198. package/dist/esm/primitives/utils/primitiveWithForwardRef.mjs +14 -0
  199. package/dist/esm/primitives/utils/splitPrimitiveProps.mjs +36 -1
  200. package/dist/esm/primitives/utils/useLayoutEffect.mjs +13 -1
  201. package/dist/esm/primitives/utils/useStableId.mjs +34 -1
  202. package/dist/esm/version.mjs +3 -1
  203. package/dist/index.js +3485 -1
  204. package/dist/internal.js +16403 -1
  205. package/dist/styles/StorageManager.css +138 -0
  206. package/dist/styles/StorageManager.layer.css +140 -0
  207. package/dist/styles/_fieldControl.css +0 -0
  208. package/dist/styles/_fieldControl.layer.css +3 -0
  209. package/dist/styles/accordion.css +64 -0
  210. package/dist/styles/accordion.layer.css +66 -0
  211. package/dist/styles/alert.css +44 -0
  212. package/dist/styles/alert.layer.css +46 -0
  213. package/dist/styles/authenticator.css +72 -0
  214. package/dist/styles/authenticator.layer.css +74 -0
  215. package/dist/styles/autocomplete.css +48 -0
  216. package/dist/styles/autocomplete.layer.css +50 -0
  217. package/dist/styles/badge.css +35 -0
  218. package/dist/styles/badge.layer.css +37 -0
  219. package/dist/styles/base.css +1491 -0
  220. package/dist/styles/base.layer.css +1493 -0
  221. package/dist/styles/breadcrumbs.css +40 -0
  222. package/dist/styles/breadcrumbs.layer.css +42 -0
  223. package/dist/styles/button.css +1122 -0
  224. package/dist/styles/button.layer.css +1124 -0
  225. package/dist/styles/card.css +26 -0
  226. package/dist/styles/card.layer.css +28 -0
  227. package/dist/styles/checkbox.css +95 -0
  228. package/dist/styles/checkbox.layer.css +97 -0
  229. package/dist/styles/checkboxField.css +6 -0
  230. package/dist/styles/checkboxField.layer.css +8 -0
  231. package/dist/styles/collection.css +70 -0
  232. package/dist/styles/collection.layer.css +72 -0
  233. package/dist/styles/copy.css +27 -0
  234. package/dist/styles/copy.layer.css +29 -0
  235. package/dist/styles/dialCodeSelect.css +3 -0
  236. package/dist/styles/dialCodeSelect.layer.css +5 -0
  237. package/dist/styles/divider.css +47 -0
  238. package/dist/styles/divider.layer.css +49 -0
  239. package/dist/styles/dropZone.css +45 -0
  240. package/dist/styles/dropZone.layer.css +47 -0
  241. package/dist/styles/field.css +17 -0
  242. package/dist/styles/field.layer.css +19 -0
  243. package/dist/styles/fieldGroup.css +130 -0
  244. package/dist/styles/fieldGroup.layer.css +132 -0
  245. package/dist/styles/fieldMessages.css +10 -0
  246. package/dist/styles/fieldMessages.layer.css +12 -0
  247. package/dist/styles/fieldModifiers.css +15 -0
  248. package/dist/styles/fieldModifiers.layer.css +17 -0
  249. package/dist/styles/fieldset.css +37 -0
  250. package/dist/styles/fieldset.layer.css +39 -0
  251. package/dist/styles/flex.css +8 -0
  252. package/dist/styles/flex.layer.css +10 -0
  253. package/dist/styles/grid.css +3 -0
  254. package/dist/styles/grid.layer.css +5 -0
  255. package/dist/styles/heading.css +40 -0
  256. package/dist/styles/heading.layer.css +42 -0
  257. package/dist/styles/highlightMatch.css +3 -0
  258. package/dist/styles/highlightMatch.layer.css +5 -0
  259. package/dist/styles/icon.css +14 -0
  260. package/dist/styles/icon.layer.css +16 -0
  261. package/dist/styles/image.css +9 -0
  262. package/dist/styles/image.layer.css +11 -0
  263. package/dist/styles/inAppMessaging.css +179 -0
  264. package/dist/styles/inAppMessaging.layer.css +181 -0
  265. package/dist/styles/input.css +83 -0
  266. package/dist/styles/input.layer.css +85 -0
  267. package/dist/styles/link.css +26 -0
  268. package/dist/styles/link.layer.css +28 -0
  269. package/dist/styles/liveness.css +374 -0
  270. package/dist/styles/liveness.layer.css +376 -0
  271. package/dist/styles/loader.css +108 -0
  272. package/dist/styles/loader.layer.css +110 -0
  273. package/dist/styles/menu.css +54 -0
  274. package/dist/styles/menu.layer.css +56 -0
  275. package/dist/styles/message.css +111 -0
  276. package/dist/styles/message.layer.css +113 -0
  277. package/dist/styles/pagination.css +41 -0
  278. package/dist/styles/pagination.layer.css +43 -0
  279. package/dist/styles/passwordField.css +49 -0
  280. package/dist/styles/passwordField.layer.css +51 -0
  281. package/dist/styles/phoneNumberField.css +30 -0
  282. package/dist/styles/phoneNumberField.layer.css +32 -0
  283. package/dist/styles/placeholder.css +31 -0
  284. package/dist/styles/placeholder.layer.css +33 -0
  285. package/dist/styles/radio.css +82 -0
  286. package/dist/styles/radio.layer.css +84 -0
  287. package/dist/styles/radioGroupField.css +25 -0
  288. package/dist/styles/radioGroupField.layer.css +27 -0
  289. package/dist/styles/radiogroup.css +5 -0
  290. package/dist/styles/radiogroup.layer.css +7 -0
  291. package/dist/styles/rating.css +33 -0
  292. package/dist/styles/rating.layer.css +35 -0
  293. package/dist/styles/reset.css +76 -0
  294. package/dist/styles/reset.layer.css +78 -0
  295. package/dist/styles/scrollView.css +4 -0
  296. package/dist/styles/scrollView.layer.css +6 -0
  297. package/dist/styles/searchField.css +29 -0
  298. package/dist/styles/searchField.layer.css +31 -0
  299. package/dist/styles/select.css +128 -0
  300. package/dist/styles/select.layer.css +130 -0
  301. package/dist/styles/selectField.css +18 -0
  302. package/dist/styles/selectField.layer.css +20 -0
  303. package/dist/styles/sliderField.css +143 -0
  304. package/dist/styles/sliderField.layer.css +145 -0
  305. package/dist/styles/stepperField.css +77 -0
  306. package/dist/styles/stepperField.layer.css +79 -0
  307. package/dist/styles/switchField.css +76 -0
  308. package/dist/styles/switchField.layer.css +78 -0
  309. package/dist/styles/table.css +146 -0
  310. package/dist/styles/table.layer.css +148 -0
  311. package/dist/styles/tabs.css +87 -0
  312. package/dist/styles/tabs.layer.css +89 -0
  313. package/dist/styles/text.css +40 -0
  314. package/dist/styles/text.layer.css +42 -0
  315. package/dist/styles/textArea.css +71 -0
  316. package/dist/styles/textArea.layer.css +73 -0
  317. package/dist/styles/textAreaField.css +12 -0
  318. package/dist/styles/textAreaField.layer.css +14 -0
  319. package/dist/styles/textField.css +14 -0
  320. package/dist/styles/textField.layer.css +16 -0
  321. package/dist/styles/toggleButton.css +280 -0
  322. package/dist/styles/toggleButton.layer.css +282 -0
  323. package/dist/styles/toggleButtonGroup.css +31 -0
  324. package/dist/styles/toggleButtonGroup.layer.css +33 -0
  325. package/dist/styles/visuallyHidden.css +12 -0
  326. package/dist/styles/visuallyHidden.layer.css +14 -0
  327. package/dist/styles.css +299 -685
  328. package/dist/styles.layer.css +6115 -0
  329. package/dist/types/components/AccountSettings/ChangePassword/ChangePassword.d.ts +6 -6
  330. package/dist/types/components/AccountSettings/ChangePassword/types.d.ts +3 -0
  331. package/dist/types/components/AccountSettings/DeleteUser/DeleteUser.d.ts +3 -3
  332. package/dist/types/components/AccountSettings/DeleteUser/types.d.ts +7 -2
  333. package/dist/types/components/AccountSettings/utils/displayText.d.ts +18 -0
  334. package/dist/types/components/AccountSettings/utils/index.d.ts +1 -0
  335. package/dist/types/components/Authenticator/Authenticator.d.ts +5 -4
  336. package/dist/types/components/Authenticator/ConfirmSignIn/ConfirmSignIn.d.ts +2 -2
  337. package/dist/types/components/Authenticator/ConfirmSignUp/ConfirmSignUp.d.ts +2 -2
  338. package/dist/types/components/Authenticator/{ResetPassword/ResetPassword.d.ts → ForgotPassword/ForgotPassword.d.ts} +1 -1
  339. package/dist/types/components/Authenticator/{ResetPassword → ForgotPassword}/index.d.ts +1 -1
  340. package/dist/types/components/Authenticator/{SetupTOTP/SetupTOTP.d.ts → SetupTotp/SetupTotp.d.ts} +1 -1
  341. package/dist/types/components/Authenticator/SetupTotp/index.d.ts +1 -0
  342. package/dist/types/components/Authenticator/SignIn/SignIn.d.ts +2 -2
  343. package/dist/types/components/Authenticator/SignUp/SignUp.d.ts +2 -2
  344. package/dist/types/components/Authenticator/VerifyUser/ConfirmVerifyUser.d.ts +2 -2
  345. package/dist/types/components/Authenticator/hooks/useCustomComponents/defaultComponents.d.ts +2 -2
  346. package/dist/types/components/Authenticator/withAuthenticator.d.ts +2 -2
  347. package/dist/types/components/ThemeProvider/ThemeContext.d.ts +6 -0
  348. package/dist/types/components/ThemeProvider/ThemeProvider.d.ts +1 -2
  349. package/dist/types/components/ThemeProvider/index.d.ts +1 -1
  350. package/dist/types/components/index.d.ts +0 -1
  351. package/dist/types/hooks/index.d.ts +0 -1
  352. package/dist/types/hooks/useAuth.d.ts +2 -2
  353. package/dist/types/hooks/useStorageURL.d.ts +2 -6
  354. package/dist/types/hooks/useTheme.d.ts +2 -2
  355. package/dist/types/index.d.ts +1 -1
  356. package/dist/types/internal.d.ts +0 -12
  357. package/dist/types/primitives/Accordion/Accordion.d.ts +19 -0
  358. package/dist/types/primitives/Accordion/AccordionContainer.d.ts +8 -0
  359. package/dist/types/primitives/Accordion/AccordionContent.d.ts +9 -0
  360. package/dist/types/primitives/Accordion/AccordionContext.d.ts +9 -0
  361. package/dist/types/primitives/Accordion/AccordionIcon.d.ts +9 -0
  362. package/dist/types/primitives/Accordion/AccordionItem.d.ts +6 -0
  363. package/dist/types/primitives/Accordion/AccordionTrigger.d.ts +9 -0
  364. package/dist/types/primitives/Accordion/index.d.ts +2 -0
  365. package/dist/types/primitives/Accordion/types.d.ts +49 -0
  366. package/dist/types/primitives/Alert/AlertIcon.d.ts +5 -2
  367. package/dist/types/primitives/Breadcrumbs/BreadcrumbItem.d.ts +1 -1
  368. package/dist/types/primitives/DropZone/DropZoneChildren.d.ts +10 -3
  369. package/dist/types/primitives/Icon/context/IconsContext.d.ts +1 -1
  370. package/dist/types/primitives/PhoneNumberField/DialCodeSelect.d.ts +2 -0
  371. package/dist/types/primitives/StepperField/useStepper.d.ts +1 -1
  372. package/dist/types/primitives/Tabs/Tabs.d.ts +14 -3
  373. package/dist/types/primitives/Tabs/TabsContainer.d.ts +6 -0
  374. package/dist/types/primitives/Tabs/TabsContext.d.ts +7 -0
  375. package/dist/types/primitives/Tabs/TabsItem.d.ts +6 -0
  376. package/dist/types/primitives/Tabs/TabsList.d.ts +6 -0
  377. package/dist/types/primitives/Tabs/TabsPanel.d.ts +6 -0
  378. package/dist/types/primitives/Tabs/index.d.ts +2 -1
  379. package/dist/types/primitives/Tabs/types.d.ts +93 -0
  380. package/dist/types/primitives/components.d.ts +2 -2
  381. package/dist/types/primitives/index.d.ts +0 -1
  382. package/dist/types/primitives/shared/constants.d.ts +0 -6
  383. package/dist/types/primitives/shared/responsive/utils.d.ts +1 -1
  384. package/dist/types/primitives/shared/styleUtils.d.ts +2 -2
  385. package/dist/types/primitives/types/collection.d.ts +2 -2
  386. package/dist/types/primitives/types/fieldset.d.ts +1 -1
  387. package/dist/types/primitives/types/index.d.ts +0 -3
  388. package/dist/types/primitives/types/radioGroupField.d.ts +2 -1
  389. package/dist/types/primitives/types/view.d.ts +32 -2
  390. package/dist/types/primitives/utils/primitiveWithForwardRef.d.ts +11 -0
  391. package/dist/types/version.d.ts +1 -1
  392. package/package.json +13 -45
  393. package/dist/Field-94e428ed.js +0 -1
  394. package/dist/esm/components/Authenticator/ResetPassword/ConfirmResetPassword.mjs +0 -1
  395. package/dist/esm/components/Authenticator/ResetPassword/ResetPassword.mjs +0 -1
  396. package/dist/esm/components/Authenticator/SetupTOTP/SetupTOTP.mjs +0 -1
  397. package/dist/esm/components/Storage/FileUploader/FileUploader.mjs +0 -1
  398. package/dist/esm/components/Storage/FileUploader/UploadDropZone/UploadDropZone.mjs +0 -1
  399. package/dist/esm/components/Storage/FileUploader/UploadPreviewer/UploadPreviewer.mjs +0 -1
  400. package/dist/esm/components/Storage/FileUploader/UploadTracker/UploadMessage.mjs +0 -1
  401. package/dist/esm/components/Storage/FileUploader/UploadTracker/UploadTracker.mjs +0 -1
  402. package/dist/esm/components/Storage/FileUploader/hooks/useFileUploader/useFileUploader.mjs +0 -1
  403. package/dist/esm/components/Storage/FileUploader/types.mjs +0 -1
  404. package/dist/esm/components/ThemeProvider/AmplifyContext.mjs +0 -1
  405. package/dist/esm/helpers/constants.mjs +0 -1
  406. package/dist/esm/hooks/actions/constants.mjs +0 -1
  407. package/dist/esm/hooks/actions/shared/types.mjs +0 -1
  408. package/dist/esm/hooks/actions/shared/useTypeCastFields.mjs +0 -1
  409. package/dist/esm/hooks/actions/useAuthSignOutAction.mjs +0 -1
  410. package/dist/esm/hooks/actions/useDataStoreCreateAction.mjs +0 -1
  411. package/dist/esm/hooks/actions/useDataStoreDeleteAction.mjs +0 -1
  412. package/dist/esm/hooks/actions/useDataStoreUpdateAction.mjs +0 -1
  413. package/dist/esm/hooks/actions/useNavigateAction.mjs +0 -1
  414. package/dist/esm/hooks/actions/useStateMutationAction.mjs +0 -1
  415. package/dist/esm/hooks/useAmplify.mjs +0 -1
  416. package/dist/esm/hooks/useDataStore.mjs +0 -1
  417. package/dist/esm/primitives/Expander/Expander.mjs +0 -1
  418. package/dist/esm/primitives/Expander/ExpanderItem.mjs +0 -1
  419. package/dist/esm/primitives/PhoneNumberField/CountryCodeSelect.mjs +0 -1
  420. package/dist/esm/primitives/shared/datastore.mjs +0 -1
  421. package/dist/esm/studio/findChildOverrides.mjs +0 -1
  422. package/dist/esm/studio/getOverrideProps.mjs +0 -1
  423. package/dist/esm/studio/getOverridesFromVariants.mjs +0 -1
  424. package/dist/esm/studio/mergeVariantsAndOverrides.mjs +0 -1
  425. package/dist/styles.js +0 -2
  426. package/dist/types/components/Authenticator/SetupTOTP/index.d.ts +0 -1
  427. package/dist/types/components/Storage/FileUploader/FileUploader.d.ts +0 -3
  428. package/dist/types/components/Storage/FileUploader/UploadDropZone/UploadDropZone.d.ts +0 -3
  429. package/dist/types/components/Storage/FileUploader/UploadDropZone/index.d.ts +0 -1
  430. package/dist/types/components/Storage/FileUploader/UploadPreviewer/UploadPreviewer.d.ts +0 -3
  431. package/dist/types/components/Storage/FileUploader/UploadPreviewer/index.d.ts +0 -1
  432. package/dist/types/components/Storage/FileUploader/UploadTracker/UploadMessage.d.ts +0 -3
  433. package/dist/types/components/Storage/FileUploader/UploadTracker/UploadTracker.d.ts +0 -3
  434. package/dist/types/components/Storage/FileUploader/UploadTracker/index.d.ts +0 -1
  435. package/dist/types/components/Storage/FileUploader/hooks/index.d.ts +0 -1
  436. package/dist/types/components/Storage/FileUploader/hooks/useFileUploader/index.d.ts +0 -2
  437. package/dist/types/components/Storage/FileUploader/hooks/useFileUploader/types.d.ts +0 -18
  438. package/dist/types/components/Storage/FileUploader/hooks/useFileUploader/useFileUploader.d.ts +0 -9
  439. package/dist/types/components/Storage/FileUploader/index.d.ts +0 -1
  440. package/dist/types/components/Storage/FileUploader/types.d.ts +0 -91
  441. package/dist/types/components/Storage/index.d.ts +0 -1
  442. package/dist/types/components/ThemeProvider/AmplifyContext.d.ts +0 -6
  443. package/dist/types/hooks/actions/constants.d.ts +0 -39
  444. package/dist/types/hooks/actions/shared/types.d.ts +0 -27
  445. package/dist/types/hooks/actions/shared/useTypeCastFields.d.ts +0 -15
  446. package/dist/types/hooks/actions/testModels/model.d.ts +0 -25
  447. package/dist/types/hooks/actions/testModels/schema.d.ts +0 -2
  448. package/dist/types/hooks/actions/testModels/todo.d.ts +0 -13
  449. package/dist/types/hooks/actions/useAuthSignOutAction.d.ts +0 -9
  450. package/dist/types/hooks/actions/useDataStoreCreateAction.d.ts +0 -9
  451. package/dist/types/hooks/actions/useDataStoreDeleteAction.d.ts +0 -10
  452. package/dist/types/hooks/actions/useDataStoreUpdateAction.d.ts +0 -10
  453. package/dist/types/hooks/actions/useNavigateAction.d.ts +0 -15
  454. package/dist/types/hooks/actions/useStateMutationAction.d.ts +0 -10
  455. package/dist/types/hooks/useAmplify.d.ts +0 -6
  456. package/dist/types/hooks/useDataStore.d.ts +0 -18
  457. package/dist/types/primitives/Expander/Expander.d.ts +0 -6
  458. package/dist/types/primitives/Expander/ExpanderItem.d.ts +0 -7
  459. package/dist/types/primitives/Expander/index.d.ts +0 -2
  460. package/dist/types/primitives/Menu/__tests_/menu.test.d.ts +0 -1
  461. package/dist/types/primitives/PhoneNumberField/CountryCodeSelect.d.ts +0 -2
  462. package/dist/types/primitives/Rating/__test__/Rating.test.d.ts +0 -1
  463. package/dist/types/primitives/Rating/__test__/utils.test.d.ts +0 -1
  464. package/dist/types/primitives/Text/__test__/Text.test.d.ts +0 -1
  465. package/dist/types/primitives/shared/datastore.d.ts +0 -7
  466. package/dist/types/primitives/shared/index.d.ts +0 -1
  467. package/dist/types/primitives/shared/types.d.ts +0 -15
  468. package/dist/types/primitives/types/datastore.d.ts +0 -31
  469. package/dist/types/primitives/types/expander.d.ts +0 -51
  470. package/dist/types/primitives/types/tabs.d.ts +0 -63
  471. package/dist/types/studio/findChildOverrides.d.ts +0 -18
  472. package/dist/types/studio/getOverrideProps.d.ts +0 -18
  473. package/dist/types/studio/getOverridesFromVariants.d.ts +0 -20
  474. package/dist/types/studio/index.d.ts +0 -5
  475. package/dist/types/studio/mergeVariantsAndOverrides.d.ts +0 -18
  476. package/dist/types/studio/types.d.ts +0 -18
  477. package/dist/types/styles.d.ts +0 -1
  478. /package/dist/types/components/Authenticator/{ResetPassword → ForgotPassword}/ConfirmResetPassword.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1 +1,3485 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=require("lodash/isEqual.js"),t=require("aws-amplify"),n=require("@aws-amplify/ui"),l=require("./Field-94e428ed.js");require("@aws-amplify/datastore");var s=require("@aws-amplify/ui-react-core"),r=require("@aws-amplify/storage"),o=require("tslib"),i=require("classnames"),d=require("lodash/debounce.js"),c=require("@radix-ui/react-accordion"),u=require("@radix-ui/react-dropdown-menu"),m=require("@radix-ui/react-slider"),p=require("@radix-ui/react-tabs"),f=require("qrcode"),C=require("@radix-ui/react-direction");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var a=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),a.default=e,Object.freeze(a)}require("@aws-amplify/core");var b=h(e),N=g(e),E=g(a),v=g(i),F=g(d),y=h(c),w=h(u),x=h(m),S=h(p),I=g(f),T=h(C);function P({children:e,icons:a}){return b.createElement(l.IconsContext.Provider,{value:a},e)}const D=b.forwardRef(((e,a)=>{var t,{buttonRef:s,children:r,className:i,dismissButtonLabel:d=l.ComponentText.Alert.dismissButtonLabel,hasIcon:c=!0,heading:u,isDismissible:m=!1,onDismiss:p,variation:f}=e,C=o.__rest(e,["buttonRef","children","className","dismissButtonLabel","hasIcon","heading","isDismissible","onDismiss","variation"]);const[g,h]=b.useState(!1),N=l.useIcons("alert"),E=b.useCallback((()=>{h(!g),n.isFunction(p)&&p()}),[h,p,g]);return g?null:b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Alert,i,n.classNameModifier(l.ComponentClassNames.Alert,f)),"data-variation":f,ref:a,role:"alert"},C),c&&b.createElement(l.AlertIcon,{variation:f,ariaHidden:!0}),b.createElement(l.View,{flex:"1"},u&&b.createElement(l.View,{className:l.ComponentClassNames.AlertHeading},u),b.createElement(l.View,{className:l.ComponentClassNames.AlertBody},r)),m&&b.createElement(l.Button,{ariaLabel:d,variation:"link",className:l.ComponentClassNames.AlertDismiss,onClick:E,ref:s},null!==(t=null==N?void 0:N.close)&&void 0!==t?t:b.createElement(l.IconClose,{"aria-hidden":"true"})))}));D.displayName="Alert";const k=b.forwardRef(((e,a)=>{var{children:t,className:s,isActive:r}=e,i=o.__rest(e,["children","className","isActive"]);return b.createElement(l.View,Object.assign({"aria-selected":r,as:"li",role:"option",className:v.default(l.ComponentClassNames.AutocompleteMenuOption,n.classNameModifierByFlag(l.ComponentClassNames.AutocompleteMenuOption,"active",r),s),ref:a},i),t)}));k.displayName="AutocompleteOption";const M=b.forwardRef(((e,a)=>{var{children:t,className:s,orientation:r}=e,i=o.__rest(e,["children","className","orientation"]);return b.createElement(l.View,Object.assign({className:v.default(l.ComponentClassNames.ScrollView,n.classNameModifier(l.ComponentClassNames.ScrollView,r),s),"data-orientation":r,ref:a},i),t)}));M.displayName="ScrollView";const O=b.forwardRef(((e,a)=>{var{ariaLabel:t,children:n,Header:s=null,Footer:r=null,LoadingIndicator:i=null,Empty:d=null,isLoading:c,listboxId:u}=e,m=o.__rest(e,["ariaLabel","children","Header","Footer","LoadingIndicator","Empty","isLoading","listboxId"]);return b.createElement(M,Object.assign({className:l.ComponentClassNames.AutocompleteMenu,ref:a},m),c?b.createElement((()=>{const e=null!=i?i:b.createElement(b.Fragment,null,b.createElement(l.Loader,null),l.ComponentText.Autocomplete.loadingText);return b.createElement(l.View,{className:l.ComponentClassNames.AutocompleteMenuLoading},e)}),null):b.createElement(b.Fragment,null,b.createElement((()=>s&&b.createElement(l.View,{className:l.ComponentClassNames.AutocompleteMenuHeader},s)),null),n.length>0?b.createElement(M,{as:"ul",ariaLabel:t,className:l.ComponentClassNames.AutocompleteMenuOptions,id:u,role:"listbox"},n):b.createElement((()=>d?b.createElement(l.View,{className:l.ComponentClassNames.AutocompleteMenuEmpty},d):b.createElement(l.View,{className:l.ComponentClassNames.AutocompleteMenuEmpty},l.ComponentText.Autocomplete.emptyText)),null),b.createElement((()=>r&&b.createElement(l.View,{className:l.ComponentClassNames.AutocompleteMenuFooter},r)),null)))}));O.displayName="AutocompleteMenu";const R=(null===globalThis||void 0===globalThis?void 0:globalThis.document)?b.useLayoutEffect:()=>{},B=b["useId".toString()]||(()=>{});let L=0;const V=e=>{const[a,t]=b.useState(B());return R((()=>{e||t((e=>null!=e?e:String(L++)))}),[e]),null!=e?e:a?`amplify-id-${a}`:""},_=new Set([l.ARROW_DOWN,l.ARROW_UP,l.ENTER_KEY,l.ESCAPE_KEY]),j=(e,a)=>e&&a?`${e}-${a}`:void 0,A=b.forwardRef(((e,a)=>{var{children:t,className:n,query:s,testId:r}=e,i=o.__rest(e,["children","className","query","testId"]);const d=j(r,"match"),c=null==t?void 0:t.toLocaleLowerCase().indexOf(null==s?void 0:s.toLocaleLowerCase());if(l.strHasLength(s)&&-1!==c){const e=t.substring(c,c+s.length);return b.createElement(l.View,Object.assign({as:"span",className:v.default(n,l.ComponentClassNames.HighlightMatch),testId:r,ref:a},i),t.substring(0,c),b.createElement(l.View,{as:"strong",className:l.ComponentClassNames.HighlightMatchHighlighted,testId:d},e),t.substring(c+s.length))}return b.createElement(l.View,{as:"span",testId:r},t)}));A.displayName="HighlightMatch";const H=l.ComponentText.SearchField.searchButtonLabel,z=b.forwardRef(((e,a)=>{var t,{size:n}=e,s=o.__rest(e,["size"]);const r=l.useIcons("searchField");return b.createElement(l.FieldGroupIconButton,Object.assign({ariaLabel:H,className:l.ComponentClassNames.SearchFieldSearch,size:n,ref:a,type:"submit"},s),null!==(t=null==r?void 0:r.search)&&void 0!==t?t:b.createElement(l.IconSearch,null))}));z.displayName="SearchFieldButton";const U=b.forwardRef(((e,a)=>{var{children:t,className:s,innerEndComponent:r,innerStartComponent:i,orientation:d="horizontal",outerEndComponent:c,outerStartComponent:u,variation:m}=e,p=o.__rest(e,["children","className","innerEndComponent","innerStartComponent","orientation","outerEndComponent","outerStartComponent","variation"]);const f=null!=r,C=null!=i?l.ComponentClassNames.FieldGroupHasInnerStart:null,g=f?l.ComponentClassNames.FieldGroupHasInnerEnd:null,h=v.default(l.ComponentClassNames.FieldGroup,C,g,n.classNameModifier(l.ComponentClassNames.FieldGroup,d),s);return b.createElement(l.Flex,Object.assign({className:h,"data-orientation":d,ref:a},p),u&&b.createElement(l.View,{className:v.default(l.ComponentClassNames.FieldGroupOuterStart,n.classNameModifier(l.ComponentClassNames.FieldGroupOuterStart,m))},u),b.createElement(l.View,{className:v.default(l.ComponentClassNames.FieldGroupFieldWrapper,n.classNameModifier(l.ComponentClassNames.FieldGroupFieldWrapper,d)),"data-orientation":d},i&&b.createElement(l.View,{className:l.ComponentClassNames.FieldGroupInnerStart},i),t,r&&b.createElement(l.View,{className:l.ComponentClassNames.FieldGroupInnerEnd},r)),c&&b.createElement(l.View,{className:v.default(l.ComponentClassNames.FieldGroupOuterEnd,n.classNameModifier(l.ComponentClassNames.FieldGroupOuterEnd,m))},c))}));U.displayName="FieldGroup";const G=b.forwardRef(((e,a)=>{var{autoComplete:t,checked:s,className:r,defaultChecked:i,defaultValue:d,id:c,isDisabled:u,isReadOnly:m,isRequired:p,size:f,type:C="text",hasError:g=!1,value:h,variation:N}=e,E=o.__rest(e,["autoComplete","checked","className","defaultChecked","defaultValue","id","isDisabled","isReadOnly","isRequired","size","type","hasError","value","variation"]);const F=v.default(l.ComponentClassNames.Input,l.ComponentClassNames.FieldGroupControl,n.classNameModifier(l.ComponentClassNames.Input,N),n.classNameModifierByFlag(l.ComponentClassNames.Input,"error",g),n.classNameModifier(l.ComponentClassNames.Input,f),r),{isFieldsetDisabled:y}=l.useFieldset();return b.createElement(l.View,Object.assign({"aria-invalid":g,as:"input",autoComplete:t,checked:s,className:F,"data-size":f,"data-variation":N,defaultChecked:i,defaultValue:d,isDisabled:y||u,id:c,readOnly:m,ref:a,required:p,type:C,value:h},E))}));G.displayName="Input";const q=e=>{const a={styleProps:{},rest:{}};return Object.keys(e).forEach((t=>{(e=>e in l.ComponentPropsToStylePropsMap)(t)?a.styleProps=Object.assign(Object.assign({},a.styleProps),{[t]:e[t]}):a.rest=Object.assign(Object.assign({},a.rest),{[t]:e[t]})})),a},W=b.forwardRef(((e,a)=>{const{className:t,descriptiveText:s,errorMessage:r,hasError:i=!1,id:d,innerEndComponent:c,innerStartComponent:u,label:m,labelHidden:p=!1,outerEndComponent:f,outerStartComponent:C,size:g,testId:h,variation:N,inputStyles:E}=e,F=o.__rest(e,["className","descriptiveText","errorMessage","hasError","id","innerEndComponent","innerStartComponent","label","labelHidden","outerEndComponent","outerStartComponent","size","testId","variation","inputStyles"]),y=V(d),w=V(),x=s?w:void 0,{styleProps:S,rest:I}=q(F);return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Field,n.classNameModifier(l.ComponentClassNames.Field,g),l.ComponentClassNames.TextField,t),"data-size":g,testId:h},S),b.createElement(l.Label,{htmlFor:y,visuallyHidden:p},m),b.createElement(l.FieldDescription,{id:w,labelHidden:p,descriptiveText:s}),b.createElement(U,{outerStartComponent:C,outerEndComponent:f,innerStartComponent:u,innerEndComponent:c,variation:N},b.createElement(G,Object.assign({"aria-describedby":x,hasError:i,id:y,ref:a,size:g,variation:N},E,I))),b.createElement(l.FieldErrorMessage,{hasError:i,errorMessage:r}))}));W.displayName="TextField";const $=new Set([l.ESCAPE_KEY,l.ENTER_KEY]),Z=({defaultValue:e="",value:a,onChange:t,onClear:s,onSubmit:r,externalRef:o})=>{const i=void 0!==a,[d,c]=b.useState(e),u=i?a:d,m=b.useRef(null),p=function({externalRef:e,internalRef:a}){return b.useCallback((t=>{n.isFunction(e)?e(t):e&&(e.current=t),a.current=t}),[e,a])}({externalRef:o,internalRef:m}),f=b.useCallback((()=>{var e;i||c(""),null===(e=null==m?void 0:m.current)||void 0===e||e.focus(),n.isFunction(s)&&s()}),[i,c,s]),C=b.useCallback((e=>{n.isFunction(r)&&r(e)}),[r]),g=b.useCallback((e=>{const{key:a}=e;$.has(a)&&(e.preventDefault(),a===l.ESCAPE_KEY?f():a===l.ENTER_KEY&&C(u))}),[u,f,C]),h=b.useCallback((e=>{i||c(e.target.value),n.isFunction(t)&&t(e)}),[i,t,c]),N=b.useCallback((()=>{C(u)}),[C,u]);return{composedValue:u,onClearHandler:f,onKeyDown:g,onClick:N,handleOnChange:h,composedRefs:p}},K=b.forwardRef(((e,a)=>{var{autoComplete:t="off",className:n,isDisabled:s,clearButtonLabel:r,labelHidden:i=!0,name:d="q",hasSearchButton:c=!0,hasSearchIcon:u=!1,onChange:m,onClear:p,onSubmit:f,searchButtonRef:C,size:g,defaultValue:h,value:N}=e,E=o.__rest(e,["autoComplete","className","isDisabled","clearButtonLabel","labelHidden","name","hasSearchButton","hasSearchIcon","onChange","onClear","onSubmit","searchButtonRef","size","defaultValue","value"]);const{composedValue:F,onClearHandler:y,onKeyDown:w,onClick:x,handleOnChange:S,composedRefs:I}=Z({defaultValue:h,value:N,onChange:m,onClear:p,onSubmit:f,externalRef:a}),T=c?b.createElement(z,{isDisabled:s,onClick:x,ref:C,size:g}):void 0,P=u?b.createElement(l.FieldGroupIcon,null,b.createElement(l.IconSearch,null)):void 0;return b.createElement(W,Object.assign({autoComplete:t,className:v.default(l.ComponentClassNames.SearchField,n),labelHidden:i,innerStartComponent:P,innerEndComponent:b.createElement(l.FieldClearButton,{ariaLabel:r,excludeFromTabOrder:!0,isVisible:!s&&l.strHasLength(F),onClick:y,size:g,variation:"link"}),isDisabled:s,name:d,onChange:S,onKeyDown:w,outerEndComponent:T,ref:I,size:g,value:F},E))}));K.displayName="SearchField";const Y=b.forwardRef(((e,a)=>{var{className:t,defaultValue:s,value:r,isLoading:i=!1,menuSlots:d={},options:c,optionFilter:u,onBlur:m,onChange:p,onClear:f,onClick:C,onSelect:g,onSubmit:h,renderOption:N,testId:E}=e,F=o.__rest(e,["className","defaultValue","value","isLoading","menuSlots","options","optionFilter","onBlur","onChange","onClear","onClick","onSelect","onSubmit","renderOption","testId"]);const{activeOptionId:y,autocompleteId:w,composedValue:x,filteredOptions:S,handleOnBlur:I,handleOnClear:T,handleOnClick:P,handleOnChange:D,handleOnKeyDown:M,isControlled:R,isCustomFiltering:B,isMenuOpen:L,listboxId:j,menuId:H,optionBaseId:z,setActiveOption:U,setIsMenuOpen:G,setInternalValue:q}=(({defaultValue:e="",value:a,options:t,optionFilter:s,onBlur:r,onChange:o,onClear:i,onClick:d,onSelect:c,onSubmit:u})=>{var m;const p=void 0!==a,[f,C]=b.useState(e),g=p?a:f,[h,N]=b.useState(!1),[E,v]=b.useState(null),F=n.isFunction(s),y=b.useMemo((()=>{var e;const a=F?e=>s(e,g):e=>{const{label:a}=e;return null==a?void 0:a.toLocaleLowerCase().includes(null==g?void 0:g.toLocaleLowerCase())};return null!==(e=null==t?void 0:t.filter(a))&&void 0!==e?e:[]}),[g,s,F,t]),w=V(),x=V(),S=V(),I=V(),T=y.findIndex((e=>e===E)),P=null!==(m=null==E?void 0:E.id)&&void 0!==m?m:-1!==T?`${I}-option-${T}`:void 0,D=b.useCallback((e=>{N(!1),v(null),n.isFunction(r)&&r(e)}),[r]),k=b.useCallback((e=>{v(null),N(!0),p||C(e.target.value),n.isFunction(o)&&o(e)}),[p,o]),M=b.useCallback((()=>{p||C(""),n.isFunction(i)&&i()}),[p,i]),O=b.useCallback((e=>{N(!0),n.isFunction(d)&&d(e)}),[d]);return b.useEffect((()=>{const e=document.getElementById(w),a=document.getElementById(S);if(a&&h&&e){const{bottom:t}=a.getBoundingClientRect(),{offsetParent:n,offsetTop:l}=e;n===document.body&&t>document.documentElement.clientHeight&&window.scrollTo({top:Math.min(t-document.documentElement.clientHeight+window.scrollY+20,l),behavior:"smooth"})}}),[w,h,S]),b.useEffect((()=>{const e=document.getElementById(x),a=l.strHasLength(P)?document.getElementById(P):null;if(a&&e){const{scrollTop:t,clientHeight:n}=e,{offsetHeight:l,offsetTop:s}=a,{top:r,bottom:o}=a.getBoundingClientRect();t>s&&(e.scrollTop=s),t+n<s+l&&(e.scrollTop=s+l-n),(r<0||o>document.documentElement.clientHeight)&&a.scrollIntoView({behavior:"smooth",block:"nearest"})}}),[P,x]),{activeOptionId:P,autocompleteId:w,composedValue:g,filteredOptions:y,handleOnBlur:D,handleOnClear:M,handleOnClick:O,handleOnChange:k,handleOnKeyDown:e=>{const{key:a}=e;if(_.has(a))switch(e.preventDefault(),a){case l.ESCAPE_KEY:h?(N(!1),v(null)):M();break;case l.ENTER_KEY:if(E){const{label:e}=E;p||C(e),n.isFunction(c)&&c(E)}else n.isFunction(u)&&u(g);N(!1),v(null);break;case l.ARROW_DOWN:{if(y.length<=0)return;N(!0);const e=T>=y.length-1?0:T+1;v(y[e]);break}case l.ARROW_UP:{if(y.length<=0)return;N(!0);const e=T<=0?y.length-1:T-1;v(y[e])}}},isControlled:p,isCustomFiltering:F,isMenuOpen:h,listboxId:x,menuId:S,optionBaseId:I,setActiveOption:v,setIsMenuOpen:N,setInternalValue:C}})({defaultValue:s,value:r,options:c,optionFilter:u,onBlur:m,onChange:p,onClear:f,onClick:C,onSelect:g,onSubmit:h}),W={role:"combobox","aria-activedescendant":y,"aria-autocomplete":"list","aria-controls":L?H:void 0,"aria-expanded":L,"aria-haspopup":"listbox","aria-owns":L?H:void 0},$=S.map(((e,a)=>{const{id:t,label:l}=e,s=o.__rest(e,["id","label"]),r=null!=t?t:`${z}-option-${a}`,i=r===y;return b.createElement(k,Object.assign({isActive:i,id:r,key:r,onClick:()=>{G(!1),U(null),R||q(l),n.isFunction(g)&&g(e)},onMouseDown:e=>{e.preventDefault()},onMouseMove:()=>{U(e)}},s),n.isFunction(N)?N(e,x):B?l:b.createElement(A,{query:x},l))}));return b.createElement(l.View,{className:v.default(l.ComponentClassNames.Autocomplete,t),id:w,testId:E},b.createElement(K,Object.assign({hasSearchButton:!1,hasSearchIcon:!0,onBlur:I,onChange:D,onClear:T,onClick:P,onKeyDown:M,ref:a,value:x},W,F)),L?b.createElement(O,Object.assign({id:H,isLoading:i,listboxId:j},d),$):null)}));Y.displayName="Autocomplete";const X=b.forwardRef(((e,a)=>{var{className:t,children:s,variation:r,size:i}=e,d=o.__rest(e,["className","children","variation","size"]);const c=v.default(l.ComponentClassNames.Badge,t,n.classNameModifier(l.ComponentClassNames.Badge,r),n.classNameModifier(l.ComponentClassNames.Badge,i));return b.createElement(l.View,Object.assign({as:"span",className:c,"data-variation":r,"data-size":i,ref:a},d),s)}));X.displayName="Badge";const Q=b.forwardRef(((e,a)=>{var{className:t,children:n,as:s="li"}=e,r=o.__rest(e,["className","children","as"]);const i=v.default(l.ComponentClassNames.BreadcrumbsItem,t);return b.createElement(l.View,Object.assign({},r,{as:s,className:i,ref:a}),n)}));Q.displayName="Breadcrumbs.Item";const J=b.forwardRef(((e,a)=>{var{as:t="a",children:n,className:s,isExternal:r}=e,i=o.__rest(e,["as","children","className","isExternal"]);return b.createElement(l.View,Object.assign({as:t,className:v.default(l.ComponentClassNames.Link,s),ref:a,rel:r?"noopener noreferrer":void 0,target:r?"_blank":void 0},i),n)}));J.displayName="Link";const ee=b.forwardRef(((e,a)=>{var t,s,{className:r,children:i,href:d,isCurrent:c}=e,u=o.__rest(e,["className","children","href","isCurrent"]);const m=v.default(l.ComponentClassNames.BreadcrumbsLink,n.classNameModifierByFlag(l.ComponentClassNames.BreadcrumbsLink,"current",c),r);if(c){const e=null!==(t=u["aria-current"])&&void 0!==t?t:"page",n=null!==(s=u.as)&&void 0!==s?s:"span";return b.createElement(l.Text,Object.assign({},u,{as:n,"aria-current":e,className:m,ref:a}),i)}return b.createElement(J,Object.assign({},u,{className:m,ref:a,href:d}),i)}));ee.displayName="Breadcrumbs.Link";const ae=b.forwardRef(((e,a)=>{var t,{className:n,children:s="/",as:r="span"}=e,i=o.__rest(e,["className","children","as"]);const d=null!==(t=i["aria-hidden"])&&void 0!==t?t:"true";return b.createElement(l.View,Object.assign({},i,{as:r,ref:a,"aria-hidden":d,className:v.default(l.ComponentClassNames.BreadcrumbsSeparator,n)}),s)}));ae.displayName="Breadcrumbs.Separator";const te=b.forwardRef(((e,a)=>{var t,{className:n,children:s}=e,r=o.__rest(e,["className","children"]);const i=v.default(l.ComponentClassNames.Breadcrumbs,n),d=null!==(t=r["aria-label"])&&void 0!==t?t:"Breadcrumb";return b.createElement(l.View,Object.assign({},r,{as:"nav","aria-label":d,className:i,ref:a}),b.createElement(l.View,{as:"ol",className:l.ComponentClassNames.BreadcrumbsList},s))}));te.displayName="Breadcrumbs.Container";const ne=Object.assign(b.forwardRef(((e,a)=>{var t,{className:n,items:l,separator:s=b.createElement(ae,null)}=e,r=o.__rest(e,["className","items","separator"]);const i=null!==(t=r["aria-label"])&&void 0!==t?t:"Breadcrumb";return b.createElement(te,Object.assign({},r,{"aria-label":i,className:n,ref:a}),null==l?void 0:l.map((({href:e,label:a},t)=>{const n=l.length-1===t;return b.createElement(Q,{key:`${e}${t}`},b.createElement(ee,{href:e,isCurrent:n},a),n?null:s)})))})),{Item:Q,Link:ee,Separator:ae,Container:te});ne.displayName="Breadcrumbs";const le=b.forwardRef(((e,a)=>{var{className:t,children:n,role:s="group",size:r,variation:i}=e,d=o.__rest(e,["className","children","role","size","variation"]);return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.ButtonGroup,t),role:s,ref:a},d),b.Children.map(n,(e=>{if(b.isValidElement(e)){const{size:a=r,variation:t=i}=e.props;return b.cloneElement(e,{size:a,variation:t})}return e})))}));le.displayName="ButtonGroup";const se=b.forwardRef(((e,a)=>{var{className:t,children:s,variation:r}=e,i=o.__rest(e,["className","children","variation"]);return b.createElement(l.View,Object.assign({className:v.default(l.ComponentClassNames.Card,n.classNameModifier(l.ComponentClassNames.Card,r),t),"data-variation":r,ref:a},i),s)}));se.displayName="Card";const re=b.forwardRef(((e,a)=>{var{as:t="span",children:n,className:s}=e,r=o.__rest(e,["as","children","className"]);return b.createElement(l.View,Object.assign({as:t,className:v.default(l.ComponentClassNames.VisuallyHidden,s),ref:a},r),n)}));re.displayName="VisuallyHidden";const oe=b.forwardRef(((e,a)=>{var{checked:t,className:s,defaultChecked:r,hasError:i,isDisabled:d,isIndeterminate:c,label:u,labelHidden:m,labelPosition:p,onBlur:f,onFocus:C,onChange:g,testId:h,inputStyles:N}=e,E=o.__rest(e,["checked","className","defaultChecked","hasError","isDisabled","isIndeterminate","label","labelHidden","labelPosition","onBlur","onFocus","onChange","testId","inputStyles"]);const{styleProps:F,rest:y}=q(E),[w,x]=b.useState(!1),S=l.useIcons("checkbox"),{isFieldsetDisabled:I}=l.useFieldset(),T=I||d,P=void 0!==t,[D,k]=b.useState((()=>P?t:r)),M=P?t:D,O=V();b.useEffect((()=>{const e=document.querySelector(`[data-id="${O}"]`);e&&"boolean"==typeof c&&(e.indeterminate=c)}),[O,c]);const R=j(h,l.ComponentClassNames.CheckboxButton),B=j(h,l.ComponentClassNames.CheckboxIcon),L=j(h,l.ComponentClassNames.CheckboxLabel),_=v.default(l.ComponentClassNames.CheckboxButton,n.classNameModifierByFlag(l.ComponentClassNames.CheckboxButton,"disabled",T),n.classNameModifierByFlag(l.ComponentClassNames.CheckboxButton,"error",i),n.classNameModifierByFlag(l.ComponentClassNames.CheckboxButton,"focused",w)),A=v.default(l.ComponentClassNames.CheckboxIcon,n.classNameModifierByFlag(l.ComponentClassNames.CheckboxIcon,"checked",M),n.classNameModifierByFlag(l.ComponentClassNames.CheckboxIcon,"disabled",T),n.classNameModifierByFlag(l.ComponentClassNames.CheckboxIcon,"indeterminate",c)),H={className:v.default(A),"data-checked":D,"data-disabled":T,"data-testid":B},z=(null==S?void 0:S.checked)?b.createElement(l.View,{as:"span",className:v.default(A)},S.checked):b.createElement(l.IconCheck,Object.assign({},H)),U=(null==S?void 0:S.indeterminate)?b.createElement(l.View,{as:"span",className:v.default(A)},S.indeterminate):b.createElement(l.IconIndeterminate,Object.assign({},H));return b.createElement(l.Flex,Object.assign({as:"label",className:v.default(l.ComponentClassNames.Checkbox,n.classNameModifierByFlag(l.ComponentClassNames.Checkbox,"disabled",T),s),"data-disabled":T,"data-label-position":p,testId:h},F),b.createElement(re,null,b.createElement(G,Object.assign({checked:t,className:l.ComponentClassNames.CheckboxInput,"data-id":O,defaultChecked:r,isDisabled:T,onBlur:e=>{n.isFunction(f)&&f(e),x(!1)},onChange:e=>{n.isFunction(g)&&g(e),P||k(e.target.checked)},onFocus:e=>{n.isFunction(C)&&C(e),x(!0)},ref:a,type:"checkbox"},y))),u&&b.createElement(l.Text,{as:"span",className:v.default(l.ComponentClassNames.CheckboxLabel,{[l.ComponentClassNames.VisuallyHidden]:m}),"data-disabled":T,testId:L},u),b.createElement(l.Flex,Object.assign({"aria-hidden":"true",as:"span",className:_,"data-checked":M,"data-disabled":T,"data-focus":w,"data-error":i,testId:R},N),c?U:z))}));oe.displayName="Checkbox";const ie=b.forwardRef(((e,a)=>{var{className:t,errorMessage:s,hasError:r=!1,labelHidden:i=!1,labelPosition:d,testId:c,size:u}=e,m=o.__rest(e,["className","errorMessage","hasError","labelHidden","labelPosition","testId","size"]);const p=j(c,l.ComponentClassNames.Checkbox);return b.createElement(l.Flex,{className:v.default(l.ComponentClassNames.Field,l.ComponentClassNames.CheckboxField,n.classNameModifier(l.ComponentClassNames.Field,u),t),"data-size":u,testId:c},b.createElement(oe,Object.assign({hasError:r,labelHidden:i,testId:p,labelPosition:d,ref:a},m)),b.createElement(l.FieldErrorMessage,{hasError:r,errorMessage:s}))}));ie.displayName="CheckboxField";const de=b.forwardRef(((e,a)=>{var{className:t,children:n}=e,s=o.__rest(e,["className","children"]);return b.createElement(l.View,Object.assign({className:v.default(l.ComponentClassNames.Grid,t),ref:a},s),n)}));de.displayName="Grid";const ce="...",ue=e=>{var a,t,{type:s,page:r,currentPage:i,currentPageLabel:d=l.ComponentText.PaginationItem.currentPageLabel,isDisabled:c,onClick:u,ariaLabel:m}=e,p=o.__rest(e,["type","page","currentPage","currentPageLabel","isDisabled","onClick","ariaLabel"]);const f=l.useIcons("pagination"),C=v.default(l.ComponentClassNames.PaginationItemButton,n.classNameModifier(l.ComponentClassNames.PaginationItemButton,"link"),n.classNameModifierByFlag(l.ComponentClassNames.PaginationItemButton,"disabled",c)),g=v.default(l.ComponentClassNames.PaginationItemButton,n.classNameModifier(l.ComponentClassNames.PaginationItemButton,"link"),n.classNameModifierByFlag(l.ComponentClassNames.PaginationItemButton,"disabled",c));switch(s){case"page":return b.createElement(l.View,{as:"li"},r===i?b.createElement(l.Flex,Object.assign({"aria-current":"page",as:"button",className:l.ComponentClassNames.PaginationItemCurrent,testId:"current"},p),b.createElement(re,null,d,":"),r):b.createElement(l.Button,Object.assign({className:v.default(l.ComponentClassNames.PaginationItemButton,n.classNameModifier(l.ComponentClassNames.PaginationItemButton,"link")),size:"small",variation:"link",onClick:()=>{null==u||u()},ariaLabel:m},p),r));case"next":return b.createElement(l.View,{as:"li"},b.createElement(l.Button,Object.assign({className:C,size:"small",variation:"link",isDisabled:c,onClick:()=>{null==u||u()},ariaLabel:m},p),null!==(a=null==f?void 0:f.next)&&void 0!==a?a:b.createElement(l.IconChevronRight,null)));case"previous":return b.createElement(l.View,{as:"li"},b.createElement(l.Button,Object.assign({className:g,size:"small",variation:"link",isDisabled:c,onClick:()=>{null==u||u()},ariaLabel:m},p),null!==(t=null==f?void 0:f.previous)&&void 0!==t?t:b.createElement(l.IconChevronLeft,null)));case"ellipsis":return b.createElement(l.View,{as:"li"},b.createElement(l.Flex,Object.assign({as:"span",className:l.ComponentClassNames.PaginationItemEllipsis,testId:"ellipsis"},p),"…"))}return b.createElement(l.View,{as:"li"})};ue.displayName="PaginationItem";const me=({currentPage:e,totalPages:a,hasMorePages:t,siblingCount:n,currentPageLabel:s=l.ComponentText.PaginationItem.currentPageLabel,pageLabel:r=l.ComponentText.PaginationItem.pageLabel,previousLabel:o=l.ComponentText.PaginationItem.previousLabel,nextLabel:i=l.ComponentText.PaginationItem.nextLabel,onNext:d,onPrevious:c,onChange:u})=>{const m=b.createElement(ue,{type:"previous",key:"previous",currentPage:e,onClick:c,isDisabled:e<=1,ariaLabel:o}),p=b.createElement(ue,{type:"next",key:"next",currentPage:e,onClick:d,isDisabled:e>=a&&!t,ariaLabel:i}),f=((e,a,t=1)=>b.useMemo((()=>{const n=Math.max(e,1),s=Math.max(t,1),r=Math.max(n,a),o=r;if(r<5+2*s)return l.getConsecutiveIntArray(1,r);const i=Math.max(n-s,1),d=Math.min(n+s,o),c=i>2,u=d<o-1;if(c&&!u){const e=3+2*s,a=l.getConsecutiveIntArray(o-e+1,o);return[1,ce,...a]}if(!c&&u){const e=3+2*s;return[...l.getConsecutiveIntArray(1,e),ce,o]}const m=l.getConsecutiveIntArray(i,d);return[1,ce,...m,ce,o]}),[e,a,t]))(e,a,n);return[m,...b.useMemo((()=>f.map(((a,t)=>a===ce?b.createElement(ue,{type:"ellipsis",key:1===t?"start-ellipsis":"end-ellipsis"}):b.createElement(ue,{key:a,type:"page",page:a,currentPage:e,currentPageLabel:s,onClick:()=>null==u?void 0:u(a,e),ariaLabel:`${r} ${a}`})))),[f,e,s,r,u]),p]},pe=b.forwardRef(((e,a)=>{var{className:t,currentPage:n=1,totalPages:s,hasMorePages:r=!1,siblingCount:i,currentPageLabel:d,pageLabel:c,previousLabel:u,nextLabel:m,onNext:p,onPrevious:f,onChange:C}=e,g=o.__rest(e,["className","currentPage","totalPages","hasMorePages","siblingCount","currentPageLabel","pageLabel","previousLabel","nextLabel","onNext","onPrevious","onChange"]);const h=me({currentPage:n,totalPages:s,hasMorePages:r,siblingCount:i,currentPageLabel:d,pageLabel:c,previousLabel:u,nextLabel:m,onNext:p,onPrevious:f,onChange:C});return b.createElement(l.View,Object.assign({as:"nav",className:v.default(l.ComponentClassNames.Pagination,t),ref:a},g),b.createElement(l.Flex,{as:"ol",justifyContent:"center",alignItems:"center",gap:"inherit"},h))}));pe.displayName="Pagination";const fe=e=>{const{currentPage:a=1,totalPages:t,hasMorePages:n=!1,siblingCount:l=1}=e,s=Math.max(a,1),r=Math.max(s,t),[o,i]=b.useState(s);b.useEffect((()=>{i(s)}),[s,r]);const d=b.useCallback((()=>{o<r&&i(o+1)}),[o,r]),c=b.useCallback((()=>{o>1&&i(o-1)}),[o]),u=b.useCallback((e=>{"number"==typeof e&&i(e)}),[]);return{currentPage:o,hasMorePages:n,onChange:u,onNext:d,onPrevious:c,siblingCount:Math.max(l,1),totalPages:r}},Ce=(e,a)=>l.strHasLength(e)?e.toLowerCase().includes(a.toLowerCase()):"object"==typeof e&&null!==e&&Object.values(e).some((e=>Ce(e,a))),ge=(e,a)=>Math.ceil(e/a),he=10,be=e=>{var{children:a,direction:t="column",items:n}=e,s=o.__rest(e,["children","direction","items"]);return b.createElement(l.Flex,Object.assign({direction:t},s),Array.isArray(n)?n.map(a):null)},Ne=e=>{var{children:a,items:t}=e,n=o.__rest(e,["children","items"]);return b.createElement(de,Object.assign({},n),Array.isArray(t)?t.map(a):null)},Ee=e=>{var{className:a,isSearchable:t,isPaginated:n,items:s,itemsPerPage:r=he,searchFilter:i=Ce,searchLabel:d=l.ComponentText.Collection.searchButtonLabel,searchNoResultsFound:c,searchPlaceholder:u,type:m="list",testId:p}=e,f=o.__rest(e,["className","isSearchable","isPaginated","items","itemsPerPage","searchFilter","searchLabel","searchNoResultsFound","searchPlaceholder","type","testId"]);const[C,g]=b.useState(),h=b.useCallback(F.default(g,300),[g]);s=Array.isArray(s)?s:[],t&&l.strHasLength(C)&&(s=s.filter((e=>i(e,C))));const N=fe({totalPages:ge(s.length,r)});n&&(s=((e,a,t)=>{if(a<1||t<1)return[];const n=(a-1)*t;return e.slice(n,n+t)})(s,N.currentPage,r));const E="list"===m?b.createElement(be,Object.assign({className:l.ComponentClassNames.CollectionItems,items:s},f)):"grid"===m?b.createElement(Ne,Object.assign({className:l.ComponentClassNames.CollectionItems,items:s},f)):null;return b.createElement(l.Flex,{testId:p,className:v.default(l.ComponentClassNames.Collection,a)},t?b.createElement(l.Flex,{className:l.ComponentClassNames.CollectionSearch},b.createElement(K,{label:d,placeholder:u,onChange:e=>h(e.target.value),onClear:()=>g("")})):null,((e,a,t)=>a.length?e:t||b.createElement(l.Flex,{justifyContent:"center"},b.createElement(l.Text,null,l.ComponentText.Collection.searchNoResultsFound)))(E,s,c),n?b.createElement(l.Flex,{className:l.ComponentClassNames.CollectionPagination},b.createElement(pe,Object.assign({},N))):null)};Ee.displayName="Collection";const ve=b.forwardRef(((e,a)=>{var{className:t,orientation:s="horizontal",size:r,label:i}=e,d=o.__rest(e,["className","orientation","size","label"]);const c=v.default(l.ComponentClassNames.Divider,n.classNameModifier(l.ComponentClassNames.Divider,s),n.classNameModifier(l.ComponentClassNames.Divider,r),i?l.ComponentClassNames.DividerLabel:null,t);return b.createElement(l.View,Object.assign({"aria-orientation":s,as:"hr",className:c,"data-size":r,"data-label":i,ref:a},d))}));ve.displayName="Divider";const Fe=b.createContext("inactive"),ye=({value:e,children:a})=>b.createElement(Fe.Provider,{value:e},a),we=N.default.forwardRef(((e,a)=>{var{className:t,children:s,testId:r,isDisabled:i,onDragEnter:d,onDragLeave:c,onDragOver:u,onDragStart:m,onDrop:p}=e,f=o.__rest(e,["className","children","testId","isDisabled","onDragEnter","onDragLeave","onDragOver","onDragStart","onDrop"]);const C=N.default.useContext(Fe),g=i?{}:{onDragEnter:d,onDragLeave:c,onDragOver:u,onDragStart:m,onDrop:p};return N.default.createElement(l.View,Object.assign({},f,g,{isDisabled:i,className:v.default(t,n.classNameModifierByFlag(l.ComponentClassNames.DropZone,"rejected","reject"===C),n.classNameModifierByFlag(l.ComponentClassNames.DropZone,"accepted","accept"===C),n.classNameModifierByFlag(n.ComponentClassName.DropZone,"disabled",i),l.ComponentClassNames.DropZone),"data-testid":r,ref:a}),s)}));we.displayName="DropZoneContainer";const xe=Object.assign(b.forwardRef(((e,a)=>{var{children:t,testId:n,isDisabled:s,acceptedFileTypes:r,onDropComplete:i}=e,d=o.__rest(e,["children","testId","isDisabled","acceptedFileTypes","onDropComplete"]);const{dragState:c,onDragEnter:u,onDragLeave:m,onDragOver:p,onDragStart:f,onDrop:C}=l.useDropZone(Object.assign({acceptedFileTypes:r,onDropComplete:i},d));return b.createElement(ye,{value:c},b.createElement(we,Object.assign({},d,{testId:n,isDisabled:s,onDragStart:f,onDragEnter:u,onDragLeave:m,onDrop:C,onDragOver:p,ref:a}),t))})),{Accepted:({children:e})=>{const a=b.useContext(Fe);if(!a)throw new Error("`DropZone.Accept` must be used inside a DropZone");return"accept"===a?b.createElement(b.Fragment,null,e):null},Rejected:({children:e})=>{const a=b.useContext(Fe);if(!a)throw new Error("`DropZone.Rejected` must be used inside a DropZone");return"reject"===a?b.createElement(b.Fragment,null,e):null},Default:({children:e})=>{const a=b.useContext(Fe);if(!a)throw new Error("`DropZone.Default` must be used inside a DropZone");return"inactive"===a?b.createElement(b.Fragment,null,e):null}});xe.displayName="DropZone";const Se=({message:e,shouldWarn:a})=>{const t=a&&("undefined"==typeof process||process&&"production"!==process.env.NODE_ENV);s.useDeprecationWarning({message:e,shouldWarn:t})},{Root:Ie}=n.sanitizeNamespaceImport(y),Te=b.forwardRef(((e,a)=>{var{children:t,className:n,defaultValue:s,isCollapsible:r,onChange:i,onValueChange:d,testId:c,type:u="single",value:m}=e,p=o.__rest(e,["children","className","defaultValue","isCollapsible","onChange","onValueChange","testId","type","value"]);const{rest:f}=q(p),C=null!=d?d:i;Se({shouldWarn:!!i,message:"Expander `onChange` prop will be deprecated in the next major release of @aws-amplify/ui-react. Please replace usage with `onValueChange`."});return"multiple"===u?b.createElement(Ie,Object.assign({className:v.default(l.ComponentClassNames.Expander,n),"data-testid":c,defaultValue:s,onValueChange:C,ref:a,type:u,value:m},f),t):b.createElement(Ie,Object.assign({className:v.default(l.ComponentClassNames.Expander,n),collapsible:r,"data-testid":c,defaultValue:s,onValueChange:C,ref:a,type:u,value:m},f),t)}));Te.displayName="Expander";const{Item:Pe,Header:De,Trigger:ke,Content:Me}=n.sanitizeNamespaceImport(y),Oe=b.forwardRef(((e,a)=>{var t,{children:n,className:s,title:r,value:i}=e,d=o.__rest(e,["children","className","title","value"]);const c=V(),u=V(),{rest:m}=q(d),p=l.useIcons("expander");return b.createElement(Pe,Object.assign({className:v.default(l.ComponentClassNames.ExpanderItem,s),"data-testid":"expander-item",ref:a,value:i},m),b.createElement(De,{className:l.ComponentClassNames.ExpanderHeader,"data-testid":"expander-header"},b.createElement(ke,{"aria-controls":u,className:l.ComponentClassNames.ExpanderTrigger,id:c},r,b.createElement("span",{className:l.ComponentClassNames.ExpanderIcon,"data-testid":"expander-icon","aria-hidden":"true"},null!==(t=null==p?void 0:p.more)&&void 0!==t?t:b.createElement(l.IconExpandMore,null)))),b.createElement(Me,{"aria-labelledby":c,className:l.ComponentClassNames.ExpanderContent,id:u},b.createElement(l.View,{className:l.ComponentClassNames.ExpanderContentText,testId:"expander-content-text"},n)))}));Oe.displayName="ExpanderItem";const Re=b.forwardRef(((e,a)=>{var{children:t,className:s,isDisabled:r,legend:i,legendHidden:d,size:c,testId:u,variation:m="outlined"}=e,p=o.__rest(e,["children","className","isDisabled","legend","legendHidden","size","testId","variation"]);const{isFieldsetDisabled:f}=l.useFieldset(),C=f||r,g=b.useMemo((()=>({isFieldsetDisabled:C})),[C]),h=v.default(l.ComponentClassNames.Fieldset,n.classNameModifier(l.ComponentClassNames.Fieldset,m),n.classNameModifier(l.ComponentClassNames.Fieldset,c),s),N=v.default(l.ComponentClassNames.FieldsetLegend,n.classNameModifier(l.ComponentClassNames.FieldsetLegend,c),s,{[l.ComponentClassNames.VisuallyHidden]:d});return b.createElement(l.FieldsetContext.Provider,{value:g},b.createElement(l.Flex,Object.assign({as:"fieldset",className:h,ref:a,disabled:C,testId:u},p),b.createElement(re,{as:"legend"},i),b.createElement(l.View,{as:"div","aria-hidden":"true",className:N},i),t))}));Re.displayName="Fieldset";const Be={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"},Le=b.forwardRef(((e,a)=>{var{className:t,children:s,isTruncated:r,level:i=6}=e,d=o.__rest(e,["className","children","isTruncated","level"]);return b.createElement(l.View,Object.assign({as:Be[i],className:v.default(l.ComponentClassNames.Heading,n.classNameModifier(l.ComponentClassNames.Heading,i),n.classNameModifierByFlag(l.ComponentClassNames.Heading,"truncated",r),t),ref:a},d),s)}));Le.displayName="Heading";const Ve=b.forwardRef(((e,a)=>{var{className:t}=e,n=o.__rest(e,["className"]);return b.createElement(l.View,Object.assign({as:"img",ref:a,className:v.default(l.ComponentClassNames.Image,t)},n))}));Ve.displayName="Image";const _e=b.forwardRef(((e,a)=>{var{ariaLabel:t,className:s,children:r,isFullWidth:i=!1,isDisabled:d,isLoading:c,size:u,style:m,type:p="button",variation:f,testId:C}=e,g=o.__rest(e,["ariaLabel","className","children","isFullWidth","isDisabled","isLoading","size","style","type","variation","testId"]);const{propStyles:h,nonStyleProps:N}=l.useStyles(g,m),E=v.default(l.ComponentClassNames.Button,n.classNameModifier(l.ComponentClassNames.Button,u),n.classNameModifier(l.ComponentClassNames.Button,f),s);return b.createElement(l.Button,Object.assign({ref:a,className:E,"data-fullwidth":i,"data-loading":c,"data-size":u,"data-variation":f,disabled:null!=d?d:c,type:p,"data-testid":C,"aria-label":t,style:h},N),r)}));_e.displayName="MenuButton";const{DropdownMenu:je,DropdownMenuTrigger:Ae,DropdownMenuContent:He}=n.sanitizeNamespaceImport(w),ze=b.forwardRef(((e,a)=>{var t,{menuAlign:n="start",children:s,className:r,isOpen:i,size:d,trigger:c,triggerClassName:u,ariaLabel:m,onOpenChange:p}=e,f=o.__rest(e,["menuAlign","children","className","isOpen","size","trigger","triggerClassName","ariaLabel","onOpenChange"]);const C=l.useIcons("menu");return b.createElement(je,{onOpenChange:p,open:i},b.createElement(Ae,{asChild:!0},null!=c?c:b.createElement(_e,{ariaLabel:m,size:d,testId:"amplify-menu-trigger-test-id",className:v.default(l.ComponentClassNames.MenuTrigger,u)},null!==(t=null==C?void 0:C.menu)&&void 0!==t?t:b.createElement(l.IconMenu,null))),b.createElement(He,{align:n,className:l.ComponentClassNames.MenuContentWrapper},b.createElement(le,Object.assign({className:v.default(l.ComponentClassNames.MenuContent,r),ref:a,size:d,testId:"amplify-menu-items-group-test-id"},f),s)))}));ze.displayName="Menu";const{DropdownMenuItem:Ue}=n.sanitizeNamespaceImport(w),Ge=b.forwardRef(((e,a)=>{var{children:t,className:n}=e,s=o.__rest(e,["children","className"]);return b.createElement(Ue,{asChild:!0,ref:a},b.createElement(_e,Object.assign({className:v.default(l.ComponentClassNames.MenuItem,n),testId:"amplify-menu-item-test-id"},s,{variation:"menu"}),t))}));Ge.displayName="MenuItem";const qe=b.forwardRef(((e,a)=>{var{children:t,className:n}=e,s=o.__rest(e,["children","className"]);return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.MessageHeading,n),ref:a},s),t)}));qe.displayName="MessageHeading";const We=b.createContext({dismissed:!1,setDismissed:()=>{}}),$e=()=>b.useContext(We),Ze=b.forwardRef(((e,a)=>{var t,n,s,r,{className:i}=e,d=o.__rest(e,["className"]);const c=l.useIcons("message"),{colorTheme:u}=$e();let m;switch(u){case"info":m=null!==(t=null==c?void 0:c.info)&&void 0!==t?t:b.createElement(l.IconInfo,null);break;case"error":m=null!==(n=null==c?void 0:c.error)&&void 0!==n?n:b.createElement(l.IconError,null);break;case"warning":m=null!==(s=null==c?void 0:c.warning)&&void 0!==s?s:b.createElement(l.IconWarning,null);break;case"success":m=null!==(r=null==c?void 0:c.success)&&void 0!==r?r:b.createElement(l.IconCheckCircle,null)}return m?b.createElement(l.View,Object.assign({className:v.default(l.ComponentClassNames.MessageIcon,i),"aria-hidden":"true",ref:a},d),m):null}));Ze.displayName="MessageIcon";const Ke=b.forwardRef(((e,a)=>{var t,{onDismiss:s,dismissLabel:r,hasIcon:i=!0,children:d,className:c}=e,u=o.__rest(e,["onDismiss","dismissLabel","hasIcon","children","className"]);const{setDismissed:m}=$e(),p=l.useIcons("message"),f=b.useCallback((()=>{m(!0),n.isFunction(s)&&s()}),[m,s]);return b.createElement(l.Button,Object.assign({variation:"link",colorTheme:"overlay",className:v.default(l.ComponentClassNames.MessageDismiss,c),ref:a,onClick:f},u),i?null!==(t=null==p?void 0:p.close)&&void 0!==t?t:b.createElement(l.IconClose,{"aria-hidden":"true"}):null,d||b.createElement(re,null,r||l.ComponentText.Message.dismissLabel))}));Ke.displayName="MessageContent";const Ye=b.forwardRef(((e,a)=>{var{children:t,className:n}=e,s=o.__rest(e,["children","className"]);return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.MessageContent,n),ref:a},s),t)}));Ye.displayName="MessageContent";const Xe=b.forwardRef(((e,a)=>{var{children:t,className:s,colorTheme:r="neutral",variation:i="filled"}=e,d=o.__rest(e,["children","className","colorTheme","variation"]);const[c,u]=b.useState(!1),m=b.useMemo((()=>({colorTheme:r,dismissed:c,setDismissed:u})),[r,c]);return b.createElement(We.Provider,{value:m},c?null:b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Message,n.classNameModifier(l.ComponentClassNames.Message,i),n.classNameModifier(l.ComponentClassNames.Message,r),s),ref:a},d),t))}));Xe.displayName="MessageContainer";const Qe=b.forwardRef(((e,a)=>{var{children:t,heading:n,dismissLabel:l,isDismissible:s,onDismiss:r,hasIcon:i=!0,colorTheme:d="neutral",variation:c="filled"}=e,u=o.__rest(e,["children","heading","dismissLabel","isDismissible","onDismiss","hasIcon","colorTheme","variation"]);return b.createElement(Xe,Object.assign({colorTheme:d,variation:c,ref:a},u),i?b.createElement(Ze,null):null,b.createElement(Ye,null,n?b.createElement(qe,null,n):null,t),s?b.createElement(Ke,{onDismiss:r,dismissLabel:l}):null)}));Qe.displayName="Message";const{passwordIsHidden:Je,passwordIsShown:ea,showPassword:aa}=l.ComponentText.PasswordField,ta=b.forwardRef(((e,a)=>{var t,s,{fieldType:r,passwordIsHiddenLabel:i=Je,passwordIsShownLabel:d=ea,showPasswordButtonLabel:c=aa,size:u,hasError:m}=e,p=o.__rest(e,["fieldType","passwordIsHiddenLabel","passwordIsShownLabel","showPasswordButtonLabel","size","hasError"]);const f=l.useIcons("passwordField"),C=v.default(l.ComponentClassNames.FieldShowPassword,n.classNameModifierByFlag(l.ComponentClassNames.FieldShowPassword,"error",m)),g="password"===r?null!==(t=null==f?void 0:f.visibility)&&void 0!==t?t:b.createElement(l.IconVisibility,{"aria-hidden":"true"}):null!==(s=null==f?void 0:f.visibilityOff)&&void 0!==s?s:b.createElement(l.IconVisibilityOff,{"aria-hidden":"true"});return b.createElement(l.Button,Object.assign({"aria-checked":"password"!==r,ariaLabel:c,className:C,ref:a,role:"switch",size:u},p),b.createElement(re,{"aria-live":"polite"},"password"===r?i:d),g)}));ta.displayName="ShowPasswordButton";const na=b.forwardRef(((e,a)=>{var{autoComplete:t="current-password",label:n,className:s,hideShowPassword:r=!1,passwordIsHiddenLabel:i,passwordIsShownLabel:d,showPasswordButtonLabel:c,showPasswordButtonRef:u,size:m,hasError:p}=e,f=o.__rest(e,["autoComplete","label","className","hideShowPassword","passwordIsHiddenLabel","passwordIsShownLabel","showPasswordButtonLabel","showPasswordButtonRef","size","hasError"]);const[C,g]=b.useState("password"),h=b.useCallback((()=>{g("password"===C?"text":"password")}),[g,C]);return b.createElement(W,Object.assign({autoComplete:t,outerEndComponent:r?null:b.createElement(ta,{fieldType:C,onClick:h,passwordIsHiddenLabel:i,passwordIsShownLabel:d,ref:u,size:m,showPasswordButtonLabel:c,hasError:p}),size:m,type:C,label:n,className:v.default(l.ComponentClassNames.PasswordField,s),ref:a,hasError:p},f))}));na.displayName="PasswordField";const la=b.forwardRef(((e,a)=>{var t,{autoComplete:s,className:r,size:i,variation:d,value:c,defaultValue:u,hasError:m,icon:p,iconColor:f,children:C,placeholder:g,isDisabled:h,isRequired:N,isMultiple:E=!1,selectSize:F=1}=e,y=o.__rest(e,["autoComplete","className","size","variation","value","defaultValue","hasError","icon","iconColor","children","placeholder","isDisabled","isRequired","isMultiple","selectSize"]);const w=void 0===c&&void 0===u&&g,x=E||F>1,S=v.default(l.ComponentClassNames.Select,l.ComponentClassNames.FieldGroupControl,n.classNameModifier(l.ComponentClassNames.Select,i),n.classNameModifier(l.ComponentClassNames.Select,d),n.classNameModifierByFlag(l.ComponentClassNames.Select,"error",m),n.classNameModifierByFlag(l.ComponentClassNames.Select,"expanded",x),r),I=l.useIcons("select"),{isFieldsetDisabled:T}=l.useFieldset();return b.createElement(l.View,{className:l.ComponentClassNames.SelectWrapper},b.createElement(l.View,Object.assign({"aria-invalid":m,as:"select",autoComplete:s,value:c,defaultValue:w?"":u,isDisabled:T||h,multiple:E,size:F,required:N,"data-size":i,"data-variation":d,className:S,ref:a},y),g&&b.createElement("option",{value:""},g),C),x?null:b.createElement(l.Flex,{className:v.default(l.ComponentClassNames.SelectIconWrapper,n.classNameModifier(l.ComponentClassNames.SelectIconWrapper,i)),color:f},null!==(t=null!=p?p:null==I?void 0:I.expand)&&void 0!==t?t:b.createElement(l.IconExpandMore,null)))}));la.displayName="Select";const sa=b.forwardRef(((e,a)=>{const{children:t,className:s,descriptiveText:r,errorMessage:i,hasError:d=!1,id:c,label:u,labelHidden:m=!1,options:p,size:f,testId:C,inputStyles:g}=e,h=o.__rest(e,["children","className","descriptiveText","errorMessage","hasError","id","label","labelHidden","options","size","testId","inputStyles"]),N=V(c),E=V(),F=r?E:void 0,{styleProps:y,rest:w}=q(h);return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Field,n.classNameModifier(l.ComponentClassNames.Field,f),l.ComponentClassNames.SelectField,s),"data-size":f,testId:C},y),b.createElement(l.Label,{htmlFor:N,visuallyHidden:m},u),b.createElement(l.FieldDescription,{id:E,labelHidden:m,descriptiveText:r}),b.createElement(la,Object.assign({"aria-describedby":F,hasError:d,id:N,ref:a,size:f},w,g),(({children:e,options:a})=>e?((null==a?void 0:a.length)&&console.warn("Amplify UI: <SelectField> component defaults to rendering children over `options`. When using the `options` prop, omit children."),e):null==a?void 0:a.map(((e,a)=>b.createElement("option",{label:e,value:e,key:`${e}-${a}`},e))))({children:t,options:p})),b.createElement(l.FieldErrorMessage,{hasError:d,errorMessage:i}))}));sa.displayName="SelectField";const ra=b.forwardRef(((e,a)=>{var{className:t,dialCodeList:s,isReadOnly:r}=e,i=o.__rest(e,["className","dialCodeList","isReadOnly"]);const d=null!=s?s:n.countryDialCodes,c=b.useMemo((()=>d.map((e=>b.createElement("option",{key:e,value:e,disabled:r},e)))),[d,r]);return b.createElement(sa,Object.assign({"aria-disabled":r,autoComplete:"tel-country-code",className:v.default(l.ComponentClassNames.CountryCodeSelect,l.ComponentClassNames.DialCodeSelect,t),labelHidden:!0,ref:a},i),c)}));ra.displayName="CountryCodeSelect";const oa=b.forwardRef(((e,a)=>{var{autoComplete:t="tel-national",className:n,countryCodeName:s,countryCodeLabel:r=l.ComponentText.PhoneNumberField.countryCodeLabel,countryCodeRef:i,defaultCountryCode:d,defaultDialCode:c,dialCodeLabel:u=l.ComponentText.PhoneNumberField.countryCodeLabel,dialCodeList:m,dialCodeName:p,dialCodeRef:f,hasError:C,isDisabled:g,isReadOnly:h,onCountryCodeChange:N,onDialCodeChange:E,onInput:F,size:y,variation:w}=e,x=o.__rest(e,["autoComplete","className","countryCodeName","countryCodeLabel","countryCodeRef","defaultCountryCode","defaultDialCode","dialCodeLabel","dialCodeList","dialCodeName","dialCodeRef","hasError","isDisabled","isReadOnly","onCountryCodeChange","onDialCodeChange","onInput","size","variation"]);const S=null!=p?p:s,I=null!=u?u:r,T=null!=c?c:d,P=null!=E?E:N,D=null!=f?f:i;return b.createElement(W,Object.assign({outerStartComponent:b.createElement(ra,{defaultValue:T,dialCodeList:m,className:n,hasError:C,isDisabled:g,isReadOnly:h,label:I,name:S,onChange:P,ref:D,size:y,variation:w}),autoComplete:t,className:v.default(l.ComponentClassNames.PhoneNumberField,n),hasError:C,isDisabled:g,isReadOnly:h,onInput:F,ref:a,size:y,type:"tel",variation:w},x))}));oa.displayName="PhoneNumberField";const ia=b.forwardRef(((e,a)=>{var{className:t,children:s,isLoaded:r,size:i}=e,d=o.__rest(e,["className","children","isLoaded","size"]);return r?b.createElement(b.Fragment,null,s):b.createElement(l.View,Object.assign({className:v.default(l.ComponentClassNames.Placeholder,n.classNameModifier(l.ComponentClassNames.Placeholder,i),t),"data-size":i,ref:a},d))}));ia.displayName="Placeholder";const da=N.default.createContext({name:"default"}),ca=b.forwardRef(((a,t)=>{var{children:s,className:r,id:i,isDisabled:d,testId:c,value:u,labelPosition:m,height:p,width:f,bottom:C,left:g,position:h,padding:N,right:E,top:F}=a,y=o.__rest(a,["children","className","id","isDisabled","testId","value","labelPosition","height","width","bottom","left","position","padding","right","top"]);const{currentValue:w,defaultValue:x,name:S,hasError:I,isGroupDisabled:T,isRequired:P,isReadOnly:D,onChange:k,size:M,labelPosition:O}=e.useContext(da),{isFieldsetDisabled:R}=l.useFieldset(),B=R||(T||d||D&&x!==u),L=void 0!==w?u===w:void 0,V=void 0!==x?u===x:void 0,_=m||O;return b.createElement(l.Flex,{as:"label",className:v.default(l.ComponentClassNames.Radio,n.classNameModifierByFlag(l.ComponentClassNames.Radio,"disabled",B),r),"data-disabled":B,"data-label-position":_,height:p,width:f,bottom:C,top:F,right:E,left:g,position:h,padding:N},s&&b.createElement(l.Text,{as:"span",className:l.ComponentClassNames.RadioLabel,"data-disabled":B},s),b.createElement(G,Object.assign({checked:L,className:v.default(l.ComponentClassNames.VisuallyHidden,l.ComponentClassNames.RadioInput),defaultChecked:V,hasError:I,id:i,isDisabled:B,isReadOnly:D,isRequired:P,onChange:k,ref:t,type:"radio",name:S,value:u},y)),b.createElement(l.Flex,{"aria-hidden":"true",as:"span",className:v.default(l.ComponentClassNames.RadioButton,n.classNameModifier(l.ComponentClassNames.RadioButton,M)),"data-size":M,testId:c}))}));ca.displayName="Radio";const ua=b.forwardRef(((e,a)=>{var{children:t,className:s,defaultValue:r,descriptiveText:i,errorMessage:d,hasError:c=!1,id:u,isDisabled:m,isRequired:p,isReadOnly:f,label:C,labelHidden:g=!1,labelPosition:h,onChange:N,name:E,size:F,testId:y,value:w}=e,x=o.__rest(e,["children","className","defaultValue","descriptiveText","errorMessage","hasError","id","isDisabled","isRequired","isReadOnly","label","labelHidden","labelPosition","onChange","name","size","testId","value"]);const S=V(u),I=V(),T=i?I:void 0,P=j(y,l.ComponentClassNames.RadioGroup),D=b.useMemo((()=>({currentValue:w,defaultValue:r,hasError:c,isRequired:p,isReadOnly:f,isGroupDisabled:m,onChange:N,size:F,name:E,labelPosition:h})),[r,c,m,p,f,N,F,E,w,h]);return b.createElement(l.Flex,Object.assign({as:"fieldset",className:v.default(l.ComponentClassNames.Field,n.classNameModifier(l.ComponentClassNames.Field,F),l.ComponentClassNames.RadioGroupField,s),"data-size":F,ref:a,role:"radiogroup",testId:y},x),b.createElement(re,{as:"legend"},C),b.createElement(l.Label,{"aria-hidden":!0,visuallyHidden:g},C),b.createElement(l.FieldDescription,{id:I,labelHidden:g,descriptiveText:i}),b.createElement(l.Flex,{"aria-describedby":T,className:l.ComponentClassNames.RadioGroup,id:S,testId:P},b.createElement(da.Provider,{value:D},t)),b.createElement(l.FieldErrorMessage,{hasError:c,errorMessage:d}))}));ua.displayName="RadioGroupField";const ma=({icon:e,fill:a,className:t})=>b.createElement(l.View,{as:"span",className:"amplify-rating-icon-container","aria-hidden":"true"},b.createElement(l.View,{as:"span",className:v.default(t),color:a},e));ma.displayName="RatingIcon";const pa=({emptyColor:e,emptyIcon:a,fillColor:t,fillIcon:n,value:s})=>{const r=s%1*100+"%";return b.createElement(l.View,{as:"span",className:"amplify-rating-icon-container","aria-hidden":"true"},b.createElement(l.View,{as:"span",className:"amplify-rating-label"},b.createElement(l.View,{as:"span",className:v.default("amplify-rating-icon","amplify-rating-icon-empty"),color:e},a)),b.createElement(l.View,{as:"span",className:"amplify-rating-label",width:r},b.createElement(l.View,{as:"span",className:v.default("amplify-rating-icon","amplify-rating-icon-filled"),color:t},n)))};pa.displayName="RatingMixedIcon";const fa=5,Ca=0,ga=b.forwardRef(((e,a)=>{var t,s,r,{className:i,emptyColor:d,emptyIcon:c,fillColor:u,icon:m,maxValue:p=fa,size:f,value:C=Ca}=e,g=o.__rest(e,["className","emptyColor","emptyIcon","fillColor","icon","maxValue","size","value"]);const h=l.useIcons("rating"),N=null!==(t=null!=m?m:null==h?void 0:h.filled)&&void 0!==t?t:b.createElement(l.IconStar,null),E=null!==(r=null!==(s=null!=c?c:m)&&void 0!==s?s:null==h?void 0:h.empty)&&void 0!==r?r:b.createElement(l.IconStar,null),F=new Array(Math.ceil(p)).fill(1).map(((e,a)=>{const t=a+1;return((e,a)=>e<=a)(t,C)?b.createElement(ma,{key:a.toString(),icon:N,fill:u,className:"amplify-rating-icon-filled"}):((e,a)=>e-1>=a)(t,C)?b.createElement(ma,{key:a.toString(),icon:E,fill:d,className:"amplify-rating-icon-empty"}):((e,a)=>e>a&&e-1<a)(t,C)?b.createElement(pa,{key:a.toString(),fillIcon:N,emptyIcon:E,value:C,fillColor:u,emptyColor:d}):void 0}));return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Rating,n.classNameModifier(l.ComponentClassNames.Rating,f),i),"data-size":f,ref:a},g),F,b.createElement(re,null,C," out of ",p," rating"))}));ga.displayName="Rating";const{Range:ha,Root:ba,Thumb:Na,Track:Ea}=n.sanitizeNamespaceImport(x),va=b.forwardRef(((e,a)=>{var{ariaValuetext:t,className:s,defaultValue:r=0,descriptiveText:i,emptyTrackColor:d,errorMessage:c,filledTrackColor:u,formatValue:m,hasError:p=!1,id:f,isDisabled:C,isValueHidden:g=!1,label:h,labelHidden:N=!1,onChange:E,orientation:F="horizontal",outerEndComponent:y,outerStartComponent:w,testId:x,thumbColor:S,trackSize:I,value:T,size:P}=e,D=o.__rest(e,["ariaValuetext","className","defaultValue","descriptiveText","emptyTrackColor","errorMessage","filledTrackColor","formatValue","hasError","id","isDisabled","isValueHidden","label","labelHidden","onChange","orientation","outerEndComponent","outerStartComponent","testId","thumbColor","trackSize","value","size"]);const{isFieldsetDisabled:k}=l.useFieldset(),M=V(f),O=V(),R=V(),B=i?R:void 0,{styleProps:L,rest:_}=q(D),j=void 0!==T,[A,H]=b.useState(j?T:r),z=j?[T]:void 0,G=j?void 0:[r],W=b.useCallback((e=>{H(e[0]),n.isFunction(E)&&E(e[0])}),[E]),$=b.useMemo((()=>{const e=n.isFunction(m)?m(A):A;return"string"==typeof m?b.createElement(l.View,{as:"span"},e):e}),[A,m]),Z="vertical"===F,K=v.default(l.ComponentClassNames.SliderFieldTrack,n.classNameModifier(l.ComponentClassNames.SliderFieldTrack,F),n.classNameModifier(l.ComponentClassNames.SliderFieldTrack,P)),Y=v.default(l.ComponentClassNames.SliderFieldRoot,n.classNameModifier(l.ComponentClassNames.SliderFieldRoot,F),n.classNameModifier(l.ComponentClassNames.SliderFieldRoot,P),s);return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Field,n.classNameModifier(l.ComponentClassNames.Field,P),l.ComponentClassNames.SliderField),testId:x,"data-size":P},L),b.createElement(l.Label,{className:l.ComponentClassNames.SliderFieldLabel,id:O,testId:"slider-label",visuallyHidden:N},b.createElement(l.View,{as:"span"},h),g?null:$),b.createElement(l.FieldDescription,{id:R,labelHidden:N,descriptiveText:i}),b.createElement(U,{className:l.ComponentClassNames.SliderFieldGroup,id:M,orientation:F,outerStartComponent:w,outerEndComponent:y},b.createElement(ba,Object.assign({className:Y,"data-testid":"slider-root",disabled:k||C,defaultValue:G,onValueChange:W,orientation:F,ref:a,value:z},_),b.createElement(Ea,{className:K,"data-testid":"slider-track",style:{backgroundColor:String(d),[""+(Z?"width":"height")]:I}},b.createElement(ha,{className:v.default(l.ComponentClassNames.SliderFieldRange,n.classNameModifier(l.ComponentClassNames.SliderFieldRange,F)),"data-testid":"slider-range",style:{backgroundColor:String(u)}})),b.createElement(Na,{"aria-describedby":B,"aria-labelledby":O,"aria-valuetext":t,className:v.default(l.ComponentClassNames.SliderFieldThumb,n.classNameModifier(l.ComponentClassNames.SliderFieldThumb,P)),style:{backgroundColor:String(S)}}))),b.createElement(l.FieldErrorMessage,{hasError:p,errorMessage:c}))}));va.displayName="SliderField";const Fa=({max:e,min:a,step:t,value:n})=>{const l=(n-a)%t;return n=n-l+Math.round(l/t)*t,(n=Math.max(a,n))>e&&(n=e-(e-a)%t),n},ya=b.forwardRef(((e,a)=>{var t,s;const{className:r,defaultValue:i,descriptiveText:d,errorMessage:c,hasError:u=!1,id:m,inputStyles:p,isDisabled:f,isReadOnly:C,isRequired:g,increaseButtonLabel:h=l.ComponentText.StepperField.increaseButtonLabel,decreaseButtonLabel:N=l.ComponentText.StepperField.decreaseButtonLabel,label:E,labelHidden:F=!1,onStepChange:y,size:w,testId:x,value:S,variation:I}=e,T=o.__rest(e,["className","defaultValue","descriptiveText","errorMessage","hasError","id","inputStyles","isDisabled","isReadOnly","isRequired","increaseButtonLabel","decreaseButtonLabel","label","labelHidden","onStepChange","size","testId","value","variation"]),P=V(m),D=V(),k=d?D:void 0,{styleProps:M,rest:O}=q(T),R=l.useIcons("stepperField"),{step:B,value:L,inputValue:_,handleDecrease:j,handleIncrease:A,handleOnBlur:H,handleOnChange:z,handleOnWheel:W,setInputValue:$,shouldDisableDecreaseButton:Z,shouldDisableIncreaseButton:K}=(({defaultValue:e=0,value:a,step:t=1,max:l=Number.MAX_SAFE_INTEGER,min:s=Number.MIN_SAFE_INTEGER,isDisabled:r,isReadOnly:o,onChange:i,onDecrease:d,onIncrease:c,onStepChange:u})=>{var m,p;const f=void 0!==a;l=Math.max(s,l);const[C,g]=b.useState((()=>Fa({min:s,max:l,step:t,value:e}))),h=f?Fa({min:s,max:l,step:t,value:a}):C,N=null!==(m=null!=r?r:o)&&void 0!==m?m:h+t>l,E=null!==(p=null!=r?r:o)&&void 0!==p?p:h-t<s,[v,F]=b.useState(h),y=b.useCallback((e=>{F(e.target.value),n.isFunction(i)&&i(e)}),[i]),w=b.useCallback((e=>{const a=parseFloat(e.target.value);if(isNaN(a))return;const r=Fa({min:s,max:l,step:t,value:a});f||g(r),n.isFunction(u)&&u(r),F(r)}),[s,l,t,f,u]),x=b.useCallback((()=>{f||g(h+t),n.isFunction(u)&&u(h+t),n.isFunction(c)&&c(),F(h+t)}),[t,h,f,c,u]),S=b.useCallback((()=>{f||g(h-t),n.isFunction(u)&&u(h-t),n.isFunction(d)&&d(),F(h-t)}),[t,h,f,d,u]),I=b.useCallback((e=>{e.currentTarget.blur()}),[]);return{step:t,value:h,inputValue:v,handleDecrease:S,handleIncrease:x,handleOnBlur:w,handleOnChange:y,handleOnWheel:I,setInputValue:F,shouldDisableDecreaseButton:E,shouldDisableIncreaseButton:N}})(Object.assign(Object.assign({},e),{defaultValue:i,onStepChange:y}));return b.useEffect((()=>{void 0!==S&&$(S)}),[S,$]),b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Field,n.classNameModifier(l.ComponentClassNames.Field,w),l.ComponentClassNames.StepperField,r),"data-size":w,"data-variation":I,testId:x},M),b.createElement(l.Label,{htmlFor:P,visuallyHidden:F},E),b.createElement(l.FieldDescription,{id:D,labelHidden:F,descriptiveText:d}),b.createElement(U,{outerStartComponent:b.createElement(l.FieldGroupIconButton,{"aria-controls":P,ariaLabel:`${N} ${L-B}`,className:v.default(l.ComponentClassNames.StepperFieldButtonDecrease,n.classNameModifier(l.ComponentClassNames.StepperFieldButtonDecrease,I),n.classNameModifierByFlag(l.ComponentClassNames.StepperFieldButtonDecrease,"disabled",Z)),"data-invalid":u,isDisabled:Z,onClick:j,size:w},null!==(t=null==R?void 0:R.remove)&&void 0!==t?t:b.createElement(l.IconRemove,{"data-testid":"decrease-icon"})),outerEndComponent:b.createElement(l.FieldGroupIconButton,{"aria-controls":P,ariaLabel:`${h} ${L+B}`,className:v.default(l.ComponentClassNames.StepperFieldButtonIncrease,n.classNameModifier(l.ComponentClassNames.StepperFieldButtonIncrease,I),n.classNameModifierByFlag(l.ComponentClassNames.StepperFieldButtonIncrease,"disabled",K)),"data-invalid":u,isDisabled:K,onClick:A,size:w},null!==(s=null==R?void 0:R.add)&&void 0!==s?s:b.createElement(l.IconAdd,{"data-testid":"increase-icon"}))},b.createElement(G,Object.assign({"aria-describedby":k,className:l.ComponentClassNames.StepperFieldInput,hasError:u,id:P,isDisabled:f,isReadOnly:C,isRequired:g,onBlur:H,onChange:z,onWheel:W,ref:a,size:w,variation:I,type:"number",value:_},p,O))),b.createElement(l.FieldErrorMessage,{hasError:u,errorMessage:c}))}));ya.displayName="StepperField";const wa=b.forwardRef(((a,t)=>{var{className:s,defaultChecked:r,id:i,isChecked:d,isDisabled:c,isLabelHidden:u,label:m,labelPosition:p,name:f,onChange:C,size:g,thumbColor:h,trackCheckedColor:N,trackColor:E,value:F,hasError:y,errorMessage:w}=a,x=o.__rest(a,["className","defaultChecked","id","isChecked","isDisabled","isLabelHidden","label","labelPosition","name","onChange","size","thumbColor","trackCheckedColor","trackColor","value","hasError","errorMessage"]);const{isOn:S,changeHandler:I,isFocused:T,setIsFocused:P}=(a=>{const{onChange:t,isChecked:l,defaultChecked:s,isDisabled:r}=a,o=void 0!==l,[i,d]=e.useState(o?l:!!s),[c,u]=e.useState(!1),m=e.useCallback((e=>{r?e.preventDefault():(n.isFunction(t)&&t(e),d(e.target.checked))}),[t,r]);return o&&i!==l&&d(l),{isOn:i,changeHandler:m,isFocused:c,setIsFocused:u}})({onChange:C,isChecked:d,defaultChecked:r,isDisabled:c}),{isFieldsetDisabled:D}=l.useFieldset(),k=D||c,M=V(i),O=u?re:l.View,R=v.default(l.ComponentClassNames.SwitchTrack,n.classNameModifierByFlag(l.ComponentClassNames.SwitchTrack,"checked",S),n.classNameModifierByFlag(l.ComponentClassNames.SwitchTrack,"disabled",k),n.classNameModifierByFlag(l.ComponentClassNames.SwitchTrack,"focused",T),n.classNameModifierByFlag(l.ComponentClassNames.SwitchTrack,"error",y)),B=v.default(l.ComponentClassNames.SwitchThumb,n.classNameModifierByFlag(l.ComponentClassNames.SwitchThumb,"checked",S),n.classNameModifierByFlag(l.ComponentClassNames.SwitchThumb,"disabled",k));return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.SwitchField,n.classNameModifier(l.ComponentClassNames.SwitchField,g),s),"data-size":g,"data-label-position":p,ref:t},x),b.createElement(re,null,b.createElement(G,{role:"switch",type:"checkbox",id:M,onChange:I,disabled:c,name:f,checked:S,value:F,onFocus:()=>{P(!0)},onBlur:()=>{P(!1)}})),b.createElement(l.Label,{htmlFor:M,className:v.default(l.ComponentClassNames.SwitchWrapper,n.classNameModifier(l.ComponentClassNames.SwitchWrapper,p)),"data-label-position":p},b.createElement(O,{as:"span",className:l.ComponentClassNames.SwitchLabel},m),b.createElement(l.View,{as:"span",className:R,"data-checked":S,"data-disabled":k,"data-focused":T,backgroundColor:S?N:E},b.createElement(l.View,{as:"span",className:B,"data-checked":S,"data-disabled":k,backgroundColor:h}))),b.createElement(l.FieldErrorMessage,{hasError:y,errorMessage:w}))}));wa.displayName="SwitchField";const xa=b.forwardRef(((e,a)=>{var{caption:t,children:s,className:r,highlightOnHover:i=!1,size:d,variation:c}=e,u=o.__rest(e,["caption","children","className","highlightOnHover","size","variation"]);const m=v.default(l.ComponentClassNames.Table,n.classNameModifier(l.ComponentClassNames.Table,d),n.classNameModifier(l.ComponentClassNames.Table,c),r);return b.createElement(l.View,Object.assign({as:"table",className:m,"data-highlightonhover":i,"data-size":d,"data-variation":c,ref:a},u),t&&b.createElement(l.View,{as:"caption",className:l.ComponentClassNames.TableCaption},t),s)}));xa.displayName="Table";const Sa=b.forwardRef(((e,a)=>{var{children:t,className:n}=e,s=o.__rest(e,["children","className"]);return b.createElement(l.View,Object.assign({as:"tbody",className:v.default(l.ComponentClassNames.TableBody,n),ref:a},s),t)}));Sa.displayName="TableBody";const Ia=b.forwardRef(((e,a)=>{var{as:t="td",children:n,className:s}=e,r=o.__rest(e,["as","children","className"]);return b.createElement(l.View,Object.assign({as:t,className:v.default("td"===t?l.ComponentClassNames.TableTd:l.ComponentClassNames.TableTh,s),ref:a},r),n)}));Ia.displayName="TableCell";const Ta=b.forwardRef(((e,a)=>{var{children:t,className:n}=e,s=o.__rest(e,["children","className"]);return b.createElement(l.View,Object.assign({as:"tfoot",className:v.default(l.ComponentClassNames.TableFoot,n),ref:a},s),t)}));Ta.displayName="TableFoot";const Pa=b.forwardRef(((e,a)=>{var{children:t,className:n}=e,s=o.__rest(e,["children","className"]);return b.createElement(l.View,Object.assign({as:"thead",className:v.default(l.ComponentClassNames.TableHead,n),ref:a},s),t)}));Pa.displayName="TableHead";const Da=b.forwardRef(((e,a)=>{var{children:t,className:n}=e,s=o.__rest(e,["children","className"]);return b.createElement(l.View,Object.assign({as:"tr",className:v.default(l.ComponentClassNames.TableRow,n),ref:a},s),t)}));Da.displayName="TableRow";const{Root:ka,List:Ma,Trigger:Oa,Content:Ra}=n.sanitizeNamespaceImport(S),Ba=e=>b.isValidElement(e),La=b.forwardRef(((e,a)=>{var{ariaLabel:t,children:n,className:s,defaultIndex:r=0,currentIndex:i,onChange:d,indicatorPosition:c,spacing:u}=e,m=o.__rest(e,["ariaLabel","children","className","defaultIndex","currentIndex","onChange","indicatorPosition","spacing"]);const p={defaultValue:r.toString(),value:null!=i?i.toString():void 0,onValueChange:d},f=b.Children.toArray(n).filter((e=>!!e));return b.createElement(ka,Object.assign({},p),b.createElement(Ma,{"aria-label":t},b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Tabs,s),"data-indicator-position":c,ref:a},m),b.Children.map(f,((e,a)=>{if(Ba(e))return b.cloneElement(e,{"data-spacing":u,key:a,value:`${a}`})})))),b.Children.map(f,((e,a)=>{if(Ba(e))return b.createElement(Ra,{key:a,value:`${a}`},e.props.children)})))})),Va=b.forwardRef(((e,a)=>{var{className:t,title:n}=e,s=o.__rest(e,["className","title"]);return b.createElement(l.View,Object.assign({as:Oa,className:v.default(l.ComponentClassNames.TabItems,t),ref:a},s),n)}));La.displayName="Tabs",Va.displayName="TabItem";const _a=b.forwardRef(((e,a)=>{var{className:t,isDisabled:s,isReadOnly:r,isRequired:i,size:d,hasError:c=!1,variation:u}=e,m=o.__rest(e,["className","isDisabled","isReadOnly","isRequired","size","hasError","variation"]);const p=v.default(l.ComponentClassNames.Textarea,l.ComponentClassNames.FieldGroupControl,n.classNameModifier(l.ComponentClassNames.Textarea,u),n.classNameModifier(l.ComponentClassNames.Textarea,d),n.classNameModifierByFlag(l.ComponentClassNames.Textarea,"error",c),t),{isFieldsetDisabled:f}=l.useFieldset();return b.createElement(l.View,Object.assign({"aria-invalid":c,as:"textarea",className:p,"data-size":d,"data-variation":u,disabled:f||s,readOnly:r,ref:a,required:i},m))}));_a.displayName="TextArea";const ja=b.forwardRef(((e,a)=>{const{className:t,descriptiveText:s,errorMessage:r,hasError:i=!1,id:d,label:c,labelHidden:u=!1,rows:m,size:p,testId:f,inputStyles:C,resize:g}=e,h=o.__rest(e,["className","descriptiveText","errorMessage","hasError","id","label","labelHidden","rows","size","testId","inputStyles","resize"]),N=V(d),E=V(),F=s?E:void 0,{styleProps:y,rest:w}=q(h);return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.Field,n.classNameModifier(l.ComponentClassNames.Field,p),l.ComponentClassNames.TextAreaField,t),"data-size":p,testId:f},y),b.createElement(l.Label,{htmlFor:N,visuallyHidden:u},c),b.createElement(l.FieldDescription,{id:E,labelHidden:u,descriptiveText:s}),b.createElement(_a,Object.assign({"aria-describedby":F,hasError:i,id:N,ref:a,rows:null!=m?m:3,size:p,resize:g},w,C)),b.createElement(l.FieldErrorMessage,{hasError:i,errorMessage:r}))}));ja.displayName="TextAreaField";const Aa=b.forwardRef(((e,a)=>{var{className:t,children:s,defaultPressed:r=!1,isDisabled:i,isPressed:d,onChange:c,onClick:u,size:m,value:p,variation:f}=e,C=o.__rest(e,["className","children","defaultPressed","isDisabled","isPressed","onChange","onClick","size","value","variation"]);const{isPressed:g,handleClick:h}=(({isPressed:e,defaultPressed:a,onClick:t,onChange:l,value:s})=>{const r=void 0!==e,[o,i]=b.useState(a);return{isPressed:e=r?e:o,handleClick:b.useCallback((e=>{n.isFunction(t)&&t(e),r||i(!o),r&&n.isFunction(l)&&l(s)}),[r,t,l,o,s])}})({isPressed:d,defaultPressed:r,onChange:c,onClick:u,value:p}),N=v.default(l.ComponentClassNames.ToggleButton,n.classNameModifier(l.ComponentClassNames.ToggleButton,f),n.classNameModifierByFlag(l.ComponentClassNames.ToggleButton,"pressed",g),t);return b.createElement(l.Button,Object.assign({"aria-pressed":g,className:N,isDisabled:i,onClick:h,ref:a,size:m,type:"button",variation:f},C),s)}));Aa.displayName="ToggleButton";const Ha=b.forwardRef(((e,a)=>{var{children:t,className:s,isExclusive:r,isSelectionRequired:i,onChange:d,size:c,value:u,variation:m}=e,p=o.__rest(e,["children","className","isExclusive","isSelectionRequired","onChange","size","value","variation"]);const f=(({onChange:e,value:a,isExclusive:t=!1,isSelectionRequired:l=!1})=>{const s=b.useCallback((t=>{if(!n.isFunction(e)||!Array.isArray(a))return;const s=n.isString(t)?a.indexOf(t):-1;let r;s>=0?(r=[...a],(!l||r.length>1)&&r.splice(s,1)):r=[...a,t],e(r)}),[e,a,l]),r=b.useCallback((t=>{n.isFunction(e)&&e(a!==t||l?t:void 0)}),[e,a,l]);return t?r:s})({onChange:d,value:u,isExclusive:r,isSelectionRequired:i});return b.createElement(l.Flex,Object.assign({className:v.default(l.ComponentClassNames.ToggleButtonGroup,s),ref:a,role:"group"},p),b.Children.map(t,(e=>b.isValidElement(e)?b.cloneElement(e,{isPressed:r?u===e.props.value:n.isString(e.props.value)&&u.includes(e.props.value),onChange:f,size:c,variation:m}):e)))}));Ha.displayName="ToggleButtonGroup";var za,Ua=Object.freeze({__proto__:null,IconsProvider:P,Alert:D,Autocomplete:Y,Badge:X,Breadcrumbs:ne,Button:l.Button,ButtonGroup:le,Card:se,CheckboxField:ie,Collection:Ee,Divider:ve,DropZone:xe,Expander:Te,ExpanderItem:Oe,FieldGroupIcon:l.FieldGroupIcon,FieldGroupIconButton:l.FieldGroupIconButton,Fieldset:Re,Flex:l.Flex,Grid:de,Heading:Le,HighlightMatch:A,Icon:l.Icon,Image:Ve,Input:G,Label:l.Label,Link:J,Loader:l.Loader,Menu:ze,MenuButton:_e,MenuItem:Ge,Message:Qe,Pagination:pe,PasswordField:na,PhoneNumberField:oa,Placeholder:ia,Radio:ca,RadioGroupField:ua,Rating:ga,ScrollView:M,SearchField:K,SelectField:sa,SliderField:va,StepperField:ya,SwitchField:wa,Tabs:La,TabItem:Va,Text:l.Text,TextAreaField:ja,TextField:W,ToggleButton:Aa,ToggleButtonGroup:Ha,View:l.View,VisuallyHidden:re,Table:xa,TableBody:Sa,TableCell:Ia,TableFoot:Ta,TableHead:Pa,TableRow:Da,usePagination:fe,ComponentClassNames:l.ComponentClassNames,ComponentClassObject:l.ComponentClassObject,ComponentPropsToStylePropsMap:l.ComponentPropsToStylePropsMap,ComponentPropsToStylePropsMapKeys:l.ComponentPropsToStylePropsMapKeys});!function(e){e.ChangePassword="amplify-accountsettings-changepassword",e.DeleteUser="amplify-accountsettings-deleteuser"}(za||(za={}));const Ga=({errors:e,id:a,dataAttr:t})=>{if(!((null==e?void 0:e.length)>0))return null;const s=t?{[t]:!0}:{};return N.default.createElement(l.View,Object.assign({},s,{id:a}),e.map((e=>N.default.createElement(l.Text,{key:e,role:"alert",variation:"error"},n.translate(e)))))},qa=e=>N.default.createElement(D,Object.assign({variation:"error"},e)),Wa=e=>{var{fieldValidationErrors:a,label:t}=e,n=o.__rest(e,["fieldValidationErrors","label"]);return N.default.createElement(N.default.Fragment,null,N.default.createElement(na,Object.assign({},n,{label:t})),a?N.default.createElement(Ga,{errors:a}):null)},$a={CurrentPasswordField:Wa,NewPasswordField:Wa,ConfirmPasswordField:Wa,SubmitButton:l.Button,ErrorMessage:qa},Za=new t.Logger("ChangePassword");function Ka({onSuccess:e,onError:a,validators:t,components:s}){const[r,o]=N.default.useState(null),[i,d]=N.default.useState({}),[c,u]=N.default.useState({}),m=N.default.useRef([]),{user:p,isLoading:f}=l.useAuth(),C=((e,a)=>{var t,n;const{currentPassword:l,newPassword:s,confirmPassword:r}=e;return!(l&&s&&r)||((null===(t=a.newPassword)||void 0===t?void 0:t.length)>0||(null===(n=a.confirmPassword)||void 0===n?void 0:n.length)>0)})(i,c),g=N.default.useMemo((()=>null!=t?t:n.getDefaultPasswordValidators()),[t]),h=N.default.useCallback((({formValues:e,eventType:a})=>{const{newPassword:t}=e,l=m.current.includes("newPassword");return n.runFieldValidators({value:t,validators:g,eventType:a,hasBlurred:l})}),[g]),b=N.default.useCallback((({formValues:e,eventType:a})=>{const{newPassword:t,confirmPassword:l}=e,s=m.current.includes("confirmPassword"),r=n.getDefaultConfirmPasswordValidators(t);return n.runFieldValidators({value:l,validators:r,eventType:a,hasBlurred:s})}),[]),v=N.default.useCallback((e=>{const a={newPassword:h(e),confirmPassword:b(e)};E.default(c,a)||u(a)}),[b,h,c]),F=n.translate("Current Password"),y=n.translate("New Password"),w=n.translate("Confirm Password"),x=n.translate("Update password"),{CurrentPasswordField:S,NewPasswordField:I,ConfirmPasswordField:T,SubmitButton:P,ErrorMessage:D}=N.default.useMemo((()=>Object.assign(Object.assign({},$a),null!=s?s:{})),[s]),k=e=>{e.preventDefault();const{name:a,value:t}=e.target,n=Object.assign(Object.assign({},i),{[a]:t});v({formValues:n,eventType:"change"}),d(n)},M=e=>{e.preventDefault();const{name:a}=e.target;if(!m.current.includes(a)){const e=[...m.current,a];m.current=e,v({formValues:i,eventType:"blur"})}};return f?null:p?N.default.createElement(l.View,{as:"form",className:za.ChangePassword,onSubmit:t=>{if(t.preventDefault(),!p)return;const{currentPassword:l,newPassword:s}=i;r&&o(null),n.changePassword({user:p,currentPassword:l,newPassword:s}).then((()=>{null==e||e()})).catch((e=>{const t=e;t.message&&o(t.message),null==a||a(t)}))}},N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(S,{autoComplete:"current-password",isRequired:!0,label:F,name:"currentPassword",onBlur:M,onChange:k}),N.default.createElement(I,{autoComplete:"new-password",fieldValidationErrors:null==c?void 0:c.newPassword,isRequired:!0,label:y,name:"newPassword",onBlur:M,onChange:k}),N.default.createElement(T,{autoComplete:"new-password",fieldValidationErrors:null==c?void 0:c.confirmPassword,isRequired:!0,label:w,name:"confirmPassword",onBlur:M,onChange:k}),N.default.createElement(P,{isDisabled:C,type:"submit"},x),r?N.default.createElement(D,null,r):null)):(Za.warn("<ChangePassword /> requires user to be authenticated."),null)}Ka.CurrentPasswordField=$a.CurrentPasswordField,Ka.NewPasswordField=$a.NewPasswordField,Ka.ConfirmPasswordField=$a.ConfirmPasswordField,Ka.SubmitButton=$a.SubmitButton,Ka.ErrorMessage=$a.ErrorMessage;const Ya={ErrorMessage:qa,DeleteButton:e=>N.default.createElement(l.Button,Object.assign({},e,{variation:"warning"})),WarningView:({onCancel:e,onConfirm:a,isDisabled:t})=>{const s=n.translate("Deleting your account is not reversable. You will lose access to your account and all data associated with it."),r=n.translate("Cancel"),o=n.translate("Delete my account");return N.default.createElement(se,null,N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(l.Text,{color:"font.error"},s),N.default.createElement(l.Flex,null,N.default.createElement(l.Button,{variation:"link",onClick:e,isDisabled:t},r),N.default.createElement(l.Button,{variation:"destructive",onClick:a,isDisabled:t},o))))}},Xa=n.getLogger("Auth");function Qa({components:e,onSuccess:a,onError:t,handleDelete:s}){const[r,i]=N.default.useState("IDLE"),[d,c]=N.default.useState(null),u=n.translate("Delete Account"),{user:m,isLoading:p}=l.useAuth(),{ErrorMessage:f,DeleteButton:C,WarningView:g}=N.default.useMemo((()=>Object.assign(Object.assign({},Ya),null!=e?e:{})),[e]),h=N.default.useCallback((()=>o.__awaiter(this,void 0,void 0,(function*(){if(m){i("DELETING"),d&&c(null);try{s?yield s(m):yield n.deleteUser(),i("DONE"),null==a||a()}catch(e){const a=e;i("ERROR"),c(a.message),null==t||t(a)}}}))),[d,s,t,a,m]),b=N.default.useCallback((()=>{i("IDLE")}),[]),E=N.default.useCallback((()=>{h()}),[h]);return p?null:m?"DONE"===r?null:N.default.createElement(l.Flex,{className:za.DeleteUser,direction:"column"},N.default.createElement(C,{isDisabled:"CONFIRMATION"===r||"DELETING"===r,onClick:e=>{e.preventDefault(),i("CONFIRMATION")}},u),"CONFIRMATION"===r||"DELETING"===r?N.default.createElement(g,{onCancel:b,isDisabled:"DELETING"===r,onConfirm:E}):null,d?N.default.createElement(f,null,d):null):(Xa.warn("<DeleteUser /> requires user to be authenticated."),null)}Qa.ErrorMessage=Ya.ErrorMessage,Qa.DeleteButton=Ya.DeleteButton,Qa.WarningView=Ya.WarningView;var Ja={ChangePassword:Ka,DeleteUser:Qa};const et="5.3.2",at=b.createContext(null),tt=()=>{const e=b.useContext(at);if(!e)throw new Error("`useCustomComponents` cannot be used outside of a `CustomComponentsContext.Provider`");return e},nt=e=>"signIn"===e||"signUp";function lt({children:e,className:a,variation:t="default"}){const{route:n}=s.useAuthenticator((({route:e})=>[e])),{components:{Header:r,Footer:o}}=tt();return N.default.createElement(l.View,{className:a,"data-amplify-authenticator":"","data-variation":t},N.default.createElement(l.View,{"data-amplify-container":""},N.default.createElement(r,null),N.default.createElement(l.View,{"data-amplify-router":"","data-amplify-router-content":nt(n)?void 0:""},e),N.default.createElement(o,null)))}function st(){const{submitForm:a,updateBlur:t,updateForm:n}=s.useAuthenticator((e=>[e.submitForm,e.updateBlur,e.updateForm]));return{handleBlur:e.useCallback((({target:{name:e}})=>{t({name:e})}),[t]),handleChange:e.useCallback((({target:{checked:e,name:a,type:t,value:l}})=>{n({name:a,value:"checkbox"===t&&!e?void 0:l})}),[n]),handleSubmit:e.useCallback((e=>{e.preventDefault(),a(l.getFormDataFromEvent(e))}),[a])}}const rt=()=>{const{error:e}=s.useAuthenticator((e=>[e.error]));return N.default.createElement(N.default.Fragment,null,e?N.default.createElement(D,{variation:"error",isDismissible:!0},n.translate(e)):null)};function ot(e){var{autocomplete:a,dialCode:t,name:l,type:r}=e,i=o.__rest(e,["autocomplete","dialCode","name","type"]);const{validationErrors:d}=s.useAuthenticator((({validationErrors:e})=>[e])),c=b.useMemo((()=>n.getErrors(d[l])),[l,d]),u=(null==c?void 0:c.length)>0,m=V(),p=u?m:void 0;return"tel"===r?b.createElement(b.Fragment,null,b.createElement(oa,Object.assign({},i,{name:l,defaultDialCode:t,dialCodeName:"country_code",autoComplete:a,hasError:u,"aria-describedby":p})),b.createElement(Ga,{dataAttr:"data-amplify-sign-up-errors",errors:c,id:m})):"password"===r?b.createElement(b.Fragment,null,b.createElement(na,Object.assign({},i,{name:l,autoComplete:a,hasError:u,"aria-describedby":p})),b.createElement(Ga,{dataAttr:"data-amplify-sign-up-errors",errors:c,id:m})):b.createElement(b.Fragment,null,b.createElement(W,Object.assign({},i,{name:l,autoComplete:a,hasError:u,type:r,"aria-describedby":p})),b.createElement(Ga,{dataAttr:"data-amplify-sign-up-errors",errors:c,id:m}))}function it(){const{fields:e}=s.useAuthenticator((({route:e})=>[e])),a=b.useRef(e.map(((e,a)=>b.createElement(ot,Object.assign({key:a},e))))).current;return b.createElement(b.Fragment,null,a)}const{getDeliveryMessageText:dt,getDeliveryMethodText:ct,getConfirmingText:ut,getConfirmText:mt,getResendCodeText:pt}=n.authenticatorTextUtil;function ft({className:e,variation:a}){const{isPending:t,resendCode:n,codeDeliveryDetails:r}=s.useAuthenticator((e=>[e.isPending,e.resendCode,e.codeDeliveryDetails])),{handleChange:o,handleSubmit:i}=st(),{components:{ConfirmSignUp:{Header:d=ft.Header,Footer:c=ft.Footer}}}=tt();return N.default.createElement(lt,{className:e,variation:a},N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-confirmsignup":"",method:"post",onChange:o,onSubmit:i},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:t},N.default.createElement(d,null),N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(l.Text,{className:"amplify-authenticator__subtitle"},dt(r)),N.default.createElement(it,null),N.default.createElement(rt,null),N.default.createElement(l.Button,{variation:"primary",isDisabled:t,type:"submit",loadingText:ut(),isLoading:t,fontWeight:"normal"},mt()),N.default.createElement(l.Button,{onClick:n,type:"button",fontWeight:"normal"},pt())),N.default.createElement(c,null))))}ft.Header=()=>{const{codeDeliveryDetails:e}=s.useAuthenticator((e=>[e.codeDeliveryDetails]));return N.default.createElement(Le,{level:4},ct(e))},ft.Footer=function(){return null};const{getChangePasswordText:Ct,getChangingText:gt,getBackToSignInText:ht}=n.authenticatorTextUtil,bt=({className:e,variation:a})=>{const{isPending:t,toSignIn:n}=s.useAuthenticator((e=>[e.isPending,e.toSignIn])),{handleBlur:r,handleChange:o,handleSubmit:i}=st(),{components:{ForceNewPassword:{FormFields:d=bt.FormFields,Header:c=bt.Header,Footer:u=bt.Footer}}}=tt();return N.default.createElement(lt,{className:e,variation:a},N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-forcenewpassword":"",method:"post",onChange:o,onSubmit:i,onBlur:r},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:t},N.default.createElement(c,null),N.default.createElement(d,null),N.default.createElement(rt,null),N.default.createElement(l.Button,{isDisabled:t,type:"submit",variation:"primary",isLoading:t,loadingText:gt(),fontWeight:"normal"},Ct()),N.default.createElement(l.Button,{onClick:n,type:"button",fontWeight:"normal",variation:"link",size:"small"},ht()),N.default.createElement(u,null))))};bt.FormFields=function(){return N.default.createElement(it,null)},bt.Header=function(){return N.default.createElement(Le,{level:4},Ct())},bt.Footer=function(){return null};const{getConfirmText:Nt,getConfirmingText:Et,getBackToSignInText:vt}=n.authenticatorTextUtil,Ft=()=>{const{isPending:e,toSignIn:a}=s.useAuthenticator((e=>[e.isPending,e.toSignIn]));return N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(l.Button,{isDisabled:e,type:"submit",variation:"primary",fontWeight:"normal",isLoading:e,loadingText:Et()},Nt()),N.default.createElement(l.Button,{onClick:a,type:"button",variation:"link",fontWeight:"normal",size:"small"},vt()))},yt=new t.Logger("SetupTOTP-logger"),{getSetupTOTPText:wt,getCopiedText:xt,getLoadingText:St}=n.authenticatorTextUtil,It=({className:e,variation:a})=>{var t;const{totpSecretCode:r,isPending:i,user:d,QRFields:c}=s.useAuthenticator((e=>[e.isPending,e.totpSecretCode])),{handleChange:u,handleSubmit:m}=st(),{components:{SetupTOTP:{Header:p=It.Header,Footer:f=It.Footer}}}=tt(),[C,g]=b.useState(!0),[h,N]=b.useState(),[E,v]=b.useState("COPY"),{totpIssuer:F="AWSCognito",totpUsername:y=(null==d?void 0:d.username)}=null!==(t=c)&&void 0!==t?t:{},w=b.useCallback((()=>o.__awaiter(void 0,void 0,void 0,(function*(){try{const e=n.getTotpCodeURL(F,y,r),a=yield I.default.toDataURL(e);N(a)}catch(e){yt.error(e)}finally{g(!1)}}))),[F,y,r]);b.useEffect((()=>{h||w()}),[w,h]);return b.createElement(lt,{className:e,variation:a},b.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-setup-totp":"",method:"post",onChange:u,onSubmit:m},b.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:i},b.createElement(p,null),b.createElement(l.Flex,{direction:"column"},C?b.createElement("p",null,St(),"…"):b.createElement("img",{"data-amplify-qrcode":!0,src:h,alt:"qr code",width:"228",height:"228"}),b.createElement(l.Flex,{"data-amplify-copy":!0},b.createElement("div",null,r),b.createElement(l.Flex,{"data-amplify-copy-svg":!0,onClick:()=>{navigator.clipboard.writeText(r),v(xt())}},b.createElement("div",{"data-amplify-copy-tooltip":!0},E),b.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},b.createElement("path",{d:"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM15 5H8C6.9 5 6.01 5.9 6.01 7L6 21C6 22.1 6.89 23 7.99 23H19C20.1 23 21 22.1 21 21V11L15 5ZM8 21V7H14V12H19V21H8Z"})))),b.createElement(it,null),b.createElement(rt,null)),b.createElement(Ft,null),b.createElement(f,null))))};It.Header=function(){return b.createElement(Le,{level:3},wt())},It.Footer=function(){return null};const{getSubmitText:Tt,getSubmittingText:Pt}=n.authenticatorTextUtil,Dt=e=>{const{cancelButtonSendType:a,cancelButtonText:t,submitButtonText:n}=e,{isPending:r,resendCode:o,skipVerification:i,toSignIn:d}=s.useAuthenticator((e=>[e.isPending])),c=r?N.default.createElement(N.default.Fragment,null,Pt(),"…"):N.default.createElement(N.default.Fragment,null,Tt()),u=null!=n?n:c;return N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(l.Button,{fontWeight:"normal",variation:"primary",isDisabled:r,type:"submit"},u),N.default.createElement(l.Button,{onClick:()=>{switch(a){case"SKIP":i();break;case"RESEND":o();break;case"SIGN_IN":d();break;default:return}},type:"button",variation:"link",fontWeight:"normal",size:"small"},t))},kt=()=>N.default.createElement("svg",{"aria-label":"Apple icon",className:"amplify-icon federated-sign-in-icon",fill:"#000",preserveAspectRatio:"xMidYMid",stroke:"#000",strokeWidth:"0",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},N.default.createElement("path",{d:"M747.4 535.7c-.4-68.2 30.5-119.6 92.9-157.5-34.9-50-87.7-77.5-157.3-82.8-65.9-5.2-138 38.4-164.4 38.4-27.9 0-91.7-36.6-141.9-36.6C273.1 298.8 163 379.8 163 544.6c0 48.7 8.9 99 26.7 150.8 23.8 68.2 109.6 235.3 199.1 232.6 46.8-1.1 79.9-33.2 140.8-33.2 59.1 0 89.7 33.2 141.9 33.2 90.3-1.3 167.9-153.2 190.5-221.6-121.1-57.1-114.6-167.2-114.6-170.7zm-105.1-305c50.7-60.2 46.1-115 44.6-134.7-44.8 2.6-96.6 30.5-126.1 64.8-32.5 36.8-51.6 82.3-47.5 133.6 48.4 3.7 92.6-21.2 129-63.7z"})),Mt=()=>N.default.createElement("svg",{"aria-label":"Google icon",className:"amplify-icon federated-sign-in-icon",viewBox:"0 0 256 262",xmlns:"http://www.w3.org/2000/svg",preserveAspectRatio:"xMidYMid"},N.default.createElement("path",{d:"M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027",fill:"#4285F4"}),N.default.createElement("path",{d:"M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1",fill:"#34A853"}),N.default.createElement("path",{d:"M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782",fill:"#FBBC05"}),N.default.createElement("path",{d:"M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251",fill:"#EB4335"})),Ot=()=>N.default.createElement(l.Icon,{className:"federated-sign-in-icon",ariaLabel:"Facebook icon",viewBox:{minX:0,minY:0,width:279,height:538},pathData:"M82.3409742,538 L82.3409742,292.936652 L0,292.936652 L0,196.990154 L82.2410458,196.990154 L82.2410458,126.4295 C82.2410458,44.575144 132.205229,0 205.252865,0 C240.227794,0 270.306232,2.59855099 279,3.79788222 L279,89.2502322 L228.536175,89.2502322 C188.964542,89.2502322 181.270057,108.139699 181.270057,135.824262 L181.270057,196.89021 L276.202006,196.89021 L263.810888,292.836708 L181.16913,292.836708 L181.16913,538 L82.3409742,538 Z",fill:"#1877F2"}),Rt=()=>N.default.createElement("svg",{"aria-label":"Amazon icon",className:"amplify-icon federated-sign-in-icon",viewBox:"0 0 243 264",xmlns:"http://www.w3.org/2000/svg",preserveAspectRatio:"xMidYMid"},N.default.createElement("path",{d:"M230.826 208.039C227.468 203.683 208.551 205.982 200.056 206.998C197.471 207.321 197.076 205.042 199.407 203.405C214.475 192.665 239.201 195.766 242.082 199.364C244.966 202.982 241.337 228.071 227.173 240.049C225.001 241.888 222.93 240.904 223.898 238.468C227.077 230.431 234.205 212.419 230.826 208.039ZM123.769 264C71.0234 264 39.0764 241.955 14.7853 217.542C9.97339 212.706 3.71799 206.296 0.311513 200.691C-1.09773 198.372 2.59096 195.022 5.04421 196.844C35.239 219.268 79.1012 239.538 122.53 239.538C151.82 239.538 188.046 227.47 217.669 214.868C222.147 212.966 222.147 219.18 221.512 221.061C221.183 222.032 206.515 236.221 186.247 247.047C167.304 257.166 143.397 264 123.769 264Z",fill:"#F2541B"}),N.default.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M142.943 111.185C142.943 124.756 143.268 136.054 136.406 148.123C130.856 157.913 122.027 163.95 112.222 163.95C98.8288 163.95 90.9806 153.772 90.9806 138.693C90.9806 109.036 117.677 103.647 142.943 103.647V111.185ZM178.166 196.081C175.858 198.15 171.635 198.22 169.914 196.894C157.974 187.684 149.89 173.688 149.89 173.688C130.706 193.156 117.127 199 92.2879 199C62.8772 199 40 180.905 40 144.729C40 116.461 55.3552 97.2408 77.2563 87.823C96.2094 79.5256 122.684 78.0173 142.943 75.7517C142.943 75.7517 144.633 53.933 138.699 45.9806C134.098 39.8163 126.272 36.9329 119.089 36.9329C106.127 36.8829 93.61 43.9051 91.1262 57.4188C90.4136 61.2829 87.5533 64.5261 84.54 64.206L51.0823 60.5922C48.5156 60.2951 45.0381 57.6639 45.8636 53.3081C53.644 12.3684 90.7373 0 123.989 0C140.983 0 163.21 4.51651 176.608 17.3349C193.597 33.1648 191.969 54.2755 191.969 77.2722V131.51C191.969 147.835 198.768 154.987 205.151 163.775C207.376 166.953 207.886 170.714 205.04 173.032C197.902 178.999 178.166 196.081 178.166 196.081Z",fill:"#F2541B"})),Bt=e=>{const{icon:a,provider:t,text:n}=e,{toFederatedSignIn:r}=s.useAuthenticator();let o;return"facebook"===a?o=N.default.createElement(Ot,null):"google"===a?o=N.default.createElement(Mt,null):"amazon"===a?o=N.default.createElement(Rt,null):"apple"===a&&(o=N.default.createElement(kt,null)),N.default.createElement(l.Button,{onClick:e=>{e.preventDefault(),r({provider:t})},className:"federated-sign-in-button",fontWeight:"normal",gap:"1rem"},o,N.default.createElement(l.Text,{as:"span"},n))},{getSignInWithFederationText:Lt,getOrText:Vt}=n.authenticatorTextUtil;function _t(){const{route:e,socialProviders:a}=s.useAuthenticator((({route:e,socialProviders:a})=>[e,a]));return 0===a.length?null:N.default.createElement(l.Flex,{direction:"column",padding:"0 0 1rem 0",className:"federated-sign-in-container"},a.map((a=>{switch(a){case"amazon":return N.default.createElement(Bt,{icon:"amazon",key:a,provider:n.FederatedIdentityProviders.Amazon,text:Lt(e,a)});case"apple":return N.default.createElement(Bt,{icon:"apple",key:a,provider:n.FederatedIdentityProviders.Apple,text:Lt(e,a)});case"facebook":return N.default.createElement(Bt,{icon:"facebook",key:a,provider:n.FederatedIdentityProviders.Facebook,text:Lt(e,a)});case"google":return N.default.createElement(Bt,{icon:"google",key:a,provider:n.FederatedIdentityProviders.Google,text:Lt(e,a)});default:console.error(`Authenticator does not support ${a}. Please open an issue: https://github.com/aws-amplify/amplify-ui/issues/choose`)}})),N.default.createElement(ve,{size:"small",label:Vt()}))}const{getSignInText:jt,getSigningInText:At,getForgotPasswordText:Ht}=n.authenticatorTextUtil;function zt(){const{isPending:e}=s.useAuthenticator((e=>[e.isPending])),{handleChange:a,handleSubmit:t}=st(),{components:{SignIn:{Header:n=zt.Header,Footer:r=zt.Footer}}}=tt();return N.default.createElement(l.View,null,N.default.createElement(n,null),N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-signin":"",method:"post",onSubmit:t,onChange:a},N.default.createElement(_t,null),N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:e},N.default.createElement(re,null,N.default.createElement("legend",null,jt())),N.default.createElement(it,null)),N.default.createElement(rt,null),N.default.createElement(l.Button,{isDisabled:e,isFullWidth:!0,type:"submit",variation:"primary",isLoading:e,loadingText:At()},jt()))),N.default.createElement(r,null))}zt.Footer=()=>{const{toResetPassword:e}=s.useAuthenticator((e=>[e.toResetPassword]));return N.default.createElement(l.View,{"data-amplify-footer":""},N.default.createElement(l.Button,{fontWeight:"normal",onClick:e,size:"small",variation:"link"},Ht()))},zt.Header=function(){return null};const{getCreateAccountText:Ut,getCreatingAccountText:Gt}=n.authenticatorTextUtil;function qt(){const{hasValidationErrors:e,isPending:a}=s.useAuthenticator((e=>[e.hasValidationErrors,e.isPending])),{handleChange:t,handleBlur:n,handleSubmit:r}=st(),{components:{SignUp:{Header:o=qt.Header,FormFields:i=qt.FormFields,Footer:d=qt.Footer}}}=tt();return N.default.createElement(l.View,null,N.default.createElement(o,null),N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-signup":"",method:"post",onChange:t,onSubmit:r,onBlur:n},N.default.createElement(_t,null),N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:a},N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(i,null),N.default.createElement(rt,null)),N.default.createElement(l.Button,{isDisabled:e||a,isFullWidth:!0,type:"submit",variation:"primary",isLoading:a,loadingText:Gt()},Ut()))),N.default.createElement(d,null))}qt.Header=function(){return null},qt.FormFields=function(){return N.default.createElement(it,null)},qt.Footer=function(){return null};const{getSignInTabText:Wt,getSignUpTabText:$t}=n.authenticatorTextUtil,Zt=({className:e,hideSignUp:a,variation:t})=>{const{route:n,toSignIn:r,toSignUp:o}=s.useAuthenticator((e=>[e.route,e.toSignIn,e.toSignUp]));return N.default.createElement(lt,{className:e,variation:t},a?N.default.createElement(l.View,{"data-amplify-router-content":""},"signIn"===n&&N.default.createElement(zt,null)):N.default.createElement(La,{indicatorPosition:"top",currentIndex:"signIn"===n?0:1,spacing:"equal",justifyContent:"center",onChange:()=>"signIn"===n?o():r()},N.default.createElement(Va,{title:Wt()},N.default.createElement(l.View,{"data-amplify-router-content":""},"signIn"===n&&N.default.createElement(zt,null))),N.default.createElement(Va,{title:$t()},N.default.createElement(l.View,{"data-amplify-router-content":""},"signUp"===n&&N.default.createElement(qt,null)))))},{getAccountRecoveryInfoText:Kt,getSkipText:Yt}=n.authenticatorTextUtil,Xt=({className:e,variation:a})=>{const{isPending:t}=s.useAuthenticator((e=>[e.isPending])),{handleChange:n,handleSubmit:r}=st(),{components:{ConfirmVerifyUser:{Header:o=Xt.Header,Footer:i=Xt.Footer}}}=tt();return N.default.createElement(lt,{className:e,variation:a},N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-confirmverifyuser":"",method:"post",onChange:n,onSubmit:r},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:t},N.default.createElement(o,null),N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(it,null)),N.default.createElement(rt,null),N.default.createElement(Dt,{cancelButtonText:Yt(),cancelButtonSendType:"SKIP"}),N.default.createElement(i,null))))};Xt.Header=function(){return N.default.createElement(Le,{level:3},Kt())},Xt.Footer=function(){return null};const{getSkipText:Qt,getVerifyText:Jt,getVerifyContactText:en,getAccountRecoveryInfoText:an}=n.authenticatorTextUtil,tn=e=>Object.entries(e).map((([e,a])=>N.default.createElement(ca,{name:"unverifiedAttr",value:e,key:e},((e,a)=>{const t=n.translate(e);let l=a;if("Phone Number"===e)l=n.censorPhoneNumber(a);else if("Email"===e){const e=a.split("@");l=`${n.censorAllButFirstAndLast(e[0])}@${e[1]}`}return`${t}: ${l}`})(n.defaultFormFieldOptions[e].label,a)))),nn=({className:e,variation:a})=>{const{components:{VerifyUser:{Header:t=nn.Header,Footer:n=nn.Footer}}}=tt(),{isPending:r,unverifiedContactMethods:o}=s.useAuthenticator((({isPending:e,unverifiedContactMethods:a})=>[e,a])),{handleChange:i,handleSubmit:d}=st(),c=r?N.default.createElement(N.default.Fragment,null,"Verifying…"):N.default.createElement(N.default.Fragment,null,Jt()),u=N.default.createElement(ua,{label:en(),labelHidden:!0,name:"verify_context",isDisabled:r},tn(o));return N.default.createElement(lt,{className:e,variation:a},N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-verifyuser":"",method:"post",onChange:i,onSubmit:d},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:r},N.default.createElement(t,null),u,N.default.createElement(rt,null),N.default.createElement(Dt,{cancelButtonText:Qt(),cancelButtonSendType:"SKIP",submitButtonText:c}),N.default.createElement(n,null))))};nn.Header=function(){return N.default.createElement(Le,{level:3},an())},nn.Footer=function(){return null};const{getChallengeText:ln}=n.authenticatorTextUtil,sn=({className:e,variation:a})=>{const{isPending:t}=s.useAuthenticator((e=>[e.isPending])),{handleChange:n,handleSubmit:r}=st(),{components:{ConfirmSignIn:{Header:o=sn.Header,Footer:i=sn.Footer}}}=tt();return N.default.createElement(lt,{className:e,variation:a},N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-confirmsignin":"",method:"post",onChange:n,onSubmit:r},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:t},N.default.createElement(o,null),N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(it,null),N.default.createElement(rt,null)),N.default.createElement(Ft,null),N.default.createElement(i,null))))};sn.Header=function(){const{user:{challengeName:e}}=s.useAuthenticator((({user:e})=>[e]));return N.default.createElement(Le,{level:3},ln(e))},sn.Footer=function(){return null};const{getResendCodeText:rn,getResetYourPasswordText:on}=n.authenticatorTextUtil,dn=({className:e,variation:a})=>{const{isPending:t}=s.useAuthenticator((e=>[e.isPending])),{handleBlur:n,handleChange:r,handleSubmit:o}=st(),{components:{ConfirmResetPassword:{Header:i=dn.Header,Footer:d=dn.Footer}}}=tt();return N.default.createElement(lt,{className:e,variation:a},N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-confirmresetpassword":"",method:"post",onSubmit:o,onChange:r,onBlur:n},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:t},N.default.createElement(i,null),N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(it,null)),N.default.createElement(rt,null),N.default.createElement(Dt,{cancelButtonSendType:"RESEND",cancelButtonText:rn()}),N.default.createElement(d,null))))};dn.Header=function(){const e=on();return N.default.createElement(Le,{level:3},e)},dn.Footer=function(){return null};const{getBackToSignInText:cn,getSendingText:un,getSendCodeText:mn,getResetYourPasswordText:pn}=n.authenticatorTextUtil,fn=({className:e,variation:a})=>{const{isPending:t}=s.useAuthenticator((e=>[e.isPending])),{handleChange:n,handleSubmit:r}=st(),{components:{ResetPassword:{Header:o=fn.Header,Footer:i=fn.Footer}}}=tt();return N.default.createElement(lt,{className:e,variation:a},N.default.createElement("form",{"data-amplify-form":"","data-amplify-authenticator-resetpassword":"",method:"post",onChange:n,onSubmit:r},N.default.createElement(l.Flex,{as:"fieldset",direction:"column",isDisabled:t},N.default.createElement(o,null),N.default.createElement(l.Flex,{direction:"column"},N.default.createElement(it,null)),N.default.createElement(rt,null),N.default.createElement(Dt,{cancelButtonText:cn(),cancelButtonSendType:"SIGN_IN",submitButtonText:t?N.default.createElement(N.default.Fragment,null,un(),"…"):N.default.createElement(N.default.Fragment,null,mn())}),N.default.createElement(i,null))))};fn.Header=function(){return N.default.createElement(Le,{level:3},pn())},fn.Footer=function(){return null};const Cn=e=>"signIn"===e||"signUp"===e;function gn(){return null}const hn=e=>{switch(e){case"authenticated":case"idle":case"setup":case"transition":return gn;case"confirmSignUp":return ft;case"confirmSignIn":return sn;case"setupTOTP":return It;case"signIn":case"signUp":return Zt;case"forceNewPassword":return bt;case"resetPassword":return fn;case"confirmResetPassword":return dn;case"verifyUser":return nn;case"confirmVerifyUser":return Xt;default:return console.warn(`Unhandled Authenticator route - please open an issue: ${e}`),gn}};function bn({className:a,hideSignUp:t,variation:n}){const{route:l}=s.useAuthenticator((({route:e})=>[e])),r=e.useMemo((()=>hn(l)),[l]);return N.default.createElement(r,{className:a,hideSignUp:Cn(l)?t:void 0,variation:n})}const Nn={Header:()=>null,SignIn:{Header:zt.Header,Footer:zt.Footer},SignUp:{Header:qt.Header,FormFields:qt.FormFields,Footer:qt.Footer},ConfirmSignUp:{Header:ft.Header,Footer:ft.Footer},SetupTOTP:{Header:It.Header,Footer:It.Footer},ConfirmResetPassword:{Header:dn.Header,Footer:dn.Footer},ConfirmSignIn:{Header:sn.Header,Footer:sn.Footer},VerifyUser:{Header:nn.Header,Footer:nn.Footer},ConfirmVerifyUser:{Header:Xt.Header,Footer:Xt.Footer},ForceNewPassword:{Header:bt.Header,Footer:bt.Footer,FormFields:bt.FormFields},ResetPassword:{Header:fn.Header,Footer:fn.Footer},Footer:()=>null};function En({children:e,className:a,components:t,formFields:l,hideSignUp:r,initialState:o,loginMechanisms:i,passwordSettings:d,signUpAttributes:c,services:u,socialProviders:m,variation:p}){Se({message:"The `passwordSettings` prop has been deprecated and will be removed in a future major version of Amplify UI.",shouldWarn:!!d});const{route:f,signOut:C,user:g}=s.useAuthenticator((({route:e,signOut:a,user:t})=>[e,a,t]));s.useAuthenticatorInitMachine({initialState:o,loginMechanisms:i,services:u,signUpAttributes:c,socialProviders:m,formFields:l});const h=b.useMemo((()=>({components:Object.assign(Object.assign({},Nn),t)})),[t]);return"authenticated"===f||"signOut"===f?e?b.createElement(b.Fragment,null,n.isFunction(e)?e({signOut:C,user:g}):e):null:b.createElement(at.Provider,{value:h},b.createElement(bn,{className:a,hideSignUp:r,variation:p}))}function vn(e){return b.useEffect((()=>{n.configureComponent({packageName:"@aws-amplify/ui-react",version:et})}),[]),b.createElement(s.AuthenticatorProvider,null,b.createElement(En,Object.assign({},e)))}function Fn(e,a={}){const{variation:t="modal"}=a;return function(n){return N.default.createElement(vn,Object.assign({variation:t},a),(a=>N.default.createElement(e,Object.assign({},n,a))))}}var yn;function wn({aggregatePercentage:e,children:a,dropZone:t,fileStatuses:s,isLoading:r,isSuccessful:o,hasMaxFilesError:i,maxFileCount:d,onClear:c,onFileClick:u}){const m=`${n.translate("Cannot choose more than")} ${d}`,p=()=>s.filter((e=>(null==e?void 0:e.fileState)===yn.SUCCESS)).length,f=s.length-p(),C=`${f} ${1===f?n.translate("file"):n.translate("files")}`,g=`${p()} ${1===p()?n.translate("file uploaded"):n.translate("files uploaded")}`,h=s.some((e=>[yn.ERROR,yn.EDITING].includes(null==e?void 0:e.fileState)))||0===f||i;return N.default.createElement(l.View,{className:l.ComponentClassNames.FileUploaderPreviewer},N.default.createElement(l.View,{className:l.ComponentClassNames.FileUploaderPreviewerBody},t,N.default.createElement(l.Text,{className:l.ComponentClassNames.FileUploaderPreviewerText},o?g:N.default.createElement(N.default.Fragment,null,`${C} ${n.translate("selected")}`)),a),N.default.createElement(l.View,{className:l.ComponentClassNames.FileUploaderPreviewerFooter},N.default.createElement(l.View,null,r&&N.default.createElement(N.default.Fragment,null,N.default.createElement(l.Text,null,n.translate("Uploading"),e>0?`: ${e}%`:""),N.default.createElement(l.Loader,{className:l.ComponentClassNames.FileUploaderLoader,variation:"linear",percentage:e,isPercentageTextHidden:!0,isDeterminate:!0}))),N.default.createElement(l.View,{className:n.ComponentClassName.FileUploaderPreviewerFooterActions},!r&&!o&&N.default.createElement(N.default.Fragment,null,N.default.createElement(l.Button,{size:"small",variation:"link",onClick:c},n.translate("Clear all")),N.default.createElement(l.Button,{disabled:h,size:"small",variation:"primary",onClick:u},`${n.translate("Upload")} ${C}`)),o&&N.default.createElement(l.Button,{size:"small",onClick:c},n.translate("Done")))),i&&N.default.createElement(D,{variation:"error",heading:m}))}function xn({children:e,inDropZone:a,onDragStart:t,onDragEnter:s,onDragLeave:r,onDrop:o,onDragOver:i}){return N.default.createElement(l.View,{className:v.default(a&&n.classNameModifier(l.ComponentClassNames.FileUploaderDropZone,"active"),l.ComponentClassNames.FileUploaderDropZone),onDragStart:t,onDragEnter:s,onDragLeave:r,onDrop:o,onDragOver:i},N.default.createElement(l.IconUpload,{"aria-hidden":!0,className:l.ComponentClassNames.FileUploaderDropZoneIcon}),N.default.createElement(l.Text,{className:l.ComponentClassNames.FileUploaderDropZoneText},n.translate("Drop files here or")),e)}vn.Provider=s.AuthenticatorProvider,vn.ResetPassword=fn,vn.SetupTOTP=It,vn.SignIn=zt,vn.SignUp=qt,vn.ForceNewPassword=bt,function(e){e.PAUSED="paused",e.SUCCESS="success",e.ERROR="error",e.LOADING="loading",e.RESUME="resume",e.EDITING="editing",e.INIT="init"}(yn||(yn={}));const Sn=({fileState:e,errorMessage:a,percentage:t})=>{switch(e){case yn.LOADING:{const e=t&&t>0?`${n.translate("Uploading")}: ${t}%`:n.translate("Uploading");return N.default.createElement(l.Text,{className:l.ComponentClassNames.FileUploaderFileStatus},e)}case yn.PAUSED:return N.default.createElement(l.Text,{className:l.ComponentClassNames.FileUploaderFileStatus},n.translate("Paused"),": ",t,"%");case yn.SUCCESS:return N.default.createElement(l.Text,{className:v.default(l.ComponentClassNames.FileUploaderFileStatus,n.classNameModifier(l.ComponentClassNames.FileUploaderFileStatus,"success"))},N.default.createElement(l.IconCheck,{fontSize:"xl"})," ",n.translate("Uploaded successfully"));case yn.ERROR:return N.default.createElement(l.Text,{className:v.default(l.ComponentClassNames.FileUploaderFileStatus,n.classNameModifier(l.ComponentClassNames.FileUploaderFileStatus,"error"))},N.default.createElement(l.IconError,{fontSize:"xl"})," ",a);default:return null}};function In({errorMessage:a,file:t,fileState:s,hasImage:r,name:o,onCancel:i,onCancelEdit:d,onPause:c,onResume:u,onSaveEdit:m,onStartEdit:p,percentage:f,isResumable:C,showImage:g}){const[h,b]=N.default.useState(o),E=N.default.useRef(null),v=URL.createObjectURL(t);N.default.useEffect((()=>{s===yn.EDITING&&E.current&&E.current.focus()}),[s]);const{size:F}=t,y=r?N.default.createElement(Ve,{alt:t.name,src:v}):N.default.createElement(l.IconFile,null),w=!C||f>0,x=s===yn.INIT||s===yn.ERROR&&a===n.translate("Extension not allowed"),S=e.useCallback((()=>N.default.createElement(N.default.Fragment,null,N.default.createElement(l.View,{className:l.ComponentClassNames.FileUploaderFileMain},N.default.createElement(l.Text,{className:l.ComponentClassNames.FileUploaderFileName},o)),x?N.default.createElement(l.Button,{onClick:p,size:"small",variation:"link"},N.default.createElement(re,null,"Edit file name ",t.name),N.default.createElement(l.IconEdit,{"aria-hidden":!0,fontSize:"medium"})):null,N.default.createElement(l.Text,{as:"span",className:l.ComponentClassNames.FileUploaderFileSize},n.humanFileSize(F,!0)))),[t.name,o,p,x,F]),I=e.useCallback((()=>{switch(s){case yn.EDITING:return N.default.createElement(N.default.Fragment,null,N.default.createElement(l.Button,{size:"small",onClick:()=>{b(o),null==d||d()}},"Cancel"),N.default.createElement(l.Button,{size:"small",variation:"primary",onClick:()=>{m(h)}},"Save"));case yn.RESUME:case yn.LOADING:return C?N.default.createElement(l.Button,{onClick:c,size:"small",variation:"link"},n.translate("pause")):null;case yn.PAUSED:return N.default.createElement(l.Button,{onClick:u,size:"small",variation:"link"},n.translate("Resume"));case yn.SUCCESS:return null;default:return N.default.createElement(l.Button,{size:"small",onClick:i},N.default.createElement(re,null,"Remove file name ",t.name),N.default.createElement(l.IconClose,{"aria-hidden":!0,fontSize:"medium"}))}}),[t.name,s,C,o,i,d,c,u,m,h]);return t?N.default.createElement(l.View,{className:l.ComponentClassNames.FileUploaderFile},N.default.createElement(l.View,{className:l.ComponentClassNames.FileUploaderFileWrapper},g?N.default.createElement(l.View,{className:l.ComponentClassNames.FileUploaderFileImage},y):null,s===yn.EDITING?N.default.createElement(l.View,{as:"form",flex:"1",onSubmit:()=>{m(h)}},N.default.createElement(W,{maxLength:1024,ref:E,label:"file name",size:"small",variation:"quiet",labelHidden:!0,onChange:e=>{b(e.target.value)},value:h})):N.default.createElement(S,null),N.default.createElement(I,null),s===yn.LOADING?N.default.createElement(l.Loader,{className:l.ComponentClassNames.FileUploaderLoader,variation:"linear",percentage:f,isDeterminate:w,isPercentageTextHidden:!0}):null),N.default.createElement(Sn,{fileState:s,errorMessage:a,percentage:f})):null}const Tn=e=>"function"==typeof(null==e?void 0:e.resume),Pn=new t.Logger("AmplifyUI:Storage");function Dn(a){var{acceptedFileTypes:t,shouldAutoProceed:s=!1,isPreviewerVisible:i,maxFileCount:d,maxSize:c,hasMultipleFiles:u=!0,onError:m,onSuccess:p,showImages:f=!0,accessLevel:C,variation:g="drop",isResumable:h=!1}=a,b=o.__rest(a,["acceptedFileTypes","shouldAutoProceed","isPreviewerVisible","maxFileCount","maxSize","hasMultipleFiles","onError","onSuccess","showImages","accessLevel","variation","isResumable"]);Se({shouldWarn:!0,message:"FileUploader has exited Dev Preview and was renamed to StorageManager with some API changes. Please migrate to the StorageManager component, as the FileUploader component is no longer supported and will be removed in a future major release. https://ui.docs.amplify.aws/react/connected-components/storage/storagemanager"}),t&&C||Pn.warn("FileUploader requires accessLevel and acceptedFileTypes props");const[E,v]=e.useState(!1),[F,y]=e.useState(!1),w=function({maxSize:a,acceptedFileTypes:t,hasMultipleFiles:l,isLoading:s,setAutoLoad:r}){const[o,i]=e.useState([]),[d,c]=e.useState(!1),[u,m]=e.useState(!1),p=(e,t)=>{const l=[...t];[...e].forEach((e=>{const t=n.checkMaxSize(a,e);l.unshift({fileState:t?yn.ERROR:yn.INIT,fileErrors:t,file:e,name:e.name})})),i(l)},f=e=>{const a=n.returnAcceptedFiles([...e],t);return a?!l&&o.length>0?o.length:l||1!=a.length?!l&&a.length>1?(p([a[0]],o),1):a.length>0?(p([...a],o),a.length+o.length):0:(p([...a],o),a.length):0};return{inDropZone:u,onDragEnter:e=>{e.preventDefault(),e.stopPropagation()},onDragLeave:e=>{if(e.preventDefault(),e.stopPropagation(),s)return!1;m(!1)},onDragOver:e=>{if(e.preventDefault(),e.stopPropagation(),s)return!1;m(!0),e.dataTransfer.dropEffect="copy"},onDragStart:e=>{e.dataTransfer.clearData()},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),s)return!1;const{files:a}=e.dataTransfer;f([...a])>0&&(c(!0),r(!0)),m(!1)},setInDropZone:m,setShowPreviewer:c,addTargetFiles:f,showPreviewer:d,fileStatuses:o,setFileStatuses:i}}({maxSize:c,acceptedFileTypes:t,hasMultipleFiles:u,isLoading:E,setAutoLoad:y}),{addTargetFiles:x,fileStatuses:S,inDropZone:I,setFileStatuses:T,setShowPreviewer:P,showPreviewer:D}=w,k=o.__rest(w,["addTargetFiles","fileStatuses","inDropZone","setFileStatuses","setShowPreviewer","showPreviewer"]),M=Math.floor(S.reduce(((e,a)=>{var t;return e+(null!==(t=null==a?void 0:a.percentage)&&void 0!==t?t:0)}),0)/S.length),O=0!==S.length&&S.every((e=>100===(null==e?void 0:e.percentage))),R=S.filter((e=>100!==e.percentage)).length>d;e.useEffect((()=>{100===Math.floor(M)&&v(!1)}),[M]),e.useEffect((()=>{P(i)}),[P,i]);const B=e.useCallback((e=>a=>{T((t=>{const n=Object.assign({},t[e]),l=0!==a.total?Math.floor(a.loaded/a.total*100):100,s=100!==l?yn.LOADING:yn.SUCCESS,r=Object.assign(Object.assign({},n),{percentage:l,fileState:s});return t[e]=r,[...t]}))}),[T]),L=e.useCallback((e=>a=>{T((t=>{const l=Object.assign({},t[e]),s=Object.assign(Object.assign({},l),{fileState:"error",fileErrors:n.translate(a.toString())});return t[e]=s,[...t]})),v(!1),"function"==typeof m&&m(a)}),[m,T]),V=e.useCallback((e=>function(){const a=S[e];Tn(a.uploadTask)&&a.uploadTask.pause();const t=[...S];t[e]=Object.assign(Object.assign({},a),{fileState:yn.PAUSED}),T(t)}),[S,T]),_=e.useCallback((e=>function(){const a=S[e];Tn(a.uploadTask)&&a.uploadTask.resume();const t=[...S];t[e]=Object.assign(Object.assign({},a),{fileState:yn.RESUME}),T(t)}),[S,T]),j=e.useCallback((()=>{v(!0);const e=[];S.forEach(((a,t)=>{if((null==a?void 0:a.fileState)===yn.SUCCESS)return;const l=n.uploadFile(Object.assign({file:a.file,fileName:a.name,level:C,isResumable:h,progressCallback:B(t),errorCallback:L(t),completeCallback:p},b));Tn(l)&&h&&e.push(l)})),T((a=>a.map(((a,t)=>{var n;return Object.assign(Object.assign({},a),{uploadTask:null==e?void 0:e[t],fileState:a.fileState===yn.INIT?yn.LOADING:a.fileState,percentage:null!==(n=a.percentage)&&void 0!==n?n:0})}))))}),[S,T,C,h,B,L,p,b]),A=e.useCallback((e=>{if(!e.target.files||0===e.target.files.length)return;const{files:a}=e.target;x([...a])>0&&(P(!0),y(!0))}),[x,P]),H=e.useCallback((()=>{P(!1),T([])}),[T,P]),z=e.useCallback((e=>()=>{const{fileState:a,uploadTask:t}=S[e];"loading"===a&&Tn(t)&&(r.Storage.cancel(t),v(!1));const n=S.filter(((a,t)=>t!==e));T(n)}),[S,T]),U=e.useCallback((e=>a=>{if(0===a.trim().length)return;const t=[...S],l=S[e],s=n.isValidExtension(a,l.file.name);t[e]=Object.assign(Object.assign({},l),{name:a,fileState:s?yn.INIT:yn.ERROR,fileErrors:s?void 0:n.translate("Extension not allowed")}),T(t)}),[S,T]),G=e.useCallback(((e,a)=>{T((t=>{const l=[...t],s=l[e],r=n.isValidExtension(s.name,s.file.name)?yn.INIT:yn.ERROR,o=a===yn.INIT?r:a;return l[e]=Object.assign(Object.assign({},s),{fileState:o}),l}))}),[T]),q=e.useCallback((e=>()=>{G(e,yn.INIT)}),[G]),W=e.useCallback((e=>a=>{G(e,yn.EDITING)}),[G]);e.useEffect((()=>{s&&F&&!R&&(j(),y(!1))}),[s,j,F,R]);const $=N.default.useRef(null),Z=null==t?void 0:t.join(),K=e.useMemo((()=>N.default.createElement(N.default.Fragment,null,N.default.createElement(l.Button,{className:l.ComponentClassNames.FileUploaderDropZoneButton,isDisabled:E,onClick:()=>{var e;null===(e=null==$?void 0:$.current)||void 0===e||e.click(),$.current.value=""},size:"small"},n.translate("Browse files")),N.default.createElement(re,null,N.default.createElement("input",{type:"file",tabIndex:-1,ref:$,onChange:A,multiple:u,accept:Z})))),[E,A,u,Z]);return D?N.default.createElement(wn,{dropZone:N.default.createElement(xn,Object.assign({},k,{inDropZone:I}),K),fileStatuses:S,isLoading:E,isSuccessful:O,hasMaxFilesError:R,maxFileCount:d,onClear:H,onFileClick:j,aggregatePercentage:M},null==S?void 0:S.map(((e,a)=>{var t;return N.default.createElement(In,{errorMessage:null==e?void 0:e.fileErrors,file:e.file,fileState:null==e?void 0:e.fileState,hasImage:null===(t=e.file)||void 0===t?void 0:t.type.startsWith("image/"),showImage:f,key:a,name:e.name,onCancel:z(a),onCancelEdit:q(a),onPause:V(a),onResume:_(a),onSaveEdit:U(a),onStartEdit:W(a),percentage:e.percentage,isResumable:h})}))):"button"===g?K:N.default.createElement(xn,Object.assign({},k,{inDropZone:I}),K)}const{DirectionProvider:kn}=n.sanitizeNamespaceImport(T);function Mn({children:e,colorMode:a,direction:t="ltr",nonce:s,theme:r}){const o=b.useMemo((()=>({theme:n.createTheme(r)})),[r]),{theme:{name:i,cssText:d}}=o;return b.createElement(l.AmplifyContext.Provider,{value:o},b.createElement(kn,{dir:t},b.createElement("div",{"data-amplify-theme":i,"data-amplify-color-mode":a,dir:t},e),void 0===r||/<\/style/i.test(d)?null:b.createElement("style",{id:`amplify-theme-${i}`,dangerouslySetInnerHTML:{__html:d},nonce:s})))}const On=Mn;var Rn=Object.freeze({__proto__:null,AccountSettings:Ja,Authenticator:vn,withAuthenticator:Fn,useAuthenticator:s.useAuthenticator,FileUploader:Dn,AmplifyProvider:Mn,ThemeProvider:On});Object.defineProperty(exports,"createTheme",{enumerable:!0,get:function(){return n.createTheme}}),Object.defineProperty(exports,"defaultDarkModeOverride",{enumerable:!0,get:function(){return n.defaultDarkModeOverride}}),Object.defineProperty(exports,"defaultTheme",{enumerable:!0,get:function(){return n.defaultTheme}}),Object.defineProperty(exports,"translations",{enumerable:!0,get:function(){return n.translations}}),exports.Button=l.Button,exports.ComponentClassNames=l.ComponentClassNames,exports.ComponentClassObject=l.ComponentClassObject,exports.ComponentPropsToStylePropsMap=l.ComponentPropsToStylePropsMap,exports.ComponentPropsToStylePropsMapKeys=l.ComponentPropsToStylePropsMapKeys,exports.FieldGroupIcon=l.FieldGroupIcon,exports.FieldGroupIconButton=l.FieldGroupIconButton,exports.Flex=l.Flex,exports.Icon=l.Icon,exports.Label=l.Label,exports.Loader=l.Loader,exports.Text=l.Text,exports.View=l.View,exports.useTheme=l.useTheme,Object.defineProperty(exports,"useAuthenticator",{enumerable:!0,get:function(){return s.useAuthenticator}}),exports.AccountSettings=Ja,exports.Alert=D,exports.AmplifyProvider=Mn,exports.Authenticator=vn,exports.Autocomplete=Y,exports.Badge=X,exports.Breadcrumbs=ne,exports.ButtonGroup=le,exports.Card=se,exports.CheckboxField=ie,exports.Collection=Ee,exports.Divider=ve,exports.DropZone=xe,exports.Expander=Te,exports.ExpanderItem=Oe,exports.Fieldset=Re,exports.FileUploader=Dn,exports.Grid=de,exports.Heading=Le,exports.HighlightMatch=A,exports.IconsProvider=P,exports.Image=Ve,exports.Input=G,exports.Link=J,exports.Menu=ze,exports.MenuButton=_e,exports.MenuItem=Ge,exports.Message=Qe,exports.Pagination=pe,exports.PasswordField=na,exports.PhoneNumberField=oa,exports.Placeholder=ia,exports.Radio=ca,exports.RadioGroupField=ua,exports.Rating=ga,exports.ScrollView=M,exports.SearchField=K,exports.SelectField=sa,exports.SliderField=va,exports.StepperField=ya,exports.SwitchField=wa,exports.TabItem=Va,exports.Table=xa,exports.TableBody=Sa,exports.TableCell=Ia,exports.TableFoot=Ta,exports.TableHead=Pa,exports.TableRow=Da,exports.Tabs=La,exports.TextAreaField=ja,exports.TextField=W,exports.ThemeProvider=On,exports.ToggleButton=Aa,exports.ToggleButtonGroup=Ha,exports.VisuallyHidden=re,exports.components=Rn,exports.primitives=Ua,exports.useAmplify=function(){const e=b.useContext(l.AmplifyContext);return{theme:l.getThemeFromContext(e)}},exports.useBreakpointValue=(e,a="base",t)=>{const{breakpoints:{values:s},tokens:r}=l.useTheme(),o=l.useBreakpoint({breakpoints:s,defaultBreakpoint:a}),i=l.getValueAtCurrentBreakpoint({breakpoint:o,breakpoints:s,values:e});return n.isDesignToken(i)||n.isString(i)?l.getStyleValue({value:i,propKey:t,tokens:r}):i},exports.usePagination=fe,exports.withAuthenticator=Fn;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var isEqual = require('lodash/isEqual.js');
7
+ var uiReactCore = require('@aws-amplify/ui-react-core');
8
+ var ui = require('@aws-amplify/ui');
9
+ var Field = require('./Field-6c0e096a.js');
10
+ require('aws-amplify/storage');
11
+ var debounce = require('lodash/debounce.js');
12
+ var Dropdown = require('@radix-ui/react-dropdown-menu');
13
+ var RadixSlider = require('@radix-ui/react-slider');
14
+ var QRCode = require('qrcode');
15
+ var utils = require('aws-amplify/utils');
16
+ var RadixDirection = require('@radix-ui/react-direction');
17
+ require('@aws-amplify/core');
18
+ require('aws-amplify/auth');
19
+
20
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
+
22
+ function _interopNamespace(e) {
23
+ if (e && e.__esModule) return e;
24
+ var n = Object.create(null);
25
+ if (e) {
26
+ Object.keys(e).forEach(function (k) {
27
+ if (k !== 'default') {
28
+ var d = Object.getOwnPropertyDescriptor(e, k);
29
+ Object.defineProperty(n, k, d.get ? d : {
30
+ enumerable: true,
31
+ get: function () { return e[k]; }
32
+ });
33
+ }
34
+ });
35
+ }
36
+ n["default"] = e;
37
+ return Object.freeze(n);
38
+ }
39
+
40
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
41
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
42
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
43
+ var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
44
+ var Dropdown__namespace = /*#__PURE__*/_interopNamespace(Dropdown);
45
+ var RadixSlider__namespace = /*#__PURE__*/_interopNamespace(RadixSlider);
46
+ var QRCode__default = /*#__PURE__*/_interopDefaultLegacy(QRCode);
47
+ var RadixDirection__namespace = /*#__PURE__*/_interopNamespace(RadixDirection);
48
+
49
+ /**
50
+ * [📖 Docs](https://ui.docs.amplify.aws/react/theming/responsive#usebreakpointvalue)
51
+ */
52
+ const useBreakpointValue = (values, defaultBreakpoint = 'base', propKey) => {
53
+ const { breakpoints: { values: breakpoints }, tokens, } = Field.useTheme();
54
+ const breakpoint = Field.useBreakpoint({
55
+ breakpoints,
56
+ defaultBreakpoint,
57
+ });
58
+ const value = Field.getValueAtCurrentBreakpoint({
59
+ breakpoint,
60
+ breakpoints,
61
+ values,
62
+ });
63
+ if (ui.isDesignToken(value) || ui.isString(value)) {
64
+ return Field.getStyleValue({ value, propKey, tokens });
65
+ }
66
+ else {
67
+ return value;
68
+ }
69
+ };
70
+
71
+ function IconsProvider({ children, icons, }) {
72
+ return (React__namespace.createElement(Field.IconsContext.Provider, { value: icons }, children));
73
+ }
74
+
75
+ const AlertPrimitive = ({ buttonRef, children, className, dismissButtonLabel = Field.ComponentText.Alert.dismissButtonLabel, hasIcon = true, heading, isDismissible = false, onDismiss, variation, ...rest }, ref) => {
76
+ const [dismissed, setDismissed] = React__namespace.useState(false);
77
+ const icons = Field.useIcons('alert');
78
+ const dismissAlert = React__namespace.useCallback(() => {
79
+ setDismissed(!dismissed);
80
+ if (ui.isFunction(onDismiss)) {
81
+ onDismiss();
82
+ }
83
+ }, [setDismissed, onDismiss, dismissed]);
84
+ return !dismissed ? (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Alert, className, ui.classNameModifier(ui.ComponentClassName.Alert, variation)), ref: ref, role: "alert", ...rest },
85
+ hasIcon && React__namespace.createElement(Field.AlertIcon, { variation: variation, ariaHidden: true }),
86
+ React__namespace.createElement(Field.View, { flex: "1" },
87
+ heading && (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.AlertHeading }, heading)),
88
+ React__namespace.createElement(Field.View, { className: ui.ComponentClassName.AlertBody }, children)),
89
+ isDismissible && (React__namespace.createElement(Field.Button, { ariaLabel: dismissButtonLabel, variation: "link", className: ui.ComponentClassName.AlertDismiss, onClick: dismissAlert, ref: buttonRef }, icons?.close ?? React__namespace.createElement(Field.IconClose, { "aria-hidden": "true" }))))) : null;
90
+ };
91
+ /**
92
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/alert)
93
+ */
94
+ const Alert = Field.primitiveWithForwardRef(AlertPrimitive);
95
+ Alert.displayName = 'Alert';
96
+
97
+ const AutocompleteOptionPrimitive = ({ children, className, isActive, ...rest }, ref) => {
98
+ return (React__namespace.createElement(Field.View, { "aria-selected": isActive, as: "li", role: "option", className: ui.classNames(ui.ComponentClassName.AutocompleteMenuOption, ui.classNameModifierByFlag(ui.ComponentClassName.AutocompleteMenuOption, 'active', isActive), className), ref: ref, ...rest }, children));
99
+ };
100
+ const AutocompleteOption = Field.primitiveWithForwardRef(AutocompleteOptionPrimitive);
101
+ AutocompleteOption.displayName = 'AutocompleteOption';
102
+
103
+ const ScrollViewPrimitive = ({ children, className, orientation, ...rest }, ref) => (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.ScrollView, ui.classNameModifier(ui.ComponentClassName.ScrollView, orientation), className), ref: ref, ...rest }, children));
104
+ /**
105
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/scrollview)
106
+ */
107
+ const ScrollView = Field.primitiveWithForwardRef(ScrollViewPrimitive);
108
+ ScrollView.displayName = 'ScrollView';
109
+
110
+ const MenuHeader = ({ children }) => {
111
+ if (!children) {
112
+ return null;
113
+ }
114
+ return (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.AutocompleteMenuHeader }, children));
115
+ };
116
+ const MenuFooter = ({ children }) => {
117
+ if (!children) {
118
+ return null;
119
+ }
120
+ return (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.AutocompleteMenuFooter }, children));
121
+ };
122
+ const MenuLoading = ({ children }) => {
123
+ return (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.AutocompleteMenuLoading }, children ?? (React__namespace.createElement(React__namespace.Fragment, null,
124
+ React__namespace.createElement(Field.Loader, null),
125
+ Field.ComponentText.Autocomplete.loadingText))));
126
+ };
127
+ const MenuEmpty = ({ children }) => (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.AutocompleteMenuEmpty }, children ?? Field.ComponentText.Autocomplete.emptyText));
128
+ const AutocompleteMenuPrimitive = ({ ariaLabel, children, Header = null, Footer = null, LoadingIndicator = null, Empty = null, isLoading, listboxId, ...rest }, ref) => {
129
+ return (React__namespace.createElement(ScrollView, { className: ui.ComponentClassName.AutocompleteMenu, ref: ref, ...rest }, isLoading ? (React__namespace.createElement(MenuLoading, null, LoadingIndicator)) : (React__namespace.createElement(React__namespace.Fragment, null,
130
+ React__namespace.createElement(MenuHeader, null, Header),
131
+ children.length > 0 ? (React__namespace.createElement(ScrollView, { as: "ul", ariaLabel: ariaLabel, className: ui.ComponentClassName.AutocompleteMenuOptions, id: listboxId, role: "listbox" }, children)) : (React__namespace.createElement(MenuEmpty, null, Empty)),
132
+ React__namespace.createElement(MenuFooter, null, Footer)))));
133
+ };
134
+ const AutocompleteMenu = Field.primitiveWithForwardRef(AutocompleteMenuPrimitive);
135
+ AutocompleteMenu.displayName = 'AutocompleteMenu';
136
+
137
+ // Source: https://github.com/radix-ui/primitives/blob/7ae63b6cce6ea53ea5d65b6d411894c004b38f47/packages/react/use-layout-effect/src/useLayoutEffect.tsx
138
+ /**
139
+ * On the server, React emits a warning when calling `useLayoutEffect`.
140
+ * This is because neither `useLayoutEffect` nor `useEffect` run on the server.
141
+ * We use this safe version which suppresses the warning by replacing it with a noop on the server.
142
+ *
143
+ * See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
144
+ */
145
+ const useLayoutEffect = globalThis?.document ? React__namespace.useLayoutEffect : () => { };
146
+
147
+ // Adapted from https://github.com/radix-ui/primitives/blob/main/packages/react/id/src/id.tsx#L8
148
+ // Prefixed autogenerated id created by useStableId
149
+ const AUTO_GENERATED_ID_PREFIX = 'amplify-id';
150
+ // Create a local version of React.useId which will reference React.useId for React 18
151
+ // and fallback to noop for React 17 and below
152
+ // Note: We use `toString()` to prevent bundlers from trying to `import { useId } from 'react';`
153
+ // since it doesn't exist in React 17 and below (prevents https://github.com/aws-amplify/amplify-ui/issues/1154)
154
+ const useReactId =
155
+ // disable eslint below to allow usage of casting React to `any`, which ensures that TS
156
+ // does not get confused about the existence of `useId` in React 17 and below
157
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
158
+ React__namespace['useId'.toString()] || (() => undefined);
159
+ let count = 0;
160
+ /**
161
+ * Create a uuid to use with amplify fields unless
162
+ * an id is provided
163
+ * @param id user specified id
164
+ * @returns string
165
+ */
166
+ const useStableId = (id) => {
167
+ const [stableId, setStableId] = React__namespace.useState(useReactId());
168
+ // React versions older than 18 will have client-side ids only
169
+ useLayoutEffect(() => {
170
+ if (!id) {
171
+ setStableId((reactId) => reactId ?? String(count++));
172
+ }
173
+ }, [id]);
174
+ return id ?? (stableId ? `${AUTO_GENERATED_ID_PREFIX}-${stableId}` : '');
175
+ };
176
+
177
+ const DEFAULT_KEYS$1 = new Set([Field.ARROW_DOWN, Field.ARROW_UP, Field.ENTER_KEY, Field.ESCAPE_KEY]);
178
+ const useAutocomplete = ({ defaultValue = '', value, options, optionFilter, onBlur, onChange, onClear, onClick, onSelect, onSubmit, }) => {
179
+ const isControlled = value !== undefined;
180
+ const [internalValue, setInternalValue] = React__namespace.useState(defaultValue);
181
+ const composedValue = isControlled ? value : internalValue;
182
+ const [isMenuOpen, setIsMenuOpen] = React__namespace.useState(false);
183
+ const [activeOption, setActiveOption] = React__namespace.useState(null);
184
+ const isCustomFiltering = ui.isFunction(optionFilter);
185
+ const filteredOptions = React__namespace.useMemo(() => {
186
+ const defaultFilter = (option) => {
187
+ const { label } = option;
188
+ return label
189
+ ?.toLocaleLowerCase()
190
+ .includes(composedValue?.toLocaleLowerCase());
191
+ };
192
+ const filter = isCustomFiltering
193
+ ? (option) => optionFilter(option, composedValue)
194
+ : defaultFilter;
195
+ return options?.filter(filter) ?? [];
196
+ }, [composedValue, optionFilter, isCustomFiltering, options]);
197
+ const autocompleteId = useStableId();
198
+ const listboxId = useStableId();
199
+ const menuId = useStableId();
200
+ const optionBaseId = useStableId();
201
+ const activeIndex = filteredOptions.findIndex((option) => option === activeOption);
202
+ const activeOptionId = activeOption?.id ??
203
+ (activeIndex !== -1 ? `${optionBaseId}-option-${activeIndex}` : undefined);
204
+ const handleOnBlur = React__namespace.useCallback((event) => {
205
+ setIsMenuOpen(false);
206
+ setActiveOption(null);
207
+ if (ui.isFunction(onBlur)) {
208
+ onBlur(event);
209
+ }
210
+ }, [onBlur]);
211
+ const handleOnChange = React__namespace.useCallback((event) => {
212
+ setActiveOption(null);
213
+ setIsMenuOpen(true);
214
+ if (!isControlled) {
215
+ setInternalValue(event.target.value);
216
+ }
217
+ if (ui.isFunction(onChange)) {
218
+ onChange(event);
219
+ }
220
+ }, [isControlled, onChange]);
221
+ const handleOnClear = React__namespace.useCallback(() => {
222
+ if (!isControlled) {
223
+ setInternalValue('');
224
+ }
225
+ if (ui.isFunction(onClear)) {
226
+ onClear();
227
+ }
228
+ }, [isControlled, onClear]);
229
+ const handleOnClick = React__namespace.useCallback((event) => {
230
+ setIsMenuOpen(true);
231
+ if (ui.isFunction(onClick)) {
232
+ onClick(event);
233
+ }
234
+ }, [onClick]);
235
+ const handleOnKeyDown = (event) => {
236
+ const { key } = event;
237
+ if (!DEFAULT_KEYS$1.has(key)) {
238
+ return;
239
+ }
240
+ event.preventDefault();
241
+ switch (key) {
242
+ case Field.ESCAPE_KEY: {
243
+ if (isMenuOpen) {
244
+ setIsMenuOpen(false);
245
+ setActiveOption(null);
246
+ }
247
+ else {
248
+ handleOnClear();
249
+ }
250
+ break;
251
+ }
252
+ case Field.ENTER_KEY: {
253
+ if (!activeOption) {
254
+ if (ui.isFunction(onSubmit)) {
255
+ onSubmit(composedValue);
256
+ }
257
+ }
258
+ else {
259
+ const { label } = activeOption;
260
+ if (!isControlled) {
261
+ setInternalValue(label);
262
+ }
263
+ if (ui.isFunction(onSelect)) {
264
+ onSelect(activeOption);
265
+ }
266
+ }
267
+ setIsMenuOpen(false);
268
+ setActiveOption(null);
269
+ break;
270
+ }
271
+ case Field.ARROW_DOWN: {
272
+ if (filteredOptions.length <= 0) {
273
+ return;
274
+ }
275
+ setIsMenuOpen(true);
276
+ const newActiveIndex = activeIndex >= filteredOptions.length - 1 ? 0 : activeIndex + 1;
277
+ setActiveOption(filteredOptions[newActiveIndex]);
278
+ break;
279
+ }
280
+ case Field.ARROW_UP: {
281
+ if (filteredOptions.length <= 0) {
282
+ return;
283
+ }
284
+ setIsMenuOpen(true);
285
+ const newActiveIndex = activeIndex <= 0 ? filteredOptions.length - 1 : activeIndex - 1;
286
+ setActiveOption(filteredOptions[newActiveIndex]);
287
+ }
288
+ }
289
+ };
290
+ // The window will scroll down to the right place to show the whole menu
291
+ // if space is not enough in current viewport
292
+ React__namespace.useEffect(() => {
293
+ const autocompleteElement = document.getElementById(autocompleteId);
294
+ const menuElement = document.getElementById(menuId);
295
+ if (menuElement && isMenuOpen && autocompleteElement) {
296
+ const { bottom } = menuElement.getBoundingClientRect();
297
+ const { offsetParent, offsetTop } = autocompleteElement;
298
+ if (offsetParent === document.body &&
299
+ bottom > document.documentElement.clientHeight) {
300
+ window.scrollTo({
301
+ top: Math.min(bottom -
302
+ document.documentElement.clientHeight +
303
+ window.scrollY +
304
+ 20, // Add 20 gap between menu bottom and window viewport bottom
305
+ offsetTop),
306
+ behavior: 'smooth',
307
+ });
308
+ }
309
+ }
310
+ }, [autocompleteId, isMenuOpen, menuId]);
311
+ // This will make the menu able to scroll with keyboard,
312
+ // and scroll each option into window viewport if necessary
313
+ React__namespace.useEffect(() => {
314
+ const listboxElement = document.getElementById(listboxId);
315
+ const activeOptionElement = Field.strHasLength(activeOptionId)
316
+ ? document.getElementById(activeOptionId)
317
+ : null;
318
+ if (activeOptionElement && listboxElement) {
319
+ const { scrollTop, clientHeight } = listboxElement;
320
+ const { offsetHeight, offsetTop } = activeOptionElement;
321
+ const { top, bottom } = activeOptionElement.getBoundingClientRect();
322
+ if (scrollTop > offsetTop) {
323
+ listboxElement.scrollTop = offsetTop;
324
+ }
325
+ if (scrollTop + clientHeight < offsetTop + offsetHeight) {
326
+ listboxElement.scrollTop = offsetTop + offsetHeight - clientHeight;
327
+ }
328
+ if (top < 0 || bottom > document.documentElement.clientHeight) {
329
+ activeOptionElement.scrollIntoView({
330
+ behavior: 'smooth',
331
+ block: 'nearest',
332
+ });
333
+ }
334
+ }
335
+ }, [activeOptionId, listboxId]);
336
+ return {
337
+ activeOptionId,
338
+ autocompleteId,
339
+ composedValue,
340
+ filteredOptions,
341
+ handleOnBlur,
342
+ handleOnClear,
343
+ handleOnClick,
344
+ handleOnChange,
345
+ handleOnKeyDown,
346
+ isControlled,
347
+ isCustomFiltering,
348
+ isMenuOpen,
349
+ listboxId,
350
+ menuId,
351
+ optionBaseId,
352
+ setActiveOption,
353
+ setIsMenuOpen,
354
+ setInternalValue,
355
+ };
356
+ };
357
+
358
+ const getTestId = (testId, component) => testId && component ? `${testId}-${component}` : undefined;
359
+
360
+ const HighlightMatchPrimitive = ({ children, className, query, testId, ...rest }, ref) => {
361
+ const matchTestId = getTestId(testId, 'match');
362
+ const startIndex = children
363
+ ?.toLocaleLowerCase()
364
+ .indexOf(query?.toLocaleLowerCase());
365
+ if (Field.strHasLength(query) && startIndex !== -1) {
366
+ const match = children.substring(startIndex, startIndex + query.length);
367
+ return (React__namespace.createElement(Field.View, { as: "span", className: ui.classNames(className, ui.ComponentClassName.HighlightMatch), testId: testId, ref: ref, ...rest },
368
+ children.substring(0, startIndex),
369
+ React__namespace.createElement(Field.View, { as: "strong", className: ui.ComponentClassName.HighlightMatchHighlighted, testId: matchTestId }, match),
370
+ children.substring(startIndex + query.length)));
371
+ }
372
+ return (React__namespace.createElement(Field.View, { as: "span", testId: testId }, children));
373
+ };
374
+ /**
375
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/highlightmatch)
376
+ */
377
+ const HighlightMatch = Field.primitiveWithForwardRef(HighlightMatchPrimitive);
378
+ HighlightMatch.displayName = 'HighlightMatch';
379
+
380
+ const ariaLabelText = Field.ComponentText.SearchField.searchButtonLabel;
381
+ const SearchFieldButtonPrimitive = ({ size, ...props }, ref) => {
382
+ const icons = Field.useIcons('searchField');
383
+ return (React__namespace.createElement(Field.FieldGroupIconButton, { ariaLabel: ariaLabelText, className: ui.ComponentClassName.SearchFieldSearch, size: size, ref: ref, type: "submit", ...props }, icons?.search ?? React__namespace.createElement(Field.IconSearch, null)));
384
+ };
385
+ const SearchFieldButton = Field.primitiveWithForwardRef(SearchFieldButtonPrimitive);
386
+ SearchFieldButton.displayName = 'SearchFieldButton';
387
+
388
+ const FieldGroupPrimitive = ({ children, className, innerEndComponent, innerStartComponent, orientation = 'horizontal', outerEndComponent, outerStartComponent, variation, ...rest }, ref) => {
389
+ // Don't apply hasInner classnames unless a component was provided
390
+ const hasInnerStartComponent = innerStartComponent != null;
391
+ const hasInnerEndComponent = innerEndComponent != null;
392
+ const fieldGroupHasInnerStartClassName = hasInnerStartComponent
393
+ ? ui.ComponentClassName.FieldGroupHasInnerStart
394
+ : null;
395
+ const fieldGroupHasInnerEndClassName = hasInnerEndComponent
396
+ ? ui.ComponentClassName.FieldGroupHasInnerEnd
397
+ : null;
398
+ const componentClasses = ui.classNames(ui.ComponentClassName.FieldGroup, fieldGroupHasInnerStartClassName, fieldGroupHasInnerEndClassName, ui.classNameModifier(ui.ComponentClassName.FieldGroup, orientation), className);
399
+ return (React__namespace.createElement(Field.Flex, { className: componentClasses, ref: ref, ...rest },
400
+ outerStartComponent && (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.FieldGroupOuterStart, ui.classNameModifier(ui.ComponentClassName.FieldGroupOuterStart, variation)) }, outerStartComponent)),
401
+ React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.FieldGroupFieldWrapper, ui.classNameModifier(ui.ComponentClassName.FieldGroupFieldWrapper, orientation)) },
402
+ innerStartComponent && (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.FieldGroupInnerStart }, innerStartComponent)),
403
+ children,
404
+ innerEndComponent && (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.FieldGroupInnerEnd }, innerEndComponent))),
405
+ outerEndComponent && (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.FieldGroupOuterEnd, ui.classNameModifier(ui.ComponentClassName.FieldGroupOuterEnd, variation)) }, outerEndComponent))));
406
+ };
407
+ const FieldGroup = Field.primitiveWithForwardRef(FieldGroupPrimitive);
408
+ FieldGroup.displayName = 'FieldGroup';
409
+
410
+ const InputPrimitive = ({ autoComplete, checked, className, defaultChecked, defaultValue, id, isDisabled, isReadOnly, isRequired, size, type = 'text', hasError = false, value, variation, ...rest }, ref) => {
411
+ const componentClasses = ui.classNames(ui.ComponentClassName.Input, ui.ComponentClassName.FieldGroupControl, ui.classNameModifier(ui.ComponentClassName.Input, variation), ui.classNameModifierByFlag(ui.ComponentClassName.Input, 'error', hasError), ui.classNameModifier(ui.ComponentClassName.Input, size), className);
412
+ const { isFieldsetDisabled } = Field.useFieldset();
413
+ return (React__namespace.createElement(Field.View, { "aria-invalid": hasError, as: "input", autoComplete: autoComplete, checked: checked, className: componentClasses, defaultChecked: defaultChecked, defaultValue: defaultValue, isDisabled: isFieldsetDisabled ? isFieldsetDisabled : isDisabled, id: id, readOnly: isReadOnly, ref: ref, required: isRequired, type: type, value: value, ...rest }));
414
+ };
415
+ const Input = Field.primitiveWithForwardRef(InputPrimitive);
416
+ Input.displayName = 'Input';
417
+
418
+ const isStyleKey = (prop) => {
419
+ return prop in Field.ComponentPropsToStylePropsMap;
420
+ };
421
+ /**
422
+ * This function splits props into style props and non-style props. This is used
423
+ * on Field primitives so we can apply style props on the wrapper element and
424
+ * the rest on the input.
425
+ * @param props this should be a destructured `rest` from the component's props
426
+ */
427
+ const splitPrimitiveProps = (props) => {
428
+ const splitProps = {
429
+ styleProps: {},
430
+ rest: {},
431
+ };
432
+ Object.keys(props).forEach((prop) => {
433
+ if (isStyleKey(prop)) {
434
+ // we know it is a style key
435
+ // so we know we can assign the key in styleProps
436
+ splitProps.styleProps = {
437
+ ...splitProps.styleProps,
438
+ [prop]: props[prop],
439
+ };
440
+ }
441
+ else {
442
+ splitProps.rest = {
443
+ ...splitProps.rest,
444
+ [prop]: props[prop],
445
+ };
446
+ }
447
+ });
448
+ return splitProps;
449
+ };
450
+
451
+ const TextFieldPrimitive = (props, ref) => {
452
+ const { className, descriptiveText, errorMessage, hasError = false, id, innerEndComponent, innerStartComponent, label, labelHidden = false, outerEndComponent, outerStartComponent, size, testId, variation, inputStyles, ..._rest } = props;
453
+ const fieldId = useStableId(id);
454
+ const descriptionId = useStableId();
455
+ const ariaDescribedBy = descriptiveText ? descriptionId : undefined;
456
+ const { styleProps, rest } = splitPrimitiveProps(_rest);
457
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), ui.ComponentClassName.TextField, className), testId: testId, ...styleProps },
458
+ React__namespace.createElement(Field.Label, { htmlFor: fieldId, visuallyHidden: labelHidden }, label),
459
+ React__namespace.createElement(Field.FieldDescription, { id: descriptionId, labelHidden: labelHidden, descriptiveText: descriptiveText }),
460
+ React__namespace.createElement(FieldGroup, { outerStartComponent: outerStartComponent, outerEndComponent: outerEndComponent, innerStartComponent: innerStartComponent, innerEndComponent: innerEndComponent, variation: variation },
461
+ React__namespace.createElement(Input, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, size: size, variation: variation, ...inputStyles, ...rest })),
462
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
463
+ };
464
+ /**
465
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/textfield)
466
+ */
467
+ const TextField = Field.primitiveWithForwardRef(TextFieldPrimitive);
468
+ TextField.displayName = 'TextField';
469
+
470
+ /**
471
+ * Creates ref callback to compose together external and internal refs
472
+ */
473
+ function useComposeRefsCallback({ externalRef, internalRef, }) {
474
+ return React__namespace.useCallback((node) => {
475
+ // Handle callback ref
476
+ if (ui.isFunction(externalRef)) {
477
+ externalRef(node);
478
+ }
479
+ else if (externalRef) {
480
+ externalRef.current = node;
481
+ }
482
+ internalRef.current = node;
483
+ }, [externalRef, internalRef]);
484
+ }
485
+
486
+ const DEFAULT_KEYS = new Set([Field.ESCAPE_KEY, Field.ENTER_KEY]);
487
+ const useSearchField = ({ defaultValue = '', value, onChange, onClear, onSubmit, externalRef, }) => {
488
+ const isControlled = value !== undefined;
489
+ const [internalValue, setInternalValue] = React__namespace.useState(defaultValue);
490
+ const composedValue = isControlled ? value : internalValue;
491
+ const internalRef = React__namespace.useRef(null);
492
+ const composedRefs = useComposeRefsCallback({
493
+ externalRef,
494
+ internalRef,
495
+ });
496
+ const onClearHandler = React__namespace.useCallback(() => {
497
+ if (!isControlled) {
498
+ setInternalValue('');
499
+ }
500
+ internalRef?.current?.focus();
501
+ if (ui.isFunction(onClear)) {
502
+ onClear();
503
+ }
504
+ }, [isControlled, setInternalValue, onClear]);
505
+ const onSubmitHandler = React__namespace.useCallback((value) => {
506
+ if (ui.isFunction(onSubmit)) {
507
+ onSubmit(value);
508
+ }
509
+ }, [onSubmit]);
510
+ const onKeyDown = React__namespace.useCallback((event) => {
511
+ const { key } = event;
512
+ if (!DEFAULT_KEYS.has(key)) {
513
+ return;
514
+ }
515
+ event.preventDefault();
516
+ if (key === Field.ESCAPE_KEY) {
517
+ onClearHandler();
518
+ }
519
+ else if (key === Field.ENTER_KEY) {
520
+ onSubmitHandler(composedValue);
521
+ }
522
+ }, [composedValue, onClearHandler, onSubmitHandler]);
523
+ const handleOnChange = React__namespace.useCallback((event) => {
524
+ if (!isControlled) {
525
+ setInternalValue(event.target.value);
526
+ }
527
+ if (ui.isFunction(onChange)) {
528
+ onChange(event);
529
+ }
530
+ }, [isControlled, onChange, setInternalValue]);
531
+ const onClick = React__namespace.useCallback(() => {
532
+ onSubmitHandler(composedValue);
533
+ }, [onSubmitHandler, composedValue]);
534
+ return {
535
+ composedValue,
536
+ onClearHandler,
537
+ onKeyDown,
538
+ onClick,
539
+ handleOnChange,
540
+ composedRefs,
541
+ };
542
+ };
543
+
544
+ const SearchFieldPrimitive = ({ autoComplete = 'off', className, isDisabled, clearButtonLabel, labelHidden = true, name = 'q', hasSearchButton = true, hasSearchIcon = false, onChange, onClear, onSubmit, searchButtonRef, size, defaultValue, value, ...rest }, ref) => {
545
+ const { composedValue, onClearHandler, onKeyDown, onClick, handleOnChange, composedRefs, } = useSearchField({
546
+ defaultValue,
547
+ value,
548
+ onChange,
549
+ onClear,
550
+ onSubmit,
551
+ externalRef: ref,
552
+ });
553
+ const SearchButton = hasSearchButton ? (React__namespace.createElement(SearchFieldButton, { isDisabled: isDisabled, onClick: onClick, ref: searchButtonRef, size: size })) : undefined;
554
+ const SearchIcon = hasSearchIcon ? (React__namespace.createElement(Field.FieldGroupIcon, null,
555
+ React__namespace.createElement(Field.IconSearch, null))) : undefined;
556
+ return (React__namespace.createElement(TextField, { autoComplete: autoComplete, className: ui.classNames(ui.ComponentClassName.SearchField, className), labelHidden: labelHidden, innerStartComponent: SearchIcon, innerEndComponent: React__namespace.createElement(Field.FieldClearButton, { ariaLabel: clearButtonLabel, excludeFromTabOrder: true, isVisible: !isDisabled && Field.strHasLength(composedValue), onClick: onClearHandler, size: size, variation: "link" }), isDisabled: isDisabled, name: name, onChange: handleOnChange, onKeyDown: onKeyDown, outerEndComponent: SearchButton, ref: composedRefs, size: size, value: composedValue, ...rest }));
557
+ };
558
+ /**
559
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/searchfield)
560
+ */
561
+ const SearchField = Field.primitiveWithForwardRef(SearchFieldPrimitive);
562
+ SearchField.displayName = 'SearchField';
563
+
564
+ const AutocompletePrimitive = ({ className, defaultValue, value, isLoading = false, menuSlots = {}, options, optionFilter, onBlur, onChange, onClear, onClick, onSelect, onSubmit, renderOption, testId, ...rest }, ref) => {
565
+ const { activeOptionId, autocompleteId, composedValue, filteredOptions, handleOnBlur, handleOnClear, handleOnClick, handleOnChange, handleOnKeyDown, isControlled, isCustomFiltering, isMenuOpen, listboxId, menuId, optionBaseId, setActiveOption, setIsMenuOpen, setInternalValue, } = useAutocomplete({
566
+ defaultValue,
567
+ value,
568
+ options,
569
+ optionFilter,
570
+ onBlur,
571
+ onChange,
572
+ onClear,
573
+ onClick,
574
+ onSelect,
575
+ onSubmit,
576
+ });
577
+ const comboboxProps = {
578
+ role: 'combobox',
579
+ 'aria-activedescendant': activeOptionId,
580
+ 'aria-autocomplete': 'list',
581
+ 'aria-controls': isMenuOpen ? menuId : undefined,
582
+ 'aria-expanded': isMenuOpen,
583
+ 'aria-haspopup': 'listbox',
584
+ 'aria-owns': isMenuOpen ? menuId : undefined,
585
+ };
586
+ const Options = filteredOptions.map((option, idx) => {
587
+ const { id, label, ...rest } = option;
588
+ const handleOnClick = () => {
589
+ setIsMenuOpen(false);
590
+ setActiveOption(null);
591
+ if (!isControlled) {
592
+ setInternalValue(label);
593
+ }
594
+ if (ui.isFunction(onSelect)) {
595
+ onSelect(option);
596
+ }
597
+ };
598
+ // This is required. Mousedown event will fire a blur event by default
599
+ // and so the menu will close before the click event on an option gets a chance to fire
600
+ const handleOnMouseDown = (event) => {
601
+ event.preventDefault();
602
+ };
603
+ const handleOnMouseMove = () => {
604
+ setActiveOption(option);
605
+ };
606
+ const optionId = id ?? `${optionBaseId}-option-${idx}`;
607
+ const isActive = optionId === activeOptionId;
608
+ return (React__namespace.createElement(AutocompleteOption, { isActive: isActive, id: optionId, key: optionId, onClick: handleOnClick, onMouseDown: handleOnMouseDown, onMouseMove: handleOnMouseMove, ...rest }, ui.isFunction(renderOption) ? (renderOption(option, composedValue)) : isCustomFiltering ? (label) : (React__namespace.createElement(HighlightMatch, { query: composedValue }, label))));
609
+ });
610
+ return (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.Autocomplete, className), id: autocompleteId, testId: testId },
611
+ React__namespace.createElement(SearchField, { hasSearchButton: false, hasSearchIcon: true, onBlur: handleOnBlur, onChange: handleOnChange, onClear: handleOnClear, onClick: handleOnClick, onKeyDown: handleOnKeyDown, ref: ref, value: composedValue, ...comboboxProps, ...rest }),
612
+ isMenuOpen ? (React__namespace.createElement(AutocompleteMenu, { id: menuId, isLoading: isLoading, listboxId: listboxId, ...menuSlots }, Options)) : null));
613
+ };
614
+ /**
615
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/autocomplete)
616
+ */
617
+ const Autocomplete = Field.primitiveWithForwardRef(AutocompletePrimitive);
618
+ Autocomplete.displayName = 'Autocomplete';
619
+
620
+ const BadgePrimitive = ({ className, children, variation, size, ...rest }, ref) => {
621
+ const componentClasses = ui.classNames(ui.ComponentClassName.Badge, className, ui.classNameModifier(ui.ComponentClassName.Badge, variation), ui.classNameModifier(ui.ComponentClassName.Badge, size));
622
+ return (React__namespace.createElement(Field.View, { as: "span", className: componentClasses, ref: ref, ...rest }, children));
623
+ };
624
+ /**
625
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/badge)
626
+ */
627
+ const Badge = Field.primitiveWithForwardRef(BadgePrimitive);
628
+ Badge.displayName = 'Badge';
629
+
630
+ const BreadcrumbItemPrimitive = ({ className, children, as = 'li', ...rest }, ref) => {
631
+ const componentClasses = ui.classNames(ui.ComponentClassName.BreadcrumbsItem, className);
632
+ return (React__namespace.createElement(Field.View, { ...rest, as: as, className: componentClasses, ref: ref }, children));
633
+ };
634
+ /**
635
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/breadcrumbs)
636
+ */
637
+ const BreadcrumbItem = Field.primitiveWithForwardRef(BreadcrumbItemPrimitive);
638
+ BreadcrumbItem.displayName = 'Breadcrumbs.Item';
639
+
640
+ const LinkPrimitive = ({ as = 'a', children, className, isExternal, ...rest }, ref) => {
641
+ return (React__namespace.createElement(Field.View, { as: as, className: ui.classNames(ui.ComponentClassName.Link, className), ref: ref, rel: isExternal ? 'noopener noreferrer' : undefined, target: isExternal ? '_blank' : undefined, ...rest }, children));
642
+ };
643
+ /**
644
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/link)
645
+ */
646
+ const Link = Field.primitiveWithForwardRef(LinkPrimitive);
647
+ Link.displayName = 'Link';
648
+
649
+ const BreadcrumbLinkPrimitive = ({ className, children, href, isCurrent, ...rest }, ref) => {
650
+ const componentClasses = ui.classNames(ui.ComponentClassName.BreadcrumbsLink, ui.classNameModifierByFlag(ui.ComponentClassName.BreadcrumbsLink, 'current', isCurrent), className);
651
+ if (isCurrent) {
652
+ const ariaCurrent = rest['aria-current'] ?? 'page';
653
+ const as = rest.as ?? 'span';
654
+ return (React__namespace.createElement(Field.Text, { ...rest, as: as, "aria-current": ariaCurrent, className: componentClasses, ref: ref }, children));
655
+ }
656
+ else {
657
+ return (React__namespace.createElement(Link, { ...rest, className: componentClasses, ref: ref, href: href }, children));
658
+ }
659
+ };
660
+ /**
661
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/breadcrumbs)
662
+ */
663
+ const BreadcrumbLink = Field.primitiveWithForwardRef(BreadcrumbLinkPrimitive);
664
+ BreadcrumbLink.displayName = 'Breadcrumbs.Link';
665
+
666
+ const BreadcrumbSeparatorPrimitive = ({ className, children = '/', as = 'span', ...rest }, ref) => {
667
+ const ariaHidden = rest['aria-hidden'] ?? 'true';
668
+ return (React__namespace.createElement(Field.View, { ...rest, as: as, ref: ref, "aria-hidden": ariaHidden, className: ui.classNames(ui.ComponentClassName.BreadcrumbsSeparator, className) }, children));
669
+ };
670
+ /**
671
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/breadcrumbs)
672
+ */
673
+ const BreadcrumbSeparator = Field.primitiveWithForwardRef(BreadcrumbSeparatorPrimitive);
674
+ BreadcrumbSeparator.displayName = 'Breadcrumbs.Separator';
675
+
676
+ const BreadcrumbContainerPrimitive = ({ className, children, ...rest }, ref) => {
677
+ const componentClasses = ui.classNames(ui.ComponentClassName.Breadcrumbs, className);
678
+ const ariaLabel = rest['aria-label'] ?? 'Breadcrumb';
679
+ return (React__namespace.createElement(Field.View, { ...rest, as: "nav", "aria-label": ariaLabel, className: componentClasses, ref: ref },
680
+ React__namespace.createElement(Field.View, { as: "ol", className: ui.ComponentClassName.BreadcrumbsList }, children)));
681
+ };
682
+ /**
683
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/breadcrumbs)
684
+ */
685
+ const BreadcrumbContainer = Field.primitiveWithForwardRef(BreadcrumbContainerPrimitive);
686
+ BreadcrumbContainer.displayName = 'Breadcrumbs.Container';
687
+
688
+ const BreadcrumbsPrimitive = ({ className, items, separator = React__namespace.createElement(BreadcrumbSeparator, null), ...rest }, ref) => {
689
+ const ariaLabel = rest['aria-label'] ?? 'Breadcrumb';
690
+ return (React__namespace.createElement(BreadcrumbContainer, { ...rest, "aria-label": ariaLabel, className: className, ref: ref }, items?.map(({ href, label }, idx) => {
691
+ const isCurrent = items.length - 1 === idx;
692
+ return (React__namespace.createElement(BreadcrumbItem, { key: `${href}${idx}` },
693
+ React__namespace.createElement(BreadcrumbLink, { href: href, isCurrent: isCurrent }, label),
694
+ isCurrent ? null : separator));
695
+ })));
696
+ };
697
+ /**
698
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/breadcrumbs)
699
+ */
700
+ const Breadcrumbs = Object.assign(Field.primitiveWithForwardRef(BreadcrumbsPrimitive), {
701
+ Item: BreadcrumbItem,
702
+ Link: BreadcrumbLink,
703
+ Separator: BreadcrumbSeparator,
704
+ Container: BreadcrumbContainer,
705
+ });
706
+ Breadcrumbs.displayName = 'Breadcrumbs';
707
+
708
+ const ButtonGroupPrimitive = ({ className, children, role = 'group', size: _size, variation: _variation, ...rest }, ref) => (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.ButtonGroup, className), role: role, ref: ref, ...rest }, React__namespace.Children.map(children, (child) => {
709
+ if (React__namespace.isValidElement(child)) {
710
+ const { size = _size, variation = _variation } = child.props;
711
+ return React__namespace.cloneElement(child, { size, variation });
712
+ }
713
+ return child;
714
+ })));
715
+ /**
716
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/button#buttongroup)
717
+ */
718
+ const ButtonGroup = Field.primitiveWithForwardRef(ButtonGroupPrimitive);
719
+ ButtonGroup.displayName = 'ButtonGroup';
720
+
721
+ const CardPrimitive = ({ className, children, variation, ...rest }, ref) => {
722
+ return (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.Card, ui.classNameModifier(ui.ComponentClassName.Card, variation), className), ref: ref, ...rest }, children));
723
+ };
724
+ /**
725
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/card)
726
+ */
727
+ const Card = Field.primitiveWithForwardRef(CardPrimitive);
728
+ Card.displayName = 'Card';
729
+
730
+ const VisuallyHiddenPrimitive = ({ as = 'span', children, className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: as, className: ui.classNames(ui.ComponentClassName.VisuallyHidden, className), ref: ref, ...rest }, children));
731
+ /**
732
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/visuallyhidden)
733
+ */
734
+ const VisuallyHidden = Field.primitiveWithForwardRef(VisuallyHiddenPrimitive);
735
+ VisuallyHidden.displayName = 'VisuallyHidden';
736
+
737
+ const CheckboxPrimitive = ({ checked: controlledChecked, className, defaultChecked, hasError, isDisabled, isIndeterminate, label, labelHidden, labelPosition, onBlur: _onBlur, onFocus: _onFocus, onChange: _onChange, testId, inputStyles, ..._rest }, ref) => {
738
+ const { styleProps, rest } = splitPrimitiveProps(_rest);
739
+ const [focused, setFocused] = React__namespace.useState(false);
740
+ const icons = Field.useIcons('checkbox');
741
+ const { isFieldsetDisabled } = Field.useFieldset();
742
+ const shouldBeDisabled = isFieldsetDisabled ? isFieldsetDisabled : isDisabled;
743
+ const isControlled = controlledChecked !== undefined;
744
+ const [localChecked, setLocalChecked] = React__namespace.useState(() =>
745
+ // if controlled, initialize to `controlledChecked` else `defaultChecked`
746
+ isControlled ? controlledChecked : defaultChecked);
747
+ const checked = isControlled ? controlledChecked : localChecked;
748
+ const onChange = (e) => {
749
+ if (ui.isFunction(_onChange)) {
750
+ _onChange(e);
751
+ }
752
+ // in controlled mode, `controlledChecked` determines checked state
753
+ if (!isControlled) {
754
+ setLocalChecked(e.target.checked);
755
+ }
756
+ };
757
+ const onFocus = (e) => {
758
+ if (ui.isFunction(_onFocus)) {
759
+ _onFocus(e);
760
+ }
761
+ setFocused(true);
762
+ };
763
+ const onBlur = (e) => {
764
+ if (ui.isFunction(_onBlur)) {
765
+ _onBlur(e);
766
+ }
767
+ setFocused(false);
768
+ };
769
+ const dataId = useStableId();
770
+ React__namespace.useEffect(() => {
771
+ const input = document.querySelector(`[data-id="${dataId}"]`);
772
+ if (input && typeof isIndeterminate === 'boolean') {
773
+ // HTMLInputElement does not have an `indeterminate` attribute
774
+ input.indeterminate =
775
+ isIndeterminate;
776
+ }
777
+ }, [dataId, isIndeterminate]);
778
+ const buttonTestId = getTestId(testId, ui.ComponentClassName.CheckboxButton);
779
+ const iconTestId = getTestId(testId, ui.ComponentClassName.CheckboxIcon);
780
+ const labelTestId = getTestId(testId, ui.ComponentClassName.CheckboxLabel);
781
+ const flexClasses = ui.classNames(ui.ComponentClassName.CheckboxButton, ui.classNameModifierByFlag(ui.ComponentClassName.CheckboxButton, 'disabled', shouldBeDisabled), ui.classNameModifierByFlag(ui.ComponentClassName.CheckboxButton, 'error', hasError), ui.classNameModifierByFlag(ui.ComponentClassName.CheckboxButton, 'focused', focused));
782
+ const iconClasses = ui.classNames(ui.ComponentClassName.CheckboxIcon, ui.classNameModifierByFlag(ui.ComponentClassName.CheckboxIcon, 'checked', checked), ui.classNameModifierByFlag(ui.ComponentClassName.CheckboxIcon, 'disabled', shouldBeDisabled), ui.classNameModifierByFlag(ui.ComponentClassName.CheckboxIcon, 'indeterminate', isIndeterminate));
783
+ const iconProps = {
784
+ className: ui.classNames(iconClasses),
785
+ 'data-checked': localChecked,
786
+ 'data-disabled': shouldBeDisabled,
787
+ 'data-testid': iconTestId,
788
+ };
789
+ const checkedIcon = icons?.checked ? (React__namespace.createElement(Field.View, { as: "span", className: ui.classNames(iconClasses) }, icons.checked)) : (React__namespace.createElement(Field.IconCheck, { ...iconProps }));
790
+ const indeterminateIcon = icons?.indeterminate ? (React__namespace.createElement(Field.View, { as: "span", className: ui.classNames(iconClasses) }, icons.indeterminate)) : (React__namespace.createElement(Field.IconIndeterminate, { ...iconProps }));
791
+ return (React__namespace.createElement(Field.Flex, { as: "label", className: ui.classNames(ui.ComponentClassName.Checkbox, ui.classNameModifierByFlag(ui.ComponentClassName.Checkbox, 'disabled', shouldBeDisabled), labelPosition ? `amplify-label-${labelPosition}` : null, className), testId: testId, ...styleProps },
792
+ React__namespace.createElement(VisuallyHidden, null,
793
+ React__namespace.createElement(Input, { checked: controlledChecked, className: ui.ComponentClassName.CheckboxInput, "data-id": dataId, defaultChecked: defaultChecked, isDisabled: shouldBeDisabled, onBlur: onBlur, onChange: onChange, onFocus: onFocus, ref: ref, type: "checkbox", ...rest })),
794
+ label && (React__namespace.createElement(Field.Text, { as: "span", className: ui.classNames(ui.ComponentClassName.CheckboxLabel, {
795
+ [ui.ComponentClassName.VisuallyHidden]: labelHidden,
796
+ }), "data-disabled": shouldBeDisabled, testId: labelTestId }, label)),
797
+ React__namespace.createElement(Field.Flex, { "aria-hidden": "true", as: "span", className: flexClasses, "data-checked": checked, "data-disabled": shouldBeDisabled, "data-focus": focused, "data-error": hasError, testId: buttonTestId, ...inputStyles }, isIndeterminate ? indeterminateIcon : checkedIcon)));
798
+ };
799
+ const Checkbox = Field.primitiveWithForwardRef(CheckboxPrimitive);
800
+ Checkbox.displayName = 'Checkbox';
801
+
802
+ const CheckboxFieldPrimitive = ({ className, errorMessage, hasError = false, labelHidden = false, labelPosition, testId, size, ...rest }, ref) => {
803
+ const checkboxTestId = getTestId(testId, ui.ComponentClassName.Checkbox);
804
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Field, ui.ComponentClassName.CheckboxField, ui.classNameModifier(ui.ComponentClassName.Field, size), className), testId: testId },
805
+ React__namespace.createElement(Checkbox, { hasError: hasError, labelHidden: labelHidden, testId: checkboxTestId, labelPosition: labelPosition, ref: ref, ...rest }),
806
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
807
+ };
808
+ /**
809
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/checkboxfield)
810
+ */
811
+ const CheckboxField = Field.primitiveWithForwardRef(CheckboxFieldPrimitive);
812
+ CheckboxField.displayName = 'CheckboxField';
813
+
814
+ const GridPrimitive = ({ className, children, ...rest }, ref) => (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.Grid, className), ref: ref, ...rest }, children));
815
+ /**
816
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/grid)
817
+ */
818
+ const Grid = Field.primitiveWithForwardRef(GridPrimitive);
819
+ Grid.displayName = 'Grid';
820
+
821
+ const ELLIPSIS = '...';
822
+ /**
823
+ * This hook will be used to determine the range of page numbers to be rendered,
824
+ * including ellipsis dots(e.g., an array like [1, '...', 4, 5, 6, '...', 10]).
825
+ * @param currentPage current page number
826
+ * @param totalPages total number of pages
827
+ * @param siblingCount the number of siblings on each side of
828
+ * @returns an array that contains the range of numbers to be rendered
829
+ */
830
+ const useRange = (currentPageParam, totalPagesParam, siblingCountParam = 1) => {
831
+ const range = React__namespace.useMemo(() => {
832
+ // The current page should not be less than 1
833
+ const currentPage = Math.max(currentPageParam, 1);
834
+ // The sibling count should not be less than 1
835
+ const siblingCount = Math.max(siblingCountParam, 1);
836
+ // The total pages should be always greater than current page
837
+ const totalPages = Math.max(currentPage, totalPagesParam);
838
+ // Note: 1-based index will be used for page value.
839
+ const firstPage = 1;
840
+ const lastPage = totalPages;
841
+ /**
842
+ * To avoid resizing our pagination component while a user is interacting with the component,
843
+ * the total number of items returned by the hook should remain constant.
844
+ * The consant is supposed to be the max number of items that would returned by the hook in all cases,
845
+ * so it should be calculated by 1(first page) + 1(last page) + 1(current page) + 2 * siblingCount + 2(ellipses)
846
+ */
847
+ const maxNumOfItems = 5 + 2 * siblingCount;
848
+ /**
849
+ * Case 1: If the total number of pages is not greater than the max number of items that would potentially be returned,
850
+ * then no need to run through the ellipsis cases, just simply return the range from 1 to totalPages (e.g. [1, 2, 3, 4]).
851
+ */
852
+ if (totalPages < maxNumOfItems) {
853
+ return Field.getConsecutiveIntArray(1, totalPages);
854
+ }
855
+ /**
856
+ * Determine if ellipsis dots should be rendered on either left or right side, or both
857
+ */
858
+ const leftSiblingPage = Math.max(currentPage - siblingCount, firstPage);
859
+ const rightSiblingPage = Math.min(currentPage + siblingCount, lastPage);
860
+ const shouldRenderStartEllipsis = leftSiblingPage > 2;
861
+ const shouldRenderEndEllipsis = rightSiblingPage < lastPage - 1;
862
+ /**
863
+ * Case 2: Only render ellipsis dots on the left side (e.g. [1, '...', 6, 7, 8, 9, 10]).
864
+ */
865
+ if (shouldRenderStartEllipsis && !shouldRenderEndEllipsis) {
866
+ // 1(current page) + 1(last page) + 1(fill up a page for the position of end ellipsis) + 2 * siblingCount
867
+ const rightItemCount = 3 + 2 * siblingCount;
868
+ const rightRange = Field.getConsecutiveIntArray(lastPage - rightItemCount + 1, lastPage);
869
+ return [firstPage, ELLIPSIS, ...rightRange];
870
+ }
871
+ /**
872
+ * Case 3: Only render ellipsis dots on the right side (e.g. [1, 2, 3, 4, 5, '...', 10]).
873
+ */
874
+ if (!shouldRenderStartEllipsis && shouldRenderEndEllipsis) {
875
+ // 1(current page) + 1(last page) + 1(fill up a page for the position of start ellipsis) + 2 * siblingCount
876
+ const leftItemCount = 3 + 2 * siblingCount;
877
+ const leftRange = Field.getConsecutiveIntArray(firstPage, leftItemCount);
878
+ return [...leftRange, ELLIPSIS, lastPage];
879
+ }
880
+ /**
881
+ * Case 4: Render ellipsis on both side (e.g. [1, '...', 4, 5, 6, '...', 10]).
882
+ */
883
+ const middleRange = Field.getConsecutiveIntArray(leftSiblingPage, rightSiblingPage);
884
+ return [firstPage, ELLIPSIS, ...middleRange, ELLIPSIS, lastPage];
885
+ }, [currentPageParam, totalPagesParam, siblingCountParam]);
886
+ return range;
887
+ };
888
+
889
+ const PAGINATION_CURRENT_TEST_ID = 'current';
890
+ const PAGINATION_ELLIPSIS_TEST_ID = 'ellipsis';
891
+ const PaginationItem = ({ type, page, currentPage, currentPageLabel = Field.ComponentText.PaginationItem.currentPageLabel, isDisabled, onClick, ariaLabel, ...rest }) => {
892
+ const icons = Field.useIcons('pagination');
893
+ const nextClasses = ui.classNames(ui.ComponentClassName.PaginationItem, ui.classNameModifier(ui.ComponentClassName.PaginationItem, 'link'), ui.classNameModifierByFlag(ui.ComponentClassName.PaginationItem, 'disabled', isDisabled));
894
+ const previousClasses = ui.classNames(ui.ComponentClassName.PaginationItem, ui.classNameModifier(ui.ComponentClassName.PaginationItem, 'link'), ui.classNameModifierByFlag(ui.ComponentClassName.PaginationItem, 'disabled', isDisabled));
895
+ switch (type) {
896
+ case 'page':
897
+ return (React__namespace.createElement(Field.View, { as: "li" }, page === currentPage ? (React__namespace.createElement(Field.Button, { "aria-current": "page", size: "small", variation: "link", className: ui.classNames(ui.ComponentClassName.PaginationItem, ui.classNameModifier(ui.ComponentClassName.PaginationItem, 'current')), testId: PAGINATION_CURRENT_TEST_ID, ...rest },
898
+ React__namespace.createElement(VisuallyHidden, null,
899
+ currentPageLabel,
900
+ ":"),
901
+ page)) : (React__namespace.createElement(Field.Button, { className: ui.ComponentClassName.PaginationItem, size: "small", variation: "link", onClick: () => {
902
+ onClick?.();
903
+ }, ariaLabel: ariaLabel, ...rest }, page))));
904
+ case 'next':
905
+ return (React__namespace.createElement(Field.View, { as: "li" },
906
+ React__namespace.createElement(Field.Button, { className: nextClasses, size: "small", variation: "link", isDisabled: isDisabled, onClick: () => {
907
+ onClick?.();
908
+ }, ariaLabel: ariaLabel, ...rest }, icons?.next ?? React__namespace.createElement(Field.IconChevronRight, null))));
909
+ case 'previous':
910
+ return (React__namespace.createElement(Field.View, { as: "li" },
911
+ React__namespace.createElement(Field.Button, { className: previousClasses, size: "small", variation: "link", isDisabled: isDisabled, onClick: () => {
912
+ onClick?.();
913
+ }, ariaLabel: ariaLabel, ...rest }, icons?.previous ?? React__namespace.createElement(Field.IconChevronLeft, null))));
914
+ case 'ellipsis':
915
+ return (React__namespace.createElement(Field.View, { as: "li" },
916
+ React__namespace.createElement(Field.Flex, { as: "span", className: ui.classNameModifier(ui.ComponentClassName.PaginationItem, 'ellipsis'), testId: PAGINATION_ELLIPSIS_TEST_ID, ...rest }, "\u2026")));
917
+ // No match type found
918
+ }
919
+ return React__namespace.createElement(Field.View, { as: "li" });
920
+ };
921
+ PaginationItem.displayName = 'PaginationItem';
922
+
923
+ /**
924
+ * This hook will be used to get the pagination items to be rendered in the pagination primitive
925
+ * @param currentPage current page number
926
+ * @param totalPages total number of pages
927
+ * @param siblingCount the number of siblings on each side of
928
+ * @param onNext callback function triggered when the next-page button is pressed
929
+ * @param onPrevious callback function triggered when the prev-page button is pressed
930
+ * @param onChange callback function triggered every time the page changes
931
+ * @returns an array of pagination items
932
+ */
933
+ const usePaginationItems = ({ currentPage, totalPages, hasMorePages, siblingCount, currentPageLabel = Field.ComponentText.PaginationItem.currentPageLabel, pageLabel = Field.ComponentText.PaginationItem.pageLabel, previousLabel = Field.ComponentText.PaginationItem.previousLabel, nextLabel = Field.ComponentText.PaginationItem.nextLabel, onNext, onPrevious, onChange, }) => {
934
+ const previousItem = (React__namespace.createElement(PaginationItem, { type: "previous", key: "previous", currentPage: currentPage, onClick: onPrevious, isDisabled: currentPage <= 1, ariaLabel: previousLabel }));
935
+ const nextItem = (React__namespace.createElement(PaginationItem, { type: "next", key: "next", currentPage: currentPage, onClick: onNext, isDisabled: currentPage >= totalPages && !hasMorePages, ariaLabel: nextLabel }));
936
+ // To get the range of page numbers to be rendered in the pagination primitive
937
+ const range = useRange(currentPage, totalPages, siblingCount);
938
+ const pageItems = React__namespace.useMemo(() => range.map((item, idx) => {
939
+ if (item === ELLIPSIS) {
940
+ return (React__namespace.createElement(PaginationItem, { type: "ellipsis", key: idx === 1 ? 'start-ellipsis' : 'end-ellipsis' }));
941
+ }
942
+ return (
943
+ // Note: Do NOT use index for `key` and instead use page number
944
+ // otherwise, react cannot update the component correctly with its diff mechanism
945
+ React__namespace.createElement(PaginationItem, { key: item, type: "page", page: item, currentPage: currentPage, currentPageLabel: currentPageLabel, onClick: () => onChange?.(item, currentPage),
946
+ /**
947
+ * @todo We should consider how we would support interpolation in our string translations.
948
+ * This works for "Go to page 31" or "translatedText {s}" as the supplied string
949
+ * But for Arabic or Japanese or some other languages the supplied string might look like: "{s} translatedText".
950
+ */
951
+ ariaLabel: `${pageLabel} ${item}` }));
952
+ }), [range, currentPage, currentPageLabel, pageLabel, onChange]);
953
+ return [previousItem, ...pageItems, nextItem];
954
+ };
955
+
956
+ const PaginationPrimitive = ({ className, currentPage = 1, totalPages, hasMorePages = false, siblingCount, currentPageLabel, pageLabel, previousLabel, nextLabel, onNext, onPrevious, onChange, ...rest }, ref) => {
957
+ const paginationItems = usePaginationItems({
958
+ currentPage,
959
+ totalPages,
960
+ hasMorePages,
961
+ siblingCount,
962
+ currentPageLabel,
963
+ pageLabel,
964
+ previousLabel,
965
+ nextLabel,
966
+ onNext,
967
+ onPrevious,
968
+ onChange,
969
+ });
970
+ return (React__namespace.createElement(Field.View, { as: "nav", className: ui.classNames(ui.ComponentClassName.Pagination, className), ref: ref, ...rest },
971
+ React__namespace.createElement(Field.Flex, { as: "ol", justifyContent: "center", alignItems: "center", gap: "inherit" }, paginationItems)));
972
+ };
973
+ /**
974
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/pagination)
975
+ */
976
+ const Pagination = Field.primitiveWithForwardRef(PaginationPrimitive);
977
+ Pagination.displayName = 'Pagination';
978
+
979
+ const usePagination = (props) => {
980
+ const { currentPage: initialPage = 1, totalPages, hasMorePages = false, siblingCount = 1, } = props;
981
+ // The current page should not be less than 1
982
+ const sanitizedInitialPage = Math.max(initialPage, 1);
983
+ // The total pages should be always greater than current page
984
+ const sanitizedTotalPages = Math.max(sanitizedInitialPage, totalPages);
985
+ const [currentPage, setCurrentPage] = React__namespace.useState(sanitizedInitialPage);
986
+ // Reset current page if initialPage or totalPages changes
987
+ React__namespace.useEffect(() => {
988
+ setCurrentPage(sanitizedInitialPage);
989
+ }, [sanitizedInitialPage, sanitizedTotalPages]);
990
+ const onNext = React__namespace.useCallback(() => {
991
+ if (currentPage < sanitizedTotalPages) {
992
+ setCurrentPage(currentPage + 1);
993
+ }
994
+ }, [currentPage, sanitizedTotalPages]);
995
+ const onPrevious = React__namespace.useCallback(() => {
996
+ if (currentPage > 1) {
997
+ setCurrentPage(currentPage - 1);
998
+ }
999
+ }, [currentPage]);
1000
+ const onChange = React__namespace.useCallback((newPageIndex) => {
1001
+ if (typeof newPageIndex === 'number') {
1002
+ setCurrentPage(newPageIndex);
1003
+ }
1004
+ }, []);
1005
+ return {
1006
+ currentPage,
1007
+ hasMorePages,
1008
+ onChange,
1009
+ onNext,
1010
+ onPrevious,
1011
+ // The sibling count should not be less than 1
1012
+ siblingCount: Math.max(siblingCount, 1),
1013
+ totalPages: sanitizedTotalPages,
1014
+ };
1015
+ };
1016
+
1017
+ /**
1018
+ * Slice a collection based on page index (starting at 1)
1019
+ */
1020
+ const getItemsAtPage = (items, page, itemsPerPage) => {
1021
+ if (page < 1 || itemsPerPage < 1) {
1022
+ return [];
1023
+ }
1024
+ const startIndex = (page - 1) * itemsPerPage;
1025
+ return items.slice(startIndex, startIndex + itemsPerPage);
1026
+ };
1027
+ /**
1028
+ * Recursively find a keyword within an object (case insensitive)
1029
+ */
1030
+ const itemHasText = (item, text) => {
1031
+ if (Field.strHasLength(item)) {
1032
+ return item.toLowerCase().includes(text.toLowerCase());
1033
+ }
1034
+ if (typeof item === 'object' && item !== null) {
1035
+ return Object.values(item).some((subItem) => itemHasText(subItem, text));
1036
+ }
1037
+ return false;
1038
+ };
1039
+ /**
1040
+ * Computes the amount of available pages
1041
+ */
1042
+ const getPageCount = (totalItems, itemsPerPage) => Math.ceil(totalItems / itemsPerPage);
1043
+
1044
+ const DEFAULT_PAGE_SIZE = 10;
1045
+ const TYPEAHEAD_DELAY_MS = 300;
1046
+ const ListCollection = ({ children, direction = 'column', items, ...rest }) => (React__namespace.createElement(Field.Flex, { direction: direction, ...rest }, Array.isArray(items) ? items.map(children) : null));
1047
+ const GridCollection = ({ children, items, ...rest }) => (React__namespace.createElement(Grid, { ...rest }, Array.isArray(items) ? items.map(children) : null));
1048
+ const renderCollectionOrNoResultsFound = (collection, items, searchNoResultsFound) => {
1049
+ if (items.length) {
1050
+ return collection;
1051
+ }
1052
+ if (searchNoResultsFound) {
1053
+ return searchNoResultsFound;
1054
+ }
1055
+ return (React__namespace.createElement(Field.Flex, { justifyContent: "center" },
1056
+ React__namespace.createElement(Field.Text, null, Field.ComponentText.Collection.searchNoResultsFound)));
1057
+ };
1058
+ /**
1059
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/collection)
1060
+ */
1061
+ const Collection = ({ className, isSearchable, isPaginated, items, itemsPerPage = DEFAULT_PAGE_SIZE, searchFilter = itemHasText, searchLabel = Field.ComponentText.Collection.searchButtonLabel, searchNoResultsFound, searchPlaceholder, type = 'list', testId, ...rest }) => {
1062
+ const [searchText, setSearchText] = React__namespace.useState();
1063
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1064
+ const onSearch = React__namespace.useCallback(debounce__default["default"](setSearchText, TYPEAHEAD_DELAY_MS), [setSearchText]);
1065
+ // Make sure that items are iterable
1066
+ items = Array.isArray(items) ? items : [];
1067
+ // Filter items by text
1068
+ if (isSearchable && Field.strHasLength(searchText)) {
1069
+ items = items.filter((item) => searchFilter(item, searchText));
1070
+ }
1071
+ // Pagination
1072
+ const pagination = usePagination({
1073
+ totalPages: getPageCount(items.length, itemsPerPage),
1074
+ });
1075
+ if (isPaginated) {
1076
+ items = getItemsAtPage(items, pagination.currentPage, itemsPerPage);
1077
+ }
1078
+ const collection = type === 'list' ? (React__namespace.createElement(ListCollection, { className: ui.ComponentClassName.CollectionItems, items: items, ...rest })) : type === 'grid' ? (React__namespace.createElement(GridCollection, { className: ui.ComponentClassName.CollectionItems, items: items, ...rest })) : null;
1079
+ return (React__namespace.createElement(Field.Flex, { testId: testId, className: ui.classNames(ui.ComponentClassName.Collection, className) },
1080
+ isSearchable ? (React__namespace.createElement(Field.Flex, { className: ui.ComponentClassName.CollectionSearch },
1081
+ React__namespace.createElement(SearchField, { label: searchLabel, placeholder: searchPlaceholder, onChange: (e) => onSearch(e.target.value), onClear: () => setSearchText('') }))) : null,
1082
+ renderCollectionOrNoResultsFound(collection, items, searchNoResultsFound),
1083
+ isPaginated ? (React__namespace.createElement(Field.Flex, { className: ui.ComponentClassName.CollectionPagination },
1084
+ React__namespace.createElement(Pagination, { ...pagination }))) : null));
1085
+ };
1086
+ Collection.displayName = 'Collection';
1087
+
1088
+ const DividerPrimitive = ({ className, orientation = 'horizontal', size, label, ...rest }, ref) => {
1089
+ const componentClasses = ui.classNames(ui.ComponentClassName.Divider, ui.classNameModifier(ui.ComponentClassName.Divider, orientation), ui.classNameModifier(ui.ComponentClassName.Divider, size), className);
1090
+ return (React__namespace.createElement(Field.View, { "aria-orientation": orientation, as: "hr", className: componentClasses, "data-label": label, ref: ref, ...rest }));
1091
+ };
1092
+ /**
1093
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/divider)
1094
+ */
1095
+ const Divider = Field.primitiveWithForwardRef(DividerPrimitive);
1096
+ Divider.displayName = 'Divider';
1097
+
1098
+ const DropZoneContext = React__namespace.createContext('inactive');
1099
+ const DropZoneProvider = ({ value, children, }) => {
1100
+ return (React__namespace.createElement(DropZoneContext.Provider, { value: value }, children));
1101
+ };
1102
+
1103
+ const Container = ({ className, children, testId, isDisabled, onDragEnter, onDragLeave, onDragOver, onDragStart, onDrop, ...rest }, ref) => {
1104
+ const dragState = React__default["default"].useContext(DropZoneContext);
1105
+ // Don't add drag event handlers if it is disabled.
1106
+ const dragProps = isDisabled
1107
+ ? {}
1108
+ : { onDragEnter, onDragLeave, onDragOver, onDragStart, onDrop };
1109
+ return (React__default["default"].createElement(Field.View, { ...rest, ...dragProps, isDisabled: isDisabled, className: ui.classNames(className, ui.classNameModifierByFlag(ui.ComponentClassName.DropZone, 'rejected', dragState === 'reject'), ui.classNameModifierByFlag(ui.ComponentClassName.DropZone, 'accepted', dragState === 'accept'), ui.classNameModifierByFlag(ui.ComponentClassName.DropZone, 'disabled', isDisabled), ui.ComponentClassName.DropZone), "data-testid": testId, ref: ref }, children));
1110
+ };
1111
+ const DropZoneContainer = Field.primitiveWithForwardRef(Container);
1112
+ DropZoneContainer.displayName = 'DropZoneContainer';
1113
+
1114
+ /**
1115
+ * These are syntactic sugar components that make it easy to compose children
1116
+ * in DropZone without having to expose the DropZoneContext.
1117
+ */
1118
+ /**
1119
+ * This component renders when the user is dragging ONLY accepted files on the DropZone.
1120
+ */
1121
+ const Accepted = ({ children, }) => {
1122
+ const dragState = React__namespace.useContext(DropZoneContext);
1123
+ if (!dragState) {
1124
+ throw new Error('`DropZone.Accept` must be used inside a DropZone');
1125
+ }
1126
+ return dragState === 'accept' ? React__namespace.createElement(React__namespace.Fragment, null, children) : null;
1127
+ };
1128
+ /**
1129
+ * This component renders when the user is dragging ANY rejected files on the DropZone.
1130
+ */
1131
+ const Rejected = ({ children, }) => {
1132
+ const dragState = React__namespace.useContext(DropZoneContext);
1133
+ if (!dragState) {
1134
+ throw new Error('`DropZone.Rejected` must be used inside a DropZone');
1135
+ }
1136
+ return dragState === 'reject' ? React__namespace.createElement(React__namespace.Fragment, null, children) : null;
1137
+ };
1138
+ /**
1139
+ * This component renders by default when the user is not dragging.
1140
+ */
1141
+ const Default = ({ children, }) => {
1142
+ const dragState = React__namespace.useContext(DropZoneContext);
1143
+ if (!dragState) {
1144
+ throw new Error('`DropZone.Default` must be used inside a DropZone');
1145
+ }
1146
+ return dragState === 'inactive' ? React__namespace.createElement(React__namespace.Fragment, null, children) : null;
1147
+ };
1148
+
1149
+ const DropZonePrimitive = ({ children, testId, isDisabled, acceptedFileTypes, onDropComplete, ...rest }, ref) => {
1150
+ const { dragState, onDragEnter, onDragLeave, onDragOver, onDragStart, onDrop, } = Field.useDropZone({
1151
+ acceptedFileTypes,
1152
+ onDropComplete,
1153
+ ...rest,
1154
+ });
1155
+ return (React__namespace.createElement(DropZoneProvider, { value: dragState },
1156
+ React__namespace.createElement(DropZoneContainer, { ...rest, testId: testId, isDisabled: isDisabled, onDragStart: onDragStart, onDragEnter: onDragEnter, onDragLeave: onDragLeave, onDrop: onDrop, onDragOver: onDragOver, ref: ref }, children)));
1157
+ };
1158
+ /**
1159
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/dropzone)
1160
+ */
1161
+ const DropZone = Object.assign(Field.primitiveWithForwardRef(DropZonePrimitive), {
1162
+ Accepted,
1163
+ Rejected,
1164
+ Default,
1165
+ });
1166
+ DropZone.displayName = 'DropZone';
1167
+
1168
+ const AccordionContext = React__namespace.createContext(undefined);
1169
+ const AccordionItemContext = React__namespace.createContext(undefined);
1170
+
1171
+ const AccordionItemPrimitive = ({ children, className, value, as = 'details', ...rest }, ref) => {
1172
+ const context = React__namespace.useContext(AccordionContext);
1173
+ const open = value ? context?.value?.includes(value) : undefined;
1174
+ return (React__namespace.createElement(AccordionItemContext.Provider, { value: value },
1175
+ React__namespace.createElement(Field.View, { ...rest, open: open, ref: ref, as: as, className: ui.classNames(ui.ComponentClassName.AccordionItem, className) }, children)));
1176
+ };
1177
+ /**
1178
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/accordion)
1179
+ */
1180
+ const AccordionItem = Field.primitiveWithForwardRef(AccordionItemPrimitive);
1181
+ AccordionItem.displayName = 'AccordionItem';
1182
+
1183
+ const AccordionContentPrimitive = ({ className, children, ...rest }, ref) => {
1184
+ return (React__namespace.createElement(Field.View, { ...rest, className: ui.classNames(ui.ComponentClassName.AccordionItemContent, className), ref: ref }, children));
1185
+ };
1186
+ /**
1187
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/accordion)
1188
+ */
1189
+ const AccordionContent = Field.primitiveWithForwardRef(AccordionContentPrimitive);
1190
+ AccordionContent.displayName = 'Accordion.Content';
1191
+
1192
+ const AccordionTriggerPrimitive = ({ children, className, ...rest }, ref) => {
1193
+ const context = React__namespace.useContext(AccordionContext);
1194
+ const value = React__namespace.useContext(AccordionItemContext);
1195
+ const handleOnClick = (e) => {
1196
+ if (ui.isTypedFunction(rest.onClick)) {
1197
+ rest.onClick(e);
1198
+ }
1199
+ if (context?.setValue && value) {
1200
+ e.preventDefault();
1201
+ context.setValue(value);
1202
+ }
1203
+ };
1204
+ return (React__namespace.createElement(Field.View, { ...rest, ref: ref, as: "summary", className: ui.classNames(ui.ComponentClassName.AccordionItemTrigger, className), onClick: handleOnClick }, children));
1205
+ };
1206
+ /**
1207
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/accordion)
1208
+ */
1209
+ const AccordionTrigger = Field.primitiveWithForwardRef(AccordionTriggerPrimitive);
1210
+ AccordionTrigger.displayName = 'Accordion.Trigger';
1211
+
1212
+ const AccordionIconPrimitive = ({ className, as = 'span', ...rest }, ref) => {
1213
+ const icons = Field.useIcons('accordion');
1214
+ return (React__namespace.createElement(Field.View, { ...rest, ref: ref, as: as, className: ui.classNames(ui.ComponentClassName.AccordionItemIcon, className), "aria-hidden": "true" }, icons?.more ?? React__namespace.createElement(Field.IconExpandMore, null)));
1215
+ };
1216
+ /**
1217
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/accordion)
1218
+ */
1219
+ const AccordionIcon = Field.primitiveWithForwardRef(AccordionIconPrimitive);
1220
+ AccordionIcon.displayName = 'Accordion.Icon';
1221
+
1222
+ const AccordionContainerPrimitive = ({ children, className, defaultValue, allowMultiple, preventCollapse, onValueChange, testId, value: controlledValue, ...rest }, ref) => {
1223
+ const isControlled = controlledValue !== undefined;
1224
+ const [localValue, setLocalValue] = React__namespace.useState(() => isControlled ? controlledValue : defaultValue ?? []);
1225
+ const value = isControlled ? controlledValue : localValue;
1226
+ const setValue = React__namespace.useCallback((_value) => {
1227
+ let newValue;
1228
+ // if the value has the incoming value we try to close it by removing it from the array
1229
+ if (value.includes(_value)) {
1230
+ // only remove it from the array if preventCollapse is false/undefined OR
1231
+ // the number of open accordions is more than 1 (so it won't fully collapse anyways)
1232
+ newValue =
1233
+ !preventCollapse || value.length > 1
1234
+ ? value.filter((v) => v !== _value)
1235
+ : value;
1236
+ }
1237
+ else {
1238
+ // open the item by adding it to the array if allowMultiple is true
1239
+ // or make it the whole array
1240
+ newValue = allowMultiple ? [...value, _value] : [_value];
1241
+ }
1242
+ if (ui.isFunction(onValueChange)) {
1243
+ onValueChange(newValue);
1244
+ }
1245
+ if (!isControlled) {
1246
+ setLocalValue(newValue);
1247
+ }
1248
+ }, [onValueChange, value, isControlled, allowMultiple, preventCollapse]);
1249
+ const contextValue = React__namespace.useMemo(() => {
1250
+ return {
1251
+ value,
1252
+ setValue,
1253
+ };
1254
+ }, [value, setValue]);
1255
+ return (React__namespace.createElement(AccordionContext.Provider, { value: contextValue },
1256
+ React__namespace.createElement(Field.View, { ...rest, className: ui.classNames(ui.ComponentClassName.Accordion, className), "data-testid": testId, ref: ref }, children)));
1257
+ };
1258
+ /**
1259
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/accordion)
1260
+ */
1261
+ const AccordionContainer = Field.primitiveWithForwardRef(AccordionContainerPrimitive);
1262
+ AccordionContainer.displayName = 'Accordion.Container';
1263
+
1264
+ const AccordionPrimitive = ({ items, ...rest }, ref) => {
1265
+ return (React__namespace.createElement(AccordionContainer, { ref: ref, ...rest }, items?.map(({ content, trigger, value }) => (React__namespace.createElement(AccordionItem, { key: value, value: value },
1266
+ React__namespace.createElement(AccordionTrigger, null,
1267
+ trigger,
1268
+ React__namespace.createElement(AccordionIcon, null)),
1269
+ React__namespace.createElement(AccordionContent, null, content))))));
1270
+ };
1271
+ /**
1272
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/accordion)
1273
+ */
1274
+ const Accordion = Object.assign(Field.primitiveWithForwardRef(AccordionPrimitive), {
1275
+ Container: AccordionContainer,
1276
+ Content: AccordionContent,
1277
+ Icon: AccordionIcon,
1278
+ Item: AccordionItem,
1279
+ Trigger: AccordionTrigger,
1280
+ });
1281
+ Accordion.displayName = 'Accordion';
1282
+
1283
+ const FieldsetPrimitive = ({ children, className, isDisabled, legend, legendHidden, size, testId, variation = 'plain', ...rest }, ref) => {
1284
+ const { isFieldsetDisabled } = Field.useFieldset();
1285
+ // Fieldsets that are nested within a disabled Fieldset should
1286
+ // also be disabled.
1287
+ const shouldBeDisabled = isFieldsetDisabled ? isFieldsetDisabled : isDisabled;
1288
+ const value = React__namespace.useMemo(() => ({
1289
+ isFieldsetDisabled: shouldBeDisabled,
1290
+ }), [shouldBeDisabled]);
1291
+ const fieldsetClasses = ui.classNames(ui.ComponentClassName.Fieldset, ui.classNameModifier(ui.ComponentClassName.Fieldset, variation), ui.classNameModifier(ui.ComponentClassName.Fieldset, size), className);
1292
+ const legendClasses = ui.classNames(ui.ComponentClassName.FieldsetLegend, ui.classNameModifier(ui.ComponentClassName.FieldsetLegend, size), {
1293
+ [ui.ComponentClassName.VisuallyHidden]: legendHidden,
1294
+ });
1295
+ return (React__namespace.createElement(Field.FieldsetContext.Provider, { value: value },
1296
+ React__namespace.createElement(Field.Flex, { as: "fieldset", className: fieldsetClasses, ref: ref, disabled: shouldBeDisabled, testId: testId, ...rest },
1297
+ React__namespace.createElement(VisuallyHidden, { as: "legend" }, legend),
1298
+ React__namespace.createElement(Field.View, { as: "div", "aria-hidden": "true", className: legendClasses }, legend),
1299
+ children)));
1300
+ };
1301
+ /**
1302
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/fieldset)
1303
+ */
1304
+ const Fieldset = Field.primitiveWithForwardRef(FieldsetPrimitive);
1305
+ Fieldset.displayName = 'Fieldset';
1306
+
1307
+ const headingLevels = {
1308
+ 1: 'h1',
1309
+ 2: 'h2',
1310
+ 3: 'h3',
1311
+ 4: 'h4',
1312
+ 5: 'h5',
1313
+ 6: 'h6',
1314
+ };
1315
+ const HeadingPrimitive = ({ className, children, isTruncated, level = 6, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: headingLevels[level], className: ui.classNames(ui.ComponentClassName.Heading, ui.classNameModifier(ui.ComponentClassName.Heading, level), ui.classNameModifierByFlag(ui.ComponentClassName.Heading, 'truncated', isTruncated), className), ref: ref, ...rest }, children));
1316
+ /**
1317
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/heading)
1318
+ */
1319
+ const Heading = Field.primitiveWithForwardRef(HeadingPrimitive);
1320
+ Heading.displayName = 'Heading';
1321
+
1322
+ const ImagePrimitive = ({ className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: "img", ref: ref, className: ui.classNames(ui.ComponentClassName.Image, className), ...rest }));
1323
+ /**
1324
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/image)
1325
+ */
1326
+ const Image = Field.primitiveWithForwardRef(ImagePrimitive);
1327
+ Image.displayName = 'Image';
1328
+
1329
+ /**
1330
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/menu)
1331
+ */
1332
+ const MenuButtonPrimitive = ({ ariaLabel, className, children, isDisabled, isLoading, size, style, type = 'button', variation, testId, ...rest }, ref) => {
1333
+ const { propStyles, nonStyleProps } = Field.useStyles(rest, style);
1334
+ const componentClasses = ui.classNames(ui.ComponentClassName.Button, ui.classNameModifier(ui.ComponentClassName.Button, size), ui.classNameModifier(ui.ComponentClassName.Button, variation), className);
1335
+ return (React__namespace.createElement(Field.Button, { ref: ref, className: componentClasses, disabled: isDisabled ?? isLoading, type: type, testId: testId, "aria-label": ariaLabel, style: propStyles, ...nonStyleProps }, children));
1336
+ };
1337
+ const MenuButton = Field.primitiveWithForwardRef(MenuButtonPrimitive);
1338
+ MenuButton.displayName = 'MenuButton';
1339
+
1340
+ // Radix packages don't support ESM in Node, in some scenarios(e.g. SSR)
1341
+ // We have to use namespace import and sanitize it to ensure the interoperablity between ESM and CJS
1342
+ const { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } = ui.sanitizeNamespaceImport(Dropdown__namespace);
1343
+ const MENU_TRIGGER_TEST_ID = 'amplify-menu-trigger-test-id';
1344
+ const MENU_ITEMS_GROUP_TEST_ID = 'amplify-menu-items-group-test-id';
1345
+ const MenuPrimitive = ({ menuAlign = 'start', children, className, isOpen, size, trigger, triggerClassName, ariaLabel, onOpenChange, ...rest }, ref) => {
1346
+ const icons = Field.useIcons('menu');
1347
+ return (React__namespace.createElement(DropdownMenu, { onOpenChange: onOpenChange, open: isOpen },
1348
+ React__namespace.createElement(DropdownMenuTrigger, { asChild: true }, trigger ?? (React__namespace.createElement(MenuButton, { ariaLabel: ariaLabel, size: size, testId: MENU_TRIGGER_TEST_ID, className: ui.classNames(ui.ComponentClassName.MenuTrigger, triggerClassName) }, icons?.menu ?? React__namespace.createElement(Field.IconMenu, null)))),
1349
+ React__namespace.createElement(DropdownMenuContent, { align: menuAlign, className: ui.ComponentClassName.MenuWrapper },
1350
+ React__namespace.createElement(ButtonGroup, { className: ui.classNames(ui.ComponentClassName.MenuContent, className), ref: ref, size: size, testId: MENU_ITEMS_GROUP_TEST_ID, ...rest }, children))));
1351
+ };
1352
+ /**
1353
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/menu)
1354
+ */
1355
+ const Menu = Field.primitiveWithForwardRef(MenuPrimitive);
1356
+ Menu.displayName = 'Menu';
1357
+
1358
+ // Radix packages don't support ESM in Node, in some scenarios(e.g. SSR)
1359
+ // We have to use namespace import and sanitize it to ensure the interoperablity between ESM and CJS
1360
+ const { DropdownMenuItem } = ui.sanitizeNamespaceImport(Dropdown__namespace);
1361
+ const MENU_ITEM_TEST_ID = 'amplify-menu-item-test-id';
1362
+ /**
1363
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/menu)
1364
+ */
1365
+ const MenuItemPrimitive = ({ children, className, ...rest }, ref) => {
1366
+ return (React__namespace.createElement(DropdownMenuItem, { asChild: true, ref: ref },
1367
+ React__namespace.createElement(MenuButton, { className: ui.classNames(ui.ComponentClassName.MenuItem, className), testId: MENU_ITEM_TEST_ID, ...rest, variation: "menu" // ensures `menu` variation is not overwritten
1368
+ }, children)));
1369
+ };
1370
+ const MenuItem = Field.primitiveWithForwardRef(MenuItemPrimitive);
1371
+ MenuItem.displayName = 'MenuItem';
1372
+
1373
+ const MessageHeadingPrimitive = ({ children, className, ...rest }, ref) => {
1374
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.MessageHeading, className), ref: ref, ...rest }, children));
1375
+ };
1376
+ const MessageHeading = Field.primitiveWithForwardRef(MessageHeadingPrimitive);
1377
+ MessageHeading.displayName = 'MessageHeading';
1378
+
1379
+ const MessageContext = React__namespace.createContext({
1380
+ dismissed: false,
1381
+ setDismissed: () => { },
1382
+ });
1383
+ const useMessage = () => React__namespace.useContext(MessageContext);
1384
+
1385
+ const MessageIconPrimitive = ({ className, ...rest }, ref) => {
1386
+ const icons = Field.useIcons('message');
1387
+ const { colorTheme } = useMessage();
1388
+ let icon;
1389
+ switch (colorTheme) {
1390
+ case 'info':
1391
+ icon = icons?.info ?? React__namespace.createElement(Field.IconInfo, null);
1392
+ break;
1393
+ case 'error':
1394
+ icon = icons?.error ?? React__namespace.createElement(Field.IconError, null);
1395
+ break;
1396
+ case 'warning':
1397
+ icon = icons?.warning ?? React__namespace.createElement(Field.IconWarning, null);
1398
+ break;
1399
+ case 'success':
1400
+ icon = icons?.success ?? React__namespace.createElement(Field.IconCheckCircle, null);
1401
+ break;
1402
+ }
1403
+ return icon ? (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.MessageIcon, className), "aria-hidden": "true", ref: ref, ...rest }, icon)) : null;
1404
+ };
1405
+ const MessageIcon = Field.primitiveWithForwardRef(MessageIconPrimitive);
1406
+ MessageIcon.displayName = 'MessageIcon';
1407
+
1408
+ const MessageDismissPrimitive = ({ onDismiss, dismissLabel, hasIcon = true, children, className, ...rest }, ref) => {
1409
+ const { setDismissed } = useMessage();
1410
+ const icons = Field.useIcons('message');
1411
+ const dismissMessage = React__namespace.useCallback(() => {
1412
+ setDismissed(true);
1413
+ if (ui.isFunction(onDismiss)) {
1414
+ onDismiss();
1415
+ }
1416
+ }, [setDismissed, onDismiss]);
1417
+ return (React__namespace.createElement(Field.Button, { variation: "link", colorTheme: "overlay", className: ui.classNames(ui.ComponentClassName.MessageDismiss, className), ref: ref, onClick: dismissMessage, ...rest },
1418
+ hasIcon ? icons?.close ?? React__namespace.createElement(Field.IconClose, { "aria-hidden": "true" }) : null,
1419
+ children ? (children) : (React__namespace.createElement(VisuallyHidden, null, dismissLabel ? dismissLabel : Field.ComponentText.Message.dismissLabel))));
1420
+ };
1421
+ const MessageDismiss = Field.primitiveWithForwardRef(MessageDismissPrimitive);
1422
+ MessageDismiss.displayName = 'MessageContent';
1423
+
1424
+ const MessageContentPrimitive = ({ children, className, ...rest }, ref) => {
1425
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.MessageContent, className), ref: ref, ...rest }, children));
1426
+ };
1427
+ const MessageContent = Field.primitiveWithForwardRef(MessageContentPrimitive);
1428
+ MessageContent.displayName = 'MessageContent';
1429
+
1430
+ const MessageContainerPrimitive = ({ children, className, colorTheme = 'neutral', variation = 'filled', ...rest }, ref) => {
1431
+ const [dismissed, setDismissed] = React__namespace.useState(false);
1432
+ const value = React__namespace.useMemo(() => ({
1433
+ colorTheme,
1434
+ dismissed,
1435
+ setDismissed,
1436
+ }), [colorTheme, dismissed]);
1437
+ return (React__namespace.createElement(MessageContext.Provider, { value: value }, !dismissed ? (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Message, ui.classNameModifier(ui.ComponentClassName.Message, variation), ui.classNameModifier(ui.ComponentClassName.Message, colorTheme), className), ref: ref, ...rest }, children)) : null));
1438
+ };
1439
+ const MessageContainer = Field.primitiveWithForwardRef(MessageContainerPrimitive);
1440
+ MessageContainer.displayName = 'MessageContainer';
1441
+
1442
+ const MessagePrimitive = ({ children, heading, dismissLabel, isDismissible, onDismiss, hasIcon = true, colorTheme = 'neutral', variation = 'filled', ...rest }, ref) => {
1443
+ return (React__namespace.createElement(MessageContainer, { colorTheme: colorTheme, variation: variation, ref: ref, ...rest },
1444
+ hasIcon ? React__namespace.createElement(MessageIcon, null) : null,
1445
+ React__namespace.createElement(MessageContent, null,
1446
+ heading ? React__namespace.createElement(MessageHeading, null, heading) : null,
1447
+ children),
1448
+ isDismissible ? (React__namespace.createElement(MessageDismiss, { onDismiss: onDismiss, dismissLabel: dismissLabel })) : null));
1449
+ };
1450
+ /**
1451
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/message)
1452
+ */
1453
+ const Message = Field.primitiveWithForwardRef(MessagePrimitive);
1454
+ Message.displayName = 'Message';
1455
+
1456
+ const { passwordIsHidden, passwordIsShown, showPassword } = Field.ComponentText.PasswordField;
1457
+ const ShowPasswordButtonPrimitive = ({ fieldType, passwordIsHiddenLabel = passwordIsHidden, passwordIsShownLabel = passwordIsShown, showPasswordButtonLabel = showPassword, size, hasError, ...rest }, ref) => {
1458
+ const icons = Field.useIcons('passwordField');
1459
+ const showPasswordButtonClass = ui.classNames(ui.ComponentClassName.FieldShowPassword, ui.classNameModifierByFlag(ui.ComponentClassName.FieldShowPassword, 'error', hasError));
1460
+ const icon = fieldType === 'password'
1461
+ ? icons?.visibility ?? React__namespace.createElement(Field.IconVisibility, { "aria-hidden": "true" })
1462
+ : icons?.visibilityOff ?? React__namespace.createElement(Field.IconVisibilityOff, { "aria-hidden": "true" });
1463
+ return (React__namespace.createElement(Field.Button, { "aria-checked": fieldType !== 'password', ariaLabel: showPasswordButtonLabel, className: showPasswordButtonClass, ref: ref, role: "switch", size: size, ...rest },
1464
+ React__namespace.createElement(VisuallyHidden, { "aria-live": "polite" }, fieldType === 'password'
1465
+ ? passwordIsHiddenLabel
1466
+ : passwordIsShownLabel),
1467
+ icon));
1468
+ };
1469
+ const ShowPasswordButton = Field.primitiveWithForwardRef(ShowPasswordButtonPrimitive);
1470
+ ShowPasswordButton.displayName = 'ShowPasswordButton';
1471
+
1472
+ const PasswordFieldPrimitive = ({ autoComplete = 'current-password', label, className, hideShowPassword = false, passwordIsHiddenLabel, passwordIsShownLabel, showPasswordButtonLabel, showPasswordButtonRef, size, hasError, ...rest }, ref) => {
1473
+ const [type, setType] = React__namespace.useState('password');
1474
+ const showPasswordOnClick = React__namespace.useCallback(() => {
1475
+ if (type === 'password') {
1476
+ setType('text');
1477
+ }
1478
+ else {
1479
+ setType('password');
1480
+ }
1481
+ }, [setType, type]);
1482
+ return (React__namespace.createElement(TextField, { autoComplete: autoComplete, outerEndComponent: hideShowPassword ? null : (React__namespace.createElement(ShowPasswordButton, { fieldType: type, onClick: showPasswordOnClick, passwordIsHiddenLabel: passwordIsHiddenLabel, passwordIsShownLabel: passwordIsShownLabel, ref: showPasswordButtonRef, size: size, showPasswordButtonLabel: showPasswordButtonLabel, hasError: hasError })), size: size, type: type, label: label, className: ui.classNames(ui.ComponentClassName.PasswordField, className), ref: ref, hasError: hasError, ...rest }));
1483
+ };
1484
+ /**
1485
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/passwordfield)
1486
+ */
1487
+ const PasswordField = Field.primitiveWithForwardRef(PasswordFieldPrimitive);
1488
+ PasswordField.displayName = 'PasswordField';
1489
+
1490
+ const SelectPrimitive = ({ autoComplete, className, size, variation, value, defaultValue, hasError, icon, iconColor, children, placeholder, isDisabled, isRequired, isMultiple = false, selectSize = 1, ...rest }, ref) => {
1491
+ const DEFAULT_PLACEHOLDER_VALUE = '';
1492
+ // value === undefined is to make sure that component is used in uncontrolled way so that setting defaultValue is valid
1493
+ const shouldSetDefaultPlaceholderValue = value === undefined && defaultValue === undefined && placeholder;
1494
+ const isExpanded = isMultiple || selectSize > 1;
1495
+ const componentClasses = ui.classNames(ui.ComponentClassName.Select, ui.ComponentClassName.FieldGroupControl, ui.classNameModifier(ui.ComponentClassName.Select, size), ui.classNameModifier(ui.ComponentClassName.Select, variation), ui.classNameModifierByFlag(ui.ComponentClassName.Select, 'error', hasError), ui.classNameModifierByFlag(ui.ComponentClassName.Select, 'expanded', isExpanded), className);
1496
+ const icons = Field.useIcons('select');
1497
+ const { isFieldsetDisabled } = Field.useFieldset();
1498
+ return (React__namespace.createElement(Field.View, { className: ui.ComponentClassName.SelectWrapper },
1499
+ React__namespace.createElement(Field.View, { "aria-invalid": hasError, as: "select", autoComplete: autoComplete, value: value, defaultValue: shouldSetDefaultPlaceholderValue
1500
+ ? DEFAULT_PLACEHOLDER_VALUE
1501
+ : defaultValue, isDisabled: isFieldsetDisabled ? isFieldsetDisabled : isDisabled, multiple: isMultiple, size: selectSize, required: isRequired, className: componentClasses, ref: ref, ...rest },
1502
+ placeholder && React__namespace.createElement("option", { value: "" }, placeholder),
1503
+ children),
1504
+ isExpanded ? null : (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.SelectIcon, ui.classNameModifier(ui.ComponentClassName.SelectIcon, size)), color: iconColor }, icon ?? icons?.expand ?? React__namespace.createElement(Field.IconExpandMore, null)))));
1505
+ };
1506
+ const Select = Field.primitiveWithForwardRef(SelectPrimitive);
1507
+ Select.displayName = 'Select';
1508
+
1509
+ const selectFieldChildren = ({ children, options, }) => {
1510
+ if (children) {
1511
+ if (options?.length) {
1512
+ // eslint-disable-next-line no-console
1513
+ console.warn('Amplify UI: <SelectField> component defaults to rendering children over `options`. When using the `options` prop, omit children.');
1514
+ }
1515
+ return children;
1516
+ }
1517
+ return options?.map((option, index) => (React__namespace.createElement("option", { label: option, value: option, key: `${option}-${index}` }, option)));
1518
+ };
1519
+ const SelectFieldPrimitive = (props, ref) => {
1520
+ const { children, className, descriptiveText, errorMessage, hasError = false, id, label, labelHidden = false, options, size, testId, inputStyles, ..._rest } = props;
1521
+ const fieldId = useStableId(id);
1522
+ const descriptionId = useStableId();
1523
+ const ariaDescribedBy = descriptiveText ? descriptionId : undefined;
1524
+ const { styleProps, rest } = splitPrimitiveProps(_rest);
1525
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), ui.ComponentClassName.SelectField, className), testId: testId, ...styleProps },
1526
+ React__namespace.createElement(Field.Label, { htmlFor: fieldId, visuallyHidden: labelHidden }, label),
1527
+ React__namespace.createElement(Field.FieldDescription, { id: descriptionId, labelHidden: labelHidden, descriptiveText: descriptiveText }),
1528
+ React__namespace.createElement(Select, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, size: size, ...rest, ...inputStyles }, selectFieldChildren({ children, options })),
1529
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
1530
+ };
1531
+ /**
1532
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/selectfield)
1533
+ */
1534
+ const SelectField = Field.primitiveWithForwardRef(SelectFieldPrimitive);
1535
+ SelectField.displayName = 'SelectField';
1536
+
1537
+ const DialCodeSelectPrimitive = ({ className, dialCodeList, isReadOnly, ...props }, ref) => {
1538
+ const dialList = dialCodeList ?? ui.countryDialCodes;
1539
+ const dialCodeOptions = React__namespace.useMemo(() => dialList.map((dialCode) => (
1540
+ // Regarding the `disabled` attribute, see comment in SelectField below
1541
+ React__namespace.createElement("option", { key: dialCode, value: dialCode, disabled: isReadOnly }, dialCode))), [dialList, isReadOnly]);
1542
+ return (React__namespace.createElement(SelectField
1543
+ /*
1544
+ Since <select> elements do not support the `readonly` html attribute, it is suggested to use the `disabled` html attribute
1545
+ so that a screen reader will announce something to the user about the interactivity of the options list ( https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)
1546
+ */
1547
+ , { "aria-disabled": isReadOnly, autoComplete: "tel-country-code", className: ui.classNames(ui.ComponentClassName.CountryCodeSelect, ui.ComponentClassName.DialCodeSelect, className), labelHidden: true, ref: ref, ...props }, dialCodeOptions));
1548
+ };
1549
+ const DialCodeSelect = Field.primitiveWithForwardRef(DialCodeSelectPrimitive);
1550
+ DialCodeSelect.displayName = 'DialCodeSelect';
1551
+
1552
+ const PhoneNumberFieldPrimitive = ({ autoComplete = 'tel-national', className, defaultDialCode, dialCodeLabel = Field.ComponentText.PhoneNumberField.countryCodeLabel, dialCodeList, dialCodeName, dialCodeRef, hasError, isDisabled, isReadOnly, onDialCodeChange, onInput, size, variation, ...rest }, ref) => {
1553
+ return (React__namespace.createElement(TextField, { outerStartComponent: React__namespace.createElement(DialCodeSelect, { defaultValue: defaultDialCode, dialCodeList: dialCodeList, className: className, hasError: hasError, isDisabled: isDisabled, isReadOnly: isReadOnly, label: dialCodeLabel, name: dialCodeName, onChange: onDialCodeChange, ref: dialCodeRef, size: size, variation: variation }), autoComplete: autoComplete, className: ui.classNames(ui.ComponentClassName.PhoneNumberField, className), hasError: hasError, isDisabled: isDisabled, isReadOnly: isReadOnly, onInput: onInput, ref: ref, size: size, type: "tel", variation: variation, ...rest }));
1554
+ };
1555
+ /**
1556
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/phonenumberfield)
1557
+ */
1558
+ const PhoneNumberField = Field.primitiveWithForwardRef(PhoneNumberFieldPrimitive);
1559
+ PhoneNumberField.displayName = 'PhoneNumberField';
1560
+
1561
+ const PlaceholderPrimitive = ({ className, children, isLoaded, size, ...rest }, ref) => {
1562
+ if (isLoaded) {
1563
+ return React__namespace.createElement(React__namespace.Fragment, null, children);
1564
+ }
1565
+ return (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.Placeholder, ui.classNameModifier(ui.ComponentClassName.Placeholder, size), className), ref: ref, ...rest }));
1566
+ };
1567
+ /**
1568
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/placeholder)
1569
+ */
1570
+ const Placeholder = Field.primitiveWithForwardRef(PlaceholderPrimitive);
1571
+ Placeholder.displayName = 'Placeholder';
1572
+
1573
+ const defaultValue = { name: 'default' };
1574
+ const RadioGroupContext = React__default["default"].createContext(defaultValue);
1575
+ const useRadioGroupContext = () => {
1576
+ return React.useContext(RadioGroupContext);
1577
+ };
1578
+
1579
+ const RadioPrimitive = ({ children, className, id, isDisabled = false, testId, value, labelPosition: radioLabelPosition, ...rest }, ref) => {
1580
+ const { currentValue, defaultValue, name, hasError, isGroupDisabled = false, isRequired, isReadOnly, onChange, size, labelPosition: groupLabelPosition, } = useRadioGroupContext();
1581
+ const { isFieldsetDisabled } = Field.useFieldset();
1582
+ const shouldBeDisabled = isFieldsetDisabled
1583
+ ? isFieldsetDisabled
1584
+ : isGroupDisabled || isDisabled || (isReadOnly && defaultValue !== value);
1585
+ // for controlled component
1586
+ const checked = currentValue !== undefined ? value === currentValue : undefined;
1587
+ // for uncontrolled component
1588
+ const defaultChecked = defaultValue !== undefined ? value === defaultValue : undefined;
1589
+ const labelPosition = radioLabelPosition
1590
+ ? radioLabelPosition
1591
+ : groupLabelPosition;
1592
+ return (React__namespace.createElement(Field.Flex, { as: "label", className: ui.classNames(ui.ComponentClassName.Radio, ui.classNameModifierByFlag(ui.ComponentClassName.Radio, `disabled`, shouldBeDisabled), labelPosition ? `amplify-label-${labelPosition}` : null, className) },
1593
+ children && (React__namespace.createElement(Field.Text, { as: "span", className: ui.classNames(ui.ComponentClassName.RadioLabel, ui.classNameModifierByFlag(ui.ComponentClassName.RadioLabel, `disabled`, shouldBeDisabled)) }, children)),
1594
+ React__namespace.createElement(Input, { checked: checked, className: ui.classNames(ui.ComponentClassName.VisuallyHidden, ui.ComponentClassName.RadioInput), defaultChecked: defaultChecked, hasError: hasError, id: id, isDisabled: shouldBeDisabled, isReadOnly: isReadOnly, isRequired: isRequired, onChange: onChange, ref: ref, type: "radio", name: name, value: value, ...rest }),
1595
+ React__namespace.createElement(Field.Flex, { "aria-hidden": "true", as: "span", className: ui.classNames(ui.ComponentClassName.RadioButton, ui.classNameModifier(ui.ComponentClassName.RadioButton, size)), testId: testId })));
1596
+ };
1597
+ const Radio = Field.primitiveWithForwardRef(RadioPrimitive);
1598
+ Radio.displayName = 'Radio';
1599
+
1600
+ const RadioGroupFieldPrimitive = ({ children, className, defaultValue, descriptiveText, errorMessage, hasError = false, id, isDisabled, isRequired, isReadOnly, legend, legendHidden = false, labelPosition, onChange, name, size, testId, value, variation, ...rest }, ref) => {
1601
+ const fieldId = useStableId(id);
1602
+ const descriptionId = useStableId();
1603
+ const ariaDescribedBy = descriptiveText ? descriptionId : undefined;
1604
+ const radioGroupTestId = getTestId(testId, ui.ComponentClassName.RadioGroup);
1605
+ const radioGroupContextValue = React__namespace.useMemo(() => ({
1606
+ currentValue: value,
1607
+ defaultValue,
1608
+ hasError,
1609
+ isRequired,
1610
+ isReadOnly,
1611
+ isGroupDisabled: isDisabled,
1612
+ onChange,
1613
+ size,
1614
+ name,
1615
+ labelPosition,
1616
+ }), [
1617
+ defaultValue,
1618
+ hasError,
1619
+ isDisabled,
1620
+ isRequired,
1621
+ isReadOnly,
1622
+ onChange,
1623
+ size,
1624
+ name,
1625
+ value,
1626
+ labelPosition,
1627
+ ]);
1628
+ return (React__namespace.createElement(Fieldset, { className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), ui.ComponentClassName.RadioGroupField, className), isDisabled: isDisabled, legend: legend, legendHidden: legendHidden, ref: ref, role: "radiogroup", size: size, testId: testId, variation: variation, ...rest },
1629
+ React__namespace.createElement(Field.FieldDescription, { id: descriptionId, labelHidden: legendHidden, descriptiveText: descriptiveText }),
1630
+ React__namespace.createElement(Field.Flex, { "aria-describedby": ariaDescribedBy, className: ui.ComponentClassName.RadioGroup, id: fieldId, testId: radioGroupTestId },
1631
+ React__namespace.createElement(RadioGroupContext.Provider, { value: radioGroupContextValue }, children)),
1632
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
1633
+ };
1634
+ /**
1635
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/radiogroupfield)
1636
+ */
1637
+ const RadioGroupField = Field.primitiveWithForwardRef(RadioGroupFieldPrimitive);
1638
+ RadioGroupField.displayName = 'RadioGroupField';
1639
+
1640
+ const isIconFilled = (currentIconIndex, ratingValue) => {
1641
+ if (currentIconIndex <= ratingValue)
1642
+ return true;
1643
+ return false;
1644
+ };
1645
+ const isIconEmpty = (currentIconIndex, ratingValue) => {
1646
+ if (currentIconIndex - 1 >= ratingValue)
1647
+ return true;
1648
+ return false;
1649
+ };
1650
+ const isIconMixed = (currentIconIndex, ratingValue) => {
1651
+ if (currentIconIndex > ratingValue && currentIconIndex - 1 < ratingValue) {
1652
+ return true;
1653
+ }
1654
+ return false;
1655
+ };
1656
+
1657
+ const RatingIcon = ({ icon, fill, className, }) => {
1658
+ return (React__namespace.createElement(Field.View, { as: "span", className: ui.ComponentClassName.RatingItem, "aria-hidden": "true" },
1659
+ React__namespace.createElement(Field.View, { as: "span", className: ui.classNames(className), color: fill }, icon)));
1660
+ };
1661
+ RatingIcon.displayName = 'RatingIcon';
1662
+
1663
+ const RatingMixedIcon = ({ emptyColor, emptyIcon, fillColor, fillIcon, value, }) => {
1664
+ const widthPercentage = `${(value % 1) * 100}%`;
1665
+ return (React__namespace.createElement(Field.View, { as: "span", className: ui.ComponentClassName.RatingItem, "aria-hidden": "true" },
1666
+ React__namespace.createElement(Field.View, { as: "span", className: ui.classNames(ui.ComponentClassName.RatingIcon, ui.classNameModifier(ui.ComponentClassName.RatingIcon, 'empty')), color: emptyColor }, emptyIcon),
1667
+ React__namespace.createElement(Field.View, { as: "span", className: ui.classNames(ui.ComponentClassName.RatingIcon, ui.classNameModifier(ui.ComponentClassName.RatingIcon, 'filled')), width: widthPercentage, color: fillColor }, fillIcon)));
1668
+ };
1669
+ RatingMixedIcon.displayName = 'RatingMixedIcon';
1670
+
1671
+ const RATING_DEFAULT_MAX_VALUE = 5;
1672
+ const RATING_DEFAULT_VALUE = 0;
1673
+ const RatingPrimitive = ({ className, emptyColor, emptyIcon, fillColor, icon, maxValue = RATING_DEFAULT_MAX_VALUE, size, value = RATING_DEFAULT_VALUE, ...rest }, ref) => {
1674
+ const icons = Field.useIcons('rating');
1675
+ const filledIcon = icon ?? icons?.filled ?? React__namespace.createElement(Field.IconStar, null);
1676
+ const _emptyIcon = emptyIcon ?? icon ?? icons?.empty ?? React__namespace.createElement(Field.IconStar, null);
1677
+ const items = new Array(Math.ceil(maxValue)).fill(1).map((_, index) => {
1678
+ const currentIconIndex = index + 1;
1679
+ if (isIconFilled(currentIconIndex, value))
1680
+ return (React__namespace.createElement(RatingIcon, { key: index.toString(), icon: filledIcon, fill: fillColor, className: ui.classNameModifier(ui.ComponentClassName.RatingIcon, 'filled') }));
1681
+ if (isIconEmpty(currentIconIndex, value))
1682
+ return (React__namespace.createElement(RatingIcon, { key: index.toString(), icon: _emptyIcon, fill: emptyColor, className: ui.classNameModifier(ui.ComponentClassName.RatingIcon, 'empty') }));
1683
+ if (isIconMixed(currentIconIndex, value))
1684
+ return (React__namespace.createElement(RatingMixedIcon, { key: index.toString(), fillIcon: filledIcon, emptyIcon: _emptyIcon, value: value, fillColor: fillColor, emptyColor: emptyColor }));
1685
+ });
1686
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Rating, ui.classNameModifier(ui.ComponentClassName.Rating, size), className), ref: ref, ...rest },
1687
+ items,
1688
+ React__namespace.createElement(VisuallyHidden, null,
1689
+ value,
1690
+ " out of ",
1691
+ maxValue,
1692
+ " rating")));
1693
+ };
1694
+ /**
1695
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/rating)
1696
+ */
1697
+ const Rating = Field.primitiveWithForwardRef(RatingPrimitive);
1698
+ Rating.displayName = 'Rating';
1699
+
1700
+ // Radix packages don't support ESM in Node, in some scenarios(e.g. SSR)
1701
+ // We have to use namespace import and sanitize it to ensure the interoperablity between ESM and CJS
1702
+ const { Range, Root, Thumb, Track } = ui.sanitizeNamespaceImport(RadixSlider__namespace);
1703
+ const SLIDER_LABEL_TEST_ID = 'slider-label';
1704
+ const SLIDER_ROOT_TEST_ID = 'slider-root';
1705
+ const SLIDER_TRACK_TEST_ID = 'slider-track';
1706
+ const SLIDER_RANGE_TEST_ID = 'slider-range';
1707
+ const SliderFieldPrimitive = ({ ariaValuetext, className, defaultValue = 0, descriptiveText, emptyTrackColor, errorMessage, filledTrackColor, formatValue, hasError = false, id, isDisabled, isValueHidden = false, label, labelHidden = false, onChange, orientation = 'horizontal', outerEndComponent, outerStartComponent, testId, thumbColor, trackSize, value, size, ..._rest }, ref) => {
1708
+ const { isFieldsetDisabled } = Field.useFieldset();
1709
+ const fieldId = useStableId(id);
1710
+ const labelId = useStableId();
1711
+ const descriptionId = useStableId();
1712
+ const ariaDescribedBy = descriptiveText ? descriptionId : undefined;
1713
+ const disabled = isFieldsetDisabled ? isFieldsetDisabled : isDisabled;
1714
+ const { styleProps, rest } = splitPrimitiveProps(_rest);
1715
+ const isControlled = value !== undefined;
1716
+ const [currentValue, setCurrentValue] = React__namespace.useState(isControlled ? value : defaultValue);
1717
+ const values = isControlled ? [value] : undefined;
1718
+ const defaultValues = !isControlled ? [defaultValue] : undefined;
1719
+ const onValueChange = React__namespace.useCallback((value) => {
1720
+ setCurrentValue(value[0]);
1721
+ if (ui.isFunction(onChange)) {
1722
+ // Do not have multiple thumbs support yet
1723
+ onChange(value[0]);
1724
+ }
1725
+ }, [onChange]);
1726
+ const renderedValue = React__namespace.useMemo(() => {
1727
+ const formattedValue = ui.isFunction(formatValue)
1728
+ ? formatValue(currentValue)
1729
+ : currentValue;
1730
+ return typeof formatValue === 'string' ? (React__namespace.createElement(Field.View, { as: "span" }, formattedValue)) : (formattedValue);
1731
+ }, [currentValue, formatValue]);
1732
+ const isVertical = orientation === 'vertical';
1733
+ const componentClasses = ui.classNames(ui.ComponentClassName.SliderFieldTrack, ui.classNameModifier(ui.ComponentClassName.SliderFieldTrack, orientation), ui.classNameModifier(ui.ComponentClassName.SliderFieldTrack, size));
1734
+ const rootComponentClasses = ui.classNames(ui.ComponentClassName.SliderFieldRoot, ui.classNameModifier(ui.ComponentClassName.SliderFieldRoot, orientation), ui.classNameModifier(ui.ComponentClassName.SliderFieldRoot, size), ui.classNameModifierByFlag(ui.ComponentClassName.SliderFieldRoot, 'disabled', disabled), className);
1735
+ return (React__namespace.createElement(Field.Flex
1736
+ // Custom classnames will be added to Root below
1737
+ , {
1738
+ // Custom classnames will be added to Root below
1739
+ className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), ui.ComponentClassName.SliderField), testId: testId, ...styleProps },
1740
+ React__namespace.createElement(Field.Label, { className: ui.ComponentClassName.SliderFieldLabel, id: labelId, testId: SLIDER_LABEL_TEST_ID, visuallyHidden: labelHidden },
1741
+ React__namespace.createElement(Field.View, { as: "span" }, label),
1742
+ !isValueHidden ? renderedValue : null),
1743
+ React__namespace.createElement(Field.FieldDescription, { id: descriptionId, labelHidden: labelHidden, descriptiveText: descriptiveText }),
1744
+ React__namespace.createElement(FieldGroup, { className: ui.ComponentClassName.SliderFieldGroup, id: fieldId, orientation: orientation, outerStartComponent: outerStartComponent, outerEndComponent: outerEndComponent },
1745
+ React__namespace.createElement(Root, { className: rootComponentClasses, "data-testid": SLIDER_ROOT_TEST_ID, disabled: disabled, defaultValue: defaultValues, onValueChange: onValueChange, orientation: orientation, ref: ref, value: values, ...rest },
1746
+ React__namespace.createElement(Track, { className: componentClasses, "data-testid": SLIDER_TRACK_TEST_ID, style: {
1747
+ backgroundColor: String(emptyTrackColor),
1748
+ [`${isVertical ? 'width' : 'height'}`]: trackSize,
1749
+ } },
1750
+ React__namespace.createElement(Range, { className: ui.classNames(ui.ComponentClassName.SliderFieldRange, ui.classNameModifier(ui.ComponentClassName.SliderFieldRange, orientation), ui.classNameModifierByFlag(ui.ComponentClassName.SliderFieldRange, 'disabled', disabled)), "data-testid": SLIDER_RANGE_TEST_ID, style: { backgroundColor: String(filledTrackColor) } })),
1751
+ React__namespace.createElement(Thumb, { "aria-describedby": ariaDescribedBy, "aria-labelledby": labelId, "aria-valuetext": ariaValuetext, className: ui.classNames(ui.ComponentClassName.SliderFieldThumb, ui.classNameModifier(ui.ComponentClassName.SliderFieldThumb, size), ui.classNameModifierByFlag(ui.ComponentClassName.SliderFieldThumb, 'disabled', disabled)), style: { backgroundColor: String(thumbColor) } }))),
1752
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
1753
+ };
1754
+ /**
1755
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/sliderfield)
1756
+ */
1757
+ const SliderField = Field.primitiveWithForwardRef(SliderFieldPrimitive);
1758
+ SliderField.displayName = 'SliderField';
1759
+
1760
+ const getCorrectSteppingValue = ({ max, min, step, value, }) => {
1761
+ // Round it to the closest step value
1762
+ // It will be based off min to be consistent with native input[type="number"]
1763
+ // This allows keyboard accessible
1764
+ const remainder = (value - min) % step;
1765
+ value = value - remainder + Math.round(remainder / step) * step;
1766
+ // Make sure new value is not outside the bound
1767
+ value = Math.max(min, value);
1768
+ if (value > max) {
1769
+ value = max - ((max - min) % step);
1770
+ }
1771
+ return value;
1772
+ };
1773
+ const useStepper = ({ defaultValue = 0, value: controlledValue, step = 1, max = Number.MAX_SAFE_INTEGER, min = Number.MIN_SAFE_INTEGER, isDisabled, isReadOnly, onChange, onDecrease, onIncrease, onStepChange, }) => {
1774
+ const isControlled = controlledValue !== undefined;
1775
+ // Make sure max value is greater than or equal to min value
1776
+ max = Math.max(min, max);
1777
+ // Maintain an internal state for uncontrolled components
1778
+ // This allows to take over the input value and correct any invalid versus purely relying on the native uncontrolled input
1779
+ const [uncontrolledValue, setUncontrolledValue] = React__namespace.useState(() =>
1780
+ // This is required for users could provide any defaultValue
1781
+ getCorrectSteppingValue({ min, max, step, value: defaultValue }));
1782
+ // Same for controlled components on the first render because users could provide invalid initial value.
1783
+ // It seems redundant afterwards but necessary for the first render
1784
+ const value = isControlled
1785
+ ? getCorrectSteppingValue({ min, max, step, value: controlledValue })
1786
+ : uncontrolledValue;
1787
+ const shouldDisableIncreaseButton = isDisabled ?? isReadOnly ?? value + step > max;
1788
+ const shouldDisableDecreaseButton = isDisabled ?? isReadOnly ?? value - step < min;
1789
+ // This is the exact value to be rendered on screen
1790
+ // It could be a string, like '-' or empty string when users clear the input
1791
+ const [inputValue, setInputValue] = React__namespace.useState(value);
1792
+ const handleOnChange = React__namespace.useCallback((event) => {
1793
+ setInputValue(event.target.value);
1794
+ if (ui.isFunction(onChange)) {
1795
+ onChange(event);
1796
+ }
1797
+ }, [onChange]);
1798
+ const handleOnBlur = React__namespace.useCallback((event) => {
1799
+ const parsedValue = parseFloat(event.target.value);
1800
+ // Though input[type='number'] has built-in validation to reject non-numerical entries
1801
+ // The entered value could still be empty string or minus '-'
1802
+ // in these cases, no need to do the following validation
1803
+ if (isNaN(parsedValue)) {
1804
+ return;
1805
+ }
1806
+ const newValue = getCorrectSteppingValue({
1807
+ min,
1808
+ max,
1809
+ step,
1810
+ value: parsedValue,
1811
+ });
1812
+ if (!isControlled) {
1813
+ setUncontrolledValue(newValue);
1814
+ }
1815
+ if (ui.isFunction(onStepChange)) {
1816
+ onStepChange(newValue);
1817
+ }
1818
+ setInputValue(newValue);
1819
+ }, [min, max, step, isControlled, onStepChange]);
1820
+ const handleIncrease = React__namespace.useCallback(() => {
1821
+ // No need to check if the value will be outside the bounds
1822
+ // The button will be disabled if so
1823
+ if (!isControlled) {
1824
+ setUncontrolledValue(value + step);
1825
+ }
1826
+ if (ui.isFunction(onStepChange)) {
1827
+ onStepChange(value + step);
1828
+ }
1829
+ if (ui.isFunction(onIncrease)) {
1830
+ onIncrease();
1831
+ }
1832
+ setInputValue(value + step);
1833
+ }, [step, value, isControlled, onIncrease, onStepChange]);
1834
+ const handleDecrease = React__namespace.useCallback(() => {
1835
+ // No need to check if the value will be outside the bounds
1836
+ // The button will be disabled if so
1837
+ if (!isControlled) {
1838
+ setUncontrolledValue(value - step);
1839
+ }
1840
+ if (ui.isFunction(onStepChange)) {
1841
+ onStepChange(value - step);
1842
+ }
1843
+ if (ui.isFunction(onDecrease)) {
1844
+ onDecrease();
1845
+ }
1846
+ setInputValue(value - step);
1847
+ }, [step, value, isControlled, onDecrease, onStepChange]);
1848
+ // This aims to disable unwanted behaviors on React input[type='number']
1849
+ // When the input gets focused, rotating a wheel will change its value
1850
+ // But the parent container(mostly the entire window) will be scrolling to elsewhere
1851
+ const handleOnWheel = React__namespace.useCallback((event) => {
1852
+ event.currentTarget.blur();
1853
+ }, []);
1854
+ return {
1855
+ step,
1856
+ value,
1857
+ inputValue,
1858
+ handleDecrease,
1859
+ handleIncrease,
1860
+ handleOnBlur,
1861
+ handleOnChange,
1862
+ handleOnWheel,
1863
+ setInputValue,
1864
+ shouldDisableDecreaseButton,
1865
+ shouldDisableIncreaseButton,
1866
+ };
1867
+ };
1868
+
1869
+ const DECREASE_ICON = 'decrease-icon';
1870
+ const INCREASE_ICON = 'increase-icon';
1871
+ const StepperFieldPrimitive = (props, ref) => {
1872
+ const { className,
1873
+ // destructure to prevent `defaultValue` from being passed to underlying `Input` via `_rest`
1874
+ defaultValue, descriptiveText, errorMessage, hasError = false, id, inputStyles, isDisabled, isReadOnly, isRequired, increaseButtonLabel = Field.ComponentText.StepperField.increaseButtonLabel, decreaseButtonLabel = Field.ComponentText.StepperField.decreaseButtonLabel, label, labelHidden = false,
1875
+ // destructure to prevent `onStepChange` from being passed to underlying `Input` via `_rest`
1876
+ onStepChange, size, testId,
1877
+ // this is only required in useStepper hook but deconstruct here to remove its existence in rest
1878
+ value: controlledValue, variation, ..._rest } = props;
1879
+ const fieldId = useStableId(id);
1880
+ const descriptionId = useStableId();
1881
+ const ariaDescribedBy = descriptiveText ? descriptionId : undefined;
1882
+ const { styleProps, rest } = splitPrimitiveProps(_rest);
1883
+ const icons = Field.useIcons('stepperField');
1884
+ const { step, value, inputValue, handleDecrease, handleIncrease, handleOnBlur, handleOnChange, handleOnWheel, setInputValue, shouldDisableDecreaseButton, shouldDisableIncreaseButton, } = useStepper({ ...props, defaultValue, onStepChange });
1885
+ React__namespace.useEffect(() => {
1886
+ const isControlled = controlledValue !== undefined;
1887
+ if (isControlled) {
1888
+ setInputValue(controlledValue);
1889
+ }
1890
+ }, [controlledValue, setInputValue]);
1891
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), ui.ComponentClassName.StepperField, className), testId: testId, ...styleProps },
1892
+ React__namespace.createElement(Field.Label, { htmlFor: fieldId, visuallyHidden: labelHidden }, label),
1893
+ React__namespace.createElement(Field.FieldDescription, { id: descriptionId, labelHidden: labelHidden, descriptiveText: descriptiveText }),
1894
+ React__namespace.createElement(FieldGroup, { outerStartComponent: React__namespace.createElement(Field.FieldGroupIconButton, { "aria-controls": fieldId, ariaLabel: `${decreaseButtonLabel} ${value - step}`, className: ui.classNames(ui.ComponentClassName.StepperFieldButtonDecrease, ui.classNameModifier(ui.ComponentClassName.StepperFieldButtonDecrease, variation), ui.classNameModifierByFlag(ui.ComponentClassName.StepperFieldButtonDecrease, 'disabled', shouldDisableDecreaseButton)), "data-invalid": hasError, isDisabled: shouldDisableDecreaseButton, onClick: handleDecrease, size: size }, icons?.remove ?? React__namespace.createElement(Field.IconRemove, { "data-testid": DECREASE_ICON })), outerEndComponent: React__namespace.createElement(Field.FieldGroupIconButton, { "aria-controls": fieldId, ariaLabel: `${increaseButtonLabel} ${value + step}`, className: ui.classNames(ui.ComponentClassName.StepperFieldButtonIncrease, ui.classNameModifier(ui.ComponentClassName.StepperFieldButtonIncrease, variation), ui.classNameModifierByFlag(ui.ComponentClassName.StepperFieldButtonIncrease, 'disabled', shouldDisableIncreaseButton)), "data-invalid": hasError, isDisabled: shouldDisableIncreaseButton, onClick: handleIncrease, size: size }, icons?.add ?? React__namespace.createElement(Field.IconAdd, { "data-testid": INCREASE_ICON })) },
1895
+ React__namespace.createElement(Input, { "aria-describedby": ariaDescribedBy, className: ui.ComponentClassName.StepperFieldInput, hasError: hasError, id: fieldId, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, onBlur: handleOnBlur, onChange: handleOnChange, onWheel: handleOnWheel, ref: ref, size: size, variation: variation, type: "number", value: inputValue, ...inputStyles, ...rest })),
1896
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
1897
+ };
1898
+ /**
1899
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/stepperfield)
1900
+ */
1901
+ const StepperField = Field.primitiveWithForwardRef(StepperFieldPrimitive);
1902
+ StepperField.displayName = 'StepperField';
1903
+
1904
+ const useSwitch = (props) => {
1905
+ const { onChange, isChecked, defaultChecked, isDisabled } = props;
1906
+ const isControlled = typeof isChecked !== 'undefined';
1907
+ const [isOn, setIsOn] = React.useState(isControlled ? isChecked : !!defaultChecked);
1908
+ const [isFocused, setIsFocused] = React.useState(false);
1909
+ const changeHandler = React.useCallback((event) => {
1910
+ if (isDisabled) {
1911
+ event.preventDefault();
1912
+ return;
1913
+ }
1914
+ if (ui.isFunction(onChange)) {
1915
+ onChange(event);
1916
+ }
1917
+ setIsOn(event.target.checked);
1918
+ }, [onChange, isDisabled]);
1919
+ if (isControlled && isOn !== isChecked) {
1920
+ setIsOn(isChecked);
1921
+ }
1922
+ return {
1923
+ isOn,
1924
+ changeHandler,
1925
+ isFocused,
1926
+ setIsFocused,
1927
+ };
1928
+ };
1929
+
1930
+ const SwitchFieldPrimitive = ({ className, defaultChecked, id, isChecked, isDisabled, isLabelHidden, label, labelPosition, name, onChange, size, thumbColor, trackCheckedColor, trackColor, value, hasError, errorMessage, ...rest }, ref) => {
1931
+ const { isOn, changeHandler, isFocused, setIsFocused } = useSwitch({
1932
+ onChange,
1933
+ isChecked,
1934
+ defaultChecked,
1935
+ isDisabled,
1936
+ });
1937
+ const { isFieldsetDisabled } = Field.useFieldset();
1938
+ const shouldBeDisabled = isFieldsetDisabled ? isFieldsetDisabled : isDisabled;
1939
+ const fieldId = useStableId(id);
1940
+ const wrapperClasses = ui.classNames(ui.ComponentClassName.SwitchTrack, ui.classNameModifierByFlag(ui.ComponentClassName.SwitchTrack, 'checked', isOn), ui.classNameModifierByFlag(ui.ComponentClassName.SwitchTrack, 'disabled', shouldBeDisabled), ui.classNameModifierByFlag(ui.ComponentClassName.SwitchTrack, 'focused', isFocused), ui.classNameModifierByFlag(ui.ComponentClassName.SwitchTrack, 'error', hasError));
1941
+ const componentClasses = ui.classNames(ui.ComponentClassName.SwitchThumb, ui.classNameModifierByFlag(ui.ComponentClassName.SwitchThumb, 'checked', isOn), ui.classNameModifierByFlag(ui.ComponentClassName.SwitchThumb, 'disabled', shouldBeDisabled));
1942
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.SwitchField, ui.classNameModifier(ui.ComponentClassName.SwitchField, size), labelPosition ? `amplify-label-${labelPosition}` : null, className), ref: ref, ...rest },
1943
+ React__namespace.createElement(VisuallyHidden, null,
1944
+ React__namespace.createElement(Input, { role: "switch", type: "checkbox", id: fieldId, onChange: changeHandler, disabled: isDisabled, name: name, checked: isOn, value: value, onFocus: () => {
1945
+ setIsFocused(true);
1946
+ }, onBlur: () => {
1947
+ setIsFocused(false);
1948
+ } })),
1949
+ React__namespace.createElement(Field.Label, { htmlFor: fieldId, className: ui.classNames(ui.ComponentClassName.SwitchWrapper, ui.classNameModifier(ui.ComponentClassName.SwitchWrapper, labelPosition)) },
1950
+ isLabelHidden ? (React__namespace.createElement(VisuallyHidden, { as: "span", className: ui.ComponentClassName.SwitchLabel }, label)) : (React__namespace.createElement(Field.View, { as: "span", className: ui.ComponentClassName.SwitchLabel }, label)),
1951
+ React__namespace.createElement(Field.View, { as: "span", className: wrapperClasses, backgroundColor: isOn ? trackCheckedColor : trackColor },
1952
+ React__namespace.createElement(Field.View, { as: "span", className: componentClasses, "data-checked": isOn, "data-disabled": shouldBeDisabled, backgroundColor: thumbColor }))),
1953
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
1954
+ };
1955
+ /**
1956
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/switchfield)
1957
+ */
1958
+ const SwitchField = Field.primitiveWithForwardRef(SwitchFieldPrimitive);
1959
+ SwitchField.displayName = 'SwitchField';
1960
+
1961
+ const TablePrimitive = ({ caption, children, className, highlightOnHover = false, size, variation, ...rest }, ref) => {
1962
+ const componentClasses = ui.classNames(ui.ComponentClassName.Table, ui.classNameModifier(ui.ComponentClassName.Table, size), ui.classNameModifier(ui.ComponentClassName.Table, variation), className);
1963
+ return (React__namespace.createElement(Field.View, { as: "table", className: componentClasses, "data-highlightonhover": highlightOnHover, ref: ref, ...rest },
1964
+ caption && (React__namespace.createElement(Field.View, { as: "caption", className: ui.ComponentClassName.TableCaption }, caption)),
1965
+ children));
1966
+ };
1967
+ /**
1968
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/table)
1969
+ */
1970
+ const Table = Field.primitiveWithForwardRef(TablePrimitive);
1971
+ Table.displayName = 'Table';
1972
+
1973
+ const TableBodyPrimitive = ({ children, className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: "tbody", className: ui.classNames(ui.ComponentClassName.TableBody, className), ref: ref, ...rest }, children));
1974
+ const TableBody = Field.primitiveWithForwardRef(TableBodyPrimitive);
1975
+ TableBody.displayName = 'TableBody';
1976
+
1977
+ const TableCellPrimitive = ({ as: asElementTag = 'td', children, className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: asElementTag, className: ui.classNames(asElementTag === 'td'
1978
+ ? ui.ComponentClassName.TableTd
1979
+ : ui.ComponentClassName.TableTh, className), ref: ref, ...rest }, children));
1980
+ const TableCell = Field.primitiveWithForwardRef(TableCellPrimitive);
1981
+ TableCell.displayName = 'TableCell';
1982
+
1983
+ const TableFootPrimitive = ({ children, className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: "tfoot", className: ui.classNames(ui.ComponentClassName.TableFoot, className), ref: ref, ...rest }, children));
1984
+ const TableFoot = Field.primitiveWithForwardRef(TableFootPrimitive);
1985
+ TableFoot.displayName = 'TableFoot';
1986
+
1987
+ const TableHeadPrimitive = ({ children, className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: "thead", className: ui.classNames(ui.ComponentClassName.TableHead, className), ref: ref, ...rest }, children));
1988
+ const TableHead = Field.primitiveWithForwardRef(TableHeadPrimitive);
1989
+ TableHead.displayName = 'TableHead';
1990
+
1991
+ const TableRowPrimitive = ({ children, className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: "tr", className: ui.classNames(ui.ComponentClassName.TableRow, className), ref: ref, ...rest }, children));
1992
+ const TableRow = Field.primitiveWithForwardRef(TableRowPrimitive);
1993
+ TableRow.displayName = 'TableRow';
1994
+
1995
+ const TabsContext = React__namespace.createContext({
1996
+ activeTab: '',
1997
+ setActiveTab: () => { },
1998
+ });
1999
+
2000
+ const TabsItemPrimitive = ({ className, value, children, onClick, as = 'button', role = 'tab', ...rest }, ref) => {
2001
+ const { activeTab, setActiveTab } = React__namespace.useContext(TabsContext);
2002
+ const isActive = activeTab === value;
2003
+ const handleOnClick = (e) => {
2004
+ if (ui.isTypedFunction(onClick)) {
2005
+ onClick?.(e);
2006
+ }
2007
+ setActiveTab(value);
2008
+ };
2009
+ return (React__namespace.createElement(Field.View, { ...rest, role: role, as: as, id: `${value}-tab`, "aria-selected": isActive, "aria-controls": `${value}-panel`, tabIndex: !isActive ? -1 : undefined, className: ui.classNames(ui.ComponentClassName.TabsItem, ui.classNameModifierByFlag(ui.ComponentClassName.TabsItem, 'active', activeTab === value), className), ref: ref, onClick: handleOnClick }, children));
2010
+ };
2011
+ /**
2012
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/tabs)
2013
+ */
2014
+ const TabsItem = Field.primitiveWithForwardRef(TabsItemPrimitive);
2015
+ TabsItem.displayName = 'Tabs.Item';
2016
+
2017
+ const isValidTab = (child) => React__namespace.isValidElement(child);
2018
+ const TabListPrimitive = ({ className, children, indicatorPosition, spacing, role = 'tablist', ...rest }, ref) => {
2019
+ const internalRef = React__namespace.useRef(null);
2020
+ const { activeTab, setActiveTab } = React__namespace.useContext(TabsContext);
2021
+ React__namespace.useImperativeHandle(ref, () => internalRef.current);
2022
+ const values = React__namespace.useMemo(() => React__namespace.Children.toArray(children)
2023
+ .map((child) => {
2024
+ if (child && isValidTab(child)) {
2025
+ return child.props.value;
2026
+ }
2027
+ })
2028
+ .filter((child) => !!child), [children]);
2029
+ const currentIndex = values.indexOf(activeTab);
2030
+ const nextTab = React__namespace.useCallback(() => {
2031
+ let nextIndex = currentIndex === values.length - 1 ? 0 : currentIndex + 1;
2032
+ const elems = internalRef.current?.querySelectorAll('button') ?? [];
2033
+ while (elems[nextIndex].disabled) {
2034
+ if (nextIndex === values.length - 1) {
2035
+ nextIndex = 0;
2036
+ }
2037
+ else {
2038
+ nextIndex++;
2039
+ }
2040
+ }
2041
+ const value = values[nextIndex];
2042
+ if (value) {
2043
+ setActiveTab(value);
2044
+ const elem = elems[nextIndex];
2045
+ elem?.focus();
2046
+ elem?.click();
2047
+ }
2048
+ }, [currentIndex, setActiveTab, values]);
2049
+ const prevTab = React__namespace.useCallback(() => {
2050
+ let prevIndex = currentIndex === 0 ? values.length - 1 : currentIndex - 1;
2051
+ const elems = internalRef.current?.querySelectorAll('button') ?? [];
2052
+ while (elems[prevIndex].disabled) {
2053
+ if (prevIndex === 0) {
2054
+ prevIndex = values.length - 1;
2055
+ }
2056
+ else {
2057
+ prevIndex--;
2058
+ }
2059
+ }
2060
+ const value = values[prevIndex];
2061
+ if (value) {
2062
+ setActiveTab(value);
2063
+ const elem = elems[prevIndex];
2064
+ elem?.focus();
2065
+ elem?.click();
2066
+ }
2067
+ }, [currentIndex, setActiveTab, values]);
2068
+ const onKeyDown = React__namespace.useCallback((event) => {
2069
+ switch (event.key) {
2070
+ case 'ArrowLeft':
2071
+ event.preventDefault();
2072
+ event.stopPropagation();
2073
+ prevTab();
2074
+ break;
2075
+ case 'ArrowUp':
2076
+ case 'ArrowRight':
2077
+ event.preventDefault();
2078
+ event.stopPropagation();
2079
+ nextTab();
2080
+ break;
2081
+ }
2082
+ }, [prevTab, nextTab]);
2083
+ return (React__namespace.createElement(Field.View, { ...rest, role: role, onKeyDown: onKeyDown, className: ui.classNames(ui.ComponentClassName.TabsList, indicatorPosition
2084
+ ? ui.classNameModifier(ui.ComponentClassName.TabsList, indicatorPosition)
2085
+ : null, spacing
2086
+ ? ui.classNameModifier(ui.ComponentClassName.TabsList, spacing)
2087
+ : null, className), ref: internalRef }, children));
2088
+ };
2089
+ /**
2090
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/tabs)
2091
+ */
2092
+ const TabList = Field.primitiveWithForwardRef(TabListPrimitive);
2093
+ TabList.displayName = 'Tabs.List';
2094
+
2095
+ const TabPanelPrimitive = ({ className, value, children, role = 'tabpanel', ...rest }, ref) => {
2096
+ const { activeTab, isLazy } = React__namespace.useContext(TabsContext);
2097
+ if (isLazy && activeTab !== value)
2098
+ return null;
2099
+ return (React__namespace.createElement(Field.View, { ...rest, role: role, id: `${value}-panel`, "aria-labelledby": `${value}-tab`, className: ui.classNames(ui.ComponentClassName.TabsPanel, ui.classNameModifierByFlag(ui.ComponentClassName.TabsPanel, 'active', activeTab === value), className), ref: ref }, children));
2100
+ };
2101
+ /**
2102
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/tabs)
2103
+ */
2104
+ const TabPanel = Field.primitiveWithForwardRef(TabPanelPrimitive);
2105
+ TabPanel.displayName = 'Tabs.Panel';
2106
+
2107
+ const TabsContainerPrimitive = ({ children, defaultValue, className, value: controlledValue, onValueChange, isLazy, ...rest }, ref) => {
2108
+ const isControlled = controlledValue !== undefined;
2109
+ const [localValue, setLocalValue] = React__namespace.useState(() => isControlled ? controlledValue : defaultValue);
2110
+ const activeTab = isControlled ? controlledValue : localValue ?? '';
2111
+ const setActiveTab = React__namespace.useCallback((newValue) => {
2112
+ if (ui.isFunction(onValueChange)) {
2113
+ onValueChange(newValue);
2114
+ }
2115
+ if (!isControlled) {
2116
+ setLocalValue(newValue);
2117
+ }
2118
+ }, [onValueChange, isControlled]);
2119
+ const _value = React__namespace.useMemo(() => {
2120
+ return {
2121
+ activeTab,
2122
+ isLazy,
2123
+ setActiveTab,
2124
+ };
2125
+ }, [activeTab, setActiveTab, isLazy]);
2126
+ return (React__namespace.createElement(TabsContext.Provider, { value: _value },
2127
+ React__namespace.createElement(Field.View, { ...rest, ref: ref, className: ui.classNames(className, ui.ComponentClassName.Tabs) }, children)));
2128
+ };
2129
+ /**
2130
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/tabs)
2131
+ */
2132
+ const TabsContainer = Field.primitiveWithForwardRef(TabsContainerPrimitive);
2133
+ TabsContainer.displayName = 'Tabs.Container';
2134
+
2135
+ const TabsPrimitive = ({ items, indicatorPosition, justifyContent, spacing, ...rest }, ref) => {
2136
+ return (React__namespace.createElement(TabsContainer, { ...rest, ref: ref },
2137
+ React__namespace.createElement(TabList, { indicatorPosition: indicatorPosition, justifyContent: justifyContent, spacing: spacing }, items?.map(({ value, label, content, ...rest }) => (React__namespace.createElement(TabsItem, { ...rest, key: value, value: value }, label)))),
2138
+ items?.map(({ value, content, isDisabled }) => (React__namespace.createElement(TabPanel, { key: value, value: value, isDisabled: isDisabled }, content)))));
2139
+ };
2140
+ /**
2141
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/tabs)
2142
+ */
2143
+ const Tabs = Object.assign(Field.primitiveWithForwardRef(TabsPrimitive), {
2144
+ Item: TabsItem,
2145
+ List: TabList,
2146
+ Panel: TabPanel,
2147
+ Container: TabsContainer,
2148
+ });
2149
+ Tabs.displayName = 'Tabs';
2150
+
2151
+ const TextAreaPrimitive = ({ className, isDisabled, isReadOnly, isRequired, size, hasError = false, variation, ...rest }, ref) => {
2152
+ const componentClasses = ui.classNames(ui.ComponentClassName.Textarea, ui.ComponentClassName.FieldGroupControl, ui.classNameModifier(ui.ComponentClassName.Textarea, variation), ui.classNameModifier(ui.ComponentClassName.Textarea, size), ui.classNameModifierByFlag(ui.ComponentClassName.Textarea, 'error', hasError), className);
2153
+ const { isFieldsetDisabled } = Field.useFieldset();
2154
+ return (React__namespace.createElement(Field.View, { "aria-invalid": hasError, as: "textarea", className: componentClasses, disabled: isFieldsetDisabled ? isFieldsetDisabled : isDisabled, readOnly: isReadOnly, ref: ref, required: isRequired, ...rest }));
2155
+ };
2156
+ const TextArea = Field.primitiveWithForwardRef(TextAreaPrimitive);
2157
+ TextArea.displayName = 'TextArea';
2158
+
2159
+ const DEFAULT_ROW_COUNT = 3;
2160
+ const TextAreaFieldPrimitive = (props, ref) => {
2161
+ const { className, descriptiveText, errorMessage, hasError = false, id, label, labelHidden = false, rows, size, testId, inputStyles,
2162
+ // Destructuring the 'resize' style prop because while it is a style prop
2163
+ // it should go on the textarea element and not the wrapper div.
2164
+ resize, ..._rest } = props;
2165
+ const fieldId = useStableId(id);
2166
+ const descriptionId = useStableId();
2167
+ const ariaDescribedBy = descriptiveText ? descriptionId : undefined;
2168
+ const { styleProps, rest } = splitPrimitiveProps(_rest);
2169
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), ui.ComponentClassName.TextAreaField, className), testId: testId, ...styleProps },
2170
+ React__namespace.createElement(Field.Label, { htmlFor: fieldId, visuallyHidden: labelHidden }, label),
2171
+ React__namespace.createElement(Field.FieldDescription, { id: descriptionId, labelHidden: labelHidden, descriptiveText: descriptiveText }),
2172
+ React__namespace.createElement(TextArea, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, rows: rows ?? DEFAULT_ROW_COUNT, size: size, resize: resize, ...rest, ...inputStyles }),
2173
+ React__namespace.createElement(Field.FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
2174
+ };
2175
+ /**
2176
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/textareafield)
2177
+ */
2178
+ const TextAreaField = Field.primitiveWithForwardRef(TextAreaFieldPrimitive);
2179
+ TextAreaField.displayName = 'TextAreaField';
2180
+
2181
+ const useToggleButton = ({ isPressed, defaultPressed, onClick, onChange, value, }) => {
2182
+ const isControlled = isPressed !== undefined;
2183
+ // Maintain internal selected state for uncontrolled component
2184
+ const [pressed, setPressed] = React__namespace.useState(defaultPressed);
2185
+ isPressed = isControlled ? isPressed : pressed;
2186
+ const handleClick = React__namespace.useCallback((event) => {
2187
+ if (ui.isFunction(onClick)) {
2188
+ onClick(event);
2189
+ }
2190
+ if (!isControlled) {
2191
+ setPressed(!pressed);
2192
+ }
2193
+ if (isControlled && ui.isFunction(onChange)) {
2194
+ onChange(value);
2195
+ }
2196
+ }, [isControlled, onClick, onChange, pressed, value]);
2197
+ return { isPressed, handleClick };
2198
+ };
2199
+
2200
+ const ToggleButtonPrimitive = ({ className, children, defaultPressed = false, isDisabled, isPressed: isPressedProp, onChange, onClick, size, value, variation, ...rest }, ref) => {
2201
+ const { isPressed, handleClick } = useToggleButton({
2202
+ isPressed: isPressedProp,
2203
+ defaultPressed,
2204
+ onChange,
2205
+ onClick,
2206
+ value,
2207
+ });
2208
+ const componentClasses = ui.classNames(ui.ComponentClassName.ToggleButton, ui.classNameModifier(ui.ComponentClassName.ToggleButton, variation), ui.classNameModifierByFlag(ui.ComponentClassName.ToggleButton, 'pressed', isPressed), className);
2209
+ return (React__namespace.createElement(Field.Button, { "aria-pressed": isPressed, className: componentClasses, isDisabled: isDisabled, onClick: handleClick, ref: ref, size: size, type: "button", variation: variation, ...rest }, children));
2210
+ };
2211
+ /**
2212
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/togglebutton)
2213
+ */
2214
+ const ToggleButton = Field.primitiveWithForwardRef(ToggleButtonPrimitive);
2215
+ ToggleButton.displayName = 'ToggleButton';
2216
+
2217
+ const useToggleButtonGroup = ({ onChange, value, isExclusive = false, isSelectionRequired = false, }) => {
2218
+ // Multiple selection
2219
+ const handleChange = React__namespace.useCallback((buttonValue) => {
2220
+ if (!ui.isFunction(onChange) || !Array.isArray(value)) {
2221
+ return;
2222
+ }
2223
+ const index = ui.isString(buttonValue) ? value.indexOf(buttonValue) : -1;
2224
+ let newValue;
2225
+ const shouldToggleOff = index >= 0;
2226
+ if (shouldToggleOff) {
2227
+ // Toggle off
2228
+ newValue = [...value];
2229
+ if (!isSelectionRequired || newValue.length > 1) {
2230
+ newValue.splice(index, 1);
2231
+ }
2232
+ }
2233
+ else {
2234
+ // Toggle on
2235
+ newValue = [...value, buttonValue];
2236
+ }
2237
+ onChange(newValue);
2238
+ }, [onChange, value, isSelectionRequired]);
2239
+ // Exclusive selection
2240
+ const handleExclusiveChange = React__namespace.useCallback((buttonValue) => {
2241
+ if (!ui.isFunction(onChange)) {
2242
+ return;
2243
+ }
2244
+ onChange(value === buttonValue && !isSelectionRequired ? undefined : buttonValue);
2245
+ }, [onChange, value, isSelectionRequired]);
2246
+ return isExclusive ? handleExclusiveChange : handleChange;
2247
+ };
2248
+
2249
+ const ToggleButtonGroupPrimitive = ({ children, className, isExclusive, isSelectionRequired, onChange, size, value, variation, ...rest }, ref) => {
2250
+ const handleChange = useToggleButtonGroup({
2251
+ onChange,
2252
+ value,
2253
+ isExclusive,
2254
+ isSelectionRequired,
2255
+ });
2256
+ return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.ToggleButtonGroup, className), ref: ref, role: "group", ...rest }, React__namespace.Children.map(children, (child) => {
2257
+ if (React__namespace.isValidElement(child)) {
2258
+ return React__namespace.cloneElement(child, {
2259
+ isPressed: isExclusive
2260
+ ? value === child.props.value
2261
+ : ui.isString(child.props.value) &&
2262
+ value.includes(child.props.value),
2263
+ onChange: handleChange,
2264
+ size,
2265
+ variation,
2266
+ });
2267
+ }
2268
+ return child;
2269
+ })));
2270
+ };
2271
+ /**
2272
+ * [📖 Docs](https://ui.docs.amplify.aws/react/components/togglebutton#togglebuttongroup)
2273
+ */
2274
+ const ToggleButtonGroup = Field.primitiveWithForwardRef(ToggleButtonGroupPrimitive);
2275
+ ToggleButtonGroup.displayName = 'ToggleButtonGroup';
2276
+
2277
+ var index$1 = /*#__PURE__*/Object.freeze({
2278
+ __proto__: null,
2279
+ IconsProvider: IconsProvider,
2280
+ Alert: Alert,
2281
+ Autocomplete: Autocomplete,
2282
+ Badge: Badge,
2283
+ Breadcrumbs: Breadcrumbs,
2284
+ Button: Field.Button,
2285
+ ButtonGroup: ButtonGroup,
2286
+ Card: Card,
2287
+ CheckboxField: CheckboxField,
2288
+ Collection: Collection,
2289
+ Divider: Divider,
2290
+ DropZone: DropZone,
2291
+ Accordion: Accordion,
2292
+ FieldGroupIcon: Field.FieldGroupIcon,
2293
+ FieldGroupIconButton: Field.FieldGroupIconButton,
2294
+ Fieldset: Fieldset,
2295
+ Flex: Field.Flex,
2296
+ Grid: Grid,
2297
+ Heading: Heading,
2298
+ HighlightMatch: HighlightMatch,
2299
+ Icon: Field.Icon,
2300
+ Image: Image,
2301
+ Input: Input,
2302
+ Label: Field.Label,
2303
+ Link: Link,
2304
+ Loader: Field.Loader,
2305
+ Menu: Menu,
2306
+ MenuButton: MenuButton,
2307
+ MenuItem: MenuItem,
2308
+ Message: Message,
2309
+ Pagination: Pagination,
2310
+ PasswordField: PasswordField,
2311
+ PhoneNumberField: PhoneNumberField,
2312
+ Placeholder: Placeholder,
2313
+ Radio: Radio,
2314
+ RadioGroupField: RadioGroupField,
2315
+ Rating: Rating,
2316
+ ScrollView: ScrollView,
2317
+ SearchField: SearchField,
2318
+ SelectField: SelectField,
2319
+ SliderField: SliderField,
2320
+ StepperField: StepperField,
2321
+ SwitchField: SwitchField,
2322
+ Tabs: Tabs,
2323
+ Text: Field.Text,
2324
+ TextAreaField: TextAreaField,
2325
+ TextField: TextField,
2326
+ ToggleButton: ToggleButton,
2327
+ ToggleButtonGroup: ToggleButtonGroup,
2328
+ View: Field.View,
2329
+ VisuallyHidden: VisuallyHidden,
2330
+ Table: Table,
2331
+ TableBody: TableBody,
2332
+ TableCell: TableCell,
2333
+ TableFoot: TableFoot,
2334
+ TableHead: TableHead,
2335
+ TableRow: TableRow,
2336
+ usePagination: usePagination,
2337
+ ComponentPropsToStylePropsMap: Field.ComponentPropsToStylePropsMap,
2338
+ ComponentPropsToStylePropsMapKeys: Field.ComponentPropsToStylePropsMapKeys
2339
+ });
2340
+
2341
+ var ComponentClassName;
2342
+ (function (ComponentClassName) {
2343
+ ComponentClassName["ChangePassword"] = "amplify-accountsettings-changepassword";
2344
+ ComponentClassName["DeleteUser"] = "amplify-accountsettings-deleteuser";
2345
+ })(ComponentClassName || (ComponentClassName = {}));
2346
+
2347
+ const ValidationErrors = ({ errors, id, dataAttr, }) => {
2348
+ if (!(errors?.length > 0))
2349
+ return null;
2350
+ const dataAttrProp = dataAttr ? { [dataAttr]: true } : {};
2351
+ return (React__default["default"].createElement(Field.View, { ...dataAttrProp, id: id }, errors.map((error) => {
2352
+ return (React__default["default"].createElement(Field.Text, { key: error, role: "alert", variation: "error" }, ui.translate(error)));
2353
+ })));
2354
+ };
2355
+
2356
+ const DefaultErrorMessage = (props) => {
2357
+ return React__default["default"].createElement(Alert, { variation: "error", ...props });
2358
+ };
2359
+
2360
+ const DefaultPasswordField = ({ fieldValidationErrors, label, ...rest }) => {
2361
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
2362
+ React__default["default"].createElement(PasswordField, { ...rest, label: label }),
2363
+ fieldValidationErrors ? (React__default["default"].createElement(ValidationErrors, { errors: fieldValidationErrors })) : null));
2364
+ };
2365
+ const DEFAULTS$1 = {
2366
+ CurrentPasswordField: DefaultPasswordField,
2367
+ NewPasswordField: DefaultPasswordField,
2368
+ ConfirmPasswordField: DefaultPasswordField,
2369
+ SubmitButton: Field.Button,
2370
+ ErrorMessage: DefaultErrorMessage,
2371
+ };
2372
+
2373
+ const defaultChangePasswordDisplayText = {
2374
+ confirmPasswordFieldLabel: 'Confirm Password',
2375
+ currentPasswordFieldLabel: 'Current Password',
2376
+ newPasswordFieldLabel: 'New Password',
2377
+ updatePasswordButtonText: 'Update password',
2378
+ };
2379
+ const defaultDeleteUserDisplayText = {
2380
+ cancelButtonText: 'Cancel',
2381
+ confirmDeleteButtonText: 'Delete',
2382
+ deleteAccountButtonText: 'Delete Account',
2383
+ warningText: 'Deleting your account is not reversible. You will lose access to your account and all data associated with it.',
2384
+ };
2385
+
2386
+ const VERSION = '6.0.1';
2387
+
2388
+ const logger$2 = ui.getLogger('AccountSettings');
2389
+ const getIsDisabled = (formValues, validationError) => {
2390
+ const { currentPassword, newPassword, confirmPassword } = formValues;
2391
+ const hasEmptyField = !currentPassword || !newPassword || !confirmPassword;
2392
+ if (hasEmptyField) {
2393
+ return true;
2394
+ }
2395
+ const arePasswordsInvalid = validationError.newPassword?.length > 0 ||
2396
+ validationError.confirmPassword?.length > 0;
2397
+ return arePasswordsInvalid;
2398
+ };
2399
+ function ChangePassword({ components, displayText: overrideDisplayText, onError, onSuccess, validators, }) {
2400
+ const [errorMessage, setErrorMessage] = React__default["default"].useState(null);
2401
+ const [formValues, setFormValues] = React__default["default"].useState({});
2402
+ const [validationError, setValidationError] = React__default["default"].useState({});
2403
+ const blurredFields = React__default["default"].useRef([]);
2404
+ const { user, isLoading } = Field.useAuth();
2405
+ const isDisabled = getIsDisabled(formValues, validationError);
2406
+ const passwordValidators = React__default["default"].useMemo(() => {
2407
+ return validators ?? ui.getDefaultPasswordValidators();
2408
+ }, [validators]);
2409
+ uiReactCore.useSetUserAgent({
2410
+ componentName: 'ChangePassword',
2411
+ packageName: 'react',
2412
+ version: VERSION,
2413
+ });
2414
+ /*
2415
+ * Note that formValues and other states are passed in as props so that
2416
+ * it does not depend on whether or not those states have been updated yet
2417
+ */
2418
+ const validateNewPassword = React__default["default"].useCallback(({ formValues, eventType }) => {
2419
+ const { newPassword } = formValues;
2420
+ const hasBlurred = blurredFields.current.includes('newPassword');
2421
+ return ui.runFieldValidators({
2422
+ value: newPassword,
2423
+ validators: passwordValidators,
2424
+ eventType,
2425
+ hasBlurred,
2426
+ });
2427
+ }, [passwordValidators]);
2428
+ const validateConfirmPassword = React__default["default"].useCallback(({ formValues, eventType }) => {
2429
+ const { newPassword, confirmPassword } = formValues;
2430
+ const hasBlurred = blurredFields.current.includes('confirmPassword');
2431
+ const confirmPasswordValidators = ui.getDefaultConfirmPasswordValidators(newPassword);
2432
+ return ui.runFieldValidators({
2433
+ value: confirmPassword,
2434
+ validators: confirmPasswordValidators,
2435
+ eventType,
2436
+ hasBlurred,
2437
+ });
2438
+ }, []);
2439
+ const runValidation = React__default["default"].useCallback((param) => {
2440
+ const passwordErrors = validateNewPassword(param);
2441
+ const confirmPasswordErrors = validateConfirmPassword(param);
2442
+ const newValidationError = {
2443
+ newPassword: passwordErrors,
2444
+ confirmPassword: confirmPasswordErrors,
2445
+ };
2446
+ // only re-render if errors have changed
2447
+ if (!isEqual__default["default"](validationError, newValidationError)) {
2448
+ setValidationError(newValidationError);
2449
+ }
2450
+ }, [validateConfirmPassword, validateNewPassword, validationError]);
2451
+ /* Translations */
2452
+ const displayText = {
2453
+ ...defaultChangePasswordDisplayText,
2454
+ ...overrideDisplayText,
2455
+ };
2456
+ const { confirmPasswordFieldLabel, currentPasswordFieldLabel, newPasswordFieldLabel, updatePasswordButtonText, } = displayText;
2457
+ /* Subcomponents */
2458
+ const { CurrentPasswordField, NewPasswordField, ConfirmPasswordField, SubmitButton, ErrorMessage, } = React__default["default"].useMemo(() => ({ ...DEFAULTS$1, ...(components ?? {}) }), [components]);
2459
+ /* Event Handlers */
2460
+ const handleChange = (event) => {
2461
+ event.preventDefault();
2462
+ const { name, value } = event.target;
2463
+ const newFormValues = { ...formValues, [name]: value };
2464
+ runValidation({ formValues: newFormValues, eventType: 'change' });
2465
+ setFormValues(newFormValues);
2466
+ };
2467
+ const handleBlur = (event) => {
2468
+ event.preventDefault();
2469
+ const { name } = event.target;
2470
+ // only update state and run validation if this is the first time blurring the field
2471
+ if (!blurredFields.current.includes(name)) {
2472
+ const newBlurredFields = [...blurredFields.current, name];
2473
+ blurredFields.current = newBlurredFields;
2474
+ runValidation({ formValues, eventType: 'blur' });
2475
+ }
2476
+ };
2477
+ const handleSubmit = (event) => {
2478
+ event.preventDefault();
2479
+ if (!user) {
2480
+ return;
2481
+ }
2482
+ const { currentPassword, newPassword } = formValues;
2483
+ if (errorMessage) {
2484
+ setErrorMessage(null);
2485
+ }
2486
+ ui.changePassword({ currentPassword, newPassword })
2487
+ .then(() => {
2488
+ // notify success to the parent
2489
+ onSuccess?.();
2490
+ })
2491
+ .catch((e) => {
2492
+ const error = e;
2493
+ if (error.message)
2494
+ setErrorMessage(error.message);
2495
+ onError?.(error); // notify error to the parent
2496
+ });
2497
+ };
2498
+ // Return null if Auth.getgetCurrentUser is still in progress
2499
+ if (isLoading) {
2500
+ return null;
2501
+ }
2502
+ // Return null if user isn't authenticated in the first place
2503
+ if (!user) {
2504
+ logger$2.warn('<ChangePassword /> requires user to be authenticated.');
2505
+ return null;
2506
+ }
2507
+ return (React__default["default"].createElement(Field.View, { as: "form", className: ComponentClassName.ChangePassword, onSubmit: handleSubmit },
2508
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
2509
+ React__default["default"].createElement(CurrentPasswordField, { autoComplete: "current-password", isRequired: true, label: currentPasswordFieldLabel, name: "currentPassword", onBlur: handleBlur, onChange: handleChange }),
2510
+ React__default["default"].createElement(NewPasswordField, { autoComplete: "new-password", fieldValidationErrors: validationError?.newPassword, isRequired: true, label: newPasswordFieldLabel, name: "newPassword", onBlur: handleBlur, onChange: handleChange }),
2511
+ React__default["default"].createElement(ConfirmPasswordField, { autoComplete: "new-password", fieldValidationErrors: validationError?.confirmPassword, isRequired: true, label: confirmPasswordFieldLabel, name: "confirmPassword", onBlur: handleBlur, onChange: handleChange }),
2512
+ React__default["default"].createElement(SubmitButton, { isDisabled: isDisabled, type: "submit" }, updatePasswordButtonText),
2513
+ errorMessage ? React__default["default"].createElement(ErrorMessage, null, errorMessage) : null)));
2514
+ }
2515
+ ChangePassword.CurrentPasswordField = DEFAULTS$1.CurrentPasswordField;
2516
+ ChangePassword.NewPasswordField = DEFAULTS$1.NewPasswordField;
2517
+ ChangePassword.ConfirmPasswordField = DEFAULTS$1.ConfirmPasswordField;
2518
+ ChangePassword.SubmitButton = DEFAULTS$1.SubmitButton;
2519
+ ChangePassword.ErrorMessage = DEFAULTS$1.ErrorMessage;
2520
+
2521
+ const DefaultWarningView = ({ displayText: overrideDisplayText, isDisabled, onCancel, onConfirm, }) => {
2522
+ // translations
2523
+ const displayText = {
2524
+ ...defaultDeleteUserDisplayText,
2525
+ ...overrideDisplayText,
2526
+ };
2527
+ const { cancelButtonText, confirmDeleteButtonText, warningText } = displayText;
2528
+ return (React__default["default"].createElement(Card, null,
2529
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
2530
+ React__default["default"].createElement(Field.Text, { color: "font.error" }, warningText),
2531
+ React__default["default"].createElement(Field.Flex, null,
2532
+ React__default["default"].createElement(Field.Button, { variation: "link", onClick: onCancel, isDisabled: isDisabled }, cancelButtonText),
2533
+ React__default["default"].createElement(Field.Button, { variation: "destructive", onClick: onConfirm, isDisabled: isDisabled }, confirmDeleteButtonText)))));
2534
+ };
2535
+ const DefaultDeleteButton = (props) => (React__default["default"].createElement(Field.Button, { ...props, variation: "warning" }));
2536
+ const DEFAULTS = {
2537
+ ErrorMessage: DefaultErrorMessage,
2538
+ DeleteButton: DefaultDeleteButton,
2539
+ WarningView: DefaultWarningView,
2540
+ };
2541
+
2542
+ const logger$1 = ui.getLogger('AccountSettings');
2543
+ function DeleteUser({ components, displayText: overrideDisplayText, handleDelete, onError, onSuccess, }) {
2544
+ const [state, setState] = React__default["default"].useState('IDLE');
2545
+ const [errorMessage, setErrorMessage] = React__default["default"].useState(null);
2546
+ uiReactCore.useSetUserAgent({
2547
+ componentName: 'DeleteUser',
2548
+ packageName: 'react',
2549
+ version: VERSION,
2550
+ });
2551
+ // translations
2552
+ const displayText = {
2553
+ ...defaultDeleteUserDisplayText,
2554
+ ...overrideDisplayText,
2555
+ };
2556
+ const { deleteAccountButtonText } = displayText;
2557
+ const { user, isLoading } = Field.useAuth();
2558
+ // subcomponents
2559
+ const { ErrorMessage, DeleteButton, WarningView } = React__default["default"].useMemo(() => ({ ...DEFAULTS, ...(components ?? {}) }), [components]);
2560
+ const startConfirmation = (event) => {
2561
+ event.preventDefault();
2562
+ setState('CONFIRMATION');
2563
+ };
2564
+ const runDeleteUser = React__default["default"].useCallback(async () => {
2565
+ if (!user) {
2566
+ return;
2567
+ }
2568
+ setState('DELETING');
2569
+ if (errorMessage) {
2570
+ setErrorMessage(null);
2571
+ }
2572
+ try {
2573
+ if (handleDelete) {
2574
+ /*
2575
+ * run custom delete handler, if provided. We pass `user` so that
2576
+ * developer can do whichever cleanup with the user object they wish.
2577
+ */
2578
+ await handleDelete(user);
2579
+ }
2580
+ else {
2581
+ // else, run default deleteUser function.
2582
+ await ui.deleteUser();
2583
+ }
2584
+ setState('DONE');
2585
+ onSuccess?.();
2586
+ }
2587
+ catch (e) {
2588
+ const error = e;
2589
+ setState('ERROR');
2590
+ setErrorMessage(error.message);
2591
+ onError?.(error);
2592
+ }
2593
+ }, [errorMessage, handleDelete, onError, onSuccess, user]);
2594
+ // called when end user cancels account deletion confirmation
2595
+ const handleCancel = React__default["default"].useCallback(() => {
2596
+ setState('IDLE');
2597
+ }, []);
2598
+ const handleConfirmDelete = React__default["default"].useCallback(() => {
2599
+ runDeleteUser();
2600
+ }, [runDeleteUser]);
2601
+ // Return null if Auth.getgetCurrentUser is still in progress
2602
+ if (isLoading) {
2603
+ return null;
2604
+ }
2605
+ // Return null if user isn't authenticated
2606
+ if (!user) {
2607
+ logger$1.warn('<DeleteUser /> requires user to be authenticated.');
2608
+ return null;
2609
+ }
2610
+ // Return null if delete user was successful
2611
+ if (state === 'DONE') {
2612
+ return null;
2613
+ }
2614
+ return (React__default["default"].createElement(Field.Flex, { className: ComponentClassName.DeleteUser, direction: "column" },
2615
+ React__default["default"].createElement(DeleteButton, { isDisabled: state === 'CONFIRMATION' || state === 'DELETING', onClick: startConfirmation }, deleteAccountButtonText),
2616
+ state === 'CONFIRMATION' || state === 'DELETING' ? (React__default["default"].createElement(WarningView, { onCancel: handleCancel, isDisabled: state === 'DELETING', onConfirm: handleConfirmDelete })) : null,
2617
+ errorMessage ? React__default["default"].createElement(ErrorMessage, null, errorMessage) : null));
2618
+ }
2619
+ DeleteUser.ErrorMessage = DEFAULTS.ErrorMessage;
2620
+ DeleteUser.DeleteButton = DEFAULTS.DeleteButton;
2621
+ DeleteUser.WarningView = DEFAULTS.WarningView;
2622
+
2623
+ var AccountSettings = { ChangePassword, DeleteUser };
2624
+
2625
+ /**
2626
+ * Logs a deprecation warning `message` to the console.
2627
+ */
2628
+ const useDeprecationWarning = ({ message, shouldWarn: _shouldWarn, }) => {
2629
+ const shouldWarn = _shouldWarn &&
2630
+ // show message on builds without Node `process` polyfill
2631
+ // or with process.env.NODE_ENV not production
2632
+ (typeof process === 'undefined' ||
2633
+ (process && process.env.NODE_ENV !== 'production'));
2634
+ uiReactCore.useDeprecationWarning({ message, shouldWarn });
2635
+ };
2636
+
2637
+ const CustomComponentsContext =
2638
+ // @ts-ignore
2639
+ React__namespace.createContext(null);
2640
+ const useCustomComponents = () => {
2641
+ const context = React__namespace.useContext(CustomComponentsContext);
2642
+ if (!context) {
2643
+ throw new Error('`useCustomComponents` cannot be used outside of a `CustomComponentsContext.Provider`');
2644
+ }
2645
+ return context;
2646
+ };
2647
+
2648
+ // TODO replace usage of this util with the `isSignInOrSignUpRoute` util in v3.
2649
+ // Currently `hasTabs` always returns `undefined` as the right condition always
2650
+ // resolves to truthy. This prevents the "data-amplify-router-content" attribute
2651
+ // from being applied below. Fixing it will cause consumer snapshot tests to break,
2652
+ // so wait to update.
2653
+ const hasTabs = (route) => {
2654
+ return route === 'signIn' || 'signUp';
2655
+ };
2656
+ function RouteContainer({ children, className, variation = 'default', }) {
2657
+ const { route } = uiReactCore.useAuthenticator(({ route }) => [route]);
2658
+ const {
2659
+ // @ts-ignore
2660
+ components: { Header, Footer }, } = useCustomComponents();
2661
+ return (React__default["default"].createElement(Field.View, { className: className, "data-amplify-authenticator": "", "data-variation": variation },
2662
+ React__default["default"].createElement(Field.View, { "data-amplify-container": "" },
2663
+ React__default["default"].createElement(Header, null),
2664
+ React__default["default"].createElement(Field.View, { "data-amplify-router": "", "data-amplify-router-content": hasTabs(route) ? undefined : '' }, children),
2665
+ React__default["default"].createElement(Footer, null))));
2666
+ }
2667
+
2668
+ const getFormDataFromEvent = (event) => {
2669
+ const formData = new FormData(event.target);
2670
+ return Object.fromEntries(formData);
2671
+ };
2672
+
2673
+ function useFormHandlers() {
2674
+ const { submitForm, updateBlur, updateForm } = uiReactCore.useAuthenticator((context) => [
2675
+ context.submitForm,
2676
+ context.updateBlur,
2677
+ context.updateForm,
2678
+ ]);
2679
+ const handleBlur = React.useCallback(({ target: { name } }) => {
2680
+ updateBlur({ name });
2681
+ }, [updateBlur]);
2682
+ // @TODO: align multiple input type handling with react docs example for 3.0 release
2683
+ // example: https://reactjs.org/docs/forms.html#handling-multiple-inputs
2684
+ const handleChange = React.useCallback(({ target: { checked, name, type, value }, }) => {
2685
+ const isUncheckedCheckbox = type === 'checkbox' && !checked;
2686
+ updateForm({
2687
+ name,
2688
+ value: isUncheckedCheckbox ? undefined : value,
2689
+ });
2690
+ }, [updateForm]);
2691
+ const handleSubmit = React.useCallback((event) => {
2692
+ event.preventDefault();
2693
+ submitForm(getFormDataFromEvent(event));
2694
+ }, [submitForm]);
2695
+ return { handleBlur, handleChange, handleSubmit };
2696
+ }
2697
+
2698
+ const RemoteErrorMessage = () => {
2699
+ const { error } = uiReactCore.useAuthenticator((context) => [context.error]);
2700
+ return (React__default["default"].createElement(React__default["default"].Fragment, null, error ? (React__default["default"].createElement(Alert, { variation: "error", isDismissible: true }, ui.translate(error))) : null));
2701
+ };
2702
+
2703
+ function FormField({ autocomplete: autoComplete, dialCode, name, type, ...props }) {
2704
+ const { validationErrors } = uiReactCore.useAuthenticator(({ validationErrors }) => [
2705
+ validationErrors,
2706
+ ]);
2707
+ const errors = React__namespace.useMemo(() => ui.getErrors(validationErrors[name]), [name, validationErrors]);
2708
+ const hasError = errors?.length > 0;
2709
+ const errorId = useStableId();
2710
+ const ariaDescribedBy = hasError ? errorId : undefined;
2711
+ if (type === 'tel') {
2712
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2713
+ React__namespace.createElement(PhoneNumberField, { ...props, name: name, defaultDialCode: dialCode, dialCodeName: "country_code", autoComplete: autoComplete, hasError: hasError, "aria-describedby": ariaDescribedBy }),
2714
+ React__namespace.createElement(ValidationErrors, { dataAttr: "data-amplify-sign-up-errors", errors: errors, id: errorId })));
2715
+ }
2716
+ else if (type === 'password') {
2717
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2718
+ React__namespace.createElement(PasswordField, { ...props, name: name, autoComplete: autoComplete, hasError: hasError, "aria-describedby": ariaDescribedBy }),
2719
+ React__namespace.createElement(ValidationErrors, { dataAttr: "data-amplify-sign-up-errors", errors: errors, id: errorId })));
2720
+ }
2721
+ else {
2722
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2723
+ React__namespace.createElement(TextField, { ...props, name: name, autoComplete: autoComplete, hasError: hasError, type: type, "aria-describedby": ariaDescribedBy }),
2724
+ React__namespace.createElement(ValidationErrors, { dataAttr: "data-amplify-sign-up-errors", errors: errors, id: errorId })));
2725
+ }
2726
+ }
2727
+
2728
+ function FormFields() {
2729
+ const { fields } = uiReactCore.useAuthenticator(({ route }) => [route]);
2730
+ const formFields = React__namespace.useRef(fields.map((field, index) => (React__namespace.createElement(FormField
2731
+ // use index for key, field order is static
2732
+ , {
2733
+ // use index for key, field order is static
2734
+ key: index, ...field })))).current;
2735
+ return React__namespace.createElement(React__namespace.Fragment, null, formFields);
2736
+ }
2737
+
2738
+ const { getDeliveryMessageText, getDeliveryMethodText, getConfirmingText: getConfirmingText$1, getConfirmText: getConfirmText$1, getResendCodeText: getResendCodeText$1, } = ui.authenticatorTextUtil;
2739
+ function ConfirmSignUp({ className, variation, }) {
2740
+ const { isPending, resendCode, codeDeliveryDetails } = uiReactCore.useAuthenticator((context) => [
2741
+ context.isPending,
2742
+ context.resendCode,
2743
+ context.codeDeliveryDetails,
2744
+ ]);
2745
+ const { handleChange, handleSubmit } = useFormHandlers();
2746
+ const { components: {
2747
+ // @ts-ignore
2748
+ ConfirmSignUp: { Header = ConfirmSignUp.Header, Footer = ConfirmSignUp.Footer, }, }, } = useCustomComponents();
2749
+ return (
2750
+ // TODO Automatically add these namespaces again from `useAmplify`
2751
+ React__default["default"].createElement(RouteContainer, { className: className, variation: variation },
2752
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-confirmsignup": "", method: "post", onChange: handleChange, onSubmit: handleSubmit },
2753
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
2754
+ React__default["default"].createElement(Header, null),
2755
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
2756
+ React__default["default"].createElement(Field.Text, { className: "amplify-authenticator__subtitle" }, getDeliveryMessageText(codeDeliveryDetails)),
2757
+ React__default["default"].createElement(FormFields, null),
2758
+ React__default["default"].createElement(RemoteErrorMessage, null),
2759
+ React__default["default"].createElement(Field.Button, { variation: "primary", isDisabled: isPending, type: "submit", loadingText: getConfirmingText$1(), isLoading: isPending, fontWeight: "normal" }, getConfirmText$1()),
2760
+ React__default["default"].createElement(Field.Button, { onClick: resendCode, type: "button", fontWeight: "normal" }, getResendCodeText$1())),
2761
+ React__default["default"].createElement(Footer, null)))));
2762
+ }
2763
+ const DefaultHeader = () => {
2764
+ const { codeDeliveryDetails } = uiReactCore.useAuthenticator((context) => [
2765
+ context.codeDeliveryDetails,
2766
+ ]);
2767
+ return (React__default["default"].createElement(Heading, { level: 4 }, getDeliveryMethodText(codeDeliveryDetails)));
2768
+ };
2769
+ ConfirmSignUp.Header = DefaultHeader;
2770
+ ConfirmSignUp.Footer = function Footer() {
2771
+ // @ts-ignore
2772
+ return null;
2773
+ };
2774
+
2775
+ const { getChangePasswordText, getChangingText, getBackToSignInText: getBackToSignInText$2 } = ui.authenticatorTextUtil;
2776
+ const ForceNewPassword = ({ className, variation, }) => {
2777
+ const { isPending, toSignIn } = uiReactCore.useAuthenticator((context) => [
2778
+ context.isPending,
2779
+ context.toSignIn,
2780
+ ]);
2781
+ const { handleBlur, handleChange, handleSubmit } = useFormHandlers();
2782
+ const { components: {
2783
+ // @ts-ignore
2784
+ ForceNewPassword: { FormFields = ForceNewPassword.FormFields, Header = ForceNewPassword.Header, Footer = ForceNewPassword.Footer, }, }, } = useCustomComponents();
2785
+ return (React__default["default"].createElement(RouteContainer, { className: className, variation: variation },
2786
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-forcenewpassword": "", method: "post", onChange: handleChange, onSubmit: handleSubmit, onBlur: handleBlur },
2787
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
2788
+ React__default["default"].createElement(Header, null),
2789
+ React__default["default"].createElement(FormFields, null),
2790
+ React__default["default"].createElement(RemoteErrorMessage, null),
2791
+ React__default["default"].createElement(Field.Button, { isDisabled: isPending, type: "submit", variation: "primary", isLoading: isPending, loadingText: getChangingText(), fontWeight: "normal" }, getChangePasswordText()),
2792
+ React__default["default"].createElement(Field.Button, { onClick: toSignIn, type: "button", fontWeight: "normal", variation: "link", size: "small" }, getBackToSignInText$2()),
2793
+ React__default["default"].createElement(Footer, null)))));
2794
+ };
2795
+ ForceNewPassword.FormFields = function FormFields$1() {
2796
+ return React__default["default"].createElement(FormFields, null);
2797
+ };
2798
+ ForceNewPassword.Header = function Header() {
2799
+ return React__default["default"].createElement(Heading, { level: 4 }, getChangePasswordText());
2800
+ };
2801
+ ForceNewPassword.Footer = function Footer() {
2802
+ return null;
2803
+ };
2804
+
2805
+ const { getConfirmText, getConfirmingText, getBackToSignInText: getBackToSignInText$1 } = ui.authenticatorTextUtil;
2806
+ const ConfirmSignInFooter = () => {
2807
+ const { isPending, toSignIn } = uiReactCore.useAuthenticator((context) => [
2808
+ context.isPending,
2809
+ context.toSignIn,
2810
+ ]);
2811
+ return (React__default["default"].createElement(Field.Flex, { direction: "column" },
2812
+ React__default["default"].createElement(Field.Button, { isDisabled: isPending, type: "submit", variation: "primary", fontWeight: "normal", isLoading: isPending, loadingText: getConfirmingText() }, getConfirmText()),
2813
+ React__default["default"].createElement(Field.Button, { onClick: toSignIn, type: "button", variation: "link", fontWeight: "normal", size: "small" }, getBackToSignInText$1())));
2814
+ };
2815
+
2816
+ const logger = new utils.ConsoleLogger('SetupTotp-logger');
2817
+ const { getSetupTotpText, getCopiedText, getLoadingText } = ui.authenticatorTextUtil;
2818
+ const SetupTotp = ({ className, variation, }) => {
2819
+ const { totpSecretCode, isPending, username, QRFields } = uiReactCore.useAuthenticator((context) => [context.isPending, context.totpSecretCode, context.username]);
2820
+ const { handleChange, handleSubmit } = useFormHandlers();
2821
+ const { components: {
2822
+ // @ts-ignore
2823
+ SetupTotp: { Header = SetupTotp.Header, Footer = SetupTotp.Footer }, }, } = useCustomComponents();
2824
+ const [isLoading, setIsLoading] = React__namespace.useState(true);
2825
+ const [qrCode, setQrCode] = React__namespace.useState();
2826
+ const [copyTextLabel, setCopyTextLabel] = React__namespace.useState('COPY');
2827
+ const { totpIssuer = 'AWSCognito', totpUsername = username } = QRFields ?? {};
2828
+ const generateQRCode = React__namespace.useCallback(async () => {
2829
+ try {
2830
+ const totpCode = ui.getTotpCodeURL(totpIssuer, totpUsername, totpSecretCode);
2831
+ const qrCodeImageSource = await QRCode__default["default"].toDataURL(totpCode);
2832
+ setQrCode(qrCodeImageSource);
2833
+ }
2834
+ catch (error) {
2835
+ logger.error(error);
2836
+ }
2837
+ finally {
2838
+ setIsLoading(false);
2839
+ }
2840
+ }, [totpIssuer, totpUsername, totpSecretCode]);
2841
+ React__namespace.useEffect(() => {
2842
+ if (!qrCode) {
2843
+ generateQRCode();
2844
+ }
2845
+ }, [generateQRCode, qrCode]);
2846
+ const copyText = () => {
2847
+ navigator.clipboard.writeText(totpSecretCode);
2848
+ setCopyTextLabel(getCopiedText());
2849
+ };
2850
+ return (React__namespace.createElement(RouteContainer, { className: className, variation: variation },
2851
+ React__namespace.createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-setup-totp": "", method: "post", onChange: handleChange, onSubmit: handleSubmit },
2852
+ React__namespace.createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
2853
+ React__namespace.createElement(Header, null),
2854
+ React__namespace.createElement(Field.Flex, { direction: "column" },
2855
+ isLoading ? (React__namespace.createElement("p", null,
2856
+ getLoadingText(),
2857
+ "\u2026")) : (React__namespace.createElement("img", { "data-amplify-qrcode": true, src: qrCode, alt: "qr code", width: "228", height: "228" })),
2858
+ React__namespace.createElement(Field.Flex, { "data-amplify-copy": true },
2859
+ React__namespace.createElement("div", null, totpSecretCode),
2860
+ React__namespace.createElement(Field.Flex, { "data-amplify-copy-svg": true, onClick: copyText },
2861
+ React__namespace.createElement("div", { "data-amplify-copy-tooltip": true }, copyTextLabel),
2862
+ React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" },
2863
+ React__namespace.createElement("path", { d: "M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM15 5H8C6.9 5 6.01 5.9 6.01 7L6 21C6 22.1 6.89 23 7.99 23H19C20.1 23 21 22.1 21 21V11L15 5ZM8 21V7H14V12H19V21H8Z" })))),
2864
+ React__namespace.createElement(FormFields, null),
2865
+ React__namespace.createElement(RemoteErrorMessage, null)),
2866
+ React__namespace.createElement(ConfirmSignInFooter, null),
2867
+ React__namespace.createElement(Footer, null)))));
2868
+ };
2869
+ SetupTotp.Header = function Header() {
2870
+ return React__namespace.createElement(Heading, { level: 3 }, getSetupTotpText());
2871
+ };
2872
+ SetupTotp.Footer = function Footer() {
2873
+ // @ts-ignore
2874
+ return null;
2875
+ };
2876
+
2877
+ const { getSubmitText, getSubmittingText } = ui.authenticatorTextUtil;
2878
+ const TwoButtonSubmitFooter = (props) => {
2879
+ const { cancelButtonSendType, cancelButtonText, submitButtonText } = props;
2880
+ const { isPending, resendCode, skipVerification, toSignIn } = uiReactCore.useAuthenticator((context) => [context.isPending]);
2881
+ const onClick = () => {
2882
+ switch (cancelButtonSendType) {
2883
+ case 'SKIP':
2884
+ skipVerification();
2885
+ break;
2886
+ case 'RESEND':
2887
+ resendCode();
2888
+ break;
2889
+ case 'SIGN_IN':
2890
+ toSignIn();
2891
+ break;
2892
+ default:
2893
+ return;
2894
+ }
2895
+ };
2896
+ const defaultSubmitText = isPending ? (React__default["default"].createElement(React__default["default"].Fragment, null,
2897
+ getSubmittingText(),
2898
+ "\u2026")) : (React__default["default"].createElement(React__default["default"].Fragment, null, getSubmitText()));
2899
+ const submitText = submitButtonText ?? defaultSubmitText;
2900
+ return (React__default["default"].createElement(Field.Flex, { direction: "column" },
2901
+ React__default["default"].createElement(Field.Button, { fontWeight: "normal", variation: "primary", isDisabled: isPending, type: "submit" }, submitText),
2902
+ React__default["default"].createElement(Field.Button, { onClick: onClick, type: "button", variation: "link", fontWeight: "normal", size: "small" }, cancelButtonText)));
2903
+ };
2904
+
2905
+ const AppleIcon = () => {
2906
+ return (React__default["default"].createElement("svg", { "aria-label": "Apple icon", className: "amplify-icon federated-sign-in-icon", fill: "#000", preserveAspectRatio: "xMidYMid", stroke: "#000", strokeWidth: "0", viewBox: "0 0 1024 1024", xmlns: "http://www.w3.org/2000/svg" },
2907
+ React__default["default"].createElement("path", { d: "M747.4 535.7c-.4-68.2 30.5-119.6 92.9-157.5-34.9-50-87.7-77.5-157.3-82.8-65.9-5.2-138 38.4-164.4 38.4-27.9 0-91.7-36.6-141.9-36.6C273.1 298.8 163 379.8 163 544.6c0 48.7 8.9 99 26.7 150.8 23.8 68.2 109.6 235.3 199.1 232.6 46.8-1.1 79.9-33.2 140.8-33.2 59.1 0 89.7 33.2 141.9 33.2 90.3-1.3 167.9-153.2 190.5-221.6-121.1-57.1-114.6-167.2-114.6-170.7zm-105.1-305c50.7-60.2 46.1-115 44.6-134.7-44.8 2.6-96.6 30.5-126.1 64.8-32.5 36.8-51.6 82.3-47.5 133.6 48.4 3.7 92.6-21.2 129-63.7z" })));
2908
+ };
2909
+ const GoogleIcon = () => {
2910
+ return (React__default["default"].createElement("svg", { "aria-label": "Google icon", className: "amplify-icon federated-sign-in-icon", viewBox: "0 0 256 262", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid" },
2911
+ React__default["default"].createElement("path", { d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027", fill: "#4285F4" }),
2912
+ React__default["default"].createElement("path", { d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1", fill: "#34A853" }),
2913
+ React__default["default"].createElement("path", { d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782", fill: "#FBBC05" }),
2914
+ React__default["default"].createElement("path", { d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251", fill: "#EB4335" })));
2915
+ };
2916
+ const FacebookIcon = () => {
2917
+ return (React__default["default"].createElement(Field.Icon, { className: "federated-sign-in-icon", ariaLabel: "Facebook icon", viewBox: { minX: 0, minY: 0, width: 279, height: 538 }, pathData: "M82.3409742,538 L82.3409742,292.936652 L0,292.936652 L0,196.990154 L82.2410458,196.990154 L82.2410458,126.4295 C82.2410458,44.575144 132.205229,0 205.252865,0 C240.227794,0 270.306232,2.59855099 279,3.79788222 L279,89.2502322 L228.536175,89.2502322 C188.964542,89.2502322 181.270057,108.139699 181.270057,135.824262 L181.270057,196.89021 L276.202006,196.89021 L263.810888,292.836708 L181.16913,292.836708 L181.16913,538 L82.3409742,538 Z", fill: "#1877F2" }));
2918
+ };
2919
+ const AmazonIcon = () => {
2920
+ return (React__default["default"].createElement("svg", { "aria-label": "Amazon icon", className: "amplify-icon federated-sign-in-icon", viewBox: "0 0 243 264", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid" },
2921
+ React__default["default"].createElement("path", { d: "M230.826 208.039C227.468 203.683 208.551 205.982 200.056 206.998C197.471 207.321 197.076 205.042 199.407 203.405C214.475 192.665 239.201 195.766 242.082 199.364C244.966 202.982 241.337 228.071 227.173 240.049C225.001 241.888 222.93 240.904 223.898 238.468C227.077 230.431 234.205 212.419 230.826 208.039ZM123.769 264C71.0234 264 39.0764 241.955 14.7853 217.542C9.97339 212.706 3.71799 206.296 0.311513 200.691C-1.09773 198.372 2.59096 195.022 5.04421 196.844C35.239 219.268 79.1012 239.538 122.53 239.538C151.82 239.538 188.046 227.47 217.669 214.868C222.147 212.966 222.147 219.18 221.512 221.061C221.183 222.032 206.515 236.221 186.247 247.047C167.304 257.166 143.397 264 123.769 264Z", fill: "#F2541B" }),
2922
+ React__default["default"].createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M142.943 111.185C142.943 124.756 143.268 136.054 136.406 148.123C130.856 157.913 122.027 163.95 112.222 163.95C98.8288 163.95 90.9806 153.772 90.9806 138.693C90.9806 109.036 117.677 103.647 142.943 103.647V111.185ZM178.166 196.081C175.858 198.15 171.635 198.22 169.914 196.894C157.974 187.684 149.89 173.688 149.89 173.688C130.706 193.156 117.127 199 92.2879 199C62.8772 199 40 180.905 40 144.729C40 116.461 55.3552 97.2408 77.2563 87.823C96.2094 79.5256 122.684 78.0173 142.943 75.7517C142.943 75.7517 144.633 53.933 138.699 45.9806C134.098 39.8163 126.272 36.9329 119.089 36.9329C106.127 36.8829 93.61 43.9051 91.1262 57.4188C90.4136 61.2829 87.5533 64.5261 84.54 64.206L51.0823 60.5922C48.5156 60.2951 45.0381 57.6639 45.8636 53.3081C53.644 12.3684 90.7373 0 123.989 0C140.983 0 163.21 4.51651 176.608 17.3349C193.597 33.1648 191.969 54.2755 191.969 77.2722V131.51C191.969 147.835 198.768 154.987 205.151 163.775C207.376 166.953 207.886 170.714 205.04 173.032C197.902 178.999 178.166 196.081 178.166 196.081Z", fill: "#F2541B" })));
2923
+ };
2924
+ const FederatedSignInButton = (props) => {
2925
+ const { icon, provider, text } = props;
2926
+ const { toFederatedSignIn } = uiReactCore.useAuthenticator();
2927
+ const handleClick = (event) => {
2928
+ event.preventDefault();
2929
+ toFederatedSignIn({ provider });
2930
+ };
2931
+ let iconComponent;
2932
+ if (icon === 'facebook') {
2933
+ iconComponent = React__default["default"].createElement(FacebookIcon, null);
2934
+ }
2935
+ else if (icon === 'google') {
2936
+ iconComponent = React__default["default"].createElement(GoogleIcon, null);
2937
+ }
2938
+ else if (icon === 'amazon') {
2939
+ iconComponent = React__default["default"].createElement(AmazonIcon, null);
2940
+ }
2941
+ else if (icon === 'apple') {
2942
+ iconComponent = React__default["default"].createElement(AppleIcon, null);
2943
+ }
2944
+ return (React__default["default"].createElement(Field.Button, { onClick: handleClick, className: "federated-sign-in-button", fontWeight: "normal", gap: "1rem" },
2945
+ iconComponent,
2946
+ React__default["default"].createElement(Field.Text, { as: "span" }, text)));
2947
+ };
2948
+
2949
+ const { getSignInWithFederationText, getOrText } = ui.authenticatorTextUtil;
2950
+ function FederatedSignIn() {
2951
+ const { route, socialProviders } = uiReactCore.useAuthenticator(({ route, socialProviders }) => [route, socialProviders]);
2952
+ if (socialProviders.length === 0) {
2953
+ // @ts-ignore
2954
+ return null;
2955
+ }
2956
+ return (React__default["default"].createElement(Field.Flex, { direction: "column", padding: `0 0 1rem 0`, className: "federated-sign-in-container" },
2957
+ socialProviders.map((provider) => {
2958
+ switch (provider) {
2959
+ case 'amazon':
2960
+ return (React__default["default"].createElement(FederatedSignInButton, { icon: "amazon", key: provider, provider: ui.FederatedIdentityProviders.Amazon, text: getSignInWithFederationText(route, provider) }));
2961
+ case 'apple':
2962
+ return (React__default["default"].createElement(FederatedSignInButton, { icon: "apple", key: provider, provider: ui.FederatedIdentityProviders.Apple, text: getSignInWithFederationText(route, provider) }));
2963
+ case 'facebook':
2964
+ return (React__default["default"].createElement(FederatedSignInButton, { icon: "facebook", key: provider, provider: ui.FederatedIdentityProviders.Facebook, text: getSignInWithFederationText(route, provider) }));
2965
+ case 'google':
2966
+ return (React__default["default"].createElement(FederatedSignInButton, { icon: "google", key: provider, provider: ui.FederatedIdentityProviders.Google, text: getSignInWithFederationText(route, provider) }));
2967
+ default:
2968
+ // eslint-disable-next-line no-console
2969
+ console.error(`Authenticator does not support ${provider}. Please open an issue: https://github.com/aws-amplify/amplify-ui/issues/choose`);
2970
+ }
2971
+ }),
2972
+ React__default["default"].createElement(Divider, { size: "small", label: getOrText() })));
2973
+ }
2974
+
2975
+ const { getSignInText, getSigningInText, getForgotPasswordText } = ui.authenticatorTextUtil;
2976
+ function SignIn() {
2977
+ const { isPending } = uiReactCore.useAuthenticator((context) => [context.isPending]);
2978
+ const { handleChange, handleSubmit } = useFormHandlers();
2979
+ const { components: {
2980
+ // @ts-ignore
2981
+ SignIn: { Header = SignIn.Header, Footer = SignIn.Footer }, }, } = useCustomComponents();
2982
+ return (React__default["default"].createElement(Field.View, null,
2983
+ React__default["default"].createElement(Header, null),
2984
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-signin": "", method: "post", onSubmit: handleSubmit, onChange: handleChange },
2985
+ React__default["default"].createElement(FederatedSignIn, null),
2986
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
2987
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
2988
+ React__default["default"].createElement(VisuallyHidden, null,
2989
+ React__default["default"].createElement("legend", null, getSignInText())),
2990
+ React__default["default"].createElement(FormFields, null)),
2991
+ React__default["default"].createElement(RemoteErrorMessage, null),
2992
+ React__default["default"].createElement(Field.Button, { isDisabled: isPending, isFullWidth: true, type: "submit", variation: "primary", isLoading: isPending, loadingText: getSigningInText() }, getSignInText()))),
2993
+ React__default["default"].createElement(Footer, null)));
2994
+ }
2995
+ const DefaultFooter = () => {
2996
+ const { toForgotPassword } = uiReactCore.useAuthenticator((context) => [
2997
+ context.toForgotPassword,
2998
+ ]);
2999
+ return (React__default["default"].createElement(Field.View, { "data-amplify-footer": "" },
3000
+ React__default["default"].createElement(Field.Button, { fontWeight: "normal", onClick: toForgotPassword, size: "small", variation: "link" }, getForgotPasswordText())));
3001
+ };
3002
+ SignIn.Footer = DefaultFooter;
3003
+ SignIn.Header = function Header() {
3004
+ // @ts-ignore
3005
+ return null;
3006
+ };
3007
+
3008
+ const { getCreateAccountText, getCreatingAccountText } = ui.authenticatorTextUtil;
3009
+ function SignUp() {
3010
+ const { hasValidationErrors, isPending } = uiReactCore.useAuthenticator((context) => [
3011
+ context.hasValidationErrors,
3012
+ context.isPending,
3013
+ ]);
3014
+ const { handleChange, handleBlur, handleSubmit } = useFormHandlers();
3015
+ const { components: {
3016
+ // @ts-ignore
3017
+ SignUp: { Header = SignUp.Header, FormFields = SignUp.FormFields, Footer = SignUp.Footer, }, }, } = useCustomComponents();
3018
+ return (React__default["default"].createElement(Field.View, null,
3019
+ React__default["default"].createElement(Header, null),
3020
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-signup": "", method: "post", onChange: handleChange, onSubmit: handleSubmit, onBlur: handleBlur },
3021
+ React__default["default"].createElement(FederatedSignIn, null),
3022
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
3023
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
3024
+ React__default["default"].createElement(FormFields, null),
3025
+ React__default["default"].createElement(RemoteErrorMessage, null)),
3026
+ React__default["default"].createElement(Field.Button, { isDisabled: hasValidationErrors || isPending, isFullWidth: true, type: "submit", variation: "primary", isLoading: isPending, loadingText: getCreatingAccountText() }, getCreateAccountText()))),
3027
+ React__default["default"].createElement(Footer, null)));
3028
+ }
3029
+ SignUp.Header = function Header() {
3030
+ // @ts-ignore
3031
+ return null;
3032
+ };
3033
+ SignUp.FormFields = function FormFields$1() {
3034
+ return React__default["default"].createElement(FormFields, null);
3035
+ };
3036
+ SignUp.Footer = function Footer() {
3037
+ // @ts-ignore
3038
+ return null;
3039
+ };
3040
+
3041
+ const { getSignInTabText, getSignUpTabText } = ui.authenticatorTextUtil;
3042
+ const SignInSignUpTabs = ({ className, hideSignUp, variation, }) => {
3043
+ const { route, toSignIn, toSignUp } = uiReactCore.useAuthenticator((context) => [
3044
+ context.route,
3045
+ context.toSignIn,
3046
+ context.toSignUp,
3047
+ ]);
3048
+ return (React__default["default"].createElement(RouteContainer, { className: className, variation: variation }, hideSignUp ? (React__default["default"].createElement(Field.View, { "data-amplify-router-content": "" }, route === 'signIn' && React__default["default"].createElement(SignIn, null))) : (React__default["default"].createElement(Tabs.Container, { value: route, isLazy: true, onValueChange: () => (route === 'signIn' ? toSignUp() : toSignIn()) },
3049
+ React__default["default"].createElement(Tabs.List, { spacing: "equal", indicatorPosition: "top" },
3050
+ React__default["default"].createElement(Tabs.Item, { value: "signIn" }, getSignInTabText()),
3051
+ React__default["default"].createElement(Tabs.Item, { value: "signUp" }, getSignUpTabText())),
3052
+ React__default["default"].createElement(Tabs.Panel, { value: "signIn", "data-amplify-router-content": "" },
3053
+ React__default["default"].createElement(SignIn, null)),
3054
+ React__default["default"].createElement(Tabs.Panel, { value: "signUp", "data-amplify-router-content": "" },
3055
+ React__default["default"].createElement(SignUp, null))))));
3056
+ };
3057
+
3058
+ const { getAccountRecoveryInfoText: getAccountRecoveryInfoText$1, getSkipText: getSkipText$1 } = ui.authenticatorTextUtil;
3059
+ const ConfirmVerifyUser = ({ className, variation, }) => {
3060
+ const { isPending } = uiReactCore.useAuthenticator((context) => [context.isPending]);
3061
+ const { handleChange, handleSubmit } = useFormHandlers();
3062
+ const { components: {
3063
+ // @ts-ignore
3064
+ ConfirmVerifyUser: { Header = ConfirmVerifyUser.Header, Footer = ConfirmVerifyUser.Footer, }, }, } = useCustomComponents();
3065
+ return (React__default["default"].createElement(RouteContainer, { className: className, variation: variation },
3066
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-confirmverifyuser": "", method: "post", onChange: handleChange, onSubmit: handleSubmit },
3067
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
3068
+ React__default["default"].createElement(Header, null),
3069
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
3070
+ React__default["default"].createElement(FormFields, null)),
3071
+ React__default["default"].createElement(RemoteErrorMessage, null),
3072
+ React__default["default"].createElement(TwoButtonSubmitFooter, { cancelButtonText: getSkipText$1(), cancelButtonSendType: "SKIP" }),
3073
+ React__default["default"].createElement(Footer, null)))));
3074
+ };
3075
+ ConfirmVerifyUser.Header = function Header() {
3076
+ return React__default["default"].createElement(Heading, { level: 3 }, getAccountRecoveryInfoText$1());
3077
+ };
3078
+ ConfirmVerifyUser.Footer = function Footer() {
3079
+ return null;
3080
+ };
3081
+
3082
+ const { getSkipText, getVerifyText, getVerifyContactText, getAccountRecoveryInfoText, } = ui.authenticatorTextUtil;
3083
+ const censorContactInformation = (type, value) => {
3084
+ const translated = ui.translate(type);
3085
+ let newVal = value;
3086
+ if (type === 'Phone Number') {
3087
+ newVal = ui.censorPhoneNumber(value);
3088
+ }
3089
+ else if (type === 'Email') {
3090
+ const splitEmail = value.split('@');
3091
+ const censoredName = ui.censorAllButFirstAndLast(splitEmail[0]);
3092
+ newVal = `${censoredName}@${splitEmail[1]}`;
3093
+ }
3094
+ return `${translated}: ${newVal}`;
3095
+ };
3096
+ const generateRadioGroup = (attributes) => {
3097
+ return Object.entries(attributes).map(([key, value]) => (React__default["default"].createElement(Radio, { name: "unverifiedAttr", value: key, key: key }, censorContactInformation(ui.defaultFormFieldOptions[key].label, value))));
3098
+ };
3099
+ const VerifyUser = ({ className, variation, }) => {
3100
+ const { components: {
3101
+ // @ts-ignore
3102
+ VerifyUser: { Header = VerifyUser.Header, Footer = VerifyUser.Footer }, }, } = useCustomComponents();
3103
+ const { isPending, unverifiedUserAttributes } = uiReactCore.useAuthenticator(({ isPending, unverifiedUserAttributes }) => [
3104
+ isPending,
3105
+ unverifiedUserAttributes,
3106
+ ]);
3107
+ const { handleChange, handleSubmit } = useFormHandlers();
3108
+ const footerSubmitText = isPending ? (React__default["default"].createElement(React__default["default"].Fragment, null, "Verifying\u2026")) : (React__default["default"].createElement(React__default["default"].Fragment, null, getVerifyText()));
3109
+ const verificationRadioGroup = (React__default["default"].createElement(RadioGroupField, { legend: getVerifyContactText(), name: "verify_context", isDisabled: isPending, legendHidden: true }, generateRadioGroup(unverifiedUserAttributes)));
3110
+ return (React__default["default"].createElement(RouteContainer, { className: className, variation: variation },
3111
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-verifyuser": "", method: "post", onChange: handleChange, onSubmit: handleSubmit },
3112
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
3113
+ React__default["default"].createElement(Header, null),
3114
+ verificationRadioGroup,
3115
+ React__default["default"].createElement(RemoteErrorMessage, null),
3116
+ React__default["default"].createElement(TwoButtonSubmitFooter, { cancelButtonText: getSkipText(), cancelButtonSendType: "SKIP", submitButtonText: footerSubmitText }),
3117
+ React__default["default"].createElement(Footer, null)))));
3118
+ };
3119
+ VerifyUser.Header = function Header() {
3120
+ return React__default["default"].createElement(Heading, { level: 3 }, getAccountRecoveryInfoText());
3121
+ };
3122
+ VerifyUser.Footer = function Footer() {
3123
+ // @ts-ignore
3124
+ return null;
3125
+ };
3126
+
3127
+ const { getChallengeText } = ui.authenticatorTextUtil;
3128
+ const ConfirmSignIn = ({ className, variation, }) => {
3129
+ const { isPending } = uiReactCore.useAuthenticator((context) => [context.isPending]);
3130
+ const { handleChange, handleSubmit } = useFormHandlers();
3131
+ const { components: {
3132
+ // @ts-ignore
3133
+ ConfirmSignIn: { Header = ConfirmSignIn.Header, Footer = ConfirmSignIn.Footer, }, }, } = useCustomComponents();
3134
+ return (React__default["default"].createElement(RouteContainer, { className: className, variation: variation },
3135
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-confirmsignin": "", method: "post", onChange: handleChange, onSubmit: handleSubmit },
3136
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
3137
+ React__default["default"].createElement(Header, null),
3138
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
3139
+ React__default["default"].createElement(FormFields, null),
3140
+ React__default["default"].createElement(RemoteErrorMessage, null)),
3141
+ React__default["default"].createElement(ConfirmSignInFooter, null),
3142
+ React__default["default"].createElement(Footer, null)))));
3143
+ };
3144
+ function Header() {
3145
+ const { challengeName } = uiReactCore.useAuthenticator(({ challengeName }) => [
3146
+ challengeName,
3147
+ ]);
3148
+ return React__default["default"].createElement(Heading, { level: 3 }, getChallengeText(challengeName));
3149
+ }
3150
+ ConfirmSignIn.Header = Header;
3151
+ ConfirmSignIn.Footer = function Footer() {
3152
+ // @ts-ignore
3153
+ return null;
3154
+ };
3155
+
3156
+ const { getResendCodeText, getResetYourPasswordText: getResetYourPasswordText$1 } = ui.authenticatorTextUtil;
3157
+ const ConfirmResetPassword = ({ className, variation, }) => {
3158
+ const { isPending } = uiReactCore.useAuthenticator((context) => [context.isPending]);
3159
+ const { handleBlur, handleChange, handleSubmit } = useFormHandlers();
3160
+ const { components: {
3161
+ // @ts-ignore
3162
+ ConfirmResetPassword: { Header = ConfirmResetPassword.Header, Footer = ConfirmResetPassword.Footer, }, }, } = useCustomComponents();
3163
+ return (React__default["default"].createElement(RouteContainer, { className: className, variation: variation },
3164
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-confirmresetpassword": "", method: "post", onSubmit: handleSubmit, onChange: handleChange, onBlur: handleBlur },
3165
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
3166
+ React__default["default"].createElement(Header, null),
3167
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
3168
+ React__default["default"].createElement(FormFields, null)),
3169
+ React__default["default"].createElement(RemoteErrorMessage, null),
3170
+ React__default["default"].createElement(TwoButtonSubmitFooter, { cancelButtonSendType: "RESEND", cancelButtonText: getResendCodeText() }),
3171
+ React__default["default"].createElement(Footer, null)))));
3172
+ };
3173
+ ConfirmResetPassword.Header = function Header() {
3174
+ const headerText = getResetYourPasswordText$1();
3175
+ return React__default["default"].createElement(Heading, { level: 3 }, headerText);
3176
+ };
3177
+ ConfirmResetPassword.Footer = function Footer() {
3178
+ // @ts-ignore
3179
+ return null;
3180
+ };
3181
+
3182
+ const { getBackToSignInText, getSendingText, getSendCodeText, getResetYourPasswordText, } = ui.authenticatorTextUtil;
3183
+ const ForgotPassword = ({ className, variation, }) => {
3184
+ const { isPending } = uiReactCore.useAuthenticator((context) => [context.isPending]);
3185
+ const { handleChange, handleSubmit } = useFormHandlers();
3186
+ const { components: {
3187
+ // @ts-ignore
3188
+ ForgotPassword: { Header = ForgotPassword.Header, Footer = ForgotPassword.Footer, }, }, } = useCustomComponents();
3189
+ return (React__default["default"].createElement(RouteContainer, { className: className, variation: variation },
3190
+ React__default["default"].createElement("form", { "data-amplify-form": "", "data-amplify-authenticator-Forgotpassword": "", method: "post", onChange: handleChange, onSubmit: handleSubmit },
3191
+ React__default["default"].createElement(Field.Flex, { as: "fieldset", direction: "column", isDisabled: isPending },
3192
+ React__default["default"].createElement(Header, null),
3193
+ React__default["default"].createElement(Field.Flex, { direction: "column" },
3194
+ React__default["default"].createElement(FormFields, null)),
3195
+ React__default["default"].createElement(RemoteErrorMessage, null),
3196
+ React__default["default"].createElement(TwoButtonSubmitFooter, { cancelButtonText: getBackToSignInText(), cancelButtonSendType: "SIGN_IN", submitButtonText: isPending ? (React__default["default"].createElement(React__default["default"].Fragment, null,
3197
+ getSendingText(),
3198
+ "\u2026")) : (React__default["default"].createElement(React__default["default"].Fragment, null, getSendCodeText())) }),
3199
+ React__default["default"].createElement(Footer, null)))));
3200
+ };
3201
+ ForgotPassword.Header = function Header() {
3202
+ return React__default["default"].createElement(Heading, { level: 3 }, getResetYourPasswordText());
3203
+ };
3204
+ ForgotPassword.Footer = function Footer() {
3205
+ // @ts-ignore
3206
+ return null;
3207
+ };
3208
+
3209
+ const isSignInOrSignUpRoute = (route) => route === 'signIn' || route === 'signUp';
3210
+
3211
+ function RenderNothing() {
3212
+ // @ts-ignore
3213
+ return null;
3214
+ }
3215
+ const getRouteComponent = (route) => {
3216
+ switch (route) {
3217
+ case 'authenticated':
3218
+ case 'idle':
3219
+ case 'setup':
3220
+ case 'transition':
3221
+ return RenderNothing;
3222
+ case 'confirmSignUp':
3223
+ return ConfirmSignUp;
3224
+ case 'confirmSignIn':
3225
+ return ConfirmSignIn;
3226
+ case 'setupTotp':
3227
+ return SetupTotp;
3228
+ case 'signIn':
3229
+ case 'signUp':
3230
+ return SignInSignUpTabs;
3231
+ case 'forceNewPassword':
3232
+ return ForceNewPassword;
3233
+ case 'forgotPassword':
3234
+ return ForgotPassword;
3235
+ case 'confirmResetPassword':
3236
+ return ConfirmResetPassword;
3237
+ case 'verifyUser':
3238
+ return VerifyUser;
3239
+ case 'confirmVerifyUser':
3240
+ return ConfirmVerifyUser;
3241
+ default:
3242
+ // eslint-disable-next-line no-console
3243
+ console.warn(`Unhandled Authenticator route - please open an issue: ${route}`);
3244
+ return RenderNothing;
3245
+ }
3246
+ };
3247
+ function Router({ className, hideSignUp, variation, }) {
3248
+ const { route } = uiReactCore.useAuthenticator(({ route }) => [route]);
3249
+ const RouterChildren = React.useMemo(() => getRouteComponent(route), [route]);
3250
+ return (React__default["default"].createElement(RouterChildren, { className: className,
3251
+ // @ts-ignore
3252
+ hideSignUp: isSignInOrSignUpRoute(route) ? hideSignUp : undefined, variation: variation }));
3253
+ }
3254
+
3255
+ const defaultComponents = {
3256
+ // @ts-ignore
3257
+ Header: () => null,
3258
+ SignIn: {
3259
+ Header: SignIn.Header,
3260
+ Footer: SignIn.Footer,
3261
+ },
3262
+ SignUp: {
3263
+ Header: SignUp.Header,
3264
+ FormFields: SignUp.FormFields,
3265
+ Footer: SignUp.Footer,
3266
+ },
3267
+ ConfirmSignUp: {
3268
+ Header: ConfirmSignUp.Header,
3269
+ Footer: ConfirmSignUp.Footer,
3270
+ },
3271
+ SetupTotp: {
3272
+ Header: SetupTotp.Header,
3273
+ Footer: SetupTotp.Footer,
3274
+ },
3275
+ ConfirmResetPassword: {
3276
+ Header: ConfirmResetPassword.Header,
3277
+ Footer: ConfirmResetPassword.Footer,
3278
+ },
3279
+ ConfirmSignIn: {
3280
+ Header: ConfirmSignIn.Header,
3281
+ Footer: ConfirmSignIn.Footer,
3282
+ },
3283
+ VerifyUser: {
3284
+ Header: VerifyUser.Header,
3285
+ Footer: VerifyUser.Footer,
3286
+ },
3287
+ ConfirmVerifyUser: {
3288
+ Header: ConfirmVerifyUser.Header,
3289
+ // @ts-ignore
3290
+ Footer: ConfirmVerifyUser.Footer,
3291
+ },
3292
+ ForceNewPassword: {
3293
+ Header: ForceNewPassword.Header,
3294
+ Footer: ForceNewPassword.Footer,
3295
+ FormFields: ForceNewPassword.FormFields,
3296
+ },
3297
+ ForgotPassword: {
3298
+ Header: ForgotPassword.Header,
3299
+ Footer: ForgotPassword.Footer,
3300
+ },
3301
+ // @ts-ignore
3302
+ Footer: () => null,
3303
+ };
3304
+
3305
+ // `AuthenticatorInternal` exists to give access to the context returned via `useAuthenticator`,
3306
+ // which allows the `Authenticator` to just return `children` if a user is authenticated.
3307
+ // Once the `Provider` is removed from the `Authenticator` component and exported as
3308
+ // `AuthenticatorProvider`, this component should be renamed to `Authenticator`.
3309
+ function AuthenticatorInternal({ children, className, components: customComponents, formFields, hideSignUp, initialState, loginMechanisms, passwordSettings, signUpAttributes, services, socialProviders, variation, }) {
3310
+ useDeprecationWarning({
3311
+ message: 'The `passwordSettings` prop has been deprecated and will be removed in a future major version of Amplify UI.',
3312
+ // shouldWarn: !!passwordSettings,
3313
+ /**
3314
+ * @migration turn off until getConfig returns zero config
3315
+ */
3316
+ shouldWarn: false,
3317
+ });
3318
+ const { route, signOut, user } = uiReactCore.useAuthenticator(({ route, signOut, user }) => [route, signOut, user]);
3319
+ uiReactCore.useAuthenticatorInitMachine({
3320
+ initialState,
3321
+ loginMechanisms,
3322
+ passwordSettings,
3323
+ services,
3324
+ signUpAttributes,
3325
+ socialProviders,
3326
+ formFields,
3327
+ });
3328
+ const value = React__namespace.useMemo(() => ({ components: { ...defaultComponents, ...customComponents } }), [customComponents]);
3329
+ const isAuthenticatedRoute = route === 'authenticated' || route === 'signOut';
3330
+ if (isAuthenticatedRoute) {
3331
+ // `Authenticator` might not have user defined `children` for non SPA use cases.
3332
+ if (!children) {
3333
+ // @ts-ignore
3334
+ return null;
3335
+ }
3336
+ return (React__namespace.createElement(React__namespace.Fragment, null, ui.isFunction(children)
3337
+ ? children({ signOut, user }) // children is a render prop
3338
+ : children));
3339
+ }
3340
+ return (React__namespace.createElement(CustomComponentsContext.Provider, { value: value },
3341
+ React__namespace.createElement(Router, { className: className, hideSignUp: hideSignUp, variation: variation })));
3342
+ }
3343
+ /**
3344
+ * [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator)
3345
+ */
3346
+ function Authenticator(props) {
3347
+ uiReactCore.useSetUserAgent({
3348
+ componentName: 'Authenticator',
3349
+ packageName: 'react',
3350
+ version: VERSION,
3351
+ });
3352
+ return (React__namespace.createElement(uiReactCore.AuthenticatorProvider, null,
3353
+ React__namespace.createElement(AuthenticatorInternal, { ...props })));
3354
+ }
3355
+ Authenticator.Provider = uiReactCore.AuthenticatorProvider;
3356
+ Authenticator.ForgotPassword = ForgotPassword;
3357
+ Authenticator.SetupTotp = SetupTotp;
3358
+ Authenticator.SignIn = SignIn;
3359
+ Authenticator.SignUp = SignUp;
3360
+ Authenticator.ForceNewPassword = ForceNewPassword;
3361
+
3362
+ /**
3363
+ * [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator)
3364
+ */
3365
+ function withAuthenticator(Component, options = {}) {
3366
+ const { variation = 'modal' } = options;
3367
+ return function WrappedWithAuthenticator(props) {
3368
+ return (React__default["default"].createElement(Authenticator, { variation: variation, ...options }, (withAuthenticatorProps) => (React__default["default"].createElement(Component, { ...props, ...withAuthenticatorProps }))));
3369
+ };
3370
+ }
3371
+
3372
+ // Radix packages don't support ESM in Node, in some scenarios(e.g. SSR)
3373
+ // We have to use namespace import and sanitize it to ensure the interoperablity between ESM and CJS
3374
+ const { DirectionProvider } = ui.sanitizeNamespaceImport(RadixDirection__namespace);
3375
+ /**
3376
+ * [📖 Docs](https://ui.docs.amplify.aws/react/theming)
3377
+ */
3378
+ function ThemeProvider({ children, colorMode, direction = 'ltr', nonce, theme, }) {
3379
+ const value = React__namespace.useMemo(() => ({ theme: ui.createTheme(theme) }), [theme]);
3380
+ const { theme: { name, cssText }, } = value;
3381
+ return (React__namespace.createElement(Field.ThemeContext.Provider, { value: value },
3382
+ React__namespace.createElement(DirectionProvider, { dir: direction },
3383
+ React__namespace.createElement("div", { "data-amplify-theme": name, "data-amplify-color-mode": colorMode, dir: direction }, children),
3384
+ typeof theme === 'undefined' || /<\/style/i.test(cssText) ? null : (React__namespace.createElement("style", { id: `amplify-theme-${name}`,
3385
+ // eslint-disable-next-line react/no-danger
3386
+ dangerouslySetInnerHTML: { __html: cssText }, nonce: nonce })))));
3387
+ }
3388
+
3389
+ var index = /*#__PURE__*/Object.freeze({
3390
+ __proto__: null,
3391
+ AccountSettings: AccountSettings,
3392
+ Authenticator: Authenticator,
3393
+ withAuthenticator: withAuthenticator,
3394
+ useAuthenticator: uiReactCore.useAuthenticator,
3395
+ ThemeProvider: ThemeProvider
3396
+ });
3397
+
3398
+ Object.defineProperty(exports, 'useAuthenticator', {
3399
+ enumerable: true,
3400
+ get: function () { return uiReactCore.useAuthenticator; }
3401
+ });
3402
+ Object.defineProperty(exports, 'createTheme', {
3403
+ enumerable: true,
3404
+ get: function () { return ui.createTheme; }
3405
+ });
3406
+ Object.defineProperty(exports, 'defaultDarkModeOverride', {
3407
+ enumerable: true,
3408
+ get: function () { return ui.defaultDarkModeOverride; }
3409
+ });
3410
+ Object.defineProperty(exports, 'defaultTheme', {
3411
+ enumerable: true,
3412
+ get: function () { return ui.defaultTheme; }
3413
+ });
3414
+ Object.defineProperty(exports, 'translations', {
3415
+ enumerable: true,
3416
+ get: function () { return ui.translations; }
3417
+ });
3418
+ exports.Button = Field.Button;
3419
+ exports.ComponentPropsToStylePropsMap = Field.ComponentPropsToStylePropsMap;
3420
+ exports.ComponentPropsToStylePropsMapKeys = Field.ComponentPropsToStylePropsMapKeys;
3421
+ exports.FieldGroupIcon = Field.FieldGroupIcon;
3422
+ exports.FieldGroupIconButton = Field.FieldGroupIconButton;
3423
+ exports.Flex = Field.Flex;
3424
+ exports.Icon = Field.Icon;
3425
+ exports.Label = Field.Label;
3426
+ exports.Loader = Field.Loader;
3427
+ exports.Text = Field.Text;
3428
+ exports.View = Field.View;
3429
+ exports.useTheme = Field.useTheme;
3430
+ exports.Accordion = Accordion;
3431
+ exports.AccountSettings = AccountSettings;
3432
+ exports.Alert = Alert;
3433
+ exports.Authenticator = Authenticator;
3434
+ exports.Autocomplete = Autocomplete;
3435
+ exports.Badge = Badge;
3436
+ exports.Breadcrumbs = Breadcrumbs;
3437
+ exports.ButtonGroup = ButtonGroup;
3438
+ exports.Card = Card;
3439
+ exports.CheckboxField = CheckboxField;
3440
+ exports.Collection = Collection;
3441
+ exports.Divider = Divider;
3442
+ exports.DropZone = DropZone;
3443
+ exports.Fieldset = Fieldset;
3444
+ exports.Grid = Grid;
3445
+ exports.Heading = Heading;
3446
+ exports.HighlightMatch = HighlightMatch;
3447
+ exports.IconsProvider = IconsProvider;
3448
+ exports.Image = Image;
3449
+ exports.Input = Input;
3450
+ exports.Link = Link;
3451
+ exports.Menu = Menu;
3452
+ exports.MenuButton = MenuButton;
3453
+ exports.MenuItem = MenuItem;
3454
+ exports.Message = Message;
3455
+ exports.Pagination = Pagination;
3456
+ exports.PasswordField = PasswordField;
3457
+ exports.PhoneNumberField = PhoneNumberField;
3458
+ exports.Placeholder = Placeholder;
3459
+ exports.Radio = Radio;
3460
+ exports.RadioGroupField = RadioGroupField;
3461
+ exports.Rating = Rating;
3462
+ exports.ScrollView = ScrollView;
3463
+ exports.SearchField = SearchField;
3464
+ exports.SelectField = SelectField;
3465
+ exports.SliderField = SliderField;
3466
+ exports.StepperField = StepperField;
3467
+ exports.SwitchField = SwitchField;
3468
+ exports.Table = Table;
3469
+ exports.TableBody = TableBody;
3470
+ exports.TableCell = TableCell;
3471
+ exports.TableFoot = TableFoot;
3472
+ exports.TableHead = TableHead;
3473
+ exports.TableRow = TableRow;
3474
+ exports.Tabs = Tabs;
3475
+ exports.TextAreaField = TextAreaField;
3476
+ exports.TextField = TextField;
3477
+ exports.ThemeProvider = ThemeProvider;
3478
+ exports.ToggleButton = ToggleButton;
3479
+ exports.ToggleButtonGroup = ToggleButtonGroup;
3480
+ exports.VisuallyHidden = VisuallyHidden;
3481
+ exports.components = index;
3482
+ exports.primitives = index$1;
3483
+ exports.useBreakpointValue = useBreakpointValue;
3484
+ exports.usePagination = usePagination;
3485
+ exports.withAuthenticator = withAuthenticator;