@trii/components 2.0.80 → 2.0.81

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 (365) hide show
  1. package/dist/cjs/index.js +8 -8
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +8 -8
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.ts +3 -0
  6. package/dist/types/components/ContactInfoPopup/ContactInfoPopup.d.ts +2 -0
  7. package/dist/types/components/EditContactModal/EditContactModal.d.ts +2 -0
  8. package/dist/types/components/EditContactModal/hooks/useEditContactModalController.d.ts +3 -1
  9. package/dist/types/utils/formatContactName.d.ts +3 -0
  10. package/package.json +2 -2
  11. package/dist/cjs/types/USAGE_EXAMPLE.d.ts +0 -7
  12. package/dist/cjs/types/components/ContactInfoPopup/ContactInfoPopup.d.ts +0 -14
  13. package/dist/cjs/types/components/ContactInfoPopup/components/BusinessSection/BusinessSection.d.ts +0 -7
  14. package/dist/cjs/types/components/ContactInfoPopup/components/BusinessSection/index.d.ts +0 -1
  15. package/dist/cjs/types/components/ContactInfoPopup/components/ContactMethod/ContactMethod.d.ts +0 -10
  16. package/dist/cjs/types/components/ContactInfoPopup/components/ContactMethod/index.d.ts +0 -1
  17. package/dist/cjs/types/components/ContactInfoPopup/components/Header/Header.d.ts +0 -12
  18. package/dist/cjs/types/components/ContactInfoPopup/components/Header/index.d.ts +0 -1
  19. package/dist/cjs/types/components/ContactInfoPopup/components/LabelsSection/LabelsSection.d.ts +0 -7
  20. package/dist/cjs/types/components/ContactInfoPopup/components/LabelsSection/index.d.ts +0 -1
  21. package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/MembersSection.d.ts +0 -7
  22. package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/components/MemberItem/MemberItem.d.ts +0 -4
  23. package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/components/MemberItem/index.d.ts +0 -1
  24. package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/components/index.d.ts +0 -1
  25. package/dist/cjs/types/components/ContactInfoPopup/components/MembersSection/index.d.ts +0 -1
  26. package/dist/cjs/types/components/ContactInfoPopup/components/Properties/Properties.d.ts +0 -7
  27. package/dist/cjs/types/components/ContactInfoPopup/components/Properties/index.d.ts +0 -1
  28. package/dist/cjs/types/components/ContactInfoPopup/components/index.d.ts +0 -6
  29. package/dist/cjs/types/components/ContactInfoPopup/index.d.ts +0 -1
  30. package/dist/cjs/types/components/ContactInfoPopup/types/is-business.typeguard.d.ts +0 -7
  31. package/dist/cjs/types/components/ContactInfoPopup/types/is-contact.typeguard.d.ts +0 -7
  32. package/dist/cjs/types/components/ModalEvents/ModalEvents.backup.d.ts +0 -23
  33. package/dist/cjs/types/components/ModalEvents/ModalEvents.d.ts +0 -9
  34. package/dist/cjs/types/components/ModalEvents/ModalEvents.refactored.d.ts +0 -9
  35. package/dist/cjs/types/components/ModalEvents/components/ActionButtons/ActionButtons.d.ts +0 -5
  36. package/dist/cjs/types/components/ModalEvents/components/ActionButtons/index.d.ts +0 -1
  37. package/dist/cjs/types/components/ModalEvents/components/AllDayCheckbox/AllDayCheckbox.d.ts +0 -7
  38. package/dist/cjs/types/components/ModalEvents/components/AllDayCheckbox/index.d.ts +0 -1
  39. package/dist/cjs/types/components/ModalEvents/components/ColorPicker/ColorPicker.d.ts +0 -8
  40. package/dist/cjs/types/components/ModalEvents/components/ColorPicker/index.d.ts +0 -1
  41. package/dist/cjs/types/components/ModalEvents/components/CreateTypeTabs/CreateTypeTabs.d.ts +0 -11
  42. package/dist/cjs/types/components/ModalEvents/components/CreateTypeTabs/index.d.ts +0 -1
  43. package/dist/cjs/types/components/ModalEvents/components/DatePicker/DatePicker.d.ts +0 -13
  44. package/dist/cjs/types/components/ModalEvents/components/DatePicker/index.d.ts +0 -1
  45. package/dist/cjs/types/components/ModalEvents/components/DatePicker/styles.d.ts +0 -10
  46. package/dist/cjs/types/components/ModalEvents/components/DescriptionTextField/DescriptionTextField.d.ts +0 -7
  47. package/dist/cjs/types/components/ModalEvents/components/DescriptionTextField/index.d.ts +0 -1
  48. package/dist/cjs/types/components/ModalEvents/components/IsPrivateCheckbox/IsPrivateCheckbox.d.ts +0 -7
  49. package/dist/cjs/types/components/ModalEvents/components/IsPrivateCheckbox/index.d.ts +0 -1
  50. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/LinkContactsSelect.d.ts +0 -7
  51. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchBar/ContactSearchBar.d.ts +0 -6
  52. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchBar/index.d.ts +0 -1
  53. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchResults/ContactsSearchResults.d.ts +0 -11
  54. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchResults/index.d.ts +0 -1
  55. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/components/index.d.ts +0 -2
  56. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/index.d.ts +0 -1
  57. package/dist/cjs/types/components/ModalEvents/components/LinkContactsSelect/styles.d.ts +0 -7
  58. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/LocationTextField.d.ts +0 -7
  59. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/MapLocationPicker.d.ts +0 -8
  60. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/SendLocation/LocationSelectorModal.d.ts +0 -8
  61. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/SendLocation/components/GoogleMap/GoogleMapStandalone.d.ts +0 -9
  62. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/SendLocation/components/GoogleMap/index.d.ts +0 -1
  63. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/SendLocation/components/index.d.ts +0 -1
  64. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/SendLocation/index.d.ts +0 -3
  65. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/SendLocation/types.d.ts +0 -15
  66. package/dist/cjs/types/components/ModalEvents/components/LocationTextField/index.d.ts +0 -1
  67. package/dist/cjs/types/components/ModalEvents/components/RecurrenceSelect/RecurrenceSelect.d.ts +0 -8
  68. package/dist/cjs/types/components/ModalEvents/components/RecurrenceSelect/index.d.ts +0 -1
  69. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/ReminderNotifications.d.ts +0 -7
  70. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/ReminderItem.d.ts +0 -12
  71. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/index.d.ts +0 -1
  72. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/style.d.ts +0 -17
  73. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/utils/selectOptions.d.ts +0 -5
  74. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/components/index.d.ts +0 -1
  75. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/index.d.ts +0 -1
  76. package/dist/cjs/types/components/ModalEvents/components/ReminderNotifications/styles.d.ts +0 -7
  77. package/dist/cjs/types/components/ModalEvents/components/ShareUsersSelect/ShareUsersSelect.d.ts +0 -7
  78. package/dist/cjs/types/components/ModalEvents/components/ShareUsersSelect/index.d.ts +0 -1
  79. package/dist/cjs/types/components/ModalEvents/components/ShareUsersSelect/styles.d.ts +0 -4
  80. package/dist/cjs/types/components/ModalEvents/components/SyncWithGoogleField/SyncWithGoogleField.d.ts +0 -5
  81. package/dist/cjs/types/components/ModalEvents/components/TaskCalendarSelect/TaskCalendarSelect.d.ts +0 -9
  82. package/dist/cjs/types/components/ModalEvents/components/TaskCalendarSelect/index.d.ts +0 -1
  83. package/dist/cjs/types/components/ModalEvents/components/TaskDatePicker/TaskDatePicker.d.ts +0 -10
  84. package/dist/cjs/types/components/ModalEvents/components/TaskDatePicker/index.d.ts +0 -1
  85. package/dist/cjs/types/components/ModalEvents/components/TitleTextField/TitleTextField.d.ts +0 -8
  86. package/dist/cjs/types/components/ModalEvents/components/TitleTextField/index.d.ts +0 -1
  87. package/dist/cjs/types/components/ModalEvents/components/index.d.ts +0 -15
  88. package/dist/cjs/types/components/ModalEvents/context/CalendarContext.d.ts +0 -84
  89. package/dist/cjs/types/components/ModalEvents/context/CalendarContextProvider.d.ts +0 -6
  90. package/dist/cjs/types/components/ModalEvents/context/types/CalendarDialogMode.d.ts +0 -1
  91. package/dist/cjs/types/components/ModalEvents/context/types/CalendarDialogState.d.ts +0 -1
  92. package/dist/cjs/types/components/ModalEvents/context/types/DialogType.d.ts +0 -1
  93. package/dist/cjs/types/components/ModalEvents/context/types/Mode.d.ts +0 -1
  94. package/dist/cjs/types/components/ModalEvents/hooks/index.d.ts +0 -2
  95. package/dist/cjs/types/components/ModalEvents/hooks/useContactSearch.d.ts +0 -23
  96. package/dist/cjs/types/components/ModalEvents/hooks/useModalData.d.ts +0 -33
  97. package/dist/cjs/types/components/ModalEvents/index.d.ts +0 -7
  98. package/dist/cjs/types/components/ModalEvents/layout/BasicInputContainer/BasicInputContainer.d.ts +0 -7
  99. package/dist/cjs/types/components/ModalEvents/layout/BasicInputContainer/index.d.ts +0 -1
  100. package/dist/cjs/types/components/ModalEvents/layout/BasicInputContainer/styles.d.ts +0 -7
  101. package/dist/cjs/types/components/ModalEvents/layout/InputContainer/InputContainer.d.ts +0 -7
  102. package/dist/cjs/types/components/ModalEvents/layout/InputContainer/index.d.ts +0 -1
  103. package/dist/cjs/types/components/ModalEvents/layout/index.d.ts +0 -2
  104. package/dist/cjs/types/components/ModalEvents/sections/ActionButtonsSection.d.ts +0 -17
  105. package/dist/cjs/types/components/ModalEvents/sections/CalendarSection.d.ts +0 -18
  106. package/dist/cjs/types/components/ModalEvents/sections/ColorSection.d.ts +0 -16
  107. package/dist/cjs/types/components/ModalEvents/sections/DateTimeSection.d.ts +0 -19
  108. package/dist/cjs/types/components/ModalEvents/sections/DescriptionSection.d.ts +0 -17
  109. package/dist/cjs/types/components/ModalEvents/sections/LinkedContactsSection.d.ts +0 -22
  110. package/dist/cjs/types/components/ModalEvents/sections/LocationSection.d.ts +0 -17
  111. package/dist/cjs/types/components/ModalEvents/sections/ModalHeader.d.ts +0 -18
  112. package/dist/cjs/types/components/ModalEvents/sections/NotificationsSection.d.ts +0 -19
  113. package/dist/cjs/types/components/ModalEvents/sections/TitleSection.d.ts +0 -22
  114. package/dist/cjs/types/components/ModalEvents/sections/index.d.ts +0 -10
  115. package/dist/cjs/types/components/ModalEvents/types/index.d.ts +0 -376
  116. package/dist/cjs/types/components/TextBox/TestBox.d.ts +0 -8
  117. package/dist/cjs/types/components/TextBox/index.d.ts +0 -1
  118. package/dist/cjs/types/components/index.d.ts +0 -4
  119. package/dist/cjs/types/index.d.ts +0 -1
  120. package/dist/cjs/types/src/components/ContactInfoPopup/ContactInfoPopup.d.ts +0 -14
  121. package/dist/cjs/types/src/components/ContactInfoPopup/components/BusinessSection/BusinessSection.d.ts +0 -7
  122. package/dist/cjs/types/src/components/ContactInfoPopup/components/BusinessSection/index.d.ts +0 -1
  123. package/dist/cjs/types/src/components/ContactInfoPopup/components/ContactMethod/ContactMethod.d.ts +0 -10
  124. package/dist/cjs/types/src/components/ContactInfoPopup/components/ContactMethod/index.d.ts +0 -1
  125. package/dist/cjs/types/src/components/ContactInfoPopup/components/Header/Header.d.ts +0 -12
  126. package/dist/cjs/types/src/components/ContactInfoPopup/components/Header/index.d.ts +0 -1
  127. package/dist/cjs/types/src/components/ContactInfoPopup/components/LabelsSection/LabelsSection.d.ts +0 -7
  128. package/dist/cjs/types/src/components/ContactInfoPopup/components/LabelsSection/index.d.ts +0 -1
  129. package/dist/cjs/types/src/components/ContactInfoPopup/components/MembersSection/MembersSection.d.ts +0 -7
  130. package/dist/cjs/types/src/components/ContactInfoPopup/components/MembersSection/components/MemberItem/MemberItem.d.ts +0 -4
  131. package/dist/cjs/types/src/components/ContactInfoPopup/components/MembersSection/components/MemberItem/index.d.ts +0 -1
  132. package/dist/cjs/types/src/components/ContactInfoPopup/components/MembersSection/components/index.d.ts +0 -1
  133. package/dist/cjs/types/src/components/ContactInfoPopup/components/MembersSection/index.d.ts +0 -1
  134. package/dist/cjs/types/src/components/ContactInfoPopup/components/Properties/Properties.d.ts +0 -7
  135. package/dist/cjs/types/src/components/ContactInfoPopup/components/Properties/index.d.ts +0 -1
  136. package/dist/cjs/types/src/components/ContactInfoPopup/components/index.d.ts +0 -6
  137. package/dist/cjs/types/src/components/ContactInfoPopup/index.d.ts +0 -1
  138. package/dist/cjs/types/src/components/ContactInfoPopup/types/is-business.typeguard.d.ts +0 -7
  139. package/dist/cjs/types/src/components/ContactInfoPopup/types/is-contact.typeguard.d.ts +0 -7
  140. package/dist/cjs/types/src/components/ModalEvents/ModalEvents.d.ts +0 -23
  141. package/dist/cjs/types/src/components/ModalEvents/index.d.ts +0 -7
  142. package/dist/cjs/types/src/components/ModalEvents/types/index.d.ts +0 -352
  143. package/dist/cjs/types/src/components/TextBox/TestBox.d.ts +0 -8
  144. package/dist/cjs/types/src/components/TextBox/index.d.ts +0 -1
  145. package/dist/cjs/types/src/components/index.d.ts +0 -4
  146. package/dist/cjs/types/src/index.d.ts +0 -1
  147. package/dist/esm/types/USAGE_EXAMPLE.d.ts +0 -7
  148. package/dist/esm/types/components/ContactInfoPopup/ContactInfoPopup.d.ts +0 -14
  149. package/dist/esm/types/components/ContactInfoPopup/components/BusinessSection/BusinessSection.d.ts +0 -7
  150. package/dist/esm/types/components/ContactInfoPopup/components/BusinessSection/index.d.ts +0 -1
  151. package/dist/esm/types/components/ContactInfoPopup/components/ContactMethod/ContactMethod.d.ts +0 -10
  152. package/dist/esm/types/components/ContactInfoPopup/components/ContactMethod/index.d.ts +0 -1
  153. package/dist/esm/types/components/ContactInfoPopup/components/Header/Header.d.ts +0 -12
  154. package/dist/esm/types/components/ContactInfoPopup/components/Header/index.d.ts +0 -1
  155. package/dist/esm/types/components/ContactInfoPopup/components/LabelsSection/LabelsSection.d.ts +0 -7
  156. package/dist/esm/types/components/ContactInfoPopup/components/LabelsSection/index.d.ts +0 -1
  157. package/dist/esm/types/components/ContactInfoPopup/components/MembersSection/MembersSection.d.ts +0 -7
  158. package/dist/esm/types/components/ContactInfoPopup/components/MembersSection/components/MemberItem/MemberItem.d.ts +0 -4
  159. package/dist/esm/types/components/ContactInfoPopup/components/MembersSection/components/MemberItem/index.d.ts +0 -1
  160. package/dist/esm/types/components/ContactInfoPopup/components/MembersSection/components/index.d.ts +0 -1
  161. package/dist/esm/types/components/ContactInfoPopup/components/MembersSection/index.d.ts +0 -1
  162. package/dist/esm/types/components/ContactInfoPopup/components/Properties/Properties.d.ts +0 -7
  163. package/dist/esm/types/components/ContactInfoPopup/components/Properties/index.d.ts +0 -1
  164. package/dist/esm/types/components/ContactInfoPopup/components/index.d.ts +0 -6
  165. package/dist/esm/types/components/ContactInfoPopup/index.d.ts +0 -1
  166. package/dist/esm/types/components/ContactInfoPopup/types/is-business.typeguard.d.ts +0 -7
  167. package/dist/esm/types/components/ContactInfoPopup/types/is-contact.typeguard.d.ts +0 -7
  168. package/dist/esm/types/components/ModalEvents/ModalEvents.backup.d.ts +0 -23
  169. package/dist/esm/types/components/ModalEvents/ModalEvents.d.ts +0 -9
  170. package/dist/esm/types/components/ModalEvents/ModalEvents.refactored.d.ts +0 -9
  171. package/dist/esm/types/components/ModalEvents/components/ActionButtons/ActionButtons.d.ts +0 -5
  172. package/dist/esm/types/components/ModalEvents/components/ActionButtons/index.d.ts +0 -1
  173. package/dist/esm/types/components/ModalEvents/components/AllDayCheckbox/AllDayCheckbox.d.ts +0 -7
  174. package/dist/esm/types/components/ModalEvents/components/AllDayCheckbox/index.d.ts +0 -1
  175. package/dist/esm/types/components/ModalEvents/components/ColorPicker/ColorPicker.d.ts +0 -8
  176. package/dist/esm/types/components/ModalEvents/components/ColorPicker/index.d.ts +0 -1
  177. package/dist/esm/types/components/ModalEvents/components/CreateTypeTabs/CreateTypeTabs.d.ts +0 -11
  178. package/dist/esm/types/components/ModalEvents/components/CreateTypeTabs/index.d.ts +0 -1
  179. package/dist/esm/types/components/ModalEvents/components/DatePicker/DatePicker.d.ts +0 -13
  180. package/dist/esm/types/components/ModalEvents/components/DatePicker/index.d.ts +0 -1
  181. package/dist/esm/types/components/ModalEvents/components/DatePicker/styles.d.ts +0 -10
  182. package/dist/esm/types/components/ModalEvents/components/DescriptionTextField/DescriptionTextField.d.ts +0 -7
  183. package/dist/esm/types/components/ModalEvents/components/DescriptionTextField/index.d.ts +0 -1
  184. package/dist/esm/types/components/ModalEvents/components/IsPrivateCheckbox/IsPrivateCheckbox.d.ts +0 -7
  185. package/dist/esm/types/components/ModalEvents/components/IsPrivateCheckbox/index.d.ts +0 -1
  186. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/LinkContactsSelect.d.ts +0 -7
  187. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchBar/ContactSearchBar.d.ts +0 -6
  188. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchBar/index.d.ts +0 -1
  189. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchResults/ContactsSearchResults.d.ts +0 -11
  190. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/components/ContactSearchResults/index.d.ts +0 -1
  191. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/components/index.d.ts +0 -2
  192. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/index.d.ts +0 -1
  193. package/dist/esm/types/components/ModalEvents/components/LinkContactsSelect/styles.d.ts +0 -7
  194. package/dist/esm/types/components/ModalEvents/components/LocationTextField/LocationTextField.d.ts +0 -7
  195. package/dist/esm/types/components/ModalEvents/components/LocationTextField/MapLocationPicker.d.ts +0 -8
  196. package/dist/esm/types/components/ModalEvents/components/LocationTextField/SendLocation/LocationSelectorModal.d.ts +0 -8
  197. package/dist/esm/types/components/ModalEvents/components/LocationTextField/SendLocation/components/GoogleMap/GoogleMapStandalone.d.ts +0 -9
  198. package/dist/esm/types/components/ModalEvents/components/LocationTextField/SendLocation/components/GoogleMap/index.d.ts +0 -1
  199. package/dist/esm/types/components/ModalEvents/components/LocationTextField/SendLocation/components/index.d.ts +0 -1
  200. package/dist/esm/types/components/ModalEvents/components/LocationTextField/SendLocation/index.d.ts +0 -3
  201. package/dist/esm/types/components/ModalEvents/components/LocationTextField/SendLocation/types.d.ts +0 -15
  202. package/dist/esm/types/components/ModalEvents/components/LocationTextField/index.d.ts +0 -1
  203. package/dist/esm/types/components/ModalEvents/components/RecurrenceSelect/RecurrenceSelect.d.ts +0 -8
  204. package/dist/esm/types/components/ModalEvents/components/RecurrenceSelect/index.d.ts +0 -1
  205. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/ReminderNotifications.d.ts +0 -7
  206. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/ReminderItem.d.ts +0 -12
  207. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/index.d.ts +0 -1
  208. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/style.d.ts +0 -17
  209. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/components/ReminderItem/utils/selectOptions.d.ts +0 -5
  210. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/components/index.d.ts +0 -1
  211. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/index.d.ts +0 -1
  212. package/dist/esm/types/components/ModalEvents/components/ReminderNotifications/styles.d.ts +0 -7
  213. package/dist/esm/types/components/ModalEvents/components/ShareUsersSelect/ShareUsersSelect.d.ts +0 -7
  214. package/dist/esm/types/components/ModalEvents/components/ShareUsersSelect/index.d.ts +0 -1
  215. package/dist/esm/types/components/ModalEvents/components/ShareUsersSelect/styles.d.ts +0 -4
  216. package/dist/esm/types/components/ModalEvents/components/SyncWithGoogleField/SyncWithGoogleField.d.ts +0 -5
  217. package/dist/esm/types/components/ModalEvents/components/TaskCalendarSelect/TaskCalendarSelect.d.ts +0 -9
  218. package/dist/esm/types/components/ModalEvents/components/TaskCalendarSelect/index.d.ts +0 -1
  219. package/dist/esm/types/components/ModalEvents/components/TaskDatePicker/TaskDatePicker.d.ts +0 -10
  220. package/dist/esm/types/components/ModalEvents/components/TaskDatePicker/index.d.ts +0 -1
  221. package/dist/esm/types/components/ModalEvents/components/TitleTextField/TitleTextField.d.ts +0 -8
  222. package/dist/esm/types/components/ModalEvents/components/TitleTextField/index.d.ts +0 -1
  223. package/dist/esm/types/components/ModalEvents/components/index.d.ts +0 -15
  224. package/dist/esm/types/components/ModalEvents/context/CalendarContext.d.ts +0 -84
  225. package/dist/esm/types/components/ModalEvents/context/CalendarContextProvider.d.ts +0 -6
  226. package/dist/esm/types/components/ModalEvents/context/types/CalendarDialogMode.d.ts +0 -1
  227. package/dist/esm/types/components/ModalEvents/context/types/CalendarDialogState.d.ts +0 -1
  228. package/dist/esm/types/components/ModalEvents/context/types/DialogType.d.ts +0 -1
  229. package/dist/esm/types/components/ModalEvents/context/types/Mode.d.ts +0 -1
  230. package/dist/esm/types/components/ModalEvents/hooks/index.d.ts +0 -2
  231. package/dist/esm/types/components/ModalEvents/hooks/useContactSearch.d.ts +0 -23
  232. package/dist/esm/types/components/ModalEvents/hooks/useModalData.d.ts +0 -33
  233. package/dist/esm/types/components/ModalEvents/index.d.ts +0 -7
  234. package/dist/esm/types/components/ModalEvents/layout/BasicInputContainer/BasicInputContainer.d.ts +0 -7
  235. package/dist/esm/types/components/ModalEvents/layout/BasicInputContainer/index.d.ts +0 -1
  236. package/dist/esm/types/components/ModalEvents/layout/BasicInputContainer/styles.d.ts +0 -7
  237. package/dist/esm/types/components/ModalEvents/layout/InputContainer/InputContainer.d.ts +0 -7
  238. package/dist/esm/types/components/ModalEvents/layout/InputContainer/index.d.ts +0 -1
  239. package/dist/esm/types/components/ModalEvents/layout/index.d.ts +0 -2
  240. package/dist/esm/types/components/ModalEvents/sections/ActionButtonsSection.d.ts +0 -17
  241. package/dist/esm/types/components/ModalEvents/sections/CalendarSection.d.ts +0 -18
  242. package/dist/esm/types/components/ModalEvents/sections/ColorSection.d.ts +0 -16
  243. package/dist/esm/types/components/ModalEvents/sections/DateTimeSection.d.ts +0 -19
  244. package/dist/esm/types/components/ModalEvents/sections/DescriptionSection.d.ts +0 -17
  245. package/dist/esm/types/components/ModalEvents/sections/LinkedContactsSection.d.ts +0 -22
  246. package/dist/esm/types/components/ModalEvents/sections/LocationSection.d.ts +0 -17
  247. package/dist/esm/types/components/ModalEvents/sections/ModalHeader.d.ts +0 -18
  248. package/dist/esm/types/components/ModalEvents/sections/NotificationsSection.d.ts +0 -19
  249. package/dist/esm/types/components/ModalEvents/sections/TitleSection.d.ts +0 -22
  250. package/dist/esm/types/components/ModalEvents/sections/index.d.ts +0 -10
  251. package/dist/esm/types/components/ModalEvents/types/index.d.ts +0 -376
  252. package/dist/esm/types/components/TextBox/TestBox.d.ts +0 -8
  253. package/dist/esm/types/components/TextBox/index.d.ts +0 -1
  254. package/dist/esm/types/components/index.d.ts +0 -4
  255. package/dist/esm/types/index.d.ts +0 -1
  256. package/dist/esm/types/src/components/ContactInfoPopup/ContactInfoPopup.d.ts +0 -14
  257. package/dist/esm/types/src/components/ContactInfoPopup/components/BusinessSection/BusinessSection.d.ts +0 -7
  258. package/dist/esm/types/src/components/ContactInfoPopup/components/BusinessSection/index.d.ts +0 -1
  259. package/dist/esm/types/src/components/ContactInfoPopup/components/ContactMethod/ContactMethod.d.ts +0 -10
  260. package/dist/esm/types/src/components/ContactInfoPopup/components/ContactMethod/index.d.ts +0 -1
  261. package/dist/esm/types/src/components/ContactInfoPopup/components/Header/Header.d.ts +0 -12
  262. package/dist/esm/types/src/components/ContactInfoPopup/components/Header/index.d.ts +0 -1
  263. package/dist/esm/types/src/components/ContactInfoPopup/components/LabelsSection/LabelsSection.d.ts +0 -7
  264. package/dist/esm/types/src/components/ContactInfoPopup/components/LabelsSection/index.d.ts +0 -1
  265. package/dist/esm/types/src/components/ContactInfoPopup/components/MembersSection/MembersSection.d.ts +0 -7
  266. package/dist/esm/types/src/components/ContactInfoPopup/components/MembersSection/components/MemberItem/MemberItem.d.ts +0 -4
  267. package/dist/esm/types/src/components/ContactInfoPopup/components/MembersSection/components/MemberItem/index.d.ts +0 -1
  268. package/dist/esm/types/src/components/ContactInfoPopup/components/MembersSection/components/index.d.ts +0 -1
  269. package/dist/esm/types/src/components/ContactInfoPopup/components/MembersSection/index.d.ts +0 -1
  270. package/dist/esm/types/src/components/ContactInfoPopup/components/Properties/Properties.d.ts +0 -7
  271. package/dist/esm/types/src/components/ContactInfoPopup/components/Properties/index.d.ts +0 -1
  272. package/dist/esm/types/src/components/ContactInfoPopup/components/index.d.ts +0 -6
  273. package/dist/esm/types/src/components/ContactInfoPopup/index.d.ts +0 -1
  274. package/dist/esm/types/src/components/ContactInfoPopup/types/is-business.typeguard.d.ts +0 -7
  275. package/dist/esm/types/src/components/ContactInfoPopup/types/is-contact.typeguard.d.ts +0 -7
  276. package/dist/esm/types/src/components/ModalEvents/ModalEvents.d.ts +0 -23
  277. package/dist/esm/types/src/components/ModalEvents/index.d.ts +0 -7
  278. package/dist/esm/types/src/components/ModalEvents/types/index.d.ts +0 -352
  279. package/dist/esm/types/src/components/TextBox/TestBox.d.ts +0 -8
  280. package/dist/esm/types/src/components/TextBox/index.d.ts +0 -1
  281. package/dist/esm/types/src/components/index.d.ts +0 -4
  282. package/dist/esm/types/src/index.d.ts +0 -1
  283. package/dist/types/components/ContactInfoPopup/ContactInfoPopup.stories.d.ts +0 -9
  284. package/dist/types/components/EditContactModal/EditContactModal.stories.d.ts +0 -9
  285. package/dist/types/components/EventsDialog/components/IsPrivateCheckbox/IsPrivateCheckbox.d.ts +0 -7
  286. package/dist/types/components/EventsDialog/components/IsPrivateCheckbox/index.d.ts +0 -1
  287. package/dist/types/components/EventsDialog/components/LinkContactsSelect/styles.d.ts +0 -7
  288. package/dist/types/components/EventsDialog/components/LocationTextField/MapLocationPicker.d.ts +0 -8
  289. package/dist/types/components/EventsDialog/components/LocationTextField/SendLocation/components/GoogleMap/index.d.ts +0 -1
  290. package/dist/types/components/EventsDialog/components/LocationTextField/SendLocation/components/index.d.ts +0 -1
  291. package/dist/types/components/EventsDialog/components/LocationTextField/SendLocation/index.d.ts +0 -3
  292. package/dist/types/components/EventsDialog/components/ShareUsersSelect/ShareUsersSelect.d.ts +0 -7
  293. package/dist/types/components/EventsDialog/components/ShareUsersSelect/index.d.ts +0 -1
  294. package/dist/types/components/EventsDialog/components/ShareUsersSelect/styles.d.ts +0 -4
  295. package/dist/types/components/EventsDialog/components/SyncWithGoogleField/SyncWithGoogleField.d.ts +0 -5
  296. package/dist/types/components/EventsDialog/context/types/CalendarContextType.d.ts +0 -0
  297. package/dist/types/components/EventsDialog/hooks/index.d.ts +0 -9
  298. package/dist/types/components/EventsDialog/hooks/useAppDispatch.d.ts +0 -17
  299. package/dist/types/components/EventsDialog/hooks/useSelect.d.ts +0 -14
  300. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/activitiesSlice.d.ts +0 -27
  301. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/types/ActivitiesSlice.d.ts +0 -12
  302. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/types/ActivitiesTableColumnName.d.ts +0 -1
  303. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/types/AddActivityRequestData.d.ts +0 -19
  304. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/types/EventNotificationFront.d.ts +0 -2
  305. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/types/UpdateActivityRequestData.d.ts +0 -6
  306. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/utils/activitiesSliceService.d.ts +0 -12
  307. package/dist/types/components/EventsDialog/redux/features/activitiesSlice/utils/selectors.d.ts +0 -132
  308. package/dist/types/components/EventsDialog/redux/features/calendarsSlice/calendarsSlice.d.ts +0 -12
  309. package/dist/types/components/EventsDialog/redux/features/calendarsSlice/types/AddCalendarResquestData.d.ts +0 -5
  310. package/dist/types/components/EventsDialog/redux/features/calendarsSlice/types/CalendarSlice.d.ts +0 -10
  311. package/dist/types/components/EventsDialog/redux/features/calendarsSlice/utils/calendarsSliceService.d.ts +0 -9
  312. package/dist/types/components/EventsDialog/redux/features/calendarsSlice/utils/selectors.d.ts +0 -106
  313. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/contactInfoService.d.ts +0 -22
  314. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/contactInfoSlice.d.ts +0 -519
  315. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/ContactData.d.ts +0 -7
  316. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/ContactFile.d.ts +0 -7
  317. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/ContactInfoState.d.ts +0 -20
  318. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/ContactNotes.d.ts +0 -5
  319. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/ConvertContact.d.ts +0 -4
  320. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/FieldsData.d.ts +0 -7
  321. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/Filter.d.ts +0 -5
  322. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/Order.d.ts +0 -1
  323. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/Pagination.d.ts +0 -14
  324. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/PaginationInfo.d.ts +0 -7
  325. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/TableItemFormat.d.ts +0 -2
  326. package/dist/types/components/EventsDialog/redux/features/contactInfoSlice/types/UpdateField.d.ts +0 -5
  327. package/dist/types/components/EventsDialog/redux/features/poolSlice/poolSlice.d.ts +0 -5
  328. package/dist/types/components/EventsDialog/redux/features/poolSlice/types/PoolSliceState.d.ts +0 -5
  329. package/dist/types/components/EventsDialog/redux/features/sessionSlice/sessionSlice.d.ts +0 -30
  330. package/dist/types/components/EventsDialog/redux/features/sessionSlice/utils/sessionHelper.d.ts +0 -5
  331. package/dist/types/components/EventsDialog/redux/features/spaceSlice/spaceSlice.d.ts +0 -45
  332. package/dist/types/components/EventsDialog/redux/features/spaceSlice/spaceSliceService.d.ts +0 -4
  333. package/dist/types/components/EventsDialog/redux/features/spaceSlice/types/SpaceSliceState.d.ts +0 -17
  334. package/dist/types/components/EventsDialog/redux/features/spacesSlice/spacesSlice.d.ts +0 -80
  335. package/dist/types/components/EventsDialog/redux/features/spacesSlice/spacesSliceService.d.ts +0 -4
  336. package/dist/types/components/EventsDialog/redux/features/spacesSlice/types/SpacesSliceState.d.ts +0 -8
  337. package/dist/types/components/EventsDialog/redux/features/tasksSlice/tasksSlice.d.ts +0 -26
  338. package/dist/types/components/EventsDialog/redux/features/tasksSlice/types/AddTaskRequestData.d.ts +0 -7
  339. package/dist/types/components/EventsDialog/redux/features/tasksSlice/types/TasksSlice.d.ts +0 -14
  340. package/dist/types/components/EventsDialog/redux/features/tasksSlice/types/UpdateTaskRequestData.d.ts +0 -10
  341. package/dist/types/components/EventsDialog/redux/features/tasksSlice/utils/selectors.d.ts +0 -111
  342. package/dist/types/components/EventsDialog/redux/features/tasksSlice/utils/tasksSliceService.d.ts +0 -16
  343. package/dist/types/components/EventsDialog/redux/features/userSlice/types/UserSliceState.d.ts +0 -11
  344. package/dist/types/components/EventsDialog/redux/features/userSlice/userSliceService.d.ts +0 -7
  345. package/dist/types/components/EventsDialog/redux/functions/getRequestConfig.d.ts +0 -13
  346. package/dist/types/components/EventsDialog/redux/functions/initRequestData.d.ts +0 -12
  347. package/dist/types/components/EventsDialog/redux/rootReducer.d.ts +0 -35
  348. package/dist/types/components/EventsDialog/redux/store.d.ts +0 -39
  349. package/dist/types/components/EventsDialog/redux/types/AddPermissionAction.d.ts +0 -4
  350. package/dist/types/components/EventsDialog/redux/types/BasicRequests.d.ts +0 -11
  351. package/dist/types/components/EventsDialog/redux/types/ChangePermissionReadMessagesAction.d.ts +0 -4
  352. package/dist/types/components/EventsDialog/redux/types/ChangePermissionStartConversationsAction.d.ts +0 -4
  353. package/dist/types/components/EventsDialog/redux/types/ChangeScheduleFn.d.ts +0 -3
  354. package/dist/types/components/EventsDialog/redux/types/Gif.d.ts +0 -41
  355. package/dist/types/components/EventsDialog/redux/types/InitRequestDataReturn.d.ts +0 -10
  356. package/dist/types/components/EventsDialog/redux/types/PermissionReadMessagesPayload.d.ts +0 -4
  357. package/dist/types/components/EventsDialog/redux/types/PermissionStartConversationsPayload.d.ts +0 -4
  358. package/dist/types/components/EventsDialog/redux/types/RemovePermissionAction.d.ts +0 -3
  359. package/dist/types/components/EventsDialog/redux/types/RequestStatus.d.ts +0 -1
  360. package/dist/types/components/EventsDialog/redux/types/SearchBy.d.ts +0 -4
  361. package/dist/types/components/EventsDialog/redux/types/SortOrder.d.ts +0 -1
  362. package/dist/types/components/EventsDialog/redux/types/UpdateChannelThunk.d.ts +0 -6
  363. package/dist/types/components/EventsDialog/utils/eventValidation.d.ts +0 -37
  364. package/dist/types/components/EventsDialog/utils/googleMapsUtils.d.ts +0 -5
  365. package/dist/types/components/EventsDialog/utils/keyboardNavigation.d.ts +0 -24
package/dist/cjs/index.js CHANGED
@@ -1,21 +1,21 @@
1
- "use strict";var l=require("react"),s=require("@mui/material"),Ae=require("@mui/icons-material"),Ar=require("@mui/icons-material/ArrowForward"),Fr=require("@mui/icons-material/Message"),ne=require("@trii/types/dist/Contacts"),ct=require("moment"),Ke=require("react-i18next"),Br=require("i18next"),Ha=require("@mui/icons-material/Close"),Bt=require("@mui/icons-material/Edit"),$r=require("@mui/icons-material/Label"),sa=require("@mui/icons-material/Delete"),Mr=require("@mui/icons-material/PhotoCamera"),ja=require("@mui/icons-material/ArrowBack"),ut=require("@mui/icons-material/Save"),Pr=require("@mui/material/Popper"),at=require("@mui/lab"),bt=require("@trii/types/dist/Common/Channels"),J=require("dayjs"),Ur=require("@mui/icons-material/AddLocationAlt"),$t=require("@mui/x-date-pickers/AdapterDayjs"),Mt=require("@mui/x-date-pickers/LocalizationProvider"),Ga=require("@mui/x-date-pickers"),Pt=require("@mui/material/Box"),Ya=require("@mui/icons-material/Cancel"),Rr=require("@mui/x-date-pickers/TimePicker"),Je=require("@mui/x-date-pickers-pro"),we=require("@mui/system"),Nr=require("@mui/icons-material/LocalPhone"),qa=require("google-libphonenumber"),Ka=require("@mui/icons-material/Add"),Lr=require("@mui/icons-material/MoreVert"),Or=require("@mui/icons-material/WhatsApp"),zr=require("@mui/icons-material/Mms"),Wr=require("@mui/icons-material/CheckRounded"),_r=require("@mui/icons-material/CloseRounded"),Vr=require("@mui/material/CircularProgress"),Hr=require("@mui/material/InputAdornment"),Gr=require("@mui/material/Typography"),Yr=require("@mui/icons-material/Warning"),qr=require("@mui/material/Chip"),ia=require("@trii/types/dist/Calendar"),Ja=require("@mui/x-date-pickers-pro/AdapterDayjs"),Qa=require("@mui/icons-material/Place"),wa=require("@mui/icons-material/Person"),Kr=require("@mui/icons-material/CalendarMonth"),Ta=require("@mui/icons-material/Repeat"),Jr=require("@mui/icons-material/WarningAmber"),Qr=require("@mui/icons-material/ContentCopy"),Xr=require("@mui/icons-material/AccessTime"),Xa=require("@reduxjs/toolkit"),Zr=require("axios");function es(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ka={exports:{}},Ut={},Za;function ts(){if(Za)return Ut;Za=1;var e=l,a=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function d(c,u,p){var h,y={},m=null,g=null;p!==void 0&&(m=""+p),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(g=u.ref);for(h in u)r.call(u,h)&&!i.hasOwnProperty(h)&&(y[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)y[h]===void 0&&(y[h]=u[h]);return{$$typeof:a,type:c,key:m,ref:g,props:y,_owner:o.current}}return Ut.Fragment=n,Ut.jsx=d,Ut.jsxs=d,Ut}var Rt={},en;function as(){return en||(en=1,process.env.NODE_ENV!=="production"&&(function(){var e=l,a=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),b=Symbol.iterator,S="@@iterator";function x(f){if(f===null||typeof f!="object")return null;var A=b&&f[b]||f[S];return typeof A=="function"?A:null}var T=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(f){{for(var A=arguments.length,z=new Array(A>1?A-1:0),ee=1;ee<A;ee++)z[ee-1]=arguments[ee];j("error",f,z)}}function j(f,A,z){{var ee=T.ReactDebugCurrentFrame,le=ee.getStackAddendum();le!==""&&(A+="%s",z=z.concat([le]));var ge=z.map(function(ie){return String(ie)});ge.unshift("Warning: "+A),Function.prototype.apply.call(console[f],console,ge)}}var w=!1,$=!1,E=!1,F=!1,D=!1,I;I=Symbol.for("react.module.reference");function R(f){return!!(typeof f=="string"||typeof f=="function"||f===r||f===i||D||f===o||f===p||f===h||F||f===g||w||$||E||typeof f=="object"&&f!==null&&(f.$$typeof===m||f.$$typeof===y||f.$$typeof===d||f.$$typeof===c||f.$$typeof===u||f.$$typeof===I||f.getModuleId!==void 0))}function V(f,A,z){var ee=f.displayName;if(ee)return ee;var le=A.displayName||A.name||"";return le!==""?z+"("+le+")":z}function W(f){return f.displayName||"Context"}function Y(f){if(f==null)return null;if(typeof f.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case r:return"Fragment";case n:return"Portal";case i:return"Profiler";case o:return"StrictMode";case p:return"Suspense";case h:return"SuspenseList"}if(typeof f=="object")switch(f.$$typeof){case c:var A=f;return W(A)+".Consumer";case d:var z=f;return W(z._context)+".Provider";case u:return V(f,f.render,"ForwardRef");case y:var ee=f.displayName||null;return ee!==null?ee:Y(f.type)||"Memo";case m:{var le=f,ge=le._payload,ie=le._init;try{return Y(ie(ge))}catch{return null}}}return null}var B=Object.assign,X=0,H,L,k,M,O,U,G;function _(){}_.__reactDisabledLog=!0;function ae(){{if(X===0){H=console.log,L=console.info,k=console.warn,M=console.error,O=console.group,U=console.groupCollapsed,G=console.groupEnd;var f={configurable:!0,enumerable:!0,value:_,writable:!0};Object.defineProperties(console,{info:f,log:f,warn:f,error:f,group:f,groupCollapsed:f,groupEnd:f})}X++}}function de(){{if(X--,X===0){var f={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:B({},f,{value:H}),info:B({},f,{value:L}),warn:B({},f,{value:k}),error:B({},f,{value:M}),group:B({},f,{value:O}),groupCollapsed:B({},f,{value:U}),groupEnd:B({},f,{value:G})})}X<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=T.ReactCurrentDispatcher,Se;function ve(f,A,z){{if(Se===void 0)try{throw Error()}catch(le){var ee=le.stack.trim().match(/\n( *(at )?)/);Se=ee&&ee[1]||""}return`
2
- `+Se+f}}var Z=!1,Ue;{var ce=typeof WeakMap=="function"?WeakMap:Map;Ue=new ce}function q(f,A){if(!f||Z)return"";{var z=Ue.get(f);if(z!==void 0)return z}var ee;Z=!0;var le=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ge;ge=oe.current,oe.current=null,ae();try{if(A){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(De){ee=De}Reflect.construct(f,[],ie)}else{try{ie.call()}catch(De){ee=De}f.call(ie.prototype)}}else{try{throw Error()}catch(De){ee=De}f()}}catch(De){if(De&&ee&&typeof De.stack=="string"){for(var re=De.stack.split(`
1
+ "use strict";var l=require("react"),s=require("@mui/material"),Ae=require("@mui/icons-material"),Br=require("@mui/icons-material/ArrowForward"),$r=require("@mui/icons-material/Message"),ne=require("@trii/types/dist/Contacts"),ct=require("moment"),Ke=require("react-i18next"),Mr=require("i18next"),Bt=require("@trii/types"),Ga=require("@mui/icons-material/Close"),$t=require("@mui/icons-material/Edit"),Pr=require("@mui/icons-material/Label"),oa=require("@mui/icons-material/Delete"),Ur=require("@mui/icons-material/PhotoCamera"),wa=require("@mui/icons-material/ArrowBack"),ut=require("@mui/icons-material/Save"),Rr=require("@mui/material/Popper"),at=require("@mui/lab"),bt=require("@trii/types/dist/Common/Channels"),K=require("dayjs"),Nr=require("@mui/icons-material/AddLocationAlt"),Mt=require("@mui/x-date-pickers/AdapterDayjs"),Pt=require("@mui/x-date-pickers/LocalizationProvider"),Ya=require("@mui/x-date-pickers"),Ut=require("@mui/material/Box"),qa=require("@mui/icons-material/Cancel"),Lr=require("@mui/x-date-pickers/TimePicker"),Je=require("@mui/x-date-pickers-pro"),we=require("@mui/system"),Or=require("@mui/icons-material/LocalPhone"),Ka=require("google-libphonenumber"),Ja=require("@mui/icons-material/Add"),zr=require("@mui/icons-material/MoreVert"),Wr=require("@mui/icons-material/WhatsApp"),_r=require("@mui/icons-material/Mms"),Vr=require("@mui/icons-material/CheckRounded"),Hr=require("@mui/icons-material/CloseRounded"),Gr=require("@mui/material/CircularProgress"),Yr=require("@mui/material/InputAdornment"),qr=require("@mui/material/Typography"),Kr=require("@mui/icons-material/Warning"),Jr=require("@mui/material/Chip"),ia=require("@trii/types/dist/Calendar"),Qa=require("@mui/x-date-pickers-pro/AdapterDayjs"),Xa=require("@mui/icons-material/Place"),Ta=require("@mui/icons-material/Person"),Qr=require("@mui/icons-material/CalendarMonth"),Ia=require("@mui/icons-material/Repeat"),Xr=require("@mui/icons-material/WarningAmber"),Zr=require("@mui/icons-material/ContentCopy"),es=require("@mui/icons-material/AccessTime"),Za=require("@reduxjs/toolkit"),ts=require("axios");function as(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ka={exports:{}},Rt={},en;function ns(){if(en)return Rt;en=1;var e=l,a=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function d(c,u,p){var m,h={},x=null,g=null;p!==void 0&&(x=""+p),u.key!==void 0&&(x=""+u.key),u.ref!==void 0&&(g=u.ref);for(m in u)r.call(u,m)&&!i.hasOwnProperty(m)&&(h[m]=u[m]);if(c&&c.defaultProps)for(m in u=c.defaultProps,u)h[m]===void 0&&(h[m]=u[m]);return{$$typeof:a,type:c,key:x,ref:g,props:h,_owner:o.current}}return Rt.Fragment=n,Rt.jsx=d,Rt.jsxs=d,Rt}var Nt={},tn;function rs(){return tn||(tn=1,process.env.NODE_ENV!=="production"&&(function(){var e=l,a=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),y=Symbol.iterator,w="@@iterator";function b(f){if(f===null||typeof f!="object")return null;var F=y&&f[y]||f[w];return typeof F=="function"?F:null}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(f){{for(var F=arguments.length,z=new Array(F>1?F-1:0),ee=1;ee<F;ee++)z[ee-1]=arguments[ee];j("error",f,z)}}function j(f,F,z){{var ee=C.ReactDebugCurrentFrame,le=ee.getStackAddendum();le!==""&&(F+="%s",z=z.concat([le]));var ge=z.map(function(oe){return String(oe)});ge.unshift("Warning: "+F),Function.prototype.apply.call(console[f],console,ge)}}var I=!1,D=!1,E=!1,B=!1,A=!1,k;k=Symbol.for("react.module.reference");function N(f){return!!(typeof f=="string"||typeof f=="function"||f===r||f===i||A||f===o||f===p||f===m||B||f===g||I||D||E||typeof f=="object"&&f!==null&&(f.$$typeof===x||f.$$typeof===h||f.$$typeof===d||f.$$typeof===c||f.$$typeof===u||f.$$typeof===k||f.getModuleId!==void 0))}function _(f,F,z){var ee=f.displayName;if(ee)return ee;var le=F.displayName||F.name||"";return le!==""?z+"("+le+")":z}function V(f){return f.displayName||"Context"}function G(f){if(f==null)return null;if(typeof f.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case r:return"Fragment";case n:return"Portal";case i:return"Profiler";case o:return"StrictMode";case p:return"Suspense";case m:return"SuspenseList"}if(typeof f=="object")switch(f.$$typeof){case c:var F=f;return V(F)+".Consumer";case d:var z=f;return V(z._context)+".Provider";case u:return _(f,f.render,"ForwardRef");case h:var ee=f.displayName||null;return ee!==null?ee:G(f.type)||"Memo";case x:{var le=f,ge=le._payload,oe=le._init;try{return G(oe(ge))}catch{return null}}}return null}var $=Object.assign,Q=0,X,U,T,M,O,R,H;function W(){}W.__reactDisabledLog=!0;function ae(){{if(Q===0){X=console.log,U=console.info,T=console.warn,M=console.error,O=console.group,R=console.groupCollapsed,H=console.groupEnd;var f={configurable:!0,enumerable:!0,value:W,writable:!0};Object.defineProperties(console,{info:f,log:f,warn:f,error:f,group:f,groupCollapsed:f,groupEnd:f})}Q++}}function de(){{if(Q--,Q===0){var f={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:$({},f,{value:X}),info:$({},f,{value:U}),warn:$({},f,{value:T}),error:$({},f,{value:M}),group:$({},f,{value:O}),groupCollapsed:$({},f,{value:R}),groupEnd:$({},f,{value:H})})}Q<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ie=C.ReactCurrentDispatcher,Se;function ve(f,F,z){{if(Se===void 0)try{throw Error()}catch(le){var ee=le.stack.trim().match(/\n( *(at )?)/);Se=ee&&ee[1]||""}return`
2
+ `+Se+f}}var Z=!1,Ue;{var ce=typeof WeakMap=="function"?WeakMap:Map;Ue=new ce}function Y(f,F){if(!f||Z)return"";{var z=Ue.get(f);if(z!==void 0)return z}var ee;Z=!0;var le=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ge;ge=ie.current,ie.current=null,ae();try{if(F){var oe=function(){throw Error()};if(Object.defineProperty(oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(oe,[])}catch(De){ee=De}Reflect.construct(f,[],oe)}else{try{oe.call()}catch(De){ee=De}f.call(oe.prototype)}}else{try{throw Error()}catch(De){ee=De}f()}}catch(De){if(De&&ee&&typeof De.stack=="string"){for(var re=De.stack.split(`
3
3
  `),Ee=ee.stack.split(`
4
4
  `),he=re.length-1,Ce=Ee.length-1;he>=1&&Ce>=0&&re[he]!==Ee[Ce];)Ce--;for(;he>=1&&Ce>=0;he--,Ce--)if(re[he]!==Ee[Ce]){if(he!==1||Ce!==1)do if(he--,Ce--,Ce<0||re[he]!==Ee[Ce]){var _e=`
5
- `+re[he].replace(" at new "," at ");return f.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",f.displayName)),typeof f=="function"&&Ue.set(f,_e),_e}while(he>=1&&Ce>=0);break}}}finally{Z=!1,oe.current=ge,de(),Error.prepareStackTrace=le}var et=f?f.displayName||f.name:"",tt=et?ve(et):"";return typeof f=="function"&&Ue.set(f,tt),tt}function pe(f,A,z){return q(f,!1)}function Ze(f){var A=f.prototype;return!!(A&&A.isReactComponent)}function Q(f,A,z){if(f==null)return"";if(typeof f=="function")return q(f,Ze(f));if(typeof f=="string")return ve(f);switch(f){case p:return ve("Suspense");case h:return ve("SuspenseList")}if(typeof f=="object")switch(f.$$typeof){case u:return pe(f.render);case y:return Q(f.type,A,z);case m:{var ee=f,le=ee._payload,ge=ee._init;try{return Q(ge(le),A,z)}catch{}}}return""}var $e=Object.prototype.hasOwnProperty,We={},Ge=T.ReactDebugCurrentFrame;function ue(f){if(f){var A=f._owner,z=Q(f.type,f._source,A?A.type:null);Ge.setExtraStackFrame(z)}else Ge.setExtraStackFrame(null)}function Kt(f,A,z,ee,le){{var ge=Function.call.bind($e);for(var ie in f)if(ge(f,ie)){var re=void 0;try{if(typeof f[ie]!="function"){var Ee=Error((ee||"React class")+": "+z+" type `"+ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof f[ie]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ee.name="Invariant Violation",Ee}re=f[ie](A,ie,ee,z,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(he){re=he}re&&!(re instanceof Error)&&(ue(le),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ee||"React class",z,ie,typeof re),ue(null)),re instanceof Error&&!(re.message in We)&&(We[re.message]=!0,ue(le),C("Failed %s type: %s",z,re.message),ue(null))}}}var rt=Array.isArray;function jt(f){return rt(f)}function wt(f){{var A=typeof Symbol=="function"&&Symbol.toStringTag,z=A&&f[Symbol.toStringTag]||f.constructor.name||"Object";return z}}function Jt(f){try{return Qt(f),!1}catch{return!0}}function Qt(f){return""+f}function Tt(f){if(Jt(f))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",wt(f)),Qt(f)}var lt=T.ReactCurrentOwner,Re={key:!0,ref:!0,__self:!0,__source:!0},dt,se,fe;fe={};function Ye(f){if($e.call(f,"ref")){var A=Object.getOwnPropertyDescriptor(f,"ref").get;if(A&&A.isReactWarning)return!1}return f.ref!==void 0}function Me(f){if($e.call(f,"key")){var A=Object.getOwnPropertyDescriptor(f,"key").get;if(A&&A.isReactWarning)return!1}return f.key!==void 0}function Xt(f,A){if(typeof f.ref=="string"&&lt.current&&A&&lt.current.stateNode!==A){var z=Y(lt.current.type);fe[z]||(C('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',Y(lt.current.type),f.ref),fe[z]=!0)}}function Ne(f,A){{var z=function(){dt||(dt=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};z.isReactWarning=!0,Object.defineProperty(f,"key",{get:z,configurable:!0})}}function ba(f,A){{var z=function(){se||(se=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};z.isReactWarning=!0,Object.defineProperty(f,"ref",{get:z,configurable:!0})}}var va=function(f,A,z,ee,le,ge,ie){var re={$$typeof:a,type:f,key:A,ref:z,props:ie,_owner:ge};return re._store={},Object.defineProperty(re._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(re,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ee}),Object.defineProperty(re,"_source",{configurable:!1,enumerable:!1,writable:!1,value:le}),Object.freeze&&(Object.freeze(re.props),Object.freeze(re)),re};function Zt(f,A,z,ee,le){{var ge,ie={},re=null,Ee=null;z!==void 0&&(Tt(z),re=""+z),Me(A)&&(Tt(A.key),re=""+A.key),Ye(A)&&(Ee=A.ref,Xt(A,le));for(ge in A)$e.call(A,ge)&&!Re.hasOwnProperty(ge)&&(ie[ge]=A[ge]);if(f&&f.defaultProps){var he=f.defaultProps;for(ge in he)ie[ge]===void 0&&(ie[ge]=he[ge])}if(re||Ee){var Ce=typeof f=="function"?f.displayName||f.name||"Unknown":f;re&&Ne(ie,Ce),Ee&&ba(ie,Ce)}return va(f,re,Ee,le,ee,lt.current,ie)}}var kt=T.ReactCurrentOwner,ea=T.ReactDebugCurrentFrame;function qe(f){if(f){var A=f._owner,z=Q(f.type,f._source,A?A.type:null);ea.setExtraStackFrame(z)}else ea.setExtraStackFrame(null)}var It;It=!1;function gt(f){return typeof f=="object"&&f!==null&&f.$$typeof===a}function Le(){{if(kt.current){var f=Y(kt.current.type);if(f)return`
5
+ `+re[he].replace(" at new "," at ");return f.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",f.displayName)),typeof f=="function"&&Ue.set(f,_e),_e}while(he>=1&&Ce>=0);break}}}finally{Z=!1,ie.current=ge,de(),Error.prepareStackTrace=le}var et=f?f.displayName||f.name:"",tt=et?ve(et):"";return typeof f=="function"&&Ue.set(f,tt),tt}function pe(f,F,z){return Y(f,!1)}function Ze(f){var F=f.prototype;return!!(F&&F.isReactComponent)}function J(f,F,z){if(f==null)return"";if(typeof f=="function")return Y(f,Ze(f));if(typeof f=="string")return ve(f);switch(f){case p:return ve("Suspense");case m:return ve("SuspenseList")}if(typeof f=="object")switch(f.$$typeof){case u:return pe(f.render);case h:return J(f.type,F,z);case x:{var ee=f,le=ee._payload,ge=ee._init;try{return J(ge(le),F,z)}catch{}}}return""}var $e=Object.prototype.hasOwnProperty,We={},Ge=C.ReactDebugCurrentFrame;function ue(f){if(f){var F=f._owner,z=J(f.type,f._source,F?F.type:null);Ge.setExtraStackFrame(z)}else Ge.setExtraStackFrame(null)}function Jt(f,F,z,ee,le){{var ge=Function.call.bind($e);for(var oe in f)if(ge(f,oe)){var re=void 0;try{if(typeof f[oe]!="function"){var Ee=Error((ee||"React class")+": "+z+" type `"+oe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof f[oe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ee.name="Invariant Violation",Ee}re=f[oe](F,oe,ee,z,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(he){re=he}re&&!(re instanceof Error)&&(ue(le),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ee||"React class",z,oe,typeof re),ue(null)),re instanceof Error&&!(re.message in We)&&(We[re.message]=!0,ue(le),S("Failed %s type: %s",z,re.message),ue(null))}}}var rt=Array.isArray;function jt(f){return rt(f)}function wt(f){{var F=typeof Symbol=="function"&&Symbol.toStringTag,z=F&&f[Symbol.toStringTag]||f.constructor.name||"Object";return z}}function Qt(f){try{return Xt(f),!1}catch{return!0}}function Xt(f){return""+f}function Tt(f){if(Qt(f))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",wt(f)),Xt(f)}var lt=C.ReactCurrentOwner,Re={key:!0,ref:!0,__self:!0,__source:!0},dt,se,fe;fe={};function Ye(f){if($e.call(f,"ref")){var F=Object.getOwnPropertyDescriptor(f,"ref").get;if(F&&F.isReactWarning)return!1}return f.ref!==void 0}function Me(f){if($e.call(f,"key")){var F=Object.getOwnPropertyDescriptor(f,"key").get;if(F&&F.isReactWarning)return!1}return f.key!==void 0}function Zt(f,F){if(typeof f.ref=="string"&&lt.current&&F&&lt.current.stateNode!==F){var z=G(lt.current.type);fe[z]||(S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',G(lt.current.type),f.ref),fe[z]=!0)}}function Ne(f,F){{var z=function(){dt||(dt=!0,S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};z.isReactWarning=!0,Object.defineProperty(f,"key",{get:z,configurable:!0})}}function va(f,F){{var z=function(){se||(se=!0,S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};z.isReactWarning=!0,Object.defineProperty(f,"ref",{get:z,configurable:!0})}}var Ca=function(f,F,z,ee,le,ge,oe){var re={$$typeof:a,type:f,key:F,ref:z,props:oe,_owner:ge};return re._store={},Object.defineProperty(re._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(re,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ee}),Object.defineProperty(re,"_source",{configurable:!1,enumerable:!1,writable:!1,value:le}),Object.freeze&&(Object.freeze(re.props),Object.freeze(re)),re};function ea(f,F,z,ee,le){{var ge,oe={},re=null,Ee=null;z!==void 0&&(Tt(z),re=""+z),Me(F)&&(Tt(F.key),re=""+F.key),Ye(F)&&(Ee=F.ref,Zt(F,le));for(ge in F)$e.call(F,ge)&&!Re.hasOwnProperty(ge)&&(oe[ge]=F[ge]);if(f&&f.defaultProps){var he=f.defaultProps;for(ge in he)oe[ge]===void 0&&(oe[ge]=he[ge])}if(re||Ee){var Ce=typeof f=="function"?f.displayName||f.name||"Unknown":f;re&&Ne(oe,Ce),Ee&&va(oe,Ce)}return Ca(f,re,Ee,le,ee,lt.current,oe)}}var It=C.ReactCurrentOwner,ta=C.ReactDebugCurrentFrame;function qe(f){if(f){var F=f._owner,z=J(f.type,f._source,F?F.type:null);ta.setExtraStackFrame(z)}else ta.setExtraStackFrame(null)}var kt;kt=!1;function gt(f){return typeof f=="object"&&f!==null&&f.$$typeof===a}function Le(){{if(It.current){var f=G(It.current.type);if(f)return`
6
6
 
7
- Check the render method of \``+f+"`."}return""}}function mt(f){{if(f!==void 0){var A=f.fileName.replace(/^.*[\\\/]/,""),z=f.lineNumber;return`
7
+ Check the render method of \``+f+"`."}return""}}function mt(f){{if(f!==void 0){var F=f.fileName.replace(/^.*[\\\/]/,""),z=f.lineNumber;return`
8
8
 
9
- Check your code at `+A+":"+z+"."}return""}}var ht={};function ta(f){{var A=Le();if(!A){var z=typeof f=="string"?f:f.displayName||f.name;z&&(A=`
9
+ Check your code at `+F+":"+z+"."}return""}}var ht={};function aa(f){{var F=Le();if(!F){var z=typeof f=="string"?f:f.displayName||f.name;z&&(F=`
10
10
 
11
- Check the top-level render call using <`+z+">.")}return A}}function aa(f,A){{if(!f._store||f._store.validated||f.key!=null)return;f._store.validated=!0;var z=ta(A);if(ht[z])return;ht[z]=!0;var ee="";f&&f._owner&&f._owner!==kt.current&&(ee=" It was passed a child from "+Y(f._owner.type)+"."),qe(f),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',z,ee),qe(null)}}function Qe(f,A){{if(typeof f!="object")return;if(jt(f))for(var z=0;z<f.length;z++){var ee=f[z];gt(ee)&&aa(ee,A)}else if(gt(f))f._store&&(f._store.validated=!0);else if(f){var le=x(f);if(typeof le=="function"&&le!==f.entries)for(var ge=le.call(f),ie;!(ie=ge.next()).done;)gt(ie.value)&&aa(ie.value,A)}}}function na(f){{var A=f.type;if(A==null||typeof A=="string")return;var z;if(typeof A=="function")z=A.propTypes;else if(typeof A=="object"&&(A.$$typeof===u||A.$$typeof===y))z=A.propTypes;else return;if(z){var ee=Y(A);Kt(z,f.props,"prop",ee,f)}else if(A.PropTypes!==void 0&&!It){It=!0;var le=Y(A);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",le||"Unknown")}typeof A.getDefaultProps=="function"&&!A.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function st(f){{for(var A=Object.keys(f.props),z=0;z<A.length;z++){var ee=A[z];if(ee!=="children"&&ee!=="key"){qe(f),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ee),qe(null);break}}f.ref!==null&&(qe(f),C("Invalid attribute `ref` supplied to `React.Fragment`."),qe(null))}}var ra={};function yt(f,A,z,ee,le,ge){{var ie=R(f);if(!ie){var re="";(f===void 0||typeof f=="object"&&f!==null&&Object.keys(f).length===0)&&(re+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ee=mt(le);Ee?re+=Ee:re+=Le();var he;f===null?he="null":jt(f)?he="array":f!==void 0&&f.$$typeof===a?(he="<"+(Y(f.type)||"Unknown")+" />",re=" Did you accidentally export a JSX literal instead of a component?"):he=typeof f,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",he,re)}var Ce=Zt(f,A,z,le,ge);if(Ce==null)return Ce;if(ie){var _e=A.children;if(_e!==void 0)if(ee)if(jt(_e)){for(var et=0;et<_e.length;et++)Qe(_e[et],f);Object.freeze&&Object.freeze(_e)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Qe(_e,f)}if($e.call(A,"key")){var tt=Y(f),De=Object.keys(A).filter(function(Sa){return Sa!=="key"}),xt=De.length>0?"{key: someKey, "+De.join(": ..., ")+": ...}":"{key: someKey}";if(!ra[tt+xt]){var Ca=De.length>0?"{"+De.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
11
+ Check the top-level render call using <`+z+">.")}return F}}function na(f,F){{if(!f._store||f._store.validated||f.key!=null)return;f._store.validated=!0;var z=aa(F);if(ht[z])return;ht[z]=!0;var ee="";f&&f._owner&&f._owner!==It.current&&(ee=" It was passed a child from "+G(f._owner.type)+"."),qe(f),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',z,ee),qe(null)}}function Qe(f,F){{if(typeof f!="object")return;if(jt(f))for(var z=0;z<f.length;z++){var ee=f[z];gt(ee)&&na(ee,F)}else if(gt(f))f._store&&(f._store.validated=!0);else if(f){var le=b(f);if(typeof le=="function"&&le!==f.entries)for(var ge=le.call(f),oe;!(oe=ge.next()).done;)gt(oe.value)&&na(oe.value,F)}}}function ra(f){{var F=f.type;if(F==null||typeof F=="string")return;var z;if(typeof F=="function")z=F.propTypes;else if(typeof F=="object"&&(F.$$typeof===u||F.$$typeof===h))z=F.propTypes;else return;if(z){var ee=G(F);Jt(z,f.props,"prop",ee,f)}else if(F.PropTypes!==void 0&&!kt){kt=!0;var le=G(F);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",le||"Unknown")}typeof F.getDefaultProps=="function"&&!F.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function st(f){{for(var F=Object.keys(f.props),z=0;z<F.length;z++){var ee=F[z];if(ee!=="children"&&ee!=="key"){qe(f),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ee),qe(null);break}}f.ref!==null&&(qe(f),S("Invalid attribute `ref` supplied to `React.Fragment`."),qe(null))}}var sa={};function yt(f,F,z,ee,le,ge){{var oe=N(f);if(!oe){var re="";(f===void 0||typeof f=="object"&&f!==null&&Object.keys(f).length===0)&&(re+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ee=mt(le);Ee?re+=Ee:re+=Le();var he;f===null?he="null":jt(f)?he="array":f!==void 0&&f.$$typeof===a?(he="<"+(G(f.type)||"Unknown")+" />",re=" Did you accidentally export a JSX literal instead of a component?"):he=typeof f,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",he,re)}var Ce=ea(f,F,z,le,ge);if(Ce==null)return Ce;if(oe){var _e=F.children;if(_e!==void 0)if(ee)if(jt(_e)){for(var et=0;et<_e.length;et++)Qe(_e[et],f);Object.freeze&&Object.freeze(_e)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Qe(_e,f)}if($e.call(F,"key")){var tt=G(f),De=Object.keys(F).filter(function(ja){return ja!=="key"}),xt=De.length>0?"{key: someKey, "+De.join(": ..., ")+": ...}":"{key: someKey}";if(!sa[tt+xt]){var Sa=De.length>0?"{"+De.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
12
12
  let props = %s;
13
13
  <%s {...props} />
14
14
  React keys must be passed directly to JSX without using spread:
15
15
  let props = %s;
16
- <%s key={someKey} {...props} />`,xt,tt,Ca,tt),ra[tt+xt]=!0}}return f===r?st(Ce):na(Ce),Ce}}function Et(f,A,z){return yt(f,A,z,!0)}function Dt(f,A,z){return yt(f,A,z,!1)}var At=Dt,Ft=Et;Rt.Fragment=r,Rt.jsx=At,Rt.jsxs=Ft})()),Rt}process.env.NODE_ENV==="production"?ka.exports=ts():ka.exports=as();var t=ka.exports;es(t);const ns=s.styled(s.Box)(({theme:e})=>({position:"absolute",top:8,right:8,display:"flex",flexDirection:"column",gap:4,zIndex:1,backgroundColor:e.palette.background.panel})),tn=s.styled(s.IconButton)({padding:4}),rs=s.styled(s.Box)({display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"16px",position:"relative"}),ss=s.styled(s.Avatar)({width:60,height:60,marginBottom:8}),is=s.styled(s.Typography)({whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:200,textAlign:"center"}),os=s.styled(s.Box)({display:"flex",justifyContent:"center",alignItems:"center",width:60,height:60,marginBottom:8}),ls=({imgUrl:e,name:a,contactId:n,navigate:r,isLoading:o=!1,onError:i,onClose:d,isBusiness:c=!1})=>{const u=l.useCallback(g=>b=>{try{if(b.preventDefault(),b.stopPropagation(),!g)throw new Error("Navigation URL is required");b.ctrlKey||b.metaKey||b.button===1?window.open(g,"_blank","noopener,noreferrer"):r(g)}catch(S){i?.(S instanceof Error?S:new Error("Navigation failed"))}},[r,i]),p=u(c?`/a/contacts/business/${n}`:`/a/contacts/contacts/${n}`),h=u(`/a/conversations/conversations?contactId=${n}`),y=a||"Unknown Contact",m=`Avatar for ${y}`;return t.jsxs(rs,{children:[t.jsxs(ns,{children:[t.jsx(tn,{color:"info",size:"small",onClick:g=>{p(g),d()},onMouseDown:g=>{g.button===1&&(p(g),d())},disabled:!n,"aria-label":"View contact details",children:t.jsx(Ar,{fontSize:"small"})}),t.jsx(tn,{color:"info",size:"small",onClick:g=>{h(g),d()},onMouseDown:g=>{g.button===1&&(h(g),d())},"aria-label":"Go to conversations",children:t.jsx(Fr,{fontSize:"small"})})]}),o?t.jsx(os,{children:t.jsx(s.CircularProgress,{size:24})}):t.jsx(ss,{src:e,alt:m,onError:()=>i?.(new Error("Failed to load avatar"))}),t.jsx(is,{variant:"h6",title:y,children:y})]})},ds=s.styled(s.Box)({display:"flex",flexDirection:"column",width:"100%",height:"max-content",alignItems:"center",gap:8}),cs=s.styled(s.Box)({width:"100%",borderBottom:"1px solid lightgray"}),us=s.styled(s.Box)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:1,minHeight:"50px",position:"relative",maxWidth:"inherit"}),ps=s.styled(s.Box)(({theme:e})=>({marginTop:"-20px",padding:0,color:e.palette.primary.main})),fs=s.styled(s.Box)({display:"flex",maxWidth:"90%",gap:"10px",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",alignItems:"center"}),gs=s.styled(s.Box)({display:"flex",flexDirection:"column",height:"50px",maxWidth:"90%"}),ms=s.styled(s.Typography)({whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",maxWidth:"90%",position:"absolute",bottom:16,left:40}),hs=({icon:e,contactList:a,title:n,showTitle:r=!0})=>{const o=i=>t.jsx(us,{children:t.jsxs(fs,{children:[t.jsx(ps,{children:e}),t.jsxs(gs,{children:[t.jsx(s.Tooltip,{title:i.address,arrow:!0,placement:"top",children:t.jsx(s.Typography,{variant:"subtitle1",fontWeight:"semi-bold",fontSize:14,color:"text.primary",sx:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",cursor:"default"},children:i.address})}),i.profileName&&t.jsx(s.Typography,{variant:"body2",fontSize:10,color:"text.disabled",sx:{marginLeft:"5px",marginTop:"10px"},children:i.profileName})]}),i.note&&t.jsx(ms,{variant:"body2",fontSize:12,color:"text.secondary",children:i.note})]})},i.id);return t.jsxs(ds,{children:[r&&t.jsx(cs,{children:t.jsx(s.Typography,{variant:"subtitle1",fontWeight:"bold",gutterBottom:!0,mt:2,children:n})}),a?.map(o)]})},ys=s.styled(s.Box)({display:"flex",flexDirection:"column",width:"100%",height:"max-content",alignItems:"center",gap:8}),xs=s.styled(s.Typography)({borderBottom:"1px solid lightgray",width:"100%"}),bs=s.styled(s.Box)({display:"flex",alignItems:"center",gap:8,width:"100%"}),vs=s.styled(s.Typography)({fontSize:14}),Cs=s.styled(Ae.Handyman)(({theme:e})=>({color:e.palette.primary.main,fontSize:16})),Ss=({properties:e,title:a})=>{const n=o=>o.replace(/-/g," "),r=(o,i)=>{if(!o||Array.isArray(o)&&o.length===0)return"";if(Array.isArray(o))return o.map(d=>r(d,i)).join(", ");if(typeof o=="string"){const d=ct(o,ct.ISO_8601).isValid(),c=u=>ct(o).format(u);switch(i){case ne.ContactField_type.TIME:return d?c("HH:mm"):o;case ne.ContactField_type.DATE:return d?c("DD/MM/YYYY"):o;case ne.ContactField_type.TIMERANGE:case ne.ContactField_type.DATERANGE:if(d)return i===ne.ContactField_type.TIMERANGE?c("HH:mm"):c("DD/MM/YYYY");const u=o.split(" ");if(u.length===2){const[p,h]=u,y=i===ne.ContactField_type.TIMERANGE?ct(p).format("HH:mm"):ct(p).format("DD/MM/YYYY"),m=i===ne.ContactField_type.TIMERANGE?ct(h).format("HH:mm"):ct(h).format("DD/MM/YYYY");return`${y} - ${m}`}return o;default:return o}}return o};return t.jsxs(ys,{children:[t.jsx(xs,{fontWeight:"bold",gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),e?.map((o,i)=>o.value.length>0&&t.jsxs(bs,{children:[t.jsx(Cs,{}),t.jsxs(vs,{children:[n(o.nameKey),":"," ",r(o.value,o.type)]})]},i))]})},js=s.styled(s.Typography)({fontWeight:"bold",marginBottom:"8px",marginTop:"16px",borderBottom:"1px solid lightgray"}),ws=s.styled(s.Box)({marginBottom:16}),Ts=s.styled(s.Chip)(({theme:e})=>({marginRight:8,marginBottom:8,backgroundColor:`${e.palette.primary.main}b3`})),ks=({contactData:e,title:a})=>!e||!e.tags?.length?null:t.jsxs(t.Fragment,{children:[t.jsx(js,{gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),t.jsx(ws,{children:e?.tags?.filter(n=>n.name?.trim()).map(n=>t.jsx(Ts,{label:n.name,color:"primary",size:"small"},n.id))})]});function an(e){return e?.isBusiness===!0?!1:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&typeof e.firstName=="string"&&typeof e.lastName=="string"&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&"origin"in e&&typeof e.isSpam=="boolean"&&(!e.businessId||typeof e.businessId=="string")}const Is=s.styled(s.Typography)({fontWeight:"bold",marginBottom:"8px",marginTop:"16px",borderBottom:"1px solid lightgray"}),Es=({contactData:e,title:a})=>!e||!an(e)?null:t.jsxs(t.Fragment,{children:[t.jsx(Is,{gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),t.jsx(s.Typography,{variant:"body2",color:"text.secondary",children:e?.businessName})]});function nn(e){return e?.isBusiness===!0?!0:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&Array.isArray(e.membersId)&&Array.isArray(e.members)&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&typeof e.imageUrl=="string"&&!("firstName"in e)&&!("lastName"in e)}const Ds=({name:e,memberId:a,navigate:n})=>{const r=`/a/conversations/conversations?contactId=${a}`,o=i=>{i.preventDefault(),i.stopPropagation(),i.ctrlKey||i.metaKey||i.button===1?window.open(r,"_blank","noopener,noreferrer"):n(r)};return t.jsx(s.Typography,{variant:"body2",color:"text.secondary",role:"link",tabIndex:0,sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:o,onMouseDown:i=>{i.button===1&&o(i)},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:e})},As=s.styled(s.Typography)({fontWeight:"bold",marginBottom:"8px",marginTop:"16px",borderBottom:"1px solid lightgray"}),Fs=({contactData:e,title:a,navigate:n})=>!e||!nn(e)||!e.members?.length?null:t.jsxs(t.Fragment,{children:[t.jsx(As,{gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),e?.members.map(r=>t.jsx(Ds,{memberId:String(r.id),name:r.name,navigate:n},r.id))]});var Bs="Labels",$s="Phone",Ms="Business",Ps="Business Members",Us="Properties",Rs="View",Ns="Tags",Ls={add:"Add",note:"Note",number:"Number",email:"Email",phones:"Phones",close:"Close",back:"Back",createNew:"Create new",delete:"Delete",cancel:"Cancel",save:"Save",noOptions:"No options",noValue:"No value",birthdate:"Birthdate",country:"Country",searchLocation:"Search location",date:"Date",from:"From",to:"To",time:"Time",title:"Title",addTitle:"Add title",description:"Description",location:"Location",addLocation:"Add location",selectLocation:"Select location",color:"Color",allDay:"All day",calendar:"Calendar",selectCalendar:"Select calendar",recurrence:"Recurrence",noRepeat:"Does not repeat",edit:"Edit",duplicate:"Duplicate",event:"Event",task:"Task",editEvent:"Edit event",editTask:"Edit task",saveEvent:"Save event",saveTask:"Save task",createEvent:"Create event",createTask:"Create task",finalizeEvent:"Finalize event",markAsCompleted:"Mark as completed",markAsIncomplete:"Mark as incomplete",linkContacts:"Linked contacts",searchContacts:"Search contacts",errorSavingChanges:"Error saving changes",savingChanges:"Saving changes...",changesSaved:"Changes saved",nameRequired:"Name is required",calendarCreatedSuccess:"Calendar created successfully",calendarUpdatedSuccess:"Calendar updated successfully",eventAlreadyDeleted:"Event has already been deleted",taskAlreadyDeleted:"Task has already been deleted",deleting:"Deleting...",confirm:"Confirm",name:"Name",create:"Create",showEvent:"Show Event",finalizeTask:"Finalize Task",showTask:"Show Task",createCalendar:"Create Calendar",editCalendar:"Edit Calendar",calendarInfo:"Calendar Information",deleteCalendar:"Delete Calendar",deleteConfirm:'Are you sure you want to delete the calendar "{{title}}"?',day:"Day",week:"Week",month:"Month",today:"Today",next:"Next",reminders:"Reminders",addReminder:"Add Reminder",shareWithUsers:"Share with Users",noSharedUsers:"No shared users",loading:"Loading...",moreActions:"More Actions",createdBy:"Created by",private:"Private",everyDay:"Every day",everyWeek:"Every week",everyMonth:"Every month",everyYear:"Every year",everyTwoDays:"Every 2 days",everyTwoWeeks:"Every 2 weeks",everyWeekday:"Weekdays (M-F)",seeMore:"See more"},Os={searchAddress:"Search address",enterLocation:"Enter a location",city:"City",state:"State",postalCode:"Postal code",country:"Country",saveMainAddress:"Save main address",saveSecondaryAddress:"Save secondary address",loadingGoogleMaps:"Loading Google Maps...",googleMapsUnavailable:"Google Maps unavailable",googleMapsNotLoaded:"Google Maps not loaded",selectedPlaceNoLocation:"Selected place has no location data"},zs={upload:"Upload photo",delete:"Delete photo"},Ws={from:"From",to:"To"},_s={contactDetails:{contactOwner:"Contact Owner",business:"Business",createdBy:"Created By",modifiedBy:"Modified By",street:"Street",city:"City",state:"State",postcode:"Postcode",country:"Country",addressInformation:"Address Information",primaryAddress:"Primary Address",secondaryAddress:"Secondary Address",contactInformation:"Contact Information",phones:"Phones",contactInfo:{emptySelection:"No selection"}},businessDetails:{businessOwner:"Business Owner"},sidebar:{events:{errorDate:"End date must be after start date"}}},Vs={reminders:{title:"Reminders",addReminder:"Add Reminder",errorDate:"The 'To' date must be greater than the 'From' date",searchContact:"Search Contact",sendReminder:{pt1:"Send reminder",pt2:"before."},timePeriod:{minute:"minute/s",hour:"hour/s",day:"day/s"},sendReminderToContact:"Send reminder to external contact"},shortcuts:{title:"Keyboard Shortcuts",advice:"Tip: You can use these shortcuts to speed up event creation and editing"},myCalendars:"My calendars",noCalendar:"No calendar",othersCalendars:"Other calendars"},Hs={labels:Bs,phone:$s,business:Ms,businessMembers:Ps,properties:Us,view:Rs,tags:Ns,global:Ls,searchLocationModal:Os,avatar:zs,contactEdit:Ws,conversations:_s,calendarView:Vs},Gs="Etiquetas",Ys="Tel\xE9fono",qs="Empresa",Ks="Miembros de la empresa",Js="Propiedades",Qs="Ver",Xs="Etiquetas",Zs={add:"Agregar",note:"Nota",number:"N\xFAmero",email:"Correo electr\xF3nico",phones:"Tel\xE9fonos",close:"Cerrar",back:"Volver",createNew:"Crear nuevo",delete:"Eliminar",cancel:"Cancelar",save:"Guardar",noOptions:"Sin opciones",noValue:"Sin valor",birthdate:"Fecha de nacimiento",country:"Pa\xEDs",searchLocation:"Buscar ubicaci\xF3n",date:"Fecha",from:"Desde",to:"Hasta",time:"Hora",title:"T\xEDtulo",addTitle:"Agregar t\xEDtulo",description:"Descripci\xF3n",location:"Ubicaci\xF3n",addLocation:"Agregar ubicaci\xF3n",selectLocation:"Seleccionar ubicaci\xF3n",color:"Color",allDay:"Todo el d\xEDa",calendar:"Calendario",selectCalendar:"Seleccionar calendario",recurrence:"Recurrencia",noRepeat:"No se repite",edit:"Editar",duplicate:"Duplicar",event:"Evento",task:"Tarea",editEvent:"Editar evento",editTask:"Editar tarea",saveEvent:"Guardar evento",saveTask:"Guardar tarea",createEvent:"Crear evento",createTask:"Crear tarea",finalizeEvent:"Finalizar evento",markAsCompleted:"Marcar como completado",markAsIncomplete:"Marcar como incompleto",linkContacts:"Contactos vinculados",searchContacts:"Buscar contactos",errorSavingChanges:"Error al guardar los cambios",savingChanges:"Guardando cambios...",changesSaved:"Cambios guardados",nameRequired:"El nombre es obligatorio",calendarCreatedSuccess:"Calendario creado con \xE9xito",calendarUpdatedSuccess:"Calendario actualizado con \xE9xito",eventAlreadyDeleted:"l evento ya ha sido eliminado",taskAlreadyDeleted:"La tarea ya ha sido eliminada",deleting:"Eliminando...",confirm:"Confirmar",name:"Nombre",create:"Crear",showEvent:"Mostrar evento",finalizeTask:"Finalizar tarea",showTask:"Mostrar tarea",createCalendar:"Crear calendario",editCalendar:"Editar calendario",calendarInfo:"Informaci\xF3n del calendario",deleteCalendar:"Eliminar calendario",deleteConfirm:'\xBFEst\xE1 seguro de que desea eliminar el calendario "{{title}}"?',day:"\xEDa",week:"Semana",month:"Mes",today:"Hoy",next:"Siguiente",reminders:"Recordatorios",addReminder:"Agregar recordatorio",shareWithUsers:"Compartir con usuarios",noSharedUsers:"Sin usuarios compartidos",loading:"Cargando...",moreActions:"M\xE1s acciones",createdBy:"Creado por",private:"Privado",everyDay:"Cada d\xEDa",everyWeek:"Cada semana",everyMonth:"Cada mes",everyYear:"Cada a\xF1o",everyTwoDays:"Cada 2 d\xEDas",everyTwoWeeks:"Cada 2 semanas",everyWeekday:"D\xEDas laborables (L-V)",seeMore:"Ver m\xE1s"},ei={searchAddress:"Buscar direcci\xF3n",enterLocation:"Ingres\xE1 una ubicaci\xF3n",city:"Ciudad",state:"Estado",postalCode:"C\xF3digo postal",country:"Pa\xEDs",saveMainAddress:"Guardar como direcci\xF3n principal",saveSecondaryAddress:"Guardar como direcci\xF3n secundaria",loadingGoogleMaps:"Cargando Google Maps...",googleMapsUnavailable:"Google Maps no disponible",googleMapsNotLoaded:"Google Maps no est\xE1 cargado",selectedPlaceNoLocation:"La ubicaci\xF3n seleccionada no tiene coordenadas"},ti={upload:"Subir foto",delete:"Eliminar foto"},ai={from:"Desde",to:"Hasta"},ni={contactDetails:{contactOwner:"Propietario del contacto",business:"Empresa",createdBy:"Creado por",modifiedBy:"Modificado por",street:"Calle",city:"Ciudad",state:"Estado",postcode:"C\xF3digo postal",country:"Pa\xEDs",addressInformation:"Informaci\xF3n de direcci\xF3n",primaryAddress:"Direcci\xF3n principal",secondaryAddress:"Direcci\xF3n secundaria",contactInformation:"Informaci\xF3n de contacto",phones:"Tel\xE9fonos",contactInfo:{emptySelection:"Sin selecci\xF3n"}},businessDetails:{businessOwner:"Propietario de la empresa"},sidebar:{events:{errorDate:"La fecha de finalizaci\xF3n debe ser posterior a la fecha de inicio"}}},ri={reminders:{title:"Recordatorios",addReminder:"Agregar recordatorio",errorDate:"La fecha 'Hasta' debe ser mayor que la fecha 'Desde'",searchContact:"Buscar contacto",sendReminder:{pt1:"Enviar recordatorio",pt2:"antes."},timePeriod:{minute:"minuto/s",hour:"hora/s",day:"d\xEDa/s"},sendReminderToContact:"Enviar recordatorio al contacto externo"},shortcuts:{title:"Atajos de teclado",advice:"Consejo: Puedes usar estos atajos para acelerar la creaci\xF3n y edici\xF3n de eventos"},myCalendars:"Mis calendarios",noCalendar:"Sin calendario",othersCalendars:"Otros calendarios"},si={labels:Gs,phone:Ys,business:qs,businessMembers:Ks,properties:Js,view:Qs,tags:Xs,global:Zs,searchLocationModal:ei,avatar:ti,contactEdit:ai,conversations:ni,calendarView:ri};const ii={en:{translation:Hs},es:{translation:si}},Nt=Br.createInstance();Nt.use(Ke.initReactI18next).init({resources:ii,lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1}});const oi=s.styled(s.Box)(({theme:e})=>({backgroundColor:e.palette.background.panel,boxShadow:"0px 4px 10px rgba(0, 0, 0, 0.1)",borderRadius:"8px",width:300,maxHeight:"calc(100vh - 500px)",overflowY:"auto",transition:"opacity 0.3s ease, transform 0.3s ease",padding:"8px",zIndex:1300,"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{background:"#E0E0E0",borderRadius:10},"&::-webkit-scrollbar-thumb":{background:"#9E9E9E",borderRadius:10,transition:"background 0.3s"},"&::-webkit-scrollbar-thumb:hover":{background:"#616161"}})),li=({open:e,anchorEl:a,onClose:n,contactData:r,avatarImgUrl:o,navigate:i,language:d="en"})=>{const{t:c,i18n:u}=Ke.useTranslation();l.useEffect(()=>{d&&u.changeLanguage(d)},[d,u]);const p=c,h=nn(r),y=an(r),m=[{icon:t.jsx(Ae.PhoneEnabled,{fontSize:"small"}),title:p("phone"),contactList:r?.phones||[],showTitle:!0},{icon:t.jsx(Ae.Email,{fontSize:"small"}),title:p("email"),contactList:r?.emails||[],showTitle:!0},{icon:t.jsx(Ae.WhatsApp,{fontSize:"small"}),title:"IM",contactList:r?.ims_whatsapp||[],showTitle:!0},{icon:t.jsx(Ae.Facebook,{fontSize:"small"}),contactList:r?.ims_facebook||[],showTitle:!1},{icon:t.jsx(Ae.Instagram,{fontSize:"small"}),contactList:r?.ims_instagram||[],showTitle:!1},{icon:t.jsx(Ae.ThreeP,{fontSize:"small"}),contactList:r?.ims_webchat||[],showTitle:!1}];return l.useEffect(()=>{const g=b=>{b.key==="Escape"&&n()};return e&&window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[e,n]),t.jsx(s.Popper,{sx:{zIndex:1300},open:e,anchorEl:a,placement:"bottom-start","data-popper-child":"true",children:t.jsx(s.ClickAwayListener,{onClickAway:n,children:t.jsx(oi,{children:t.jsxs(s.CardContent,{children:[t.jsx(ls,{navigate:i,contactId:r?.id,imgUrl:o,name:r?.name,onClose:n,isBusiness:h}),t.jsx(ks,{contactData:r,title:p("labels")}),y&&t.jsx(Es,{contactData:r,title:p("business")}),h&&t.jsx(Fs,{contactData:r,title:p("businessMembers"),navigate:i}),m.map((g,b)=>t.jsx(hs,{icon:g.icon,title:g.title,contactList:g.contactList,showTitle:g.showTitle},b)),t.jsx(Ss,{properties:r?.properties,title:p("properties")})]})})})})},rn=e=>t.jsx(Ke.I18nextProvider,{i18n:Nt,children:t.jsx(li,{...e})}),sn=e=>e,on=l.createContext(sn),di=({t:e,children:a})=>t.jsx(on.Provider,{value:e,children:a}),xe=()=>{const e=l.useContext(on);return e?(...a)=>{const[n,...r]=a;return e(n,...r)}:(console.warn("[useTranslationContext] using noop, context value is falsy"),sn)},ci=({tags:e,onEditTags:a})=>{const n=xe(),[r,o]=l.useState(null),i=l.useMemo(()=>e??[],[e]),d=i.slice(0,4),c=Math.max(i.length-d.length,0),u=y=>{o(y.currentTarget)},p=()=>{o(null)},h=!!r;return t.jsxs(s.Box,{sx:{mt:1,display:"flex",justifyContent:"center"},children:[t.jsxs(s.Box,{sx:{maxWidth:320,position:"relative","&:hover .tags-action, &:focus-within .tags-action":{opacity:1}},children:[t.jsxs(s.Stack,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",justifyContent:"center",children:[d.map(y=>t.jsx(s.Chip,{label:y.name,size:"small",variant:"outlined",sx:{borderRadius:999,maxWidth:140,"& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},y.id)),c>0?t.jsx(s.Chip,{label:`+${c}`,size:"small",variant:"outlined",onClick:u,sx:{borderRadius:999}}):null]}),t.jsx(s.IconButton,{className:"tags-action",size:"small","aria-label":i.length?n("tags.edit"):n("tags.add"),onClick:a,sx:{position:"absolute",left:"100%",ml:1,top:"50%",transform:"translateY(-50%)",color:"text.secondary",bgcolor:y=>y.palette.background.panel,opacity:0,transition:"opacity 0.2s ease-in-out","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:i.length?t.jsx(Bt,{fontSize:"small"}):t.jsx($r,{fontSize:"small"})})]}),t.jsx(s.Popover,{open:h,anchorEl:r,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:t.jsxs(s.Box,{sx:{p:1.5,maxWidth:320,maxHeight:240,overflowY:"auto"},children:[t.jsx(s.Typography,{variant:"subtitle2",sx:{mb:1},children:n("tags")}),t.jsx(s.Stack,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",children:i.map(y=>t.jsx(s.Chip,{label:y.name,size:"small",variant:"outlined",sx:{borderRadius:999,maxWidth:160,"& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},y.id))})]})})]})},ln=l.createContext(null),ui=ln.Provider,it=()=>l.useContext(ln),pi=s.styled(s.Typography)({whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:360,textAlign:"center"}),fi=s.styled(s.Box)({display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}),gi=s.styled(s.Box)({position:"relative",display:"flex",justifyContent:"center",maxWidth:"100%","&:hover .edit-icon":{opacity:1,visibility:"visible"}}),mi=s.styled(s.IconButton)({opacity:0,visibility:"hidden",transition:"all 0.2s",position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)"}),hi=({displayName:e,contactType:a,firstName:n,lastName:r,name:o,entityId:i,onEntityUpdated:d})=>{const c=it(),[u,p]=l.useState(!1),[h,y]=l.useState(!1),[m,g]=l.useState({firstName:n||"",lastName:r||"",name:o||""});l.useEffect(()=>{g({firstName:n||"",lastName:r||"",name:o||""})},[n,r,o]);const b=async()=>{if(!(!c||!i||!a||a==="unknown")){y(!0);try{let x={};a==="contact"?x={firstName:m.firstName,lastName:m.lastName}:a==="business"&&(x={name:m.name});const T=await c.updateEntity({entityType:a,entityId:i,body:x});T&&d&&d(T),p(!1)}catch(x){console.error("Failed to update name",x)}finally{y(!1)}}},S=a==="contact"||a==="business";return u?t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:1},children:[a==="contact"?t.jsxs(t.Fragment,{children:[t.jsx(s.TextField,{value:m.firstName,onChange:x=>g({...m,firstName:x.target.value}),size:"small",placeholder:"First Name",sx:{width:140}}),t.jsx(s.TextField,{value:m.lastName,onChange:x=>g({...m,lastName:x.target.value}),size:"small",placeholder:"Last Name",sx:{width:140}})]}):t.jsx(s.TextField,{value:m.name,onChange:x=>g({...m,name:x.target.value}),size:"small",placeholder:"Name",sx:{width:280}}),t.jsx(s.IconButton,{onClick:b,disabled:h,color:"primary",children:h?t.jsx(s.CircularProgress,{size:24}):t.jsx(Ae.Save,{})})]}):t.jsx(fi,{children:t.jsxs(gi,{children:[t.jsx(pi,{variant:"h6",title:e,children:e}),S&&t.jsx(mi,{size:"small",onClick:()=>p(!0),className:"edit-icon",sx:{ml:1},children:t.jsx(Ae.Edit,{fontSize:"small"})})]})})},yi=({src:e,alt:a,onError:n,onUpload:r,onDelete:o,isUploading:i,isDeleting:d})=>{const c=xe();return t.jsxs(s.Box,{sx:{width:60,height:60,mb:1,position:"relative","&:hover .avatar-actions, &:focus-within .avatar-actions":{opacity:1,pointerEvents:"auto"}},children:[t.jsx(s.Avatar,{src:e,alt:a,onError:n,sx:{width:60,height:60}}),t.jsxs(s.Box,{className:"avatar-actions",sx:{position:"absolute",inset:0,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",gap:.5,bgcolor:"rgba(0, 0, 0, 0.35)",opacity:0,pointerEvents:"none",transition:"opacity 0.2s ease-in-out"},children:[t.jsx(s.IconButton,{size:"small","aria-label":c("avatar.upload"),onClick:r,disabled:!!i,sx:{color:"common.white",bgcolor:"rgba(0, 0, 0, 0.25)","&:hover":{bgcolor:"rgba(0, 0, 0, 0.35)"}},children:t.jsx(Mr,{fontSize:"small"})}),t.jsx(s.IconButton,{size:"small","aria-label":c("avatar.delete"),onClick:o,disabled:!!d,sx:{color:"common.white",bgcolor:"rgba(0, 0, 0, 0.25)","&:hover":{bgcolor:"rgba(0, 0, 0, 0.35)"}},children:t.jsx(sa,{fontSize:"small"})})]})]})},xi=s.styled(s.Box)({display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",marginBottom:"20px",position:"relative"}),bi=({imgUrl:e,displayName:a,onError:n,tags:r,onEditTags:o,onUploadPhoto:i,onPhotoFileChange:d,photoInputRef:c,isUploadingPhoto:u,onDeletePhoto:p,isDeletingPhoto:h,contactType:y,firstName:m,lastName:g,name:b,entityId:S,onEntityUpdated:x})=>{const T=`Avatar for ${a}`;return t.jsxs(xi,{children:[t.jsx("input",{ref:c,type:"file",accept:"image/*",onChange:d,style:{display:"none"}}),t.jsx(yi,{src:e,alt:T,onError:()=>n?.(new Error("Failed to load avatar")),onUpload:i,isUploading:u,onDelete:p,isDeleting:h}),t.jsx(hi,{displayName:a,contactType:y,firstName:m,lastName:g,name:b,entityId:S,onEntityUpdated:x}),t.jsx(ci,{tags:r,onEditTags:o})]})},Ia=20,vi=e=>{const{popperContainer:a,...n}=e;return t.jsx(Pr,{...n,container:a??n.container,style:{...n.style??{},zIndex:2e4}})},Ci=({value:e,options:a,onChange:n,onBack:r,onSave:o,isSaving:i,onCreateNew:d,isCreatingNew:c,popperContainer:u})=>{const p=xe(),[h,y]=l.useState(""),[m,g]=l.useState(Ia),b=l.useDeferredValue(h),S=l.useMemo(()=>a??[],[a]),x=l.useMemo(()=>{const E=String(b??"").trim().toLowerCase();return E?S.filter(F=>String(F?.name??"").toLowerCase().includes(E)):S},[S,b]),T=l.useMemo(()=>x.slice(0,m),[x,m]),C=l.useMemo(()=>{const E=new Map;for(const F of e??[])F?.id&&E.set(String(F.id),F);for(const F of T??[])F?.id&&(E.has(String(F.id))||E.set(String(F.id),F));return Array.from(E.values())},[e,T]),j=(E,F)=>{y(F??""),g(Ia)},w=E=>{const F=E;F.scrollTop+F.clientHeight>=F.scrollHeight-24&&g(D=>D+Ia)},$=()=>{const E=String(h??"").trim(),F=!E||i||c;return t.jsxs(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("global.noOptions"),t.jsx(at.LoadingButton,{onClick:()=>d(E),loading:c,disabled:F,variant:"contained",size:"small",sx:{marginTop:1.3},children:p("global.createNew")})]})};return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:2},children:[t.jsx(s.IconButton,{size:"small",onClick:r,"aria-label":p("global.back"),disabled:i,children:t.jsx(ja,{fontSize:"small"})}),t.jsx(s.Typography,{variant:"subtitle1",children:p("tags")}),t.jsx(s.Box,{sx:{flex:1}}),t.jsx(at.LoadingButton,{variant:"contained",size:"small",startIcon:t.jsx(ut,{}),onClick:o,loading:i,disabled:i,children:p("global.save")})]}),t.jsx(s.Autocomplete,{multiple:!0,disablePortal:!1,value:e,onChange:(E,F)=>n(F),options:C,filterOptions:E=>E,inputValue:h,onInputChange:j,getOptionLabel:E=>E?.name??"",isOptionEqualToValue:(E,F)=>String(E?.id)===String(F?.id),PopperComponent:E=>t.jsx(vi,{...E,popperContainer:u}),renderOption:(E,F)=>{const{key:D,...I}=E;return l.createElement("li",{...I,key:F?.id?String(F.id):String(D??F?.name??"")},F.name??"")},renderTags:(E,F)=>E.map((D,I)=>{const R=F({index:I}),{key:V,...W}=R;return t.jsx(s.Chip,{label:D.name??"",...W},D?.id?String(D.id):String(V??D?.name??I))}),size:"small",renderInput:E=>t.jsx(s.TextField,{...E,size:"small"}),ListboxProps:{onScroll:w,sx:{maxHeight:280,overflowY:"auto"}},noOptionsText:t.jsx($,{}),sx:{width:"100%"}})]})};var Si=Object.defineProperty,ji=(e,a,n)=>a in e?Si(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,dn=(e,a,n)=>ji(e,typeof a!="symbol"?a+"":a,n);let cn=class extends Error{constructor(a,n,r){super(a),dn(this,"status"),dn(this,"body"),this.name="ApiError",this.status=n,this.body=r}};async function Oe({url:e,method:a="GET",headers:n,body:r,signal:o}){const i=await globalThis.fetch(e,{method:a,headers:{...r?{"Content-Type":"application/json"}:{},...n??{}},body:r?JSON.stringify(r):void 0,signal:o}),d=(i.headers.get("content-type")||"").includes("application/json")?await i.json().catch(()=>null):await i.text().catch(()=>null);if(!i.ok){const c=typeof d=="object"&&d&&"message"in d?String(d.message):`Request failed with status ${i.status}`;throw new cn(c,i.status,d)}return d}async function wi({url:e,method:a="POST",headers:n,formData:r,signal:o}){const i=await globalThis.fetch(e,{method:a,headers:{...n??{}},body:r,signal:o}),d=(i.headers.get("content-type")||"").includes("application/json")?await i.json().catch(()=>null):await i.text().catch(()=>null);if(!i.ok){const c=typeof d=="object"&&d&&"message"in d?String(d.message):`Request failed with status ${i.status}`;throw new cn(c,i.status,d)}return d}function Te(e,a){const n=e.endsWith("/")?e.slice(0,-1):e,r=a.startsWith("/")?a:`/${a}`;return`${n}${r}`}function Pe(e,a){const n=encodeURIComponent(a);return{CONTACTS:Te(e,`/contacts/${n}`),MEDIA:Te(e,`/media/${n}`),SETTINGS:Te(e,`/settings/${n}`)}}async function Ti({baseUrl:e,spaceId:a,signal:n}){const r=Pe(e,a),o=Te(r.CONTACTS,"/labels");return Oe({url:o,signal:n})}async function un({baseUrl:e,spaceId:a,name:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/labels");return Oe({url:i,method:"POST",body:{name:n},signal:r})}async function ki({baseUrl:e,spaceId:a,contactId:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,`/contacts/${encodeURIComponent(n)}`);return Oe({url:i,signal:r})}async function Ii({baseUrl:e,spaceId:a,businessId:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,`/business/${encodeURIComponent(n)}`);return Oe({url:i,signal:r})}async function Ei({baseUrl:e,spaceId:a,forType:n,signal:r}){const o=Pe(e,a),i=`${Te(o.CONTACTS,"/ContactFields")}?filter=custom&for=${encodeURIComponent(n)}`;return Oe({url:i,signal:r})}async function Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:o,signal:i}){const d=n==="business"?`/business/${encodeURIComponent(r)}`:`/contacts/${encodeURIComponent(r)}`,c=Pe(e,a),u=Te(c.CONTACTS,d);return Oe({url:u,method:"PUT",body:o,signal:i})}async function Di({baseUrl:e,spaceId:a,pagination:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/Search");return Oe({url:i,method:"POST",body:n,signal:r})}async function Ai({baseUrl:e,spaceId:a,business:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/business");return Oe({url:i,method:"POST",body:n,signal:r})}async function oa({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/contactAddresses");return Oe({url:i,method:"DELETE",body:n,signal:r})}async function Fi({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/contactAddresses/check");return Oe({url:i,method:"POST",body:n,signal:r})}async function Bi({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/contactAddresses/set");return Oe({url:i,method:"POST",body:n,signal:r})}async function $i({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,`/contactAddresses/${encodeURIComponent(n.contactAddressId)}`);return Oe({url:i,method:"PUT",body:n,signal:r})}async function pn({baseUrl:e,spaceId:a,signal:n}){const r=Pe(e,a),o=Te(r.SETTINGS,"/user");return Oe({url:o,signal:n})}async function Mi({baseUrl:e,spaceId:a,signal:n}){const r=Pe(e,a),o=Te(r.SETTINGS,"/users");return Oe({url:o,signal:n})}async function Pi({baseUrl:e,spaceId:a,signal:n,userId:r}){const o=Pe(e,a),i=Te(o.SETTINGS,`/usersInfo/${r}`);return Oe({url:i,signal:n})}async function fn({baseUrl:e,spaceId:a,contactId:n,file:r,signal:o}){const i=Pe(e,a),d=new FormData;d.append("file",r,r.name);const c=Te(i.MEDIA,`/upload?module=contacts&folderType=avatars&contactId=${encodeURIComponent(n)}`);return wi({url:c,formData:d,signal:o})}const gn=(e,a)=>({fetchLabels:({signal:n}={})=>Ti({baseUrl:e,spaceId:a,signal:n}),createLabel:({name:n,signal:r})=>un({baseUrl:e,spaceId:a,name:n,signal:r}),fetchContact:({contactId:n,signal:r})=>ki({baseUrl:e,spaceId:a,contactId:n,signal:r}),fetchBusiness:({businessId:n,signal:r})=>Ii({baseUrl:e,spaceId:a,businessId:n,signal:r}),fetchBusinessTableData:({pagination:n,signal:r})=>Di({baseUrl:e,spaceId:a,pagination:n,signal:r}),createBusiness:({business:n,signal:r})=>Ai({baseUrl:e,spaceId:a,business:n,signal:r}),fetchContactFields:({forType:n,signal:r})=>Ei({baseUrl:e,spaceId:a,forType:n,signal:r}),updateEntity:({entityType:n,entityId:r,body:o,signal:i})=>Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:o,signal:i}),deleteAddress:({data:n,signal:r})=>oa({baseUrl:e,spaceId:a,data:n,signal:r}),deleteAddres:({data:n,signal:r})=>oa({baseUrl:e,spaceId:a,data:n,signal:r}),checkContactAddress:({data:n,signal:r})=>Fi({baseUrl:e,spaceId:a,data:n,signal:r}),setContactAddress:({data:n,signal:r})=>Bi({baseUrl:e,spaceId:a,data:n,signal:r}),updateContactAddress:({data:n,signal:r})=>$i({baseUrl:e,spaceId:a,data:n,signal:r}),fetchUserTrii:({signal:n}={})=>pn({baseUrl:e,spaceId:a,signal:n}),fetchUsers:({signal:n}={})=>Mi({baseUrl:e,spaceId:a,signal:n}),fetchUserTriiById:({userId:n,signal:r})=>Pi({baseUrl:e,spaceId:a,userId:n,signal:r}),uploadAvatar:({contactId:n,file:r,signal:o})=>fn({baseUrl:e,spaceId:a,contactId:n,file:r,signal:o})}),mn=()=>!!window?.google?.maps?.places?.Autocomplete,Ui=(e=1e4)=>new Promise(a=>{if(mn()){a(!0);return}const n=Date.now(),r=window.setInterval(()=>{if(mn()){window.clearInterval(r),a(!0);return}Date.now()-n>e&&(window.clearInterval(r),a(!1))},100)}),Ri=()=>{const[e,a]=l.useState(!1),[n,r]=l.useState(!0),[o,i]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const d=await Ui(1e4);a(d),d||i("Google Maps API failed to load")}catch{i("Error loading Google Maps API"),a(!1)}finally{r(!1)}})()},[]),{isLoaded:e,isLoading:n,error:o}},Ni=({onPlaceSelected:e,onError:a,placeholder:n})=>{const r=xe(),o=l.useRef(null),i=l.useRef(null),d=l.useRef(e),c=l.useRef(a),{isLoaded:u,isLoading:p,error:h}=Ri(),y=l.useMemo(()=>p?r("searchLocationModal.loadingGoogleMaps"):h?r("searchLocationModal.googleMapsUnavailable"):u?n??r("searchLocationModal.enterLocation"):r("searchLocationModal.googleMapsNotLoaded"),[u,p,h,n,r]);return l.useEffect(()=>{d.current=e},[e]),l.useEffect(()=>{c.current=a},[a]),l.useEffect(()=>{if(!u||!o.current||i.current)return;const m=window?.google;if(!m?.maps?.places?.Autocomplete){c.current?.(r("searchLocationModal.googleMapsUnavailable"));return}o.current.focus();let g=null;const b=()=>{document.querySelectorAll(".pac-container").forEach(x=>{const T=x;T.style.zIndex="20000",T.style.position="fixed"})};g=new MutationObserver(x=>{for(const T of x)for(const C of Array.from(T.addedNodes)){if(C.nodeType!==Node.ELEMENT_NODE)continue;const j=C;j.classList?.contains("pac-container")&&(j.style.zIndex="20000",j.style.position="fixed")}}),g.observe(document.body,{childList:!0,subtree:!0}),b(),window.setTimeout(b,100),i.current=new m.maps.places.Autocomplete(o.current,{types:["geocode"],componentRestrictions:{country:"ar"}});const S=i.current.addListener?.("place_changed",()=>{const x=i.current?.getPlace?.();if(!x?.geometry?.location){c.current?.(r("searchLocationModal.selectedPlaceNoLocation"));return}let T="",C="",j="",w="",$="",E="";const F=x.address_components??[];for(const V of F){const W=V?.types??[];if(W.includes("locality")||W.includes("administrative_area_level_2")){T=V.long_name;continue}if(W.includes("administrative_area_level_1")){C=V.long_name;continue}if(W.includes("country")){j=V.long_name;continue}if(W.includes("postal_code")){w=V.long_name;continue}if(W.includes("route")){$=V.long_name;continue}W.includes("street_number")&&(E=V.long_name)}const D=typeof x.geometry.location.lat=="function"?x.geometry.location.lat():0,I=typeof x.geometry.location.lng=="function"?x.geometry.location.lng():0,R={location:{lat:D,lng:I},address:x.formatted_address??"",city:T,state:C,country:j,postalCode:w,streetName:$,streetNumber:E,shortAddress:[$,E].filter(Boolean).join(" ")};d.current(R)});return()=>{g&&g.disconnect(),S?.remove&&S.remove(),i.current=null}},[u,r]),t.jsx(s.TextField,{fullWidth:!0,size:"small",inputRef:o,placeholder:y,disabled:p||!u||!!h,error:!!h})},Li={street:"",city:"",state:"",zipcode:"",country:""},Oi=({baseUrl:e,spaceId:a,entityType:n,entityId:r,onBack:o,onEntityUpdated:i})=>{const d=xe(),[c,u]=l.useState(Li),[p,h]=l.useState(""),[y,m]=l.useState(""),[g,b]=l.useState(!1),[S,x]=l.useState(!1),T=l.useMemo(()=>!!(String(c.street??"").trim()||String(c.city??"").trim()||String(c.state??"").trim()||String(c.zipcode??"").trim()||String(c.country??"").trim()),[c]),C=D=>{h(D.address??"");const I=String(D.shortAddress??"").trim()||[D.streetName,D.streetNumber].filter(Boolean).join(" ").trim();u({street:I,city:D.city??"",state:D.state??"",zipcode:D.postalCode??"",country:D.country??""}),m("")},j=D=>{m(String(D??""))},w=D=>I=>{const R=I.target.value;u(V=>({...V,[D]:R}))},$=async()=>{if(!g&&!(!e||!a)&&r){b(!0);try{const D=await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{address1:{street:String(c.street??""),city:String(c.city??""),state:String(c.state??""),zipcode:String(c.zipcode??""),country:String(c.country??"")}}});i?.(D),o()}finally{b(!1)}}},E=async()=>{if(!S&&!(!e||!a)&&r){x(!0);try{const D=await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{address2:{street:String(c.street??""),city:String(c.city??""),state:String(c.state??""),zipcode:String(c.zipcode??""),country:String(c.country??"")}}});i?.(D),o()}finally{x(!1)}}},F=!T||g||S;return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:3},children:[t.jsx(s.IconButton,{size:"small",onClick:o,"aria-label":d("global.back"),children:t.jsx(ja,{fontSize:"small"})}),t.jsx(s.Typography,{variant:"h6",children:d("searchLocationModal.searchAddress")})]}),t.jsxs(s.Stack,{spacing:3,children:[t.jsxs(s.Box,{sx:{position:"relative",zIndex:1400},children:[t.jsx(Ni,{onPlaceSelected:C,onError:j,placeholder:d("searchLocationModal.enterLocation")}),y?t.jsx(s.Typography,{variant:"caption",color:"error",sx:{mt:.5,display:"block"},children:y}):null]}),t.jsx(s.TextField,{label:d("conversations.contactDetails.street"),value:c.street,onChange:w("street"),fullWidth:!0,size:"medium"}),t.jsxs(s.Stack,{direction:{xs:"column",sm:"row"},spacing:2,children:[t.jsx(s.TextField,{label:d("searchLocationModal.city"),value:c.city,onChange:w("city"),fullWidth:!0,size:"medium"}),t.jsx(s.TextField,{label:d("searchLocationModal.state"),value:c.state,onChange:w("state"),fullWidth:!0,size:"medium"})]}),t.jsxs(s.Stack,{direction:{xs:"column",sm:"row"},spacing:2,children:[t.jsx(s.TextField,{label:d("searchLocationModal.postalCode"),value:c.zipcode,onChange:w("zipcode"),fullWidth:!0,size:"medium"}),t.jsx(s.TextField,{label:d("searchLocationModal.country"),value:c.country,onChange:w("country"),fullWidth:!0,size:"medium"})]}),p?t.jsx(s.Typography,{variant:"caption",sx:{opacity:.7},children:p}):null,t.jsxs(s.Stack,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{pt:2},children:[t.jsx(at.LoadingButton,{variant:"contained",size:"large",startIcon:t.jsx(ut,{}),onClick:$,loading:g,disabled:F,children:d("searchLocationModal.saveMainAddress")}),t.jsx(at.LoadingButton,{variant:"outlined",size:"large",startIcon:t.jsx(ut,{}),onClick:E,loading:S,disabled:F,children:d("searchLocationModal.saveSecondaryAddress")})]})]})]})};function Ea(e){return e?.isBusiness===!0?!0:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&Array.isArray(e.membersId)&&Array.isArray(e.members)&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&typeof e.imageUrl=="string"&&!("firstName"in e)&&!("lastName"in e)}function hn(e){return e?.isBusiness===!0?!1:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&typeof e.firstName=="string"&&typeof e.lastName=="string"&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&"origin"in e&&typeof e.isSpam=="boolean"&&(!e.businessId||typeof e.businessId=="string")}function zi({open:e,baseUrl:a,spaceId:n,contactId:r}){const o=l.useRef(null),i=l.useMemo(()=>!a||!n?null:gn(a,n),[a,n]),[d,c]=l.useState({isLoading:!1,error:null,contactData:null,labels:[],labelsLoading:!1,labelsError:null,contactFields:[],contactFieldsLoading:!1,contactFieldsError:null,userTrii:null,userLoading:!1,userError:null}),u=l.useMemo(()=>!!(e&&i&&r),[e,i,r]);l.useEffect(()=>{e||(o.current?.abort(),c({isLoading:!1,error:null,contactData:null,labels:[],labelsLoading:!1,labelsError:null,contactFields:[],contactFieldsLoading:!1,contactFieldsError:null,userTrii:null,userLoading:!1,userError:null}))},[e]);const p=l.useMemo(()=>!!(e&&i),[e,i]);l.useEffect(()=>{if(!p||!i)return;const m=new AbortController;return c(g=>({...g,labelsLoading:!0,labelsError:null})),i.fetchLabels({signal:m.signal}).then(g=>{c(b=>({...b,labels:g,labelsLoading:!1,labelsError:null}))}).catch(g=>{m.signal.aborted||c(b=>({...b,labelsLoading:!1,labelsError:g}))}),()=>{m.abort()}},[i,p]),l.useEffect(()=>{if(!u||!i)return;o.current?.abort();const m=new AbortController;return o.current=m,c(g=>({...g,isLoading:!0,error:null,contactData:null})),i.fetchContact({contactId:r,signal:m.signal}).then(g=>{c(b=>({...b,isLoading:!1,error:null,contactData:g}))}).catch(g=>{m.signal.aborted||c(b=>({...b,isLoading:!1,error:g}))}),()=>{m.abort()}},[i,u,r]);const h=l.useMemo(()=>!!(e&&i),[e,i]);l.useEffect(()=>{if(!h||!i)return;const m=new AbortController;return c(g=>({...g,userLoading:!0,userError:null})),i.fetchUserTrii({signal:m.signal}).then(g=>{c(b=>({...b,userLoading:!1,userError:null,userTrii:g}))}).catch(g=>{m.signal.aborted||c(b=>({...b,userLoading:!1,userError:g}))}),()=>{m.abort()}},[i,h]);const y=l.useMemo(()=>{const m=d.contactData,g=Ea(m),b=hn(m);let S="unknown";g&&(S="business"),b&&(S="contact");let x="Unknown Contact";g?x=m.name:b&&(x=`${m.firstName} ${m.lastName}`.trim());const T=m?.tags??[];return{isBusiness:g,isContact:b,contactType:S,displayName:x,tags:T,labels:d.labels,contactFields:d.contactFields,userTrii:d.userTrii,userLoading:d.userLoading,userError:d.userError}},[d.contactData,d.labels,d.contactFields,d.userTrii,d.userLoading,d.userError]);return l.useEffect(()=>{if(!e||!i)return;const m=d.contactData,g=Ea(m),b=hn(m),S=g?"business":b?"contact":null;if(!S)return;const x=new AbortController;return c(T=>({...T,contactFieldsLoading:!0,contactFieldsError:null})),i.fetchContactFields({forType:S,signal:x.signal}).then(T=>{c(C=>({...C,contactFields:T,contactFieldsLoading:!1,contactFieldsError:null}))}).catch(T=>{x.signal.aborted||c(C=>({...C,contactFieldsLoading:!1,contactFieldsError:T}))}),()=>{x.abort()}},[i,e,d.contactData]),{state:d,selectors:y,actions:{setContactData:m=>c(g=>({...g,contactData:m??null})),clearError:()=>c(m=>({...m,error:null}))}}}const Lt=({baseUrl:e,spaceId:a,entityType:n,entityId:r,initialImageUrl:o,onEntityUpdated:i})=>{const[d,c]=l.useState(o??""),[u,p]=l.useState(null),[h,y]=l.useState(!1),[m,g]=l.useState(!1),b=l.useRef(null),S=l.useMemo(()=>!!(e&&a&&n&&r),[e,a,n,r]);function x(I){return I.split("?sv=")[0]}function T(I){return I.split("&cacheId=")[0]}function C(I){let R=x(I);return!R||(R=T(R),!R)?"":R}const j=async()=>{if(!e||!a)return null;const I=await pn({baseUrl:e,spaceId:a});return p(I),I},w=async I=>{const R=(u??await j())?.storageAzureSAS,V=R?.expireAt,W=V?new Date(V):null;let Y=R?.sas??"";if((!Y||W&&W<new Date)&&(Y=(await j())?.storageAzureSAS?.sas??""),!Y)return I;const B=`${Date.now()}`;return`${I}${Y}&cacheId=${B}`},$=async I=>{if(!I){c("");return}const R=x(I);if(!R)return;const V=await w(R);c(V)},E=async I=>{const R=I.target.files?.[0];if(R&&S){b.current&&(b.current.value=""),y(!0);try{const V=await fn({baseUrl:e,spaceId:a,contactId:r,file:R}),W=await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{imageUrl:V}});i?.(W),await $(V)}finally{y(!1)}}},F=()=>{b.current?.click()},D=async()=>{if(S&&!m){g(!0);try{await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{imageUrl:""}}),i?.({imageUrl:""}),c("")}finally{g(!1)}}};return l.useEffect(()=>{if(!o){c("");return}$(o)},[o]),{inputAtributes:{onChange:E,ref:b,type:"file",accept:"image/*"},action:{uploadImage:F,deleteImage:D},imageUrl:d,removeParams:C,isUploading:h,isDeleting:m}},be=(e,a)=>{const[n,r]=l.useState(a||""),[o,i]=l.useState(!1),[d,c]=l.useState("");return l.useEffect(()=>{r(a||"")},[a]),{actions:{onError:u=>{i(!0),c(u)},onSuccess:()=>{i(!1),c("")},resetValue:()=>{r(a||"")},changeValue:u=>{r(u)}},attributes:{error:o,helperText:d,type:e,value:n,onChange:u=>{r(u.target.value)}}}},yn=(e="")=>{const[a,n]=l.useState(e),r=d=>{n(d.target.value)},o=d=>{n(d)},i=()=>{n(e??"")};return l.useEffect(()=>{n(e)},[e]),{actions:{resetValue:i,changeValue:o},attributes:{value:a,onChange:r}}};let la;const Wi=new Uint8Array(16);function _i(){if(!la&&(la=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!la))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return la(Wi)}const Fe=[];for(let e=0;e<256;++e)Fe.push((e+256).toString(16).slice(1));function Vi(e,a=0){return Fe[e[a+0]]+Fe[e[a+1]]+Fe[e[a+2]]+Fe[e[a+3]]+"-"+Fe[e[a+4]]+Fe[e[a+5]]+"-"+Fe[e[a+6]]+Fe[e[a+7]]+"-"+Fe[e[a+8]]+Fe[e[a+9]]+"-"+Fe[e[a+10]]+Fe[e[a+11]]+Fe[e[a+12]]+Fe[e[a+13]]+Fe[e[a+14]]+Fe[e[a+15]]}const Hi=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var xn={randomUUID:Hi};function Ot(e,a,n){if(xn.randomUUID&&!a&&!e)return xn.randomUUID();e=e||{};const r=e.random||(e.rng||_i)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,a){n=n||0;for(let o=0;o<16;++o)a[n+o]=r[o];return a}return Vi(r)}function Gi(e){return{id:Ot(),address:"",note:"",channelType:e,isSaved:!1}}var da={createNewAddress:Gi};const Yi=(e,a,n)=>{if(a!==n&&!(a===null&&n==="")){const r={};return r[e]=n,r}return null},qi=(e,a,n)=>n.map(r=>r.id===a?{...r,address:e}:r);var vt={getEditedField:Yi,getAddressesWithUpdatedValues:qi};const bn=({entityId:e,initial:a,dispatch:n,deleteAddress:r})=>{const[o,i]=l.useState(!1),[d,c]=l.useState(()=>a),[u,p]=l.useState(a?.ims_facebook||[]),[h,y]=l.useState(a?.ims_mercadolibre||[]),[m,g]=l.useState(a?.ims_webchat||[]),[b,S]=l.useState(a?.ims_instagram||[]),[x,T]=l.useState(a?.ims_whatsapp||[]),[C,j]=l.useState(a?.emails||[]),[w,$]=l.useState(a?.phones||[]),[E,F]=l.useState(a?.ims_rcs||[]),D=()=>{const k=da.createNewAddress(bt.ChannelType.PHONE),M=[...w,k];$(M)},I=()=>{const k=da.createNewAddress(bt.ChannelType.EMAIL),M=[...C,k];j(M)},R=()=>{const k=da.createNewAddress(bt.ChannelType.WHATSAPP),M=[...x,k];T(M)},V=()=>{const k=da.createNewAddress(bt.ChannelType.RCS),M=[...E,k];F(M)},W=k=>{const M=[...x,k];T(M),c(O=>({...O??{},ims_whatsapp:M}))},Y=(k,M)=>{if(M){if(M.channelType===3){const O=C.map(U=>U.id===k?M:U);j(O),c(U=>({...U??{},emails:O}))}if(M.channelType===5){const O=w.map(U=>U.id===k?M:U);$(O),c(U=>({...U??{},phones:O}))}if(M.channelType===13){const O=x.map(U=>U.id===k?M:U);T(O),c(U=>({...U??{},ims_whatsapp:O}))}if(M.channelType===21){const O=E.map(U=>U.id===k?M:U);F(O),c(U=>({...U??{},ims_rcs:O}))}if(M.channelType===41){const O=h.map(U=>U.id===k?M:U);y(O),c(U=>({...U??{},ims_mercadolibre:O}))}}},B=async(k,M,O)=>{const U=k.target.value;if(O===3){const G=vt.getAddressesWithUpdatedValues(U,M,C);j(G)}else if(O===5){const G=vt.getAddressesWithUpdatedValues(U,M,w);$(G)}else if(O===13){const G=vt.getAddressesWithUpdatedValues(U,M,x);T(G)}else if(O===21){const G=vt.getAddressesWithUpdatedValues(U,M,E);F(G)}else if(O===41){const G=vt.getAddressesWithUpdatedValues(U,M,h);y(G)}},X=(k,M,O)=>{if(O===14){const U=u.map(G=>G.id===M?{...G,note:k.target.value}:G);p(U)}if(O===20){const U=m.map(G=>G.id===M?{...G,note:k.target.value}:G);g(U)}if(O===16){const U=b.map(G=>G.id===M?{...G,note:k.target.value}:G);S(U)}if(O===3){const U=C.map(G=>G.id===M?{...G,note:k.target.value}:G);j(U)}if(O===5){const U=w.map(G=>G.id===M?{...G,note:k.target.value}:G);$(U)}if(O===13){const U=x.map(G=>G.id===M?{...G,note:k.target.value}:G);T(U)}if(O===21){const U=E.map(G=>G.id===M?{...G,note:k.target.value}:G);F(U)}if(O===41){const U=h.map(G=>G.id===M?{...G,note:k.target.value}:G);y(U)}},H=async(k,M)=>{if(e&&(M===3||M===5||M===13||M===14||M===20||M===16||M===21||M===41)){i(k);const O={contactId:e,contactAddressId:k,type:M};switch(n?await n(r(O)):await r(O),i(!1),M){case 3:const U=C.filter(Z=>Z.id!==k);j(U),c(Z=>({...Z??{},emails:U}));break;case 5:const G=w.filter(Z=>Z.id!==k);$(G),c(Z=>({...Z??{},phones:G}));break;case 13:const _=x.filter(Z=>Z.id!==k);T(_),c(Z=>({...Z??{},ims_whatsapp:_}));break;case 21:const ae=E.filter(Z=>Z.id!==k);F(ae),c(Z=>({...Z??{},ims_rcs:ae}));break;case 41:const de=h.filter(Z=>Z.id!==k);y(de),c(Z=>({...Z??{},ims_mercadolibre:de}));break;case 14:const oe=u.filter(Z=>Z.id!==k);p(oe),c(Z=>({...Z??{},ims_facebook:oe}));break;case 20:const Se=m.filter(Z=>Z.id!==k);g(Se),c(Z=>({...Z??{},ims_webchat:Se}));break;case 16:const ve=b.filter(Z=>Z.id!==k);S(ve),c(Z=>({...Z??{},ims_instagram:ve}));break}}};function L(){p(d?.ims_facebook||[]),y(d?.ims_mercadolibre||[]),g(d?.ims_webchat||[]),S(d?.ims_instagram||[]),T(d?.ims_whatsapp||[]),F(d?.ims_rcs||[]),j(d?.emails||[]),$(d?.phones||[])}return l.useEffect(()=>{c(a),a?.emails&&a?.phones&&(j(a.emails),$(a.phones)),T(a?.ims_whatsapp||[]),F(a?.ims_rcs||[]),p(a?.ims_facebook||[]),g(a?.ims_webchat||[]),S(a?.ims_instagram||[]),y(a?.ims_mercadolibre||[])},[a]),{field:{imsWhatsapp:x,imsRCS:E,imsMercadolibre:h,imsFacebooks:u,imsWebchats:m,imsInstagrams:b,emails:C,phoneNumbers:w},action:{handleAddressFieldChange:B,handleNoteFieldChange:X,handleDeleteAddress:H,addPhone:D,addEmail:I,addWhatsapp:R,addRCS:V,replaceAddress:Y,addWhatsappVerified:W,resetToInitialContactInformation:L},state:{isDeletingAddress:o}}},vn=({initialState:e=[]}={})=>{const[a,n]=l.useState(e);return{attributes:{value:a,onChange:(r,o)=>{const i=o.some(d=>!a.some(c=>d.id===c.id));(a.filter(d=>!o.some(c=>c.id===d.id)).length>0||i)&&n(o)}},actions:{addValue:r=>{n(o=>o.concat(r))},setValue:r=>{n(r)}}}},Ki=({business:e,customContactFields:a,baseUrl:n,spaceId:r})=>{const o=l.useMemo(()=>async ce=>{!n||!r||await oa({baseUrl:n,spaceId:r,data:ce})},[n,r]),i=async ce=>ce,[d,c]=l.useState([]),u=be("text",e?.name||""),p=Lt({baseUrl:n,spaceId:r,entityType:"business",entityId:e?.id,initialImageUrl:e?.imageUrl||""}),h=yn(e?.owner),y=vn({initialState:e?.tags??[]}),[m,g]=l.useState([]),{field:{imsFacebooks:b,imsMercadolibre:S,imsWebchats:x,imsInstagrams:T,imsWhatsapp:C,emails:j,phoneNumbers:w,imsRCS:$},action:{addPhone:E,addEmail:F,addWhatsapp:D,addRCS:I,addWhatsappVerified:R,replaceAddress:V,handleAddressFieldChange:W,handleNoteFieldChange:Y,handleDeleteAddress:B,resetToInitialContactInformation:X},state:{isDeletingAddress:H}}=bn({entityId:e?.id,initial:e,dispatch:i,deleteAddress:o}),L=be("text",e?.address1?.street||""),k=be("text",e?.address2?.street||""),M=be("text",e?.address1?.city||""),O=be("text",e?.address2?.city||""),U=be("text",e?.address1?.state||""),G=be("text",e?.address2?.state||""),_=be("text",e?.address1?.zipcode||""),ae=be("text",e?.address2?.zipcode||""),de=be("text",e?.address1?.country||""),oe=be("text",e?.address2?.country||""),Se=(ce,q,pe)=>q!==pe&&!(q===null&&pe==="")?{[ce]:pe}:{},ve=()=>{if(!e)return null;const ce={street:L.attributes.value,city:M.attributes.value,state:U.attributes.value,zipcode:_.attributes.value,country:de.attributes.value},q={street:k.attributes.value,city:O.attributes.value,state:G.attributes.value,zipcode:ae.attributes.value,country:oe.attributes.value};return{id:e.id,...Se("owner",e.owner,h.attributes.value),...Se("name",e.name,u.attributes.value),imageUrl:p.imageUrl?p.removeParams(p.imageUrl):null,tags:y.attributes.value,properties:d,members:m,phoneNumbers:w,emails:j,address1:ce,address2:q}};function Z(ce){if(!e)return;const q=Q=>Q.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),pe=e.properties.find(Q=>Q.nameKey===ce)??e.properties.find(Q=>q(Q.nameKey)===q(ce));if(!pe){console.error(`No se encontr\xF3 una propiedad con nameKey: ${ce}`);return}const Ze=d.map(Q=>Q.nameKey===ce?{...Q,value:pe.value}:Q);c(Ze)}const Ue=()=>e?a.map(ce=>{const q=Q=>Q.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),pe=e.properties.find(Q=>Q.nameKey===ce.nameKey)??e.properties.find(Q=>q(Q.nameKey)===q(ce.nameKey));if(pe)return{...pe,nameKey:ce.nameKey,type:pe.type??ce.type,value:pe.value};const Ze=d.find(Q=>Q.nameKey===ce.nameKey);return{nameKey:ce.nameKey,type:ce.type,value:Ze?Ze.value:""}}):[];return l.useEffect(()=>{e&&a&&c(Ue())},[e,a]),l.useEffect(()=>{e&&y.actions.setValue(e.tags??[])},[e]),{field:{name:u,imsWhatsapp:C,imsRCS:$,contactImage:p,contactPropietary:h,imsMercadolibre:S,imsFacebooks:b,imsWebchats:x,imsInstagrams:T,emails:j,phoneNumbers:w,homeAddress:L,secondaryHomeAddress:k,city:M,secondaryCity:O,state:U,secondaryState:G,postalCode:_,secondaryPostalCode:ae,country:de,secondaryCountry:oe,customProperties:d,labelMultipleSelect:y},action:{setCustomProperties:c,addWhatsapp:D,addRCS:I,getEditedBusiness:ve,handleAddressFieldChange:W,handleNoteFieldChange:Y,handleDeleteAddress:B,addPhone:E,addEmail:F,replaceAddress:V,addWhatsappVerified:R,resetToInitialContactInformation:X,resetCustomProperty:Z},state:{isDeletingAddress:H},selectedContacts:m,setSelectedContacts:g}},Ji=({contact:e,customContactFields:a,baseUrl:n,spaceId:r})=>{const o=l.useMemo(()=>async Q=>{!n||!r||await oa({baseUrl:n,spaceId:r,data:Q})},[n,r]),i=async Q=>Q,{getEditedField:d}=vt,[c,u]=l.useState([]),p=be("text",e?.firstName||""),h=be("text",e?.lastName||""),y=Lt({baseUrl:n,spaceId:r,entityType:"contact",entityId:e?.id?String(e.id):void 0,initialImageUrl:e?.imageUrl}),[m,g]=l.useState(e?.birthDate?J(e.birthDate):null),b=bn({entityId:e?.id,initial:e,dispatch:i,deleteAddress:o}),{field:{imsFacebooks:S,imsMercadolibre:x,imsWebchats:T,imsInstagrams:C,imsWhatsapp:j,emails:w,phoneNumbers:$,imsRCS:E},action:{addPhone:F,addEmail:D,addWhatsapp:I,addRCS:R,addWhatsappVerified:V,replaceAddress:W,handleAddressFieldChange:Y,handleNoteFieldChange:B,handleDeleteAddress:X,resetToInitialContactInformation:H},state:{isDeletingAddress:L}}=b,k=vn({initialState:e?.tags}),M=yn(e?.owner),O=be("text",e?.address1?.street),U=be("text",e?.address2?.street),G=be("text",e?.address1?.city),_=be("text",e?.address2?.city),ae=be("text",e?.address1?.state),de=be("text",e?.address2?.state),oe=be("text",e?.address1?.zipcode),Se=be("text",e?.address2?.zipcode),ve=be("text",e?.address1?.country),Z=be("text",e?.address2?.country),Ue=()=>{if(!e)return null;const Q=e,$e=k.attributes.value.map(ue=>({id:ue.id,name:ue.name})),We=$.map(ue=>{const{id:Kt,...rt}=ue;return rt}),Ge=w.map(ue=>{const{id:Kt,...rt}=ue;return rt});return{id:Q.id,owner:M.attributes.value,firstName:p.attributes.value,lastName:h.attributes.value,address1:{...d("street",Q.address1?.street,O.attributes.value),...d("city",Q.address1?.street,G.attributes.value),...d("state",Q.address1?.street,ae.attributes.value),...d("zipcode",Q.address1?.street,oe.attributes.value),...d("country",Q.address1?.street,ve.attributes.value)},address2:{...d("street",Q.address2?.street,U.attributes.value),...d("city",Q.address2?.street,_.attributes.value),...d("state",Q.address2?.street,de.attributes.value),...d("zipcode",Q.address2?.street,Se.attributes.value),...d("country",Q.address2?.street,Z.attributes.value)},emails:Ge,phones:We,tags:$e,imageUrl:y.imageUrl?y.removeParams(y.imageUrl):null,properties:c,birthDate:m?.toDate()}};function ce(){e&&(!e.businessId||e.businessName)}function q(){g(e?.birthDate?J(e.birthDate):null)}function pe(Q){if(!e)return;const $e=ue=>ue.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),We=e.properties.find(ue=>ue.nameKey===Q)??e.properties.find(ue=>$e(ue.nameKey)===$e(Q));if(!We){console.error(`No se encontr\xF3 una propiedad con nameKey: ${Q}`);return}const Ge=c.map(ue=>ue.nameKey===Q?{...ue,value:We.value}:ue);u(Ge)}const Ze=()=>e?a.map(Q=>{const $e=ue=>ue.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),We=e.properties.find(ue=>ue.nameKey===Q.nameKey)??e.properties.find(ue=>$e(ue.nameKey)===$e(Q.nameKey));if(We)return{...We,nameKey:Q.nameKey,type:We.type??Q.type,value:We.value};const Ge=c.find(ue=>ue.nameKey===Q.nameKey);return{nameKey:Q.nameKey,type:Q.type,value:Ge?Ge.value:""}}):[];return l.useEffect(()=>{e&&a&&u(Ze())},[e,a]),l.useEffect(()=>{e?.tags&&k.actions.setValue(e.tags),e?.businessId&&e.businessName},[e]),{field:{birthDate:m,imsWhatsapp:j,imsRCS:E,contactFirstname:p,contactLastname:h,contactImage:y,contactPropietary:M,imsMercadolibre:x,imsFacebooks:S,imsWebchats:T,imsInstagrams:C,emails:w,phoneNumbers:$,homeAddress:O,secondaryHomeAddress:U,city:G,secondaryCity:_,state:ae,secondaryState:de,postalCode:oe,secondaryPostalCode:Se,country:ve,secondaryCountry:Z,customProperties:c,labelMultipleSelect:k},action:{setBirthDate:g,setCustomProperties:u,getEditedContact:Ue,handleAddressFieldChange:Y,handleNoteFieldChange:B,handleDeleteAddress:X,addPhone:F,addEmail:D,addWhatsapp:I,addRCS:R,replaceAddress:W,addWhatsappVerified:V,resetToInitialContactInformation:H,resetSelectedBusiness:ce,resetBirthDate:q,resetCustomProperty:pe},state:{isDeletingAddress:L}}},Da=l.createContext(null),Qi=({children:e,contact:a,customContactFields:n,baseUrl:r,spaceId:o})=>{const i=Ji({contact:a,customContactFields:n,baseUrl:r,spaceId:o});return t.jsx(Da.Provider,{value:{entityType:"contact",editEntity:i,entityId:String(a.id)},children:e})},Xi=({children:e,business:a,customContactFields:n,baseUrl:r,spaceId:o})=>{const i=Ki({business:a,customContactFields:n,baseUrl:r,spaceId:o});return t.jsx(Da.Provider,{value:{entityType:"business",editEntity:i,entityId:String(a.id)},children:e})},Zi=({children:e,entityType:a,entityData:n,customContactFields:r,baseUrl:o,spaceId:i})=>a==="contact"?t.jsx(Qi,{contact:n,customContactFields:r,baseUrl:o,spaceId:i,children:e}):t.jsx(Xi,{business:n,customContactFields:r,baseUrl:o,spaceId:i,children:e}),nt=()=>{const e=l.useContext(Da);if(!e)throw new Error("useEditEntity must be used within EditEntityProvider");return e},Ct=({userId:e,users:a,currentUser:n})=>{if(!e)return null;if(n?.uid&&n.uid===e)return n.display_name||n.email||null;const r=a.find(o=>o?.id===e);return r?.name?.trim()||r?.email||null},ca=({title:e,children:a,enableDirectionSearch:n=!1,onDirectionSearchClick:r})=>{const o=xe();return t.jsxs(s.Box,{sx:{border:"1px solid",borderColor:"divider",borderRadius:2,p:2,mb:2},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[t.jsx(s.Typography,{variant:"subtitle1",children:e}),n&&t.jsx(s.Button,{startIcon:t.jsx(Ur,{sx:{color:"primary.main",height:18,width:18}}),size:"small",variant:"outlined",color:"primary",onClick:()=>r&&r(),children:o("global.searchLocation")})]}),t.jsx(s.Divider,{sx:{my:1.5}}),a]})},Cn=({children:e,...a})=>t.jsx(s.Box,{display:"grid",gridTemplateColumns:{xs:"1fr",md:"repeat(2, minmax(0, 1fr))"},gap:2,...a,children:e}),eo=({birthDate:e,setBirthDate:a,dateFormat:n})=>{const r=(n||"YYYY/MM/DD").toUpperCase();return t.jsx(Mt.LocalizationProvider,{dateAdapter:$t.AdapterDayjs,children:t.jsx(Pt,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Ga.DatePicker,{value:e,onChange:o=>a(o),slotProps:{textField:{size:"small"}},format:r})})})},to={view:"main",setView:()=>{}},Sn=l.createContext(null),ao=Sn.Provider,no=()=>l.useContext(Sn)||(console.warn("[useEditContactView] using noop, context value is missing"),to),jn=()=>{},wn=l.createContext(jn),ro=({navigate:e,children:a})=>t.jsx(wn.Provider,{value:e,children:a}),so=()=>l.useContext(wn)||(console.warn("[useNavigateContext] using noop, context value is falsy"),jn);function io({value:e,displayValue:a,businessId:n}){const r=it(),o=so(),[i,d]=l.useState(null),c=Lt({initialImageUrl:i?.imageUrl,entityType:"business",entityId:n}),[u,p]=l.useState(null),[h,y]=l.useState(!1);return t.jsxs(s.Box,{display:"flex",alignItems:"center",children:[t.jsx(s.Typography,{onClick:async m=>{const g=m.currentTarget;if(y(!0),!r){console.error("API is null");return}const b=await r.fetchBusiness({businessId:n});if(b&&Ea(b)&&d(b),y(!1),!g){console.error("Target element is null");return}p(g)},variant:"body2",fontWeight:"600",sx:{padding:1,cursor:"pointer"},color:m=>m.palette.text.primary,children:a||typeof e=="string"&&e||"-"}),i&&t.jsx(rn,{contactData:i,open:!!u,anchorEl:u,onClose:()=>p(null),navigate:o,avatarImgUrl:c.imageUrl}),h&&t.jsx(s.Box,{display:"flex",alignItems:"center",justifyContent:"center",p:1,children:t.jsx(s.CircularProgress,{size:20})})]})}const oo=e=>"email"in e,Aa=e=>e.entityType==="contact"&&e.inputType==="birthday",lo=s.styled(s.IconButton)({opacity:0,transition:"opacity 0.3s ease-in-out","& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"},marginLeft:"15px"}),Tn=s.styled(s.IconButton)({"& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"}}),ot=e=>{const{title:a,value:n,isNotEditable:r,displayValue:o,baseUrl:i,spaceId:d,minWidth:c,onEntityUpdated:u}=e,p=xe(),{setView:h}=no(),y=e.inputType??"text",[m,g]=l.useState(!1),[b,S]=l.useState(!1),x=l.useRef(null),[T,C]=l.useState(!1),[j,w]=l.useState(()=>e.entityType==="business"||typeof n=="string"?n:void 0);l.useEffect(()=>{const B=x.current;if(!B)return;const X=()=>{const H=B.scrollWidth>B.clientWidth;C(L=>L===H?L:H)};if(X(),typeof ResizeObserver<"u"){let H=0;const L=new ResizeObserver(()=>{if(typeof window>"u"){X();return}H&&window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>{X()})});return L.observe(B),()=>{typeof window<"u"&&H&&window.cancelAnimationFrame(H),L.disconnect()}}if(!(typeof window>"u"))return window.addEventListener("resize",X),()=>{window.removeEventListener("resize",X)}},[a]),l.useEffect(()=>{e.entityType==="business"?w(n):w(typeof n=="string"?n:void 0)},[n,e.entityType]);const $=()=>{if(e.entityType==="contact"&&y==="selectBusiness"){h("businessSelect");return}g(B=>!B)},E=B=>{w(B.target.value)},F=B=>{const X=B.target.value;w(X)},D=()=>{Aa(e)&&e.contact.action.resetBirthDate(),g(!1)},I=async()=>{if(!e.constructUpdateObject){g(!1);return}if(e.entityType==="business"&&j===void 0){g(!1);return}S(!0);try{if(!i||!d)throw new Error("Missing baseUrl or spaceId for updateEntity");if(e.entityType==="contact"){let B=j===void 0?null:j;if(Aa(e)){const k=J(e.contact.field.birthDate);k.isValid()&&(B=k.toISOString())}const X=e.constructUpdateObject(B),H=e.entityId??X?.id;if(!H)throw new Error("Missing contactId for updateEntity");const L=await Xe({baseUrl:i,spaceId:d,entityType:"contact",entityId:H,body:X});u?.(L)}else{const B=e.constructUpdateObject(j),X=e.entityId??B?.id;if(!X)throw new Error("Missing businessId for updateEntity");const H=await Xe({baseUrl:i,spaceId:d,entityType:"business",entityId:X,body:B});u?.(H)}}finally{S(!1),g(!1)}},R=typeof j=="string"?j:"",V=j instanceof Date?j.toISOString():typeof j=="string"?j:"",W=c??(e.entityType==="contact"?"45%":"200px"),Y=e.options??[];return t.jsxs(s.Box,{className:"fadein col-5",sx:{display:"flex",backgroundColor:B=>B.palette.mode==="dark"?"1e1e1e":B.palette.background.default,flexDirection:"column",borderRadius:1,minWidth:W,"&:hover .edit-icon":{opacity:1}},children:[t.jsxs(s.Box,{display:"flex",position:"relative",minHeight:"25px",children:[T?t.jsx(s.Tooltip,{title:a,arrow:!0,children:t.jsx(s.Typography,{ref:x,component:"span",variant:"body2",letterSpacing:-.5,fontWeight:"600",alignSelf:"center",flexGrow:m?1:0,color:B=>B.palette.text.primary,noWrap:!0,sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a})}):t.jsx(s.Typography,{ref:x,component:"span",variant:"body2",letterSpacing:-.5,fontWeight:"600",alignSelf:"center",flexGrow:m?1:0,color:B=>B.palette.text.primary,noWrap:!0,sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),r?null:m?t.jsxs(t.Fragment,{children:[t.jsx(Tn,{size:"small",onClick:I,children:b?t.jsx(s.CircularProgress,{size:24}):t.jsx(ut,{})}),t.jsx(Tn,{size:"small",onClick:D,children:t.jsx(Ya,{})})]}):t.jsx(lo,{className:"edit-icon",size:"small",onClick:$,children:t.jsx(Bt,{})})]}),t.jsx(s.Box,{width:m?"100%":"50%",position:"relative",children:m&&y==="text"?t.jsx(s.TextField,{value:V,onChange:E,variant:"standard",size:"small",sx:{width:"100%"}}):m&&(y==="select"||y==="selectMembers")?t.jsxs(s.Select,{value:R,onChange:F,variant:"standard",size:"small",sx:{width:"100%"},children:[e.entityType==="contact"?t.jsx(s.MenuItem,{value:"",children:p("conversations.contactDetails.contactInfo.emptySelection")}):null,Y.map((B,X)=>t.jsx(s.MenuItem,{value:B.id,children:e.entityType==="contact"?B.name?.trim()||(oo(B)?B.email:"")||"Sin nombre":B.name?.trim()||B.email||"Sin nombre"},X))]}):m&&Aa(e)?t.jsx(eo,{birthDate:e.contact.field.birthDate,setBirthDate:e.contact.action.setBirthDate,dateFormat:e.dateFormat}):!m&&e.entityType==="contact"&&y==="selectBusiness"&&e.businessId?t.jsx(io,{value:String(n??""),displayValue:String(o??""),businessId:e.businessId}):t.jsx(s.Typography,{variant:"body2",fontWeight:"400",sx:{padding:"2.5px 14px 8.5px 0px"},color:B=>B.palette.text.primary,children:o||typeof n=="string"&&n||"-"})})]})},zt=e=>{const{title:a,value:n,isNotEditable:r,options:o=[],displayValue:i,constructUpdateObject:d,businessId:c,baseUrl:u,spaceId:p,contactId:h,onEntityUpdated:y}=e;if(e.inputType==="birthday")return t.jsx(ot,{entityType:"contact",entityId:h,title:a,value:n,isNotEditable:r,inputType:"birthday",options:o,displayValue:i,constructUpdateObject:d,contact:e.contact,businessId:c,baseUrl:u,spaceId:p,dateFormat:e.dateFormat,onEntityUpdated:y});const m=e.inputType??"text";return t.jsx(ot,{entityType:"contact",entityId:h,title:a,value:n,isNotEditable:r,inputType:m,options:o,displayValue:i,constructUpdateObject:d,businessId:c,baseUrl:u,spaceId:p,onEntityUpdated:y})},co=({nameKey:e,value:a,onChange:n,type:r})=>{const o=u=>{r===ne.ContactField_type.NUMBER_ACCOUNTING||r===ne.ContactField_type.NUMBER_DECIMAL||r===ne.ContactField_type.NUMBER_CURRENCY||r===ne.ContactField_type.CURRENCY?d(u):r===ne.ContactField_type.NUMBER_INTEGER?c(u):(r===ne.ContactField_type.LONGTEXT||r===ne.ContactField_type.TEXT||r===ne.ContactField_type.ADDRESS)&&i(u)},i=u=>{n(e,u.target.value)},d=u=>{const p=u.target.value.replace(/[^0-9.]/g,"");n(e,p)},c=u=>{const p=u.target.value;/^\d*$/.test(p)&&n(e,p)};return t.jsx(s.TextField,{size:"small",variant:"standard",value:a,onChange:o,inputProps:{pattern:"[0-9]*"},multiline:r===ne.ContactField_type.LONGTEXT,rows:r===ne.ContactField_type.LONGTEXT?4:1,sx:{width:"100%"}})},uo=({value:e,handleChange:a,dateFormat:n})=>{const r=(n||"YYYY/MM/DD").toUpperCase();return t.jsx(Mt.LocalizationProvider,{dateAdapter:$t.AdapterDayjs,children:t.jsx(Pt,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Ga.DatePicker,{value:e?J(e):null,onChange:o=>a(o),format:r,slotProps:{textField:{size:"small",sx:{width:"100%"},variant:"standard"},openPickerButton:{disableRipple:!0}}})})})},po=({handleChange:e,value:a,options:n})=>{const r=xe();return t.jsx(s.FormControl,{className:"fadein",sx:{width:"100%"},children:t.jsxs(s.Select,{value:a,onChange:o=>e(o.target.value),size:"small",variant:"standard",children:[t.jsx(s.MenuItem,{value:"",children:r("global.noValue")}),n.map((o,i)=>t.jsx(s.MenuItem,{value:o,children:o},i))]})})},fo=({value:e,handleChange:a,userTimeFormat:n})=>{const r=n==="24"?"HH:mm":"hh:mm";return t.jsx(Mt.LocalizationProvider,{dateAdapter:$t.AdapterDayjs,children:t.jsx(Pt,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Rr.TimePicker,{value:e?J(e):null,onChange:o=>a(o),format:r,slotProps:{textField:{size:"small",sx:{width:"100%"},variant:"standard"},openPickerButton:{disableRipple:!0}}})})})},go=({value:e,handleChange:a,userTimeFormat:n})=>{const r=xe(),o=[J().set("hour",0).set("minute",0),J().set("hour",0).set("minute",0)],i=n==="24"?"HH:mm":"hh:mm";return t.jsx(Mt.LocalizationProvider,{dateAdapter:$t.AdapterDayjs,children:t.jsx(Pt,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Je.MultiInputTimeRangeField,{slotProps:{textField:({position:d})=>({label:r(d==="start"?"contactEdit.from":"contactEdit.to"),size:"small",variant:"standard",inputProps:{placeholder:i}})},value:e||o,onChange:d=>a(d),format:i})})})},mo=({value:e,handleChange:a,userDateFormat:n})=>{const r=xe(),o=[J(),J()],i=(n||"YYYY/MM/DD").toUpperCase();return t.jsx(Mt.LocalizationProvider,{dateAdapter:$t.AdapterDayjs,children:t.jsx(Pt,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Je.MultiInputDateRangeField,{slotProps:{textField:({position:d})=>({label:r(d==="start"?"contactEdit.from":"contactEdit.to"),size:"small",sx:{width:"100%"},variant:"standard",inputProps:{placeholder:i}})},value:e||o,onChange:d=>a(d),format:i})})})},ho=s.styled(s.IconButton)(()=>({opacity:0,transition:"opacity 0.3s ease-in-out","& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"},marginLeft:"15px"})),kn=s.styled(s.IconButton)(()=>({"& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"}})),yo=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadius,minWidth:"45%","&:hover .edit-icon":{opacity:1}})),In=s.styled(s.Typography)(({theme:e})=>({fontWeight:600,fontSize:"0.875rem",alignSelf:"center",color:e.palette.text.primary,letterSpacing:-.5,padding:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0})),xo=s.styled(s.Typography)(({theme:e})=>({fontWeight:400,fontSize:"0.875rem",padding:"2.5px 14px 8.5px 0px",color:e.palette.text.primary,wordWrap:"break-word",maxHeight:"80px",overflow:"auto",whiteSpace:"break-spaces"})),En=({property:e,entity:a,entityType:n,entityId:r,customContactFields:o,userTrii:i,baseUrl:d,spaceId:c,onEntityUpdated:u})=>{const{customProperties:p}=a.field,{setCustomProperties:h}=a.action,[y,m]=l.useState(!1),[g,b]=l.useState(!1),S=l.useRef(null),[x,T]=l.useState(!1),C=(i?.regCon_dateFormat||"YYYY/MM/DD").toUpperCase(),j=i?.regCon_timeFormat||"24",w=L=>L===ne.ContactField_type.NUMBER_INTEGER||L===ne.ContactField_type.NUMBER_DECIMAL||L===ne.ContactField_type.NUMBER_CURRENCY||L===ne.ContactField_type.NUMBER_ACCOUNTING||L===ne.ContactField_type.CURRENCY,$=(L,k)=>L.toLowerCase()==="dni"?!0:w(k),E=(L,k,M)=>{if(M===""||M===null||M===void 0)return null;if($(L,k)){const O=Number(M);return Number.isNaN(O)?M:O}return M},F=()=>m(L=>!L),D=()=>{m(!1),a.action.resetCustomProperty(e.nameKey)},I=async()=>{if(!d||!c||!r)return;b(!0);const L=p.find(_=>_.nameKey===e.nameKey)||e,{nameKey:k,value:M}=L,O=o.find(_=>_.nameKey===k)?.type??L.type;let U;if(O===ne.ContactField_type.TIME){const _=J(M);_.isValid()?U=_.format(j==="24"?"HH:mm":"hh:mm"):U=M}else if(O===ne.ContactField_type.DATE){const _=J(M);_.isValid()?U=_.toISOString():U=M}else U=E(k,O,M);const G={properties:[{nameKey:k,type:O,value:U}]};try{const _=await Xe({baseUrl:d,spaceId:c,entityType:n,entityId:r,body:G}),ae=p.map(de=>de.nameKey===k?{...de,type:O,value:U}:de);h(ae),u?.(_)}finally{b(!1),m(!1)}},R=L=>o.find(k=>k.nameKey===L)?.name||L;l.useEffect(()=>{const L=S.current;if(!L)return;const k=()=>{const M=L.scrollWidth>L.clientWidth;T(O=>O===M?O:M)};if(k(),typeof ResizeObserver<"u"){let M=0;const O=new ResizeObserver(()=>{if(typeof window>"u"){k();return}M&&window.cancelAnimationFrame(M),M=window.requestAnimationFrame(()=>{k()})});return O.observe(L),()=>{typeof window<"u"&&M&&window.cancelAnimationFrame(M),O.disconnect()}}if(!(typeof window>"u"))return window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[o,e.nameKey]);const V=(L,k)=>{const M=e.type===ne.ContactField_type.DATERANGE?Array.isArray(k)&&k[0]&&k[1]?`${J(k[0]).toISOString()} - ${J(k[1]).toISOString()}`:"":e.type===ne.ContactField_type.DATE?J(k).isValid()?J(k).toISOString():"Invalid Date":e.type===ne.ContactField_type.TIME?J(k).isValid()?J(k).toISOString():"Invalid Time":k,O=p.map(U=>U.nameKey===L?{...U,value:M}:U);h(O)},{type:W,nameKey:Y,value:B}=e,X=L=>L==null?!1:typeof L=="string"?L.trim().length>0:!0,H=()=>W===ne.ContactField_type.DATE?t.jsx(uo,{value:B?J(B):null,handleChange:L=>V(Y,L?.toDate()),dateFormat:C}):W===ne.ContactField_type.TIME?t.jsx(fo,{value:e?.valueDate?J(e.valueDate):B?J(B):null,handleChange:L=>V(Y,L),userTimeFormat:j}):W===ne.ContactField_type.DATERANGE?t.jsx(mo,{value:B&&typeof B=="string"&&B.includes(" - ")?[J(B.split(" - ")[0]),J(B.split(" - ")[1])]:null,handleChange:L=>V(Y,[L[0]?.toDate?.(),L[1]?.toDate?.()]),userDateFormat:C}):W===ne.ContactField_type.TIMERANGE?t.jsx(go,{value:Array.isArray(B)&&B.length===2?[J(B[0]),J(B[1])]:null,handleChange:L=>V(Y,[L[0]?.toDate?.(),L[1]?.toDate?.()]),userTimeFormat:j}):W===ne.ContactField_type.OPTIONS?t.jsx(po,{value:typeof B=="string"?B:"",handleChange:L=>V(Y,L),options:o.find(L=>L.nameKey===Y)?.typeOptions??[]}):t.jsx(co,{type:W,nameKey:Y,value:B,onChange:V});return t.jsxs(yo,{className:`fadein ${e.type===ne.ContactField_type.LONGTEXT?"col-12":"col-5"}`,children:[t.jsxs(s.Box,{display:"flex",position:"relative",minHeight:"25px",alignItems:"center",children:[x?t.jsx(s.Tooltip,{title:R(e.nameKey),arrow:!0,children:t.jsx(In,{ref:S,flexGrow:1,noWrap:!0,children:R(e.nameKey)})}):t.jsx(In,{ref:S,flexGrow:1,noWrap:!0,children:R(e.nameKey)}),y?t.jsxs(t.Fragment,{children:[t.jsx(kn,{size:"small",onClick:I,children:g?t.jsx(s.CircularProgress,{size:24}):t.jsx(ut,{})}),t.jsx(kn,{size:"small",onClick:D,children:t.jsx(Ya,{})})]}):t.jsx(ho,{className:"edit-icon",size:"small",onClick:F,children:t.jsx(Bt,{})})]}),t.jsx(s.Box,{width:y||e.type===ne.ContactField_type.LONGTEXT?"100%":"50%",position:"relative",children:y?H():t.jsx(xo,{children:X(e?.value)?e.type===ne.ContactField_type.DATERANGE?(()=>{if(typeof e.value=="string"){const L=e.value.split(" - ");if(L.length===2){const[k,M]=L,O=J(k),U=J(M);return`${O.isValid()?O.format(C):"-"} - ${U.isValid()?U.format(C):"-"}`}}else if(Array.isArray(e.value)&&e.value.length===2)return`${J(e.value[0]).format(C)} - ${J(e.value[1]).format(C)}`;return`${e.value}`})():e.type===ne.ContactField_type.TIMERANGE?Array.isArray(e.value)&&e.value.length===2?`${J(e.value[0]).format(j==="24"?"HH:mm":"hh:mm")} - ${J(e.value[1]).format(j==="24"?"HH:mm":"hh:mm")}`:`${e.value}`:e.type===ne.ContactField_type.TIME?(()=>{try{const L=e.valueDate||e.value;return`${J(L).format(j==="24"?"HH:mm":"hh:mm A")}`}catch{return`${e.value}`}})():e.type===ne.ContactField_type.DATE?(()=>{try{return`${J(e.value).format(C)}`}catch{return`${e.value}`}})():`${e?.value}`:null})})]})},bo=e=>{const{dateFormat:a,entityData:n,customContactFields:r,baseUrl:o,spaceId:i,currentUser:d,onEntityUpdated:c}=e,u=xe(),{entityType:p,editEntity:h}=nt(),y=it();if(p!=="contact")return null;const[m,g]=l.useState([]),[b,S]=l.useState(null),[x,T]=l.useState(null),[C,j]=l.useState(null),w=h;l.useEffect(()=>{if(!y)return;const I=new AbortController;return y.fetchUsers({signal:I.signal}).then(R=>{I.signal.aborted||g(R??[])}).catch(()=>{I.signal.aborted||g([])}),()=>{I.abort()}},[y]),l.useEffect(()=>{const I=new AbortController,R=async V=>{if(!V||!y)return null;try{const W=await y.fetchUserTriiById({userId:V,signal:I.signal});return W?.display_name||W?.email||null}catch{return null}};return(async()=>{const V=Ct({userId:n.owner,users:m,currentUser:d})??(n.owner?await R(n.owner):null),W=Ct({userId:n.createdBy??void 0,users:m,currentUser:d})??(n.createdBy?await R(n.createdBy):null),Y=Ct({userId:n.updatedBy??void 0,users:m,currentUser:d})??(n.updatedBy?await R(n.updatedBy):null);I.signal.aborted||(S(V),j(W),T(Y))})(),()=>{I.abort()}},[y,n,m,d]);const $=(a||"YYYY/MM/DD").toUpperCase(),E=w.field.birthDate,F=E?.isValid()?E.format($):null,D=I=>{const R=new Date;let V=R.getFullYear()-I.getFullYear();const W=R.getMonth()-I.getMonth();return(W<0||W===0&&R.getDate()<I.getDate())&&V--,V};return t.jsx(ca,{title:"General",children:t.jsxs(Cn,{children:[t.jsx(zt,{title:u("conversations.contactDetails.contactOwner"),displayValue:b||"-",value:n.owner,inputType:"select",options:m,constructUpdateObject:I=>({owner:typeof I=="string"?I:""}),contact:w,baseUrl:o,spaceId:i,contactId:n.id,onEntityUpdated:c}),t.jsx(zt,{title:u("conversations.contactDetails.business"),displayValue:n.businessName||"-",value:n.businessId,inputType:"selectBusiness",businessId:n.businessId,contact:w,baseUrl:o,spaceId:i,contactId:n.id,onEntityUpdated:c}),t.jsx(zt,{title:u("conversations.contactDetails.createdBy"),value:C||"-",isNotEditable:!0,contact:w,baseUrl:o,spaceId:i,contactId:n.id}),t.jsx(zt,{title:u("conversations.contactDetails.modifiedBy"),value:x||"-",isNotEditable:!0,contact:w,baseUrl:o,spaceId:i,contactId:n.id}),t.jsx(zt,{title:u("global.birthdate"),inputType:"birthday",displayValue:E?`${F} (${D(E.toDate())})`:"-",value:E?E.toISOString():"",constructUpdateObject:I=>({birthDate:I}),contact:w,baseUrl:o,spaceId:i,contactId:n.id,dateFormat:a,onEntityUpdated:c}),w.field.customProperties.map(I=>t.jsx(En,{property:I,entity:w,entityType:"contact",entityId:String(n.id),customContactFields:r,userTrii:d,baseUrl:o,spaceId:i,onEntityUpdated:c},I.nameKey))]})})},Fa=({title:e,value:a,isNotEditable:n,inputType:r="text",options:o=[],displayValue:i,constructUpdateObject:d,baseUrl:c,spaceId:u,businessId:p,onEntityUpdated:h})=>t.jsx(ot,{entityType:"business",entityId:p,title:e,value:a,isNotEditable:n,inputType:r,options:o,displayValue:i,constructUpdateObject:d,baseUrl:c,spaceId:u,onEntityUpdated:h}),vo=e=>{const a=xe(),{entityData:n,customContactFields:r,baseUrl:o,spaceId:i,currentUser:d,onEntityUpdated:c}=e,{entityType:u,editEntity:p}=nt(),h=it();if(u!=="business")return null;const[y,m]=l.useState([]),[g,b]=l.useState(null),[S,x]=l.useState(null),[T,C]=l.useState(null),j=p;return l.useEffect(()=>{if(!h)return;const w=new AbortController;return h.fetchUsers({signal:w.signal}).then($=>{w.signal.aborted||m($??[])}).catch(()=>{w.signal.aborted||m([])}),()=>{w.abort()}},[h]),l.useEffect(()=>{const w=new AbortController,$=async E=>{if(!E||!h)return null;try{const F=await h.fetchUserTriiById({userId:E,signal:w.signal});return F?.display_name||F?.email||null}catch{return null}};return(async()=>{const E=Ct({userId:n.owner,users:y,currentUser:d})??(n.owner?await $(n.owner):null),F=Ct({userId:n.createdBy??void 0,users:y,currentUser:d})??(n.createdBy?await $(n.createdBy):null),D=Ct({userId:n.updatedBy??void 0,users:y,currentUser:d})??(n.updatedBy?await $(n.updatedBy):null);w.signal.aborted||(b(E),C(F),x(D))})(),()=>{w.abort()}},[h,n,y,d]),t.jsx(ca,{title:"General",children:t.jsxs(Cn,{children:[t.jsx(Fa,{title:a("conversations.businessDetails.businessOwner"),value:n.owner,displayValue:g||"-",inputType:"select",options:y,constructUpdateObject:w=>({owner:typeof w=="string"?w:""}),baseUrl:o,spaceId:i,businessId:n.id,onEntityUpdated:c}),t.jsx(Fa,{title:a("conversations.contactDetails.createdBy"),value:T||"-",isNotEditable:!0}),t.jsx(Fa,{title:a("conversations.contactDetails.modifiedBy"),value:S||"-",isNotEditable:!0}),j.field.customProperties.map(w=>t.jsx(En,{property:w,entity:j,entityType:"business",entityId:String(n.id),customContactFields:r,userTrii:d,baseUrl:o,spaceId:i,onEntityUpdated:c},w.nameKey))]})})},Co=e=>{const{entityType:a,entityData:n}=e;return l.useMemo(()=>a==="contact"||a==="business"?a:"contact",[a])==="contact"?t.jsx(bo,{...e,entityData:n,entityType:"contact"}):t.jsx(vo,{...e,entityData:n,entityType:"business"})},So=()=>{const[e,a]=l.useState(!1),[n,r]=l.useState("");return{isOpen:e,title:n,openModal:o=>{r(o),a(!0)},closeModal:()=>{a(!1),r("")}}},jo=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:e.spacing(1),backgroundColor:e.palette.background.dropdownMenu,borderRadius:e.shape.borderRadius,color:e.palette.text.primary,width:"50%",paddingBottom:"3px",minHeight:"50px",position:"relative"})),wo=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",gap:e.spacing(1),overflow:"hidden",maxWidth:"80%"})),To=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),ko=we.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",gap:e.spacing(.5),overflow:"hidden",flexFlow:"nowrap",flexWrap:"wrap",marginTop:"-5px"})),Io=we.styled(s.Avatar)(({})=>({width:32,height:32,cursor:"pointer"})),Ba=we.styled(s.Box)(({})=>({fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"})),Eo=we.styled(Ba)(({theme:e})=>({fontSize:12,color:e.palette.text.secondary,position:"absolute",bottom:0,maxWidth:"70%"})),Do=we.styled(Ba)(({})=>({fontSize:14,fontWeight:500})),Ao=we.styled(Ba)(({})=>({fontSize:14,fontWeight:500})),Fo=({item:e})=>{const a=e.profileUrl,{imageUrl:n}=Lt({initialImageUrl:a});return t.jsx(t.Fragment,{children:t.jsxs(jo,{children:[t.jsx(wo,{children:t.jsxs(ko,{children:[t.jsx(s.Tooltip,{title:e.address||"",arrow:!0,children:t.jsx(Do,{children:e.address})}),t.jsx(s.Tooltip,{title:e.profileName||"",arrow:!0,children:t.jsx(Ao,{sx:{marginTop:"-10px",marginLeft:"5px",fontSize:"10px"},children:e.profileName})}),t.jsx(s.Tooltip,{title:e.note||"",arrow:!0,children:t.jsx(Eo,{children:e.note})})]})}),t.jsxs(To,{children:[a!==""&&t.jsx(Io,{src:n,alt:e.profileName,style:{cursor:"pointer"},children:e?.profileName?.charAt(0).toUpperCase()}),t.jsx(s.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:t.jsx(s.IconButton,{size:"small",sx:{marginTop:"-5px",padding:0},children:e.isFavorite?t.jsx(Ae.Star,{sx:{color:"#fcac34"}}):t.jsx(Ae.StarBorder,{sx:{color:"#fcac34"}})})})]})]})})},$a=qa.PhoneNumberUtil.getInstance(),Bo=e=>{if(!e||!e.trim())return e;try{const a=$a.parse(e,void 0);return $a.isValidNumber(a)?$a.format(a,qa.PhoneNumberFormat.INTERNATIONAL):e}catch{return e}},$o=we.styled(s.IconButton)(({theme:e})=>({padding:e.spacing(.5),marginTop:"-5px"})),Mo=we.styled(Nr)(({theme:e})=>({height:16,width:16,color:e.palette.secondary.main})),Po=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:e.spacing(1),backgroundColor:e.palette.background.dropdownMenu,borderRadius:e.shape.borderRadius,color:e.palette.text.primary,width:"50%",paddingBottom:"3px",minHeight:"50px",position:"relative"})),Uo=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",gap:e.spacing(1),maxWidth:"80%"})),Ro=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),No=we.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",gap:e.spacing(.5),overflow:"hidden",flexFlow:"nowrap",flexWrap:"wrap",marginTop:"-5px"})),Dn=we.styled(s.Box)(({})=>({fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"})),Lo=we.styled(Dn)(({theme:e})=>({fontSize:12,color:e.palette.text.secondary,position:"absolute",bottom:0,maxWidth:"70%"})),Oo=we.styled(Dn)(({})=>({fontSize:14,fontWeight:500})),zo=({item:e})=>{const a=()=>{const r=e.address;if(!r)return;const o=new CustomEvent("call-contact-header",{detail:{phoneAddress:r}});window.dispatchEvent(o)},n=l.useMemo(()=>Bo(e.address||""),[e.address]);return t.jsx(t.Fragment,{children:t.jsxs(Po,{children:[t.jsxs(Uo,{children:[t.jsx($o,{onClick:a,color:"primary",size:"small",children:t.jsx(Mo,{})}),t.jsxs(No,{children:[t.jsx(s.Tooltip,{title:n||"",arrow:!0,children:t.jsx(Oo,{children:n})}),t.jsx(s.Tooltip,{title:e.note||"",arrow:!0,children:t.jsx(Lo,{children:e.note})})]})]}),t.jsx(Ro,{children:t.jsx(s.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:t.jsx(s.IconButton,{size:"small",sx:{marginTop:"-5px",padding:0},children:e.isFavorite?t.jsx(Ae.Star,{sx:{color:"#fcac34"}}):t.jsx(Ae.StarBorder,{sx:{color:"#fcac34"}})})})})]})})},Wo=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(1,0,2,0),width:"100%",gap:e.spacing(1),"&:hover .edit-icon":{opacity:1}})),_o=s.styled(s.Typography)(({})=>({letterSpacing:-.5,fontSize:14})),Vo=s.styled(s.Box)(({})=>({display:"flex",alignItems:"center"})),Ho=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1),width:"100%"})),Go=s.styled(s.IconButton)({opacity:0,transition:"opacity 0.3s ease-in-out","& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"},marginLeft:"15px"}),Yo=({title:e,methodItems:a,isPhone:n,handleEdit:r,owner:o})=>t.jsxs(Wo,{children:[t.jsxs(Vo,{children:[t.jsx(_o,{children:e}),t.jsx(Go,{className:"edit-icon",size:"small",onClick:r,children:t.jsx(Bt,{fontSize:"small",sx:{color:i=>i.palette.secondary.main}})})]}),t.jsx(Ho,{children:a.map((i,d)=>n?t.jsx(zo,{item:i},d):t.jsx(Fo,{item:i,owner:o},d))})]}),qo=({title:e})=>t.jsx(s.Box,{children:t.jsx(s.Typography,{variant:"subtitle2",children:e})}),Ko={container:{display:"flex",justifyContent:"space-between",alignItems:"center"}},ua=({title:e,handleAdd:a})=>{const n=xe();return t.jsxs(s.Box,{sx:Ko.container,children:[t.jsx(s.Typography,{variant:"subtitle2",children:e}),t.jsx(s.Button,{onClick:a,size:"small",startIcon:t.jsx(Ka,{}),variant:"text",color:"primary",children:n("global.add")})]})},Jo={container:{border:"1px solid lightgray",borderRadius:1,p:2,width:"100%",display:"flex",flexDirection:"column",gap:1}},Wt=({children:e})=>t.jsx(s.Box,{sx:Jo.container,children:e}),An={container:{display:"flex",width:"50%",alignItems:"center",justifyContent:"end"},noteTextField:{width:"100%",marginRight:"15px"}},Qo=({onDelete:e,addressData:a,handleLinkAccountSave:n,checked:r,onCheckContactAddress:o})=>{const i=xe(),[d,c]=l.useState(null),u=!!d,{channelType:p,address:h}=a,[y,m]=l.useState(!1),[g,b]=l.useState(null),[S,x]=l.useState(!1),T=D=>{c(D.currentTarget)},C=()=>{c(null)},j=()=>{x(!1)},w=()=>{e(),C()},$=async()=>{m(!0);try{if(!o)return;const D=await o(13);if(!D)return;b(D),x(!0)}catch(D){console.error("Error verifying WhatsApp account:",D)}finally{m(!1)}C()},E=async()=>{m(!0);try{if(!o)return;const D=await o(21);if(!D)return;b(D),x(!0)}catch(D){console.error("Error verifying RCS account:",D)}finally{m(!1)}C()},F=async()=>{await n(),x(!1)};return t.jsxs(s.Box,{children:[t.jsx(s.IconButton,{"aria-controls":u?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,onClick:T,children:t.jsx(Lr,{})}),t.jsxs(s.Menu,{id:"basic-menu",anchorEl:d,open:u,onClose:C,MenuListProps:{"aria-labelledby":"basic-button"},children:[t.jsxs(s.MenuItem,{onClick:w,children:[t.jsx(s.ListItemIcon,{children:t.jsx(sa,{color:"error"})}),t.jsx(s.ListItemText,{children:i("global.delete")})]}),p===5&&t.jsxs(s.MenuItem,{onClick:$,disabled:!r,children:[t.jsx(s.ListItemIcon,{children:y?t.jsx(s.CircularProgress,{size:24}):t.jsx(Or,{sx:{color:"green"}})}),t.jsx(s.ListItemText,{children:i("optionsMenu.verifyWspAccount")})]}),p===21&&t.jsxs(s.MenuItem,{onClick:E,disabled:!r,children:[t.jsx(s.ListItemIcon,{children:y?t.jsx(s.CircularProgress,{size:24}):t.jsx(zr,{})}),t.jsx(s.ListItemText,{children:i("optionsMenu.verifyRCSAccount")})]})]}),t.jsx(s.Modal,{open:S,onClose:j,"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:t.jsx(s.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,boxShadow:24,p:4,backgroundColor:D=>D.palette.background.default},children:g?.success?t.jsxs(t.Fragment,{children:[t.jsxs(s.Typography,{id:"modal-modal-title",variant:"h6",component:"h2",children:[i("optionsMenu.wspAccountFound")," ",h]}),t.jsx(s.Typography,{id:"modal-modal-description",sx:{mt:2},children:i("optionsMenu.wantToLinkContact")}),t.jsxs(s.Box,{sx:{marginTop:"10px"},children:[t.jsx(s.Button,{onClick:F,color:"primary",children:i("optionsMenu.yesLink")}),t.jsx(s.Button,{onClick:j,color:"secondary",children:"No"})]})]}):t.jsxs(s.Box,{sx:{position:"relative"},children:[t.jsxs(s.Typography,{id:"modal-modal-title",variant:"h6",component:"h2",children:[i("optionsMenu.noWspAccountFound")," ",h]}),t.jsx(s.Button,{onClick:j,color:"secondary",sx:{position:"absolute",bottom:-25,right:0},children:i("global.cancel")})]})})})]})},_t=e=>{const a=xe(),n=it(),{editEntity:r,entityId:o}=nt(),[i,d]=l.useState(!1),c=e.checked??!0,u=e.entityId??o,{note:p,channelType:h,id:y,address:m}=e.addressData,g=!e.addressData.hasOwnProperty("isSaved"),b=e.replaceAddress??r.action.replaceAddress,S=e.addWhatsappVerified||(typeof r.action?.addWhatsappVerified=="function"?r.action.addWhatsappVerified:void 0),x=async w=>{if(!n||!u)return null;const $=await n.setContactAddress({data:{address:m,contactId:u,type:w}});return b(y,$),$},T=async()=>{if(!n||!u)return;const w=await n.updateContactAddress({data:{contactAddressId:y,contactId:u,note:p??""}});b(y,w)},C=async()=>{d(!0),g?(await T(),d(!1)):await x(h)&&d(!1)},j=async()=>{d(!0);const w=await x(13);w&&S&&S(w),w&&d(!1)};return t.jsxs(s.Box,{sx:{...An.container},children:[g&&t.jsx(s.TextField,{size:"small",label:a("global.note"),variant:"outlined",onChange:w=>e.handleNoteFieldChange(w,y,h),value:p,fullWidth:!0,InputLabelProps:{shrink:!0},className:"smallInput",sx:An.noteTextField}),t.jsx(s.IconButton,{onClick:C,children:i?t.jsx(s.CircularProgress,{size:24}):t.jsx(ut,{color:"primary"})}),t.jsx(Qo,{onDelete:()=>e.handleDeleteAddress(y,h),addressData:e.addressData,handleLinkAccountSave:j,checked:c&&!i,onCheckContactAddress:async w=>{if(!n)return null;try{return await n.checkContactAddress({data:{address:m,type:w}})}catch{return null}}})]})},Xo={container:{display:"flex",gap:"100px",alignItems:"center"}},Vt=({children:e})=>t.jsx(s.Box,{sx:Xo.container,children:e}),Zo={container:{width:"100%",borderRadius:1,px:1.5,py:2,display:"flex",flexDirection:"column",gap:2,overflow:"auto",maxHeight:"calc(100vh - 250px)"}},Ht=({children:e})=>t.jsx(s.Box,{sx:{...Zo.container},children:e}),el=({status:e})=>{switch(e){case"idle":return null;case"loading":return t.jsx(Vr,{size:20});case"available":return t.jsx(Wr,{style:{height:27,width:27},color:"success"});case"unavailable":return t.jsx(_r,{style:{height:27,width:27},color:"error"});default:return null}},Fn=({status:e,text:a})=>t.jsxs(Hr,{position:"end",children:[a?t.jsx(Gr,{marginRight:.5,children:a}):null,t.jsx("div",{style:{width:30,display:"flex",justifyContent:"center"},children:t.jsx(el,{status:e})})]}),tl={code:{width:"60%",color:"gray"}},al=({data:e,editEntity:a})=>{const n=a.action;return t.jsx(Wt,{children:t.jsxs(Vt,{children:[t.jsx(s.Typography,{sx:tl.code,variant:"body2",children:e.address}),t.jsx(_t,{addressData:e,handleNoteFieldChange:n.handleNoteFieldChange,handleDeleteAddress:n.handleDeleteAddress})]})})},nl=({IMSs:e,editEntity:a})=>t.jsx(Ht,{children:e?.map(n=>t.jsx(al,{data:n,editEntity:a},n.id))}),pa=({editEntity:e,title:a,IMSs:n})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(qo,{title:a}),t.jsx(nl,{IMSs:n,editEntity:e})]}),rl={addressField:{}},Ma=({data:e,onChange:a,setWarnings:n})=>{const{id:r,channelType:o,address:i}=e,d=xe(),c=it(),[u,p]=l.useState("idle"),[h,y]=l.useState(i),m=!e.hasOwnProperty("isSaved");return l.useEffect(()=>{let g=setTimeout(async()=>{if(i!==""&&i!==h){if(!c)return;p("loading"),y(i);const b={address:i,type:o};try{const S=await c.checkContactAddress({data:b}),{success:x,warnings:T}=S;n(T),p(x?"available":"unavailable")}catch{n([]),p("unavailable")}}},1700);return()=>clearTimeout(g)},[c,e,i,o,h,n]),t.jsx(t.Fragment,{children:t.jsx(s.TextField,{disabled:m,sx:rl.addressField,size:"small",label:o===bt.ChannelType.WHATSAPP||o===bt.ChannelType.RCS?d?d("global.number"):"Number":d?d("global.email"):"Email",value:i,onChange:g=>{a(g,r,o)},variant:"outlined",fullWidth:!0,InputLabelProps:{shrink:!0},className:"smallInput",InputProps:{endAdornment:t.jsx(t.Fragment,{children:t.jsx(Fn,{status:u})})}})})},sl={addressField:{}},il=({data:e,onChange:a,setWarnings:n})=>{const r=it(),o=xe(),{id:i,channelType:d,address:c}=e,[u,p]=l.useState("idle"),[h,y]=l.useState(c),m=!e.hasOwnProperty("isSaved");return l.useEffect(()=>{let g=setTimeout(async()=>{if(c!==""&&c!==h){if(!r)return;p("loading"),y(c);const b={address:c,type:d};try{const{success:S,warnings:x}=await r.checkContactAddress({data:b});n(x),p(S?"available":"unavailable")}catch{n([]),p("unavailable")}}},1700);return()=>clearTimeout(g)},[e]),t.jsx(t.Fragment,{children:t.jsx(s.TextField,{disabled:m,sx:sl.addressField,size:"small",label:o("global.number"),value:c,onChange:g=>{a(g,i,d)},variant:"outlined",fullWidth:!0,InputLabelProps:{shrink:!0},className:"smallInput",InputProps:{endAdornment:t.jsx(t.Fragment,{children:t.jsx(Fn,{status:u})})}})})},Pa={secondaryContainer:{display:"flex",alignItems:"baseline",height:"100%",gap:.5},icon:{height:15},chip:{borderRadius:"6px",height:"22px"}},ol=({text:e})=>t.jsx(s.Grid,{item:!0,children:t.jsx(s.Box,{sx:Pa.secondaryContainer,children:t.jsx(qr,{icon:t.jsx(Yr,{sx:Pa.icon}),sx:Pa.chip,label:e,color:"error",variant:"outlined"})})}),fa=({warnings:e})=>{const a=xe();return t.jsx(s.Box,{children:t.jsx(s.Grid,{container:!0,children:e?.map((n,r)=>t.jsx(ol,{text:a(`contactAddressError.${n}`)},r))})})},ll={numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{marginTop:"10px"},adressInputBox:{position:"relative",width:"45%"}},dl=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]),[c,u]=l.useState(!0);return l.useEffect(()=>{u(i.length===0&&(e.address??"")!=="")},[i,e.address]),t.jsx(Wt,{children:t.jsxs(Vt,{children:[t.jsxs(s.Box,{sx:{...ll.numberCountryContainer,flexDirection:"column"},children:[t.jsx(il,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange}),i.length>0&&t.jsx(fa,{warnings:i})]}),t.jsx(_t,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress,addWhatsappVerified:r.addWhatsappVerified,checked:c})]})})},cl=({phoneNumbers:e})=>t.jsx(Ht,{variant:"large",children:e?.map(a=>t.jsx(dl,{data:a},a.id))}),ul=({phoneNumbers:e,handleAdd:a})=>{const n=xe();return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(ua,{handleAdd:a,title:n("global.phones")}),t.jsx(cl,{phoneNumbers:e})]})},Bn={emailField:{width:"60%"},numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{position:"absolute",bottom:"-30px"},adressInputBox:{position:"relative",width:"60%"}},pl=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]);return t.jsxs(Wt,{children:[t.jsxs(Vt,{children:[t.jsx(s.Box,{sx:Bn.numberCountryContainer,children:t.jsx(s.Box,{sx:Bn.adressInputBox,children:t.jsx(Ma,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange})})}),t.jsx(_t,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress})]}),i.length>0&&t.jsx(fa,{warnings:i})]})},fl=({emails:e})=>t.jsx(Ht,{variant:"large",children:e?.map(a=>t.jsx(pl,{data:a},a.id))}),gl=({emails:e,handleAdd:a})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(ua,{handleAdd:a,title:"Emails"}),t.jsx(fl,{emails:e})]}),$n={emailField:{width:"60%"},numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{position:"absolute",bottom:"-30px"},adressInputBox:{position:"relative",width:"60%"}},ml=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]);return t.jsxs(Wt,{children:[t.jsxs(Vt,{children:[t.jsx(s.Box,{sx:$n.numberCountryContainer,children:t.jsx(s.Box,{sx:$n.adressInputBox,children:t.jsx(Ma,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange})})}),t.jsx(_t,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress})]}),i.length>0&&t.jsx(fa,{warnings:i})]})},hl=({whatsapps:e})=>t.jsx(Ht,{variant:"large",children:e?.map(a=>t.jsx(ml,{data:a},a.id))}),yl=({whatsapps:e,handleAdd:a})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(ua,{handleAdd:a,title:"WhatsApp"}),t.jsx(hl,{whatsapps:e})]}),Mn={emailField:{width:"60%"},numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{position:"absolute",bottom:"-30px"},adressInputBox:{position:"relative",width:"60%"}},xl=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]);return t.jsxs(Wt,{children:[t.jsxs(Vt,{children:[t.jsx(s.Box,{sx:Mn.numberCountryContainer,children:t.jsx(s.Box,{sx:Mn.adressInputBox,children:t.jsx(Ma,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange})})}),t.jsx(_t,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress})]}),i.length>0&&t.jsx(fa,{warnings:i})]})},bl=({RCSs:e})=>t.jsx(Ht,{variant:"large",children:e?.map(a=>t.jsx(xl,{data:a},a.id))}),vl=({RCSs:e,handleAdd:a})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(ua,{handleAdd:a,title:"RCS"}),t.jsx(bl,{RCSs:e})]}),Cl=we.styled(s.Box)(({theme:e})=>({position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:1e3,backgroundColor:e.palette.background.panel,padding:e.spacing(4),borderRadius:e.shape.borderRadius})),Sl=({open:e,onClose:a,title:n})=>{const r=xe(),{editEntity:o}=nt(),{emails:i,phoneNumbers:d,imsWhatsapp:c,imsRCS:u}=o.field,{addEmail:p,addPhone:h,addWhatsapp:y,resetToInitialContactInformation:m,addRCS:g}=o.action;function b(){a(),m()}return t.jsx(s.Modal,{open:e,onClose:a,children:t.jsxs(Cl,{children:[(()=>{switch(n){case"Phones":return t.jsx(ul,{handleAdd:h,phoneNumbers:d});case"Emails":return t.jsx(gl,{handleAdd:p,emails:i});case"Whatsapp":return t.jsx(yl,{handleAdd:y,whatsapps:c});case"RCS":return t.jsx(vl,{handleAdd:g,RCSs:u});case"Facebook":return t.jsx(pa,{title:"Facebook",IMSs:o.field.imsFacebooks,editEntity:o});case"Webchat":return t.jsx(pa,{title:"Webchat",IMSs:o.field.imsWebchats,editEntity:o});case"Instagram":return t.jsx(pa,{title:"Instagram",IMSs:o.field.imsInstagrams,editEntity:o});case"Mercado libre":return t.jsx(pa,{title:"Mercado Libre",IMSs:o.field.imsMercadolibre,editEntity:o});default:return t.jsx(s.Typography,{children:"No information available for this section."})}})(),t.jsx(s.Box,{mt:2,display:"flex",justifyContent:"flex-end",children:t.jsx(s.Button,{variant:"contained",color:"primary",onClick:b,children:r("global.close")})})]})})},jl=({ownerData:e})=>{const{isOpen:a,title:n,openModal:r,closeModal:o}=So(),{editEntity:i}=nt(),d=xe(),c=i.field.phoneNumbers,u=i.field.emails,p=i.field.imsFacebooks,h=i.field.imsWhatsapp,y=i.field.imsMercadolibre,m=i.field.imsWebchats,g=i.field.imsInstagrams,b=i.field.imsRCS,S=[{key:"phones",title:d("conversations.contactDetails.phones"),items:c,isPhone:!0,modalTitle:"Phones",visible:!0},{key:"emails",title:"Emails",items:u,modalTitle:"Emails",visible:!0},{key:"facebook",title:"Facebook",items:p,modalTitle:"Facebook",visible:!0},{key:"whatsapp",title:"Whatsapp",items:h,modalTitle:"Whatsapp",visible:!0},{key:"rcs",title:"RCS",items:b,modalTitle:"RCS",visible:b.length>0},{key:"mercado-libre",title:"Mercado libre",items:y,modalTitle:"Mercado libre",visible:!0},{key:"webchat",title:"Webchat",items:m,modalTitle:"Webchat",visible:!0},{key:"instagram",title:"Instagram",items:g,modalTitle:"Instagram",visible:!0}];return t.jsxs(t.Fragment,{children:[t.jsx(ca,{title:d("conversations.contactDetails.contactInformation"),children:t.jsx("div",{className:"grid grid-cols-1 gap-3",children:S.filter(x=>x.visible).map(x=>t.jsx(Yo,{handleEdit:()=>r(x.modalTitle),title:x.title,methodItems:x.items,isPhone:x.isPhone,owner:e},x.key))})}),t.jsx(Sl,{open:a,onClose:o,title:n})]})},wl=({entityType:e,entityData:a,baseUrl:n,spaceId:r,onEntityUpdated:o,onDirectionSearchClick:i})=>{const d={baseUrl:n,spaceId:r,entityId:String(a.id),onEntityUpdated:o},c=xe(),u=({addressNumber:p,title:h})=>t.jsxs("div",{className:"flex flex-col gap-4 rounded-xl p-4",children:[t.jsx(s.Typography,{variant:"body2",children:h}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx("div",{className:"col-span-2",children:t.jsx(ot,{entityType:e,title:c("conversations.contactDetails.street"),value:a[p]?.street??"",...d,constructUpdateObject:y=>({[p]:{street:y}}),minWidth:"100%"})}),t.jsx(ot,{entityType:e,title:c("conversations.contactDetails.city"),value:a[p]?.city??"",...d,constructUpdateObject:y=>({[p]:{city:y}}),minWidth:"100%"}),t.jsx(ot,{entityType:e,title:c("conversations.contactDetails.state"),value:a[p]?.state??"",...d,constructUpdateObject:y=>({[p]:{state:y}}),minWidth:"100%"}),t.jsx(ot,{entityType:e,title:c("conversations.contactDetails.postcode"),value:a[p]?.zipcode??"",...d,constructUpdateObject:y=>({[p]:{zipcode:y}}),minWidth:"100%"}),t.jsx(ot,{entityType:e,title:c("conversations.contactDetails.country"),value:a[p]?.country??"",...d,constructUpdateObject:y=>({[p]:{country:y}}),minWidth:"100%"})]})]});return t.jsx(ca,{title:c("conversations.contactDetails.addressInformation"),enableDirectionSearch:!0,onDirectionSearchClick:i,children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(u,{addressNumber:"address1",title:c("conversations.contactDetails.primaryAddress")}),t.jsx(u,{addressNumber:"address2",title:c("conversations.contactDetails.secondaryAddress")})]})})},Tl=({entity:e,setEntity:a})=>l.useCallback(n=>{if(!n||typeof n!="object")return;const r=n;if("id"in r){a(n);return}if(!e)return;const o={...e,...r};a(o)},[e,a]),kl=({open:e,baseUrl:a,spaceId:n,contactData:r,contactType:o,labels:i,selectedTags:d,onTagsUpdated:c})=>{const[u,p]=l.useState("main"),[h,y]=l.useState([]),[m,g]=l.useState(!1),[b,S]=l.useState(!1),[x,T]=l.useState([]),[C,j]=l.useState(!1),w=l.useMemo(()=>{const D=i??[],I=x??[],R=new Map;for(const V of D)V?.id&&R.set(String(V.id),V);for(const V of I)V?.id&&R.set(String(V.id),V);return Array.from(R.values())},[i,x]),$=l.useCallback(()=>{p("main"),y([]),g(!1),S(!1),T([]),j(!1)},[]);l.useEffect(()=>{e||$()},[e,$]),l.useEffect(()=>{if(u!=="tags"){g(!1);return}if(m||!w.length)return;const D=new Set(d.map(R=>String(R.id))),I=w.filter(R=>D.has(String(R?.id)));y(I),g(!0)},[u,m,w,d]);const E=l.useCallback(async D=>{if(C||!a||!n)return;const I=String(D??"").trim();if(!I)return;const R=I.toLowerCase(),V=w.find(W=>String(W?.name??"").trim().toLowerCase()===R);if(V?.id){y(W=>{const Y=W??[];return Y.some(B=>String(B?.id)===String(V.id))?Y:[...Y,V]});return}j(!0);try{const W=await un({baseUrl:a,spaceId:n,name:I});T(Y=>{const B=Y??[];return!W?.id||B.some(X=>String(X?.id)===String(W.id))?B:[...B,W]}),y(Y=>{const B=Y??[];return!W?.id||B.some(X=>String(X?.id)===String(W.id))?B:[...B,W]})}finally{j(!1)}},[C,a,n,w]),F=l.useCallback(async()=>{if(b||!a||!n||!r||o!=="contact"&&o!=="business")return;const D=h.filter(I=>I?.id&&I?.name).map(I=>({id:String(I.id),name:String(I.name)}));S(!0);try{await Xe({baseUrl:a,spaceId:n,entityType:o,entityId:String(r.id),body:{tags:D}}),c(D),p("main")}finally{S(!1)}},[b,a,n,r,o,h,c]);return{view:u,setView:p,draftLabels:h,setDraftLabels:y,labelsOptions:w,isSaving:b,isCreatingLabel:C,handleCreateLabel:E,handleSaveTags:F}},Il=({onClose:e})=>l.useCallback((a,n)=>{n!=="escapeKeyDown"&&e()},[e]),El={format:"IBusiness",total:0,lastPage:1,perPage:10,order:"ASC",orderColumn:"Id"},Dl=({baseUrl:e,spaceId:a,contactId:n,initialBusiness:r,onBack:o,onEntityUpdated:i,currentUser:d})=>{const c=xe(),u=it(),p=l.useRef(null),h=l.useRef(null),[y,m]=l.useState(()=>r?.businessName??""),[g,b]=l.useState(!1),[S,x]=l.useState(!1),[T,C]=l.useState(!1),[j,w]=l.useState([]),[$,E]=l.useState(r??null),[F,D]=l.useState(1),[I,R]=l.useState(!1),[V,W]=l.useState(!1),Y=l.useMemo(()=>{const _=d?.display_name,ae=d?.email;return String(_||ae||"").trim()},[d]);l.useEffect(()=>()=>{p.current&&(clearTimeout(p.current),p.current=null),h.current?.abort()},[]),l.useEffect(()=>{E(r??null),m(r?.businessName??"")},[r]);const B=()=>{h.current?.abort(),h.current=null,p.current&&(clearTimeout(p.current),p.current=null),b(!1),W(!1),D(1),R(!1),w([])},X=_=>_.filter(ae=>!!ae?.id).map(ae=>({businessId:String(ae.id),businessName:String(ae.name??"")})),H=async({query:_,page:ae})=>{if(!u)return;h.current?.abort();const de=new AbortController;h.current=de,x(!0);try{const oe={...El,currentPage:ae,filter:[{value:_,column:"name",condition:""}]},Se=await u.fetchBusinessTableData({pagination:oe,signal:de.signal});if(de.signal.aborted)return;const ve=X(Se?.contactos??[]);b(!0);const Z=Se?.paginacion?.total??0;w(Ue=>{const ce=ae===1?ve:(()=>{const q=new Map;for(const pe of Ue)q.set(pe.businessId,pe);for(const pe of ve)q.set(pe.businessId,pe);return Array.from(q.values())})();return Z&&ce.length>=Z&&W(!0),ce})}finally{x(!1),C(!1),R(!1)}},L=_=>{B(),_&&(p.current&&(clearTimeout(p.current),p.current=null),C(!0),p.current=setTimeout(()=>{H({query:_,page:1})},800))},k=_=>{const ae=_.target;if(!(ae.scrollHeight-ae.scrollTop-ae.clientHeight<1)||V||S||!y)return;const de=F+1;R(!0),D(de),H({query:y,page:de})},M=async()=>{if(!u||!Y)return;const _=String(y??"").trim();if(_){x(!0);try{const ae={name:_,owner:Y,imageUrl:"",members:[],tags:[],properties:[],address1:{street:"",city:"",state:"",zipcode:"",country:""},address2:{street:"",city:"",state:"",zipcode:"",country:""}},de=await u.createBusiness({business:ae}),oe={businessId:String(de.id??""),businessName:String(de.name??_)};w([oe]),E(oe),b(!0)}finally{x(!1)}}},O=async()=>{if(!e||!a||!n)return;const _=$?.businessId??"",ae=await Xe({baseUrl:e,spaceId:a,entityType:"contact",entityId:n,body:{businessId:_}});i?.(ae),o()},U=g&&j.length===0&&y?t.jsxs(s.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{px:1,py:.5},children:[t.jsx(s.Typography,{variant:"body2",children:c("global.noOptions")}),t.jsx(at.LoadingButton,{size:"small",variant:"contained",onClick:M,loading:S,disabled:S||!Y,children:c("global.createNew")})]}):t.jsx(s.Typography,{variant:"body2",children:c("global.noOptions")}),G=!n||!e||!a;return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:2},children:[t.jsx(s.IconButton,{size:"small",onClick:o,"aria-label":c("global.back"),children:t.jsx(ja,{fontSize:"small"})}),t.jsx(s.Typography,{variant:"subtitle1",children:c("conversations.contactDetails.business")}),t.jsx(s.Box,{sx:{flex:1}}),t.jsx(at.LoadingButton,{variant:"contained",size:"small",startIcon:t.jsx(ut,{}),onClick:O,loading:!1,disabled:G,children:c("global.save")})]}),t.jsxs(s.Box,{sx:{position:"relative"},children:[S||T||I?t.jsx(s.Box,{sx:{position:"absolute",left:0,right:0,top:0},children:t.jsx(s.LinearProgress,{sx:{borderRadius:1}})}):null,t.jsx(s.Autocomplete,{fullWidth:!0,disablePortal:!0,value:$,onChange:(_,ae)=>{E(ae)},inputValue:y,onInputChange:(_,ae,de)=>{m(ae),de==="input"&&L(ae)},options:j,getOptionLabel:_=>_?.businessName??"",isOptionEqualToValue:(_,ae)=>_.businessId===ae.businessId,noOptionsText:U,renderInput:_=>t.jsx(s.TextField,{..._,size:"small",label:c("conversations.contactDetails.business"),placeholder:c("global.noValue"),InputProps:{..._.InputProps,endAdornment:t.jsxs(t.Fragment,{children:[S||T?t.jsx(s.CircularProgress,{size:18,sx:{mr:1}}):null,_.InputProps.endAdornment]})}}),ListboxProps:{sx:{maxHeight:240,overflowY:"auto"},onScroll:k}})]})]})},Al=({open:e,onClose:a,baseUrl:n,spaceId:r,contactId:o,sx:i,language:d="en",navigate:c,googleMapsApiKey:u,onEntityUpdated:p})=>{const{t:h,i18n:y}=Ke.useTranslation(),m=l.useRef(null);l.useEffect(()=>{if(window.google?.maps||document.querySelector('script[src^="https://maps.googleapis.com/maps/api/js"]'))return;if(!u){console.warn("Google Maps API key is missing. The location search feature will not work.");return}const H=document.createElement("script");return H.src=`https://maps.googleapis.com/maps/api/js?key=${u}&libraries=places`,H.async=!0,H.defer=!0,document.body.appendChild(H),()=>{}},[u]),l.useEffect(()=>{d&&y.changeLanguage(d)},[d,y]);const g=H=>h(H),b=l.useMemo(()=>!n||!r?null:gn(n,r),[n,r]),{state:S,selectors:x,actions:T}=zi({open:e,baseUrl:n,spaceId:r,contactId:o}),C=Tl({entity:S.contactData,setEntity:H=>{T.setContactData(H??void 0),H&&p&&p(H)}}),{view:j,setView:w,draftLabels:$,setDraftLabels:E,labelsOptions:F,isSaving:D,isCreatingLabel:I,handleCreateLabel:R,handleSaveTags:V}=kl({open:e,baseUrl:n,spaceId:r,contactData:S.contactData,contactType:x.contactType,labels:x.labels,selectedTags:x.tags,onTagsUpdated:H=>{if(!S.contactData)return;const L={...S.contactData,tags:H};T.setContactData(L),p&&p(L)}}),W=Lt({baseUrl:n,spaceId:r,entityType:x.contactType==="business"||x.contactType==="contact"?x.contactType:void 0,entityId:S.contactData?String(S.contactData.id):void 0,initialImageUrl:S.contactData?.imageUrl,onEntityUpdated:C}),Y=Il({onClose:a}),B={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"min(640px, calc(100vw - 32px))",height:"min(560px, calc(100vh - 64px))",bgcolor:H=>H.palette.background.panel,borderRadius:3,boxShadow:24,outline:0,p:3,overflow:"visible"},X=Array.isArray(i)?[B,...i]:i?[B,i]:B;return t.jsx(ui,{value:b,children:t.jsx(di,{t:g,children:t.jsx(ro,{navigate:c,children:t.jsx(s.Modal,{open:e,onClose:Y,closeAfterTransition:!0,slots:{backdrop:s.Backdrop},slotProps:{backdrop:{timeout:200}},children:t.jsx(s.Fade,{in:e,timeout:200,children:t.jsxs(s.Box,{sx:X,ref:m,children:[t.jsx(s.IconButton,{"aria-label":"close",onClick:Y,sx:{position:"absolute",right:5,top:5,color:H=>H.palette.grey[500],zIndex:1},size:"small",children:t.jsx(Ha,{sx:{fontSize:20}})}),S.isLoading&&!S.contactData?t.jsx(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:220},children:t.jsx(s.CircularProgress,{})}):S.error?t.jsx(s.Box,{sx:{mb:2},children:"Failed to load contact"}):S.contactData?t.jsx(ao,{value:{view:j,setView:w},children:t.jsx(Zi,{entityType:x.contactType==="business"?"business":"contact",entityData:S.contactData,customContactFields:x.contactFields,baseUrl:n,spaceId:r,children:t.jsxs(s.Box,{sx:{position:"relative",height:"100%"},children:[t.jsx(s.Fade,{in:j==="main",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsxs(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:[t.jsx(bi,{imgUrl:W.imageUrl,displayName:x.displayName,tags:x.tags,onEditTags:()=>{w("tags")},onUploadPhoto:W.action.uploadImage,onPhotoFileChange:W.inputAtributes.onChange,photoInputRef:W.inputAtributes.ref,isUploadingPhoto:W.isUploading,onDeletePhoto:W.action.deleteImage,isDeletingPhoto:W.isDeleting,contactType:x.contactType,entityId:S.contactData?.id,firstName:x.isContact?S.contactData.firstName:void 0,lastName:x.isContact?S.contactData.lastName:void 0,name:x.isBusiness?S.contactData.name:void 0,onEntityUpdated:C}),t.jsxs(s.Box,{sx:{px:1,pb:2},children:[t.jsx(Co,{dateFormat:x.userTrii?.regCon_dateFormat||"MM/dd/yyyy",entityType:x.contactType==="contact"||x.contactType==="business"?x.contactType:"contact",entityData:S.contactData,customContactFields:x.contactFields,baseUrl:n,spaceId:r,onEntityUpdated:C,currentUser:x.userTrii}),t.jsx(wl,{entityType:x.contactType==="contact"||x.contactType==="business"?x.contactType:"contact",entityData:S.contactData,baseUrl:n,spaceId:r,onEntityUpdated:C,onDirectionSearchClick:()=>w("searchLocation")}),t.jsx(jl,{ownerData:S.contactData})]})]})}),t.jsx(s.Fade,{in:j==="searchLocation",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsx(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:t.jsx(Oi,{baseUrl:n,spaceId:r,entityType:x.contactType==="business"?"business":"contact",entityId:String(S.contactData.id),onBack:()=>w("main"),onEntityUpdated:C})})}),t.jsx(s.Fade,{in:j==="tags",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsx(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:t.jsx(Ci,{value:$,options:F,onChange:E,onBack:()=>w("main"),onSave:V,isSaving:D,onCreateNew:R,isCreatingNew:I,popperContainer:m.current})})}),t.jsx(s.Fade,{in:j==="businessSelect",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsx(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:t.jsx(Dl,{baseUrl:n,spaceId:r,contactId:String(S.contactData.id),initialBusiness:x.isContact&&S.contactData?.businessId?{businessId:String(S.contactData.businessId),businessName:String(S.contactData.businessName??"")}:null,onBack:()=>w("main"),onEntityUpdated:C,currentUser:x.userTrii})})})]})})}):null]})})})})})})},Fl=e=>t.jsx(Ke.I18nextProvider,{i18n:Nt,children:t.jsx(Al,{...e})}),Pn=l.createContext(null),Bl=Pn.Provider,Un=()=>l.useContext(Pn),$l={events:[],setEvents:()=>{},filteredEvents:[]},Ml=(e,a)=>{const[n,r]=l.useState([]);l.useEffect(()=>{if(!a?.length){r([]);return}const i=a.map(d=>({id:d.id,title:d.title||"",start:new Date(d.startAt),end:new Date(d.endAt||d.startAt),startAt:d.startAt,endAt:d.endAt,allDay:d.allDay||!1,color:d.color,calendarId:d.calendarId,details:d.details,location:d.location,isPrivate:d.isPrivate,rule:d.rule,relatedContact:d.relatedContact,sharedWith:d.sharedWith,finalized:d.finalized,kind:"event",originalOccurrenceDate:d.originalOccurrenceDate,parentId:d.parentId}));r(i)},[a]);const o=l.useMemo(()=>e?.length?n.filter(i=>i.calendarId&&e.includes(i.calendarId)):n,[n,e]);return l.useMemo(()=>({events:n,setEvents:r,filteredEvents:o}),[n,o])},Rn={open:!1,handleOpen:()=>{},handleClose:()=>{}},Nn=()=>{const[e,a]=l.useState(!1),n=l.useCallback(()=>{a(!0)},[]),r=l.useCallback(()=>{a(!1)},[]);return l.useMemo(()=>({open:e,handleOpen:n,handleClose:r}),[e,n,r])},pt={actions:{onError:()=>{},onSuccess:()=>{},resetValue:()=>{},changeValue:()=>{}},attributes:{error:!1,helperText:"",type:"",value:"",onChange:()=>{}}},ft=(e,a)=>{const[n,r]=l.useState(a||""),[o,i]=l.useState(!1),[d,c]=l.useState("");l.useEffect(()=>{r(a||"")},[a]);const u=l.useCallback(S=>{i(!0),c(S)},[]),p=l.useCallback(()=>{i(!1),c("")},[]),h=l.useCallback(S=>{r(S.target.value)},[]),y=l.useCallback(S=>{r(S)},[]),m=l.useCallback(()=>{r(a||"")},[a]),g=l.useMemo(()=>({onError:u,onSuccess:p,resetValue:m,changeValue:y}),[u,p,m,y]),b=l.useMemo(()=>({error:o,helperText:d,type:e,value:n,onChange:h}),[o,d,e,n,h]);return{actions:g,attributes:b}};function Ln(e){return typeof e=="number"}const Pl={notifications:[],action:{addNotification:()=>{},deleteNotification:e=>{},handleTimeFieldChange:(e,a)=>{},handleTimePeriodChange:(e,a)=>{},handleReminderChange:(e,a)=>{},resetNotifications:()=>{}}};function Ul(e){const[a,n]=l.useState(e||[]),r=l.useCallback(()=>{const h={id:Ot(),timeValue:15,timePeriod:ia.EventNotificationPeriod.MINUTE,sendToContact:!1};n(y=>y.concat(h))},[]),o=l.useCallback(h=>{n(y=>y.filter(m=>m.id!==h))},[]),i=l.useCallback((h,y)=>{const m=Number(h.target.value);Ln(m)&&n(g=>g.map(b=>b.id===y?{...b,timeValue:m}:b))},[]),d=l.useCallback((h,y)=>{if(!Ln(h.target.value))return;const m=h.target.value;n(g=>g.map(b=>b.id===y?{...b,timePeriod:m}:b))},[]),c=l.useCallback((h,y)=>{const m=h.target.checked;n(g=>g.map(b=>b.id===y?{...b,sendToContact:m}:b))},[]),u=l.useCallback(()=>{n([])},[]);l.useEffect(()=>{if(e){const h=e.map(y=>({...y,id:y.id||Ot()}));n(h)}},[e]);const p=l.useMemo(()=>({addNotification:r,deleteNotification:o,handleTimeFieldChange:i,handleTimePeriodChange:d,handleReminderChange:c,resetNotifications:u}),[r,o,i,d,c,u]);return{notifications:a,action:p}}const Rl={state:{selectedStartDate:J(),selectedEndDate:J().add(30,"minute"),error:!1},action:{setSelectedStartDate:()=>{},setSelectedEndDate:()=>{},setError:()=>{},handleSelect:()=>()=>{}}},Nl={state:{search:"",selectedContacts:[]},action:{handleSelectContact:()=>{},handleRemoveContact:()=>{},handleSearchChange:()=>{},resetField:()=>{}}},Ll={field:{userIds:[]},action:{setUserIds:()=>{},resetField:()=>{}}},Ol={titleField:pt,descriptionField:pt,locationField:pt,colorField:pt,date:Rl,allDay:!1,setAllDay:()=>{},isPrivate:!1,setIsPrivate:()=>{},recurrenceRule:"",setRecurrenceRule:()=>{},notifications:Pl,shareWithUsers:Ll,linkContact:Nl,create:()=>({title:"",details:"",location:"",allDay:!1,isPrivate:!1,color:"",startAt:"",endAt:"",notifications:[],sharedWith:[],rule:""}),resetFields:()=>{}},zl=(e,a)=>{const[n,r]=l.useState(e??J()),[o,i]=l.useState(a??J().add(30,"minute")),[d,c]=l.useState(!1),u=l.useCallback(y=>m=>{y(m)},[]),p=l.useMemo(()=>({selectedStartDate:n,selectedEndDate:o,error:d}),[n,o,d]),h=l.useMemo(()=>({setSelectedStartDate:r,setSelectedEndDate:i,setError:c,handleSelect:u}),[u]);return{state:p,action:h}},Wl=()=>{const[e,a]=l.useState(""),[n,r]=l.useState([]),o=l.useCallback(h=>{r(y=>y.some(m=>m.id===h.id)?y:[...y,{id:h.id,name:h.name??""}]),a("")},[]),i=l.useCallback(h=>{r(y=>y.filter(m=>m.id!==h))},[]),d=l.useCallback(h=>{a(h)},[]),c=l.useCallback(()=>{a(""),r([])},[]),u=l.useMemo(()=>({search:e,selectedContacts:n}),[e,n]),p=l.useMemo(()=>({handleSelectContact:o,handleRemoveContact:i,handleSearchChange:d,resetField:c}),[o,i,d,c]);return{state:u,action:p}},_l=()=>{const[e,a]=l.useState([]),n=l.useCallback(()=>{a([])},[]),r=l.useMemo(()=>({userIds:e}),[e]),o=l.useMemo(()=>({setUserIds:a,resetField:n}),[n]);return{field:r,action:o}},Vl=e=>{const a=l.useRef(null),n=ft("text",e?.title??""),r=ft("text",e?.details??e?.description??""),o=ft("text",e?.location??""),i=ft("text",e?.color??"#1976d2"),d=zl(e?.startAt?J(e.startAt):void 0,e?.endAt?J(e.endAt):void 0),[c,u]=l.useState(e?.allDay??!1),[p,h]=l.useState(e?.isPrivate??!1),[y,m]=l.useState(e?.rule??""),g=Ul(e?.notifications),b=_l(),S=Wl(),x=l.useCallback(()=>({title:n.attributes.value,details:r.attributes.value,location:o.attributes.value,allDay:c,isPrivate:p,color:i.attributes.value,startAt:d.state.selectedStartDate.toISOString(),endAt:d.state.selectedEndDate.toISOString(),notifications:g.notifications.filter(C=>C.timeValue>0).map(C=>({id:C.id,timePeriod:C.timePeriod,timeValue:C.timeValue,sendToContact:C.sendToContact})),sharedWith:b.field.userIds,rule:y,relatedContactId:S.state.selectedContacts[0]?.id??null}),[n.attributes.value,r.attributes.value,o.attributes.value,c,p,i.attributes.value,d.state.selectedStartDate,d.state.selectedEndDate,g.notifications,b.field.userIds,y,S.state.selectedContacts]),T=l.useCallback(()=>{n.actions.resetValue(),r.actions.resetValue(),o.actions.resetValue(),i.actions.changeValue("#1976d2"),u(!1),h(!1),m(""),g.action.resetNotifications(),b.action.resetField(),S.action.resetField(),d.action.setError(!1)},[n.actions,r.actions,o.actions,i.actions,g.action,b.action,S.action,d.action]);return l.useEffect(()=>{const C=e?.id;!e||a.current===C||(a.current=C,u(e.allDay??!1),h(e.isPrivate??!1),m(e.rule??""),n.actions.changeValue(e.title??""),r.actions.changeValue(e.details??e.description??""),o.actions.changeValue(e.location??""),i.actions.changeValue(e.color??"#1976d2"),e.startAt&&d.action.setSelectedStartDate(J(e.startAt)),e.endAt&&d.action.setSelectedEndDate(J(e.endAt)))},[e?.id]),l.useMemo(()=>({titleField:n,descriptionField:r,locationField:o,colorField:i,date:d,allDay:c,setAllDay:u,isPrivate:p,setIsPrivate:h,recurrenceRule:y,setRecurrenceRule:m,notifications:g,shareWithUsers:b,linkContact:S,create:x,resetFields:T}),[n,r,o,i,d,c,p,y,g,b,S,x,T])},Hl={field:{userIds:[]},action:{setUserIds:()=>{},resetField:()=>{}}},Gl={nameField:pt,color:"#ffffff",handleColorChange:()=>{},shareWithUsers:Hl,googleCalendar:null,handleGoogleCalendarChange:()=>{}},Yl=()=>{const[e,a]=l.useState([]),n=l.useCallback(()=>{a([])},[]),r=l.useMemo(()=>({userIds:e}),[e]),o=l.useMemo(()=>({setUserIds:a,resetField:n}),[n]);return{field:r,action:o}},ql=()=>{const e=ft("text",""),[a,n]=l.useState("#ffffff"),[r,o]=l.useState(null),i=Yl(),d=l.useCallback(u=>{n(u)},[]),c=l.useCallback(u=>{o(u)},[]);return l.useMemo(()=>({nameField:e,color:a,handleColorChange:d,shareWithUsers:i,googleCalendar:r,handleGoogleCalendarChange:c}),[e,a,d,i,r,c])},Kl={tasks:[],setTasks:()=>{},filteredTasks:[]},Jl=e=>{const[a,n]=l.useState([]),r=l.useMemo(()=>e?.length?a.filter(o=>o.calendarId&&e.includes(o.calendarId)):a,[a,e]);return l.useMemo(()=>({tasks:a,setTasks:n,filteredTasks:r}),[a,r])},Ql={state:{selectedStartDate:J(),selectedEndDate:J(),error:!1},action:{setSelectedStartDate:()=>{},setSelectedEndDate:()=>{},setError:()=>{},handleSelect:()=>()=>{}}},Xl={state:{search:"",selectedContacts:[]},action:{handleSelectContact:()=>{},handleRemoveContact:()=>{},handleSearchChange:()=>{},resetField:()=>{}}},Zl={titleField:pt,descriptionField:pt,date:Ql,linkContact:Xl,create:()=>({title:"",description:"",startAt:"",endAt:""}),resetFields:()=>{}},ed=(e,a)=>{const[n,r]=l.useState(e??J()),[o,i]=l.useState(a??J()),[d,c]=l.useState(!1),u=l.useCallback(y=>m=>{y(m)},[]),p=l.useMemo(()=>({selectedStartDate:n,selectedEndDate:o,error:d}),[n,o,d]),h=l.useMemo(()=>({setSelectedStartDate:r,setSelectedEndDate:i,setError:c,handleSelect:u}),[u]);return{state:p,action:h}},td=()=>{const[e,a]=l.useState(""),[n,r]=l.useState([]),o=l.useCallback(h=>{r(y=>y.some(m=>m.id===h.id)?y:[...y,{id:h.id,name:h.name??""}]),a("")},[]),i=l.useCallback(h=>{r(y=>y.filter(m=>m.id!==h))},[]),d=l.useCallback(h=>{a(h)},[]),c=l.useCallback(()=>{a(""),r([])},[]),u=l.useMemo(()=>({search:e,selectedContacts:n}),[e,n]),p=l.useMemo(()=>({handleSelectContact:o,handleRemoveContact:i,handleSearchChange:d,resetField:c}),[o,i,d,c]);return{state:u,action:p}},ad=e=>{const a=l.useRef(null),n=ft("text",e?.title??""),r=ft("text",e?.description??""),o=ed(e?.startAt?J(e.startAt):void 0,e?.startAt?J(e.startAt):void 0),i=td(),d=l.useCallback(()=>({title:n.attributes.value,description:r.attributes.value,startAt:o.state.selectedStartDate.toISOString(),endAt:o.state.selectedStartDate.toISOString(),relatedContactId:i.state.selectedContacts[0]?.id??null}),[n.attributes.value,r.attributes.value,o.state.selectedStartDate,i.state.selectedContacts]),c=l.useCallback(()=>{n.actions.resetValue(),r.actions.resetValue(),i.action.resetField(),o.action.setError(!1)},[n.actions,r.actions,i.action,o.action]);return l.useEffect(()=>{const u=e?.id;if(!(!e||a.current===u)&&(a.current=u,n.actions.changeValue(e.title??""),r.actions.changeValue(e.description??""),e.startAt)){const p=J(e.startAt);o.action.setSelectedStartDate(p),o.action.setSelectedEndDate(p)}},[e?.id]),l.useMemo(()=>({titleField:n,descriptionField:r,date:o,linkContact:i,create:d,resetFields:c}),[n,r,o,i,d,c])},Ua=l.createContext({eventDialog:Rn,createCalendarDialog:Rn,event:Ol,events:$l,calendar:Gl,dialogMode:"view",handleCreateEvent:()=>{},handleSelectEvent:()=>{},handleOpenEventCreate:()=>{},handleStartEditingEvent:()=>{},handleSaveUpdatedEvent:()=>{},handleEndEvent:()=>{},handleDeleteEvent:()=>{},handleResizeEvent:()=>{},selectedEvent:{},savingSnackbar:{open:!1,message:"",severity:"info"},handleCloseSnackbar:()=>{},dialogType:"event",setDialogType:()=>{},handleOpenTaskCreate:()=>{},handleOpenCreateFromSlot:()=>{},handleCloseCreateCalendarDialog:()=>{},calendarDialogMode:"create",editingCalendar:null,handleOpenCreateCalendarDialog:()=>{},handleOpenEditCalendarDialog:()=>{},handleSubmitCalendar:async()=>{},tasks:Kl,activeCalendarIds:[],setActiveCalendarIds:()=>{},handleCreateTask:()=>{},task:Zl,selectedTask:null,taskCalendarId:"",setTaskCalendarId:()=>{},eventCalendarId:"",setEventCalendarId:()=>{},userManuallyChangedColor:!1,setUserManuallyChangedColor:()=>{},myCalendars:[],otherCalendars:[],isLoadingCalendars:!1,isCreatingEvent:!1,isUpdatingEvent:!1,isDeletingEvent:!1,isCreatingTask:!1,isUpdatingTask:!1,isDeletingTask:!1,handleSaveUpdatedTask:()=>{},handleDeleteTask:()=>{},handleToggleTaskCompleted:()=>{},handleDuplicateItem:()=>{},calendarView:"month",setCalendarView:()=>{},calendarDate:new Date,setCalendarDate:()=>{},navigateToDate:()=>{},confirmDeleteDialog:{open:!1,handleClose:()=>{},itemType:"event"},handleConfirmDelete:()=>{},deleteRecurringDialog:{open:!1,handleClose:()=>{}},handleConfirmDeleteRecurring:()=>{},editRecurringDialog:{open:!1,handleClose:()=>{}},handleConfirmEditRecurring:()=>{},hiddenTabs:!1}),On=e=>e,zn=l.createContext(On),nd=({t:e,children:a})=>t.jsx(zn.Provider,{value:e,children:a}),Be=()=>{const e=l.useContext(zn);return e?(...a)=>{const[n,...r]=a;return e(n,...r)}:(console.warn("[useTranslationContext] using noop, context value is falsy"),On)};var rd=Object.defineProperty,sd=(e,a,n)=>a in e?rd(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,Wn=(e,a,n)=>sd(e,typeof a!="symbol"?a+"":a,n);class id extends Error{constructor(a,n,r){super(a),Wn(this,"status"),Wn(this,"body"),this.name="ApiError",this.status=n,this.body=r}}async function Ie({url:e,method:a="GET",headers:n,body:r,signal:o}){const i=await globalThis.fetch(e,{method:a,headers:{...r?{"Content-Type":"application/json"}:{},...n??{}},body:r?JSON.stringify(r):void 0,signal:o}),d=(i.headers.get("content-type")||"").includes("application/json")?await i.json().catch(()=>null):await i.text().catch(()=>null);if(!i.ok){const c=typeof d=="object"&&d&&"message"in d?String(d.message):`Request failed with status ${i.status}`;throw new id(c,i.status,d)}return d}function ke(e,a){const n=e.endsWith("/")?e.slice(0,-1):e,r=a.startsWith("/")?a:`/${a}`;return`${n}${r}`}function ga(e,a){const n=encodeURIComponent(a);return{CONTACTS:ke(e,`/contacts/${n}`),MEDIA:ke(e,`/media/${n}`),SETTINGS:ke(e,`/settings/${n}`),CALENDAR:ke(e,`/calendar/${n}`)}}function He(e){return ga(e.baseUrl,e.spaceId).CALENDAR}async function od(e){const a=ga(e.baseUrl,e.spaceId);return Ie({url:ke(a.SETTINGS,"/user")})}async function ld(e,a,n){const r=`${He(e)}/Events?start=${encodeURIComponent(a)}&end=${encodeURIComponent(n)}`;return Ie({url:r})}async function dd(e,a){const n=He(e);return Ie({url:ke(n,"/events"),method:"POST",body:a})}async function _n(e,a){const n=He(e),{activityId:r,updatedActivity:o,originalOccurrenceDate:i}=a;if(i){const d=i instanceof Date?i.toISOString():i,c=`${n}/events/occurrence/${r}?occurrence=${d}`;return Ie({url:c,method:"PUT",body:o})}return Ie({url:ke(n,`/events/${r}`),method:"PUT",body:o})}async function Ra(e,a,n){const r=He(e);if(n){const o=n instanceof Date?n.toISOString():n,i=`${r}/events/${a}?occurrence=${o}`;await Ie({url:i,method:"DELETE"})}else await Ie({url:ke(r,`/events/${a}`),method:"DELETE"})}async function cd(e,a){const n=He(e);return Ie({url:ke(n,`/events/${a}`),method:"PUT",body:{finalized:!0}})}async function ud(e,a){const n=He(e);return Ie({url:ke(n,`/Task/${a}`)})}async function pd(e,a){const n=He(e);return Ie({url:ke(n,"/Task"),method:"POST",body:a})}async function Vn(e,a,n){const r=He(e);return Ie({url:ke(r,`/Task/${a}`),method:"PUT",body:n})}async function fd(e,a){const n=He(e);await Ie({url:ke(n,`/Task/${a}`),method:"DELETE"})}async function gd(e,a,n){const r=He(e);return Ie({url:ke(r,`/Task/${a}`),method:"PUT",body:{isCompleted:n}})}async function md(e){const a=He(e);return Ie({url:ke(a,"/Calendar")})}async function hd(e,a){const n=He(e);return Ie({url:ke(n,"/Calendar"),method:"POST",body:a})}async function yd(e,a,n){const r=He(e);return Ie({url:ke(r,`/Calendar/${a}`),method:"PUT",body:n})}async function xd({baseUrl:e,spaceId:a,contactId:n,signal:r}){const o=ga(e,a),i=ke(o.CONTACTS,`/contacts/${encodeURIComponent(n)}`);return Ie({url:i,signal:r})}async function bd({baseUrl:e,spaceId:a,pagination:n,signal:r}){const o=ga(e,a),i=ke(o.CONTACTS,"/Search");return Ie({url:i,method:"POST",body:n,signal:r})}function Na(e){const a=J(e),n=a.minute();return n===0||n===30?a.second(0).millisecond(0):n>0&&n<30?a.minute(30).second(0).millisecond(0):a.add(1,"hour").minute(0).second(0).millisecond(0)}const Gt=e=>{if(!e)return e;const a=e.indexOf("_");if(a===-1)return e;const n=e.substring(0,a),r=e.substring(a+1);return/^\d{14}$/.test(r)?n:e},Yt=e=>e?e.parentId?e.parentId:Gt(e.id):"",vd=({children:e,externalOpen:a,externalOnClose:n,externalMode:r="create",externalType:o="event",externalEventCalendarId:i,externalTaskCalendarId:d,externalSelectedEvent:c,externalSelectedTask:u,hiddenTabs:p=!1,externalContactId:h,externalOnActionComplete:y})=>{const{t:m}=Ke.useTranslation(),g=Un(),b=(v,...N)=>m(v,...N),[S,x]=l.useState(o),[T,C]=l.useState(null),[j,w]=l.useState(null),[$,E]=l.useState(r),[F,D]=l.useState(d||""),[I,R]=l.useState(i||""),[V,W]=l.useState(!1),[Y,B]=l.useState("create"),[X,H]=l.useState(null),[L,k]=l.useState({open:!1,message:"",severity:"info"}),[M,O]=l.useState(!1),[U,G]=l.useState("event"),[_,ae]=l.useState(!1),[de,oe]=l.useState(!1),[Se,ve]=l.useState(null),[Z,Ue]=l.useState(!1),[ce,q]=l.useState(!1),[pe,Ze]=l.useState(!1),[Q,$e]=l.useState(!1),[We,Ge]=l.useState(!1),[ue,Kt]=l.useState(!1),rt="trii_calendar_last_view",jt=v=>v==="month"||v==="week"||v==="day",[wt,Jt]=l.useState(()=>{try{const v=localStorage.getItem(rt);return jt(v)?v:"month"}catch{return"month"}}),[Qt,Tt]=l.useState(new Date),lt=v=>{Tt(v),Jt("day")},Re=Nn(),dt=Nn(),se=Vl(T??void 0),fe=ad(j??void 0);l.useEffect(()=>{r!==void 0&&E(r)},[r]),l.useEffect(()=>{o!==void 0&&x(o)},[o]),l.useEffect(()=>{i!==void 0&&R(i)},[i]),l.useEffect(()=>{d!==void 0&&D(d)},[d]),l.useEffect(()=>{c!==void 0&&(C(c),c?.calendarId&&R(c.calendarId))},[c]),l.useEffect(()=>{u!==void 0&&(w(u),u?.calendarId&&D(u.calendarId))},[u]),l.useEffect(()=>{if(!h||!g||r!=="create"||!Re.open)return;let v=!1;return xd({baseUrl:g.baseUrl,spaceId:g.spaceId,contactId:h}).then(N=>{v||!N||(se.linkContact.action.resetField(),se.linkContact.action.handleSelectContact(N),fe.linkContact.action.resetField(),fe.linkContact.action.handleSelectContact(N))}).catch(()=>{}),()=>{v=!0}},[h,Re.open]),l.useEffect(()=>{if(a!==void 0)if(a&&!Re.open){if(r==="create"){se.resetFields(),fe.resetFields(),W(!1),C(null),w(null),se.date.action.setError(!1),fe.date.action.setError(!1);const v=Na(new Date),N=v.add(30,"minute");if(o==="task"?(fe.date.action.setSelectedStartDate(v),fe.date.action.setSelectedEndDate(v)):(se.date.action.setSelectedStartDate(v),se.date.action.setSelectedEndDate(N)),!i){const P=Le?.[0]??st?.[0]?.id??Ne?.[0]?.id??"";P&&R(P)}if(!d){const P=Le?.[0]??Ne?.[0]?.id??"";P&&D(P)}}Re.handleOpen()}else!a&&Re.open&&Re.handleClose()},[a]);const Ye=()=>{($==="edit"||$==="create")&&(se.resetFields(),fe.resetFields()),se.date.action.setError(!1),fe.date.action.setError(!1),n?n():Re.handleClose()},Me=ql(),Xt=Y==="create",[Ne,ba]=l.useState([]),[va,Zt]=l.useState(!1),[kt,ea]=l.useState([]),[qe,It]=l.useState(""),gt="calendar_selected_ids",[Le,mt]=l.useState(()=>{try{const v=localStorage.getItem(gt);return v?JSON.parse(v):[]}catch{return[]}}),ht=Ml(Le,kt),ta=Jl(Le),aa=()=>{k(v=>({...v,open:!1}))},Qe=l.useCallback((v,N,P)=>{y?.(v,N,P)},[y]);function na(v){const N=v?.startAt??v?.start,P=v?.endAt??v?.end??N;return{startAt:N,endAt:P}}const{myCalendars:st,otherCalendars:ra}=l.useMemo(()=>{const v=Ne??[];if(!qe)return{myCalendars:v,otherCalendars:[]};const N=v.filter(K=>K.userId===qe),P=v.filter(K=>K.userId!==qe);return N.length===0&&v.length>0?{myCalendars:v,otherCalendars:[]}:{myCalendars:N,otherCalendars:P}},[Ne,qe]),yt=l.useCallback(async()=>{if(g)try{const v=new Date,N=v.getUTCFullYear(),P=v.getUTCMonth(),K=new Date(Date.UTC(N,P-1,1,0,0,0)).toISOString(),te=new Date(Date.UTC(N,P+2,1,0,0,0)).toISOString(),ye=await ld(g,K,te);ea(ye)}catch(v){console.error("Error fetching activities:",v)}},[g]),Et=l.useCallback(async v=>{if(g)try{const N=await ud(g,v);ta.setTasks(N.map(P=>({id:P.id,title:P.title||"",start:new Date(P.startAt),end:new Date(P.endAt||P.startAt),startAt:P.startAt,endAt:P.endAt,description:P.description,calendarId:P.calendarId,isCompleted:P.isCompleted||!1,relatedContact:P.relatedContact,kind:"task"})))}catch(N){console.error("Error fetching tasks:",N)}},[g]),Dt=l.useCallback(async()=>{if(g){Zt(!0);try{const v=await md(g);ba(v)}catch(v){console.error("Error fetching calendars:",v)}finally{Zt(!1)}}},[g]);l.useEffect(()=>{const v=st?.[0]?.id??Ne?.[0]?.id??"";v&&Re.open&&$==="create"&&(I||R(v),F||D(v))},[Re.open,$]);const At=l.useRef(!1);l.useEffect(()=>{a||(At.current=!1)},[a]),l.useEffect(()=>{if(!g||!a||At.current||(At.current=!0,Dt(),r==="create"))return;let v=!1;return od(g).then(N=>{v||It(N.uid)}).catch(()=>{}),()=>{v=!0}},[g,a,r,Dt]);function Ft(v,N,P){x(v),E("create"),C(null),w(null),se.resetFields(),fe.resetFields(),W(!1);const K=Na(N??new Date),te=P?Na(P):K.add(30,"minute"),ye=te.isAfter(K)?te:K.add(30,"minute");if(v==="task"){fe.date.action.setSelectedStartDate(K),fe.date.action.setSelectedEndDate(K),fe.date.action.setError(!1);const Ve=Le?.[0]??Ne?.[0]?.id??"";D(Ve)}else{se.date.action.setSelectedStartDate(K),se.date.action.setSelectedEndDate(ye),se.date.action.setError(!1);const Ve=Le?.[0]??st?.[0]?.id??Ne?.[0]?.id??"";R(Ve);const me=st?.find(je=>je.id===Ve)??Ne?.find(je=>je.id===Ve);me?.color&&se.colorField.actions.changeValue(me.color)}Re.handleOpen()}function f(){Ft("event")}function A(){se.date.action.setError(!1),fe.date.action.setError(!1),E("edit")}function z(v){const{startAt:N,endAt:P}=na(v),K={...v,kind:"event",startAt:N,endAt:P,details:v?.details??""};x("event"),C(K),w(null);const te=K.calendarId||st?.[0]?.id||Ne?.[0]?.id||"";R(te),E("view"),se.date.action.setError(!1),fe.date.action.setError(!1),Re.handleOpen()}async function ee(v){if(!g)return;let N;if(v)N={title:v.title,details:v.description||v.details||"",startAt:new Date(v.startAt),endAt:new Date(v.endAt),allDay:v.allDay,location:v.location||"",isPrivate:v.isPrivate||!1,color:v.color||"",rule:v.rule||"",contactId:v.relatedContactId||h||null,sharedWith:v.sharedWith||[],notifications:(v.notifications||[]).map(te=>({id:Ot(),timeValue:te.value,timePeriod:te.type,sendToContact:te.sendToContact||!1})),eventTypeId:"",repeatId:""};else{const te=se.create();if(!te.title){k({open:!0,message:b("global.nameRequired"),severity:"error"});return}N={...te,startAt:new Date(te.startAt),endAt:new Date(te.endAt),contactId:te.relatedContactId||h||null,eventTypeId:"",repeatId:"",notifications:te.notifications.map(ye=>({...ye,id:ye.id||Ot()}))}}const P=I;if(!P){k({open:!0,message:b("global.errorSavingChanges"),severity:"error"});return}const K={...N,calendarId:P};Ue(!0);try{k({open:!0,message:b("global.savingChanges"),severity:"info"});const te=await dd(g,K);Le.includes(P)||mt(ye=>[...ye,P]),k({open:!0,message:b("global.changesSaved"),severity:"success"}),Qe("created","event",te),se.resetFields(),Ye()}catch(te){console.error("Error creando evento:",te);const ye=te?.response?.data?.message||te?.message||b("global.errorSavingChanges");k({open:!0,message:ye,severity:"error"})}finally{Ue(!1)}}async function le(){if(!T?.id)return;const v=se.create(),N=I||T.calendarId||"";if(!N){k({open:!0,message:b("global.errorSavingChanges"),severity:"error"});return}T.originalOccurrenceDate!=null?(ve(()=>async P=>{await ge(v,N,P)}),oe(!0)):await ge(v,N,!1)}async function ge(v,N,P){const K=T?.originalOccurrenceDate!=null,te={title:v.title,details:v.details,startAt:v.startAt,endAt:v.endAt,allDay:v.allDay,isPrivate:v.isPrivate,location:v.location,color:v.color,calendarId:N,notifications:v.notifications,sharedWith:v.sharedWith};(P||!K)&&(te.rule=v.rule);const ye=Yt(T),Ve={updatedActivity:te,activityId:ye};K&&!P&&(Ve.originalOccurrenceDate=T.originalOccurrenceDate),q(!0);try{const me=await _n(g,Ve);me&&(C(me),me.calendarId&&R(me.calendarId)),k({open:!0,message:b("global.changesSaved"),severity:"success"}),Qe("updated","event",me),Ye()}catch(me){console.error("Error actualizando evento:",me);const je=me?.response?.data?.message||me?.message||b("global.errorSavingChanges");k({open:!0,message:je,severity:"error"})}finally{q(!1)}}async function ie(v){oe(!1),Se&&(await Se(v),ve(null))}async function re(){T?.originalOccurrenceDate!=null?ae(!0):(G("event"),O(!0))}async function Ee(){if(g)if(O(!1),U==="event")try{const v=Yt(T);Ye(),await Ra(g,v),k({open:!0,message:b("global.changesSaved"),severity:"success"}),Qe("deleted","event",{id:v}),yt()}catch(v){console.error("Error deleting event:",v);const N=v?.message?.includes("duplicate key")?b("global.eventAlreadyDeleted","El evento ya fue eliminado"):b("global.errorSavingChanges");k({open:!0,message:N,severity:"error"})}else{if(!j?.id)return;try{const v=Gt(j.id),N=j.calendarId;Ye(),await fd(g,v),w(null),fe.resetFields(),k({open:!0,message:b("global.changesSaved"),severity:"success"}),Qe("deleted","task",{id:v}),N&&Et(N)}catch(v){console.error("Error deleting task:",v);const N=v?.message?.includes("duplicate key")?b("global.taskAlreadyDeleted","La tarea ya fue eliminada"):b("global.errorSavingChanges");k({open:!0,message:N,severity:"error"})}}}async function he(v){ae(!1);const N=Yt(T);Ye();try{v?await Ra(g,N):await Ra(g,N,T.originalOccurrenceDate),k({open:!0,message:b("global.changesSaved"),severity:"success"}),Qe("deleted","event",{id:N}),yt()}catch(P){console.error("Error deleting recurring event:",P);const K=P?.message?.includes("duplicate key")?b("global.eventAlreadyDeleted","El evento ya fue eliminado"):b("global.errorSavingChanges");k({open:!0,message:K,severity:"error"})}}async function Ce(){if(!g)return;const v=Yt(T);await cd(g,v),Ye()}async function _e(v,N,P){const K=N instanceof Date?N:new Date(N),te=P instanceof Date?P:new Date(P),ye=K.toISOString(),Ve=te.toISOString(),me=v.kind==="task";!me&&v.originalOccurrenceDate!=null?(C(v),ve(()=>async je=>{await et(v,ye,Ve,K,te,me,je)}),oe(!0)):await et(v,ye,Ve,K,te,me,!1)}async function et(v,N,P,K,te,ye,Ve){ye||ht.setEvents(me=>me.map(je=>je.id===v.id?{...je,start:K,end:te,startAt:K,endAt:te}:je)),k({open:!0,message:b("global.savingChanges"),severity:"info"});try{if(ye){const me=Gt(v.id),je={title:v.title,description:v.description,startAt:N,endAt:P,calendarId:v.calendarId,allDay:v.allDay||!1,isCompleted:v.isCompleted||!1};await Vn(g,me,je),await Et(v.calendarId)}else{const me=Yt(v),je=v.originalOccurrenceDate!=null,_a={title:v.title,details:v.details,startAt:new Date(N),endAt:new Date(P),allDay:v.allDay,isPrivate:v.isPrivate,location:v.location,color:v.color,calendarId:v.calendarId};(Ve||!je)&&(_a.rule=v.rule);const Va={updatedActivity:_a,activityId:me};je&&!Ve&&(Va.originalOccurrenceDate=v.originalOccurrenceDate),await _n(g,Va)}k({open:!0,message:b("global.changesSaved"),severity:"success"}),yt()}catch{ye||ht.setEvents(me=>me.map(je=>je.id===v.id?{...je,start:v.start,end:v.end}:je)),k({open:!0,message:b("global.errorSavingChanges"),severity:"error"})}}function tt(v,N){Ft("event",v,N)}function De(){Me.nameField.actions.resetValue(),Me.handleColorChange("#ffffff"),Me.shareWithUsers.action.resetField(),Me.handleGoogleCalendarChange(null)}function xt(){De(),H(null),B("create"),dt.handleClose()}function Ca(v){Me.nameField.actions.changeValue(v.title??""),Me.nameField.actions.onSuccess(),Me.handleColorChange(v.color??"#ffffff"),Me.shareWithUsers.action.setUserIds(v.sharedWith??[]),Me.handleGoogleCalendarChange(v.googleCalendar??null)}function Sa(){B("create"),H(null),De(),dt.handleOpen()}function br(v){B("edit"),H(v),Ca(v),dt.handleOpen()}async function vr(){if(!g)return;const v=(Me.nameField.attributes.value??"").trim();if(!v){k({open:!0,message:b("global.nameRequired"),severity:"error"});return}const N=Me.shareWithUsers.field.userIds,P={title:v,color:Me.color,sharedWith:N.length?N:void 0,googleCalendar:Me.googleCalendar};try{if(Xt)await hd(g,P);else{const K=X?.id;if(!K)return;await yd(g,K,P)}xt(),k({open:!0,message:b(Xt?"global.calendarCreatedSuccess":"global.calendarUpdatedSuccess"),severity:"success"}),Dt()}catch{k({open:!0,message:b("global.errorSavingChanges"),severity:"error"})}}async function Cr(v){if(!g)return;let N;if(v?N={title:v.title,description:v.description||"",startAt:v.startAt,contactId:v.relatedContactId||null}:N=fe.create(),!N.title){k({open:!0,message:b("global.nameRequired"),severity:"error"});return}const P=F;if(!P){k({open:!0,message:b("global.errorSavingChanges"),severity:"error"});return}const K={...N,calendarId:P,contactId:N.contactId||N.relatedContactId||h||null};$e(!0);try{k({open:!0,message:b("global.savingChanges"),severity:"info"});const te=await pd(g,K);Le.includes(P)||mt(ye=>[...ye,P]),k({open:!0,message:b("global.changesSaved"),severity:"success"}),Qe("created","task",te),fe.resetFields(),Ye()}catch(te){console.error("Error creando tarea:",te);const ye=te?.response?.data?.message||te?.message||b("global.errorSavingChanges");k({open:!0,message:ye,severity:"error"})}finally{$e(!1)}}function Sr(){Ft("task")}async function jr(){if(!g||!j?.id)return;const v=fe.create();if(!v.title){k({open:!0,message:b("global.nameRequired"),severity:"error"});return}const N=F||j.calendarId;if(!N){k({open:!0,message:b("global.errorSavingChanges"),severity:"error"});return}const P={...v,calendarId:N};Ge(!0);try{const K=Gt(j.id),te=await Vn(g,K,P);te&&w(te),k({open:!0,message:b("global.changesSaved"),severity:"success"}),Qe("updated","task",te),Ye()}catch(K){console.error("Error actualizando tarea:",K);const te=K?.response?.data?.message||K?.message||b("global.errorSavingChanges");k({open:!0,message:te,severity:"error"})}finally{Ge(!1)}}async function wr(){j?.id&&(G("task"),O(!0))}async function Tr(){if(!g||!j?.id)return;const v=!j.isCompleted;try{const N=Gt(j.id),P=j.calendarId,K=await gd(g,N,v);K&&w(K),k({open:!0,message:b("global.changesSaved"),severity:"success"}),P&&Et(P)}catch{k({open:!0,message:b("global.errorSavingChanges"),severity:"error"})}}function kr(){const v=S==="event",N=v?T:j;if(!N)return;const P={...N};v?(C(null),E("create"),W(!0),setTimeout(()=>{if(se.titleField.actions.changeValue(P.title??""),se.descriptionField.actions.changeValue(P.details??P.description??""),se.locationField.actions.changeValue(P.location??""),se.colorField.actions.changeValue(P.color??""),se.setAllDay(P.allDay??!1),se.setIsPrivate(P.isPrivate??!1),se.setRecurrenceRule(P.rule??""),se.date.action.setSelectedStartDate(J(P.startAt)),se.date.action.setSelectedEndDate(J(P.endAt)),se.date.action.setError(!1),se.notifications.action.resetNotifications(),P.relatedContact?.id&&se.linkContact.action.handleSelectContact(P.relatedContact),P.sharedWith){const K=P.sharedWith.map(te=>te.id);se.shareWithUsers.action.setUserIds(K)}R(P.calendarId??I)},50)):(w(null),E("create"),setTimeout(()=>{fe.titleField.actions.changeValue(P.title??""),fe.descriptionField.actions.changeValue(P.description??""),fe.date.action.setSelectedStartDate(J(P.startAt)),fe.date.action.setSelectedEndDate(J(P.startAt)),fe.date.action.setError(!1),P.relatedContact?.id&&fe.linkContact.action.handleSelectContact(P.relatedContact),D(P.calendarId??F)},50))}function Ir(v){const{startAt:N,endAt:P}=na(v),K={...v,kind:"task",startAt:N,endAt:P,description:v?.description??""};x("task"),w(K),D(K.calendarId??""),R(K.calendarId??""),C(null),E("view"),se.date.action.setError(!1),fe.date.action.setError(!1),Re.handleOpen()}function Er(v){return v?.kind==="task"?Ir(v):z(v)}l.useEffect(()=>{try{Le&&localStorage.setItem(gt,JSON.stringify(Le))}catch{}},[Le]),l.useEffect(()=>{Ne?.length&&mt(v=>{const N=new Set(Ne.map(K=>K.id)),P=(v??[]).filter(K=>N.has(K));return P.length?P:Ne.map(K=>K.id)})},[Ne]),l.useEffect(()=>{try{localStorage.setItem(rt,wt)}catch{}},[wt]);const Dr={eventDialog:{...Re,handleClose:Ye},dialogMode:$,createCalendarDialog:dt,event:se,calendar:Me,events:ht,handleCreateEvent:ee,handleSelectEvent:Er,handleOpenEventCreate:f,handleStartEditingEvent:A,handleSaveUpdatedEvent:le,handleEndEvent:Ce,handleDeleteEvent:re,handleResizeEvent:_e,selectedEvent:T,savingSnackbar:L,handleCloseSnackbar:aa,dialogType:S,setDialogType:x,handleOpenTaskCreate:Sr,handleOpenCreateFromSlot:tt,handleCloseCreateCalendarDialog:xt,calendarDialogMode:Y,editingCalendar:X,handleOpenCreateCalendarDialog:Sa,handleOpenEditCalendarDialog:br,handleSubmitCalendar:vr,tasks:ta,activeCalendarIds:Le,setActiveCalendarIds:mt,handleCreateTask:Cr,task:fe,selectedTask:j,taskCalendarId:F,setTaskCalendarId:D,eventCalendarId:I,setEventCalendarId:R,userManuallyChangedColor:V,setUserManuallyChangedColor:W,myCalendars:st,otherCalendars:ra,isLoadingCalendars:va,isCreatingEvent:Z,isUpdatingEvent:ce,isDeletingEvent:pe,isCreatingTask:Q,isUpdatingTask:We,isDeletingTask:ue,handleSaveUpdatedTask:jr,handleDeleteTask:wr,handleToggleTaskCompleted:Tr,handleDuplicateItem:kr,calendarView:wt,setCalendarView:Jt,calendarDate:Qt,setCalendarDate:Tt,navigateToDate:lt,confirmDeleteDialog:{open:M,handleClose:()=>O(!1),itemType:U},handleConfirmDelete:Ee,deleteRecurringDialog:{open:_,handleClose:()=>ae(!1)},handleConfirmDeleteRecurring:he,editRecurringDialog:{open:de,handleClose:()=>{oe(!1),ve(null)}},handleConfirmEditRecurring:ie,hiddenTabs:p};return t.jsx(nd,{t:b,children:t.jsx(Ua.Provider,{value:Dr,children:e})})},ma=s.styled(s.Box)(()=>({display:"flex",flexDirection:"column",gap:.5})),La=s.styled(s.Box)(()=>({display:"flex",alignItems:"baseline",gap:1})),Oa=s.styled(s.Typography)(()=>({marginX:"8px",marginTop:"-15px",color:"text.primary"})),St="DD/MM/YYYY",ha="HH:mm",Cd=({selectedStartDate:e,selectedEndDate:a,handleSelectStart:n,handleSelectEnd:r,isError:o,disabled:i,hideLabel:d=!1,allDay:c=!1})=>{const u=Be(),p=l.useMemo(()=>a.diff(e,"minute"),[e,a]),h=l.useMemo(()=>{if(p===0)return"0 min";const x=Math.floor(p/60),T=p%60;return x===0?`${T} min`:T===0?`${x} h`:`${x}.${Math.round(T/60*10)} h`},[p]),y=x=>{if(!x)return;const T=x.hour(e.hour()).minute(e.minute()).second(0).millisecond(0),C=x.hour(a.hour()).minute(a.minute()).second(0).millisecond(0);n(T),r(C)},m=x=>{if(!x)return;const T=x.hour(0).minute(0).second(0).millisecond(0);n(T)},g=x=>{if(!x)return;const T=x.hour(23).minute(59).second(59).millisecond(999);r(T)},b=x=>{if(!x)return;const T=e.hour(x.hour()).minute(x.minute()).second(0).millisecond(0),C=T.add(p,"minute");n(T),r(C)},S=x=>{if(!x)return;let T=e.hour(x.hour()).minute(x.minute()).second(0).millisecond(0);(T.isBefore(e)||T.isSame(e))&&(T=T.add(1,"day")),r(T)};return i?t.jsxs(ma,{children:[!d&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:u("global.date")}),c?t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,marginTop:"10px"},children:[t.jsx(s.Typography,{variant:"body1",children:e.format(St)}),t.jsx(s.Typography,{variant:"body1",color:"text.secondary",children:"\u2013"}),t.jsx(s.Typography,{variant:"body1",children:a.format(St)})]}):t.jsxs(s.Box,{children:[t.jsx(s.Typography,{variant:"body1",sx:{mb:1},children:e.format(St)}),t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(s.Typography,{variant:"body1",children:e.format(ha)}),t.jsx(s.Typography,{variant:"body1",color:"text.secondary",children:"\u2013"}),t.jsx(s.Typography,{variant:"body1",children:a.format(ha)}),p>0&&t.jsxs(s.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.7rem",ml:1},children:["(",h,")"]})]})]})]}):t.jsxs(ma,{children:[!d&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:u("global.date")}),t.jsx(Je.LocalizationProvider,{dateAdapter:Ja.AdapterDayjs,children:c?t.jsxs(La,{children:[t.jsx(Je.DatePicker,{disabled:i,format:St,label:u("global.from"),slotProps:{textField:()=>({size:"small"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:x=>x.palette.background.panel}}}},value:e,onChange:m,minDate:J(),sx:{flex:1}}),t.jsx(Oa,{variant:"body1",children:"\u2013"}),t.jsx(Je.DatePicker,{disabled:i,format:St,label:u("global.to"),slotProps:{textField:()=>({size:"small"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:x=>x.palette.background.panel}}}},value:a,onChange:g,minDate:e,sx:{flex:1}})]}):t.jsxs(t.Fragment,{children:[t.jsx(s.Box,{sx:{mb:1},children:t.jsx(Je.DatePicker,{disabled:i,format:St,slotProps:{textField:()=>({size:"small",fullWidth:!0}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:x=>x.palette.background.panel}}}},value:e,onChange:y,minDate:J()})}),t.jsxs(La,{children:[t.jsx(Je.TimePicker,{disabled:i,format:ha,ampm:!1,slotProps:{textField:()=>({label:u("global.from"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:x=>x.palette.background.panel}}}},value:e,onChange:b,sx:{alignSelf:"baseline",flex:1}}),t.jsx(Oa,{variant:"body1",children:"\u2013"}),t.jsxs(s.Box,{sx:{flex:1,display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(Je.TimePicker,{disabled:i,format:ha,ampm:!1,slotProps:{textField:()=>({label:u("global.to"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:x=>x.palette.background.panel}}}},value:a,onChange:S,sx:{alignSelf:"baseline",width:"100%"}}),p>0&&t.jsxs(s.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.7rem",ml:1.5},children:["(",h,")"]})]})]})]})}),o&&t.jsx(s.Fade,{in:o,children:t.jsx(s.Typography,{color:"red",variant:"caption",sx:{mt:1,ml:"10px"},children:u("calendarView.reminders.errorDate")})})]})};s.styled(s.Box)(()=>({display:"flex",gap:2,alignItems:"center"})),s.styled(s.Box)(({theme:e})=>({width:"15%",userSelect:"none",color:e.palette.text.secondary}));const ze=({children:e,title:a})=>t.jsxs(s.Box,{children:[t.jsx(s.Typography,{variant:"subtitle2",sx:{mb:1,userSelect:"none"},children:a}),e]}),za=({titleField:e,disabled:a,variantMode:n="default"})=>{const r=Be(),{value:o,type:i,...d}=e.attributes,c=o||"";return n==="inline"?t.jsx(s.TextField,{...d,value:c,disabled:a,autoFocus:!0,fullWidth:!0,placeholder:r("global.addTitle"),variant:"standard",InputProps:{disableUnderline:!1,sx:{fontSize:22,fontWeight:500}},sx:{"& .MuiInput-underline:before":{borderBottomColor:"divider"},"& .MuiInput-underline:hover:before":{borderBottomColor:"text.secondary"},"& .MuiInput-underline:after":{borderBottomWidth:2}}}):a?t.jsx(ze,{title:r("global.title"),children:t.jsx(s.Typography,{variant:"body1",sx:{py:.5,color:u=>u.palette.text.secondary,fontSize:"0.9rem"},children:c||"-"})}):t.jsx(ze,{title:r("global.title"),children:t.jsx(s.TextField,{...d,value:c,disabled:a,autoFocus:!0,fullWidth:!0,variant:"outlined",size:"small",type:i})})},Sd=s.styled(s.Box)(()=>({marginBottom:"6px",padding:"8px 16px",border:"1px solid lightgray",borderRadius:"3px"})),jd=s.styled(s.Box)(()=>({marginBottom:"6px",padding:"4px 0px"})),Hn=s.styled(s.Box)(()=>({display:"flex",gap:"8px",alignItems:"center",userSelect:"none"})),wd=s.styled(s.TextField)(()=>({width:"13%"})),Td=s.styled(s.Select)(()=>({width:"23%"})),kd=s.styled(s.Box)(()=>({display:"flex",gap:1,width:"100%",alignItems:"center"})),Id=s.styled(s.IconButton)(()=>({ml:"auto",color:"error"})),Gn=[{title:"minute",value:ia.EventNotificationPeriod.MINUTE},{title:"hour",value:ia.EventNotificationPeriod.HOUR},{title:"day",value:ia.EventNotificationPeriod.DAY}],Ed=({data:e,timeValueHandler:a,timePeriodHandler:n,sendToContactHandler:r,deleteHandler:o,disabled:i=!1})=>{const d=Be(),c=e.timeValue??0;return i?t.jsxs(jd,{children:[t.jsx(Hn,{children:t.jsxs(s.Typography,{variant:"body1",sx:{color:"text.secondary"},children:[d("calendarView.reminders.sendReminder.pt1")," ",c," ",d(`calendarView.reminders.timePeriod.${Gn.find(u=>u.value===e.timePeriod)?.title||"minutes"}`)," ",d("calendarView.reminders.sendReminder.pt2")]})}),e.sendToContact&&t.jsxs(s.Typography,{variant:"body1",sx:{mt:.5,fontSize:"0.875rem",color:"text.secondary"},children:["*",d("calendarView.reminders.sendReminderToContact")]})]}):t.jsxs(Sd,{children:[t.jsxs(Hn,{children:[t.jsx(s.Typography,{variant:"body2",sx:{userSelect:"none"},children:d("calendarView.reminders.sendReminder.pt1")}),t.jsx(wd,{disabled:i,onChange:u=>a(u,e.id),value:c,type:"text",variant:"outlined",size:"small"}),t.jsx(Td,{disabled:i,onChange:u=>n(u,e.id),value:e.timePeriod,variant:"outlined",size:"small",MenuProps:{PaperProps:{sx:{backgroundColor:u=>u.palette.background.panel}}},children:Gn.map(u=>t.jsx(s.MenuItem,{value:u.value,children:d(`calendarView.reminders.timePeriod.${u.title}`)},u.value))}),t.jsx(s.Typography,{variant:"body2",sx:{userSelect:"none"},children:d("calendarView.reminders.sendReminder.pt2")})]}),t.jsxs(kd,{children:[t.jsx(s.FormControlLabel,{sx:{display:"flex",alignItems:"center"},disabled:i,label:d("calendarView.reminders.sendReminderToContact"),control:t.jsx(s.Checkbox,{checked:e.sendToContact,onChange:u=>r(u,e.id),color:"secondary",disabled:i})}),t.jsx(Id,{disabled:i,onClick:()=>o(e.id),sx:{ml:"auto"},children:t.jsx(sa,{})})]})]})},Dd=s.styled(s.Box)`
16
+ <%s key={someKey} {...props} />`,xt,tt,Sa,tt),sa[tt+xt]=!0}}return f===r?st(Ce):ra(Ce),Ce}}function Et(f,F,z){return yt(f,F,z,!0)}function Dt(f,F,z){return yt(f,F,z,!1)}var At=Dt,Ft=Et;Nt.Fragment=r,Nt.jsx=At,Nt.jsxs=Ft})()),Nt}process.env.NODE_ENV==="production"?ka.exports=ns():ka.exports=rs();var t=ka.exports;as(t);const ss=s.styled(s.Box)(({theme:e})=>({position:"absolute",top:8,right:8,display:"flex",flexDirection:"column",gap:4,zIndex:1,backgroundColor:e.palette.background.panel})),an=s.styled(s.IconButton)({padding:4}),os=s.styled(s.Box)({display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"16px",position:"relative"}),is=s.styled(s.Avatar)({width:60,height:60,marginBottom:8}),ls=s.styled(s.Typography)({whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:200,textAlign:"center"}),ds=s.styled(s.Box)({display:"flex",justifyContent:"center",alignItems:"center",width:60,height:60,marginBottom:8}),cs=({imgUrl:e,name:a,contactId:n,navigate:r,isLoading:o=!1,onError:i,onClose:d,isBusiness:c=!1})=>{const u=l.useCallback(g=>y=>{try{if(y.preventDefault(),y.stopPropagation(),!g)throw new Error("Navigation URL is required");y.ctrlKey||y.metaKey||y.button===1?window.open(g,"_blank","noopener,noreferrer"):r(g)}catch(w){i?.(w instanceof Error?w:new Error("Navigation failed"))}},[r,i]),p=u(c?`/a/contacts/business/${n}`:`/a/contacts/contacts/${n}`),m=u(`/a/conversations/conversations?contactId=${n}`),h=a||"Unknown Contact",x=`Avatar for ${h}`;return t.jsxs(os,{children:[t.jsxs(ss,{children:[t.jsx(an,{color:"info",size:"small",onClick:g=>{p(g),d()},onMouseDown:g=>{g.button===1&&(p(g),d())},disabled:!n,"aria-label":"View contact details",children:t.jsx(Br,{fontSize:"small"})}),t.jsx(an,{color:"info",size:"small",onClick:g=>{m(g),d()},onMouseDown:g=>{g.button===1&&(m(g),d())},"aria-label":"Go to conversations",children:t.jsx($r,{fontSize:"small"})})]}),o?t.jsx(ds,{children:t.jsx(s.CircularProgress,{size:24})}):t.jsx(is,{src:e,alt:x,onError:()=>i?.(new Error("Failed to load avatar"))}),t.jsx(ls,{variant:"h6",title:h,children:h})]})},us=s.styled(s.Box)({display:"flex",flexDirection:"column",width:"100%",height:"max-content",alignItems:"center",gap:8}),ps=s.styled(s.Box)({width:"100%",borderBottom:"1px solid lightgray"}),fs=s.styled(s.Box)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:1,minHeight:"50px",position:"relative",maxWidth:"inherit"}),gs=s.styled(s.Box)(({theme:e})=>({marginTop:"-20px",padding:0,color:e.palette.primary.main})),ms=s.styled(s.Box)({display:"flex",maxWidth:"90%",gap:"10px",width:"100%",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",alignItems:"center"}),hs=s.styled(s.Box)({display:"flex",flexDirection:"column",height:"50px",maxWidth:"90%"}),ys=s.styled(s.Typography)({whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",maxWidth:"90%",position:"absolute",bottom:16,left:40}),xs=({icon:e,contactList:a,title:n,showTitle:r=!0})=>{const o=i=>t.jsx(fs,{children:t.jsxs(ms,{children:[t.jsx(gs,{children:e}),t.jsxs(hs,{children:[t.jsx(s.Tooltip,{title:i.address,arrow:!0,placement:"top",children:t.jsx(s.Typography,{variant:"subtitle1",fontWeight:"semi-bold",fontSize:14,color:"text.primary",sx:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",cursor:"default"},children:i.address})}),i.profileName&&t.jsx(s.Typography,{variant:"body2",fontSize:10,color:"text.disabled",sx:{marginLeft:"5px",marginTop:"10px"},children:i.profileName})]}),i.note&&t.jsx(ys,{variant:"body2",fontSize:12,color:"text.secondary",children:i.note})]})},i.id);return t.jsxs(us,{children:[r&&t.jsx(ps,{children:t.jsx(s.Typography,{variant:"subtitle1",fontWeight:"bold",gutterBottom:!0,mt:2,children:n})}),a?.map(o)]})},bs=s.styled(s.Box)({display:"flex",flexDirection:"column",width:"100%",height:"max-content",alignItems:"center",gap:8}),vs=s.styled(s.Typography)({borderBottom:"1px solid lightgray",width:"100%"}),Cs=s.styled(s.Box)({display:"flex",alignItems:"center",gap:8,width:"100%"}),Ss=s.styled(s.Typography)({fontSize:14}),js=s.styled(Ae.Handyman)(({theme:e})=>({color:e.palette.primary.main,fontSize:16})),ws=({properties:e,title:a})=>{const n=o=>o.replace(/-/g," "),r=(o,i)=>{if(!o||Array.isArray(o)&&o.length===0)return"";if(Array.isArray(o))return o.map(d=>r(d,i)).join(", ");if(typeof o=="string"){const d=ct(o,ct.ISO_8601).isValid(),c=u=>ct(o).format(u);switch(i){case ne.ContactField_type.TIME:return d?c("HH:mm"):o;case ne.ContactField_type.DATE:return d?c("DD/MM/YYYY"):o;case ne.ContactField_type.TIMERANGE:case ne.ContactField_type.DATERANGE:if(d)return i===ne.ContactField_type.TIMERANGE?c("HH:mm"):c("DD/MM/YYYY");const u=o.split(" ");if(u.length===2){const[p,m]=u,h=i===ne.ContactField_type.TIMERANGE?ct(p).format("HH:mm"):ct(p).format("DD/MM/YYYY"),x=i===ne.ContactField_type.TIMERANGE?ct(m).format("HH:mm"):ct(m).format("DD/MM/YYYY");return`${h} - ${x}`}return o;default:return o}}return o};return t.jsxs(bs,{children:[t.jsx(vs,{fontWeight:"bold",gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),e?.map((o,i)=>o.value.length>0&&t.jsxs(Cs,{children:[t.jsx(js,{}),t.jsxs(Ss,{children:[n(o.nameKey),":"," ",r(o.value,o.type)]})]},i))]})},Ts=s.styled(s.Typography)({fontWeight:"bold",marginBottom:"8px",marginTop:"16px",borderBottom:"1px solid lightgray"}),Is=s.styled(s.Box)({marginBottom:16}),ks=s.styled(s.Chip)(({theme:e})=>({marginRight:8,marginBottom:8,backgroundColor:`${e.palette.primary.main}b3`})),Es=({contactData:e,title:a})=>!e||!e.tags?.length?null:t.jsxs(t.Fragment,{children:[t.jsx(Ts,{gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),t.jsx(Is,{children:e?.tags?.filter(n=>n.name?.trim()).map(n=>t.jsx(ks,{label:n.name,color:"primary",size:"small"},n.id))})]});function nn(e){return e?.isBusiness===!0?!1:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&typeof e.firstName=="string"&&typeof e.lastName=="string"&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&"origin"in e&&typeof e.isSpam=="boolean"&&(!e.businessId||typeof e.businessId=="string")}const Ds=s.styled(s.Typography)({fontWeight:"bold",marginBottom:"8px",marginTop:"16px",borderBottom:"1px solid lightgray"}),As=({contactData:e,title:a})=>!e||!nn(e)?null:t.jsxs(t.Fragment,{children:[t.jsx(Ds,{gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),t.jsx(s.Typography,{variant:"body2",color:"text.secondary",children:e?.businessName})]});function rn(e){return e?.isBusiness===!0?!0:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&Array.isArray(e.membersId)&&Array.isArray(e.members)&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&typeof e.imageUrl=="string"&&!("firstName"in e)&&!("lastName"in e)}const Fs=({name:e,memberId:a,navigate:n})=>{const r=`/a/conversations/conversations?contactId=${a}`,o=i=>{i.preventDefault(),i.stopPropagation(),i.ctrlKey||i.metaKey||i.button===1?window.open(r,"_blank","noopener,noreferrer"):n(r)};return t.jsx(s.Typography,{variant:"body2",color:"text.secondary",role:"link",tabIndex:0,sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:o,onMouseDown:i=>{i.button===1&&o(i)},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:e})},Bs=s.styled(s.Typography)({fontWeight:"bold",marginBottom:"8px",marginTop:"16px",borderBottom:"1px solid lightgray"}),$s=({contactData:e,title:a,navigate:n})=>!e||!rn(e)||!e.members?.length?null:t.jsxs(t.Fragment,{children:[t.jsx(Bs,{gutterBottom:!0,mt:2,variant:"subtitle1",children:a}),e?.members.map(r=>t.jsx(Fs,{memberId:String(r.id),name:r.name,navigate:n},r.id))]});var Ms="Labels",Ps="Phone",Us="Business",Rs="Business Members",Ns="Properties",Ls="View",Os="Tags",zs={add:"Add",note:"Note",number:"Number",email:"Email",phones:"Phones",close:"Close",back:"Back",createNew:"Create new",delete:"Delete",cancel:"Cancel",save:"Save",noOptions:"No options",noValue:"No value",birthdate:"Birthdate",country:"Country",searchLocation:"Search location",date:"Date",from:"From",to:"To",time:"Time",title:"Title",addTitle:"Add title",description:"Description",location:"Location",addLocation:"Add location",selectLocation:"Select location",color:"Color",allDay:"All day",calendar:"Calendar",selectCalendar:"Select calendar",recurrence:"Recurrence",noRepeat:"Does not repeat",edit:"Edit",duplicate:"Duplicate",event:"Event",task:"Task",editEvent:"Edit event",editTask:"Edit task",saveEvent:"Save event",saveTask:"Save task",createEvent:"Create event",createTask:"Create task",finalizeEvent:"Finalize event",markAsCompleted:"Mark as completed",markAsIncomplete:"Mark as incomplete",linkContacts:"Linked contacts",searchContacts:"Search contacts",errorSavingChanges:"Error saving changes",savingChanges:"Saving changes...",changesSaved:"Changes saved",nameRequired:"Name is required",calendarCreatedSuccess:"Calendar created successfully",calendarUpdatedSuccess:"Calendar updated successfully",eventAlreadyDeleted:"Event has already been deleted",taskAlreadyDeleted:"Task has already been deleted",deleting:"Deleting...",confirm:"Confirm",name:"Name",create:"Create",showEvent:"Show Event",finalizeTask:"Finalize Task",showTask:"Show Task",createCalendar:"Create Calendar",editCalendar:"Edit Calendar",calendarInfo:"Calendar Information",deleteCalendar:"Delete Calendar",deleteConfirm:'Are you sure you want to delete the calendar "{{title}}"?',day:"Day",week:"Week",month:"Month",today:"Today",next:"Next",reminders:"Reminders",addReminder:"Add Reminder",shareWithUsers:"Share with Users",noSharedUsers:"No shared users",loading:"Loading...",moreActions:"More Actions",createdBy:"Created by",private:"Private",everyDay:"Every day",everyWeek:"Every week",everyMonth:"Every month",everyYear:"Every year",everyTwoDays:"Every 2 days",everyTwoWeeks:"Every 2 weeks",everyWeekday:"Weekdays (M-F)",seeMore:"See more"},Ws={searchAddress:"Search address",enterLocation:"Enter a location",city:"City",state:"State",postalCode:"Postal code",country:"Country",saveMainAddress:"Save main address",saveSecondaryAddress:"Save secondary address",loadingGoogleMaps:"Loading Google Maps...",googleMapsUnavailable:"Google Maps unavailable",googleMapsNotLoaded:"Google Maps not loaded",selectedPlaceNoLocation:"Selected place has no location data"},_s={upload:"Upload photo",delete:"Delete photo"},Vs={from:"From",to:"To"},Hs={contactDetails:{contactOwner:"Contact Owner",business:"Business",createdBy:"Created By",modifiedBy:"Modified By",street:"Street",city:"City",state:"State",postcode:"Postcode",country:"Country",addressInformation:"Address Information",primaryAddress:"Primary Address",secondaryAddress:"Secondary Address",contactInformation:"Contact Information",phones:"Phones",contactInfo:{emptySelection:"No selection"}},businessDetails:{businessOwner:"Business Owner"},sidebar:{events:{errorDate:"End date must be after start date"}}},Gs={reminders:{title:"Reminders",addReminder:"Add Reminder",errorDate:"The 'To' date must be greater than the 'From' date",searchContact:"Search Contact",sendReminder:{pt1:"Send reminder",pt2:"before."},timePeriod:{minute:"minute/s",hour:"hour/s",day:"day/s"},sendReminderToContact:"Send reminder to external contact"},shortcuts:{title:"Keyboard Shortcuts",advice:"Tip: You can use these shortcuts to speed up event creation and editing"},myCalendars:"My calendars",noCalendar:"No calendar",othersCalendars:"Other calendars"},Ys={labels:Ms,phone:Ps,business:Us,businessMembers:Rs,properties:Ns,view:Ls,tags:Os,global:zs,searchLocationModal:Ws,avatar:_s,contactEdit:Vs,conversations:Hs,calendarView:Gs},qs="Etiquetas",Ks="Tel\xE9fono",Js="Empresa",Qs="Miembros de la empresa",Xs="Propiedades",Zs="Ver",eo="Etiquetas",to={add:"Agregar",note:"Nota",number:"N\xFAmero",email:"Correo electr\xF3nico",phones:"Tel\xE9fonos",close:"Cerrar",back:"Volver",createNew:"Crear nuevo",delete:"Eliminar",cancel:"Cancelar",save:"Guardar",noOptions:"Sin opciones",noValue:"Sin valor",birthdate:"Fecha de nacimiento",country:"Pa\xEDs",searchLocation:"Buscar ubicaci\xF3n",date:"Fecha",from:"Desde",to:"Hasta",time:"Hora",title:"T\xEDtulo",addTitle:"Agregar t\xEDtulo",description:"Descripci\xF3n",location:"Ubicaci\xF3n",addLocation:"Agregar ubicaci\xF3n",selectLocation:"Seleccionar ubicaci\xF3n",color:"Color",allDay:"Todo el d\xEDa",calendar:"Calendario",selectCalendar:"Seleccionar calendario",recurrence:"Recurrencia",noRepeat:"No se repite",edit:"Editar",duplicate:"Duplicar",event:"Evento",task:"Tarea",editEvent:"Editar evento",editTask:"Editar tarea",saveEvent:"Guardar evento",saveTask:"Guardar tarea",createEvent:"Crear evento",createTask:"Crear tarea",finalizeEvent:"Finalizar evento",markAsCompleted:"Marcar como completado",markAsIncomplete:"Marcar como incompleto",linkContacts:"Contactos vinculados",searchContacts:"Buscar contactos",errorSavingChanges:"Error al guardar los cambios",savingChanges:"Guardando cambios...",changesSaved:"Cambios guardados",nameRequired:"El nombre es obligatorio",calendarCreatedSuccess:"Calendario creado con \xE9xito",calendarUpdatedSuccess:"Calendario actualizado con \xE9xito",eventAlreadyDeleted:"l evento ya ha sido eliminado",taskAlreadyDeleted:"La tarea ya ha sido eliminada",deleting:"Eliminando...",confirm:"Confirmar",name:"Nombre",create:"Crear",showEvent:"Mostrar evento",finalizeTask:"Finalizar tarea",showTask:"Mostrar tarea",createCalendar:"Crear calendario",editCalendar:"Editar calendario",calendarInfo:"Informaci\xF3n del calendario",deleteCalendar:"Eliminar calendario",deleteConfirm:'\xBFEst\xE1 seguro de que desea eliminar el calendario "{{title}}"?',day:"\xEDa",week:"Semana",month:"Mes",today:"Hoy",next:"Siguiente",reminders:"Recordatorios",addReminder:"Agregar recordatorio",shareWithUsers:"Compartir con usuarios",noSharedUsers:"Sin usuarios compartidos",loading:"Cargando...",moreActions:"M\xE1s acciones",createdBy:"Creado por",private:"Privado",everyDay:"Cada d\xEDa",everyWeek:"Cada semana",everyMonth:"Cada mes",everyYear:"Cada a\xF1o",everyTwoDays:"Cada 2 d\xEDas",everyTwoWeeks:"Cada 2 semanas",everyWeekday:"D\xEDas laborables (L-V)",seeMore:"Ver m\xE1s"},ao={searchAddress:"Buscar direcci\xF3n",enterLocation:"Ingres\xE1 una ubicaci\xF3n",city:"Ciudad",state:"Estado",postalCode:"C\xF3digo postal",country:"Pa\xEDs",saveMainAddress:"Guardar como direcci\xF3n principal",saveSecondaryAddress:"Guardar como direcci\xF3n secundaria",loadingGoogleMaps:"Cargando Google Maps...",googleMapsUnavailable:"Google Maps no disponible",googleMapsNotLoaded:"Google Maps no est\xE1 cargado",selectedPlaceNoLocation:"La ubicaci\xF3n seleccionada no tiene coordenadas"},no={upload:"Subir foto",delete:"Eliminar foto"},ro={from:"Desde",to:"Hasta"},so={contactDetails:{contactOwner:"Propietario del contacto",business:"Empresa",createdBy:"Creado por",modifiedBy:"Modificado por",street:"Calle",city:"Ciudad",state:"Estado",postcode:"C\xF3digo postal",country:"Pa\xEDs",addressInformation:"Informaci\xF3n de direcci\xF3n",primaryAddress:"Direcci\xF3n principal",secondaryAddress:"Direcci\xF3n secundaria",contactInformation:"Informaci\xF3n de contacto",phones:"Tel\xE9fonos",contactInfo:{emptySelection:"Sin selecci\xF3n"}},businessDetails:{businessOwner:"Propietario de la empresa"},sidebar:{events:{errorDate:"La fecha de finalizaci\xF3n debe ser posterior a la fecha de inicio"}}},oo={reminders:{title:"Recordatorios",addReminder:"Agregar recordatorio",errorDate:"La fecha 'Hasta' debe ser mayor que la fecha 'Desde'",searchContact:"Buscar contacto",sendReminder:{pt1:"Enviar recordatorio",pt2:"antes."},timePeriod:{minute:"minuto/s",hour:"hora/s",day:"d\xEDa/s"},sendReminderToContact:"Enviar recordatorio al contacto externo"},shortcuts:{title:"Atajos de teclado",advice:"Consejo: Puedes usar estos atajos para acelerar la creaci\xF3n y edici\xF3n de eventos"},myCalendars:"Mis calendarios",noCalendar:"Sin calendario",othersCalendars:"Otros calendarios"},io={labels:qs,phone:Ks,business:Js,businessMembers:Qs,properties:Xs,view:Zs,tags:eo,global:to,searchLocationModal:ao,avatar:no,contactEdit:ro,conversations:so,calendarView:oo};const lo={en:{translation:Ys},es:{translation:io}},Lt=Mr.createInstance();Lt.use(Ke.initReactI18next).init({resources:lo,lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1}});const sn=(e="",a="",n=Bt.Spaces.nameFormat.FIRST_LAST)=>{const r=e?.trim()||"",o=a?.trim()||"";switch(n){case Bt.Spaces.nameFormat.FIRST_LAST:return`${r} ${o}`.trim();case Bt.Spaces.nameFormat.LAST_FIRST:return`${o} ${r}`.trim();case Bt.Spaces.nameFormat.FIRST_COMMA_LAST:return r&&o?`${r}, ${o}`:r||o;case Bt.Spaces.nameFormat.LAST_COMMA_FIRST:return r&&o?`${o}, ${r}`:o||r;default:return`${r} ${o}`.trim()}},co=s.styled(s.Box)(({theme:e})=>({backgroundColor:e.palette.background.panel,boxShadow:"0px 4px 10px rgba(0, 0, 0, 0.1)",borderRadius:"8px",width:300,maxHeight:"calc(100vh - 500px)",overflowY:"auto",transition:"opacity 0.3s ease, transform 0.3s ease",padding:"8px",zIndex:1300,"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{background:"#E0E0E0",borderRadius:10},"&::-webkit-scrollbar-thumb":{background:"#9E9E9E",borderRadius:10,transition:"background 0.3s"},"&::-webkit-scrollbar-thumb:hover":{background:"#616161"}})),uo=({open:e,anchorEl:a,onClose:n,contactData:r,avatarImgUrl:o,navigate:i,language:d="en",contactNameFormat:c})=>{const{t:u,i18n:p}=Ke.useTranslation();l.useEffect(()=>{d&&p.changeLanguage(d)},[d,p]);const m=u,h=rn(r),x=nn(r),g=r?x?sn(r.firstName,r.lastName,c):r.name:void 0,y=[{icon:t.jsx(Ae.PhoneEnabled,{fontSize:"small"}),title:m("phone"),contactList:r?.phones||[],showTitle:!0},{icon:t.jsx(Ae.Email,{fontSize:"small"}),title:m("email"),contactList:r?.emails||[],showTitle:!0},{icon:t.jsx(Ae.WhatsApp,{fontSize:"small"}),title:"IM",contactList:r?.ims_whatsapp||[],showTitle:!0},{icon:t.jsx(Ae.Facebook,{fontSize:"small"}),contactList:r?.ims_facebook||[],showTitle:!1},{icon:t.jsx(Ae.Instagram,{fontSize:"small"}),contactList:r?.ims_instagram||[],showTitle:!1},{icon:t.jsx(Ae.ThreeP,{fontSize:"small"}),contactList:r?.ims_webchat||[],showTitle:!1}];return l.useEffect(()=>{const w=b=>{b.key==="Escape"&&n()};return e&&window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}},[e,n]),t.jsx(s.Popper,{sx:{zIndex:1300},open:e,anchorEl:a,placement:"bottom-start","data-popper-child":"true",children:t.jsx(s.ClickAwayListener,{onClickAway:n,children:t.jsx(co,{children:t.jsxs(s.CardContent,{children:[t.jsx(cs,{navigate:i,contactId:r?.id,imgUrl:o,name:g,onClose:n,isBusiness:h}),t.jsx(Es,{contactData:r,title:m("labels")}),x&&t.jsx(As,{contactData:r,title:m("business")}),h&&t.jsx($s,{contactData:r,title:m("businessMembers"),navigate:i}),y.map((w,b)=>t.jsx(xs,{icon:w.icon,title:w.title,contactList:w.contactList,showTitle:w.showTitle},b)),t.jsx(ws,{properties:r?.properties,title:m("properties")})]})})})})},on=e=>t.jsx(Ke.I18nextProvider,{i18n:Lt,children:t.jsx(uo,{...e})}),ln=e=>e,dn=l.createContext(ln),po=({t:e,children:a})=>t.jsx(dn.Provider,{value:e,children:a}),xe=()=>{const e=l.useContext(dn);return e?(...a)=>{const[n,...r]=a;return e(n,...r)}:(console.warn("[useTranslationContext] using noop, context value is falsy"),ln)},fo=({tags:e,onEditTags:a})=>{const n=xe(),[r,o]=l.useState(null),i=l.useMemo(()=>e??[],[e]),d=i.slice(0,4),c=Math.max(i.length-d.length,0),u=h=>{o(h.currentTarget)},p=()=>{o(null)},m=!!r;return t.jsxs(s.Box,{sx:{mt:1,display:"flex",justifyContent:"center"},children:[t.jsxs(s.Box,{sx:{maxWidth:320,position:"relative","&:hover .tags-action, &:focus-within .tags-action":{opacity:1}},children:[t.jsxs(s.Stack,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",justifyContent:"center",children:[d.map(h=>t.jsx(s.Chip,{label:h.name,size:"small",variant:"outlined",sx:{borderRadius:999,maxWidth:140,"& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},h.id)),c>0?t.jsx(s.Chip,{label:`+${c}`,size:"small",variant:"outlined",onClick:u,sx:{borderRadius:999}}):null]}),t.jsx(s.IconButton,{className:"tags-action",size:"small","aria-label":i.length?n("tags.edit"):n("tags.add"),onClick:a,sx:{position:"absolute",left:"100%",ml:1,top:"50%",transform:"translateY(-50%)",color:"text.secondary",bgcolor:h=>h.palette.background.panel,opacity:0,transition:"opacity 0.2s ease-in-out","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:i.length?t.jsx($t,{fontSize:"small"}):t.jsx(Pr,{fontSize:"small"})})]}),t.jsx(s.Popover,{open:m,anchorEl:r,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:t.jsxs(s.Box,{sx:{p:1.5,maxWidth:320,maxHeight:240,overflowY:"auto"},children:[t.jsx(s.Typography,{variant:"subtitle2",sx:{mb:1},children:n("tags")}),t.jsx(s.Stack,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",children:i.map(h=>t.jsx(s.Chip,{label:h.name,size:"small",variant:"outlined",sx:{borderRadius:999,maxWidth:160,"& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},h.id))})]})})]})},cn=l.createContext(null),go=cn.Provider,ot=()=>l.useContext(cn),mo=s.styled(s.Typography)({whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:360,textAlign:"center"}),ho=s.styled(s.Box)({display:"flex",alignItems:"center",justifyContent:"center",width:"100%"}),yo=s.styled(s.Box)({position:"relative",display:"flex",justifyContent:"center",maxWidth:"100%","&:hover .edit-icon":{opacity:1,visibility:"visible"}}),xo=s.styled(s.IconButton)({opacity:0,visibility:"hidden",transition:"all 0.2s",position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)"}),bo=({displayName:e,contactType:a,firstName:n,lastName:r,name:o,entityId:i,onEntityUpdated:d})=>{const c=ot(),[u,p]=l.useState(!1),[m,h]=l.useState(!1),[x,g]=l.useState({firstName:n||"",lastName:r||"",name:o||""});l.useEffect(()=>{g({firstName:n||"",lastName:r||"",name:o||""})},[n,r,o]);const y=async()=>{if(!(!c||!i||!a||a==="unknown")){h(!0);try{let b={};a==="contact"?b={firstName:x.firstName,lastName:x.lastName}:a==="business"&&(b={name:x.name});const C=await c.updateEntity({entityType:a,entityId:i,body:b});C&&d&&d(C),p(!1)}catch(b){console.error("Failed to update name",b)}finally{h(!1)}}},w=a==="contact"||a==="business";return u?t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:1},children:[a==="contact"?t.jsxs(t.Fragment,{children:[t.jsx(s.TextField,{value:x.firstName,onChange:b=>g({...x,firstName:b.target.value}),size:"small",placeholder:"First Name",sx:{width:140}}),t.jsx(s.TextField,{value:x.lastName,onChange:b=>g({...x,lastName:b.target.value}),size:"small",placeholder:"Last Name",sx:{width:140}})]}):t.jsx(s.TextField,{value:x.name,onChange:b=>g({...x,name:b.target.value}),size:"small",placeholder:"Name",sx:{width:280}}),t.jsx(s.IconButton,{onClick:y,disabled:m,color:"primary",children:m?t.jsx(s.CircularProgress,{size:24}):t.jsx(Ae.Save,{})})]}):t.jsx(ho,{children:t.jsxs(yo,{children:[t.jsx(mo,{variant:"h6",title:e,children:e}),w&&t.jsx(xo,{size:"small",onClick:()=>p(!0),className:"edit-icon",sx:{ml:1},children:t.jsx(Ae.Edit,{fontSize:"small"})})]})})},vo=({src:e,alt:a,onError:n,onUpload:r,onDelete:o,isUploading:i,isDeleting:d})=>{const c=xe();return t.jsxs(s.Box,{sx:{width:60,height:60,mb:1,position:"relative","&:hover .avatar-actions, &:focus-within .avatar-actions":{opacity:1,pointerEvents:"auto"}},children:[t.jsx(s.Avatar,{src:e,alt:a,onError:n,sx:{width:60,height:60}}),t.jsxs(s.Box,{className:"avatar-actions",sx:{position:"absolute",inset:0,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",gap:.5,bgcolor:"rgba(0, 0, 0, 0.35)",opacity:0,pointerEvents:"none",transition:"opacity 0.2s ease-in-out"},children:[t.jsx(s.IconButton,{size:"small","aria-label":c("avatar.upload"),onClick:r,disabled:!!i,sx:{color:"common.white",bgcolor:"rgba(0, 0, 0, 0.25)","&:hover":{bgcolor:"rgba(0, 0, 0, 0.35)"}},children:t.jsx(Ur,{fontSize:"small"})}),t.jsx(s.IconButton,{size:"small","aria-label":c("avatar.delete"),onClick:o,disabled:!!d,sx:{color:"common.white",bgcolor:"rgba(0, 0, 0, 0.25)","&:hover":{bgcolor:"rgba(0, 0, 0, 0.35)"}},children:t.jsx(oa,{fontSize:"small"})})]})]})},Co=s.styled(s.Box)({display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",marginBottom:"20px",position:"relative"}),So=({imgUrl:e,displayName:a,onError:n,tags:r,onEditTags:o,onUploadPhoto:i,onPhotoFileChange:d,photoInputRef:c,isUploadingPhoto:u,onDeletePhoto:p,isDeletingPhoto:m,contactType:h,firstName:x,lastName:g,name:y,entityId:w,onEntityUpdated:b})=>{const C=`Avatar for ${a}`;return t.jsxs(Co,{children:[t.jsx("input",{ref:c,type:"file",accept:"image/*",onChange:d,style:{display:"none"}}),t.jsx(vo,{src:e,alt:C,onError:()=>n?.(new Error("Failed to load avatar")),onUpload:i,isUploading:u,onDelete:p,isDeleting:m}),t.jsx(bo,{displayName:a,contactType:h,firstName:x,lastName:g,name:y,entityId:w,onEntityUpdated:b}),t.jsx(fo,{tags:r,onEditTags:o})]})},Ea=20,jo=e=>{const{popperContainer:a,...n}=e;return t.jsx(Rr,{...n,container:a??n.container,style:{...n.style??{},zIndex:2e4}})},wo=({value:e,options:a,onChange:n,onBack:r,onSave:o,isSaving:i,onCreateNew:d,isCreatingNew:c,popperContainer:u})=>{const p=xe(),[m,h]=l.useState(""),[x,g]=l.useState(Ea),y=l.useDeferredValue(m),w=l.useMemo(()=>a??[],[a]),b=l.useMemo(()=>{const E=String(y??"").trim().toLowerCase();return E?w.filter(B=>String(B?.name??"").toLowerCase().includes(E)):w},[w,y]),C=l.useMemo(()=>b.slice(0,x),[b,x]),S=l.useMemo(()=>{const E=new Map;for(const B of e??[])B?.id&&E.set(String(B.id),B);for(const B of C??[])B?.id&&(E.has(String(B.id))||E.set(String(B.id),B));return Array.from(E.values())},[e,C]),j=(E,B)=>{h(B??""),g(Ea)},I=E=>{const B=E;B.scrollTop+B.clientHeight>=B.scrollHeight-24&&g(A=>A+Ea)},D=()=>{const E=String(m??"").trim(),B=!E||i||c;return t.jsxs(s.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p("global.noOptions"),t.jsx(at.LoadingButton,{onClick:()=>d(E),loading:c,disabled:B,variant:"contained",size:"small",sx:{marginTop:1.3},children:p("global.createNew")})]})};return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:2},children:[t.jsx(s.IconButton,{size:"small",onClick:r,"aria-label":p("global.back"),disabled:i,children:t.jsx(wa,{fontSize:"small"})}),t.jsx(s.Typography,{variant:"subtitle1",children:p("tags")}),t.jsx(s.Box,{sx:{flex:1}}),t.jsx(at.LoadingButton,{variant:"contained",size:"small",startIcon:t.jsx(ut,{}),onClick:o,loading:i,disabled:i,children:p("global.save")})]}),t.jsx(s.Autocomplete,{multiple:!0,disablePortal:!1,value:e,onChange:(E,B)=>n(B),options:S,filterOptions:E=>E,inputValue:m,onInputChange:j,getOptionLabel:E=>E?.name??"",isOptionEqualToValue:(E,B)=>String(E?.id)===String(B?.id),PopperComponent:E=>t.jsx(jo,{...E,popperContainer:u}),renderOption:(E,B)=>{const{key:A,...k}=E;return l.createElement("li",{...k,key:B?.id?String(B.id):String(A??B?.name??"")},B.name??"")},renderTags:(E,B)=>E.map((A,k)=>{const N=B({index:k}),{key:_,...V}=N;return t.jsx(s.Chip,{label:A.name??"",...V},A?.id?String(A.id):String(_??A?.name??k))}),size:"small",renderInput:E=>t.jsx(s.TextField,{...E,size:"small"}),ListboxProps:{onScroll:I,sx:{maxHeight:280,overflowY:"auto"}},noOptionsText:t.jsx(D,{}),sx:{width:"100%"}})]})};var To=Object.defineProperty,Io=(e,a,n)=>a in e?To(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,un=(e,a,n)=>Io(e,typeof a!="symbol"?a+"":a,n);let pn=class extends Error{constructor(a,n,r){super(a),un(this,"status"),un(this,"body"),this.name="ApiError",this.status=n,this.body=r}};async function Oe({url:e,method:a="GET",headers:n,body:r,signal:o}){const i=await globalThis.fetch(e,{method:a,headers:{...r?{"Content-Type":"application/json"}:{},...n??{}},body:r?JSON.stringify(r):void 0,signal:o}),d=(i.headers.get("content-type")||"").includes("application/json")?await i.json().catch(()=>null):await i.text().catch(()=>null);if(!i.ok){const c=typeof d=="object"&&d&&"message"in d?String(d.message):`Request failed with status ${i.status}`;throw new pn(c,i.status,d)}return d}async function ko({url:e,method:a="POST",headers:n,formData:r,signal:o}){const i=await globalThis.fetch(e,{method:a,headers:{...n??{}},body:r,signal:o}),d=(i.headers.get("content-type")||"").includes("application/json")?await i.json().catch(()=>null):await i.text().catch(()=>null);if(!i.ok){const c=typeof d=="object"&&d&&"message"in d?String(d.message):`Request failed with status ${i.status}`;throw new pn(c,i.status,d)}return d}function Te(e,a){const n=e.endsWith("/")?e.slice(0,-1):e,r=a.startsWith("/")?a:`/${a}`;return`${n}${r}`}function Pe(e,a){const n=encodeURIComponent(a);return{CONTACTS:Te(e,`/contacts/${n}`),MEDIA:Te(e,`/media/${n}`),SETTINGS:Te(e,`/settings/${n}`)}}async function Eo({baseUrl:e,spaceId:a,signal:n}){const r=Pe(e,a),o=Te(r.CONTACTS,"/labels");return Oe({url:o,signal:n})}async function fn({baseUrl:e,spaceId:a,name:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/labels");return Oe({url:i,method:"POST",body:{name:n},signal:r})}async function Do({baseUrl:e,spaceId:a,contactId:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,`/contacts/${encodeURIComponent(n)}`);return Oe({url:i,signal:r})}async function Ao({baseUrl:e,spaceId:a,businessId:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,`/business/${encodeURIComponent(n)}`);return Oe({url:i,signal:r})}async function Fo({baseUrl:e,spaceId:a,forType:n,signal:r}){const o=Pe(e,a),i=`${Te(o.CONTACTS,"/ContactFields")}?filter=custom&for=${encodeURIComponent(n)}`;return Oe({url:i,signal:r})}async function Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:o,signal:i}){const d=n==="business"?`/business/${encodeURIComponent(r)}`:`/contacts/${encodeURIComponent(r)}`,c=Pe(e,a),u=Te(c.CONTACTS,d);return Oe({url:u,method:"PUT",body:o,signal:i})}async function Bo({baseUrl:e,spaceId:a,pagination:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/Search");return Oe({url:i,method:"POST",body:n,signal:r})}async function $o({baseUrl:e,spaceId:a,business:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/business");return Oe({url:i,method:"POST",body:n,signal:r})}async function la({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/contactAddresses");return Oe({url:i,method:"DELETE",body:n,signal:r})}async function Mo({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/contactAddresses/check");return Oe({url:i,method:"POST",body:n,signal:r})}async function Po({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,"/contactAddresses/set");return Oe({url:i,method:"POST",body:n,signal:r})}async function Uo({baseUrl:e,spaceId:a,data:n,signal:r}){const o=Pe(e,a),i=Te(o.CONTACTS,`/contactAddresses/${encodeURIComponent(n.contactAddressId)}`);return Oe({url:i,method:"PUT",body:n,signal:r})}async function gn({baseUrl:e,spaceId:a,signal:n}){const r=Pe(e,a),o=Te(r.SETTINGS,"/user");return Oe({url:o,signal:n})}async function Ro({baseUrl:e,spaceId:a,signal:n}){const r=Pe(e,a),o=Te(r.SETTINGS,"/users");return Oe({url:o,signal:n})}async function No({baseUrl:e,spaceId:a,signal:n,userId:r}){const o=Pe(e,a),i=Te(o.SETTINGS,`/usersInfo/${r}`);return Oe({url:i,signal:n})}async function mn({baseUrl:e,spaceId:a,contactId:n,file:r,signal:o}){const i=Pe(e,a),d=new FormData;d.append("file",r,r.name);const c=Te(i.MEDIA,`/upload?module=contacts&folderType=avatars&contactId=${encodeURIComponent(n)}`);return ko({url:c,formData:d,signal:o})}const hn=(e,a)=>({fetchLabels:({signal:n}={})=>Eo({baseUrl:e,spaceId:a,signal:n}),createLabel:({name:n,signal:r})=>fn({baseUrl:e,spaceId:a,name:n,signal:r}),fetchContact:({contactId:n,signal:r})=>Do({baseUrl:e,spaceId:a,contactId:n,signal:r}),fetchBusiness:({businessId:n,signal:r})=>Ao({baseUrl:e,spaceId:a,businessId:n,signal:r}),fetchBusinessTableData:({pagination:n,signal:r})=>Bo({baseUrl:e,spaceId:a,pagination:n,signal:r}),createBusiness:({business:n,signal:r})=>$o({baseUrl:e,spaceId:a,business:n,signal:r}),fetchContactFields:({forType:n,signal:r})=>Fo({baseUrl:e,spaceId:a,forType:n,signal:r}),updateEntity:({entityType:n,entityId:r,body:o,signal:i})=>Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:o,signal:i}),deleteAddress:({data:n,signal:r})=>la({baseUrl:e,spaceId:a,data:n,signal:r}),deleteAddres:({data:n,signal:r})=>la({baseUrl:e,spaceId:a,data:n,signal:r}),checkContactAddress:({data:n,signal:r})=>Mo({baseUrl:e,spaceId:a,data:n,signal:r}),setContactAddress:({data:n,signal:r})=>Po({baseUrl:e,spaceId:a,data:n,signal:r}),updateContactAddress:({data:n,signal:r})=>Uo({baseUrl:e,spaceId:a,data:n,signal:r}),fetchUserTrii:({signal:n}={})=>gn({baseUrl:e,spaceId:a,signal:n}),fetchUsers:({signal:n}={})=>Ro({baseUrl:e,spaceId:a,signal:n}),fetchUserTriiById:({userId:n,signal:r})=>No({baseUrl:e,spaceId:a,userId:n,signal:r}),uploadAvatar:({contactId:n,file:r,signal:o})=>mn({baseUrl:e,spaceId:a,contactId:n,file:r,signal:o})}),yn=()=>!!window?.google?.maps?.places?.Autocomplete,Lo=(e=1e4)=>new Promise(a=>{if(yn()){a(!0);return}const n=Date.now(),r=window.setInterval(()=>{if(yn()){window.clearInterval(r),a(!0);return}Date.now()-n>e&&(window.clearInterval(r),a(!1))},100)}),Oo=()=>{const[e,a]=l.useState(!1),[n,r]=l.useState(!0),[o,i]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const d=await Lo(1e4);a(d),d||i("Google Maps API failed to load")}catch{i("Error loading Google Maps API"),a(!1)}finally{r(!1)}})()},[]),{isLoaded:e,isLoading:n,error:o}},zo=({onPlaceSelected:e,onError:a,placeholder:n})=>{const r=xe(),o=l.useRef(null),i=l.useRef(null),d=l.useRef(e),c=l.useRef(a),{isLoaded:u,isLoading:p,error:m}=Oo(),h=l.useMemo(()=>p?r("searchLocationModal.loadingGoogleMaps"):m?r("searchLocationModal.googleMapsUnavailable"):u?n??r("searchLocationModal.enterLocation"):r("searchLocationModal.googleMapsNotLoaded"),[u,p,m,n,r]);return l.useEffect(()=>{d.current=e},[e]),l.useEffect(()=>{c.current=a},[a]),l.useEffect(()=>{if(!u||!o.current||i.current)return;const x=window?.google;if(!x?.maps?.places?.Autocomplete){c.current?.(r("searchLocationModal.googleMapsUnavailable"));return}o.current.focus();let g=null;const y=()=>{document.querySelectorAll(".pac-container").forEach(b=>{const C=b;C.style.zIndex="20000",C.style.position="fixed"})};g=new MutationObserver(b=>{for(const C of b)for(const S of Array.from(C.addedNodes)){if(S.nodeType!==Node.ELEMENT_NODE)continue;const j=S;j.classList?.contains("pac-container")&&(j.style.zIndex="20000",j.style.position="fixed")}}),g.observe(document.body,{childList:!0,subtree:!0}),y(),window.setTimeout(y,100),i.current=new x.maps.places.Autocomplete(o.current,{types:["geocode"],componentRestrictions:{country:"ar"}});const w=i.current.addListener?.("place_changed",()=>{const b=i.current?.getPlace?.();if(!b?.geometry?.location){c.current?.(r("searchLocationModal.selectedPlaceNoLocation"));return}let C="",S="",j="",I="",D="",E="";const B=b.address_components??[];for(const _ of B){const V=_?.types??[];if(V.includes("locality")||V.includes("administrative_area_level_2")){C=_.long_name;continue}if(V.includes("administrative_area_level_1")){S=_.long_name;continue}if(V.includes("country")){j=_.long_name;continue}if(V.includes("postal_code")){I=_.long_name;continue}if(V.includes("route")){D=_.long_name;continue}V.includes("street_number")&&(E=_.long_name)}const A=typeof b.geometry.location.lat=="function"?b.geometry.location.lat():0,k=typeof b.geometry.location.lng=="function"?b.geometry.location.lng():0,N={location:{lat:A,lng:k},address:b.formatted_address??"",city:C,state:S,country:j,postalCode:I,streetName:D,streetNumber:E,shortAddress:[D,E].filter(Boolean).join(" ")};d.current(N)});return()=>{g&&g.disconnect(),w?.remove&&w.remove(),i.current=null}},[u,r]),t.jsx(s.TextField,{fullWidth:!0,size:"small",inputRef:o,placeholder:h,disabled:p||!u||!!m,error:!!m})},Wo={street:"",city:"",state:"",zipcode:"",country:""},_o=({baseUrl:e,spaceId:a,entityType:n,entityId:r,onBack:o,onEntityUpdated:i})=>{const d=xe(),[c,u]=l.useState(Wo),[p,m]=l.useState(""),[h,x]=l.useState(""),[g,y]=l.useState(!1),[w,b]=l.useState(!1),C=l.useMemo(()=>!!(String(c.street??"").trim()||String(c.city??"").trim()||String(c.state??"").trim()||String(c.zipcode??"").trim()||String(c.country??"").trim()),[c]),S=A=>{m(A.address??"");const k=String(A.shortAddress??"").trim()||[A.streetName,A.streetNumber].filter(Boolean).join(" ").trim();u({street:k,city:A.city??"",state:A.state??"",zipcode:A.postalCode??"",country:A.country??""}),x("")},j=A=>{x(String(A??""))},I=A=>k=>{const N=k.target.value;u(_=>({..._,[A]:N}))},D=async()=>{if(!g&&!(!e||!a)&&r){y(!0);try{const A=await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{address1:{street:String(c.street??""),city:String(c.city??""),state:String(c.state??""),zipcode:String(c.zipcode??""),country:String(c.country??"")}}});i?.(A),o()}finally{y(!1)}}},E=async()=>{if(!w&&!(!e||!a)&&r){b(!0);try{const A=await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{address2:{street:String(c.street??""),city:String(c.city??""),state:String(c.state??""),zipcode:String(c.zipcode??""),country:String(c.country??"")}}});i?.(A),o()}finally{b(!1)}}},B=!C||g||w;return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:3},children:[t.jsx(s.IconButton,{size:"small",onClick:o,"aria-label":d("global.back"),children:t.jsx(wa,{fontSize:"small"})}),t.jsx(s.Typography,{variant:"h6",children:d("searchLocationModal.searchAddress")})]}),t.jsxs(s.Stack,{spacing:3,children:[t.jsxs(s.Box,{sx:{position:"relative",zIndex:1400},children:[t.jsx(zo,{onPlaceSelected:S,onError:j,placeholder:d("searchLocationModal.enterLocation")}),h?t.jsx(s.Typography,{variant:"caption",color:"error",sx:{mt:.5,display:"block"},children:h}):null]}),t.jsx(s.TextField,{label:d("conversations.contactDetails.street"),value:c.street,onChange:I("street"),fullWidth:!0,size:"medium"}),t.jsxs(s.Stack,{direction:{xs:"column",sm:"row"},spacing:2,children:[t.jsx(s.TextField,{label:d("searchLocationModal.city"),value:c.city,onChange:I("city"),fullWidth:!0,size:"medium"}),t.jsx(s.TextField,{label:d("searchLocationModal.state"),value:c.state,onChange:I("state"),fullWidth:!0,size:"medium"})]}),t.jsxs(s.Stack,{direction:{xs:"column",sm:"row"},spacing:2,children:[t.jsx(s.TextField,{label:d("searchLocationModal.postalCode"),value:c.zipcode,onChange:I("zipcode"),fullWidth:!0,size:"medium"}),t.jsx(s.TextField,{label:d("searchLocationModal.country"),value:c.country,onChange:I("country"),fullWidth:!0,size:"medium"})]}),p?t.jsx(s.Typography,{variant:"caption",sx:{opacity:.7},children:p}):null,t.jsxs(s.Stack,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{pt:2},children:[t.jsx(at.LoadingButton,{variant:"contained",size:"large",startIcon:t.jsx(ut,{}),onClick:D,loading:g,disabled:B,children:d("searchLocationModal.saveMainAddress")}),t.jsx(at.LoadingButton,{variant:"outlined",size:"large",startIcon:t.jsx(ut,{}),onClick:E,loading:w,disabled:B,children:d("searchLocationModal.saveSecondaryAddress")})]})]})]})};function Da(e){return e?.isBusiness===!0?!0:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&Array.isArray(e.membersId)&&Array.isArray(e.members)&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&typeof e.imageUrl=="string"&&!("firstName"in e)&&!("lastName"in e)}function xn(e){return e?.isBusiness===!0?!1:e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.spaceId=="string"&&typeof e.name=="string"&&typeof e.firstName=="string"&&typeof e.lastName=="string"&&Array.isArray(e.phones)&&Array.isArray(e.emails)&&"origin"in e&&typeof e.isSpam=="boolean"&&(!e.businessId||typeof e.businessId=="string")}function Vo({open:e,baseUrl:a,spaceId:n,contactId:r,contactNameFormat:o}){const i=l.useRef(null),d=l.useMemo(()=>!a||!n?null:hn(a,n),[a,n]),[c,u]=l.useState({isLoading:!1,error:null,contactData:null,labels:[],labelsLoading:!1,labelsError:null,contactFields:[],contactFieldsLoading:!1,contactFieldsError:null,userTrii:null,userLoading:!1,userError:null}),p=l.useMemo(()=>!!(e&&d&&r),[e,d,r]);l.useEffect(()=>{e||(i.current?.abort(),u({isLoading:!1,error:null,contactData:null,labels:[],labelsLoading:!1,labelsError:null,contactFields:[],contactFieldsLoading:!1,contactFieldsError:null,userTrii:null,userLoading:!1,userError:null}))},[e]);const m=l.useMemo(()=>!!(e&&d),[e,d]);l.useEffect(()=>{if(!m||!d)return;const g=new AbortController;return u(y=>({...y,labelsLoading:!0,labelsError:null})),d.fetchLabels({signal:g.signal}).then(y=>{u(w=>({...w,labels:y,labelsLoading:!1,labelsError:null}))}).catch(y=>{g.signal.aborted||u(w=>({...w,labelsLoading:!1,labelsError:y}))}),()=>{g.abort()}},[d,m]),l.useEffect(()=>{if(!p||!d)return;i.current?.abort();const g=new AbortController;return i.current=g,u(y=>({...y,isLoading:!0,error:null,contactData:null})),d.fetchContact({contactId:r,signal:g.signal}).then(y=>{u(w=>({...w,isLoading:!1,error:null,contactData:y}))}).catch(y=>{g.signal.aborted||u(w=>({...w,isLoading:!1,error:y}))}),()=>{g.abort()}},[d,p,r]);const h=l.useMemo(()=>!!(e&&d),[e,d]);l.useEffect(()=>{if(!h||!d)return;const g=new AbortController;return u(y=>({...y,userLoading:!0,userError:null})),d.fetchUserTrii({signal:g.signal}).then(y=>{u(w=>({...w,userLoading:!1,userError:null,userTrii:y}))}).catch(y=>{g.signal.aborted||u(w=>({...w,userLoading:!1,userError:y}))}),()=>{g.abort()}},[d,h]);const x=l.useMemo(()=>{const g=c.contactData,y=Da(g),w=xn(g);let b="unknown";y&&(b="business"),w&&(b="contact");let C="Unknown Contact";y?C=g.name:w&&(C=sn(g.firstName,g.lastName,o));const S=g?.tags??[];return{isBusiness:y,isContact:w,contactType:b,displayName:C,tags:S,labels:c.labels,contactFields:c.contactFields,userTrii:c.userTrii,userLoading:c.userLoading,userError:c.userError}},[c.contactData,c.labels,c.contactFields,c.userTrii,c.userLoading,c.userError,o]);return l.useEffect(()=>{if(!e||!d)return;const g=c.contactData,y=Da(g),w=xn(g),b=y?"business":w?"contact":null;if(!b)return;const C=new AbortController;return u(S=>({...S,contactFieldsLoading:!0,contactFieldsError:null})),d.fetchContactFields({forType:b,signal:C.signal}).then(S=>{u(j=>({...j,contactFields:S,contactFieldsLoading:!1,contactFieldsError:null}))}).catch(S=>{C.signal.aborted||u(j=>({...j,contactFieldsLoading:!1,contactFieldsError:S}))}),()=>{C.abort()}},[d,e,c.contactData]),{state:c,selectors:x,actions:{setContactData:g=>u(y=>({...y,contactData:g??null})),clearError:()=>u(g=>({...g,error:null}))}}}const Ot=({baseUrl:e,spaceId:a,entityType:n,entityId:r,initialImageUrl:o,onEntityUpdated:i})=>{const[d,c]=l.useState(o??""),[u,p]=l.useState(null),[m,h]=l.useState(!1),[x,g]=l.useState(!1),y=l.useRef(null),w=l.useMemo(()=>!!(e&&a&&n&&r),[e,a,n,r]);function b(k){return k.split("?sv=")[0]}function C(k){return k.split("&cacheId=")[0]}function S(k){let N=b(k);return!N||(N=C(N),!N)?"":N}const j=async()=>{if(!e||!a)return null;const k=await gn({baseUrl:e,spaceId:a});return p(k),k},I=async k=>{const N=(u??await j())?.storageAzureSAS,_=N?.expireAt,V=_?new Date(_):null;let G=N?.sas??"";if((!G||V&&V<new Date)&&(G=(await j())?.storageAzureSAS?.sas??""),!G)return k;const $=`${Date.now()}`;return`${k}${G}&cacheId=${$}`},D=async k=>{if(!k){c("");return}const N=b(k);if(!N)return;const _=await I(N);c(_)},E=async k=>{const N=k.target.files?.[0];if(N&&w){y.current&&(y.current.value=""),h(!0);try{const _=await mn({baseUrl:e,spaceId:a,contactId:r,file:N}),V=await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{imageUrl:_}});i?.(V),await D(_)}finally{h(!1)}}},B=()=>{y.current?.click()},A=async()=>{if(w&&!x){g(!0);try{await Xe({baseUrl:e,spaceId:a,entityType:n,entityId:r,body:{imageUrl:""}}),i?.({imageUrl:""}),c("")}finally{g(!1)}}};return l.useEffect(()=>{if(!o){c("");return}D(o)},[o]),{inputAtributes:{onChange:E,ref:y,type:"file",accept:"image/*"},action:{uploadImage:B,deleteImage:A},imageUrl:d,removeParams:S,isUploading:m,isDeleting:x}},be=(e,a)=>{const[n,r]=l.useState(a||""),[o,i]=l.useState(!1),[d,c]=l.useState("");return l.useEffect(()=>{r(a||"")},[a]),{actions:{onError:u=>{i(!0),c(u)},onSuccess:()=>{i(!1),c("")},resetValue:()=>{r(a||"")},changeValue:u=>{r(u)}},attributes:{error:o,helperText:d,type:e,value:n,onChange:u=>{r(u.target.value)}}}},bn=(e="")=>{const[a,n]=l.useState(e),r=d=>{n(d.target.value)},o=d=>{n(d)},i=()=>{n(e??"")};return l.useEffect(()=>{n(e)},[e]),{actions:{resetValue:i,changeValue:o},attributes:{value:a,onChange:r}}};let da;const Ho=new Uint8Array(16);function Go(){if(!da&&(da=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!da))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return da(Ho)}const Fe=[];for(let e=0;e<256;++e)Fe.push((e+256).toString(16).slice(1));function Yo(e,a=0){return Fe[e[a+0]]+Fe[e[a+1]]+Fe[e[a+2]]+Fe[e[a+3]]+"-"+Fe[e[a+4]]+Fe[e[a+5]]+"-"+Fe[e[a+6]]+Fe[e[a+7]]+"-"+Fe[e[a+8]]+Fe[e[a+9]]+"-"+Fe[e[a+10]]+Fe[e[a+11]]+Fe[e[a+12]]+Fe[e[a+13]]+Fe[e[a+14]]+Fe[e[a+15]]}const qo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var vn={randomUUID:qo};function zt(e,a,n){if(vn.randomUUID&&!a&&!e)return vn.randomUUID();e=e||{};const r=e.random||(e.rng||Go)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,a){n=n||0;for(let o=0;o<16;++o)a[n+o]=r[o];return a}return Yo(r)}function Ko(e){return{id:zt(),address:"",note:"",channelType:e,isSaved:!1}}var ca={createNewAddress:Ko};const Jo=(e,a,n)=>{if(a!==n&&!(a===null&&n==="")){const r={};return r[e]=n,r}return null},Qo=(e,a,n)=>n.map(r=>r.id===a?{...r,address:e}:r);var vt={getEditedField:Jo,getAddressesWithUpdatedValues:Qo};const Cn=({entityId:e,initial:a,dispatch:n,deleteAddress:r})=>{const[o,i]=l.useState(!1),[d,c]=l.useState(()=>a),[u,p]=l.useState(a?.ims_facebook||[]),[m,h]=l.useState(a?.ims_mercadolibre||[]),[x,g]=l.useState(a?.ims_webchat||[]),[y,w]=l.useState(a?.ims_instagram||[]),[b,C]=l.useState(a?.ims_whatsapp||[]),[S,j]=l.useState(a?.emails||[]),[I,D]=l.useState(a?.phones||[]),[E,B]=l.useState(a?.ims_rcs||[]),A=()=>{const T=ca.createNewAddress(bt.ChannelType.PHONE),M=[...I,T];D(M)},k=()=>{const T=ca.createNewAddress(bt.ChannelType.EMAIL),M=[...S,T];j(M)},N=()=>{const T=ca.createNewAddress(bt.ChannelType.WHATSAPP),M=[...b,T];C(M)},_=()=>{const T=ca.createNewAddress(bt.ChannelType.RCS),M=[...E,T];B(M)},V=T=>{const M=[...b,T];C(M),c(O=>({...O??{},ims_whatsapp:M}))},G=(T,M)=>{if(M){if(M.channelType===3){const O=S.map(R=>R.id===T?M:R);j(O),c(R=>({...R??{},emails:O}))}if(M.channelType===5){const O=I.map(R=>R.id===T?M:R);D(O),c(R=>({...R??{},phones:O}))}if(M.channelType===13){const O=b.map(R=>R.id===T?M:R);C(O),c(R=>({...R??{},ims_whatsapp:O}))}if(M.channelType===21){const O=E.map(R=>R.id===T?M:R);B(O),c(R=>({...R??{},ims_rcs:O}))}if(M.channelType===41){const O=m.map(R=>R.id===T?M:R);h(O),c(R=>({...R??{},ims_mercadolibre:O}))}}},$=async(T,M,O)=>{const R=T.target.value;if(O===3){const H=vt.getAddressesWithUpdatedValues(R,M,S);j(H)}else if(O===5){const H=vt.getAddressesWithUpdatedValues(R,M,I);D(H)}else if(O===13){const H=vt.getAddressesWithUpdatedValues(R,M,b);C(H)}else if(O===21){const H=vt.getAddressesWithUpdatedValues(R,M,E);B(H)}else if(O===41){const H=vt.getAddressesWithUpdatedValues(R,M,m);h(H)}},Q=(T,M,O)=>{if(O===14){const R=u.map(H=>H.id===M?{...H,note:T.target.value}:H);p(R)}if(O===20){const R=x.map(H=>H.id===M?{...H,note:T.target.value}:H);g(R)}if(O===16){const R=y.map(H=>H.id===M?{...H,note:T.target.value}:H);w(R)}if(O===3){const R=S.map(H=>H.id===M?{...H,note:T.target.value}:H);j(R)}if(O===5){const R=I.map(H=>H.id===M?{...H,note:T.target.value}:H);D(R)}if(O===13){const R=b.map(H=>H.id===M?{...H,note:T.target.value}:H);C(R)}if(O===21){const R=E.map(H=>H.id===M?{...H,note:T.target.value}:H);B(R)}if(O===41){const R=m.map(H=>H.id===M?{...H,note:T.target.value}:H);h(R)}},X=async(T,M)=>{if(e&&(M===3||M===5||M===13||M===14||M===20||M===16||M===21||M===41)){i(T);const O={contactId:e,contactAddressId:T,type:M};switch(n?await n(r(O)):await r(O),i(!1),M){case 3:const R=S.filter(Z=>Z.id!==T);j(R),c(Z=>({...Z??{},emails:R}));break;case 5:const H=I.filter(Z=>Z.id!==T);D(H),c(Z=>({...Z??{},phones:H}));break;case 13:const W=b.filter(Z=>Z.id!==T);C(W),c(Z=>({...Z??{},ims_whatsapp:W}));break;case 21:const ae=E.filter(Z=>Z.id!==T);B(ae),c(Z=>({...Z??{},ims_rcs:ae}));break;case 41:const de=m.filter(Z=>Z.id!==T);h(de),c(Z=>({...Z??{},ims_mercadolibre:de}));break;case 14:const ie=u.filter(Z=>Z.id!==T);p(ie),c(Z=>({...Z??{},ims_facebook:ie}));break;case 20:const Se=x.filter(Z=>Z.id!==T);g(Se),c(Z=>({...Z??{},ims_webchat:Se}));break;case 16:const ve=y.filter(Z=>Z.id!==T);w(ve),c(Z=>({...Z??{},ims_instagram:ve}));break}}};function U(){p(d?.ims_facebook||[]),h(d?.ims_mercadolibre||[]),g(d?.ims_webchat||[]),w(d?.ims_instagram||[]),C(d?.ims_whatsapp||[]),B(d?.ims_rcs||[]),j(d?.emails||[]),D(d?.phones||[])}return l.useEffect(()=>{c(a),a?.emails&&a?.phones&&(j(a.emails),D(a.phones)),C(a?.ims_whatsapp||[]),B(a?.ims_rcs||[]),p(a?.ims_facebook||[]),g(a?.ims_webchat||[]),w(a?.ims_instagram||[]),h(a?.ims_mercadolibre||[])},[a]),{field:{imsWhatsapp:b,imsRCS:E,imsMercadolibre:m,imsFacebooks:u,imsWebchats:x,imsInstagrams:y,emails:S,phoneNumbers:I},action:{handleAddressFieldChange:$,handleNoteFieldChange:Q,handleDeleteAddress:X,addPhone:A,addEmail:k,addWhatsapp:N,addRCS:_,replaceAddress:G,addWhatsappVerified:V,resetToInitialContactInformation:U},state:{isDeletingAddress:o}}},Sn=({initialState:e=[]}={})=>{const[a,n]=l.useState(e);return{attributes:{value:a,onChange:(r,o)=>{const i=o.some(d=>!a.some(c=>d.id===c.id));(a.filter(d=>!o.some(c=>c.id===d.id)).length>0||i)&&n(o)}},actions:{addValue:r=>{n(o=>o.concat(r))},setValue:r=>{n(r)}}}},Xo=({business:e,customContactFields:a,baseUrl:n,spaceId:r})=>{const o=l.useMemo(()=>async ce=>{!n||!r||await la({baseUrl:n,spaceId:r,data:ce})},[n,r]),i=async ce=>ce,[d,c]=l.useState([]),u=be("text",e?.name||""),p=Ot({baseUrl:n,spaceId:r,entityType:"business",entityId:e?.id,initialImageUrl:e?.imageUrl||""}),m=bn(e?.owner),h=Sn({initialState:e?.tags??[]}),[x,g]=l.useState([]),{field:{imsFacebooks:y,imsMercadolibre:w,imsWebchats:b,imsInstagrams:C,imsWhatsapp:S,emails:j,phoneNumbers:I,imsRCS:D},action:{addPhone:E,addEmail:B,addWhatsapp:A,addRCS:k,addWhatsappVerified:N,replaceAddress:_,handleAddressFieldChange:V,handleNoteFieldChange:G,handleDeleteAddress:$,resetToInitialContactInformation:Q},state:{isDeletingAddress:X}}=Cn({entityId:e?.id,initial:e,dispatch:i,deleteAddress:o}),U=be("text",e?.address1?.street||""),T=be("text",e?.address2?.street||""),M=be("text",e?.address1?.city||""),O=be("text",e?.address2?.city||""),R=be("text",e?.address1?.state||""),H=be("text",e?.address2?.state||""),W=be("text",e?.address1?.zipcode||""),ae=be("text",e?.address2?.zipcode||""),de=be("text",e?.address1?.country||""),ie=be("text",e?.address2?.country||""),Se=(ce,Y,pe)=>Y!==pe&&!(Y===null&&pe==="")?{[ce]:pe}:{},ve=()=>{if(!e)return null;const ce={street:U.attributes.value,city:M.attributes.value,state:R.attributes.value,zipcode:W.attributes.value,country:de.attributes.value},Y={street:T.attributes.value,city:O.attributes.value,state:H.attributes.value,zipcode:ae.attributes.value,country:ie.attributes.value};return{id:e.id,...Se("owner",e.owner,m.attributes.value),...Se("name",e.name,u.attributes.value),imageUrl:p.imageUrl?p.removeParams(p.imageUrl):null,tags:h.attributes.value,properties:d,members:x,phoneNumbers:I,emails:j,address1:ce,address2:Y}};function Z(ce){if(!e)return;const Y=J=>J.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),pe=e.properties.find(J=>J.nameKey===ce)??e.properties.find(J=>Y(J.nameKey)===Y(ce));if(!pe){console.error(`No se encontr\xF3 una propiedad con nameKey: ${ce}`);return}const Ze=d.map(J=>J.nameKey===ce?{...J,value:pe.value}:J);c(Ze)}const Ue=()=>e?a.map(ce=>{const Y=J=>J.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),pe=e.properties.find(J=>J.nameKey===ce.nameKey)??e.properties.find(J=>Y(J.nameKey)===Y(ce.nameKey));if(pe)return{...pe,nameKey:ce.nameKey,type:pe.type??ce.type,value:pe.value};const Ze=d.find(J=>J.nameKey===ce.nameKey);return{nameKey:ce.nameKey,type:ce.type,value:Ze?Ze.value:""}}):[];return l.useEffect(()=>{e&&a&&c(Ue())},[e,a]),l.useEffect(()=>{e&&h.actions.setValue(e.tags??[])},[e]),{field:{name:u,imsWhatsapp:S,imsRCS:D,contactImage:p,contactPropietary:m,imsMercadolibre:w,imsFacebooks:y,imsWebchats:b,imsInstagrams:C,emails:j,phoneNumbers:I,homeAddress:U,secondaryHomeAddress:T,city:M,secondaryCity:O,state:R,secondaryState:H,postalCode:W,secondaryPostalCode:ae,country:de,secondaryCountry:ie,customProperties:d,labelMultipleSelect:h},action:{setCustomProperties:c,addWhatsapp:A,addRCS:k,getEditedBusiness:ve,handleAddressFieldChange:V,handleNoteFieldChange:G,handleDeleteAddress:$,addPhone:E,addEmail:B,replaceAddress:_,addWhatsappVerified:N,resetToInitialContactInformation:Q,resetCustomProperty:Z},state:{isDeletingAddress:X},selectedContacts:x,setSelectedContacts:g}},Zo=({contact:e,customContactFields:a,baseUrl:n,spaceId:r})=>{const o=l.useMemo(()=>async J=>{!n||!r||await la({baseUrl:n,spaceId:r,data:J})},[n,r]),i=async J=>J,{getEditedField:d}=vt,[c,u]=l.useState([]),p=be("text",e?.firstName||""),m=be("text",e?.lastName||""),h=Ot({baseUrl:n,spaceId:r,entityType:"contact",entityId:e?.id?String(e.id):void 0,initialImageUrl:e?.imageUrl}),[x,g]=l.useState(e?.birthDate?K(e.birthDate):null),y=Cn({entityId:e?.id,initial:e,dispatch:i,deleteAddress:o}),{field:{imsFacebooks:w,imsMercadolibre:b,imsWebchats:C,imsInstagrams:S,imsWhatsapp:j,emails:I,phoneNumbers:D,imsRCS:E},action:{addPhone:B,addEmail:A,addWhatsapp:k,addRCS:N,addWhatsappVerified:_,replaceAddress:V,handleAddressFieldChange:G,handleNoteFieldChange:$,handleDeleteAddress:Q,resetToInitialContactInformation:X},state:{isDeletingAddress:U}}=y,T=Sn({initialState:e?.tags}),M=bn(e?.owner),O=be("text",e?.address1?.street),R=be("text",e?.address2?.street),H=be("text",e?.address1?.city),W=be("text",e?.address2?.city),ae=be("text",e?.address1?.state),de=be("text",e?.address2?.state),ie=be("text",e?.address1?.zipcode),Se=be("text",e?.address2?.zipcode),ve=be("text",e?.address1?.country),Z=be("text",e?.address2?.country),Ue=()=>{if(!e)return null;const J=e,$e=T.attributes.value.map(ue=>({id:ue.id,name:ue.name})),We=D.map(ue=>{const{id:Jt,...rt}=ue;return rt}),Ge=I.map(ue=>{const{id:Jt,...rt}=ue;return rt});return{id:J.id,owner:M.attributes.value,firstName:p.attributes.value,lastName:m.attributes.value,address1:{...d("street",J.address1?.street,O.attributes.value),...d("city",J.address1?.street,H.attributes.value),...d("state",J.address1?.street,ae.attributes.value),...d("zipcode",J.address1?.street,ie.attributes.value),...d("country",J.address1?.street,ve.attributes.value)},address2:{...d("street",J.address2?.street,R.attributes.value),...d("city",J.address2?.street,W.attributes.value),...d("state",J.address2?.street,de.attributes.value),...d("zipcode",J.address2?.street,Se.attributes.value),...d("country",J.address2?.street,Z.attributes.value)},emails:Ge,phones:We,tags:$e,imageUrl:h.imageUrl?h.removeParams(h.imageUrl):null,properties:c,birthDate:x?.toDate()}};function ce(){e&&(!e.businessId||e.businessName)}function Y(){g(e?.birthDate?K(e.birthDate):null)}function pe(J){if(!e)return;const $e=ue=>ue.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),We=e.properties.find(ue=>ue.nameKey===J)??e.properties.find(ue=>$e(ue.nameKey)===$e(J));if(!We){console.error(`No se encontr\xF3 una propiedad con nameKey: ${J}`);return}const Ge=c.map(ue=>ue.nameKey===J?{...ue,value:We.value}:ue);u(Ge)}const Ze=()=>e?a.map(J=>{const $e=ue=>ue.trim().toLowerCase().replace(/\s+/g,"-").replace(/-+/g,"-"),We=e.properties.find(ue=>ue.nameKey===J.nameKey)??e.properties.find(ue=>$e(ue.nameKey)===$e(J.nameKey));if(We)return{...We,nameKey:J.nameKey,type:We.type??J.type,value:We.value};const Ge=c.find(ue=>ue.nameKey===J.nameKey);return{nameKey:J.nameKey,type:J.type,value:Ge?Ge.value:""}}):[];return l.useEffect(()=>{e&&a&&u(Ze())},[e,a]),l.useEffect(()=>{e?.tags&&T.actions.setValue(e.tags),e?.businessId&&e.businessName},[e]),{field:{birthDate:x,imsWhatsapp:j,imsRCS:E,contactFirstname:p,contactLastname:m,contactImage:h,contactPropietary:M,imsMercadolibre:b,imsFacebooks:w,imsWebchats:C,imsInstagrams:S,emails:I,phoneNumbers:D,homeAddress:O,secondaryHomeAddress:R,city:H,secondaryCity:W,state:ae,secondaryState:de,postalCode:ie,secondaryPostalCode:Se,country:ve,secondaryCountry:Z,customProperties:c,labelMultipleSelect:T},action:{setBirthDate:g,setCustomProperties:u,getEditedContact:Ue,handleAddressFieldChange:G,handleNoteFieldChange:$,handleDeleteAddress:Q,addPhone:B,addEmail:A,addWhatsapp:k,addRCS:N,replaceAddress:V,addWhatsappVerified:_,resetToInitialContactInformation:X,resetSelectedBusiness:ce,resetBirthDate:Y,resetCustomProperty:pe},state:{isDeletingAddress:U}}},Aa=l.createContext(null),ei=({children:e,contact:a,customContactFields:n,baseUrl:r,spaceId:o})=>{const i=Zo({contact:a,customContactFields:n,baseUrl:r,spaceId:o});return t.jsx(Aa.Provider,{value:{entityType:"contact",editEntity:i,entityId:String(a.id)},children:e})},ti=({children:e,business:a,customContactFields:n,baseUrl:r,spaceId:o})=>{const i=Xo({business:a,customContactFields:n,baseUrl:r,spaceId:o});return t.jsx(Aa.Provider,{value:{entityType:"business",editEntity:i,entityId:String(a.id)},children:e})},ai=({children:e,entityType:a,entityData:n,customContactFields:r,baseUrl:o,spaceId:i})=>a==="contact"?t.jsx(ei,{contact:n,customContactFields:r,baseUrl:o,spaceId:i,children:e}):t.jsx(ti,{business:n,customContactFields:r,baseUrl:o,spaceId:i,children:e}),nt=()=>{const e=l.useContext(Aa);if(!e)throw new Error("useEditEntity must be used within EditEntityProvider");return e},Ct=({userId:e,users:a,currentUser:n})=>{if(!e)return null;if(n?.uid&&n.uid===e)return n.display_name||n.email||null;const r=a.find(o=>o?.id===e);return r?.name?.trim()||r?.email||null},ua=({title:e,children:a,enableDirectionSearch:n=!1,onDirectionSearchClick:r})=>{const o=xe();return t.jsxs(s.Box,{sx:{border:"1px solid",borderColor:"divider",borderRadius:2,p:2,mb:2},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[t.jsx(s.Typography,{variant:"subtitle1",children:e}),n&&t.jsx(s.Button,{startIcon:t.jsx(Nr,{sx:{color:"primary.main",height:18,width:18}}),size:"small",variant:"outlined",color:"primary",onClick:()=>r&&r(),children:o("global.searchLocation")})]}),t.jsx(s.Divider,{sx:{my:1.5}}),a]})},jn=({children:e,...a})=>t.jsx(s.Box,{display:"grid",gridTemplateColumns:{xs:"1fr",md:"repeat(2, minmax(0, 1fr))"},gap:2,...a,children:e}),ni=({birthDate:e,setBirthDate:a,dateFormat:n})=>{const r=(n||"YYYY/MM/DD").toUpperCase();return t.jsx(Pt.LocalizationProvider,{dateAdapter:Mt.AdapterDayjs,children:t.jsx(Ut,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Ya.DatePicker,{value:e,onChange:o=>a(o),slotProps:{textField:{size:"small"}},format:r})})})},ri={view:"main",setView:()=>{}},wn=l.createContext(null),si=wn.Provider,oi=()=>l.useContext(wn)||(console.warn("[useEditContactView] using noop, context value is missing"),ri),Tn=()=>{},In=l.createContext(Tn),ii=({navigate:e,children:a})=>t.jsx(In.Provider,{value:e,children:a}),li=()=>l.useContext(In)||(console.warn("[useNavigateContext] using noop, context value is falsy"),Tn);function di({value:e,displayValue:a,businessId:n}){const r=ot(),o=li(),[i,d]=l.useState(null),c=Ot({initialImageUrl:i?.imageUrl,entityType:"business",entityId:n}),[u,p]=l.useState(null),[m,h]=l.useState(!1);return t.jsxs(s.Box,{display:"flex",alignItems:"center",children:[t.jsx(s.Typography,{onClick:async x=>{const g=x.currentTarget;if(h(!0),!r){console.error("API is null");return}const y=await r.fetchBusiness({businessId:n});if(y&&Da(y)&&d(y),h(!1),!g){console.error("Target element is null");return}p(g)},variant:"body2",fontWeight:"600",sx:{padding:1,cursor:"pointer"},color:x=>x.palette.text.primary,children:a||typeof e=="string"&&e||"-"}),i&&t.jsx(on,{contactData:i,open:!!u,anchorEl:u,onClose:()=>p(null),navigate:o,avatarImgUrl:c.imageUrl}),m&&t.jsx(s.Box,{display:"flex",alignItems:"center",justifyContent:"center",p:1,children:t.jsx(s.CircularProgress,{size:20})})]})}const ci=e=>"email"in e,Fa=e=>e.entityType==="contact"&&e.inputType==="birthday",ui=s.styled(s.IconButton)({opacity:0,transition:"opacity 0.3s ease-in-out","& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"},marginLeft:"15px"}),kn=s.styled(s.IconButton)({"& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"}}),it=e=>{const{title:a,value:n,isNotEditable:r,displayValue:o,baseUrl:i,spaceId:d,minWidth:c,onEntityUpdated:u}=e,p=xe(),{setView:m}=oi(),h=e.inputType??"text",[x,g]=l.useState(!1),[y,w]=l.useState(!1),b=l.useRef(null),[C,S]=l.useState(!1),[j,I]=l.useState(()=>e.entityType==="business"||typeof n=="string"?n:void 0);l.useEffect(()=>{const $=b.current;if(!$)return;const Q=()=>{const X=$.scrollWidth>$.clientWidth;S(U=>U===X?U:X)};if(Q(),typeof ResizeObserver<"u"){let X=0;const U=new ResizeObserver(()=>{if(typeof window>"u"){Q();return}X&&window.cancelAnimationFrame(X),X=window.requestAnimationFrame(()=>{Q()})});return U.observe($),()=>{typeof window<"u"&&X&&window.cancelAnimationFrame(X),U.disconnect()}}if(!(typeof window>"u"))return window.addEventListener("resize",Q),()=>{window.removeEventListener("resize",Q)}},[a]),l.useEffect(()=>{e.entityType==="business"?I(n):I(typeof n=="string"?n:void 0)},[n,e.entityType]);const D=()=>{if(e.entityType==="contact"&&h==="selectBusiness"){m("businessSelect");return}g($=>!$)},E=$=>{I($.target.value)},B=$=>{const Q=$.target.value;I(Q)},A=()=>{Fa(e)&&e.contact.action.resetBirthDate(),g(!1)},k=async()=>{if(!e.constructUpdateObject){g(!1);return}if(e.entityType==="business"&&j===void 0){g(!1);return}w(!0);try{if(!i||!d)throw new Error("Missing baseUrl or spaceId for updateEntity");if(e.entityType==="contact"){let $=j===void 0?null:j;if(Fa(e)){const T=K(e.contact.field.birthDate);T.isValid()&&($=T.toISOString())}const Q=e.constructUpdateObject($),X=e.entityId??Q?.id;if(!X)throw new Error("Missing contactId for updateEntity");const U=await Xe({baseUrl:i,spaceId:d,entityType:"contact",entityId:X,body:Q});u?.(U)}else{const $=e.constructUpdateObject(j),Q=e.entityId??$?.id;if(!Q)throw new Error("Missing businessId for updateEntity");const X=await Xe({baseUrl:i,spaceId:d,entityType:"business",entityId:Q,body:$});u?.(X)}}finally{w(!1),g(!1)}},N=typeof j=="string"?j:"",_=j instanceof Date?j.toISOString():typeof j=="string"?j:"",V=c??(e.entityType==="contact"?"45%":"200px"),G=e.options??[];return t.jsxs(s.Box,{className:"fadein col-5",sx:{display:"flex",backgroundColor:$=>$.palette.mode==="dark"?"1e1e1e":$.palette.background.default,flexDirection:"column",borderRadius:1,minWidth:V,"&:hover .edit-icon":{opacity:1}},children:[t.jsxs(s.Box,{display:"flex",position:"relative",minHeight:"25px",children:[C?t.jsx(s.Tooltip,{title:a,arrow:!0,children:t.jsx(s.Typography,{ref:b,component:"span",variant:"body2",letterSpacing:-.5,fontWeight:"600",alignSelf:"center",flexGrow:x?1:0,color:$=>$.palette.text.primary,noWrap:!0,sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a})}):t.jsx(s.Typography,{ref:b,component:"span",variant:"body2",letterSpacing:-.5,fontWeight:"600",alignSelf:"center",flexGrow:x?1:0,color:$=>$.palette.text.primary,noWrap:!0,sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),r?null:x?t.jsxs(t.Fragment,{children:[t.jsx(kn,{size:"small",onClick:k,children:y?t.jsx(s.CircularProgress,{size:24}):t.jsx(ut,{})}),t.jsx(kn,{size:"small",onClick:A,children:t.jsx(qa,{})})]}):t.jsx(ui,{className:"edit-icon",size:"small",onClick:D,children:t.jsx($t,{})})]}),t.jsx(s.Box,{width:x?"100%":"50%",position:"relative",children:x&&h==="text"?t.jsx(s.TextField,{value:_,onChange:E,variant:"standard",size:"small",sx:{width:"100%"}}):x&&(h==="select"||h==="selectMembers")?t.jsxs(s.Select,{value:N,onChange:B,variant:"standard",size:"small",sx:{width:"100%"},children:[e.entityType==="contact"?t.jsx(s.MenuItem,{value:"",children:p("conversations.contactDetails.contactInfo.emptySelection")}):null,G.map(($,Q)=>t.jsx(s.MenuItem,{value:$.id,children:e.entityType==="contact"?$.name?.trim()||(ci($)?$.email:"")||"Sin nombre":$.name?.trim()||$.email||"Sin nombre"},Q))]}):x&&Fa(e)?t.jsx(ni,{birthDate:e.contact.field.birthDate,setBirthDate:e.contact.action.setBirthDate,dateFormat:e.dateFormat}):!x&&e.entityType==="contact"&&h==="selectBusiness"&&e.businessId?t.jsx(di,{value:String(n??""),displayValue:String(o??""),businessId:e.businessId}):t.jsx(s.Typography,{variant:"body2",fontWeight:"400",sx:{padding:"2.5px 14px 8.5px 0px"},color:$=>$.palette.text.primary,children:o||typeof n=="string"&&n||"-"})})]})},Wt=e=>{const{title:a,value:n,isNotEditable:r,options:o=[],displayValue:i,constructUpdateObject:d,businessId:c,baseUrl:u,spaceId:p,contactId:m,onEntityUpdated:h}=e;if(e.inputType==="birthday")return t.jsx(it,{entityType:"contact",entityId:m,title:a,value:n,isNotEditable:r,inputType:"birthday",options:o,displayValue:i,constructUpdateObject:d,contact:e.contact,businessId:c,baseUrl:u,spaceId:p,dateFormat:e.dateFormat,onEntityUpdated:h});const x=e.inputType??"text";return t.jsx(it,{entityType:"contact",entityId:m,title:a,value:n,isNotEditable:r,inputType:x,options:o,displayValue:i,constructUpdateObject:d,businessId:c,baseUrl:u,spaceId:p,onEntityUpdated:h})},pi=({nameKey:e,value:a,onChange:n,type:r})=>{const o=u=>{r===ne.ContactField_type.NUMBER_ACCOUNTING||r===ne.ContactField_type.NUMBER_DECIMAL||r===ne.ContactField_type.NUMBER_CURRENCY||r===ne.ContactField_type.CURRENCY?d(u):r===ne.ContactField_type.NUMBER_INTEGER?c(u):(r===ne.ContactField_type.LONGTEXT||r===ne.ContactField_type.TEXT||r===ne.ContactField_type.ADDRESS)&&i(u)},i=u=>{n(e,u.target.value)},d=u=>{const p=u.target.value.replace(/[^0-9.]/g,"");n(e,p)},c=u=>{const p=u.target.value;/^\d*$/.test(p)&&n(e,p)};return t.jsx(s.TextField,{size:"small",variant:"standard",value:a,onChange:o,inputProps:{pattern:"[0-9]*"},multiline:r===ne.ContactField_type.LONGTEXT,rows:r===ne.ContactField_type.LONGTEXT?4:1,sx:{width:"100%"}})},fi=({value:e,handleChange:a,dateFormat:n})=>{const r=(n||"YYYY/MM/DD").toUpperCase();return t.jsx(Pt.LocalizationProvider,{dateAdapter:Mt.AdapterDayjs,children:t.jsx(Ut,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Ya.DatePicker,{value:e?K(e):null,onChange:o=>a(o),format:r,slotProps:{textField:{size:"small",sx:{width:"100%"},variant:"standard"},openPickerButton:{disableRipple:!0}}})})})},gi=({handleChange:e,value:a,options:n})=>{const r=xe();return t.jsx(s.FormControl,{className:"fadein",sx:{width:"100%"},children:t.jsxs(s.Select,{value:a,onChange:o=>e(o.target.value),size:"small",variant:"standard",children:[t.jsx(s.MenuItem,{value:"",children:r("global.noValue")}),n.map((o,i)=>t.jsx(s.MenuItem,{value:o,children:o},i))]})})},mi=({value:e,handleChange:a,userTimeFormat:n})=>{const r=n==="24"?"HH:mm":"hh:mm";return t.jsx(Pt.LocalizationProvider,{dateAdapter:Mt.AdapterDayjs,children:t.jsx(Ut,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Lr.TimePicker,{value:e?K(e):null,onChange:o=>a(o),format:r,slotProps:{textField:{size:"small",sx:{width:"100%"},variant:"standard"},openPickerButton:{disableRipple:!0}}})})})},hi=({value:e,handleChange:a,userTimeFormat:n})=>{const r=xe(),o=[K().set("hour",0).set("minute",0),K().set("hour",0).set("minute",0)],i=n==="24"?"HH:mm":"hh:mm";return t.jsx(Pt.LocalizationProvider,{dateAdapter:Mt.AdapterDayjs,children:t.jsx(Ut,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Je.MultiInputTimeRangeField,{slotProps:{textField:({position:d})=>({label:r(d==="start"?"contactEdit.from":"contactEdit.to"),size:"small",variant:"standard",inputProps:{placeholder:i}})},value:e||o,onChange:d=>a(d),format:i})})})},yi=({value:e,handleChange:a,userDateFormat:n})=>{const r=xe(),o=[K(),K()],i=(n||"YYYY/MM/DD").toUpperCase();return t.jsx(Pt.LocalizationProvider,{dateAdapter:Mt.AdapterDayjs,children:t.jsx(Ut,{sx:{overflow:"visible",paddingTop:"0px"},children:t.jsx(Je.MultiInputDateRangeField,{slotProps:{textField:({position:d})=>({label:r(d==="start"?"contactEdit.from":"contactEdit.to"),size:"small",sx:{width:"100%"},variant:"standard",inputProps:{placeholder:i}})},value:e||o,onChange:d=>a(d),format:i})})})},xi=s.styled(s.IconButton)(()=>({opacity:0,transition:"opacity 0.3s ease-in-out","& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"},marginLeft:"15px"})),En=s.styled(s.IconButton)(()=>({"& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"}})),bi=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",borderRadius:e.shape.borderRadius,minWidth:"45%","&:hover .edit-icon":{opacity:1}})),Dn=s.styled(s.Typography)(({theme:e})=>({fontWeight:600,fontSize:"0.875rem",alignSelf:"center",color:e.palette.text.primary,letterSpacing:-.5,padding:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0})),vi=s.styled(s.Typography)(({theme:e})=>({fontWeight:400,fontSize:"0.875rem",padding:"2.5px 14px 8.5px 0px",color:e.palette.text.primary,wordWrap:"break-word",maxHeight:"80px",overflow:"auto",whiteSpace:"break-spaces"})),An=({property:e,entity:a,entityType:n,entityId:r,customContactFields:o,userTrii:i,baseUrl:d,spaceId:c,onEntityUpdated:u})=>{const{customProperties:p}=a.field,{setCustomProperties:m}=a.action,[h,x]=l.useState(!1),[g,y]=l.useState(!1),w=l.useRef(null),[b,C]=l.useState(!1),S=(i?.regCon_dateFormat||"YYYY/MM/DD").toUpperCase(),j=i?.regCon_timeFormat||"24",I=U=>U===ne.ContactField_type.NUMBER_INTEGER||U===ne.ContactField_type.NUMBER_DECIMAL||U===ne.ContactField_type.NUMBER_CURRENCY||U===ne.ContactField_type.NUMBER_ACCOUNTING||U===ne.ContactField_type.CURRENCY,D=(U,T)=>U.toLowerCase()==="dni"?!0:I(T),E=(U,T,M)=>{if(M===""||M===null||M===void 0)return null;if(D(U,T)){const O=Number(M);return Number.isNaN(O)?M:O}return M},B=()=>x(U=>!U),A=()=>{x(!1),a.action.resetCustomProperty(e.nameKey)},k=async()=>{if(!d||!c||!r)return;y(!0);const U=p.find(W=>W.nameKey===e.nameKey)||e,{nameKey:T,value:M}=U,O=o.find(W=>W.nameKey===T)?.type??U.type;let R;if(O===ne.ContactField_type.TIME){const W=K(M);W.isValid()?R=W.format(j==="24"?"HH:mm":"hh:mm"):R=M}else if(O===ne.ContactField_type.DATE){const W=K(M);W.isValid()?R=W.toISOString():R=M}else R=E(T,O,M);const H={properties:[{nameKey:T,type:O,value:R}]};try{const W=await Xe({baseUrl:d,spaceId:c,entityType:n,entityId:r,body:H}),ae=p.map(de=>de.nameKey===T?{...de,type:O,value:R}:de);m(ae),u?.(W)}finally{y(!1),x(!1)}},N=U=>o.find(T=>T.nameKey===U)?.name||U;l.useEffect(()=>{const U=w.current;if(!U)return;const T=()=>{const M=U.scrollWidth>U.clientWidth;C(O=>O===M?O:M)};if(T(),typeof ResizeObserver<"u"){let M=0;const O=new ResizeObserver(()=>{if(typeof window>"u"){T();return}M&&window.cancelAnimationFrame(M),M=window.requestAnimationFrame(()=>{T()})});return O.observe(U),()=>{typeof window<"u"&&M&&window.cancelAnimationFrame(M),O.disconnect()}}if(!(typeof window>"u"))return window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)}},[o,e.nameKey]);const _=(U,T)=>{const M=e.type===ne.ContactField_type.DATERANGE?Array.isArray(T)&&T[0]&&T[1]?`${K(T[0]).toISOString()} - ${K(T[1]).toISOString()}`:"":e.type===ne.ContactField_type.DATE?K(T).isValid()?K(T).toISOString():"Invalid Date":e.type===ne.ContactField_type.TIME?K(T).isValid()?K(T).toISOString():"Invalid Time":T,O=p.map(R=>R.nameKey===U?{...R,value:M}:R);m(O)},{type:V,nameKey:G,value:$}=e,Q=U=>U==null?!1:typeof U=="string"?U.trim().length>0:!0,X=()=>V===ne.ContactField_type.DATE?t.jsx(fi,{value:$?K($):null,handleChange:U=>_(G,U?.toDate()),dateFormat:S}):V===ne.ContactField_type.TIME?t.jsx(mi,{value:e?.valueDate?K(e.valueDate):$?K($):null,handleChange:U=>_(G,U),userTimeFormat:j}):V===ne.ContactField_type.DATERANGE?t.jsx(yi,{value:$&&typeof $=="string"&&$.includes(" - ")?[K($.split(" - ")[0]),K($.split(" - ")[1])]:null,handleChange:U=>_(G,[U[0]?.toDate?.(),U[1]?.toDate?.()]),userDateFormat:S}):V===ne.ContactField_type.TIMERANGE?t.jsx(hi,{value:Array.isArray($)&&$.length===2?[K($[0]),K($[1])]:null,handleChange:U=>_(G,[U[0]?.toDate?.(),U[1]?.toDate?.()]),userTimeFormat:j}):V===ne.ContactField_type.OPTIONS?t.jsx(gi,{value:typeof $=="string"?$:"",handleChange:U=>_(G,U),options:o.find(U=>U.nameKey===G)?.typeOptions??[]}):t.jsx(pi,{type:V,nameKey:G,value:$,onChange:_});return t.jsxs(bi,{className:`fadein ${e.type===ne.ContactField_type.LONGTEXT?"col-12":"col-5"}`,children:[t.jsxs(s.Box,{display:"flex",position:"relative",minHeight:"25px",alignItems:"center",children:[b?t.jsx(s.Tooltip,{title:N(e.nameKey),arrow:!0,children:t.jsx(Dn,{ref:w,flexGrow:1,noWrap:!0,children:N(e.nameKey)})}):t.jsx(Dn,{ref:w,flexGrow:1,noWrap:!0,children:N(e.nameKey)}),h?t.jsxs(t.Fragment,{children:[t.jsx(En,{size:"small",onClick:k,children:g?t.jsx(s.CircularProgress,{size:24}):t.jsx(ut,{})}),t.jsx(En,{size:"small",onClick:A,children:t.jsx(qa,{})})]}):t.jsx(xi,{className:"edit-icon",size:"small",onClick:B,children:t.jsx($t,{})})]}),t.jsx(s.Box,{width:h||e.type===ne.ContactField_type.LONGTEXT?"100%":"50%",position:"relative",children:h?X():t.jsx(vi,{children:Q(e?.value)?e.type===ne.ContactField_type.DATERANGE?(()=>{if(typeof e.value=="string"){const U=e.value.split(" - ");if(U.length===2){const[T,M]=U,O=K(T),R=K(M);return`${O.isValid()?O.format(S):"-"} - ${R.isValid()?R.format(S):"-"}`}}else if(Array.isArray(e.value)&&e.value.length===2)return`${K(e.value[0]).format(S)} - ${K(e.value[1]).format(S)}`;return`${e.value}`})():e.type===ne.ContactField_type.TIMERANGE?Array.isArray(e.value)&&e.value.length===2?`${K(e.value[0]).format(j==="24"?"HH:mm":"hh:mm")} - ${K(e.value[1]).format(j==="24"?"HH:mm":"hh:mm")}`:`${e.value}`:e.type===ne.ContactField_type.TIME?(()=>{try{const U=e.valueDate||e.value;return`${K(U).format(j==="24"?"HH:mm":"hh:mm A")}`}catch{return`${e.value}`}})():e.type===ne.ContactField_type.DATE?(()=>{try{return`${K(e.value).format(S)}`}catch{return`${e.value}`}})():`${e?.value}`:null})})]})},Ci=e=>{const{dateFormat:a,entityData:n,customContactFields:r,baseUrl:o,spaceId:i,currentUser:d,onEntityUpdated:c}=e,u=xe(),{entityType:p,editEntity:m}=nt(),h=ot();if(p!=="contact")return null;const[x,g]=l.useState([]),[y,w]=l.useState(null),[b,C]=l.useState(null),[S,j]=l.useState(null),I=m;l.useEffect(()=>{if(!h)return;const k=new AbortController;return h.fetchUsers({signal:k.signal}).then(N=>{k.signal.aborted||g(N??[])}).catch(()=>{k.signal.aborted||g([])}),()=>{k.abort()}},[h]),l.useEffect(()=>{const k=new AbortController,N=async _=>{if(!_||!h)return null;try{const V=await h.fetchUserTriiById({userId:_,signal:k.signal});return V?.display_name||V?.email||null}catch{return null}};return(async()=>{const _=Ct({userId:n.owner,users:x,currentUser:d})??(n.owner?await N(n.owner):null),V=Ct({userId:n.createdBy??void 0,users:x,currentUser:d})??(n.createdBy?await N(n.createdBy):null),G=Ct({userId:n.updatedBy??void 0,users:x,currentUser:d})??(n.updatedBy?await N(n.updatedBy):null);k.signal.aborted||(w(_),j(V),C(G))})(),()=>{k.abort()}},[h,n,x,d]);const D=(a||"YYYY/MM/DD").toUpperCase(),E=I.field.birthDate,B=E?.isValid()?E.format(D):null,A=k=>{const N=new Date;let _=N.getFullYear()-k.getFullYear();const V=N.getMonth()-k.getMonth();return(V<0||V===0&&N.getDate()<k.getDate())&&_--,_};return t.jsx(ua,{title:"General",children:t.jsxs(jn,{children:[t.jsx(Wt,{title:u("conversations.contactDetails.contactOwner"),displayValue:y||"-",value:n.owner,inputType:"select",options:x,constructUpdateObject:k=>({owner:typeof k=="string"?k:""}),contact:I,baseUrl:o,spaceId:i,contactId:n.id,onEntityUpdated:c}),t.jsx(Wt,{title:u("conversations.contactDetails.business"),displayValue:n.businessName||"-",value:n.businessId,inputType:"selectBusiness",businessId:n.businessId,contact:I,baseUrl:o,spaceId:i,contactId:n.id,onEntityUpdated:c}),t.jsx(Wt,{title:u("conversations.contactDetails.createdBy"),value:S||"-",isNotEditable:!0,contact:I,baseUrl:o,spaceId:i,contactId:n.id}),t.jsx(Wt,{title:u("conversations.contactDetails.modifiedBy"),value:b||"-",isNotEditable:!0,contact:I,baseUrl:o,spaceId:i,contactId:n.id}),t.jsx(Wt,{title:u("global.birthdate"),inputType:"birthday",displayValue:E?`${B} (${A(E.toDate())})`:"-",value:E?E.toISOString():"",constructUpdateObject:k=>({birthDate:k}),contact:I,baseUrl:o,spaceId:i,contactId:n.id,dateFormat:a,onEntityUpdated:c}),I.field.customProperties.map(k=>t.jsx(An,{property:k,entity:I,entityType:"contact",entityId:String(n.id),customContactFields:r,userTrii:d,baseUrl:o,spaceId:i,onEntityUpdated:c},k.nameKey))]})})},Ba=({title:e,value:a,isNotEditable:n,inputType:r="text",options:o=[],displayValue:i,constructUpdateObject:d,baseUrl:c,spaceId:u,businessId:p,onEntityUpdated:m})=>t.jsx(it,{entityType:"business",entityId:p,title:e,value:a,isNotEditable:n,inputType:r,options:o,displayValue:i,constructUpdateObject:d,baseUrl:c,spaceId:u,onEntityUpdated:m}),Si=e=>{const a=xe(),{entityData:n,customContactFields:r,baseUrl:o,spaceId:i,currentUser:d,onEntityUpdated:c}=e,{entityType:u,editEntity:p}=nt(),m=ot();if(u!=="business")return null;const[h,x]=l.useState([]),[g,y]=l.useState(null),[w,b]=l.useState(null),[C,S]=l.useState(null),j=p;return l.useEffect(()=>{if(!m)return;const I=new AbortController;return m.fetchUsers({signal:I.signal}).then(D=>{I.signal.aborted||x(D??[])}).catch(()=>{I.signal.aborted||x([])}),()=>{I.abort()}},[m]),l.useEffect(()=>{const I=new AbortController,D=async E=>{if(!E||!m)return null;try{const B=await m.fetchUserTriiById({userId:E,signal:I.signal});return B?.display_name||B?.email||null}catch{return null}};return(async()=>{const E=Ct({userId:n.owner,users:h,currentUser:d})??(n.owner?await D(n.owner):null),B=Ct({userId:n.createdBy??void 0,users:h,currentUser:d})??(n.createdBy?await D(n.createdBy):null),A=Ct({userId:n.updatedBy??void 0,users:h,currentUser:d})??(n.updatedBy?await D(n.updatedBy):null);I.signal.aborted||(y(E),S(B),b(A))})(),()=>{I.abort()}},[m,n,h,d]),t.jsx(ua,{title:"General",children:t.jsxs(jn,{children:[t.jsx(Ba,{title:a("conversations.businessDetails.businessOwner"),value:n.owner,displayValue:g||"-",inputType:"select",options:h,constructUpdateObject:I=>({owner:typeof I=="string"?I:""}),baseUrl:o,spaceId:i,businessId:n.id,onEntityUpdated:c}),t.jsx(Ba,{title:a("conversations.contactDetails.createdBy"),value:C||"-",isNotEditable:!0}),t.jsx(Ba,{title:a("conversations.contactDetails.modifiedBy"),value:w||"-",isNotEditable:!0}),j.field.customProperties.map(I=>t.jsx(An,{property:I,entity:j,entityType:"business",entityId:String(n.id),customContactFields:r,userTrii:d,baseUrl:o,spaceId:i,onEntityUpdated:c},I.nameKey))]})})},ji=e=>{const{entityType:a,entityData:n}=e;return l.useMemo(()=>a==="contact"||a==="business"?a:"contact",[a])==="contact"?t.jsx(Ci,{...e,entityData:n,entityType:"contact"}):t.jsx(Si,{...e,entityData:n,entityType:"business"})},wi=()=>{const[e,a]=l.useState(!1),[n,r]=l.useState("");return{isOpen:e,title:n,openModal:o=>{r(o),a(!0)},closeModal:()=>{a(!1),r("")}}},Ti=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:e.spacing(1),backgroundColor:e.palette.background.dropdownMenu,borderRadius:e.shape.borderRadius,color:e.palette.text.primary,width:"50%",paddingBottom:"3px",minHeight:"50px",position:"relative"})),Ii=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",gap:e.spacing(1),overflow:"hidden",maxWidth:"80%"})),ki=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),Ei=we.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",gap:e.spacing(.5),overflow:"hidden",flexFlow:"nowrap",flexWrap:"wrap",marginTop:"-5px"})),Di=we.styled(s.Avatar)(({})=>({width:32,height:32,cursor:"pointer"})),$a=we.styled(s.Box)(({})=>({fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"})),Ai=we.styled($a)(({theme:e})=>({fontSize:12,color:e.palette.text.secondary,position:"absolute",bottom:0,maxWidth:"70%"})),Fi=we.styled($a)(({})=>({fontSize:14,fontWeight:500})),Bi=we.styled($a)(({})=>({fontSize:14,fontWeight:500})),$i=({item:e})=>{const a=e.profileUrl,{imageUrl:n}=Ot({initialImageUrl:a});return t.jsx(t.Fragment,{children:t.jsxs(Ti,{children:[t.jsx(Ii,{children:t.jsxs(Ei,{children:[t.jsx(s.Tooltip,{title:e.address||"",arrow:!0,children:t.jsx(Fi,{children:e.address})}),t.jsx(s.Tooltip,{title:e.profileName||"",arrow:!0,children:t.jsx(Bi,{sx:{marginTop:"-10px",marginLeft:"5px",fontSize:"10px"},children:e.profileName})}),t.jsx(s.Tooltip,{title:e.note||"",arrow:!0,children:t.jsx(Ai,{children:e.note})})]})}),t.jsxs(ki,{children:[a!==""&&t.jsx(Di,{src:n,alt:e.profileName,style:{cursor:"pointer"},children:e?.profileName?.charAt(0).toUpperCase()}),t.jsx(s.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:t.jsx(s.IconButton,{size:"small",sx:{marginTop:"-5px",padding:0},children:e.isFavorite?t.jsx(Ae.Star,{sx:{color:"#fcac34"}}):t.jsx(Ae.StarBorder,{sx:{color:"#fcac34"}})})})]})]})})},Ma=Ka.PhoneNumberUtil.getInstance(),Mi=e=>{if(!e||!e.trim())return e;try{const a=Ma.parse(e,void 0);return Ma.isValidNumber(a)?Ma.format(a,Ka.PhoneNumberFormat.INTERNATIONAL):e}catch{return e}},Pi=we.styled(s.IconButton)(({theme:e})=>({padding:e.spacing(.5),marginTop:"-5px"})),Ui=we.styled(Or)(({theme:e})=>({height:16,width:16,color:e.palette.secondary.main})),Ri=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:e.spacing(1),backgroundColor:e.palette.background.dropdownMenu,borderRadius:e.shape.borderRadius,color:e.palette.text.primary,width:"50%",paddingBottom:"3px",minHeight:"50px",position:"relative"})),Ni=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"flex-start",gap:e.spacing(1),maxWidth:"80%"})),Li=we.styled(s.Box)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1)})),Oi=we.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",gap:e.spacing(.5),overflow:"hidden",flexFlow:"nowrap",flexWrap:"wrap",marginTop:"-5px"})),Fn=we.styled(s.Box)(({})=>({fontSize:14,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"})),zi=we.styled(Fn)(({theme:e})=>({fontSize:12,color:e.palette.text.secondary,position:"absolute",bottom:0,maxWidth:"70%"})),Wi=we.styled(Fn)(({})=>({fontSize:14,fontWeight:500})),_i=({item:e})=>{const a=()=>{const r=e.address;if(!r)return;const o=new CustomEvent("call-contact-header",{detail:{phoneAddress:r}});window.dispatchEvent(o)},n=l.useMemo(()=>Mi(e.address||""),[e.address]);return t.jsx(t.Fragment,{children:t.jsxs(Ri,{children:[t.jsxs(Ni,{children:[t.jsx(Pi,{onClick:a,color:"primary",size:"small",children:t.jsx(Ui,{})}),t.jsxs(Oi,{children:[t.jsx(s.Tooltip,{title:n||"",arrow:!0,children:t.jsx(Wi,{children:n})}),t.jsx(s.Tooltip,{title:e.note||"",arrow:!0,children:t.jsx(zi,{children:e.note})})]})]}),t.jsx(Li,{children:t.jsx(s.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:t.jsx(s.IconButton,{size:"small",sx:{marginTop:"-5px",padding:0},children:e.isFavorite?t.jsx(Ae.Star,{sx:{color:"#fcac34"}}):t.jsx(Ae.StarBorder,{sx:{color:"#fcac34"}})})})})]})})},Vi=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",padding:e.spacing(1,0,2,0),width:"100%",gap:e.spacing(1),"&:hover .edit-icon":{opacity:1}})),Hi=s.styled(s.Typography)(({})=>({letterSpacing:-.5,fontSize:14})),Gi=s.styled(s.Box)(({})=>({display:"flex",alignItems:"center"})),Yi=s.styled(s.Box)(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1),width:"100%"})),qi=s.styled(s.IconButton)({opacity:0,transition:"opacity 0.3s ease-in-out","& .MuiSvgIcon-root":{width:"0.8em",height:"0.8em"},marginLeft:"15px"}),Ki=({title:e,methodItems:a,isPhone:n,handleEdit:r,owner:o})=>t.jsxs(Vi,{children:[t.jsxs(Gi,{children:[t.jsx(Hi,{children:e}),t.jsx(qi,{className:"edit-icon",size:"small",onClick:r,children:t.jsx($t,{fontSize:"small",sx:{color:i=>i.palette.secondary.main}})})]}),t.jsx(Yi,{children:a.map((i,d)=>n?t.jsx(_i,{item:i},d):t.jsx($i,{item:i,owner:o},d))})]}),Ji=({title:e})=>t.jsx(s.Box,{children:t.jsx(s.Typography,{variant:"subtitle2",children:e})}),Qi={container:{display:"flex",justifyContent:"space-between",alignItems:"center"}},pa=({title:e,handleAdd:a})=>{const n=xe();return t.jsxs(s.Box,{sx:Qi.container,children:[t.jsx(s.Typography,{variant:"subtitle2",children:e}),t.jsx(s.Button,{onClick:a,size:"small",startIcon:t.jsx(Ja,{}),variant:"text",color:"primary",children:n("global.add")})]})},Xi={container:{border:"1px solid lightgray",borderRadius:1,p:2,width:"100%",display:"flex",flexDirection:"column",gap:1}},_t=({children:e})=>t.jsx(s.Box,{sx:Xi.container,children:e}),Bn={container:{display:"flex",width:"50%",alignItems:"center",justifyContent:"end"},noteTextField:{width:"100%",marginRight:"15px"}},Zi=({onDelete:e,addressData:a,handleLinkAccountSave:n,checked:r,onCheckContactAddress:o})=>{const i=xe(),[d,c]=l.useState(null),u=!!d,{channelType:p,address:m}=a,[h,x]=l.useState(!1),[g,y]=l.useState(null),[w,b]=l.useState(!1),C=A=>{c(A.currentTarget)},S=()=>{c(null)},j=()=>{b(!1)},I=()=>{e(),S()},D=async()=>{x(!0);try{if(!o)return;const A=await o(13);if(!A)return;y(A),b(!0)}catch(A){console.error("Error verifying WhatsApp account:",A)}finally{x(!1)}S()},E=async()=>{x(!0);try{if(!o)return;const A=await o(21);if(!A)return;y(A),b(!0)}catch(A){console.error("Error verifying RCS account:",A)}finally{x(!1)}S()},B=async()=>{await n(),b(!1)};return t.jsxs(s.Box,{children:[t.jsx(s.IconButton,{"aria-controls":u?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":u?"true":void 0,onClick:C,children:t.jsx(zr,{})}),t.jsxs(s.Menu,{id:"basic-menu",anchorEl:d,open:u,onClose:S,MenuListProps:{"aria-labelledby":"basic-button"},children:[t.jsxs(s.MenuItem,{onClick:I,children:[t.jsx(s.ListItemIcon,{children:t.jsx(oa,{color:"error"})}),t.jsx(s.ListItemText,{children:i("global.delete")})]}),p===5&&t.jsxs(s.MenuItem,{onClick:D,disabled:!r,children:[t.jsx(s.ListItemIcon,{children:h?t.jsx(s.CircularProgress,{size:24}):t.jsx(Wr,{sx:{color:"green"}})}),t.jsx(s.ListItemText,{children:i("optionsMenu.verifyWspAccount")})]}),p===21&&t.jsxs(s.MenuItem,{onClick:E,disabled:!r,children:[t.jsx(s.ListItemIcon,{children:h?t.jsx(s.CircularProgress,{size:24}):t.jsx(_r,{})}),t.jsx(s.ListItemText,{children:i("optionsMenu.verifyRCSAccount")})]})]}),t.jsx(s.Modal,{open:w,onClose:j,"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:t.jsx(s.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,boxShadow:24,p:4,backgroundColor:A=>A.palette.background.default},children:g?.success?t.jsxs(t.Fragment,{children:[t.jsxs(s.Typography,{id:"modal-modal-title",variant:"h6",component:"h2",children:[i("optionsMenu.wspAccountFound")," ",m]}),t.jsx(s.Typography,{id:"modal-modal-description",sx:{mt:2},children:i("optionsMenu.wantToLinkContact")}),t.jsxs(s.Box,{sx:{marginTop:"10px"},children:[t.jsx(s.Button,{onClick:B,color:"primary",children:i("optionsMenu.yesLink")}),t.jsx(s.Button,{onClick:j,color:"secondary",children:"No"})]})]}):t.jsxs(s.Box,{sx:{position:"relative"},children:[t.jsxs(s.Typography,{id:"modal-modal-title",variant:"h6",component:"h2",children:[i("optionsMenu.noWspAccountFound")," ",m]}),t.jsx(s.Button,{onClick:j,color:"secondary",sx:{position:"absolute",bottom:-25,right:0},children:i("global.cancel")})]})})})]})},Vt=e=>{const a=xe(),n=ot(),{editEntity:r,entityId:o}=nt(),[i,d]=l.useState(!1),c=e.checked??!0,u=e.entityId??o,{note:p,channelType:m,id:h,address:x}=e.addressData,g=!e.addressData.hasOwnProperty("isSaved"),y=e.replaceAddress??r.action.replaceAddress,w=e.addWhatsappVerified||(typeof r.action?.addWhatsappVerified=="function"?r.action.addWhatsappVerified:void 0),b=async I=>{if(!n||!u)return null;const D=await n.setContactAddress({data:{address:x,contactId:u,type:I}});return y(h,D),D},C=async()=>{if(!n||!u)return;const I=await n.updateContactAddress({data:{contactAddressId:h,contactId:u,note:p??""}});y(h,I)},S=async()=>{d(!0),g?(await C(),d(!1)):await b(m)&&d(!1)},j=async()=>{d(!0);const I=await b(13);I&&w&&w(I),I&&d(!1)};return t.jsxs(s.Box,{sx:{...Bn.container},children:[g&&t.jsx(s.TextField,{size:"small",label:a("global.note"),variant:"outlined",onChange:I=>e.handleNoteFieldChange(I,h,m),value:p,fullWidth:!0,InputLabelProps:{shrink:!0},className:"smallInput",sx:Bn.noteTextField}),t.jsx(s.IconButton,{onClick:S,children:i?t.jsx(s.CircularProgress,{size:24}):t.jsx(ut,{color:"primary"})}),t.jsx(Zi,{onDelete:()=>e.handleDeleteAddress(h,m),addressData:e.addressData,handleLinkAccountSave:j,checked:c&&!i,onCheckContactAddress:async I=>{if(!n)return null;try{return await n.checkContactAddress({data:{address:x,type:I}})}catch{return null}}})]})},el={container:{display:"flex",gap:"100px",alignItems:"center"}},Ht=({children:e})=>t.jsx(s.Box,{sx:el.container,children:e}),tl={container:{width:"100%",borderRadius:1,px:1.5,py:2,display:"flex",flexDirection:"column",gap:2,overflow:"auto",maxHeight:"calc(100vh - 250px)"}},Gt=({children:e})=>t.jsx(s.Box,{sx:{...tl.container},children:e}),al=({status:e})=>{switch(e){case"idle":return null;case"loading":return t.jsx(Gr,{size:20});case"available":return t.jsx(Vr,{style:{height:27,width:27},color:"success"});case"unavailable":return t.jsx(Hr,{style:{height:27,width:27},color:"error"});default:return null}},$n=({status:e,text:a})=>t.jsxs(Yr,{position:"end",children:[a?t.jsx(qr,{marginRight:.5,children:a}):null,t.jsx("div",{style:{width:30,display:"flex",justifyContent:"center"},children:t.jsx(al,{status:e})})]}),nl={code:{width:"60%",color:"gray"}},rl=({data:e,editEntity:a})=>{const n=a.action;return t.jsx(_t,{children:t.jsxs(Ht,{children:[t.jsx(s.Typography,{sx:nl.code,variant:"body2",children:e.address}),t.jsx(Vt,{addressData:e,handleNoteFieldChange:n.handleNoteFieldChange,handleDeleteAddress:n.handleDeleteAddress})]})})},sl=({IMSs:e,editEntity:a})=>t.jsx(Gt,{children:e?.map(n=>t.jsx(rl,{data:n,editEntity:a},n.id))}),fa=({editEntity:e,title:a,IMSs:n})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(Ji,{title:a}),t.jsx(sl,{IMSs:n,editEntity:e})]}),ol={addressField:{}},Pa=({data:e,onChange:a,setWarnings:n})=>{const{id:r,channelType:o,address:i}=e,d=xe(),c=ot(),[u,p]=l.useState("idle"),[m,h]=l.useState(i),x=!e.hasOwnProperty("isSaved");return l.useEffect(()=>{let g=setTimeout(async()=>{if(i!==""&&i!==m){if(!c)return;p("loading"),h(i);const y={address:i,type:o};try{const w=await c.checkContactAddress({data:y}),{success:b,warnings:C}=w;n(C),p(b?"available":"unavailable")}catch{n([]),p("unavailable")}}},1700);return()=>clearTimeout(g)},[c,e,i,o,m,n]),t.jsx(t.Fragment,{children:t.jsx(s.TextField,{disabled:x,sx:ol.addressField,size:"small",label:o===bt.ChannelType.WHATSAPP||o===bt.ChannelType.RCS?d?d("global.number"):"Number":d?d("global.email"):"Email",value:i,onChange:g=>{a(g,r,o)},variant:"outlined",fullWidth:!0,InputLabelProps:{shrink:!0},className:"smallInput",InputProps:{endAdornment:t.jsx(t.Fragment,{children:t.jsx($n,{status:u})})}})})},il={addressField:{}},ll=({data:e,onChange:a,setWarnings:n})=>{const r=ot(),o=xe(),{id:i,channelType:d,address:c}=e,[u,p]=l.useState("idle"),[m,h]=l.useState(c),x=!e.hasOwnProperty("isSaved");return l.useEffect(()=>{let g=setTimeout(async()=>{if(c!==""&&c!==m){if(!r)return;p("loading"),h(c);const y={address:c,type:d};try{const{success:w,warnings:b}=await r.checkContactAddress({data:y});n(b),p(w?"available":"unavailable")}catch{n([]),p("unavailable")}}},1700);return()=>clearTimeout(g)},[e]),t.jsx(t.Fragment,{children:t.jsx(s.TextField,{disabled:x,sx:il.addressField,size:"small",label:o("global.number"),value:c,onChange:g=>{a(g,i,d)},variant:"outlined",fullWidth:!0,InputLabelProps:{shrink:!0},className:"smallInput",InputProps:{endAdornment:t.jsx(t.Fragment,{children:t.jsx($n,{status:u})})}})})},Ua={secondaryContainer:{display:"flex",alignItems:"baseline",height:"100%",gap:.5},icon:{height:15},chip:{borderRadius:"6px",height:"22px"}},dl=({text:e})=>t.jsx(s.Grid,{item:!0,children:t.jsx(s.Box,{sx:Ua.secondaryContainer,children:t.jsx(Jr,{icon:t.jsx(Kr,{sx:Ua.icon}),sx:Ua.chip,label:e,color:"error",variant:"outlined"})})}),ga=({warnings:e})=>{const a=xe();return t.jsx(s.Box,{children:t.jsx(s.Grid,{container:!0,children:e?.map((n,r)=>t.jsx(dl,{text:a(`contactAddressError.${n}`)},r))})})},cl={numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{marginTop:"10px"},adressInputBox:{position:"relative",width:"45%"}},ul=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]),[c,u]=l.useState(!0);return l.useEffect(()=>{u(i.length===0&&(e.address??"")!=="")},[i,e.address]),t.jsx(_t,{children:t.jsxs(Ht,{children:[t.jsxs(s.Box,{sx:{...cl.numberCountryContainer,flexDirection:"column"},children:[t.jsx(ll,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange}),i.length>0&&t.jsx(ga,{warnings:i})]}),t.jsx(Vt,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress,addWhatsappVerified:r.addWhatsappVerified,checked:c})]})})},pl=({phoneNumbers:e})=>t.jsx(Gt,{variant:"large",children:e?.map(a=>t.jsx(ul,{data:a},a.id))}),fl=({phoneNumbers:e,handleAdd:a})=>{const n=xe();return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(pa,{handleAdd:a,title:n("global.phones")}),t.jsx(pl,{phoneNumbers:e})]})},Mn={emailField:{width:"60%"},numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{position:"absolute",bottom:"-30px"},adressInputBox:{position:"relative",width:"60%"}},gl=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]);return t.jsxs(_t,{children:[t.jsxs(Ht,{children:[t.jsx(s.Box,{sx:Mn.numberCountryContainer,children:t.jsx(s.Box,{sx:Mn.adressInputBox,children:t.jsx(Pa,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange})})}),t.jsx(Vt,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress})]}),i.length>0&&t.jsx(ga,{warnings:i})]})},ml=({emails:e})=>t.jsx(Gt,{variant:"large",children:e?.map(a=>t.jsx(gl,{data:a},a.id))}),hl=({emails:e,handleAdd:a})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(pa,{handleAdd:a,title:"Emails"}),t.jsx(ml,{emails:e})]}),Pn={emailField:{width:"60%"},numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{position:"absolute",bottom:"-30px"},adressInputBox:{position:"relative",width:"60%"}},yl=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]);return t.jsxs(_t,{children:[t.jsxs(Ht,{children:[t.jsx(s.Box,{sx:Pn.numberCountryContainer,children:t.jsx(s.Box,{sx:Pn.adressInputBox,children:t.jsx(Pa,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange})})}),t.jsx(Vt,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress})]}),i.length>0&&t.jsx(ga,{warnings:i})]})},xl=({whatsapps:e})=>t.jsx(Gt,{variant:"large",children:e?.map(a=>t.jsx(yl,{data:a},a.id))}),bl=({whatsapps:e,handleAdd:a})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(pa,{handleAdd:a,title:"WhatsApp"}),t.jsx(xl,{whatsapps:e})]}),Un={emailField:{width:"60%"},numberCountryContainer:{display:"flex",justifyContent:"flex-start",width:"50%"},warningMessage:{position:"absolute",bottom:"-30px"},adressInputBox:{position:"relative",width:"60%"}},vl=({data:e})=>{const a="edit",{editEntity:n}=nt(),r=n.action,o=n.state,[i,d]=l.useState([]);return t.jsxs(_t,{children:[t.jsxs(Ht,{children:[t.jsx(s.Box,{sx:Un.numberCountryContainer,children:t.jsx(s.Box,{sx:Un.adressInputBox,children:t.jsx(Pa,{data:e,setWarnings:d,onChange:r.handleAddressFieldChange})})}),t.jsx(Vt,{mode:a,addressData:e,handleNoteFieldChange:r.handleNoteFieldChange,handleDeleteAddress:r.handleDeleteAddress,isDeletingAddress:o.isDeletingAddress,replaceAddress:r.replaceAddress})]}),i.length>0&&t.jsx(ga,{warnings:i})]})},Cl=({RCSs:e})=>t.jsx(Gt,{variant:"large",children:e?.map(a=>t.jsx(vl,{data:a},a.id))}),Sl=({RCSs:e,handleAdd:a})=>t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsx(pa,{handleAdd:a,title:"RCS"}),t.jsx(Cl,{RCSs:e})]}),jl=we.styled(s.Box)(({theme:e})=>({position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:1e3,backgroundColor:e.palette.background.panel,padding:e.spacing(4),borderRadius:e.shape.borderRadius})),wl=({open:e,onClose:a,title:n})=>{const r=xe(),{editEntity:o}=nt(),{emails:i,phoneNumbers:d,imsWhatsapp:c,imsRCS:u}=o.field,{addEmail:p,addPhone:m,addWhatsapp:h,resetToInitialContactInformation:x,addRCS:g}=o.action;function y(){a(),x()}return t.jsx(s.Modal,{open:e,onClose:a,children:t.jsxs(jl,{children:[(()=>{switch(n){case"Phones":return t.jsx(fl,{handleAdd:m,phoneNumbers:d});case"Emails":return t.jsx(hl,{handleAdd:p,emails:i});case"Whatsapp":return t.jsx(bl,{handleAdd:h,whatsapps:c});case"RCS":return t.jsx(Sl,{handleAdd:g,RCSs:u});case"Facebook":return t.jsx(fa,{title:"Facebook",IMSs:o.field.imsFacebooks,editEntity:o});case"Webchat":return t.jsx(fa,{title:"Webchat",IMSs:o.field.imsWebchats,editEntity:o});case"Instagram":return t.jsx(fa,{title:"Instagram",IMSs:o.field.imsInstagrams,editEntity:o});case"Mercado libre":return t.jsx(fa,{title:"Mercado Libre",IMSs:o.field.imsMercadolibre,editEntity:o});default:return t.jsx(s.Typography,{children:"No information available for this section."})}})(),t.jsx(s.Box,{mt:2,display:"flex",justifyContent:"flex-end",children:t.jsx(s.Button,{variant:"contained",color:"primary",onClick:y,children:r("global.close")})})]})})},Tl=({ownerData:e})=>{const{isOpen:a,title:n,openModal:r,closeModal:o}=wi(),{editEntity:i}=nt(),d=xe(),c=i.field.phoneNumbers,u=i.field.emails,p=i.field.imsFacebooks,m=i.field.imsWhatsapp,h=i.field.imsMercadolibre,x=i.field.imsWebchats,g=i.field.imsInstagrams,y=i.field.imsRCS,w=[{key:"phones",title:d("conversations.contactDetails.phones"),items:c,isPhone:!0,modalTitle:"Phones",visible:!0},{key:"emails",title:"Emails",items:u,modalTitle:"Emails",visible:!0},{key:"facebook",title:"Facebook",items:p,modalTitle:"Facebook",visible:!0},{key:"whatsapp",title:"Whatsapp",items:m,modalTitle:"Whatsapp",visible:!0},{key:"rcs",title:"RCS",items:y,modalTitle:"RCS",visible:y.length>0},{key:"mercado-libre",title:"Mercado libre",items:h,modalTitle:"Mercado libre",visible:!0},{key:"webchat",title:"Webchat",items:x,modalTitle:"Webchat",visible:!0},{key:"instagram",title:"Instagram",items:g,modalTitle:"Instagram",visible:!0}];return t.jsxs(t.Fragment,{children:[t.jsx(ua,{title:d("conversations.contactDetails.contactInformation"),children:t.jsx("div",{className:"grid grid-cols-1 gap-3",children:w.filter(b=>b.visible).map(b=>t.jsx(Ki,{handleEdit:()=>r(b.modalTitle),title:b.title,methodItems:b.items,isPhone:b.isPhone,owner:e},b.key))})}),t.jsx(wl,{open:a,onClose:o,title:n})]})},Il=({entityType:e,entityData:a,baseUrl:n,spaceId:r,onEntityUpdated:o,onDirectionSearchClick:i})=>{const d={baseUrl:n,spaceId:r,entityId:String(a.id),onEntityUpdated:o},c=xe(),u=({addressNumber:p,title:m})=>t.jsxs("div",{className:"flex flex-col gap-4 rounded-xl p-4",children:[t.jsx(s.Typography,{variant:"body2",children:m}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[t.jsx("div",{className:"col-span-2",children:t.jsx(it,{entityType:e,title:c("conversations.contactDetails.street"),value:a[p]?.street??"",...d,constructUpdateObject:h=>({[p]:{street:h}}),minWidth:"100%"})}),t.jsx(it,{entityType:e,title:c("conversations.contactDetails.city"),value:a[p]?.city??"",...d,constructUpdateObject:h=>({[p]:{city:h}}),minWidth:"100%"}),t.jsx(it,{entityType:e,title:c("conversations.contactDetails.state"),value:a[p]?.state??"",...d,constructUpdateObject:h=>({[p]:{state:h}}),minWidth:"100%"}),t.jsx(it,{entityType:e,title:c("conversations.contactDetails.postcode"),value:a[p]?.zipcode??"",...d,constructUpdateObject:h=>({[p]:{zipcode:h}}),minWidth:"100%"}),t.jsx(it,{entityType:e,title:c("conversations.contactDetails.country"),value:a[p]?.country??"",...d,constructUpdateObject:h=>({[p]:{country:h}}),minWidth:"100%"})]})]});return t.jsx(ua,{title:c("conversations.contactDetails.addressInformation"),enableDirectionSearch:!0,onDirectionSearchClick:i,children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(u,{addressNumber:"address1",title:c("conversations.contactDetails.primaryAddress")}),t.jsx(u,{addressNumber:"address2",title:c("conversations.contactDetails.secondaryAddress")})]})})},kl=({entity:e,setEntity:a})=>l.useCallback(n=>{if(!n||typeof n!="object")return;const r=n;if("id"in r){a(n);return}if(!e)return;const o={...e,...r};a(o)},[e,a]),El=({open:e,baseUrl:a,spaceId:n,contactData:r,contactType:o,labels:i,selectedTags:d,onTagsUpdated:c})=>{const[u,p]=l.useState("main"),[m,h]=l.useState([]),[x,g]=l.useState(!1),[y,w]=l.useState(!1),[b,C]=l.useState([]),[S,j]=l.useState(!1),I=l.useMemo(()=>{const A=i??[],k=b??[],N=new Map;for(const _ of A)_?.id&&N.set(String(_.id),_);for(const _ of k)_?.id&&N.set(String(_.id),_);return Array.from(N.values())},[i,b]),D=l.useCallback(()=>{p("main"),h([]),g(!1),w(!1),C([]),j(!1)},[]);l.useEffect(()=>{e||D()},[e,D]),l.useEffect(()=>{if(u!=="tags"){g(!1);return}if(x||!I.length)return;const A=new Set(d.map(N=>String(N.id))),k=I.filter(N=>A.has(String(N?.id)));h(k),g(!0)},[u,x,I,d]);const E=l.useCallback(async A=>{if(S||!a||!n)return;const k=String(A??"").trim();if(!k)return;const N=k.toLowerCase(),_=I.find(V=>String(V?.name??"").trim().toLowerCase()===N);if(_?.id){h(V=>{const G=V??[];return G.some($=>String($?.id)===String(_.id))?G:[...G,_]});return}j(!0);try{const V=await fn({baseUrl:a,spaceId:n,name:k});C(G=>{const $=G??[];return!V?.id||$.some(Q=>String(Q?.id)===String(V.id))?$:[...$,V]}),h(G=>{const $=G??[];return!V?.id||$.some(Q=>String(Q?.id)===String(V.id))?$:[...$,V]})}finally{j(!1)}},[S,a,n,I]),B=l.useCallback(async()=>{if(y||!a||!n||!r||o!=="contact"&&o!=="business")return;const A=m.filter(k=>k?.id&&k?.name).map(k=>({id:String(k.id),name:String(k.name)}));w(!0);try{await Xe({baseUrl:a,spaceId:n,entityType:o,entityId:String(r.id),body:{tags:A}}),c(A),p("main")}finally{w(!1)}},[y,a,n,r,o,m,c]);return{view:u,setView:p,draftLabels:m,setDraftLabels:h,labelsOptions:I,isSaving:y,isCreatingLabel:S,handleCreateLabel:E,handleSaveTags:B}},Dl=({onClose:e})=>l.useCallback((a,n)=>{n!=="escapeKeyDown"&&e()},[e]),Al={format:"IBusiness",total:0,lastPage:1,perPage:10,order:"ASC",orderColumn:"Id"},Fl=({baseUrl:e,spaceId:a,contactId:n,initialBusiness:r,onBack:o,onEntityUpdated:i,currentUser:d})=>{const c=xe(),u=ot(),p=l.useRef(null),m=l.useRef(null),[h,x]=l.useState(()=>r?.businessName??""),[g,y]=l.useState(!1),[w,b]=l.useState(!1),[C,S]=l.useState(!1),[j,I]=l.useState([]),[D,E]=l.useState(r??null),[B,A]=l.useState(1),[k,N]=l.useState(!1),[_,V]=l.useState(!1),G=l.useMemo(()=>{const W=d?.display_name,ae=d?.email;return String(W||ae||"").trim()},[d]);l.useEffect(()=>()=>{p.current&&(clearTimeout(p.current),p.current=null),m.current?.abort()},[]),l.useEffect(()=>{E(r??null),x(r?.businessName??"")},[r]);const $=()=>{m.current?.abort(),m.current=null,p.current&&(clearTimeout(p.current),p.current=null),y(!1),V(!1),A(1),N(!1),I([])},Q=W=>W.filter(ae=>!!ae?.id).map(ae=>({businessId:String(ae.id),businessName:String(ae.name??"")})),X=async({query:W,page:ae})=>{if(!u)return;m.current?.abort();const de=new AbortController;m.current=de,b(!0);try{const ie={...Al,currentPage:ae,filter:[{value:W,column:"name",condition:""}]},Se=await u.fetchBusinessTableData({pagination:ie,signal:de.signal});if(de.signal.aborted)return;const ve=Q(Se?.contactos??[]);y(!0);const Z=Se?.paginacion?.total??0;I(Ue=>{const ce=ae===1?ve:(()=>{const Y=new Map;for(const pe of Ue)Y.set(pe.businessId,pe);for(const pe of ve)Y.set(pe.businessId,pe);return Array.from(Y.values())})();return Z&&ce.length>=Z&&V(!0),ce})}finally{b(!1),S(!1),N(!1)}},U=W=>{$(),W&&(p.current&&(clearTimeout(p.current),p.current=null),S(!0),p.current=setTimeout(()=>{X({query:W,page:1})},800))},T=W=>{const ae=W.target;if(!(ae.scrollHeight-ae.scrollTop-ae.clientHeight<1)||_||w||!h)return;const de=B+1;N(!0),A(de),X({query:h,page:de})},M=async()=>{if(!u||!G)return;const W=String(h??"").trim();if(W){b(!0);try{const ae={name:W,owner:G,imageUrl:"",members:[],tags:[],properties:[],address1:{street:"",city:"",state:"",zipcode:"",country:""},address2:{street:"",city:"",state:"",zipcode:"",country:""}},de=await u.createBusiness({business:ae}),ie={businessId:String(de.id??""),businessName:String(de.name??W)};I([ie]),E(ie),y(!0)}finally{b(!1)}}},O=async()=>{if(!e||!a||!n)return;const W=D?.businessId??"",ae=await Xe({baseUrl:e,spaceId:a,entityType:"contact",entityId:n,body:{businessId:W}});i?.(ae),o()},R=g&&j.length===0&&h?t.jsxs(s.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{px:1,py:.5},children:[t.jsx(s.Typography,{variant:"body2",children:c("global.noOptions")}),t.jsx(at.LoadingButton,{size:"small",variant:"contained",onClick:M,loading:w,disabled:w||!G,children:c("global.createNew")})]}):t.jsx(s.Typography,{variant:"body2",children:c("global.noOptions")}),H=!n||!e||!a;return t.jsxs(s.Box,{sx:{width:"100%"},children:[t.jsxs(s.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:2},children:[t.jsx(s.IconButton,{size:"small",onClick:o,"aria-label":c("global.back"),children:t.jsx(wa,{fontSize:"small"})}),t.jsx(s.Typography,{variant:"subtitle1",children:c("conversations.contactDetails.business")}),t.jsx(s.Box,{sx:{flex:1}}),t.jsx(at.LoadingButton,{variant:"contained",size:"small",startIcon:t.jsx(ut,{}),onClick:O,loading:!1,disabled:H,children:c("global.save")})]}),t.jsxs(s.Box,{sx:{position:"relative"},children:[w||C||k?t.jsx(s.Box,{sx:{position:"absolute",left:0,right:0,top:0},children:t.jsx(s.LinearProgress,{sx:{borderRadius:1}})}):null,t.jsx(s.Autocomplete,{fullWidth:!0,disablePortal:!0,value:D,onChange:(W,ae)=>{E(ae)},inputValue:h,onInputChange:(W,ae,de)=>{x(ae),de==="input"&&U(ae)},options:j,getOptionLabel:W=>W?.businessName??"",isOptionEqualToValue:(W,ae)=>W.businessId===ae.businessId,noOptionsText:R,renderInput:W=>t.jsx(s.TextField,{...W,size:"small",label:c("conversations.contactDetails.business"),placeholder:c("global.noValue"),InputProps:{...W.InputProps,endAdornment:t.jsxs(t.Fragment,{children:[w||C?t.jsx(s.CircularProgress,{size:18,sx:{mr:1}}):null,W.InputProps.endAdornment]})}}),ListboxProps:{sx:{maxHeight:240,overflowY:"auto"},onScroll:T}})]})]})},Bl=({open:e,onClose:a,baseUrl:n,spaceId:r,contactId:o,sx:i,language:d="en",navigate:c,googleMapsApiKey:u,onEntityUpdated:p,contactNameFormat:m})=>{const{t:h,i18n:x}=Ke.useTranslation(),g=l.useRef(null);l.useEffect(()=>{if(window.google?.maps||document.querySelector('script[src^="https://maps.googleapis.com/maps/api/js"]'))return;if(!u){console.warn("Google Maps API key is missing. The location search feature will not work.");return}const U=document.createElement("script");return U.src=`https://maps.googleapis.com/maps/api/js?key=${u}&libraries=places`,U.async=!0,U.defer=!0,document.body.appendChild(U),()=>{}},[u]),l.useEffect(()=>{d&&x.changeLanguage(d)},[d,x]);const y=U=>h(U),w=l.useMemo(()=>!n||!r?null:hn(n,r),[n,r]),{state:b,selectors:C,actions:S}=Vo({open:e,baseUrl:n,spaceId:r,contactId:o,contactNameFormat:m}),j=kl({entity:b.contactData,setEntity:U=>{S.setContactData(U??void 0),U&&p&&p(U)}}),{view:I,setView:D,draftLabels:E,setDraftLabels:B,labelsOptions:A,isSaving:k,isCreatingLabel:N,handleCreateLabel:_,handleSaveTags:V}=El({open:e,baseUrl:n,spaceId:r,contactData:b.contactData,contactType:C.contactType,labels:C.labels,selectedTags:C.tags,onTagsUpdated:U=>{if(!b.contactData)return;const T={...b.contactData,tags:U};S.setContactData(T),p&&p(T)}}),G=Ot({baseUrl:n,spaceId:r,entityType:C.contactType==="business"||C.contactType==="contact"?C.contactType:void 0,entityId:b.contactData?String(b.contactData.id):void 0,initialImageUrl:b.contactData?.imageUrl,onEntityUpdated:j}),$=Dl({onClose:a}),Q={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"min(640px, calc(100vw - 32px))",height:"min(560px, calc(100vh - 64px))",bgcolor:U=>U.palette.background.panel,borderRadius:3,boxShadow:24,outline:0,p:3,overflow:"visible"},X=Array.isArray(i)?[Q,...i]:i?[Q,i]:Q;return t.jsx(go,{value:w,children:t.jsx(po,{t:y,children:t.jsx(ii,{navigate:c,children:t.jsx(s.Modal,{open:e,onClose:$,closeAfterTransition:!0,slots:{backdrop:s.Backdrop},slotProps:{backdrop:{timeout:200}},children:t.jsx(s.Fade,{in:e,timeout:200,children:t.jsxs(s.Box,{sx:X,ref:g,children:[t.jsx(s.IconButton,{"aria-label":"close",onClick:$,sx:{position:"absolute",right:5,top:5,color:U=>U.palette.grey[500],zIndex:1},size:"small",children:t.jsx(Ga,{sx:{fontSize:20}})}),b.isLoading&&!b.contactData?t.jsx(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:220},children:t.jsx(s.CircularProgress,{})}):b.error?t.jsx(s.Box,{sx:{mb:2},children:"Failed to load contact"}):b.contactData?t.jsx(si,{value:{view:I,setView:D},children:t.jsx(ai,{entityType:C.contactType==="business"?"business":"contact",entityData:b.contactData,customContactFields:C.contactFields,baseUrl:n,spaceId:r,children:t.jsxs(s.Box,{sx:{position:"relative",height:"100%"},children:[t.jsx(s.Fade,{in:I==="main",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsxs(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:[t.jsx(So,{imgUrl:G.imageUrl,displayName:C.displayName,tags:C.tags,onEditTags:()=>{D("tags")},onUploadPhoto:G.action.uploadImage,onPhotoFileChange:G.inputAtributes.onChange,photoInputRef:G.inputAtributes.ref,isUploadingPhoto:G.isUploading,onDeletePhoto:G.action.deleteImage,isDeletingPhoto:G.isDeleting,contactType:C.contactType,entityId:b.contactData?.id,firstName:C.isContact?b.contactData.firstName:void 0,lastName:C.isContact?b.contactData.lastName:void 0,name:C.isBusiness?b.contactData.name:void 0,onEntityUpdated:j}),t.jsxs(s.Box,{sx:{px:1,pb:2},children:[t.jsx(ji,{dateFormat:C.userTrii?.regCon_dateFormat||"MM/dd/yyyy",entityType:C.contactType==="contact"||C.contactType==="business"?C.contactType:"contact",entityData:b.contactData,customContactFields:C.contactFields,baseUrl:n,spaceId:r,onEntityUpdated:j,currentUser:C.userTrii}),t.jsx(Il,{entityType:C.contactType==="contact"||C.contactType==="business"?C.contactType:"contact",entityData:b.contactData,baseUrl:n,spaceId:r,onEntityUpdated:j,onDirectionSearchClick:()=>D("searchLocation")}),t.jsx(Tl,{ownerData:b.contactData})]})]})}),t.jsx(s.Fade,{in:I==="searchLocation",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsx(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:t.jsx(_o,{baseUrl:n,spaceId:r,entityType:C.contactType==="business"?"business":"contact",entityId:String(b.contactData.id),onBack:()=>D("main"),onEntityUpdated:j})})}),t.jsx(s.Fade,{in:I==="tags",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsx(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:t.jsx(wo,{value:E,options:A,onChange:B,onBack:()=>D("main"),onSave:V,isSaving:k,onCreateNew:_,isCreatingNew:N,popperContainer:g.current})})}),t.jsx(s.Fade,{in:I==="businessSelect",timeout:200,mountOnEnter:!0,unmountOnExit:!0,children:t.jsx(s.Box,{sx:{pt:.5,position:"absolute",inset:0,overflowY:"auto"},children:t.jsx(Fl,{baseUrl:n,spaceId:r,contactId:String(b.contactData.id),initialBusiness:C.isContact&&b.contactData?.businessId?{businessId:String(b.contactData.businessId),businessName:String(b.contactData.businessName??"")}:null,onBack:()=>D("main"),onEntityUpdated:j,currentUser:C.userTrii})})})]})})}):null]})})})})})})},$l=e=>t.jsx(Ke.I18nextProvider,{i18n:Lt,children:t.jsx(Bl,{...e})}),Rn=l.createContext(null),Ml=Rn.Provider,Nn=()=>l.useContext(Rn),Pl={events:[],setEvents:()=>{},filteredEvents:[]},Ul=(e,a)=>{const[n,r]=l.useState([]);l.useEffect(()=>{if(!a?.length){r([]);return}const i=a.map(d=>({id:d.id,title:d.title||"",start:new Date(d.startAt),end:new Date(d.endAt||d.startAt),startAt:d.startAt,endAt:d.endAt,allDay:d.allDay||!1,color:d.color,calendarId:d.calendarId,details:d.details,location:d.location,isPrivate:d.isPrivate,rule:d.rule,relatedContact:d.relatedContact,sharedWith:d.sharedWith,finalized:d.finalized,kind:"event",originalOccurrenceDate:d.originalOccurrenceDate,parentId:d.parentId}));r(i)},[a]);const o=l.useMemo(()=>e?.length?n.filter(i=>i.calendarId&&e.includes(i.calendarId)):n,[n,e]);return l.useMemo(()=>({events:n,setEvents:r,filteredEvents:o}),[n,o])},Ln={open:!1,handleOpen:()=>{},handleClose:()=>{}},On=()=>{const[e,a]=l.useState(!1),n=l.useCallback(()=>{a(!0)},[]),r=l.useCallback(()=>{a(!1)},[]);return l.useMemo(()=>({open:e,handleOpen:n,handleClose:r}),[e,n,r])},pt={actions:{onError:()=>{},onSuccess:()=>{},resetValue:()=>{},changeValue:()=>{}},attributes:{error:!1,helperText:"",type:"",value:"",onChange:()=>{}}},ft=(e,a)=>{const[n,r]=l.useState(a||""),[o,i]=l.useState(!1),[d,c]=l.useState("");l.useEffect(()=>{r(a||"")},[a]);const u=l.useCallback(w=>{i(!0),c(w)},[]),p=l.useCallback(()=>{i(!1),c("")},[]),m=l.useCallback(w=>{r(w.target.value)},[]),h=l.useCallback(w=>{r(w)},[]),x=l.useCallback(()=>{r(a||"")},[a]),g=l.useMemo(()=>({onError:u,onSuccess:p,resetValue:x,changeValue:h}),[u,p,x,h]),y=l.useMemo(()=>({error:o,helperText:d,type:e,value:n,onChange:m}),[o,d,e,n,m]);return{actions:g,attributes:y}};function zn(e){return typeof e=="number"}const Rl={notifications:[],action:{addNotification:()=>{},deleteNotification:e=>{},handleTimeFieldChange:(e,a)=>{},handleTimePeriodChange:(e,a)=>{},handleReminderChange:(e,a)=>{},resetNotifications:()=>{}}};function Nl(e){const[a,n]=l.useState(e||[]),r=l.useCallback(()=>{const m={id:zt(),timeValue:15,timePeriod:ia.EventNotificationPeriod.MINUTE,sendToContact:!1};n(h=>h.concat(m))},[]),o=l.useCallback(m=>{n(h=>h.filter(x=>x.id!==m))},[]),i=l.useCallback((m,h)=>{const x=Number(m.target.value);zn(x)&&n(g=>g.map(y=>y.id===h?{...y,timeValue:x}:y))},[]),d=l.useCallback((m,h)=>{if(!zn(m.target.value))return;const x=m.target.value;n(g=>g.map(y=>y.id===h?{...y,timePeriod:x}:y))},[]),c=l.useCallback((m,h)=>{const x=m.target.checked;n(g=>g.map(y=>y.id===h?{...y,sendToContact:x}:y))},[]),u=l.useCallback(()=>{n([])},[]);l.useEffect(()=>{if(e){const m=e.map(h=>({...h,id:h.id||zt()}));n(m)}},[e]);const p=l.useMemo(()=>({addNotification:r,deleteNotification:o,handleTimeFieldChange:i,handleTimePeriodChange:d,handleReminderChange:c,resetNotifications:u}),[r,o,i,d,c,u]);return{notifications:a,action:p}}const Ll={state:{selectedStartDate:K(),selectedEndDate:K().add(30,"minute"),error:!1},action:{setSelectedStartDate:()=>{},setSelectedEndDate:()=>{},setError:()=>{},handleSelect:()=>()=>{}}},Ol={state:{search:"",selectedContacts:[]},action:{handleSelectContact:()=>{},handleRemoveContact:()=>{},handleSearchChange:()=>{},resetField:()=>{}}},zl={field:{userIds:[]},action:{setUserIds:()=>{},resetField:()=>{}}},Wl={titleField:pt,descriptionField:pt,locationField:pt,colorField:pt,date:Ll,allDay:!1,setAllDay:()=>{},isPrivate:!1,setIsPrivate:()=>{},recurrenceRule:"",setRecurrenceRule:()=>{},notifications:Rl,shareWithUsers:zl,linkContact:Ol,create:()=>({title:"",details:"",location:"",allDay:!1,isPrivate:!1,color:"",startAt:"",endAt:"",notifications:[],sharedWith:[],rule:""}),resetFields:()=>{}},_l=(e,a)=>{const[n,r]=l.useState(e??K()),[o,i]=l.useState(a??K().add(30,"minute")),[d,c]=l.useState(!1),u=l.useCallback(h=>x=>{h(x)},[]),p=l.useMemo(()=>({selectedStartDate:n,selectedEndDate:o,error:d}),[n,o,d]),m=l.useMemo(()=>({setSelectedStartDate:r,setSelectedEndDate:i,setError:c,handleSelect:u}),[u]);return{state:p,action:m}},Vl=()=>{const[e,a]=l.useState(""),[n,r]=l.useState([]),o=l.useCallback(m=>{r(h=>h.some(x=>x.id===m.id)?h:[...h,{id:m.id,name:m.name??""}]),a("")},[]),i=l.useCallback(m=>{r(h=>h.filter(x=>x.id!==m))},[]),d=l.useCallback(m=>{a(m)},[]),c=l.useCallback(()=>{a(""),r([])},[]),u=l.useMemo(()=>({search:e,selectedContacts:n}),[e,n]),p=l.useMemo(()=>({handleSelectContact:o,handleRemoveContact:i,handleSearchChange:d,resetField:c}),[o,i,d,c]);return{state:u,action:p}},Hl=()=>{const[e,a]=l.useState([]),n=l.useCallback(()=>{a([])},[]),r=l.useMemo(()=>({userIds:e}),[e]),o=l.useMemo(()=>({setUserIds:a,resetField:n}),[n]);return{field:r,action:o}},Gl=e=>{const a=l.useRef(null),n=ft("text",e?.title??""),r=ft("text",e?.details??e?.description??""),o=ft("text",e?.location??""),i=ft("text",e?.color??"#1976d2"),d=_l(e?.startAt?K(e.startAt):void 0,e?.endAt?K(e.endAt):void 0),[c,u]=l.useState(e?.allDay??!1),[p,m]=l.useState(e?.isPrivate??!1),[h,x]=l.useState(e?.rule??""),g=Nl(e?.notifications),y=Hl(),w=Vl(),b=l.useCallback(()=>({title:n.attributes.value,details:r.attributes.value,location:o.attributes.value,allDay:c,isPrivate:p,color:i.attributes.value,startAt:d.state.selectedStartDate.toISOString(),endAt:d.state.selectedEndDate.toISOString(),notifications:g.notifications.filter(S=>S.timeValue>0).map(S=>({id:S.id,timePeriod:S.timePeriod,timeValue:S.timeValue,sendToContact:S.sendToContact})),sharedWith:y.field.userIds,rule:h,relatedContactId:w.state.selectedContacts[0]?.id??null}),[n.attributes.value,r.attributes.value,o.attributes.value,c,p,i.attributes.value,d.state.selectedStartDate,d.state.selectedEndDate,g.notifications,y.field.userIds,h,w.state.selectedContacts]),C=l.useCallback(()=>{n.actions.resetValue(),r.actions.resetValue(),o.actions.resetValue(),i.actions.changeValue("#1976d2"),u(!1),m(!1),x(""),g.action.resetNotifications(),y.action.resetField(),w.action.resetField(),d.action.setError(!1)},[n.actions,r.actions,o.actions,i.actions,g.action,y.action,w.action,d.action]);return l.useEffect(()=>{const S=e?.id;!e||a.current===S||(a.current=S,u(e.allDay??!1),m(e.isPrivate??!1),x(e.rule??""),n.actions.changeValue(e.title??""),r.actions.changeValue(e.details??e.description??""),o.actions.changeValue(e.location??""),i.actions.changeValue(e.color??"#1976d2"),e.startAt&&d.action.setSelectedStartDate(K(e.startAt)),e.endAt&&d.action.setSelectedEndDate(K(e.endAt)))},[e?.id]),l.useMemo(()=>({titleField:n,descriptionField:r,locationField:o,colorField:i,date:d,allDay:c,setAllDay:u,isPrivate:p,setIsPrivate:m,recurrenceRule:h,setRecurrenceRule:x,notifications:g,shareWithUsers:y,linkContact:w,create:b,resetFields:C}),[n,r,o,i,d,c,p,h,g,y,w,b,C])},Yl={field:{userIds:[]},action:{setUserIds:()=>{},resetField:()=>{}}},ql={nameField:pt,color:"#ffffff",handleColorChange:()=>{},shareWithUsers:Yl,googleCalendar:null,handleGoogleCalendarChange:()=>{}},Kl=()=>{const[e,a]=l.useState([]),n=l.useCallback(()=>{a([])},[]),r=l.useMemo(()=>({userIds:e}),[e]),o=l.useMemo(()=>({setUserIds:a,resetField:n}),[n]);return{field:r,action:o}},Jl=()=>{const e=ft("text",""),[a,n]=l.useState("#ffffff"),[r,o]=l.useState(null),i=Kl(),d=l.useCallback(u=>{n(u)},[]),c=l.useCallback(u=>{o(u)},[]);return l.useMemo(()=>({nameField:e,color:a,handleColorChange:d,shareWithUsers:i,googleCalendar:r,handleGoogleCalendarChange:c}),[e,a,d,i,r,c])},Ql={tasks:[],setTasks:()=>{},filteredTasks:[]},Xl=e=>{const[a,n]=l.useState([]),r=l.useMemo(()=>e?.length?a.filter(o=>o.calendarId&&e.includes(o.calendarId)):a,[a,e]);return l.useMemo(()=>({tasks:a,setTasks:n,filteredTasks:r}),[a,r])},Zl={state:{selectedStartDate:K(),selectedEndDate:K(),error:!1},action:{setSelectedStartDate:()=>{},setSelectedEndDate:()=>{},setError:()=>{},handleSelect:()=>()=>{}}},ed={state:{search:"",selectedContacts:[]},action:{handleSelectContact:()=>{},handleRemoveContact:()=>{},handleSearchChange:()=>{},resetField:()=>{}}},td={titleField:pt,descriptionField:pt,date:Zl,linkContact:ed,create:()=>({title:"",description:"",startAt:"",endAt:""}),resetFields:()=>{}},ad=(e,a)=>{const[n,r]=l.useState(e??K()),[o,i]=l.useState(a??K()),[d,c]=l.useState(!1),u=l.useCallback(h=>x=>{h(x)},[]),p=l.useMemo(()=>({selectedStartDate:n,selectedEndDate:o,error:d}),[n,o,d]),m=l.useMemo(()=>({setSelectedStartDate:r,setSelectedEndDate:i,setError:c,handleSelect:u}),[u]);return{state:p,action:m}},nd=()=>{const[e,a]=l.useState(""),[n,r]=l.useState([]),o=l.useCallback(m=>{r(h=>h.some(x=>x.id===m.id)?h:[...h,{id:m.id,name:m.name??""}]),a("")},[]),i=l.useCallback(m=>{r(h=>h.filter(x=>x.id!==m))},[]),d=l.useCallback(m=>{a(m)},[]),c=l.useCallback(()=>{a(""),r([])},[]),u=l.useMemo(()=>({search:e,selectedContacts:n}),[e,n]),p=l.useMemo(()=>({handleSelectContact:o,handleRemoveContact:i,handleSearchChange:d,resetField:c}),[o,i,d,c]);return{state:u,action:p}},rd=e=>{const a=l.useRef(null),n=ft("text",e?.title??""),r=ft("text",e?.description??""),o=ad(e?.startAt?K(e.startAt):void 0,e?.startAt?K(e.startAt):void 0),i=nd(),d=l.useCallback(()=>({title:n.attributes.value,description:r.attributes.value,startAt:o.state.selectedStartDate.toISOString(),endAt:o.state.selectedStartDate.toISOString(),relatedContactId:i.state.selectedContacts[0]?.id??null}),[n.attributes.value,r.attributes.value,o.state.selectedStartDate,i.state.selectedContacts]),c=l.useCallback(()=>{n.actions.resetValue(),r.actions.resetValue(),i.action.resetField(),o.action.setError(!1)},[n.actions,r.actions,i.action,o.action]);return l.useEffect(()=>{const u=e?.id;if(!(!e||a.current===u)&&(a.current=u,n.actions.changeValue(e.title??""),r.actions.changeValue(e.description??""),e.startAt)){const p=K(e.startAt);o.action.setSelectedStartDate(p),o.action.setSelectedEndDate(p)}},[e?.id]),l.useMemo(()=>({titleField:n,descriptionField:r,date:o,linkContact:i,create:d,resetFields:c}),[n,r,o,i,d,c])},Ra=l.createContext({eventDialog:Ln,createCalendarDialog:Ln,event:Wl,events:Pl,calendar:ql,dialogMode:"view",handleCreateEvent:()=>{},handleSelectEvent:()=>{},handleOpenEventCreate:()=>{},handleStartEditingEvent:()=>{},handleSaveUpdatedEvent:()=>{},handleEndEvent:()=>{},handleDeleteEvent:()=>{},handleResizeEvent:()=>{},selectedEvent:{},savingSnackbar:{open:!1,message:"",severity:"info"},handleCloseSnackbar:()=>{},dialogType:"event",setDialogType:()=>{},handleOpenTaskCreate:()=>{},handleOpenCreateFromSlot:()=>{},handleCloseCreateCalendarDialog:()=>{},calendarDialogMode:"create",editingCalendar:null,handleOpenCreateCalendarDialog:()=>{},handleOpenEditCalendarDialog:()=>{},handleSubmitCalendar:async()=>{},tasks:Ql,activeCalendarIds:[],setActiveCalendarIds:()=>{},handleCreateTask:()=>{},task:td,selectedTask:null,taskCalendarId:"",setTaskCalendarId:()=>{},eventCalendarId:"",setEventCalendarId:()=>{},userManuallyChangedColor:!1,setUserManuallyChangedColor:()=>{},myCalendars:[],otherCalendars:[],isLoadingCalendars:!1,isCreatingEvent:!1,isUpdatingEvent:!1,isDeletingEvent:!1,isCreatingTask:!1,isUpdatingTask:!1,isDeletingTask:!1,handleSaveUpdatedTask:()=>{},handleDeleteTask:()=>{},handleToggleTaskCompleted:()=>{},handleDuplicateItem:()=>{},calendarView:"month",setCalendarView:()=>{},calendarDate:new Date,setCalendarDate:()=>{},navigateToDate:()=>{},confirmDeleteDialog:{open:!1,handleClose:()=>{},itemType:"event"},handleConfirmDelete:()=>{},deleteRecurringDialog:{open:!1,handleClose:()=>{}},handleConfirmDeleteRecurring:()=>{},editRecurringDialog:{open:!1,handleClose:()=>{}},handleConfirmEditRecurring:()=>{},hiddenTabs:!1}),Wn=e=>e,_n=l.createContext(Wn),sd=({t:e,children:a})=>t.jsx(_n.Provider,{value:e,children:a}),Be=()=>{const e=l.useContext(_n);return e?(...a)=>{const[n,...r]=a;return e(n,...r)}:(console.warn("[useTranslationContext] using noop, context value is falsy"),Wn)};var od=Object.defineProperty,id=(e,a,n)=>a in e?od(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,Vn=(e,a,n)=>id(e,typeof a!="symbol"?a+"":a,n);class ld extends Error{constructor(a,n,r){super(a),Vn(this,"status"),Vn(this,"body"),this.name="ApiError",this.status=n,this.body=r}}async function ke({url:e,method:a="GET",headers:n,body:r,signal:o}){const i=await globalThis.fetch(e,{method:a,headers:{...r?{"Content-Type":"application/json"}:{},...n??{}},body:r?JSON.stringify(r):void 0,signal:o}),d=(i.headers.get("content-type")||"").includes("application/json")?await i.json().catch(()=>null):await i.text().catch(()=>null);if(!i.ok){const c=typeof d=="object"&&d&&"message"in d?String(d.message):`Request failed with status ${i.status}`;throw new ld(c,i.status,d)}return d}function Ie(e,a){const n=e.endsWith("/")?e.slice(0,-1):e,r=a.startsWith("/")?a:`/${a}`;return`${n}${r}`}function ma(e,a){const n=encodeURIComponent(a);return{CONTACTS:Ie(e,`/contacts/${n}`),MEDIA:Ie(e,`/media/${n}`),SETTINGS:Ie(e,`/settings/${n}`),CALENDAR:Ie(e,`/calendar/${n}`)}}function He(e){return ma(e.baseUrl,e.spaceId).CALENDAR}async function dd(e){const a=ma(e.baseUrl,e.spaceId);return ke({url:Ie(a.SETTINGS,"/user")})}async function cd(e,a,n){const r=`${He(e)}/Events?start=${encodeURIComponent(a)}&end=${encodeURIComponent(n)}`;return ke({url:r})}async function ud(e,a){const n=He(e);return ke({url:Ie(n,"/events"),method:"POST",body:a})}async function Hn(e,a){const n=He(e),{activityId:r,updatedActivity:o,originalOccurrenceDate:i}=a;if(i){const d=i instanceof Date?i.toISOString():i,c=`${n}/events/occurrence/${r}?occurrence=${d}`;return ke({url:c,method:"PUT",body:o})}return ke({url:Ie(n,`/events/${r}`),method:"PUT",body:o})}async function Na(e,a,n){const r=He(e);if(n){const o=n instanceof Date?n.toISOString():n,i=`${r}/events/${a}?occurrence=${o}`;await ke({url:i,method:"DELETE"})}else await ke({url:Ie(r,`/events/${a}`),method:"DELETE"})}async function pd(e,a){const n=He(e);return ke({url:Ie(n,`/events/${a}`),method:"PUT",body:{finalized:!0}})}async function fd(e,a){const n=He(e);return ke({url:Ie(n,`/Task/${a}`)})}async function gd(e,a){const n=He(e);return ke({url:Ie(n,"/Task"),method:"POST",body:a})}async function Gn(e,a,n){const r=He(e);return ke({url:Ie(r,`/Task/${a}`),method:"PUT",body:n})}async function md(e,a){const n=He(e);await ke({url:Ie(n,`/Task/${a}`),method:"DELETE"})}async function hd(e,a,n){const r=He(e);return ke({url:Ie(r,`/Task/${a}`),method:"PUT",body:{isCompleted:n}})}async function yd(e){const a=He(e);return ke({url:Ie(a,"/Calendar")})}async function xd(e,a){const n=He(e);return ke({url:Ie(n,"/Calendar"),method:"POST",body:a})}async function bd(e,a,n){const r=He(e);return ke({url:Ie(r,`/Calendar/${a}`),method:"PUT",body:n})}async function vd({baseUrl:e,spaceId:a,contactId:n,signal:r}){const o=ma(e,a),i=Ie(o.CONTACTS,`/contacts/${encodeURIComponent(n)}`);return ke({url:i,signal:r})}async function Cd({baseUrl:e,spaceId:a,pagination:n,signal:r}){const o=ma(e,a),i=Ie(o.CONTACTS,"/Search");return ke({url:i,method:"POST",body:n,signal:r})}function La(e){const a=K(e),n=a.minute();return n===0||n===30?a.second(0).millisecond(0):n>0&&n<30?a.minute(30).second(0).millisecond(0):a.add(1,"hour").minute(0).second(0).millisecond(0)}const Yt=e=>{if(!e)return e;const a=e.indexOf("_");if(a===-1)return e;const n=e.substring(0,a),r=e.substring(a+1);return/^\d{14}$/.test(r)?n:e},qt=e=>e?e.parentId?e.parentId:Yt(e.id):"",Sd=({children:e,externalOpen:a,externalOnClose:n,externalMode:r="create",externalType:o="event",externalEventCalendarId:i,externalTaskCalendarId:d,externalSelectedEvent:c,externalSelectedTask:u,hiddenTabs:p=!1,externalContactId:m,externalOnActionComplete:h})=>{const{t:x}=Ke.useTranslation(),g=Nn(),y=(v,...L)=>x(v,...L),[w,b]=l.useState(o),[C,S]=l.useState(null),[j,I]=l.useState(null),[D,E]=l.useState(r),[B,A]=l.useState(d||""),[k,N]=l.useState(i||""),[_,V]=l.useState(!1),[G,$]=l.useState("create"),[Q,X]=l.useState(null),[U,T]=l.useState({open:!1,message:"",severity:"info"}),[M,O]=l.useState(!1),[R,H]=l.useState("event"),[W,ae]=l.useState(!1),[de,ie]=l.useState(!1),[Se,ve]=l.useState(null),[Z,Ue]=l.useState(!1),[ce,Y]=l.useState(!1),[pe,Ze]=l.useState(!1),[J,$e]=l.useState(!1),[We,Ge]=l.useState(!1),[ue,Jt]=l.useState(!1),rt="trii_calendar_last_view",jt=v=>v==="month"||v==="week"||v==="day",[wt,Qt]=l.useState(()=>{try{const v=localStorage.getItem(rt);return jt(v)?v:"month"}catch{return"month"}}),[Xt,Tt]=l.useState(new Date),lt=v=>{Tt(v),Qt("day")},Re=On(),dt=On(),se=Gl(C??void 0),fe=rd(j??void 0);l.useEffect(()=>{r!==void 0&&E(r)},[r]),l.useEffect(()=>{o!==void 0&&b(o)},[o]),l.useEffect(()=>{i!==void 0&&N(i)},[i]),l.useEffect(()=>{d!==void 0&&A(d)},[d]),l.useEffect(()=>{c!==void 0&&(S(c),c?.calendarId&&N(c.calendarId))},[c]),l.useEffect(()=>{u!==void 0&&(I(u),u?.calendarId&&A(u.calendarId))},[u]),l.useEffect(()=>{if(!m||!g||r!=="create"||!Re.open)return;let v=!1;return vd({baseUrl:g.baseUrl,spaceId:g.spaceId,contactId:m}).then(L=>{v||!L||(se.linkContact.action.resetField(),se.linkContact.action.handleSelectContact(L),fe.linkContact.action.resetField(),fe.linkContact.action.handleSelectContact(L))}).catch(()=>{}),()=>{v=!0}},[m,Re.open]),l.useEffect(()=>{if(a!==void 0)if(a&&!Re.open){if(r==="create"){se.resetFields(),fe.resetFields(),V(!1),S(null),I(null),se.date.action.setError(!1),fe.date.action.setError(!1);const v=La(new Date),L=v.add(30,"minute");if(o==="task"?(fe.date.action.setSelectedStartDate(v),fe.date.action.setSelectedEndDate(v)):(se.date.action.setSelectedStartDate(v),se.date.action.setSelectedEndDate(L)),!i){const P=Le?.[0]??st?.[0]?.id??Ne?.[0]?.id??"";P&&N(P)}if(!d){const P=Le?.[0]??Ne?.[0]?.id??"";P&&A(P)}}Re.handleOpen()}else!a&&Re.open&&Re.handleClose()},[a]);const Ye=()=>{(D==="edit"||D==="create")&&(se.resetFields(),fe.resetFields()),se.date.action.setError(!1),fe.date.action.setError(!1),n?n():Re.handleClose()},Me=Jl(),Zt=G==="create",[Ne,va]=l.useState([]),[Ca,ea]=l.useState(!1),[It,ta]=l.useState([]),[qe,kt]=l.useState(""),gt="calendar_selected_ids",[Le,mt]=l.useState(()=>{try{const v=localStorage.getItem(gt);return v?JSON.parse(v):[]}catch{return[]}}),ht=Ul(Le,It),aa=Xl(Le),na=()=>{T(v=>({...v,open:!1}))},Qe=l.useCallback((v,L,P)=>{h?.(v,L,P)},[h]);function ra(v){const L=v?.startAt??v?.start,P=v?.endAt??v?.end??L;return{startAt:L,endAt:P}}const{myCalendars:st,otherCalendars:sa}=l.useMemo(()=>{const v=Ne??[];if(!qe)return{myCalendars:v,otherCalendars:[]};const L=v.filter(q=>q.userId===qe),P=v.filter(q=>q.userId!==qe);return L.length===0&&v.length>0?{myCalendars:v,otherCalendars:[]}:{myCalendars:L,otherCalendars:P}},[Ne,qe]),yt=l.useCallback(async()=>{if(g)try{const v=new Date,L=v.getUTCFullYear(),P=v.getUTCMonth(),q=new Date(Date.UTC(L,P-1,1,0,0,0)).toISOString(),te=new Date(Date.UTC(L,P+2,1,0,0,0)).toISOString(),ye=await cd(g,q,te);ta(ye)}catch(v){console.error("Error fetching activities:",v)}},[g]),Et=l.useCallback(async v=>{if(g)try{const L=await fd(g,v);aa.setTasks(L.map(P=>({id:P.id,title:P.title||"",start:new Date(P.startAt),end:new Date(P.endAt||P.startAt),startAt:P.startAt,endAt:P.endAt,description:P.description,calendarId:P.calendarId,isCompleted:P.isCompleted||!1,relatedContact:P.relatedContact,kind:"task"})))}catch(L){console.error("Error fetching tasks:",L)}},[g]),Dt=l.useCallback(async()=>{if(g){ea(!0);try{const v=await yd(g);va(v)}catch(v){console.error("Error fetching calendars:",v)}finally{ea(!1)}}},[g]);l.useEffect(()=>{const v=st?.[0]?.id??Ne?.[0]?.id??"";v&&Re.open&&D==="create"&&(k||N(v),B||A(v))},[Re.open,D]);const At=l.useRef(!1);l.useEffect(()=>{a||(At.current=!1)},[a]),l.useEffect(()=>{if(!g||!a||At.current||(At.current=!0,Dt(),r==="create"))return;let v=!1;return dd(g).then(L=>{v||kt(L.uid)}).catch(()=>{}),()=>{v=!0}},[g,a,r,Dt]);function Ft(v,L,P){b(v),E("create"),S(null),I(null),se.resetFields(),fe.resetFields(),V(!1);const q=La(L??new Date),te=P?La(P):q.add(30,"minute"),ye=te.isAfter(q)?te:q.add(30,"minute");if(v==="task"){fe.date.action.setSelectedStartDate(q),fe.date.action.setSelectedEndDate(q),fe.date.action.setError(!1);const Ve=Le?.[0]??Ne?.[0]?.id??"";A(Ve)}else{se.date.action.setSelectedStartDate(q),se.date.action.setSelectedEndDate(ye),se.date.action.setError(!1);const Ve=Le?.[0]??st?.[0]?.id??Ne?.[0]?.id??"";N(Ve);const me=st?.find(je=>je.id===Ve)??Ne?.find(je=>je.id===Ve);me?.color&&se.colorField.actions.changeValue(me.color)}Re.handleOpen()}function f(){Ft("event")}function F(){se.date.action.setError(!1),fe.date.action.setError(!1),E("edit")}function z(v){const{startAt:L,endAt:P}=ra(v),q={...v,kind:"event",startAt:L,endAt:P,details:v?.details??""};b("event"),S(q),I(null);const te=q.calendarId||st?.[0]?.id||Ne?.[0]?.id||"";N(te),E("view"),se.date.action.setError(!1),fe.date.action.setError(!1),Re.handleOpen()}async function ee(v){if(!g)return;let L;if(v)L={title:v.title,details:v.description||v.details||"",startAt:new Date(v.startAt),endAt:new Date(v.endAt),allDay:v.allDay,location:v.location||"",isPrivate:v.isPrivate||!1,color:v.color||"",rule:v.rule||"",contactId:v.relatedContactId||m||null,sharedWith:v.sharedWith||[],notifications:(v.notifications||[]).map(te=>({id:zt(),timeValue:te.value,timePeriod:te.type,sendToContact:te.sendToContact||!1})),eventTypeId:"",repeatId:""};else{const te=se.create();if(!te.title){T({open:!0,message:y("global.nameRequired"),severity:"error"});return}L={...te,startAt:new Date(te.startAt),endAt:new Date(te.endAt),contactId:te.relatedContactId||m||null,eventTypeId:"",repeatId:"",notifications:te.notifications.map(ye=>({...ye,id:ye.id||zt()}))}}const P=k;if(!P){T({open:!0,message:y("global.errorSavingChanges"),severity:"error"});return}const q={...L,calendarId:P};Ue(!0);try{T({open:!0,message:y("global.savingChanges"),severity:"info"});const te=await ud(g,q);Le.includes(P)||mt(ye=>[...ye,P]),T({open:!0,message:y("global.changesSaved"),severity:"success"}),Qe("created","event",te),se.resetFields(),Ye()}catch(te){console.error("Error creando evento:",te);const ye=te?.response?.data?.message||te?.message||y("global.errorSavingChanges");T({open:!0,message:ye,severity:"error"})}finally{Ue(!1)}}async function le(){if(!C?.id)return;const v=se.create(),L=k||C.calendarId||"";if(!L){T({open:!0,message:y("global.errorSavingChanges"),severity:"error"});return}C.originalOccurrenceDate!=null?(ve(()=>async P=>{await ge(v,L,P)}),ie(!0)):await ge(v,L,!1)}async function ge(v,L,P){const q=C?.originalOccurrenceDate!=null,te={title:v.title,details:v.details,startAt:v.startAt,endAt:v.endAt,allDay:v.allDay,isPrivate:v.isPrivate,location:v.location,color:v.color,calendarId:L,notifications:v.notifications,sharedWith:v.sharedWith};(P||!q)&&(te.rule=v.rule);const ye=qt(C),Ve={updatedActivity:te,activityId:ye};q&&!P&&(Ve.originalOccurrenceDate=C.originalOccurrenceDate),Y(!0);try{const me=await Hn(g,Ve);me&&(S(me),me.calendarId&&N(me.calendarId)),T({open:!0,message:y("global.changesSaved"),severity:"success"}),Qe("updated","event",me),Ye()}catch(me){console.error("Error actualizando evento:",me);const je=me?.response?.data?.message||me?.message||y("global.errorSavingChanges");T({open:!0,message:je,severity:"error"})}finally{Y(!1)}}async function oe(v){ie(!1),Se&&(await Se(v),ve(null))}async function re(){C?.originalOccurrenceDate!=null?ae(!0):(H("event"),O(!0))}async function Ee(){if(g)if(O(!1),R==="event")try{const v=qt(C);Ye(),await Na(g,v),T({open:!0,message:y("global.changesSaved"),severity:"success"}),Qe("deleted","event",{id:v}),yt()}catch(v){console.error("Error deleting event:",v);const L=v?.message?.includes("duplicate key")?y("global.eventAlreadyDeleted","El evento ya fue eliminado"):y("global.errorSavingChanges");T({open:!0,message:L,severity:"error"})}else{if(!j?.id)return;try{const v=Yt(j.id),L=j.calendarId;Ye(),await md(g,v),I(null),fe.resetFields(),T({open:!0,message:y("global.changesSaved"),severity:"success"}),Qe("deleted","task",{id:v}),L&&Et(L)}catch(v){console.error("Error deleting task:",v);const L=v?.message?.includes("duplicate key")?y("global.taskAlreadyDeleted","La tarea ya fue eliminada"):y("global.errorSavingChanges");T({open:!0,message:L,severity:"error"})}}}async function he(v){ae(!1);const L=qt(C);Ye();try{v?await Na(g,L):await Na(g,L,C.originalOccurrenceDate),T({open:!0,message:y("global.changesSaved"),severity:"success"}),Qe("deleted","event",{id:L}),yt()}catch(P){console.error("Error deleting recurring event:",P);const q=P?.message?.includes("duplicate key")?y("global.eventAlreadyDeleted","El evento ya fue eliminado"):y("global.errorSavingChanges");T({open:!0,message:q,severity:"error"})}}async function Ce(){if(!g)return;const v=qt(C);await pd(g,v),Ye()}async function _e(v,L,P){const q=L instanceof Date?L:new Date(L),te=P instanceof Date?P:new Date(P),ye=q.toISOString(),Ve=te.toISOString(),me=v.kind==="task";!me&&v.originalOccurrenceDate!=null?(S(v),ve(()=>async je=>{await et(v,ye,Ve,q,te,me,je)}),ie(!0)):await et(v,ye,Ve,q,te,me,!1)}async function et(v,L,P,q,te,ye,Ve){ye||ht.setEvents(me=>me.map(je=>je.id===v.id?{...je,start:q,end:te,startAt:q,endAt:te}:je)),T({open:!0,message:y("global.savingChanges"),severity:"info"});try{if(ye){const me=Yt(v.id),je={title:v.title,description:v.description,startAt:L,endAt:P,calendarId:v.calendarId,allDay:v.allDay||!1,isCompleted:v.isCompleted||!1};await Gn(g,me,je),await Et(v.calendarId)}else{const me=qt(v),je=v.originalOccurrenceDate!=null,Va={title:v.title,details:v.details,startAt:new Date(L),endAt:new Date(P),allDay:v.allDay,isPrivate:v.isPrivate,location:v.location,color:v.color,calendarId:v.calendarId};(Ve||!je)&&(Va.rule=v.rule);const Ha={updatedActivity:Va,activityId:me};je&&!Ve&&(Ha.originalOccurrenceDate=v.originalOccurrenceDate),await Hn(g,Ha)}T({open:!0,message:y("global.changesSaved"),severity:"success"}),yt()}catch{ye||ht.setEvents(me=>me.map(je=>je.id===v.id?{...je,start:v.start,end:v.end}:je)),T({open:!0,message:y("global.errorSavingChanges"),severity:"error"})}}function tt(v,L){Ft("event",v,L)}function De(){Me.nameField.actions.resetValue(),Me.handleColorChange("#ffffff"),Me.shareWithUsers.action.resetField(),Me.handleGoogleCalendarChange(null)}function xt(){De(),X(null),$("create"),dt.handleClose()}function Sa(v){Me.nameField.actions.changeValue(v.title??""),Me.nameField.actions.onSuccess(),Me.handleColorChange(v.color??"#ffffff"),Me.shareWithUsers.action.setUserIds(v.sharedWith??[]),Me.handleGoogleCalendarChange(v.googleCalendar??null)}function ja(){$("create"),X(null),De(),dt.handleOpen()}function Cr(v){$("edit"),X(v),Sa(v),dt.handleOpen()}async function Sr(){if(!g)return;const v=(Me.nameField.attributes.value??"").trim();if(!v){T({open:!0,message:y("global.nameRequired"),severity:"error"});return}const L=Me.shareWithUsers.field.userIds,P={title:v,color:Me.color,sharedWith:L.length?L:void 0,googleCalendar:Me.googleCalendar};try{if(Zt)await xd(g,P);else{const q=Q?.id;if(!q)return;await bd(g,q,P)}xt(),T({open:!0,message:y(Zt?"global.calendarCreatedSuccess":"global.calendarUpdatedSuccess"),severity:"success"}),Dt()}catch{T({open:!0,message:y("global.errorSavingChanges"),severity:"error"})}}async function jr(v){if(!g)return;let L;if(v?L={title:v.title,description:v.description||"",startAt:v.startAt,contactId:v.relatedContactId||null}:L=fe.create(),!L.title){T({open:!0,message:y("global.nameRequired"),severity:"error"});return}const P=B;if(!P){T({open:!0,message:y("global.errorSavingChanges"),severity:"error"});return}const q={...L,calendarId:P,contactId:L.contactId||L.relatedContactId||m||null};$e(!0);try{T({open:!0,message:y("global.savingChanges"),severity:"info"});const te=await gd(g,q);Le.includes(P)||mt(ye=>[...ye,P]),T({open:!0,message:y("global.changesSaved"),severity:"success"}),Qe("created","task",te),fe.resetFields(),Ye()}catch(te){console.error("Error creando tarea:",te);const ye=te?.response?.data?.message||te?.message||y("global.errorSavingChanges");T({open:!0,message:ye,severity:"error"})}finally{$e(!1)}}function wr(){Ft("task")}async function Tr(){if(!g||!j?.id)return;const v=fe.create();if(!v.title){T({open:!0,message:y("global.nameRequired"),severity:"error"});return}const L=B||j.calendarId;if(!L){T({open:!0,message:y("global.errorSavingChanges"),severity:"error"});return}const P={...v,calendarId:L};Ge(!0);try{const q=Yt(j.id),te=await Gn(g,q,P);te&&I(te),T({open:!0,message:y("global.changesSaved"),severity:"success"}),Qe("updated","task",te),Ye()}catch(q){console.error("Error actualizando tarea:",q);const te=q?.response?.data?.message||q?.message||y("global.errorSavingChanges");T({open:!0,message:te,severity:"error"})}finally{Ge(!1)}}async function Ir(){j?.id&&(H("task"),O(!0))}async function kr(){if(!g||!j?.id)return;const v=!j.isCompleted;try{const L=Yt(j.id),P=j.calendarId,q=await hd(g,L,v);q&&I(q),T({open:!0,message:y("global.changesSaved"),severity:"success"}),P&&Et(P)}catch{T({open:!0,message:y("global.errorSavingChanges"),severity:"error"})}}function Er(){const v=w==="event",L=v?C:j;if(!L)return;const P={...L};v?(S(null),E("create"),V(!0),setTimeout(()=>{if(se.titleField.actions.changeValue(P.title??""),se.descriptionField.actions.changeValue(P.details??P.description??""),se.locationField.actions.changeValue(P.location??""),se.colorField.actions.changeValue(P.color??""),se.setAllDay(P.allDay??!1),se.setIsPrivate(P.isPrivate??!1),se.setRecurrenceRule(P.rule??""),se.date.action.setSelectedStartDate(K(P.startAt)),se.date.action.setSelectedEndDate(K(P.endAt)),se.date.action.setError(!1),se.notifications.action.resetNotifications(),P.relatedContact?.id&&se.linkContact.action.handleSelectContact(P.relatedContact),P.sharedWith){const q=P.sharedWith.map(te=>te.id);se.shareWithUsers.action.setUserIds(q)}N(P.calendarId??k)},50)):(I(null),E("create"),setTimeout(()=>{fe.titleField.actions.changeValue(P.title??""),fe.descriptionField.actions.changeValue(P.description??""),fe.date.action.setSelectedStartDate(K(P.startAt)),fe.date.action.setSelectedEndDate(K(P.startAt)),fe.date.action.setError(!1),P.relatedContact?.id&&fe.linkContact.action.handleSelectContact(P.relatedContact),A(P.calendarId??B)},50))}function Dr(v){const{startAt:L,endAt:P}=ra(v),q={...v,kind:"task",startAt:L,endAt:P,description:v?.description??""};b("task"),I(q),A(q.calendarId??""),N(q.calendarId??""),S(null),E("view"),se.date.action.setError(!1),fe.date.action.setError(!1),Re.handleOpen()}function Ar(v){return v?.kind==="task"?Dr(v):z(v)}l.useEffect(()=>{try{Le&&localStorage.setItem(gt,JSON.stringify(Le))}catch{}},[Le]),l.useEffect(()=>{Ne?.length&&mt(v=>{const L=new Set(Ne.map(q=>q.id)),P=(v??[]).filter(q=>L.has(q));return P.length?P:Ne.map(q=>q.id)})},[Ne]),l.useEffect(()=>{try{localStorage.setItem(rt,wt)}catch{}},[wt]);const Fr={eventDialog:{...Re,handleClose:Ye},dialogMode:D,createCalendarDialog:dt,event:se,calendar:Me,events:ht,handleCreateEvent:ee,handleSelectEvent:Ar,handleOpenEventCreate:f,handleStartEditingEvent:F,handleSaveUpdatedEvent:le,handleEndEvent:Ce,handleDeleteEvent:re,handleResizeEvent:_e,selectedEvent:C,savingSnackbar:U,handleCloseSnackbar:na,dialogType:w,setDialogType:b,handleOpenTaskCreate:wr,handleOpenCreateFromSlot:tt,handleCloseCreateCalendarDialog:xt,calendarDialogMode:G,editingCalendar:Q,handleOpenCreateCalendarDialog:ja,handleOpenEditCalendarDialog:Cr,handleSubmitCalendar:Sr,tasks:aa,activeCalendarIds:Le,setActiveCalendarIds:mt,handleCreateTask:jr,task:fe,selectedTask:j,taskCalendarId:B,setTaskCalendarId:A,eventCalendarId:k,setEventCalendarId:N,userManuallyChangedColor:_,setUserManuallyChangedColor:V,myCalendars:st,otherCalendars:sa,isLoadingCalendars:Ca,isCreatingEvent:Z,isUpdatingEvent:ce,isDeletingEvent:pe,isCreatingTask:J,isUpdatingTask:We,isDeletingTask:ue,handleSaveUpdatedTask:Tr,handleDeleteTask:Ir,handleToggleTaskCompleted:kr,handleDuplicateItem:Er,calendarView:wt,setCalendarView:Qt,calendarDate:Xt,setCalendarDate:Tt,navigateToDate:lt,confirmDeleteDialog:{open:M,handleClose:()=>O(!1),itemType:R},handleConfirmDelete:Ee,deleteRecurringDialog:{open:W,handleClose:()=>ae(!1)},handleConfirmDeleteRecurring:he,editRecurringDialog:{open:de,handleClose:()=>{ie(!1),ve(null)}},handleConfirmEditRecurring:oe,hiddenTabs:p};return t.jsx(sd,{t:y,children:t.jsx(Ra.Provider,{value:Fr,children:e})})},ha=s.styled(s.Box)(()=>({display:"flex",flexDirection:"column",gap:.5})),Oa=s.styled(s.Box)(()=>({display:"flex",alignItems:"baseline",gap:1})),za=s.styled(s.Typography)(()=>({marginX:"8px",marginTop:"-15px",color:"text.primary"})),St="DD/MM/YYYY",ya="HH:mm",jd=({selectedStartDate:e,selectedEndDate:a,handleSelectStart:n,handleSelectEnd:r,isError:o,disabled:i,hideLabel:d=!1,allDay:c=!1})=>{const u=Be(),p=l.useMemo(()=>a.diff(e,"minute"),[e,a]),m=l.useMemo(()=>{if(p===0)return"0 min";const b=Math.floor(p/60),C=p%60;return b===0?`${C} min`:C===0?`${b} h`:`${b}.${Math.round(C/60*10)} h`},[p]),h=b=>{if(!b)return;const C=b.hour(e.hour()).minute(e.minute()).second(0).millisecond(0),S=b.hour(a.hour()).minute(a.minute()).second(0).millisecond(0);n(C),r(S)},x=b=>{if(!b)return;const C=b.hour(0).minute(0).second(0).millisecond(0);n(C)},g=b=>{if(!b)return;const C=b.hour(23).minute(59).second(59).millisecond(999);r(C)},y=b=>{if(!b)return;const C=e.hour(b.hour()).minute(b.minute()).second(0).millisecond(0),S=C.add(p,"minute");n(C),r(S)},w=b=>{if(!b)return;let C=e.hour(b.hour()).minute(b.minute()).second(0).millisecond(0);(C.isBefore(e)||C.isSame(e))&&(C=C.add(1,"day")),r(C)};return i?t.jsxs(ha,{children:[!d&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:u("global.date")}),c?t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,marginTop:"10px"},children:[t.jsx(s.Typography,{variant:"body1",children:e.format(St)}),t.jsx(s.Typography,{variant:"body1",color:"text.secondary",children:"\u2013"}),t.jsx(s.Typography,{variant:"body1",children:a.format(St)})]}):t.jsxs(s.Box,{children:[t.jsx(s.Typography,{variant:"body1",sx:{mb:1},children:e.format(St)}),t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(s.Typography,{variant:"body1",children:e.format(ya)}),t.jsx(s.Typography,{variant:"body1",color:"text.secondary",children:"\u2013"}),t.jsx(s.Typography,{variant:"body1",children:a.format(ya)}),p>0&&t.jsxs(s.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.7rem",ml:1},children:["(",m,")"]})]})]})]}):t.jsxs(ha,{children:[!d&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:u("global.date")}),t.jsx(Je.LocalizationProvider,{dateAdapter:Qa.AdapterDayjs,children:c?t.jsxs(Oa,{children:[t.jsx(Je.DatePicker,{disabled:i,format:St,label:u("global.from"),slotProps:{textField:()=>({size:"small"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:b=>b.palette.background.panel}}}},value:e,onChange:x,minDate:K(),sx:{flex:1}}),t.jsx(za,{variant:"body1",children:"\u2013"}),t.jsx(Je.DatePicker,{disabled:i,format:St,label:u("global.to"),slotProps:{textField:()=>({size:"small"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:b=>b.palette.background.panel}}}},value:a,onChange:g,minDate:e,sx:{flex:1}})]}):t.jsxs(t.Fragment,{children:[t.jsx(s.Box,{sx:{mb:1},children:t.jsx(Je.DatePicker,{disabled:i,format:St,slotProps:{textField:()=>({size:"small",fullWidth:!0}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:b=>b.palette.background.panel}}}},value:e,onChange:h,minDate:K()})}),t.jsxs(Oa,{children:[t.jsx(Je.TimePicker,{disabled:i,format:ya,ampm:!1,slotProps:{textField:()=>({label:u("global.from"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:b=>b.palette.background.panel}}}},value:e,onChange:y,sx:{alignSelf:"baseline",flex:1}}),t.jsx(za,{variant:"body1",children:"\u2013"}),t.jsxs(s.Box,{sx:{flex:1,display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(Je.TimePicker,{disabled:i,format:ya,ampm:!1,slotProps:{textField:()=>({label:u("global.to"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:b=>b.palette.background.panel}}}},value:a,onChange:w,sx:{alignSelf:"baseline",width:"100%"}}),p>0&&t.jsxs(s.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.7rem",ml:1.5},children:["(",m,")"]})]})]})]})}),o&&t.jsx(s.Fade,{in:o,children:t.jsx(s.Typography,{color:"red",variant:"caption",sx:{mt:1,ml:"10px"},children:u("calendarView.reminders.errorDate")})})]})};s.styled(s.Box)(()=>({display:"flex",gap:2,alignItems:"center"})),s.styled(s.Box)(({theme:e})=>({width:"15%",userSelect:"none",color:e.palette.text.secondary}));const ze=({children:e,title:a})=>t.jsxs(s.Box,{children:[t.jsx(s.Typography,{variant:"subtitle2",sx:{mb:1,userSelect:"none"},children:a}),e]}),Wa=({titleField:e,disabled:a,variantMode:n="default"})=>{const r=Be(),{value:o,type:i,...d}=e.attributes,c=o||"";return n==="inline"?t.jsx(s.TextField,{...d,value:c,disabled:a,autoFocus:!0,fullWidth:!0,placeholder:r("global.addTitle"),variant:"standard",InputProps:{disableUnderline:!1,sx:{fontSize:22,fontWeight:500}},sx:{"& .MuiInput-underline:before":{borderBottomColor:"divider"},"& .MuiInput-underline:hover:before":{borderBottomColor:"text.secondary"},"& .MuiInput-underline:after":{borderBottomWidth:2}}}):a?t.jsx(ze,{title:r("global.title"),children:t.jsx(s.Typography,{variant:"body1",sx:{py:.5,color:u=>u.palette.text.secondary,fontSize:"0.9rem"},children:c||"-"})}):t.jsx(ze,{title:r("global.title"),children:t.jsx(s.TextField,{...d,value:c,disabled:a,autoFocus:!0,fullWidth:!0,variant:"outlined",size:"small",type:i})})},wd=s.styled(s.Box)(()=>({marginBottom:"6px",padding:"8px 16px",border:"1px solid lightgray",borderRadius:"3px"})),Td=s.styled(s.Box)(()=>({marginBottom:"6px",padding:"4px 0px"})),Yn=s.styled(s.Box)(()=>({display:"flex",gap:"8px",alignItems:"center",userSelect:"none"})),Id=s.styled(s.TextField)(()=>({width:"13%"})),kd=s.styled(s.Select)(()=>({width:"23%"})),Ed=s.styled(s.Box)(()=>({display:"flex",gap:1,width:"100%",alignItems:"center"})),Dd=s.styled(s.IconButton)(()=>({ml:"auto",color:"error"})),qn=[{title:"minute",value:ia.EventNotificationPeriod.MINUTE},{title:"hour",value:ia.EventNotificationPeriod.HOUR},{title:"day",value:ia.EventNotificationPeriod.DAY}],Ad=({data:e,timeValueHandler:a,timePeriodHandler:n,sendToContactHandler:r,deleteHandler:o,disabled:i=!1})=>{const d=Be(),c=e.timeValue??0;return i?t.jsxs(Td,{children:[t.jsx(Yn,{children:t.jsxs(s.Typography,{variant:"body1",sx:{color:"text.secondary"},children:[d("calendarView.reminders.sendReminder.pt1")," ",c," ",d(`calendarView.reminders.timePeriod.${qn.find(u=>u.value===e.timePeriod)?.title||"minutes"}`)," ",d("calendarView.reminders.sendReminder.pt2")]})}),e.sendToContact&&t.jsxs(s.Typography,{variant:"body1",sx:{mt:.5,fontSize:"0.875rem",color:"text.secondary"},children:["*",d("calendarView.reminders.sendReminderToContact")]})]}):t.jsxs(wd,{children:[t.jsxs(Yn,{children:[t.jsx(s.Typography,{variant:"body2",sx:{userSelect:"none"},children:d("calendarView.reminders.sendReminder.pt1")}),t.jsx(Id,{disabled:i,onChange:u=>a(u,e.id),value:c,type:"text",variant:"outlined",size:"small"}),t.jsx(kd,{disabled:i,onChange:u=>n(u,e.id),value:e.timePeriod,variant:"outlined",size:"small",MenuProps:{PaperProps:{sx:{backgroundColor:u=>u.palette.background.panel}}},children:qn.map(u=>t.jsx(s.MenuItem,{value:u.value,children:d(`calendarView.reminders.timePeriod.${u.title}`)},u.value))}),t.jsx(s.Typography,{variant:"body2",sx:{userSelect:"none"},children:d("calendarView.reminders.sendReminder.pt2")})]}),t.jsxs(Ed,{children:[t.jsx(s.FormControlLabel,{sx:{display:"flex",alignItems:"center"},disabled:i,label:d("calendarView.reminders.sendReminderToContact"),control:t.jsx(s.Checkbox,{checked:e.sendToContact,onChange:u=>r(u,e.id),color:"secondary",disabled:i})}),t.jsx(Dd,{disabled:i,onClick:()=>o(e.id),sx:{ml:"auto"},children:t.jsx(oa,{})})]})]})},Fd=s.styled(s.Box)`
17
17
  display: 'flex',
18
18
  flexDirection: 'column',
19
19
  gap: 1,
20
- `,Ad=s.styled(s.Box)(()=>({display:"flex",justifyContent:"space-between",alignItems:"baseline",userSelect:"none"})),Fd=({notificationsField:e,disabled:a})=>{const n=Be(),{addNotification:r,deleteNotification:o,handleReminderChange:i,handleTimeFieldChange:d,handleTimePeriodChange:c}=e.action,u=e.notifications.length>0;return t.jsxs(Dd,{children:[t.jsxs(Ad,{children:[t.jsx(s.Typography,{variant:"subtitle2",sx:{userSelect:"none"},children:n("calendarView.reminders.title")}),!a&&t.jsx(s.Button,{disabled:a,startIcon:t.jsx(Ka,{}),size:"small",variant:"outlined",onClick:r,color:"secondary",children:n("calendarView.reminders.addReminder")})]}),t.jsx(s.Box,{sx:{pt:1},children:u?e.notifications.map(p=>t.jsx(Ed,{data:p,deleteHandler:o,sendToContactHandler:i,timePeriodHandler:c,timeValueHandler:d,disabled:a},p.id)):a?t.jsx(s.Typography,{variant:"body1",sx:{py:.5},children:"-"}):null})]})},Yn=({descriptionField:e,disabled:a})=>{const n=Be(),{value:r,type:o,...i}=e.attributes,d=r||"";return a?t.jsx(ze,{title:n("global.description"),children:t.jsx(s.Typography,{variant:"body2",sx:{py:.5,whiteSpace:"pre-wrap",color:c=>c.palette.text.secondary,fontSize:"0.9rem"},children:d||"-"})}):t.jsx(ze,{title:n("global.description"),children:t.jsx(s.TextField,{...i,value:d,disabled:a,size:"small",multiline:!0,maxRows:5,fullWidth:!0,variant:"outlined"})})},Bd=({onPlaceSelected:e})=>{const a=l.useRef(null),n=l.useRef(null),r=l.useRef(null),o=l.useRef(null),[i,d]=l.useState([]),[c,u]=l.useState(!1),p=Be();l.useEffect(()=>{if(!a.current)return;const m=()=>{if(!window.google?.maps?.places)return console.warn("Google Places API no est\xE1 disponible a\xFAn"),!1;n.current=new window.google.maps.places.AutocompleteService;const g=document.createElement("div");return r.current=new window.google.maps.places.PlacesService(g),o.current=new window.google.maps.places.AutocompleteSessionToken,!0};if(!m()){const g=setTimeout(()=>{m()},500);return()=>clearTimeout(g)}},[]);const h=m=>{const g=m.target.value;if(!g||g.length<3||!n.current){d([]),u(!1);return}n.current.getPlacePredictions({input:g,types:["geocode"],sessionToken:o.current||void 0},(b,S)=>{S===window.google.maps.places.PlacesServiceStatus.OK&&b?(d(b),u(!0)):(d([]),u(!1))})},y=(m,g)=>{r.current&&r.current.getDetails({placeId:m,fields:["geometry","formatted_address"],sessionToken:o.current||void 0},(b,S)=>{if(S===window.google.maps.places.PlacesServiceStatus.OK&&b?.geometry?.location){const x=b.geometry.location.lat(),T=b.geometry.location.lng(),C=b.formatted_address??g;e({lat:x,lng:T},C),a.current&&(a.current.value=C),u(!1),d([]),o.current=new window.google.maps.places.AutocompleteSessionToken}})};return l.useEffect(()=>{const m=g=>{a.current&&!a.current.contains(g.target)&&u(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]),t.jsxs("div",{style:{position:"absolute",width:"100%",maxWidth:300,margin:"0 auto",zIndex:13e3,top:"10px",left:"10px"},children:[t.jsx("input",{ref:a,placeholder:p("global.searchLocation","Buscar en Google Maps"),onChange:h,onFocus:()=>i.length>0&&u(!0),style:{width:"100%",padding:"12px 16px 5px",borderRadius:"24px",border:"1px solid #ccc",backgroundColor:"white",fontSize:"15px",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",outline:"none",position:"relative",zIndex:13e3}}),c&&i.length>0&&t.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)",marginTop:"4px",maxHeight:"300px",overflowY:"auto",zIndex:13001},children:i.map(m=>t.jsxs("div",{onClick:()=>y(m.place_id,m.description),style:{padding:"12px 16px",cursor:"pointer",borderBottom:"1px solid #f0f0f0",fontSize:"14px",transition:"background-color 0.2s"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f5f5f5"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="white"},children:[t.jsx("div",{style:{fontWeight:500},children:m.structured_formatting.main_text}),t.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:"2px"},children:m.structured_formatting.secondary_text})]},m.place_id))})]})},qn="AIzaSyAQ1bUt3y6UoAhbi5-HAwYwaFx71pAiaKU",Kn=["places"],Wa={apiKey:qn,libraries:Kn,loading:"async"},ya=()=>!!(window.google?.maps?.Map&&window.google?.maps?.Marker&&window.google?.maps?.Geocoder&&window.google?.maps?.places),Jn=(e=qn,a=Kn)=>{if(ya())return Promise.resolve();const n=()=>{document.querySelectorAll('script[src*="maps.googleapis.com"]').forEach(r=>{r.parentNode?.removeChild(r)})};return document.getElementById("google-maps-script")?new Promise((r,o)=>{let i=0;const d=100,c=setInterval(()=>{i++,ya()?(clearInterval(c),r()):i>=d&&(clearInterval(c),n(),Jn(e,a).then(r).catch(o))},100)}):new Promise((r,o)=>{try{n();const i="initGoogleMaps";window[i]=()=>{ya()?r():setTimeout(()=>{ya()||console.warn("Google Maps API se carg\xF3 pero algunos componentes no est\xE1n disponibles"),r()},500)};const d=document.createElement("script");d.id="google-maps-script",d.type="text/javascript";const c=Array.isArray(a)?a.join(","):a;d.src=`https://maps.googleapis.com/maps/api/js?key=${e}&libraries=${c}&callback=${i}&loading=async`,d.async=!0,d.defer=!0,d.onerror=()=>{delete window[i],o(new Error("Error al cargar Google Maps API"))},document.head.appendChild(d)}catch(i){o(i)}})},qt=(e,a,n=18,r=400,o=400,i="red",d=Wa.apiKey)=>`https://maps.googleapis.com/maps/api/staticmap?center=${e},${a}&zoom=${n}&size=${r}x${o}&markers=color:${i}%7Clabel:A%7C${e},${a}&key=${d}`,$d=({onLocationChange:e,initialLocation:a})=>{const n=l.useRef(null),r=l.useRef(null),o=l.useRef(null),i=l.useRef(null),[d,c]=l.useState(!0),[u,p]=l.useState(!1),[h,y]=l.useState(a||null),m=18,g=l.useCallback(C=>{y(C),e(C)},[e]);l.useEffect(()=>{let C=!0;(async()=>{try{if(await Jn(Wa.apiKey,Wa.libraries),!window.google?.maps?.Map||!window.google?.maps?.Geocoder){console.error("Google Maps APIs no est\xE1n completamente disponibles"),c(!1);return}window.google?.maps?.Geocoder&&(i.current=new window.google.maps.Geocoder),c(!1)}catch(j){console.error("Error al cargar Google Maps:",j),c(!1)}})(),a||navigator.geolocation.getCurrentPosition(j=>{const w=j.coords.latitude,$=j.coords.longitude,E=w.toString(),F=$.toString(),D=qt(w,$,m);g({lat:E,lng:F,title:"",description:"",url:D})},j=>{console.error("Error getting location:",j);const w=-34.6037,$=-58.3816;g({lat:w.toString(),lng:$.toString(),title:"",description:"",url:qt(w,$,m)})})},[a,g,m]),l.useEffect(()=>{if(d||r.current)return;const C=setTimeout(()=>{r.current||b()},50);return()=>clearTimeout(C)},[d]),l.useEffect(()=>{u&&h&&x()},[u,h]),l.useEffect(()=>()=>{o.current&&(o.current.setMap(null),o.current=null)},[]);const b=()=>{if(!n.current){console.warn("Contenedor del mapa no disponible");return}if(!window.google?.maps){console.warn("Google Maps API no disponible a\xFAn");return}try{const C={zoom:m,disableDefaultUI:!1,zoomControl:!0,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1};r.current=new window.google.maps.Map(n.current,C),r.current.addListener("click",j=>{S(j)}),p(!0)}catch(C){console.error("Error inicializando mapa:",C)}},S=C=>{if(!C.latLng||!i.current)return;const j={lat:C.latLng.lat(),lng:C.latLng.lng()};o.current?o.current.setPosition(j):r.current&&(o.current=new window.google.maps.Marker({position:j,map:r.current})),i.current.geocode({location:j},(w,$)=>{if($==="OK"&&w&&w[0]){const E=w[0].formatted_address,F=qt(j.lat,j.lng,m);g({lat:j.lat.toString(),lng:j.lng.toString(),title:E||"",description:"",url:F})}else{const E=qt(j.lat,j.lng,m);g({lat:j.lat.toString(),lng:j.lng.toString(),title:`${j.lat.toFixed(6)}, ${j.lng.toFixed(6)}`,description:"",url:E})}})},x=()=>{if(!(!r.current||!h))try{const C={lat:parseFloat(h.lat),lng:parseFloat(h.lng)};r.current.setCenter(C),o.current?o.current.setPosition(C):o.current=new window.google.maps.Marker({position:C,map:r.current})}catch(C){console.error("Error actualizando mapa:",C)}},T=(C,j)=>{const w=qt(C.lat,C.lng,m);g({lat:C.lat.toString(),lng:C.lng.toString(),title:j||"",description:"",url:w})};return d?t.jsx(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:t.jsx(s.CircularProgress,{})}):t.jsxs(s.Box,{sx:{position:"relative",height:"calc(100vh - 305px)"},children:[t.jsx(Bd,{onPlaceSelected:T}),t.jsx("div",{style:{height:"100%"},ref:n})]})},Md=({open:e,onClose:a,onSelectLocation:n,initialAddress:r})=>{const o=Be(),[i,d]=l.useState(null),c=l.useRef(null);l.useEffect(()=>{e||d(null)},[e]),l.useEffect(()=>{c.current&&i&&(c.current.scrollTop=c.current.scrollHeight/4)},[i]);const u=l.useCallback(h=>{d(h)},[]),p=l.useCallback(()=>{i&&(n(i.title||`${i.lat}, ${i.lng}`,i.lat,i.lng),a())},[i,n,a]);return t.jsxs(s.Dialog,{open:e,onClose:a,maxWidth:"md",fullWidth:!0,disableEnforceFocus:!0,disableAutoFocus:!0,PaperProps:{sx:{maxHeight:"80vh",height:"80vh"}},sx:{"& .MuiDialog-paper":{backgroundColor:h=>h.palette.background.panel}},children:[t.jsxs(s.Box,{sx:{position:"relative",display:"flex",alignItems:"center",p:2},children:[t.jsx(s.Typography,{variant:"body1",sx:{flex:1},children:o("global.selectLocation","Seleccionar ubicaci\xF3n")}),t.jsx(s.IconButton,{"aria-label":"close",onClick:a,size:"small",children:t.jsx(Ha,{fontSize:"small"})})]}),t.jsx(s.DialogContent,{sx:{p:0,display:"flex",flexDirection:"column",height:"100%"},children:t.jsxs(s.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflow:"hidden",width:"100%",height:"100%",position:"relative"},children:[t.jsx(s.Box,{ref:c,sx:{width:"100%",flex:1,overflow:"auto",zIndex:1},children:t.jsx($d,{onLocationChange:u,initialLocation:void 0})}),t.jsx(s.Divider,{sx:{width:"100%",padding:0}}),t.jsxs(s.Box,{sx:{width:"100%",display:"flex",justifyContent:"flex-end",gap:".5rem",p:2},children:[t.jsx(s.Button,{variant:"outlined",color:"error",size:"small",sx:{borderRadius:"0.5rem"},onClick:a,children:o("global.cancel","Cancelar")}),t.jsx(s.Button,{variant:"outlined",color:"secondary",size:"small",sx:{borderRadius:"0.5rem"},onClick:p,disabled:!i,children:o("global.selectLocation","Seleccionar ubicaci\xF3n")})]})]})})]})},Pd=({locationField:e,disabled:a})=>{const n=Be(),[r,o]=l.useState(!1),{value:i,type:d,...c}=e.attributes,u=i||"",p=()=>{a||o(!0)},h=()=>{o(!1)},y=m=>{e.actions.changeValue(m)};return a?t.jsx(s.Box,{children:t.jsx(ze,{title:n("global.location","Ubicaci\xF3n"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[u&&t.jsx(Qa,{sx:{opacity:.5,color:m=>m.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"body1",sx:{color:m=>m.palette.text.secondary,fontSize:"0.9rem"},children:u||"-"})]})})}):t.jsxs(s.Box,{children:[t.jsx(ze,{title:n("global.location","Ubicaci\xF3n"),children:t.jsx(s.TextField,{...c,value:u,disabled:a,size:"small",fullWidth:!0,variant:"outlined",placeholder:n("global.addLocation","Agregar ubicaci\xF3n"),onClick:p,InputProps:{startAdornment:t.jsx(Qa,{sx:{mr:1,opacity:.5},fontSize:"small"}),readOnly:!0},sx:{cursor:a?"default":"pointer","& .MuiInputBase-input":{cursor:a?"default":"pointer"}}})}),t.jsx(Md,{open:r,onClose:h,onSelectLocation:y,initialAddress:u})]})},Ud=({handleScroll:e,contactList:a,handleSelectContact:n,selectedContactIds:r,search:o})=>{const i=Be(),d=s.useTheme();return t.jsx(s.List,{sx:{width:"100%",height:"100%",overflow:"auto",border:`1px solid ${d.palette.divider}`,borderTop:"none",backgroundColor:d.palette.background.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12))"},onScroll:e,children:o&&a?.map(c=>t.jsxs(s.ListItemButton,{sx:{width:"100%"},onClick:()=>n(c),selected:r.includes(c.id),children:[t.jsx(s.ListItemIcon,{children:t.jsx(Ae.Person,{sx:{color:u=>u.palette.text.disabled}})}),t.jsx(s.ListItemText,{primary:i(c.name),secondary:c?.phone})]},c.id))})},Rd={format:"IContact",total:0,lastPage:1,perPage:10,order:"ASC",orderColumn:"Id"};function Nd(e){const a=l.useRef(null),n=l.useRef(null),[r,o]=l.useState([]),[i,d]=l.useState(!1),[c,u]=l.useState(!1),[p,h]=l.useState(!1),[y,m]=l.useState(!1),[g,b]=l.useState(1),[S,x]=l.useState(!1),T=l.useCallback(()=>{n.current?.abort(),n.current=null,a.current&&(clearTimeout(a.current),a.current=null),d(!1),x(!1),b(1),m(!1),o([])},[]),C=E=>E.filter(F=>!!F?.id),j=l.useCallback(async({query:E,page:F})=>{if(!e)return;n.current?.abort();const D=new AbortController;n.current=D,u(!0);try{const I={...Rd,currentPage:F,filter:[{value:E,column:"name",condition:""}]},R=await bd({baseUrl:e.baseUrl,spaceId:e.spaceId,pagination:I,signal:D.signal});if(D.signal.aborted)return;const V=C(R?.contactos??[]);d(!0);const W=R?.paginacion?.total??0;o(Y=>{const B=F===1?V:(()=>{const X=new Map;for(const H of Y)X.set(H.id,H);for(const H of V)X.set(H.id,H);return Array.from(X.values())})();return W&&B.length>=W&&x(!0),B})}finally{u(!1),h(!1),m(!1)}},[e]),w=l.useCallback(E=>{T(),E&&(a.current&&(clearTimeout(a.current),a.current=null),h(!0),a.current=setTimeout(()=>{j({query:E,page:1})},800))},[j,T]),$=l.useCallback((E,F)=>{const D=E.target;if(!(D.scrollHeight-D.scrollTop-D.clientHeight<1)||S||c||!F)return;const I=g+1;m(!0),b(I),j({query:F,page:I})},[S,c,g,j]);return{contactList:r,hasSearched:i,isLoading:c,isLoadingTimer:p,isNextPage:y,handleQueryChanged:w,handleScroll:$,resetSearchState:T}}const Qn=({linkContactsHandler:e,disabled:a=!1})=>{const n=Be(),r=Un(),o=l.useRef(null),[i,d]=l.useState(null),{action:{handleSearchChange:c,handleSelectContact:u,handleRemoveContact:p},state:{search:h,selectedContacts:y}}=e,{contactList:m,hasSearched:g,isLoading:b,isLoadingTimer:S,handleQueryChanged:x,handleScroll:T,resetSearchState:C}=Nd(r),j=h||"",w=!!i&&j.length>0&&!a,$=y.map(I=>I.id);l.useEffect(()=>{j?x(j):C()},[j,x,C]);const E=I=>{c(I),I&&!i?d(o.current):I||d(null)},F=I=>{u(I),d(null),C()},D=()=>{d(null)};return a?t.jsx(ze,{title:n("global.linkContacts"),children:y.length>0?t.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,pt:.5},children:y.map(I=>t.jsx(s.Chip,{icon:t.jsx(wa,{fontSize:"small"}),label:I.name,size:"small",variant:"outlined"},I.id))}):t.jsx(s.Typography,{variant:"body1",sx:{py:.5},children:"-"})}):t.jsx(s.ClickAwayListener,{onClickAway:D,children:t.jsxs(s.Box,{children:[t.jsxs(ze,{title:n("global.linkContacts"),children:[t.jsx(s.TextField,{ref:o,fullWidth:!0,size:"small",placeholder:n("global.searchContacts"),value:j,onChange:I=>E(I.target.value),onFocus:()=>{j&&d(o.current)},InputProps:{startAdornment:t.jsx(wa,{sx:{mr:1,opacity:.5},fontSize:"small"}),endAdornment:b||S?t.jsx(s.CircularProgress,{size:18,sx:{mr:1}}):null}}),y.length>0&&t.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mt:1},children:y.map(I=>t.jsx(s.Chip,{icon:t.jsx(wa,{fontSize:"small"}),label:I.name,size:"small",onDelete:()=>p(I.id)},I.id))})]}),t.jsx(s.Popper,{open:w,anchorEl:i,placement:"bottom-start",style:{width:i?.offsetWidth||"auto",zIndex:1300},children:t.jsxs(s.Paper,{elevation:8,sx:{mt:.5,maxHeight:300,overflow:"hidden"},children:[g&&m.length>0&&t.jsx(Ud,{handleScroll:I=>T(I,j),contactList:m,handleSelectContact:F,selectedContactIds:$,search:j}),g&&m.length===0&&t.jsx(s.Box,{sx:{p:2,textAlign:"center",color:"text.secondary"},children:t.jsx(s.Typography,{variant:"body2",children:n("global.noResults","No se encontraron resultados")})})]})})]})})},Ld=({isFinalized:e})=>{const{eventDialog:{handleClose:a},handleCreateEvent:n,dialogMode:r,handleStartEditingEvent:o,handleSaveUpdatedEvent:i,handleEndEvent:d,dialogType:c,handleCreateTask:u,handleSaveUpdatedTask:p,selectedTask:h,handleToggleTaskCompleted:y,event:m,task:g,eventCalendarId:b,taskCalendarId:S,isCreatingEvent:x,isUpdatingEvent:T,isCreatingTask:C,isUpdatingTask:j}=l.useContext(Ua),w=Be(),$=c==="event",E=x,F=T,D=!1,I=C,R=j,V=()=>{$?n():u()},W=(()=>{if(r==="view")return o;if(r==="edit")return $?()=>i?.():()=>p?.();if(r==="create")return V})(),Y=w(r==="view"?$?"global.editEvent":"global.editTask":r==="edit"?$?"global.saveEvent":"global.saveTask":$?"global.createEvent":"global.createTask"),B=$?E||F:I||R,X=()=>{if(r==="view")return!0;const M=$?m:g,O=$?b:S;return M?.titleField?.attributes?.value?.trim().length>0&&!!O},H=$?E||F||e||!X():I||R||e||!X(),L=!$&&r==="view",k=h?.isCompleted||!1;return L?t.jsx(s.DialogActions,{children:t.jsx(at.LoadingButton,{startIcon:t.jsx(Ae.CheckCircleOutline,{}),size:"small",loading:R,disabled:R,onClick:y,variant:"contained",color:k?"inherit":"primary",children:k?w("global.markAsIncomplete","Marcar como incompleta"):w("global.markAsCompleted","Marcar como completada")})}):t.jsxs(s.DialogActions,{children:[t.jsx(s.Button,{variant:"outlined",size:"small",onClick:a,color:"secondary",children:w("global.cancel")}),$&&(r==="edit"||r==="view")&&t.jsx(at.LoadingButton,{startIcon:t.jsx(Ae.EventAvailable,{}),size:"small",disabled:e,loading:D,onClick:d,variant:"contained",children:w("global.finalizeEvent")}),t.jsx(at.LoadingButton,{startIcon:t.jsx(Ae.EditCalendar,{}),size:"small",loading:B,disabled:H,onClick:W,variant:"contained",children:Y})]})},Xn={textTransform:"none",borderRadius:2,minHeight:34,px:1.5,fontSize:13,fontWeight:500,lineHeight:1.1},Od=({value:e,onChange:a,labels:n})=>t.jsxs(s.Box,{sx:{display:"flex",gap:1},children:[t.jsx(s.Button,{size:"small",onClick:()=>a("event"),variant:e==="event"?"contained":"text",disableElevation:!0,color:"primary",sx:{...Xn},children:n.event}),t.jsx(s.Button,{size:"small",onClick:()=>a("task"),variant:e==="task"?"contained":"text",disableElevation:!0,sx:{...Xn},color:"primary",children:n.task})]}),zd="DD/MM/YYYY",Wd="HH:mm",_d=({selectedDateTime:e,handleSelect:a,disabled:n,isError:r=!1,hideLabel:o=!1})=>{const i=Be(),d=u=>{if(!u)return;const p=u.hour(e.hour()).minute(e.minute());a(p)},c=u=>{if(!u)return;const p=e.hour(u.hour()).minute(u.minute());a(p)};return n?t.jsxs(ma,{children:[!o&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:i("global.date")}),t.jsxs(s.Box,{children:[t.jsx(s.Typography,{variant:"body1",sx:{mb:1},children:e.format(zd)}),t.jsx(s.Typography,{variant:"body1",children:e.format(Wd)})]})]}):t.jsxs(ma,{children:[!o&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:i("global.date")}),t.jsx(La,{children:t.jsxs(Je.LocalizationProvider,{dateAdapter:Ja.AdapterDayjs,children:[t.jsx(Je.DatePicker,{disabled:n,value:e,onChange:d,slotProps:{textField:()=>({label:i("global.date"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:u=>u.palette.background.panel}}}},sx:{alignSelf:"baseline",flex:1},minDate:J()}),t.jsx(Oa,{variant:"body1",children:"_"}),t.jsx(Je.TimePicker,{disabled:n,value:e,onChange:c,ampm:!1,slotProps:{textField:()=>({label:i("global.time"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:u=>u.palette.background.panel}}}},sx:{alignSelf:"baseline",flex:1}})]})}),t.jsx(s.Fade,{in:r,children:t.jsx(s.Typography,{color:"red",variant:"caption",children:i("conversations.sidebar.events.errorDate")})})]})},Zn=({disabled:e,calendars:a,userId:n,value:r,onChange:o,loading:i=!1})=>{const d=Be(),c=l.useMemo(()=>a??[],[a]),u=l.useMemo(()=>{const p=c.find(h=>h.id===r);return e&&r&&!p&&!i&&console.warn("TaskCalendarSelect: Calendario no encontrado",{calendarId:r,availableCalendars:c.map(h=>({id:h.id,title:h.title})),totalCalendars:c.length}),p??null},[c,r,e,i]);if(e){if(i)return t.jsx(ze,{title:d("global.calendar"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[t.jsx(s.CircularProgress,{size:16,sx:{opacity:.5}}),t.jsx(s.Typography,{variant:"subtitle2",sx:{color:h=>h.palette.text.secondary,fontSize:"0.9rem"},children:d("global.loading","Cargando...")})]})});const p=u?u.title:r?d("global.calendarNotFound","Calendario no disponible"):"-";return t.jsx(ze,{title:d("global.calendar"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[u&&t.jsx(Kr,{sx:{opacity:.5,color:h=>h.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"subtitle2",sx:{color:h=>h.palette.text.secondary,fontSize:"0.9rem"},children:p})]})})}return t.jsx(ze,{title:d("global.calendar"),children:t.jsx(s.Autocomplete,{disabled:e||i,size:"small",fullWidth:!0,options:c,value:u,onChange:(p,h)=>o(h?.id??""),getOptionLabel:p=>p?.title??"",isOptionEqualToValue:(p,h)=>p.id===h.id,loading:i,groupBy:n?p=>p.userId===n?d("calendarView.myCalendars"):d("calendarView.othersCalendars"):void 0,renderGroup:p=>t.jsxs("li",{children:[t.jsx(s.ListSubheader,{component:"div",sx:{lineHeight:"32px",fontSize:"0.75rem",fontWeight:600,color:"text.secondary",backgroundColor:h=>h.palette.background.panel},children:p.group}),t.jsx("ul",{style:{padding:0},children:p.children})]},p.key),slotProps:{popper:{sx:{zIndex:1400}},paper:{sx:{backgroundColor:p=>p.palette.background.panel}}},renderInput:p=>t.jsx(s.TextField,{...p,placeholder:d("global.selectCalendar"),InputProps:{...p.InputProps,endAdornment:t.jsxs(t.Fragment,{children:[i?t.jsx(s.CircularProgress,{color:"inherit",size:20}):null,p.InputProps.endAdornment]})}})})})},Vd=({checked:e,onChange:a,disabled:n})=>{const r=Be();return t.jsx(s.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx(s.FormControlLabel,{control:t.jsx(s.Checkbox,{checked:e,onChange:o=>a(o.target.checked),disabled:n,color:"secondary"}),label:r("global.allDay","Todo el d\xEDa")})})},Hd=({colorField:e,disabled:a,onColorChange:n})=>{const r=Be(),o=e.attributes.value||"#1976d2",i=(c=>{if(c.startsWith("#"))return c;const u=c.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(u&&u[1]&&u[2]&&u[3]){const p=parseInt(u[1]),h=parseInt(u[2]),y=parseInt(u[3]),m=g=>{const b=g.toString(16);return b.length===1?"0"+b:b};return`#${m(p)}${m(h)}${m(y)}`}return"#1976d2"})(o),d=c=>{const u=c.target.value;n?n(u):e.actions.changeValue(u)};return a?t.jsx(ze,{title:r("global.color","Color"),children:t.jsxs(s.Box,{sx:{display:"flex",gap:1,alignItems:"center"},children:[t.jsx(s.Box,{sx:{width:40,height:40,backgroundColor:i,border:"1px solid rgba(0, 0, 0, 0.23)",borderRadius:1}}),t.jsx(s.Typography,{variant:"body2",sx:{color:"text.secondary"},children:i})]})}):t.jsx(ze,{title:r("global.color","Color"),children:t.jsx(s.Box,{sx:{display:"flex",gap:1,alignItems:"center"},children:t.jsx("input",{type:"color",value:i,onChange:d,disabled:a,style:{width:60,height:40,border:"1px solid rgba(0, 0, 0, 0.23)",borderRadius:4,cursor:a?"not-allowed":"pointer"}})})})},er=[{value:"",label:"global.noRepeat"},{value:"FREQ=DAILY",label:"global.everyDay"},{value:"FREQ=WEEKLY",label:"global.everyWeek"},{value:"FREQ=MONTHLY",label:"global.everyMonth"},{value:"FREQ=YEARLY",label:"global.everyYear"},{value:"FREQ=DAILY;INTERVAL=2",label:"global.everyTwoDays"},{value:"FREQ=WEEKLY;INTERVAL=2",label:"global.everyTwoWeeks"},{value:"FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR",label:"global.everyWeekday"}],Gd=({value:e,onChange:a,disabled:n,hideLabel:r=!1})=>{const o=Be(),i=p=>{a(p.target.value)},d=l.useMemo(()=>er.map(p=>t.jsx(s.MenuItem,{value:p.value,children:o(p.label,p.label)},p.value)),[o]),c=l.useMemo(()=>{const p=er.find(h=>h.value===e);return p?o(p.label,p.label):o("global.noRepeat")},[e,o]);if(n)return r?t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(Ta,{sx:{opacity:.5,color:p=>p.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"body2",children:c})]}):t.jsx(ze,{title:o("global.recurrence","Recurrencia"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[t.jsx(Ta,{sx:{opacity:.5,color:p=>p.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"body1",children:c})]})});const u=t.jsx(s.Select,{disabled:n,size:"small",variant:"outlined",fullWidth:!0,value:e||"",onChange:i,startAdornment:t.jsx(Ta,{sx:{mr:1,ml:1,opacity:.5},fontSize:"small"}),MenuProps:{PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}}},children:d});return r?u:t.jsx(ze,{title:o("global.recurrence","Recurrencia"),children:u})},Yd=({open:e,onClose:a,onConfirm:n,itemTitle:r,itemType:o})=>{const{t:i}=Ke.useTranslation(),d=()=>{n(),a()},c=o==="event"?i("calendar.deleteEvent","Eliminar evento"):i("calendar.deleteTask","Eliminar tarea"),u=o==="event"?i("calendar.confirmDeleteEvent","\xBFEst\xE1s seguro de que quer\xE9s eliminar este evento?"):i("calendar.confirmDeleteTask","\xBFEst\xE1s seguro de que quer\xE9s eliminar esta tarea?");return t.jsxs(s.Dialog,{open:e,onClose:a,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}},children:[t.jsxs(s.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(Jr,{color:"warning"}),c]}),t.jsxs(s.DialogContent,{children:[t.jsx(s.Typography,{variant:"body2",sx:{mb:2},children:u}),r&&t.jsx(s.Box,{sx:{p:1.5,bgcolor:"action.hover",borderRadius:1,borderLeft:3,borderColor:"warning.main"},children:t.jsxs(s.Typography,{variant:"body2",sx:{fontWeight:500},children:['"',r,'"']})})]}),t.jsxs(s.DialogActions,{sx:{px:3,pb:2},children:[t.jsx(s.Button,{onClick:a,variant:"outlined",color:"inherit",sx:{borderRadius:"8px"},children:i("global.cancel","Cancelar")}),t.jsx(s.Button,{onClick:d,variant:"contained",color:"error",sx:{borderRadius:"8px"},children:i("global.delete","Eliminar")})]})]})},qd=({open:e,onClose:a,onConfirm:n,eventTitle:r})=>{const{t:o}=Ke.useTranslation(),[i,d]=l.useState("single"),c=()=>{n(i==="all"),a()},u=()=>{d("single"),a()};return t.jsxs(s.Dialog,{open:e,onClose:u,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}},children:[t.jsx(s.DialogTitle,{children:o("calendar.deleteRecurringEvent","Borrar evento recurrente")}),t.jsxs(s.DialogContent,{children:[r&&t.jsxs(s.Box,{sx:{mb:2,color:"text.secondary",fontSize:"0.875rem"},children:['"',r,'"']}),t.jsx(s.FormControl,{component:"fieldset",fullWidth:!0,children:t.jsxs(s.RadioGroup,{value:i,onChange:p=>d(p.target.value),children:[t.jsx(s.FormControlLabel,{value:"single",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.deleteThisEvent","Este evento"),sx:{mb:1}}),t.jsx(s.FormControlLabel,{value:"all",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.deleteAllEvents","Todos los eventos")})]})})]}),t.jsxs(s.DialogActions,{sx:{px:3,pb:2},children:[t.jsx(s.Button,{onClick:u,variant:"outlined",color:"inherit",sx:{borderRadius:"8px"},children:o("global.cancel","Cancelar")}),t.jsx(s.Button,{onClick:c,variant:"contained",color:"error",sx:{borderRadius:"8px"},children:o("global.delete","Eliminar")})]})]})},Kd=({open:e,onClose:a,onConfirm:n,eventTitle:r})=>{const{t:o}=Ke.useTranslation(),[i,d]=l.useState("single"),c=()=>{n(i==="all"),a()},u=()=>{d("single"),a()};return t.jsxs(s.Dialog,{open:e,onClose:u,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}},children:[t.jsx(s.DialogTitle,{children:o("calendar.editRecurringEvent","Editar evento recurrente")}),t.jsxs(s.DialogContent,{children:[r&&t.jsxs(s.Box,{sx:{mb:2,color:"text.secondary",fontSize:"0.875rem"},children:['"',r,'"']}),t.jsx(s.FormControl,{component:"fieldset",fullWidth:!0,children:t.jsxs(s.RadioGroup,{value:i,onChange:p=>d(p.target.value),children:[t.jsx(s.FormControlLabel,{value:"single",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.editThisEvent","Este evento"),sx:{mb:1}}),t.jsx(s.FormControlLabel,{value:"all",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.editAllEvents","Todos los eventos")})]})})]}),t.jsxs(s.DialogActions,{sx:{px:3,pb:2},children:[t.jsx(s.Button,{onClick:u,variant:"outlined",color:"inherit",sx:{borderRadius:"8px"},children:o("global.cancel","Cancelar")}),t.jsx(s.Button,{onClick:c,variant:"contained",color:"secondary",sx:{borderRadius:"8px"},children:o("global.save","Guardar")})]})]})},Jd=()=>{const e=Be(),{event:a,task:n,dialogMode:r,selectedEvent:o,handleDeleteEvent:i,handleStartEditingEvent:d,handleDuplicateItem:c,dialogType:u,setDialogType:p,selectedTask:h,taskCalendarId:y,setTaskCalendarId:m,eventCalendarId:g,setEventCalendarId:b,myCalendars:S,otherCalendars:x,isLoadingCalendars:T,handleDeleteTask:C,userManuallyChangedColor:j,setUserManuallyChangedColor:w,eventDialog:{open:$,handleClose:E},confirmDeleteDialog:F,handleConfirmDelete:D,deleteRecurringDialog:I,handleConfirmDeleteRecurring:R,editRecurringDialog:V,handleConfirmEditRecurring:W,hiddenTabs:Y,savingSnackbar:B,handleCloseSnackbar:X}=l.useContext(Ua);if(!a||!n)return t.jsx(s.Modal,{open:$,onClose:E,closeAfterTransition:!0,slots:{backdrop:s.Backdrop},slotProps:{backdrop:{timeout:200}},children:t.jsx(s.Fade,{in:$,timeout:200,children:t.jsx(s.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"min(640px, calc(100vw - 32px))",height:"min(560px, calc(100vh - 64px))",bgcolor:q=>q.palette.background.panel,borderRadius:3,boxShadow:24,outline:0,p:3,overflow:"visible"}})})});const H=u==="event",L=H?a:n,k=H?o:h,M=l.useRef(null),O=l.useRef(null);l.useEffect(()=>{$||(M.current=null,O.current=null)},[$]);const{titleField:U,descriptionField:G,date:_,linkContact:ae}=L,de=H?a.notifications:null,oe=H?{locationField:a.locationField,colorField:a.colorField,allDay:a.allDay,setAllDay:a.setAllDay,isPrivate:a.isPrivate,setIsPrivate:a.setIsPrivate,recurrenceRule:a.recurrenceRule,setRecurrenceRule:a.setRecurrenceRule}:null,Se=e(r==="edit"?H?"global.editEvent":"global.editTask":r==="create"?H?"global.createEvent":"global.createTask":H?"global.showEvent":"global.showTask"),ve=(r==="edit"||r==="view")&&!!k?.id,Z=r==="view";l.useEffect(()=>{if(r!=="create"||u!=="event"||!$||j||!g)return;const q=S.find(pe=>pe.id===g);q?.color&&a.colorField.actions.changeValue(q.color)},[r,u,$,g,j,S]),l.useEffect(()=>{if(!$||u!=="event"||r!=="edit")return;const q=_.state.selectedStartDate.isAfter(_.state.selectedEndDate)&&!_.state.selectedStartDate.isSame(_.state.selectedEndDate,"minute");O.current!==q&&(O.current=q,_.action.setError(q))},[$,u,r,_.state.selectedStartDate.valueOf(),_.state.selectedEndDate.valueOf()]),l.useEffect(()=>{if(!$||r==="create")return;const q=k?.relatedContact;q?.id&&M.current!==q.id&&(M.current=q.id,ae.action.resetField(),ae.action.handleSelectContact({id:q.id,name:q.name}))},[$,r,k?.id]);const Ue=q=>{if(q==="task"){const pe=a.date.state.selectedStartDate;n.date.action.setSelectedStartDate(pe),n.date.action.setSelectedEndDate(pe),n.date.action.setError(!1),a.date.action.setError(!1)}else{const pe=n.date.state.selectedStartDate;a.date.action.setSelectedStartDate(pe),a.date.action.setError(!1),n.date.action.setError(!1)}p(q)},ce=q=>{a.colorField.actions.changeValue(q),w(!0)};return t.jsxs(t.Fragment,{children:[t.jsx(s.Modal,{open:$,onClose:E,closeAfterTransition:!0,slots:{backdrop:s.Backdrop},slotProps:{backdrop:{timeout:200}},children:t.jsx(s.Fade,{in:$,timeout:200,children:t.jsxs(s.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"min(640px, calc(100vw - 32px))",maxHeight:"calc(100vh - 64px)",bgcolor:q=>q.palette.background.panel,borderRadius:3,boxShadow:24,outline:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsxs(s.Box,{sx:{display:"flex",flexDirection:"column",gap:2,p:3,pt:4,overflowY:"auto",flex:1},children:[t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",justifyContent:r==="create"?"flex-end":"space-between",gap:1,mb:.5},children:[r!=="create"&&t.jsx(s.Typography,{sx:{fontWeight:600},children:Se}),t.jsxs(s.Box,{sx:{display:"flex",gap:1},children:[Z&&t.jsx(s.IconButton,{size:"small",onClick:d,"aria-label":e("global.edit","Editar"),children:t.jsx(Bt,{fontSize:"small"})}),ve&&t.jsx(s.IconButton,{size:"small",onClick:H?i:C,color:"error","aria-label":e("global.delete","Eliminar"),children:t.jsx(sa,{fontSize:"small"})}),Z&&t.jsx(s.IconButton,{size:"small",onClick:c,"aria-label":e("global.duplicate","Duplicar"),children:t.jsx(Qr,{fontSize:"small"})})]})]}),r==="create"&&t.jsxs(t.Fragment,{children:[t.jsx(za,{disabled:!1,titleField:U,variantMode:"inline"}),!Y&&t.jsx(Od,{value:u,onChange:Ue,labels:{event:e("global.event","Evento"),task:e("global.task","Tarea")}})]}),u==="event"?t.jsxs(t.Fragment,{children:[r!=="create"&&t.jsx(za,{disabled:r==="view",titleField:U}),t.jsx(Yn,{disabled:r==="view",descriptionField:G}),t.jsx(Zn,{disabled:r==="view",calendars:[...S,...x],userId:S[0]?.userId,value:g,onChange:q=>b(q),loading:T}),t.jsxs(s.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5,borderRadius:1,padding:"15px",bgcolor:q=>q.palette.mode==="dark"?"rgba(255, 255, 255, 0.05)":"rgba(0, 0, 0, 0.02)"},children:[t.jsx(s.Box,{sx:{display:"flex",gap:1.5,alignItems:"flex-start"},children:t.jsx(s.Box,{sx:{flex:1},children:t.jsx(Cd,{disabled:r==="view",selectedStartDate:_.state.selectedStartDate,selectedEndDate:_.state.selectedEndDate,handleSelectStart:_.action.handleSelect(_.action.setSelectedStartDate),handleSelectEnd:_.action.handleSelect(_.action.setSelectedEndDate),isError:_.state.error,hideLabel:!0,allDay:oe?.allDay??!1})})}),oe&&t.jsxs(s.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[t.jsx(Vd,{checked:oe.allDay,onChange:oe.setAllDay,disabled:r==="view"}),t.jsx(s.Box,{sx:{flex:1},children:t.jsx(Gd,{disabled:r==="view",value:oe.recurrenceRule,onChange:oe.setRecurrenceRule,hideLabel:!0})})]})]}),oe&&t.jsx(t.Fragment,{children:t.jsx(Hd,{disabled:r==="view",colorField:oe.colorField,onColorChange:r==="create"?ce:void 0})}),de&&t.jsx(Fd,{disabled:r==="view",notificationsField:de}),t.jsx(Qn,{linkContactsHandler:ae,disabled:r==="view"}),oe&&t.jsx(Pd,{disabled:r==="view",locationField:oe.locationField})]}):t.jsxs(t.Fragment,{children:[r!=="create"&&t.jsx(za,{disabled:r==="view",titleField:U}),t.jsx(Yn,{disabled:r==="view",descriptionField:G}),t.jsx(Zn,{disabled:r==="view",calendars:[...S,...x],userId:S[0]?.userId,value:y,onChange:q=>m(q),loading:T}),t.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5,p:2,borderRadius:1,bgcolor:q=>q.palette.mode==="dark"?"rgba(255, 255, 255, 0.05)":"rgba(0, 0, 0, 0.02)"},children:t.jsxs(s.Box,{sx:{display:"flex",gap:1.5,alignItems:"flex-start"},children:[t.jsx(Xr,{sx:{mt:.5,color:"text.secondary",fontSize:"1.25rem"}}),t.jsx(s.Box,{sx:{flex:1},children:t.jsx(_d,{disabled:r==="view",selectedDateTime:_.state.selectedStartDate,handleSelect:q=>{_.action.setSelectedStartDate(q),_.action.setSelectedEndDate(q),_.action.setError(!1)},isError:_.state.error,hideLabel:!0})})]})}),t.jsx(Qn,{linkContactsHandler:ae,disabled:r==="view"})]})]}),t.jsx(s.Box,{sx:{borderTop:1,borderColor:"divider",p:2},children:t.jsx(Ld,{isFinalized:o?.finalized})})]})})}),t.jsx(Yd,{open:F.open,onClose:F.handleClose,onConfirm:D,itemTitle:F.itemType==="event"?o?.title:h?.title,itemType:F.itemType}),t.jsx(qd,{open:I.open,onClose:I.handleClose,onConfirm:R,eventTitle:o?.title}),t.jsx(Kd,{open:V.open,onClose:V.handleClose,onConfirm:W,eventTitle:o?.title}),t.jsx(s.Snackbar,{open:B.open,autoHideDuration:6e3,onClose:X,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:t.jsx(s.Alert,{onClose:X,severity:B.severity,sx:{width:"100%"},variant:"filled",children:B.message})})]})},tr=e=>{const a=e.palette.background;return s.createTheme({...e,components:{MuiSelect:{defaultProps:{MenuProps:{PaperProps:{sx:{backgroundColor:a.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}}}},MuiAutocomplete:{styleOverrides:{popper:{zIndex:11,"& div":{backgroundColor:a.panel}}}},MuiPaper:{styleOverrides:{root:{backgroundColor:a.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:a.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}},MuiList:{styleOverrides:{root:{padding:0}}},MuiModal:{styleOverrides:{root:{}}},MuiTypography:{styleOverrides:{root:{color:e.palette.text.primary}}},MuiChip:{styleOverrides:{root:{color:e.palette.text.primary,border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:"4px",height:"20px",fontSize:"0.7125rem"}}},MuiListSubheader:{styleOverrides:{root:{backgroundColor:a.accordionHeader}}},MuiButton:{styleOverrides:{outlined:{color:e.palette.mode==="light"?e.palette.primary.dark:e.palette.info.dark,borderColor:e.palette.mode==="light"?e.palette.primary.dark:e.palette.info.dark,"&:hover":{borderColor:e.palette.mode==="light"?e.palette.primary.main:e.palette.info.main,color:e.palette.mode==="light"?e.palette.primary.main:e.palette.info.main}}}}}})},Qd=e=>{const{open:a,onClose:n,baseUrl:r,spaceId:o,language:i="en",mode:d="create",type:c="event",eventCalendarId:u,taskCalendarId:p,selectedEvent:h,selectedTask:y,hiddenTabs:m=!1,onActionComplete:g,contactId:b}=e,{i18n:S}=Ke.useTranslation();l.useEffect(()=>{i&&S.changeLanguage(i)},[i,S]);const x=l.useMemo(()=>({baseUrl:r,spaceId:o}),[r,o]);return t.jsx(Bl,{value:x,children:t.jsx(vd,{externalOpen:a,externalOnClose:n,externalMode:d,externalType:c,externalEventCalendarId:u,externalTaskCalendarId:p,externalSelectedEvent:h,externalSelectedTask:y,hiddenTabs:m,externalOnActionComplete:g,externalContactId:b,children:t.jsx(Jd,{})})})},Xd=e=>{const a=s.useTheme(),n=a?.palette?a:s.createTheme(),r=tr(n);return t.jsx(s.ThemeProvider,{theme:r,children:t.jsx(Ke.I18nextProvider,{i18n:Nt,children:t.jsx(Qd,{...e})})})},xa=s.createTheme({name:"lightBlueIndigo",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#ebf6fd",mainGradient:"linear-gradient(270deg, #215c97, #1976d2)",navMenu:"#1976d2",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#1976d2",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#1976d2",light:"#42a5f5",dark:"#1565c0",contrastText:"#fff"},secondary:{main:"#1976d2",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#ebf6fd",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#1976d2"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#1976d2"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),ar=s.createTheme({name:"lightBlue",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#e3f2fd",mainGradient:"linear-gradient(270deg, #005cb2, #1e88e5)",navMenu:"#4fc354",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#1e88e5",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#1e88e5",light:"#6ab7ff",dark:"#005cb2",contrastText:"#fff"},secondary:{main:"#1e88e5",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#e3f2fd",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#1e88e5"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#1e88e5"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),nr=s.createTheme({name:"lightRed",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#ffebee",mainGradient:"linear-gradient(270deg, #b61827, #ef5350)",navMenu:"#f44336",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ef5350",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ef5350",light:"#ff867c",dark:"#b61827",contrastText:"#fff"},secondary:{main:"#ef5350",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#ffebee",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ef5350"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ef5350"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),rr=s.createTheme({name:"lightGreen",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#e8f5e9",mainGradient:"linear-gradient(270deg, #087f23, #4caf50)",navMenu:"#4fc354",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#4caf50",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#4caf50",light:"#80e27e",dark:"#087f23",contrastText:"#fff"},secondary:{main:"#4caf50",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#e8f5e9",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#4caf50"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#4caf50"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),sr=s.createTheme({name:"lightPink",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fce4ec",mainGradient:"linear-gradient(270deg, #b0003a, #e91e63)",navMenu:"#e91e63",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#e91e63",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#e91e63",light:"#ff6090",dark:"#b0003a",contrastText:"#fff"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fce4ec",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#e91e63"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#e91e63"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),ir=s.createTheme({name:"lightPurple",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#f3e5f5",mainGradient:"linear-gradient(270deg, #6a0080, #9c27b0)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#9c27b0",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#9c27b0",light:"#d05ce3",dark:"#6a0080",contrastText:"#fff"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#f3e5f5",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#9c27b0"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#9c27b0"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),or=s.createTheme({name:"lightTeal",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#e0f2f1",mainGradient:"linear-gradient(270deg, #00675b, #009688)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#009688",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#009688",light:"#52c7b8",dark:"#00675b",contrastText:"#fff"},secondary:{main:"#009688",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#e0f2f1",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#009688"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#009688"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),lr=s.createTheme({name:"lightLime",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#f9fbe7",mainGradient:"linear-gradient(270deg, #99aa00, #cddc39)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#cddc39",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#cddc39",light:"#ffff6e",dark:"#99aa00",contrastText:"#fff"},secondary:{main:"#cddc39",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#f9fbe7",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#cddc39"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#cddc39"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),dr=s.createTheme({name:"lightYellow",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fffde7",mainGradient:"linear-gradient(270deg, #c8b900, #ffeb3b)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ffeb3b",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ffeb3b",light:"#ffff72",dark:"#c8b900",contrastText:"#fff"},secondary:{main:"#ffeb3b",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fffde7",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ffeb3b"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ffeb3b"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),cr=s.createTheme({name:"lightAmber",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fff8e1",mainGradient:"linear-gradient(270deg, #c68400, #ffb300)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ffb300",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ffb300",light:"#ffe54c",dark:"#c68400",contrastText:"#fff"},secondary:{main:"#ffb300",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fff8e1",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ffb300"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ffb300"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),ur=s.createTheme({name:"lightOrange",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fff3e0",mainGradient:"linear-gradient(270deg, #c66900, #ff9800)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ff9800",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ff9800",light:"#ffc947",dark:"#c66900",contrastText:"#fff"},secondary:{main:"#ff9800",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fff3e0",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ff9800"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ff9800"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),pr=s.createTheme({name:"lightBrown",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#efebe9",mainGradient:"linear-gradient(270deg, #4b2c20, #795548)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#795548",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#795548",light:"#a98274",dark:"#4b2c20",contrastText:"#fff"},secondary:{main:"#795548",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#efebe9",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#795548"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#795548"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),fr=s.createTheme({name:"lightGray",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fafafa",mainGradient:"linear-gradient(270deg, #707070, #9e9e9e)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#9e9e9e",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#9e9e9e",light:"#cfcfcf",dark:"#707070",contrastText:"#fff"},secondary:{main:"#9e9e9e",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fafafa",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#9e9e9e"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#9e9e9e"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),gr=s.createTheme({name:"darkBlue",palette:{mode:"dark",primary:{main:"#1f5c8e",light:"#2196f3",dark:"#0d47a1",contrastText:"#fff"},secondary:{light:"#FFEA41",main:"#90caf9",dark:"#DBBE01",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#f44336",light:"#e57373",dark:"#d32f2f"},warning:{main:"#ffa726",light:"#ffb74d",dark:"#f57c00"},info:{main:"#29b6f6",light:"#4fc3f7",dark:"#0288d1"},success:{main:"#66bb6a",light:"#81c784",dark:"#388e3c"},background:{default:"#222B45",mainGradient:"linear-gradient(270deg, #222B45, #222B45)",mainCenter:"#28324e",navMenu:"#222B45",panel:"#2d364e",dropdownMenu:"#484f65",tooltip:"#484f65",accordionHeader:"#2a3249e3",panelHeader:"#2a3249e3",panelCenter:"#484f65",panelGradient:"#384057",paper:"#2d364e"},containerBox:{default:"#2d354e",main:"#2d354e"},action:{active:"rgba(255, 255, 255, 0.2)",hover:"rgba(255, 255, 255, 0.08)",selected:"rgba(255, 255, 255, 0.16)",disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"#EEEEEF",secondary:"#AEB0B4",disabled:"rgba(255, 255, 255, 0.5)",colorMain:"#EEEEEF"},divider:"rgba(255, 255, 255, 0.12)",dropdownBox:"#2d354e",color:{icons:"#fff"},cellHeader:"#505050",Skeleton:{bg:"#f5f5f5"},messageBox:"#1f5c8e",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),mr=s.createTheme({name:"darkBlack",palette:{mode:"dark",background:{default:"#201f1e",mainGradient:"linear-gradient(270deg, #201f1e, #201f1e)",mainCenter:"#252423",navMenu:"#201f1e",panel:"#3B3A39",dropdownMenu:"#585858",tooltip:"#616161eb",accordionHeader:"#25242369",panelHeader:"#3b3a39ba",panelCenter:"#585858",panelGradient:"#454443",paper:"#3B3A39"},primary:{main:"#1976d2",light:"#2196f3",dark:"#42a5f5",contrastText:"#fff"},secondary:{light:"#FFEA41",main:"#90caf9",dark:"#DBBE01",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#f44336",light:"#e57373",dark:"#d32f2f"},warning:{main:"#ffa726",light:"#ffb74d",dark:"#f57c00"},info:{main:"#29b6f6",light:"#4fc3f7",dark:"#0288d1"},success:{main:"#66bb6a",light:"#81c784",dark:"#388e3c"},containerBox:{main:"#ffffffb3",default:"#3B3A39"},action:{active:"rgba(255, 255, 255, 0.2)",hover:"rgba(255, 255, 255, 0.08)",selected:"rgba(255, 255, 255, 0.16)",disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"#EEEEEF",secondary:"#AEB0B4",disabled:"rgba(255, 255, 255, 0.5)",colorMain:"#EEEEEF"},divider:"rgba(255, 255, 255, 0.12)",dropdownBox:"#3B3A39",color:{icons:"#fff"},cellHeader:"#505050",Skeleton:{bg:"#f5f5f5"},messageBox:"#1f5c8e",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),Zd="https://agent-api.trii.app/api/v1/settings/user/setTheme",ec={themeSelected:xa,darkMode:!1,toggleStatus:"idle"},hr=Xa.createAsyncThunk("Theme/updateTheme",async(e,{getState:a})=>{const{uid:n}=a().User.user,r=JSON.stringify({theme:e,uid:n});return(await Zr.put(Zd,r)).data}),yr=Xa.createSlice({name:"Theme",initialState:ec,reducers:{toggleTheme:(e,a)=>{const n=xr(a.payload);Object.assign(e,{themeSelected:n,toggleStatus:"toggled"})},toggleModeTheme:e=>{e.darkMode=!e.darkMode}},extraReducers:e=>{e.addCase(hr.fulfilled,(a,n)=>{const r=xr(n.payload.theme);Object.assign(a,{themeSelected:r})})}}),xr=e=>{switch(e){case"lightBlueIndigo":return xa;case"darkBlack":return mr;case"darkBlue":return gr;case"lightAmber":return cr;case"lightBlue":return ar;case"lightBrown":return pr;case"lightGray":return fr;case"lightGreen":return rr;case"lightLime":return lr;case"lightOrange":return ur;case"lightPink":return sr;case"lightPurple":return ir;case"lightRed":return nr;case"lightTeal":return or;case"lightYellow":return dr;default:return xa}},tc=e=>["lightBlueIndigo","darkBlack","darkBlue","lightAmber","lightBlue","lightBrown","lightGray","lightGreen","lightLime","lightOrange","lightPink","lightPurple","lightRed","lightTeal","lightYellow"].includes(e),{toggleTheme:ac,toggleModeTheme:nc}=yr.actions,rc=e=>e.Theme.toggleStatus,sc=e=>e.Theme.themeSelected,ic=e=>e.Theme.darkMode;yr.reducer,exports.ContactInfoPopup=rn,exports.EditContactModal=Fl,exports.EventsDialog=Xd,exports.MuiComponentsConfig=tr,exports.darkBlack=mr,exports.darkBlue=gr,exports.i18n=Nt,exports.isValidThemeName=tc,exports.lightAmber=cr,exports.lightBlue=ar,exports.lightBlueIndigo=xa,exports.lightBrown=pr,exports.lightGray=fr,exports.lightGreen=rr,exports.lightLime=lr,exports.lightOrange=ur,exports.lightPink=sr,exports.lightPurple=ir,exports.lightRed=nr,exports.lightTeal=or,exports.lightYellow=dr,exports.selectThemeToggleStatus=rc,exports.selectedDarkTheme=ic,exports.selectedTheme=sc,exports.toggleModeTheme=nc,exports.toggleTheme=ac,exports.updateTheme=hr;
20
+ `,Bd=s.styled(s.Box)(()=>({display:"flex",justifyContent:"space-between",alignItems:"baseline",userSelect:"none"})),$d=({notificationsField:e,disabled:a})=>{const n=Be(),{addNotification:r,deleteNotification:o,handleReminderChange:i,handleTimeFieldChange:d,handleTimePeriodChange:c}=e.action,u=e.notifications.length>0;return t.jsxs(Fd,{children:[t.jsxs(Bd,{children:[t.jsx(s.Typography,{variant:"subtitle2",sx:{userSelect:"none"},children:n("calendarView.reminders.title")}),!a&&t.jsx(s.Button,{disabled:a,startIcon:t.jsx(Ja,{}),size:"small",variant:"outlined",onClick:r,color:"secondary",children:n("calendarView.reminders.addReminder")})]}),t.jsx(s.Box,{sx:{pt:1},children:u?e.notifications.map(p=>t.jsx(Ad,{data:p,deleteHandler:o,sendToContactHandler:i,timePeriodHandler:c,timeValueHandler:d,disabled:a},p.id)):a?t.jsx(s.Typography,{variant:"body1",sx:{py:.5},children:"-"}):null})]})},Kn=({descriptionField:e,disabled:a})=>{const n=Be(),{value:r,type:o,...i}=e.attributes,d=r||"";return a?t.jsx(ze,{title:n("global.description"),children:t.jsx(s.Typography,{variant:"body2",sx:{py:.5,whiteSpace:"pre-wrap",color:c=>c.palette.text.secondary,fontSize:"0.9rem"},children:d||"-"})}):t.jsx(ze,{title:n("global.description"),children:t.jsx(s.TextField,{...i,value:d,disabled:a,size:"small",multiline:!0,maxRows:5,fullWidth:!0,variant:"outlined"})})},Md=({onPlaceSelected:e})=>{const a=l.useRef(null),n=l.useRef(null),r=l.useRef(null),o=l.useRef(null),[i,d]=l.useState([]),[c,u]=l.useState(!1),p=Be();l.useEffect(()=>{if(!a.current)return;const x=()=>{if(!window.google?.maps?.places)return console.warn("Google Places API no est\xE1 disponible a\xFAn"),!1;n.current=new window.google.maps.places.AutocompleteService;const g=document.createElement("div");return r.current=new window.google.maps.places.PlacesService(g),o.current=new window.google.maps.places.AutocompleteSessionToken,!0};if(!x()){const g=setTimeout(()=>{x()},500);return()=>clearTimeout(g)}},[]);const m=x=>{const g=x.target.value;if(!g||g.length<3||!n.current){d([]),u(!1);return}n.current.getPlacePredictions({input:g,types:["geocode"],sessionToken:o.current||void 0},(y,w)=>{w===window.google.maps.places.PlacesServiceStatus.OK&&y?(d(y),u(!0)):(d([]),u(!1))})},h=(x,g)=>{r.current&&r.current.getDetails({placeId:x,fields:["geometry","formatted_address"],sessionToken:o.current||void 0},(y,w)=>{if(w===window.google.maps.places.PlacesServiceStatus.OK&&y?.geometry?.location){const b=y.geometry.location.lat(),C=y.geometry.location.lng(),S=y.formatted_address??g;e({lat:b,lng:C},S),a.current&&(a.current.value=S),u(!1),d([]),o.current=new window.google.maps.places.AutocompleteSessionToken}})};return l.useEffect(()=>{const x=g=>{a.current&&!a.current.contains(g.target)&&u(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]),t.jsxs("div",{style:{position:"absolute",width:"100%",maxWidth:300,margin:"0 auto",zIndex:13e3,top:"10px",left:"10px"},children:[t.jsx("input",{ref:a,placeholder:p("global.searchLocation","Buscar en Google Maps"),onChange:m,onFocus:()=>i.length>0&&u(!0),style:{width:"100%",padding:"12px 16px 5px",borderRadius:"24px",border:"1px solid #ccc",backgroundColor:"white",fontSize:"15px",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",outline:"none",position:"relative",zIndex:13e3}}),c&&i.length>0&&t.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:"white",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)",marginTop:"4px",maxHeight:"300px",overflowY:"auto",zIndex:13001},children:i.map(x=>t.jsxs("div",{onClick:()=>h(x.place_id,x.description),style:{padding:"12px 16px",cursor:"pointer",borderBottom:"1px solid #f0f0f0",fontSize:"14px",transition:"background-color 0.2s"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f5f5f5"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="white"},children:[t.jsx("div",{style:{fontWeight:500},children:x.structured_formatting.main_text}),t.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:"2px"},children:x.structured_formatting.secondary_text})]},x.place_id))})]})},Jn="AIzaSyAQ1bUt3y6UoAhbi5-HAwYwaFx71pAiaKU",Qn=["places"],_a={apiKey:Jn,libraries:Qn,loading:"async"},xa=()=>!!(window.google?.maps?.Map&&window.google?.maps?.Marker&&window.google?.maps?.Geocoder&&window.google?.maps?.places),Xn=(e=Jn,a=Qn)=>{if(xa())return Promise.resolve();const n=()=>{document.querySelectorAll('script[src*="maps.googleapis.com"]').forEach(r=>{r.parentNode?.removeChild(r)})};return document.getElementById("google-maps-script")?new Promise((r,o)=>{let i=0;const d=100,c=setInterval(()=>{i++,xa()?(clearInterval(c),r()):i>=d&&(clearInterval(c),n(),Xn(e,a).then(r).catch(o))},100)}):new Promise((r,o)=>{try{n();const i="initGoogleMaps";window[i]=()=>{xa()?r():setTimeout(()=>{xa()||console.warn("Google Maps API se carg\xF3 pero algunos componentes no est\xE1n disponibles"),r()},500)};const d=document.createElement("script");d.id="google-maps-script",d.type="text/javascript";const c=Array.isArray(a)?a.join(","):a;d.src=`https://maps.googleapis.com/maps/api/js?key=${e}&libraries=${c}&callback=${i}&loading=async`,d.async=!0,d.defer=!0,d.onerror=()=>{delete window[i],o(new Error("Error al cargar Google Maps API"))},document.head.appendChild(d)}catch(i){o(i)}})},Kt=(e,a,n=18,r=400,o=400,i="red",d=_a.apiKey)=>`https://maps.googleapis.com/maps/api/staticmap?center=${e},${a}&zoom=${n}&size=${r}x${o}&markers=color:${i}%7Clabel:A%7C${e},${a}&key=${d}`,Pd=({onLocationChange:e,initialLocation:a})=>{const n=l.useRef(null),r=l.useRef(null),o=l.useRef(null),i=l.useRef(null),[d,c]=l.useState(!0),[u,p]=l.useState(!1),[m,h]=l.useState(a||null),x=18,g=l.useCallback(S=>{h(S),e(S)},[e]);l.useEffect(()=>{let S=!0;(async()=>{try{if(await Xn(_a.apiKey,_a.libraries),!window.google?.maps?.Map||!window.google?.maps?.Geocoder){console.error("Google Maps APIs no est\xE1n completamente disponibles"),c(!1);return}window.google?.maps?.Geocoder&&(i.current=new window.google.maps.Geocoder),c(!1)}catch(j){console.error("Error al cargar Google Maps:",j),c(!1)}})(),a||navigator.geolocation.getCurrentPosition(j=>{const I=j.coords.latitude,D=j.coords.longitude,E=I.toString(),B=D.toString(),A=Kt(I,D,x);g({lat:E,lng:B,title:"",description:"",url:A})},j=>{console.error("Error getting location:",j);const I=-34.6037,D=-58.3816;g({lat:I.toString(),lng:D.toString(),title:"",description:"",url:Kt(I,D,x)})})},[a,g,x]),l.useEffect(()=>{if(d||r.current)return;const S=setTimeout(()=>{r.current||y()},50);return()=>clearTimeout(S)},[d]),l.useEffect(()=>{u&&m&&b()},[u,m]),l.useEffect(()=>()=>{o.current&&(o.current.setMap(null),o.current=null)},[]);const y=()=>{if(!n.current){console.warn("Contenedor del mapa no disponible");return}if(!window.google?.maps){console.warn("Google Maps API no disponible a\xFAn");return}try{const S={zoom:x,disableDefaultUI:!1,zoomControl:!0,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1};r.current=new window.google.maps.Map(n.current,S),r.current.addListener("click",j=>{w(j)}),p(!0)}catch(S){console.error("Error inicializando mapa:",S)}},w=S=>{if(!S.latLng||!i.current)return;const j={lat:S.latLng.lat(),lng:S.latLng.lng()};o.current?o.current.setPosition(j):r.current&&(o.current=new window.google.maps.Marker({position:j,map:r.current})),i.current.geocode({location:j},(I,D)=>{if(D==="OK"&&I&&I[0]){const E=I[0].formatted_address,B=Kt(j.lat,j.lng,x);g({lat:j.lat.toString(),lng:j.lng.toString(),title:E||"",description:"",url:B})}else{const E=Kt(j.lat,j.lng,x);g({lat:j.lat.toString(),lng:j.lng.toString(),title:`${j.lat.toFixed(6)}, ${j.lng.toFixed(6)}`,description:"",url:E})}})},b=()=>{if(!(!r.current||!m))try{const S={lat:parseFloat(m.lat),lng:parseFloat(m.lng)};r.current.setCenter(S),o.current?o.current.setPosition(S):o.current=new window.google.maps.Marker({position:S,map:r.current})}catch(S){console.error("Error actualizando mapa:",S)}},C=(S,j)=>{const I=Kt(S.lat,S.lng,x);g({lat:S.lat.toString(),lng:S.lng.toString(),title:j||"",description:"",url:I})};return d?t.jsx(s.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:t.jsx(s.CircularProgress,{})}):t.jsxs(s.Box,{sx:{position:"relative",height:"calc(100vh - 305px)"},children:[t.jsx(Md,{onPlaceSelected:C}),t.jsx("div",{style:{height:"100%"},ref:n})]})},Ud=({open:e,onClose:a,onSelectLocation:n,initialAddress:r})=>{const o=Be(),[i,d]=l.useState(null),c=l.useRef(null);l.useEffect(()=>{e||d(null)},[e]),l.useEffect(()=>{c.current&&i&&(c.current.scrollTop=c.current.scrollHeight/4)},[i]);const u=l.useCallback(m=>{d(m)},[]),p=l.useCallback(()=>{i&&(n(i.title||`${i.lat}, ${i.lng}`,i.lat,i.lng),a())},[i,n,a]);return t.jsxs(s.Dialog,{open:e,onClose:a,maxWidth:"md",fullWidth:!0,disableEnforceFocus:!0,disableAutoFocus:!0,PaperProps:{sx:{maxHeight:"80vh",height:"80vh"}},sx:{"& .MuiDialog-paper":{backgroundColor:m=>m.palette.background.panel}},children:[t.jsxs(s.Box,{sx:{position:"relative",display:"flex",alignItems:"center",p:2},children:[t.jsx(s.Typography,{variant:"body1",sx:{flex:1},children:o("global.selectLocation","Seleccionar ubicaci\xF3n")}),t.jsx(s.IconButton,{"aria-label":"close",onClick:a,size:"small",children:t.jsx(Ga,{fontSize:"small"})})]}),t.jsx(s.DialogContent,{sx:{p:0,display:"flex",flexDirection:"column",height:"100%"},children:t.jsxs(s.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflow:"hidden",width:"100%",height:"100%",position:"relative"},children:[t.jsx(s.Box,{ref:c,sx:{width:"100%",flex:1,overflow:"auto",zIndex:1},children:t.jsx(Pd,{onLocationChange:u,initialLocation:void 0})}),t.jsx(s.Divider,{sx:{width:"100%",padding:0}}),t.jsxs(s.Box,{sx:{width:"100%",display:"flex",justifyContent:"flex-end",gap:".5rem",p:2},children:[t.jsx(s.Button,{variant:"outlined",color:"error",size:"small",sx:{borderRadius:"0.5rem"},onClick:a,children:o("global.cancel","Cancelar")}),t.jsx(s.Button,{variant:"outlined",color:"secondary",size:"small",sx:{borderRadius:"0.5rem"},onClick:p,disabled:!i,children:o("global.selectLocation","Seleccionar ubicaci\xF3n")})]})]})})]})},Rd=({locationField:e,disabled:a})=>{const n=Be(),[r,o]=l.useState(!1),{value:i,type:d,...c}=e.attributes,u=i||"",p=()=>{a||o(!0)},m=()=>{o(!1)},h=x=>{e.actions.changeValue(x)};return a?t.jsx(s.Box,{children:t.jsx(ze,{title:n("global.location","Ubicaci\xF3n"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[u&&t.jsx(Xa,{sx:{opacity:.5,color:x=>x.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"body1",sx:{color:x=>x.palette.text.secondary,fontSize:"0.9rem"},children:u||"-"})]})})}):t.jsxs(s.Box,{children:[t.jsx(ze,{title:n("global.location","Ubicaci\xF3n"),children:t.jsx(s.TextField,{...c,value:u,disabled:a,size:"small",fullWidth:!0,variant:"outlined",placeholder:n("global.addLocation","Agregar ubicaci\xF3n"),onClick:p,InputProps:{startAdornment:t.jsx(Xa,{sx:{mr:1,opacity:.5},fontSize:"small"}),readOnly:!0},sx:{cursor:a?"default":"pointer","& .MuiInputBase-input":{cursor:a?"default":"pointer"}}})}),t.jsx(Ud,{open:r,onClose:m,onSelectLocation:h,initialAddress:u})]})},Nd=({handleScroll:e,contactList:a,handleSelectContact:n,selectedContactIds:r,search:o})=>{const i=Be(),d=s.useTheme();return t.jsx(s.List,{sx:{width:"100%",height:"100%",overflow:"auto",border:`1px solid ${d.palette.divider}`,borderTop:"none",backgroundColor:d.palette.background.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12))"},onScroll:e,children:o&&a?.map(c=>t.jsxs(s.ListItemButton,{sx:{width:"100%"},onClick:()=>n(c),selected:r.includes(c.id),children:[t.jsx(s.ListItemIcon,{children:t.jsx(Ae.Person,{sx:{color:u=>u.palette.text.disabled}})}),t.jsx(s.ListItemText,{primary:i(c.name),secondary:c?.phone})]},c.id))})},Ld={format:"IContact",total:0,lastPage:1,perPage:10,order:"ASC",orderColumn:"Id"};function Od(e){const a=l.useRef(null),n=l.useRef(null),[r,o]=l.useState([]),[i,d]=l.useState(!1),[c,u]=l.useState(!1),[p,m]=l.useState(!1),[h,x]=l.useState(!1),[g,y]=l.useState(1),[w,b]=l.useState(!1),C=l.useCallback(()=>{n.current?.abort(),n.current=null,a.current&&(clearTimeout(a.current),a.current=null),d(!1),b(!1),y(1),x(!1),o([])},[]),S=E=>E.filter(B=>!!B?.id),j=l.useCallback(async({query:E,page:B})=>{if(!e)return;n.current?.abort();const A=new AbortController;n.current=A,u(!0);try{const k={...Ld,currentPage:B,filter:[{value:E,column:"name",condition:""}]},N=await Cd({baseUrl:e.baseUrl,spaceId:e.spaceId,pagination:k,signal:A.signal});if(A.signal.aborted)return;const _=S(N?.contactos??[]);d(!0);const V=N?.paginacion?.total??0;o(G=>{const $=B===1?_:(()=>{const Q=new Map;for(const X of G)Q.set(X.id,X);for(const X of _)Q.set(X.id,X);return Array.from(Q.values())})();return V&&$.length>=V&&b(!0),$})}finally{u(!1),m(!1),x(!1)}},[e]),I=l.useCallback(E=>{C(),E&&(a.current&&(clearTimeout(a.current),a.current=null),m(!0),a.current=setTimeout(()=>{j({query:E,page:1})},800))},[j,C]),D=l.useCallback((E,B)=>{const A=E.target;if(!(A.scrollHeight-A.scrollTop-A.clientHeight<1)||w||c||!B)return;const k=g+1;x(!0),y(k),j({query:B,page:k})},[w,c,g,j]);return{contactList:r,hasSearched:i,isLoading:c,isLoadingTimer:p,isNextPage:h,handleQueryChanged:I,handleScroll:D,resetSearchState:C}}const Zn=({linkContactsHandler:e,disabled:a=!1})=>{const n=Be(),r=Nn(),o=l.useRef(null),[i,d]=l.useState(null),{action:{handleSearchChange:c,handleSelectContact:u,handleRemoveContact:p},state:{search:m,selectedContacts:h}}=e,{contactList:x,hasSearched:g,isLoading:y,isLoadingTimer:w,handleQueryChanged:b,handleScroll:C,resetSearchState:S}=Od(r),j=m||"",I=!!i&&j.length>0&&!a,D=h.map(k=>k.id);l.useEffect(()=>{j?b(j):S()},[j,b,S]);const E=k=>{c(k),k&&!i?d(o.current):k||d(null)},B=k=>{u(k),d(null),S()},A=()=>{d(null)};return a?t.jsx(ze,{title:n("global.linkContacts"),children:h.length>0?t.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,pt:.5},children:h.map(k=>t.jsx(s.Chip,{icon:t.jsx(Ta,{fontSize:"small"}),label:k.name,size:"small",variant:"outlined"},k.id))}):t.jsx(s.Typography,{variant:"body1",sx:{py:.5},children:"-"})}):t.jsx(s.ClickAwayListener,{onClickAway:A,children:t.jsxs(s.Box,{children:[t.jsxs(ze,{title:n("global.linkContacts"),children:[t.jsx(s.TextField,{ref:o,fullWidth:!0,size:"small",placeholder:n("global.searchContacts"),value:j,onChange:k=>E(k.target.value),onFocus:()=>{j&&d(o.current)},InputProps:{startAdornment:t.jsx(Ta,{sx:{mr:1,opacity:.5},fontSize:"small"}),endAdornment:y||w?t.jsx(s.CircularProgress,{size:18,sx:{mr:1}}):null}}),h.length>0&&t.jsx(s.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mt:1},children:h.map(k=>t.jsx(s.Chip,{icon:t.jsx(Ta,{fontSize:"small"}),label:k.name,size:"small",onDelete:()=>p(k.id)},k.id))})]}),t.jsx(s.Popper,{open:I,anchorEl:i,placement:"bottom-start",style:{width:i?.offsetWidth||"auto",zIndex:1300},children:t.jsxs(s.Paper,{elevation:8,sx:{mt:.5,maxHeight:300,overflow:"hidden"},children:[g&&x.length>0&&t.jsx(Nd,{handleScroll:k=>C(k,j),contactList:x,handleSelectContact:B,selectedContactIds:D,search:j}),g&&x.length===0&&t.jsx(s.Box,{sx:{p:2,textAlign:"center",color:"text.secondary"},children:t.jsx(s.Typography,{variant:"body2",children:n("global.noResults","No se encontraron resultados")})})]})})]})})},zd=({isFinalized:e})=>{const{eventDialog:{handleClose:a},handleCreateEvent:n,dialogMode:r,handleStartEditingEvent:o,handleSaveUpdatedEvent:i,handleEndEvent:d,dialogType:c,handleCreateTask:u,handleSaveUpdatedTask:p,selectedTask:m,handleToggleTaskCompleted:h,event:x,task:g,eventCalendarId:y,taskCalendarId:w,isCreatingEvent:b,isUpdatingEvent:C,isCreatingTask:S,isUpdatingTask:j}=l.useContext(Ra),I=Be(),D=c==="event",E=b,B=C,A=!1,k=S,N=j,_=()=>{D?n():u()},V=(()=>{if(r==="view")return o;if(r==="edit")return D?()=>i?.():()=>p?.();if(r==="create")return _})(),G=I(r==="view"?D?"global.editEvent":"global.editTask":r==="edit"?D?"global.saveEvent":"global.saveTask":D?"global.createEvent":"global.createTask"),$=D?E||B:k||N,Q=()=>{if(r==="view")return!0;const M=D?x:g,O=D?y:w;return M?.titleField?.attributes?.value?.trim().length>0&&!!O},X=D?E||B||e||!Q():k||N||e||!Q(),U=!D&&r==="view",T=m?.isCompleted||!1;return U?t.jsx(s.DialogActions,{children:t.jsx(at.LoadingButton,{startIcon:t.jsx(Ae.CheckCircleOutline,{}),size:"small",loading:N,disabled:N,onClick:h,variant:"contained",color:T?"inherit":"primary",children:T?I("global.markAsIncomplete","Marcar como incompleta"):I("global.markAsCompleted","Marcar como completada")})}):t.jsxs(s.DialogActions,{children:[t.jsx(s.Button,{variant:"outlined",size:"small",onClick:a,color:"secondary",children:I("global.cancel")}),D&&(r==="edit"||r==="view")&&t.jsx(at.LoadingButton,{startIcon:t.jsx(Ae.EventAvailable,{}),size:"small",disabled:e,loading:A,onClick:d,variant:"contained",children:I("global.finalizeEvent")}),t.jsx(at.LoadingButton,{startIcon:t.jsx(Ae.EditCalendar,{}),size:"small",loading:$,disabled:X,onClick:V,variant:"contained",children:G})]})},er={textTransform:"none",borderRadius:2,minHeight:34,px:1.5,fontSize:13,fontWeight:500,lineHeight:1.1},Wd=({value:e,onChange:a,labels:n})=>t.jsxs(s.Box,{sx:{display:"flex",gap:1},children:[t.jsx(s.Button,{size:"small",onClick:()=>a("event"),variant:e==="event"?"contained":"text",disableElevation:!0,color:"primary",sx:{...er},children:n.event}),t.jsx(s.Button,{size:"small",onClick:()=>a("task"),variant:e==="task"?"contained":"text",disableElevation:!0,sx:{...er},color:"primary",children:n.task})]}),_d="DD/MM/YYYY",Vd="HH:mm",Hd=({selectedDateTime:e,handleSelect:a,disabled:n,isError:r=!1,hideLabel:o=!1})=>{const i=Be(),d=u=>{if(!u)return;const p=u.hour(e.hour()).minute(e.minute());a(p)},c=u=>{if(!u)return;const p=e.hour(u.hour()).minute(u.minute());a(p)};return n?t.jsxs(ha,{children:[!o&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:i("global.date")}),t.jsxs(s.Box,{children:[t.jsx(s.Typography,{variant:"body1",sx:{mb:1},children:e.format(_d)}),t.jsx(s.Typography,{variant:"body1",children:e.format(Vd)})]})]}):t.jsxs(ha,{children:[!o&&t.jsx("span",{style:{userSelect:"none",marginBottom:10},children:i("global.date")}),t.jsx(Oa,{children:t.jsxs(Je.LocalizationProvider,{dateAdapter:Qa.AdapterDayjs,children:[t.jsx(Je.DatePicker,{disabled:n,value:e,onChange:d,slotProps:{textField:()=>({label:i("global.date"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:u=>u.palette.background.panel}}}},sx:{alignSelf:"baseline",flex:1},minDate:K()}),t.jsx(za,{variant:"body1",children:"_"}),t.jsx(Je.TimePicker,{disabled:n,value:e,onChange:c,ampm:!1,slotProps:{textField:()=>({label:i("global.time"),size:"small",className:"smallInput"}),popper:{sx:{"& .MuiPaper-root":{backgroundColor:u=>u.palette.background.panel}}}},sx:{alignSelf:"baseline",flex:1}})]})}),t.jsx(s.Fade,{in:r,children:t.jsx(s.Typography,{color:"red",variant:"caption",children:i("conversations.sidebar.events.errorDate")})})]})},tr=({disabled:e,calendars:a,userId:n,value:r,onChange:o,loading:i=!1})=>{const d=Be(),c=l.useMemo(()=>a??[],[a]),u=l.useMemo(()=>{const p=c.find(m=>m.id===r);return e&&r&&!p&&!i&&console.warn("TaskCalendarSelect: Calendario no encontrado",{calendarId:r,availableCalendars:c.map(m=>({id:m.id,title:m.title})),totalCalendars:c.length}),p??null},[c,r,e,i]);if(e){if(i)return t.jsx(ze,{title:d("global.calendar"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[t.jsx(s.CircularProgress,{size:16,sx:{opacity:.5}}),t.jsx(s.Typography,{variant:"subtitle2",sx:{color:m=>m.palette.text.secondary,fontSize:"0.9rem"},children:d("global.loading","Cargando...")})]})});const p=u?u.title:r?d("global.calendarNotFound","Calendario no disponible"):"-";return t.jsx(ze,{title:d("global.calendar"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[u&&t.jsx(Qr,{sx:{opacity:.5,color:m=>m.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"subtitle2",sx:{color:m=>m.palette.text.secondary,fontSize:"0.9rem"},children:p})]})})}return t.jsx(ze,{title:d("global.calendar"),children:t.jsx(s.Autocomplete,{disabled:e||i,size:"small",fullWidth:!0,options:c,value:u,onChange:(p,m)=>o(m?.id??""),getOptionLabel:p=>p?.title??"",isOptionEqualToValue:(p,m)=>p.id===m.id,loading:i,groupBy:n?p=>p.userId===n?d("calendarView.myCalendars"):d("calendarView.othersCalendars"):void 0,renderGroup:p=>t.jsxs("li",{children:[t.jsx(s.ListSubheader,{component:"div",sx:{lineHeight:"32px",fontSize:"0.75rem",fontWeight:600,color:"text.secondary",backgroundColor:m=>m.palette.background.panel},children:p.group}),t.jsx("ul",{style:{padding:0},children:p.children})]},p.key),slotProps:{popper:{sx:{zIndex:1400}},paper:{sx:{backgroundColor:p=>p.palette.background.panel}}},renderInput:p=>t.jsx(s.TextField,{...p,placeholder:d("global.selectCalendar"),InputProps:{...p.InputProps,endAdornment:t.jsxs(t.Fragment,{children:[i?t.jsx(s.CircularProgress,{color:"inherit",size:20}):null,p.InputProps.endAdornment]})}})})})},Gd=({checked:e,onChange:a,disabled:n})=>{const r=Be();return t.jsx(s.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx(s.FormControlLabel,{control:t.jsx(s.Checkbox,{checked:e,onChange:o=>a(o.target.checked),disabled:n,color:"secondary"}),label:r("global.allDay","Todo el d\xEDa")})})},Yd=({colorField:e,disabled:a,onColorChange:n})=>{const r=Be(),o=e.attributes.value||"#1976d2",i=(c=>{if(c.startsWith("#"))return c;const u=c.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(u&&u[1]&&u[2]&&u[3]){const p=parseInt(u[1]),m=parseInt(u[2]),h=parseInt(u[3]),x=g=>{const y=g.toString(16);return y.length===1?"0"+y:y};return`#${x(p)}${x(m)}${x(h)}`}return"#1976d2"})(o),d=c=>{const u=c.target.value;n?n(u):e.actions.changeValue(u)};return a?t.jsx(ze,{title:r("global.color","Color"),children:t.jsxs(s.Box,{sx:{display:"flex",gap:1,alignItems:"center"},children:[t.jsx(s.Box,{sx:{width:40,height:40,backgroundColor:i,border:"1px solid rgba(0, 0, 0, 0.23)",borderRadius:1}}),t.jsx(s.Typography,{variant:"body2",sx:{color:"text.secondary"},children:i})]})}):t.jsx(ze,{title:r("global.color","Color"),children:t.jsx(s.Box,{sx:{display:"flex",gap:1,alignItems:"center"},children:t.jsx("input",{type:"color",value:i,onChange:d,disabled:a,style:{width:60,height:40,border:"1px solid rgba(0, 0, 0, 0.23)",borderRadius:4,cursor:a?"not-allowed":"pointer"}})})})},ar=[{value:"",label:"global.noRepeat"},{value:"FREQ=DAILY",label:"global.everyDay"},{value:"FREQ=WEEKLY",label:"global.everyWeek"},{value:"FREQ=MONTHLY",label:"global.everyMonth"},{value:"FREQ=YEARLY",label:"global.everyYear"},{value:"FREQ=DAILY;INTERVAL=2",label:"global.everyTwoDays"},{value:"FREQ=WEEKLY;INTERVAL=2",label:"global.everyTwoWeeks"},{value:"FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR",label:"global.everyWeekday"}],qd=({value:e,onChange:a,disabled:n,hideLabel:r=!1})=>{const o=Be(),i=p=>{a(p.target.value)},d=l.useMemo(()=>ar.map(p=>t.jsx(s.MenuItem,{value:p.value,children:o(p.label,p.label)},p.value)),[o]),c=l.useMemo(()=>{const p=ar.find(m=>m.value===e);return p?o(p.label,p.label):o("global.noRepeat")},[e,o]);if(n)return r?t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(Ia,{sx:{opacity:.5,color:p=>p.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"body2",children:c})]}):t.jsx(ze,{title:o("global.recurrence","Recurrencia"),children:t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",gap:1,py:.5},children:[t.jsx(Ia,{sx:{opacity:.5,color:p=>p.palette.text.secondary},fontSize:"small"}),t.jsx(s.Typography,{variant:"body1",children:c})]})});const u=t.jsx(s.Select,{disabled:n,size:"small",variant:"outlined",fullWidth:!0,value:e||"",onChange:i,startAdornment:t.jsx(Ia,{sx:{mr:1,ml:1,opacity:.5},fontSize:"small"}),MenuProps:{PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}}},children:d});return r?u:t.jsx(ze,{title:o("global.recurrence","Recurrencia"),children:u})},Kd=({open:e,onClose:a,onConfirm:n,itemTitle:r,itemType:o})=>{const{t:i}=Ke.useTranslation(),d=()=>{n(),a()},c=o==="event"?i("calendar.deleteEvent","Eliminar evento"):i("calendar.deleteTask","Eliminar tarea"),u=o==="event"?i("calendar.confirmDeleteEvent","\xBFEst\xE1s seguro de que quer\xE9s eliminar este evento?"):i("calendar.confirmDeleteTask","\xBFEst\xE1s seguro de que quer\xE9s eliminar esta tarea?");return t.jsxs(s.Dialog,{open:e,onClose:a,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}},children:[t.jsxs(s.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(Xr,{color:"warning"}),c]}),t.jsxs(s.DialogContent,{children:[t.jsx(s.Typography,{variant:"body2",sx:{mb:2},children:u}),r&&t.jsx(s.Box,{sx:{p:1.5,bgcolor:"action.hover",borderRadius:1,borderLeft:3,borderColor:"warning.main"},children:t.jsxs(s.Typography,{variant:"body2",sx:{fontWeight:500},children:['"',r,'"']})})]}),t.jsxs(s.DialogActions,{sx:{px:3,pb:2},children:[t.jsx(s.Button,{onClick:a,variant:"outlined",color:"inherit",sx:{borderRadius:"8px"},children:i("global.cancel","Cancelar")}),t.jsx(s.Button,{onClick:d,variant:"contained",color:"error",sx:{borderRadius:"8px"},children:i("global.delete","Eliminar")})]})]})},Jd=({open:e,onClose:a,onConfirm:n,eventTitle:r})=>{const{t:o}=Ke.useTranslation(),[i,d]=l.useState("single"),c=()=>{n(i==="all"),a()},u=()=>{d("single"),a()};return t.jsxs(s.Dialog,{open:e,onClose:u,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}},children:[t.jsx(s.DialogTitle,{children:o("calendar.deleteRecurringEvent","Borrar evento recurrente")}),t.jsxs(s.DialogContent,{children:[r&&t.jsxs(s.Box,{sx:{mb:2,color:"text.secondary",fontSize:"0.875rem"},children:['"',r,'"']}),t.jsx(s.FormControl,{component:"fieldset",fullWidth:!0,children:t.jsxs(s.RadioGroup,{value:i,onChange:p=>d(p.target.value),children:[t.jsx(s.FormControlLabel,{value:"single",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.deleteThisEvent","Este evento"),sx:{mb:1}}),t.jsx(s.FormControlLabel,{value:"all",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.deleteAllEvents","Todos los eventos")})]})})]}),t.jsxs(s.DialogActions,{sx:{px:3,pb:2},children:[t.jsx(s.Button,{onClick:u,variant:"outlined",color:"inherit",sx:{borderRadius:"8px"},children:o("global.cancel","Cancelar")}),t.jsx(s.Button,{onClick:c,variant:"contained",color:"error",sx:{borderRadius:"8px"},children:o("global.delete","Eliminar")})]})]})},Qd=({open:e,onClose:a,onConfirm:n,eventTitle:r})=>{const{t:o}=Ke.useTranslation(),[i,d]=l.useState("single"),c=()=>{n(i==="all"),a()},u=()=>{d("single"),a()};return t.jsxs(s.Dialog,{open:e,onClose:u,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{backgroundColor:p=>p.palette.background.panel}},children:[t.jsx(s.DialogTitle,{children:o("calendar.editRecurringEvent","Editar evento recurrente")}),t.jsxs(s.DialogContent,{children:[r&&t.jsxs(s.Box,{sx:{mb:2,color:"text.secondary",fontSize:"0.875rem"},children:['"',r,'"']}),t.jsx(s.FormControl,{component:"fieldset",fullWidth:!0,children:t.jsxs(s.RadioGroup,{value:i,onChange:p=>d(p.target.value),children:[t.jsx(s.FormControlLabel,{value:"single",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.editThisEvent","Este evento"),sx:{mb:1}}),t.jsx(s.FormControlLabel,{value:"all",control:t.jsx(s.Radio,{color:"secondary"}),label:o("calendar.editAllEvents","Todos los eventos")})]})})]}),t.jsxs(s.DialogActions,{sx:{px:3,pb:2},children:[t.jsx(s.Button,{onClick:u,variant:"outlined",color:"inherit",sx:{borderRadius:"8px"},children:o("global.cancel","Cancelar")}),t.jsx(s.Button,{onClick:c,variant:"contained",color:"secondary",sx:{borderRadius:"8px"},children:o("global.save","Guardar")})]})]})},Xd=()=>{const e=Be(),{event:a,task:n,dialogMode:r,selectedEvent:o,handleDeleteEvent:i,handleStartEditingEvent:d,handleDuplicateItem:c,dialogType:u,setDialogType:p,selectedTask:m,taskCalendarId:h,setTaskCalendarId:x,eventCalendarId:g,setEventCalendarId:y,myCalendars:w,otherCalendars:b,isLoadingCalendars:C,handleDeleteTask:S,userManuallyChangedColor:j,setUserManuallyChangedColor:I,eventDialog:{open:D,handleClose:E},confirmDeleteDialog:B,handleConfirmDelete:A,deleteRecurringDialog:k,handleConfirmDeleteRecurring:N,editRecurringDialog:_,handleConfirmEditRecurring:V,hiddenTabs:G,savingSnackbar:$,handleCloseSnackbar:Q}=l.useContext(Ra);if(!a||!n)return t.jsx(s.Modal,{open:D,onClose:E,closeAfterTransition:!0,slots:{backdrop:s.Backdrop},slotProps:{backdrop:{timeout:200}},children:t.jsx(s.Fade,{in:D,timeout:200,children:t.jsx(s.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"min(640px, calc(100vw - 32px))",height:"min(560px, calc(100vh - 64px))",bgcolor:Y=>Y.palette.background.panel,borderRadius:3,boxShadow:24,outline:0,p:3,overflow:"visible"}})})});const X=u==="event",U=X?a:n,T=X?o:m,M=l.useRef(null),O=l.useRef(null);l.useEffect(()=>{D||(M.current=null,O.current=null)},[D]);const{titleField:R,descriptionField:H,date:W,linkContact:ae}=U,de=X?a.notifications:null,ie=X?{locationField:a.locationField,colorField:a.colorField,allDay:a.allDay,setAllDay:a.setAllDay,isPrivate:a.isPrivate,setIsPrivate:a.setIsPrivate,recurrenceRule:a.recurrenceRule,setRecurrenceRule:a.setRecurrenceRule}:null,Se=e(r==="edit"?X?"global.editEvent":"global.editTask":r==="create"?X?"global.createEvent":"global.createTask":X?"global.showEvent":"global.showTask"),ve=(r==="edit"||r==="view")&&!!T?.id,Z=r==="view";l.useEffect(()=>{if(r!=="create"||u!=="event"||!D||j||!g)return;const Y=w.find(pe=>pe.id===g);Y?.color&&a.colorField.actions.changeValue(Y.color)},[r,u,D,g,j,w]),l.useEffect(()=>{if(!D||u!=="event"||r!=="edit")return;const Y=W.state.selectedStartDate.isAfter(W.state.selectedEndDate)&&!W.state.selectedStartDate.isSame(W.state.selectedEndDate,"minute");O.current!==Y&&(O.current=Y,W.action.setError(Y))},[D,u,r,W.state.selectedStartDate.valueOf(),W.state.selectedEndDate.valueOf()]),l.useEffect(()=>{if(!D||r==="create")return;const Y=T?.relatedContact;Y?.id&&M.current!==Y.id&&(M.current=Y.id,ae.action.resetField(),ae.action.handleSelectContact({id:Y.id,name:Y.name}))},[D,r,T?.id]);const Ue=Y=>{if(Y==="task"){const pe=a.date.state.selectedStartDate;n.date.action.setSelectedStartDate(pe),n.date.action.setSelectedEndDate(pe),n.date.action.setError(!1),a.date.action.setError(!1)}else{const pe=n.date.state.selectedStartDate;a.date.action.setSelectedStartDate(pe),a.date.action.setError(!1),n.date.action.setError(!1)}p(Y)},ce=Y=>{a.colorField.actions.changeValue(Y),I(!0)};return t.jsxs(t.Fragment,{children:[t.jsx(s.Modal,{open:D,onClose:E,closeAfterTransition:!0,slots:{backdrop:s.Backdrop},slotProps:{backdrop:{timeout:200}},children:t.jsx(s.Fade,{in:D,timeout:200,children:t.jsxs(s.Box,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"min(640px, calc(100vw - 32px))",maxHeight:"calc(100vh - 64px)",bgcolor:Y=>Y.palette.background.panel,borderRadius:3,boxShadow:24,outline:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsxs(s.Box,{sx:{display:"flex",flexDirection:"column",gap:2,p:3,pt:4,overflowY:"auto",flex:1},children:[t.jsxs(s.Box,{sx:{display:"flex",alignItems:"center",justifyContent:r==="create"?"flex-end":"space-between",gap:1,mb:.5},children:[r!=="create"&&t.jsx(s.Typography,{sx:{fontWeight:600},children:Se}),t.jsxs(s.Box,{sx:{display:"flex",gap:1},children:[Z&&t.jsx(s.IconButton,{size:"small",onClick:d,"aria-label":e("global.edit","Editar"),children:t.jsx($t,{fontSize:"small"})}),ve&&t.jsx(s.IconButton,{size:"small",onClick:X?i:S,color:"error","aria-label":e("global.delete","Eliminar"),children:t.jsx(oa,{fontSize:"small"})}),Z&&t.jsx(s.IconButton,{size:"small",onClick:c,"aria-label":e("global.duplicate","Duplicar"),children:t.jsx(Zr,{fontSize:"small"})})]})]}),r==="create"&&t.jsxs(t.Fragment,{children:[t.jsx(Wa,{disabled:!1,titleField:R,variantMode:"inline"}),!G&&t.jsx(Wd,{value:u,onChange:Ue,labels:{event:e("global.event","Evento"),task:e("global.task","Tarea")}})]}),u==="event"?t.jsxs(t.Fragment,{children:[r!=="create"&&t.jsx(Wa,{disabled:r==="view",titleField:R}),t.jsx(Kn,{disabled:r==="view",descriptionField:H}),t.jsx(tr,{disabled:r==="view",calendars:[...w,...b],userId:w[0]?.userId,value:g,onChange:Y=>y(Y),loading:C}),t.jsxs(s.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5,borderRadius:1,padding:"15px",bgcolor:Y=>Y.palette.mode==="dark"?"rgba(255, 255, 255, 0.05)":"rgba(0, 0, 0, 0.02)"},children:[t.jsx(s.Box,{sx:{display:"flex",gap:1.5,alignItems:"flex-start"},children:t.jsx(s.Box,{sx:{flex:1},children:t.jsx(jd,{disabled:r==="view",selectedStartDate:W.state.selectedStartDate,selectedEndDate:W.state.selectedEndDate,handleSelectStart:W.action.handleSelect(W.action.setSelectedStartDate),handleSelectEnd:W.action.handleSelect(W.action.setSelectedEndDate),isError:W.state.error,hideLabel:!0,allDay:ie?.allDay??!1})})}),ie&&t.jsxs(s.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[t.jsx(Gd,{checked:ie.allDay,onChange:ie.setAllDay,disabled:r==="view"}),t.jsx(s.Box,{sx:{flex:1},children:t.jsx(qd,{disabled:r==="view",value:ie.recurrenceRule,onChange:ie.setRecurrenceRule,hideLabel:!0})})]})]}),ie&&t.jsx(t.Fragment,{children:t.jsx(Yd,{disabled:r==="view",colorField:ie.colorField,onColorChange:r==="create"?ce:void 0})}),de&&t.jsx($d,{disabled:r==="view",notificationsField:de}),t.jsx(Zn,{linkContactsHandler:ae,disabled:r==="view"}),ie&&t.jsx(Rd,{disabled:r==="view",locationField:ie.locationField})]}):t.jsxs(t.Fragment,{children:[r!=="create"&&t.jsx(Wa,{disabled:r==="view",titleField:R}),t.jsx(Kn,{disabled:r==="view",descriptionField:H}),t.jsx(tr,{disabled:r==="view",calendars:[...w,...b],userId:w[0]?.userId,value:h,onChange:Y=>x(Y),loading:C}),t.jsx(s.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5,p:2,borderRadius:1,bgcolor:Y=>Y.palette.mode==="dark"?"rgba(255, 255, 255, 0.05)":"rgba(0, 0, 0, 0.02)"},children:t.jsxs(s.Box,{sx:{display:"flex",gap:1.5,alignItems:"flex-start"},children:[t.jsx(es,{sx:{mt:.5,color:"text.secondary",fontSize:"1.25rem"}}),t.jsx(s.Box,{sx:{flex:1},children:t.jsx(Hd,{disabled:r==="view",selectedDateTime:W.state.selectedStartDate,handleSelect:Y=>{W.action.setSelectedStartDate(Y),W.action.setSelectedEndDate(Y),W.action.setError(!1)},isError:W.state.error,hideLabel:!0})})]})}),t.jsx(Zn,{linkContactsHandler:ae,disabled:r==="view"})]})]}),t.jsx(s.Box,{sx:{borderTop:1,borderColor:"divider",p:2},children:t.jsx(zd,{isFinalized:o?.finalized})})]})})}),t.jsx(Kd,{open:B.open,onClose:B.handleClose,onConfirm:A,itemTitle:B.itemType==="event"?o?.title:m?.title,itemType:B.itemType}),t.jsx(Jd,{open:k.open,onClose:k.handleClose,onConfirm:N,eventTitle:o?.title}),t.jsx(Qd,{open:_.open,onClose:_.handleClose,onConfirm:V,eventTitle:o?.title}),t.jsx(s.Snackbar,{open:$.open,autoHideDuration:6e3,onClose:Q,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:t.jsx(s.Alert,{onClose:Q,severity:$.severity,sx:{width:"100%"},variant:"filled",children:$.message})})]})},nr=e=>{const a=e.palette.background;return s.createTheme({...e,components:{MuiSelect:{defaultProps:{MenuProps:{PaperProps:{sx:{backgroundColor:a.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}}}},MuiAutocomplete:{styleOverrides:{popper:{zIndex:11,"& div":{backgroundColor:a.panel}}}},MuiPaper:{styleOverrides:{root:{backgroundColor:a.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:a.panel,backgroundImage:"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"}}},MuiList:{styleOverrides:{root:{padding:0}}},MuiModal:{styleOverrides:{root:{}}},MuiTypography:{styleOverrides:{root:{color:e.palette.text.primary}}},MuiChip:{styleOverrides:{root:{color:e.palette.text.primary,border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:"4px",height:"20px",fontSize:"0.7125rem"}}},MuiListSubheader:{styleOverrides:{root:{backgroundColor:a.accordionHeader}}},MuiButton:{styleOverrides:{outlined:{color:e.palette.mode==="light"?e.palette.primary.dark:e.palette.info.dark,borderColor:e.palette.mode==="light"?e.palette.primary.dark:e.palette.info.dark,"&:hover":{borderColor:e.palette.mode==="light"?e.palette.primary.main:e.palette.info.main,color:e.palette.mode==="light"?e.palette.primary.main:e.palette.info.main}}}}}})},Zd=e=>{const{open:a,onClose:n,baseUrl:r,spaceId:o,language:i="en",mode:d="create",type:c="event",eventCalendarId:u,taskCalendarId:p,selectedEvent:m,selectedTask:h,hiddenTabs:x=!1,onActionComplete:g,contactId:y}=e,{i18n:w}=Ke.useTranslation();l.useEffect(()=>{i&&w.changeLanguage(i)},[i,w]);const b=l.useMemo(()=>({baseUrl:r,spaceId:o}),[r,o]);return t.jsx(Ml,{value:b,children:t.jsx(Sd,{externalOpen:a,externalOnClose:n,externalMode:d,externalType:c,externalEventCalendarId:u,externalTaskCalendarId:p,externalSelectedEvent:m,externalSelectedTask:h,hiddenTabs:x,externalOnActionComplete:g,externalContactId:y,children:t.jsx(Xd,{})})})},ec=e=>{const a=s.useTheme(),n=a?.palette?a:s.createTheme(),r=nr(n);return t.jsx(s.ThemeProvider,{theme:r,children:t.jsx(Ke.I18nextProvider,{i18n:Lt,children:t.jsx(Zd,{...e})})})},ba=s.createTheme({name:"lightBlueIndigo",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#ebf6fd",mainGradient:"linear-gradient(270deg, #215c97, #1976d2)",navMenu:"#1976d2",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#1976d2",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#1976d2",light:"#42a5f5",dark:"#1565c0",contrastText:"#fff"},secondary:{main:"#1976d2",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#ebf6fd",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#1976d2"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#1976d2"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),rr=s.createTheme({name:"lightBlue",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#e3f2fd",mainGradient:"linear-gradient(270deg, #005cb2, #1e88e5)",navMenu:"#4fc354",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#1e88e5",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#1e88e5",light:"#6ab7ff",dark:"#005cb2",contrastText:"#fff"},secondary:{main:"#1e88e5",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#e3f2fd",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#1e88e5"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#1e88e5"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),sr=s.createTheme({name:"lightRed",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#ffebee",mainGradient:"linear-gradient(270deg, #b61827, #ef5350)",navMenu:"#f44336",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ef5350",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ef5350",light:"#ff867c",dark:"#b61827",contrastText:"#fff"},secondary:{main:"#ef5350",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#ffebee",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ef5350"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ef5350"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),or=s.createTheme({name:"lightGreen",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#e8f5e9",mainGradient:"linear-gradient(270deg, #087f23, #4caf50)",navMenu:"#4fc354",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#4caf50",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#4caf50",light:"#80e27e",dark:"#087f23",contrastText:"#fff"},secondary:{main:"#4caf50",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#e8f5e9",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#4caf50"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#4caf50"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),ir=s.createTheme({name:"lightPink",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fce4ec",mainGradient:"linear-gradient(270deg, #b0003a, #e91e63)",navMenu:"#e91e63",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#e91e63",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#e91e63",light:"#ff6090",dark:"#b0003a",contrastText:"#fff"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fce4ec",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#e91e63"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#e91e63"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),lr=s.createTheme({name:"lightPurple",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#f3e5f5",mainGradient:"linear-gradient(270deg, #6a0080, #9c27b0)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#9c27b0",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#9c27b0",light:"#d05ce3",dark:"#6a0080",contrastText:"#fff"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#f3e5f5",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#9c27b0"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#9c27b0"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),dr=s.createTheme({name:"lightTeal",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#e0f2f1",mainGradient:"linear-gradient(270deg, #00675b, #009688)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#009688",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#009688",light:"#52c7b8",dark:"#00675b",contrastText:"#fff"},secondary:{main:"#009688",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#e0f2f1",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#009688"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#009688"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),cr=s.createTheme({name:"lightLime",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#f9fbe7",mainGradient:"linear-gradient(270deg, #99aa00, #cddc39)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#cddc39",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#cddc39",light:"#ffff6e",dark:"#99aa00",contrastText:"#fff"},secondary:{main:"#cddc39",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#f9fbe7",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#cddc39"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#cddc39"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),ur=s.createTheme({name:"lightYellow",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fffde7",mainGradient:"linear-gradient(270deg, #c8b900, #ffeb3b)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ffeb3b",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ffeb3b",light:"#ffff72",dark:"#c8b900",contrastText:"#fff"},secondary:{main:"#ffeb3b",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fffde7",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ffeb3b"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ffeb3b"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),pr=s.createTheme({name:"lightAmber",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fff8e1",mainGradient:"linear-gradient(270deg, #c68400, #ffb300)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ffb300",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ffb300",light:"#ffe54c",dark:"#c68400",contrastText:"#fff"},secondary:{main:"#ffb300",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fff8e1",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ffb300"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ffb300"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),fr=s.createTheme({name:"lightOrange",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fff3e0",mainGradient:"linear-gradient(270deg, #c66900, #ff9800)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#ff9800",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#ff9800",light:"#ffc947",dark:"#c66900",contrastText:"#fff"},secondary:{main:"#ff9800",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fff3e0",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#ff9800"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#ff9800"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),gr=s.createTheme({name:"lightBrown",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#efebe9",mainGradient:"linear-gradient(270deg, #4b2c20, #795548)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#795548",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#795548",light:"#a98274",dark:"#4b2c20",contrastText:"#fff"},secondary:{main:"#795548",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#efebe9",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#795548"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#795548"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),mr=s.createTheme({name:"lightGray",palette:{mode:"light",background:{default:"#ffffff",mainCenter:"#fafafa",mainGradient:"linear-gradient(270deg, #707070, #9e9e9e)",navMenu:"#f8bbd0",dropdownMenu:"#f5f5f5",panel:"#ffffff",tooltip:"#9e9e9e",accordionHeader:"#F3F4F6",panelHeader:"#F3F4F6",panelCenter:"#ffffff",panelGradient:"#ffffff",paper:"#ffffff"},primary:{main:"#9e9e9e",light:"#cfcfcf",dark:"#707070",contrastText:"#fff"},secondary:{main:"#9e9e9e",light:"#ba68c8",dark:"#7b1fa2",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#d32f2f",light:"#ef5350",dark:"#c62828"},warning:{main:"#ed6c02",light:"#ff9800",dark:"#e65100"},info:{main:"#0288d1",light:"#03a9f4",dark:"#01579b"},success:{main:"#2e7d32",light:"#4caf50",dark:"#1b5e20"},containerBox:{default:"#ffffff",main:"#f5f5f5"},action:{active:"rgba(0, 0, 0, 0.10)",hover:"rgba(0, 0, 0, 0.05)",selected:"#fafafa",disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.58)",colorMain:"#9e9e9e"},divider:"rgba(0, 0, 0, 0.12)",dropdownBox:"#ffffff",color:{icons:"#9e9e9e"},cellHeader:"#d3d3d3",Skeleton:{bg:"#f5f5f5"},messageBox:"#d3e6fd",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),hr=s.createTheme({name:"darkBlue",palette:{mode:"dark",primary:{main:"#1f5c8e",light:"#2196f3",dark:"#0d47a1",contrastText:"#fff"},secondary:{light:"#FFEA41",main:"#90caf9",dark:"#DBBE01",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#f44336",light:"#e57373",dark:"#d32f2f"},warning:{main:"#ffa726",light:"#ffb74d",dark:"#f57c00"},info:{main:"#29b6f6",light:"#4fc3f7",dark:"#0288d1"},success:{main:"#66bb6a",light:"#81c784",dark:"#388e3c"},background:{default:"#222B45",mainGradient:"linear-gradient(270deg, #222B45, #222B45)",mainCenter:"#28324e",navMenu:"#222B45",panel:"#2d364e",dropdownMenu:"#484f65",tooltip:"#484f65",accordionHeader:"#2a3249e3",panelHeader:"#2a3249e3",panelCenter:"#484f65",panelGradient:"#384057",paper:"#2d364e"},containerBox:{default:"#2d354e",main:"#2d354e"},action:{active:"rgba(255, 255, 255, 0.2)",hover:"rgba(255, 255, 255, 0.08)",selected:"rgba(255, 255, 255, 0.16)",disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"#EEEEEF",secondary:"#AEB0B4",disabled:"rgba(255, 255, 255, 0.5)",colorMain:"#EEEEEF"},divider:"rgba(255, 255, 255, 0.12)",dropdownBox:"#2d354e",color:{icons:"#fff"},cellHeader:"#505050",Skeleton:{bg:"#f5f5f5"},messageBox:"#1f5c8e",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),yr=s.createTheme({name:"darkBlack",palette:{mode:"dark",background:{default:"#201f1e",mainGradient:"linear-gradient(270deg, #201f1e, #201f1e)",mainCenter:"#252423",navMenu:"#201f1e",panel:"#3B3A39",dropdownMenu:"#585858",tooltip:"#616161eb",accordionHeader:"#25242369",panelHeader:"#3b3a39ba",panelCenter:"#585858",panelGradient:"#454443",paper:"#3B3A39"},primary:{main:"#1976d2",light:"#2196f3",dark:"#42a5f5",contrastText:"#fff"},secondary:{light:"#FFEA41",main:"#90caf9",dark:"#DBBE01",contrastText:"rgba(0, 0, 0, 0.87)"},error:{main:"#f44336",light:"#e57373",dark:"#d32f2f"},warning:{main:"#ffa726",light:"#ffb74d",dark:"#f57c00"},info:{main:"#29b6f6",light:"#4fc3f7",dark:"#0288d1"},success:{main:"#66bb6a",light:"#81c784",dark:"#388e3c"},containerBox:{main:"#ffffffb3",default:"#3B3A39"},action:{active:"rgba(255, 255, 255, 0.2)",hover:"rgba(255, 255, 255, 0.08)",selected:"rgba(255, 255, 255, 0.16)",disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)"},text:{primary:"#EEEEEF",secondary:"#AEB0B4",disabled:"rgba(255, 255, 255, 0.5)",colorMain:"#EEEEEF"},divider:"rgba(255, 255, 255, 0.12)",dropdownBox:"#3B3A39",color:{icons:"#fff"},cellHeader:"#505050",Skeleton:{bg:"#f5f5f5"},messageBox:"#1f5c8e",boxShadow:"rgba(0, 0, 0, 0.1)",disabled:"rgba(0, 0, 0, 0.26)"}}),tc="https://agent-api.trii.app/api/v1/settings/user/setTheme",ac={themeSelected:ba,darkMode:!1,toggleStatus:"idle"},xr=Za.createAsyncThunk("Theme/updateTheme",async(e,{getState:a})=>{const{uid:n}=a().User.user,r=JSON.stringify({theme:e,uid:n});return(await ts.put(tc,r)).data}),br=Za.createSlice({name:"Theme",initialState:ac,reducers:{toggleTheme:(e,a)=>{const n=vr(a.payload);Object.assign(e,{themeSelected:n,toggleStatus:"toggled"})},toggleModeTheme:e=>{e.darkMode=!e.darkMode}},extraReducers:e=>{e.addCase(xr.fulfilled,(a,n)=>{const r=vr(n.payload.theme);Object.assign(a,{themeSelected:r})})}}),vr=e=>{switch(e){case"lightBlueIndigo":return ba;case"darkBlack":return yr;case"darkBlue":return hr;case"lightAmber":return pr;case"lightBlue":return rr;case"lightBrown":return gr;case"lightGray":return mr;case"lightGreen":return or;case"lightLime":return cr;case"lightOrange":return fr;case"lightPink":return ir;case"lightPurple":return lr;case"lightRed":return sr;case"lightTeal":return dr;case"lightYellow":return ur;default:return ba}},nc=e=>["lightBlueIndigo","darkBlack","darkBlue","lightAmber","lightBlue","lightBrown","lightGray","lightGreen","lightLime","lightOrange","lightPink","lightPurple","lightRed","lightTeal","lightYellow"].includes(e),{toggleTheme:rc,toggleModeTheme:sc}=br.actions,oc=e=>e.Theme.toggleStatus,ic=e=>e.Theme.themeSelected,lc=e=>e.Theme.darkMode;br.reducer,exports.ContactInfoPopup=on,exports.EditContactModal=$l,exports.EventsDialog=ec,exports.MuiComponentsConfig=nr,exports.darkBlack=yr,exports.darkBlue=hr,exports.i18n=Lt,exports.isValidThemeName=nc,exports.lightAmber=pr,exports.lightBlue=rr,exports.lightBlueIndigo=ba,exports.lightBrown=gr,exports.lightGray=mr,exports.lightGreen=or,exports.lightLime=cr,exports.lightOrange=fr,exports.lightPink=ir,exports.lightPurple=lr,exports.lightRed=sr,exports.lightTeal=dr,exports.lightYellow=ur,exports.selectThemeToggleStatus=oc,exports.selectedDarkTheme=lc,exports.selectedTheme=ic,exports.toggleModeTheme=sc,exports.toggleTheme=rc,exports.updateTheme=xr;
21
21
  //# sourceMappingURL=index.js.map