@bikdotai/bik-component-library 0.0.780-beta.4 → 0.0.780-beta.5

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 (433) hide show
  1. package/dist/cjs/assets/icons/Ai_event_generating.svg.js +1 -1
  2. package/dist/cjs/components/ProgressChecklist/MultiChecklistItem.d.ts +29 -1
  3. package/dist/cjs/components/ProgressChecklist/ProgressChecklist.d.ts +1 -27
  4. package/dist/cjs/components/QueryBuilder/Filters/CustomField/components/CustomField.js +1 -1
  5. package/dist/cjs/components/QueryBuilder/Filters/Event/components/EventFilter.js +1 -1
  6. package/dist/cjs/components/QueryBuilder/Filters/Segment/components/SegmentFilter.js +1 -1
  7. package/dist/cjs/components/QueryBuilder/Filters/UserProperty/components/UserPropertyFilter.js +1 -1
  8. package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.js +1 -1
  9. package/dist/cjs/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.js +1 -1
  10. package/dist/cjs/components/QueryBuilder/components/Connectors/Components/EmojiPicker.d.ts +1 -2
  11. package/dist/cjs/components/QueryBuilder/components/Connectors/Components/EmojiPicker.js +1 -1
  12. package/dist/cjs/components/QueryBuilder/components/Connectors/Components/InTheLast.js +1 -1
  13. package/dist/cjs/components/QueryBuilder/components/Connectors/Components/InTwoLast.js +1 -1
  14. package/dist/cjs/components/QueryBuilder/components/Connectors/Components/MultiselectDropdownFreeText.js +1 -1
  15. package/dist/cjs/components/QueryBuilder/components/Connectors/Components/SingleselectDropdownFreeText.js +1 -1
  16. package/dist/cjs/components/QueryBuilder/components/Connectors/Connector.js +1 -1
  17. package/dist/cjs/components/QueryBuilder/components/DropdownWrapper.d.ts +1 -3
  18. package/dist/cjs/components/QueryBuilder/components/DropdownWrapper.js +1 -1
  19. package/dist/cjs/components/QueryBuilder/components/QueryBuilderNode/Property/PropertyNode.js +1 -1
  20. package/dist/cjs/components/QueryBuilder/constants/connector.d.ts +1 -1
  21. package/dist/cjs/components/QueryBuilder/constants/connector.js +1 -1
  22. package/dist/cjs/components/QueryBuilder/constants/connectorPosition.js +1 -1
  23. package/dist/cjs/components/QueryBuilder/helpers/Connector.helper.d.ts +1 -1
  24. package/dist/cjs/components/QueryBuilder/helpers/Connector.helper.js +1 -1
  25. package/dist/cjs/components/QueryBuilder/helpers/PropertyCustomProcessor.d.ts +1 -1
  26. package/dist/cjs/components/QueryBuilder/helpers/SegmentValidator.d.ts +3 -15
  27. package/dist/cjs/components/QueryBuilder/types/QueryBuilder.type.d.ts +2 -22
  28. package/dist/cjs/components/QueryBuilder/types/QueryBuilder.type.js +1 -1
  29. package/dist/cjs/components/QueryBuilder/types/QueryBuilderAPI.type.d.ts +1 -1
  30. package/dist/cjs/components/QueryBuilder/types/QueryBuilderConnector.type.d.ts +1 -6
  31. package/dist/cjs/components/QueryBuilder/types/QueryBuilderEnum.type.d.ts +21 -0
  32. package/dist/cjs/components/QueryBuilder/types/QueryBuilderEnum.type.js +1 -0
  33. package/dist/cjs/components/QueryBuilder/types/index.d.ts +2 -1
  34. package/dist/cjs/components/SearchFilter/components/DatePickerButton.d.ts +1 -1
  35. package/dist/cjs/components/SearchFilter/components/DateRangeOnlyButton.d.ts +1 -1
  36. package/dist/cjs/components/SearchFilter/components/SearchFilterItem.d.ts +1 -1
  37. package/dist/cjs/components/SearchFilter/components/SearchFilterItem.js +1 -1
  38. package/dist/cjs/components/SearchFilter/types/SearchFilter.type.d.ts +1 -1
  39. package/dist/cjs/components/TablePagination/TablePagination.js +1 -1
  40. package/dist/cjs/components/WhatsAppTextEditor/AIRephraseButton.d.ts +4 -1
  41. package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.d.ts +4 -1
  42. package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.d.ts +1 -4
  43. package/dist/cjs/components/WhatsAppTextEditor/ai/actionRegistry.d.ts +2 -1
  44. package/dist/cjs/components/accordion/Accordion.d.ts +2 -35
  45. package/dist/cjs/components/accordion/Accordion.model.d.ts +35 -0
  46. package/dist/cjs/components/accordion/Accordion.style.d.ts +1 -1
  47. package/dist/cjs/components/analytics-card/AnalyticsCard.d.ts +1 -1
  48. package/dist/cjs/components/analytics-card/AnalyticsCard.model.d.ts +1 -0
  49. package/dist/cjs/components/analytics-card/AnalyticsCard.styled.d.ts +1 -1
  50. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsChip.d.ts +1 -17
  51. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsChip.model.d.ts +18 -0
  52. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsChipChannelFooter.d.ts +1 -1
  53. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
  54. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsMultiChip.d.ts +1 -1
  55. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/LazyCharts.d.ts +2 -0
  56. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/LazyCharts.js +1 -0
  57. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
  58. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/VerticalBarGraph/VerticalGraph.js +1 -1
  59. package/dist/cjs/components/avatar/Avatar.js +1 -1
  60. package/dist/cjs/components/bik-layout/BikSidebar.d.ts +1 -1
  61. package/dist/cjs/components/bik-layout/Sidebar.model.d.ts +27 -0
  62. package/dist/cjs/components/bik-layout/SidebarPopup.d.ts +1 -1
  63. package/dist/cjs/components/bik-layout/SidebarSkeleton.d.ts +1 -1
  64. package/dist/cjs/components/bik-layout/SidebarStyles.d.ts +1 -1
  65. package/dist/cjs/components/bik-layout/SimpleSidebar.d.ts +1 -27
  66. package/dist/cjs/components/country-code-picker/CountryCodePicker.js +1 -1
  67. package/dist/cjs/components/country-code-picker/CountryPicker.js +1 -1
  68. package/dist/cjs/components/custom-date-time/CustomDateTime.js +1 -1
  69. package/dist/cjs/components/custom-date-time/DateSelector/DateSelector.js +1 -1
  70. package/dist/cjs/components/datePicker/TimePicker.js +1 -1
  71. package/dist/cjs/components/discount-modal/CouponExpiration/CouponExpiration.js +1 -1
  72. package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
  73. package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  74. package/dist/cjs/components/discount-modal/DynamicCoupon/MinimumRequirementComponent.js +1 -1
  75. package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
  76. package/dist/cjs/components/dropdown/OpenedDropdown/components/searchbox/SearchZeroState.d.ts +0 -2
  77. package/dist/cjs/components/dropdown/OpenedDropdown/components/searchbox/SearchZeroState.js +1 -1
  78. package/dist/cjs/components/dropdown/hooks/useDropdown.d.ts +0 -2
  79. package/dist/cjs/components/dropdown/hooks/useDropdown.js +1 -1
  80. package/dist/cjs/components/dropdown/type.d.ts +0 -9
  81. package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
  82. package/dist/cjs/components/floating-input-dropdown/FloatingInputDropdown.d.ts +1 -1
  83. package/dist/cjs/components/image-cropper/BikImageCropper.d.ts +1 -6
  84. package/dist/cjs/components/image-cropper/BikImageCropper.model.d.ts +6 -0
  85. package/dist/cjs/components/image-cropper/BikImagePipeline/BikImagePipeline.d.ts +1 -1
  86. package/dist/cjs/components/input/ChipInput.js +1 -1
  87. package/dist/cjs/components/input/ChipInput.styled.d.ts +6 -66
  88. package/dist/cjs/components/input/ChipInput.styled.js +1 -1
  89. package/dist/cjs/components/input/Input-helper.d.ts +1 -1
  90. package/dist/cjs/components/input/Input.d.ts +1 -71
  91. package/dist/cjs/components/input/Input.model.d.ts +72 -0
  92. package/dist/cjs/components/input/Input.styled.d.ts +1 -1
  93. package/dist/cjs/components/input-with-vars/InputWithVariables.d.ts +1 -1
  94. package/dist/cjs/components/list-item/List.model.d.ts +18 -0
  95. package/dist/cjs/components/list-item/ListItem.d.ts +1 -17
  96. package/dist/cjs/components/list-item/ListItem.styled.d.ts +1 -1
  97. package/dist/cjs/components/list-item/themes.d.ts +1 -1
  98. package/dist/cjs/components/multi-level-dropdown/GroupedMenuList.d.ts +2 -1
  99. package/dist/cjs/components/multi-level-dropdown/GroupedMenuList.js +1 -1
  100. package/dist/cjs/components/multi-level-dropdown/MenuItem.d.ts +2 -1
  101. package/dist/cjs/components/multi-level-dropdown/MenuItem.js +1 -1
  102. package/dist/cjs/components/multi-level-dropdown/MenuList.js +1 -1
  103. package/dist/cjs/components/multi-level-dropdown/type.d.ts +2 -1
  104. package/dist/cjs/components/product-picker-v2/ProductPickerTag.d.ts +2 -2
  105. package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +3 -3
  106. package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.d.ts +3 -4
  107. package/dist/cjs/components/product-picker-v2/index.d.ts +1 -1
  108. package/dist/cjs/components/product-picker-v2/modal.d.ts +2 -58
  109. package/dist/cjs/components/product-picker-v2/product.d.ts +2 -3
  110. package/dist/cjs/components/product-picker-v2/productInfoOverlay.d.ts +1 -2
  111. package/dist/cjs/components/product-picker-v2/productScreen.d.ts +3 -3
  112. package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
  113. package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +3 -4
  114. package/dist/cjs/components/product-picker-v2/reducers.d.ts +1 -1
  115. package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
  116. package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +3 -4
  117. package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +3 -4
  118. package/dist/cjs/components/product-picker-v2/type.d.ts +65 -0
  119. package/dist/cjs/components/product-picker-v2/utility.d.ts +3 -3
  120. package/dist/cjs/components/product-picker-v2/utility.js +1 -1
  121. package/dist/cjs/components/product-picker-v2/variant.d.ts +2 -12
  122. package/dist/cjs/components/product-picker-v2/variantComponents.d.ts +2 -3
  123. package/dist/cjs/components/sample-button/SampleButton.d.ts +1 -16
  124. package/dist/cjs/components/sample-button/SampleButton.model.d.ts +17 -0
  125. package/dist/cjs/components/sample-button/SampleButton.styled.d.ts +1 -1
  126. package/dist/cjs/components/sample-button/themes.d.ts +1 -1
  127. package/dist/cjs/components/searchBar/searchBar.d.ts +1 -1
  128. package/dist/cjs/components/slider/slider.js +1 -1
  129. package/dist/cjs/components/stepper/Stepper.d.ts +1 -17
  130. package/dist/cjs/components/stepper/Stepper.model.d.ts +17 -0
  131. package/dist/cjs/components/stepper/Stepper.styled.d.ts +1 -1
  132. package/dist/cjs/components/stepper/StepperService.d.ts +1 -1
  133. package/dist/cjs/components/stepper/themes.d.ts +1 -1
  134. package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +9 -9
  135. package/dist/cjs/components/template-context-mapper/TemplateContextMapper.js +1 -1
  136. package/dist/cjs/components/template-context-mapper/context/templateModalContext.d.ts +7 -7
  137. package/dist/cjs/components/template-context-mapper/custom-hooks/useAdditionalVariables.d.ts +1 -1
  138. package/dist/cjs/components/template-context-mapper/helpers/WebpushTemplateHelper.d.ts +6 -4
  139. package/dist/cjs/components/template-context-mapper/helpers/WebpushTemplateHelper.js +1 -1
  140. package/dist/cjs/components/template-context-mapper/modalElements/Body.d.ts +2 -2
  141. package/dist/cjs/components/template-context-mapper/modalElements/Body.js +10 -10
  142. package/dist/cjs/components/template-context-mapper/modalElements/DesktopPreview.js +7 -7
  143. package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.d.ts +3 -3
  144. package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.js +1 -1
  145. package/dist/cjs/components/template-context-mapper/modalElements/EditWebpushTemplate.d.ts +2 -2
  146. package/dist/cjs/components/template-context-mapper/modalElements/EditWebpushTemplate.js +1 -1
  147. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.d.ts +3 -14
  148. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  149. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts +5 -5
  150. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
  151. package/dist/cjs/components/template-context-mapper/modalElements/Footer.js +4 -4
  152. package/dist/cjs/components/template-context-mapper/modalElements/MobilePreview.d.ts +1 -1
  153. package/dist/cjs/components/template-context-mapper/modalElements/MobilePreview.js +3 -3
  154. package/dist/cjs/components/template-context-mapper/modalElements/QualityWarningModal.d.ts +1 -1
  155. package/dist/cjs/components/template-context-mapper/modalElements/TemplateAnalyticsComponent.d.ts +1 -1
  156. package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +2 -2
  157. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.d.ts +1 -1
  158. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +4 -4
  159. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.d.ts +5 -4
  160. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js +1 -1
  161. package/dist/cjs/components/template-context-mapper/modalElements/VariableEditorHeader.d.ts +1 -1
  162. package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +2 -2
  163. package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  164. package/dist/cjs/components/template-context-mapper/modalElements/modal.d.ts +13 -0
  165. package/dist/cjs/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.d.ts +1 -1
  166. package/dist/cjs/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.js +1 -1
  167. package/dist/cjs/components/template-context-mapper/utils/convertPlaceholdersToBikDropdown.d.ts +2 -2
  168. package/dist/cjs/components/template-context-mapper/utils/getDataFromTemplateComponent.d.ts +2 -2
  169. package/dist/cjs/components/template-context-mapper/utils/highlightFor.d.ts +1 -1
  170. package/dist/cjs/components/template-preview/models/TemplateMeta.d.ts +1 -1
  171. package/dist/cjs/components/template-preview/models/WhatsappCarouselTemplate.d.ts +2 -2
  172. package/dist/cjs/components/toaster/Toaster.styled.js +1 -1
  173. package/dist/cjs/components/variable-picker-v3/SubHeaderItems.js +1 -1
  174. package/dist/cjs/components/zeroState/ZeroState.js +1 -2
  175. package/dist/cjs/firebase/environment.d.ts +58 -0
  176. package/dist/cjs/firebase/environment.js +1 -0
  177. package/dist/cjs/firebase/firebaseUserFetcher.d.ts +34 -0
  178. package/dist/cjs/firebase/firebaseUserFetcher.js +1 -0
  179. package/dist/cjs/firebase/index.d.ts +7 -0
  180. package/dist/cjs/firebase/lazyFirebaseApp.d.ts +22 -0
  181. package/dist/cjs/firebase/lazyFirebaseApp.js +1 -0
  182. package/dist/cjs/firebase/lazyFirebaseMethods.d.ts +589 -0
  183. package/dist/cjs/firebase/lazyFirebaseMethods.js +1 -0
  184. package/dist/cjs/firebase/lazyFirestore.d.ts +6 -0
  185. package/dist/cjs/firebase/lazyFirestore.js +1 -0
  186. package/dist/cjs/firebase/lazyFirestoreLite.d.ts +6 -0
  187. package/dist/cjs/firebase/lazyFirestoreLite.js +1 -0
  188. package/dist/cjs/firebase/lazyStorage.d.ts +5 -0
  189. package/dist/cjs/firebase/lazyStorage.js +1 -0
  190. package/dist/cjs/index.d.ts +3 -0
  191. package/dist/cjs/index.js +1 -1
  192. package/dist/cjs/request-executor/executor.d.ts +99 -0
  193. package/dist/cjs/request-executor/executor.js +1 -0
  194. package/dist/cjs/request-executor/index.d.ts +2 -0
  195. package/dist/cjs/request-executor/model.d.ts +14 -0
  196. package/dist/cjs/utils/logging/ErrorConstructor/ApiError.d.ts +3 -0
  197. package/dist/cjs/utils/logging/ErrorConstructor/ApiError.js +1 -0
  198. package/dist/cjs/utils/logging/ErrorConstructor/BroadcastFlowError.d.ts +4 -0
  199. package/dist/cjs/utils/logging/ErrorConstructor/BroadcastFlowError.js +1 -0
  200. package/dist/cjs/utils/logging/ErrorConstructor/CohortError.d.ts +4 -0
  201. package/dist/cjs/utils/logging/ErrorConstructor/CohortError.js +1 -0
  202. package/dist/cjs/utils/logging/ErrorConstructor/CustomError.d.ts +3 -0
  203. package/dist/cjs/utils/logging/ErrorConstructor/CustomError.js +1 -0
  204. package/dist/cjs/utils/logging/ErrorConstructor/ExcelUploadError.d.ts +3 -0
  205. package/dist/cjs/utils/logging/ErrorConstructor/ExcelUploadError.js +1 -0
  206. package/dist/cjs/utils/logging/ErrorConstructor/FirebaseCallError.d.ts +3 -0
  207. package/dist/cjs/utils/logging/ErrorConstructor/FirebaseCallError.js +1 -0
  208. package/dist/cjs/utils/logging/ErrorConstructor/FirebaseSubscriptionError.d.ts +3 -0
  209. package/dist/cjs/utils/logging/ErrorConstructor/FirebaseSubscriptionError.js +1 -0
  210. package/dist/cjs/utils/logging/ErrorConstructor/RechargeFailure.d.ts +3 -0
  211. package/dist/cjs/utils/logging/ErrorConstructor/RechargeFailure.js +1 -0
  212. package/dist/cjs/utils/logging/ErrorConstructor/WhatsappIntegrationError.d.ts +3 -0
  213. package/dist/cjs/utils/logging/ErrorConstructor/WhatsappIntegrationError.js +1 -0
  214. package/dist/cjs/utils/logging/Logger.d.ts +24 -0
  215. package/dist/cjs/utils/logging/Logger.js +1 -0
  216. package/dist/cjs/utils/logging/index.d.ts +10 -0
  217. package/dist/esm/assets/icons/Ai_event_generating.svg.js +1 -1
  218. package/dist/esm/components/ProgressChecklist/MultiChecklistItem.d.ts +29 -1
  219. package/dist/esm/components/ProgressChecklist/ProgressChecklist.d.ts +1 -27
  220. package/dist/esm/components/QueryBuilder/Filters/CustomField/components/CustomField.js +1 -1
  221. package/dist/esm/components/QueryBuilder/Filters/Event/components/EventFilter.js +1 -1
  222. package/dist/esm/components/QueryBuilder/Filters/Segment/components/SegmentFilter.js +1 -1
  223. package/dist/esm/components/QueryBuilder/Filters/UserProperty/components/UserPropertyFilter.js +1 -1
  224. package/dist/esm/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.js +1 -1
  225. package/dist/esm/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.js +1 -1
  226. package/dist/esm/components/QueryBuilder/components/Connectors/Components/EmojiPicker.d.ts +1 -2
  227. package/dist/esm/components/QueryBuilder/components/Connectors/Components/EmojiPicker.js +1 -1
  228. package/dist/esm/components/QueryBuilder/components/Connectors/Components/InTheLast.js +1 -1
  229. package/dist/esm/components/QueryBuilder/components/Connectors/Components/InTwoLast.js +1 -1
  230. package/dist/esm/components/QueryBuilder/components/Connectors/Components/MultiselectDropdownFreeText.js +1 -1
  231. package/dist/esm/components/QueryBuilder/components/Connectors/Components/SingleselectDropdownFreeText.js +1 -1
  232. package/dist/esm/components/QueryBuilder/components/Connectors/Connector.js +1 -1
  233. package/dist/esm/components/QueryBuilder/components/DropdownWrapper.d.ts +1 -3
  234. package/dist/esm/components/QueryBuilder/components/DropdownWrapper.js +1 -1
  235. package/dist/esm/components/QueryBuilder/components/QueryBuilderNode/Property/PropertyNode.js +1 -1
  236. package/dist/esm/components/QueryBuilder/constants/connector.d.ts +1 -1
  237. package/dist/esm/components/QueryBuilder/constants/connector.js +1 -1
  238. package/dist/esm/components/QueryBuilder/constants/connectorPosition.js +1 -1
  239. package/dist/esm/components/QueryBuilder/helpers/Connector.helper.d.ts +1 -1
  240. package/dist/esm/components/QueryBuilder/helpers/Connector.helper.js +1 -1
  241. package/dist/esm/components/QueryBuilder/helpers/PropertyCustomProcessor.d.ts +1 -1
  242. package/dist/esm/components/QueryBuilder/helpers/SegmentValidator.d.ts +3 -15
  243. package/dist/esm/components/QueryBuilder/types/QueryBuilder.type.d.ts +2 -22
  244. package/dist/esm/components/QueryBuilder/types/QueryBuilder.type.js +1 -1
  245. package/dist/esm/components/QueryBuilder/types/QueryBuilderAPI.type.d.ts +1 -1
  246. package/dist/esm/components/QueryBuilder/types/QueryBuilderConnector.type.d.ts +1 -6
  247. package/dist/esm/components/QueryBuilder/types/QueryBuilderEnum.type.d.ts +21 -0
  248. package/dist/esm/components/QueryBuilder/types/QueryBuilderEnum.type.js +1 -0
  249. package/dist/esm/components/QueryBuilder/types/index.d.ts +2 -1
  250. package/dist/esm/components/SearchFilter/components/DatePickerButton.d.ts +1 -1
  251. package/dist/esm/components/SearchFilter/components/DateRangeOnlyButton.d.ts +1 -1
  252. package/dist/esm/components/SearchFilter/components/SearchFilterItem.d.ts +1 -1
  253. package/dist/esm/components/SearchFilter/components/SearchFilterItem.js +1 -1
  254. package/dist/esm/components/SearchFilter/types/SearchFilter.type.d.ts +1 -1
  255. package/dist/esm/components/TablePagination/TablePagination.js +1 -1
  256. package/dist/esm/components/WhatsAppTextEditor/AIRephraseButton.d.ts +4 -1
  257. package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.d.ts +4 -1
  258. package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.d.ts +1 -4
  259. package/dist/esm/components/WhatsAppTextEditor/ai/actionRegistry.d.ts +2 -1
  260. package/dist/esm/components/accordion/Accordion.d.ts +2 -35
  261. package/dist/esm/components/accordion/Accordion.model.d.ts +35 -0
  262. package/dist/esm/components/accordion/Accordion.style.d.ts +1 -1
  263. package/dist/esm/components/analytics-card/AnalyticsCard.d.ts +1 -1
  264. package/dist/esm/components/analytics-card/AnalyticsCard.model.d.ts +1 -0
  265. package/dist/esm/components/analytics-card/AnalyticsCard.styled.d.ts +1 -1
  266. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsChip.d.ts +1 -17
  267. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsChip.model.d.ts +18 -0
  268. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsChipChannelFooter.d.ts +1 -1
  269. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
  270. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsMultiChip.d.ts +1 -1
  271. package/dist/esm/components/analytics-chips-and-dropdowns/chart/LazyCharts.d.ts +2 -0
  272. package/dist/esm/components/analytics-chips-and-dropdowns/chart/LazyCharts.js +1 -0
  273. package/dist/esm/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
  274. package/dist/esm/components/analytics-chips-and-dropdowns/chart/VerticalBarGraph/VerticalGraph.js +1 -1
  275. package/dist/esm/components/avatar/Avatar.js +1 -1
  276. package/dist/esm/components/bik-layout/BikSidebar.d.ts +1 -1
  277. package/dist/esm/components/bik-layout/Sidebar.model.d.ts +27 -0
  278. package/dist/esm/components/bik-layout/SidebarPopup.d.ts +1 -1
  279. package/dist/esm/components/bik-layout/SidebarSkeleton.d.ts +1 -1
  280. package/dist/esm/components/bik-layout/SidebarStyles.d.ts +1 -1
  281. package/dist/esm/components/bik-layout/SimpleSidebar.d.ts +1 -27
  282. package/dist/esm/components/country-code-picker/CountryCodePicker.js +1 -1
  283. package/dist/esm/components/country-code-picker/CountryPicker.js +1 -1
  284. package/dist/esm/components/custom-date-time/CustomDateTime.js +1 -1
  285. package/dist/esm/components/custom-date-time/DateSelector/DateSelector.js +1 -1
  286. package/dist/esm/components/datePicker/TimePicker.js +1 -1
  287. package/dist/esm/components/discount-modal/CouponExpiration/CouponExpiration.js +1 -1
  288. package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
  289. package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  290. package/dist/esm/components/discount-modal/DynamicCoupon/MinimumRequirementComponent.js +1 -1
  291. package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
  292. package/dist/esm/components/dropdown/OpenedDropdown/components/searchbox/SearchZeroState.d.ts +0 -2
  293. package/dist/esm/components/dropdown/OpenedDropdown/components/searchbox/SearchZeroState.js +1 -1
  294. package/dist/esm/components/dropdown/hooks/useDropdown.d.ts +0 -2
  295. package/dist/esm/components/dropdown/hooks/useDropdown.js +1 -1
  296. package/dist/esm/components/dropdown/type.d.ts +0 -9
  297. package/dist/esm/components/dropdown-button/DropdownButton.js +1 -1
  298. package/dist/esm/components/floating-input-dropdown/FloatingInputDropdown.d.ts +1 -1
  299. package/dist/esm/components/image-cropper/BikImageCropper.d.ts +1 -6
  300. package/dist/esm/components/image-cropper/BikImageCropper.model.d.ts +6 -0
  301. package/dist/esm/components/image-cropper/BikImagePipeline/BikImagePipeline.d.ts +1 -1
  302. package/dist/esm/components/input/ChipInput.js +1 -1
  303. package/dist/esm/components/input/ChipInput.styled.d.ts +6 -66
  304. package/dist/esm/components/input/ChipInput.styled.js +1 -1
  305. package/dist/esm/components/input/Input-helper.d.ts +1 -1
  306. package/dist/esm/components/input/Input.d.ts +1 -71
  307. package/dist/esm/components/input/Input.model.d.ts +72 -0
  308. package/dist/esm/components/input/Input.styled.d.ts +1 -1
  309. package/dist/esm/components/input-with-vars/InputWithVariables.d.ts +1 -1
  310. package/dist/esm/components/list-item/List.model.d.ts +18 -0
  311. package/dist/esm/components/list-item/ListItem.d.ts +1 -17
  312. package/dist/esm/components/list-item/ListItem.styled.d.ts +1 -1
  313. package/dist/esm/components/list-item/themes.d.ts +1 -1
  314. package/dist/esm/components/multi-level-dropdown/GroupedMenuList.d.ts +2 -1
  315. package/dist/esm/components/multi-level-dropdown/GroupedMenuList.js +1 -1
  316. package/dist/esm/components/multi-level-dropdown/MenuItem.d.ts +2 -1
  317. package/dist/esm/components/multi-level-dropdown/MenuItem.js +1 -1
  318. package/dist/esm/components/multi-level-dropdown/MenuList.js +1 -1
  319. package/dist/esm/components/multi-level-dropdown/type.d.ts +2 -1
  320. package/dist/esm/components/product-picker-v2/ProductPickerTag.d.ts +2 -2
  321. package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +3 -3
  322. package/dist/esm/components/product-picker-v2/helpers/ProductHelper.d.ts +3 -4
  323. package/dist/esm/components/product-picker-v2/index.d.ts +1 -1
  324. package/dist/esm/components/product-picker-v2/modal.d.ts +2 -58
  325. package/dist/esm/components/product-picker-v2/product.d.ts +2 -3
  326. package/dist/esm/components/product-picker-v2/productInfoOverlay.d.ts +1 -2
  327. package/dist/esm/components/product-picker-v2/productScreen.d.ts +3 -3
  328. package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
  329. package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +3 -4
  330. package/dist/esm/components/product-picker-v2/reducers.d.ts +1 -1
  331. package/dist/esm/components/product-picker-v2/reducers.js +1 -1
  332. package/dist/esm/components/product-picker-v2/searchScreen.d.ts +3 -4
  333. package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +3 -4
  334. package/dist/esm/components/product-picker-v2/type.d.ts +65 -0
  335. package/dist/esm/components/product-picker-v2/utility.d.ts +3 -3
  336. package/dist/esm/components/product-picker-v2/utility.js +1 -1
  337. package/dist/esm/components/product-picker-v2/variant.d.ts +2 -12
  338. package/dist/esm/components/product-picker-v2/variantComponents.d.ts +2 -3
  339. package/dist/esm/components/sample-button/SampleButton.d.ts +1 -16
  340. package/dist/esm/components/sample-button/SampleButton.model.d.ts +17 -0
  341. package/dist/esm/components/sample-button/SampleButton.styled.d.ts +1 -1
  342. package/dist/esm/components/sample-button/themes.d.ts +1 -1
  343. package/dist/esm/components/searchBar/searchBar.d.ts +1 -1
  344. package/dist/esm/components/slider/slider.js +1 -1
  345. package/dist/esm/components/stepper/Stepper.d.ts +1 -17
  346. package/dist/esm/components/stepper/Stepper.model.d.ts +17 -0
  347. package/dist/esm/components/stepper/Stepper.styled.d.ts +1 -1
  348. package/dist/esm/components/stepper/StepperService.d.ts +1 -1
  349. package/dist/esm/components/stepper/themes.d.ts +1 -1
  350. package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +9 -9
  351. package/dist/esm/components/template-context-mapper/TemplateContextMapper.js +1 -1
  352. package/dist/esm/components/template-context-mapper/context/templateModalContext.d.ts +7 -7
  353. package/dist/esm/components/template-context-mapper/custom-hooks/useAdditionalVariables.d.ts +1 -1
  354. package/dist/esm/components/template-context-mapper/helpers/WebpushTemplateHelper.d.ts +6 -4
  355. package/dist/esm/components/template-context-mapper/helpers/WebpushTemplateHelper.js +1 -1
  356. package/dist/esm/components/template-context-mapper/modalElements/Body.d.ts +2 -2
  357. package/dist/esm/components/template-context-mapper/modalElements/Body.js +10 -10
  358. package/dist/esm/components/template-context-mapper/modalElements/DesktopPreview.js +6 -6
  359. package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.d.ts +3 -3
  360. package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.js +1 -1
  361. package/dist/esm/components/template-context-mapper/modalElements/EditWebpushTemplate.d.ts +2 -2
  362. package/dist/esm/components/template-context-mapper/modalElements/EditWebpushTemplate.js +1 -1
  363. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.d.ts +3 -14
  364. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  365. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts +5 -5
  366. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
  367. package/dist/esm/components/template-context-mapper/modalElements/Footer.js +4 -4
  368. package/dist/esm/components/template-context-mapper/modalElements/MobilePreview.d.ts +1 -1
  369. package/dist/esm/components/template-context-mapper/modalElements/MobilePreview.js +5 -5
  370. package/dist/esm/components/template-context-mapper/modalElements/QualityWarningModal.d.ts +1 -1
  371. package/dist/esm/components/template-context-mapper/modalElements/TemplateAnalyticsComponent.d.ts +1 -1
  372. package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +2 -2
  373. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.d.ts +1 -1
  374. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +1 -1
  375. package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.d.ts +5 -4
  376. package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js +1 -1
  377. package/dist/esm/components/template-context-mapper/modalElements/VariableEditorHeader.d.ts +1 -1
  378. package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +2 -2
  379. package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  380. package/dist/esm/components/template-context-mapper/modalElements/modal.d.ts +13 -0
  381. package/dist/esm/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.d.ts +1 -1
  382. package/dist/esm/components/template-context-mapper/modalElements/useEditWhtasappTemplateMedia.js +1 -1
  383. package/dist/esm/components/template-context-mapper/utils/convertPlaceholdersToBikDropdown.d.ts +2 -2
  384. package/dist/esm/components/template-context-mapper/utils/getDataFromTemplateComponent.d.ts +2 -2
  385. package/dist/esm/components/template-context-mapper/utils/highlightFor.d.ts +1 -1
  386. package/dist/esm/components/template-preview/models/TemplateMeta.d.ts +1 -1
  387. package/dist/esm/components/template-preview/models/WhatsappCarouselTemplate.d.ts +2 -2
  388. package/dist/esm/components/toaster/Toaster.styled.js +1 -1
  389. package/dist/esm/components/variable-picker-v3/SubHeaderItems.js +1 -1
  390. package/dist/esm/components/zeroState/ZeroState.js +1 -2
  391. package/dist/esm/firebase/environment.d.ts +58 -0
  392. package/dist/esm/firebase/environment.js +1 -0
  393. package/dist/esm/firebase/firebaseUserFetcher.d.ts +34 -0
  394. package/dist/esm/firebase/firebaseUserFetcher.js +1 -0
  395. package/dist/esm/firebase/index.d.ts +7 -0
  396. package/dist/esm/firebase/lazyFirebaseApp.d.ts +22 -0
  397. package/dist/esm/firebase/lazyFirebaseApp.js +1 -0
  398. package/dist/esm/firebase/lazyFirebaseMethods.d.ts +589 -0
  399. package/dist/esm/firebase/lazyFirebaseMethods.js +1 -0
  400. package/dist/esm/firebase/lazyFirestore.d.ts +6 -0
  401. package/dist/esm/firebase/lazyFirestore.js +1 -0
  402. package/dist/esm/firebase/lazyFirestoreLite.d.ts +6 -0
  403. package/dist/esm/firebase/lazyFirestoreLite.js +1 -0
  404. package/dist/esm/firebase/lazyStorage.d.ts +5 -0
  405. package/dist/esm/firebase/lazyStorage.js +1 -0
  406. package/dist/esm/index.d.ts +3 -0
  407. package/dist/esm/index.js +1 -1
  408. package/dist/esm/request-executor/executor.d.ts +99 -0
  409. package/dist/esm/request-executor/executor.js +1 -0
  410. package/dist/esm/request-executor/index.d.ts +2 -0
  411. package/dist/esm/request-executor/model.d.ts +14 -0
  412. package/dist/esm/utils/logging/ErrorConstructor/ApiError.d.ts +3 -0
  413. package/dist/esm/utils/logging/ErrorConstructor/ApiError.js +1 -0
  414. package/dist/esm/utils/logging/ErrorConstructor/BroadcastFlowError.d.ts +4 -0
  415. package/dist/esm/utils/logging/ErrorConstructor/BroadcastFlowError.js +1 -0
  416. package/dist/esm/utils/logging/ErrorConstructor/CohortError.d.ts +4 -0
  417. package/dist/esm/utils/logging/ErrorConstructor/CohortError.js +1 -0
  418. package/dist/esm/utils/logging/ErrorConstructor/CustomError.d.ts +3 -0
  419. package/dist/esm/utils/logging/ErrorConstructor/CustomError.js +1 -0
  420. package/dist/esm/utils/logging/ErrorConstructor/ExcelUploadError.d.ts +3 -0
  421. package/dist/esm/utils/logging/ErrorConstructor/ExcelUploadError.js +1 -0
  422. package/dist/esm/utils/logging/ErrorConstructor/FirebaseCallError.d.ts +3 -0
  423. package/dist/esm/utils/logging/ErrorConstructor/FirebaseCallError.js +1 -0
  424. package/dist/esm/utils/logging/ErrorConstructor/FirebaseSubscriptionError.d.ts +3 -0
  425. package/dist/esm/utils/logging/ErrorConstructor/FirebaseSubscriptionError.js +1 -0
  426. package/dist/esm/utils/logging/ErrorConstructor/RechargeFailure.d.ts +3 -0
  427. package/dist/esm/utils/logging/ErrorConstructor/RechargeFailure.js +1 -0
  428. package/dist/esm/utils/logging/ErrorConstructor/WhatsappIntegrationError.d.ts +3 -0
  429. package/dist/esm/utils/logging/ErrorConstructor/WhatsappIntegrationError.js +1 -0
  430. package/dist/esm/utils/logging/Logger.d.ts +24 -0
  431. package/dist/esm/utils/logging/Logger.js +1 -0
  432. package/dist/esm/utils/logging/index.d.ts +10 -0
  433. package/package.json +8 -8
@@ -1 +1 @@
1
- import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useMemo as e}from"react";import"../dropdown/DropdownPopover/index.js";import{Dropdown as r}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import"../../constants/Theme.js";import"../../_virtual/_tslib.js";import"lodash/debounce";import"../TypographyStyle.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{TimePickerContainer as n,TimeInputWrapper as p,TimeLabel as i}from"./DatePicker.styled.js";const l=l=>{let{fromTime:d="00:00",toTime:s="23:59",onFromTimeChange:a,onToTimeChange:m,timeInterval:u=30}=l;const c=e((()=>{const t=[];for(let o=0;o<1440;o+=u){const e=Math.floor(o/60),r=o%60,n=e>=12?"PM":"AM",p=`${0===e?12:e>12?e-12:e}:${r.toString().padStart(2,"0")} ${n}`,i=`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`;t.push({label:p,value:i,selected:i===d})}if(d&&!t.find((t=>t.value===d))){const[o,e]=d.split(":").map(Number),r=o>=12?"PM":"AM",n=`${0===o?12:o>12?o-12:o}:${e.toString().padStart(2,"0")} ${r}`;t.push({label:n,value:d,selected:!0}),t.sort(((t,o)=>t.value.localeCompare(o.value)))}return t}),[u,d]),w=e((()=>{const t=[];for(let o=0;o<1440;o+=u){const e=Math.floor(o/60),r=o%60,n=e>=12?"PM":"AM",p=`${0===e?12:e>12?e-12:e}:${r.toString().padStart(2,"0")} ${n}`,i=`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`;t.push({label:p,value:i,selected:i===s})}if(s&&!t.find((t=>t.value===s))){const[o,e]=s.split(":").map(Number),r=o>=12?"PM":"AM",n=`${0===o?12:o>12?o-12:o}:${e.toString().padStart(2,"0")} ${r}`;t.push({label:n,value:s,selected:!0}),t.sort(((t,o)=>t.value.localeCompare(o.value)))}return t}),[u,s]),S=(t,o)=>{if(t)return o.find((o=>o.value===t))},h=S(d,c),j=S(s,w);return t(n,{children:[t(p,{children:[o(i,{children:"From"}),o(r,{placeHolder:"HH:MM",options:c,defaultOptions:h?[h]:[],onSelect:t=>{!Array.isArray(t)&&"value"in t&&(null==a||a(t.value))},size:"small","data-test":"time-picker-from",width:"154px",placement:"bottom-start"})]}),t(p,{children:[o(i,{children:"To"}),o(r,{placeHolder:"HH:MM",options:w,defaultOptions:j?[j]:[],onSelect:t=>{!Array.isArray(t)&&"value"in t&&(null==m||m(t.value))},size:"small","data-test":"time-picker-to",width:"154px",placement:"bottom-start"})]})]})};export{l as TimePicker};
1
+ import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useMemo as e}from"react";import"../dropdown/DropdownPopover/index.js";import{Dropdown as r}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import"lodash/debounce";import"../TypographyStyle.js";import"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{TimePickerContainer as n,TimeInputWrapper as p,TimeLabel as i}from"./DatePicker.styled.js";const d=d=>{let{fromTime:l="00:00",toTime:s="23:59",onFromTimeChange:a,onToTimeChange:m,timeInterval:c=30}=d;const u=e((()=>{const t=[];for(let o=0;o<1440;o+=c){const e=Math.floor(o/60),r=o%60,n=e>=12?"PM":"AM",p=`${0===e?12:e>12?e-12:e}:${r.toString().padStart(2,"0")} ${n}`,i=`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`;t.push({label:p,value:i,selected:i===l})}if(l&&!t.find((t=>t.value===l))){const[o,e]=l.split(":").map(Number),r=o>=12?"PM":"AM",n=`${0===o?12:o>12?o-12:o}:${e.toString().padStart(2,"0")} ${r}`;t.push({label:n,value:l,selected:!0}),t.sort(((t,o)=>t.value.localeCompare(o.value)))}return t}),[c,l]),w=e((()=>{const t=[];for(let o=0;o<1440;o+=c){const e=Math.floor(o/60),r=o%60,n=e>=12?"PM":"AM",p=`${0===e?12:e>12?e-12:e}:${r.toString().padStart(2,"0")} ${n}`,i=`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`;t.push({label:p,value:i,selected:i===s})}if(s&&!t.find((t=>t.value===s))){const[o,e]=s.split(":").map(Number),r=o>=12?"PM":"AM",n=`${0===o?12:o>12?o-12:o}:${e.toString().padStart(2,"0")} ${r}`;t.push({label:n,value:s,selected:!0}),t.sort(((t,o)=>t.value.localeCompare(o.value)))}return t}),[c,s]),S=(t,o)=>{if(t)return o.find((o=>o.value===t))},h=S(l,u),j=S(s,w);return t(n,{children:[t(p,{children:[o(i,{children:"From"}),o(r,{placeHolder:"HH:MM",options:u,defaultOptions:h?[h]:[],onSelect:t=>{!Array.isArray(t)&&"value"in t&&(null==a||a(t.value))},size:"small","data-test":"time-picker-from",width:"154px",placement:"bottom-start"})]}),t(p,{children:[o(i,{children:"To"}),o(r,{placeHolder:"HH:MM",options:w,defaultOptions:j?[j]:[],onSelect:t=>{!Array.isArray(t)&&"value"in t&&(null==m||m(t.value))},size:"small","data-test":"time-picker-to",width:"154px",placement:"bottom-start"})]})]})};export{d as TimePicker};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{format as n}from"date-fns";import{useState as r,useEffect as i}from"react";import{CustomDateTime as s}from"../../custom-date-time/CustomDateTime.js";import{COUPON_EXPIRATION as a}from"../type.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as p}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"../../zeroState/ZeroState.js";import"../../../constants/Theme.js";import"../../../_virtual/_tslib.js";import"lodash/debounce";import{BodySecondary as d}from"../../TypographyStyle.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../checkBox/CheckBox.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../button/Button.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../../icon-button/IconButton.js";import{Input as c}from"../../input/Input.js";import"../../dropdown/MenuItem/MenuItem.js";const l=l=>{var m;const[u,D]=r(),[x,f]=r(),j=(new Date).setDate((new Date).getDate()+1),w=()=>{try{const e=l.discountData.expireAt;if(!e)return j;let t;return"object"==typeof e&&"seconds"in e?t=new Date(1e3*e.seconds):e instanceof Date?t=e:"number"==typeof e||"string"==typeof e?t=new Date(e):(console.warn("safeToDate: unknown type",e),t=j),isNaN(t.getTime())?(console.warn("safeToDate: Invalid date for value:",e),j):t}catch(e){return console.error("safeToDate error:",e),j}},I=[{selected:l.selectedExpiration===a.DYNAMIC_EXPIRATION,label:"After a certain no. of days",value:a.DYNAMIC_EXPIRATION},{selected:l.selectedExpiration===a.FIXED_EXPIRATION,label:"Fixed expiry date",value:a.FIXED_EXPIRATION}];i((()=>{(void 0===l.selectedExpiration||null===l.selectedExpiration||u||x)&&l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:void 0,expireAt:void 0})),l.selectedExpiration&&(u||x)&&(l.selectedExpiration===a.FIXED_EXPIRATION?f(void 0):D(void 0))}),[l.selectedExpiration,u,x]);return e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13,margin:"16px 0 0 28px"}},{children:[t("div",{children:!l.hideExpirationOptions&&e(o,{children:[t(d,Object.assign({style:{marginBottom:8}},{children:"Expiration"})),t("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:t(p,{width:"268px",options:I,placement:"bottom-start",onSelect:e=>{const t=e.value;l.setSelectedExpiration(t),l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAt:void 0,expireAfter:void 0}))},truncatedText:!1})}))]})}),l.selectedExpiration===a.DYNAMIC_EXPIRATION&&t(c,{value:null===(m=l.discountData.expireAfter)||void 0===m?void 0:m.toString(),placeholder:"Eg. 5",labelText:"No. of days before coupon expires",width:"268px",type:"number",onChangeText:e=>{(e=>{f(void 0);const t=Number.parseInt(e);t>0?l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:t,expireAt:void 0})):f("Please enter valid input")})(e)},isRequired:!0,errorMessage:l.inValidCouponExpiry?"Required Field":x,state:l.inValidCouponExpiry?"invalid":"none"}),l.selectedExpiration===a.FIXED_EXPIRATION&&e(o,{children:[t(d,{children:"Expiring on"}),t(s,{placement:"bottom-start",time:(()=>{try{return n(w(),"hh:mm a")}catch(e){return console.error("formatTime error:",e),""}})(),date:new Date(w()),error:u,setError:D,onChange:e=>{l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAt:e,expireAfter:void 0}))},minDate:new Date(j)})]})]}))};export{l as CouponExpiration};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{format as n}from"date-fns";import{useState as r,useEffect as i}from"react";import{CustomDateTime as s}from"../../custom-date-time/CustomDateTime.js";import{COUPON_EXPIRATION as a}from"../type.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as p}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"../../zeroState/ZeroState.js";import"lodash/debounce";import{BodySecondary as d}from"../../TypographyStyle.js";import"../../../constants/Theme.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../checkBox/CheckBox.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../button/Button.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../../icon-button/IconButton.js";import{Input as c}from"../../input/Input.js";import"../../dropdown/MenuItem/MenuItem.js";const l=l=>{var m;const[u,D]=r(),[x,f]=r(),j=(new Date).setDate((new Date).getDate()+1),w=()=>{try{const e=l.discountData.expireAt;if(!e)return j;let t;return"object"==typeof e&&"seconds"in e?t=new Date(1e3*e.seconds):e instanceof Date?t=e:"number"==typeof e||"string"==typeof e?t=new Date(e):(console.warn("safeToDate: unknown type",e),t=j),isNaN(t.getTime())?(console.warn("safeToDate: Invalid date for value:",e),j):t}catch(e){return console.error("safeToDate error:",e),j}},I=[{selected:l.selectedExpiration===a.DYNAMIC_EXPIRATION,label:"After a certain no. of days",value:a.DYNAMIC_EXPIRATION},{selected:l.selectedExpiration===a.FIXED_EXPIRATION,label:"Fixed expiry date",value:a.FIXED_EXPIRATION}];i((()=>{(void 0===l.selectedExpiration||null===l.selectedExpiration||u||x)&&l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:void 0,expireAt:void 0})),l.selectedExpiration&&(u||x)&&(l.selectedExpiration===a.FIXED_EXPIRATION?f(void 0):D(void 0))}),[l.selectedExpiration,u,x]);return e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13,margin:"16px 0 0 28px"}},{children:[t("div",{children:!l.hideExpirationOptions&&e(o,{children:[t(d,Object.assign({style:{marginBottom:8}},{children:"Expiration"})),t("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:t(p,{width:"268px",options:I,placement:"bottom-start",onSelect:e=>{const t=e.value;l.setSelectedExpiration(t),l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAt:void 0,expireAfter:void 0}))},truncatedText:!1})}))]})}),l.selectedExpiration===a.DYNAMIC_EXPIRATION&&t(c,{value:null===(m=l.discountData.expireAfter)||void 0===m?void 0:m.toString(),placeholder:"Eg. 5",labelText:"No. of days before coupon expires",width:"268px",type:"number",onChangeText:e=>{(e=>{f(void 0);const t=Number.parseInt(e);t>0?l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:t,expireAt:void 0})):f("Please enter valid input")})(e)},isRequired:!0,errorMessage:l.inValidCouponExpiry?"Required Field":x,state:l.inValidCouponExpiry?"invalid":"none"}),l.selectedExpiration===a.FIXED_EXPIRATION&&e(o,{children:[t(d,{children:"Expiring on"}),t(s,{placement:"bottom-start",time:(()=>{try{return n(w(),"hh:mm a")}catch(e){return console.error("formatTime error:",e),""}})(),date:new Date(w()),error:u,setError:D,onChange:e=>{l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAt:e,expireAfter:void 0}))},minDate:new Date(j)})]})]}))};export{l as CouponExpiration};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import{ApplicationType as o}from"@bikdotai/bik-models/growth/models/bik-store";import{useState as n,useEffect as l}from"react";import{DISCOUNT_TYPES as r,MIN_PURCHASE_REQUIREMENT as d,DISCOUNT_APPLIES_TO as a,OFFER_APPLIES_TO as c,initialStaticCouponErrorState as s,initialDynamicCouponErrorState as u,COUPON_EXPIRATION as p,DISCOUNT_TARGET_TYPES as C,DISCOUNT_TARGET_SELECTION as b,DISCOUNT_VALUE_TYPES as v}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as y}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{DEFAULT_THEME as P}from"../../constants/Theme.js";import"../../_virtual/_tslib.js";import"lodash/debounce";import{TitleSmall as m,BodyCaption as I,TitleRegular as h}from"../TypographyStyle.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as S}from"../modals/styledModal.js";import{ProductPickerContent as O}from"../product-picker/ProductPickerModal.js";import{Tag as E}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import f from"../../assets/icons/gift_icon.svg.js";import g from"../../assets/icons/percentage_icon.svg.js";import V from"../../assets/icons/shipping_icon.svg.js";import D from"../../assets/icons/triangle_error.svg.js";import _ from"../../assets/icons/warning.svg.js";import{ProductPickerModal as A}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as N}from"../variable-picker-v3/model.js";import{VariablePicker as k}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as j,CouponTypeContainerStyled as F,VariablePickerContainer as x}from"./DiscountModal.styled.js";import{validateDiscountData as R,descriptionBuilder as M}from"./DiscountUtils.js";import w,{DISCOUNT_PRODUCTS as q}from"./DynamicCoupon/DynamicCoupon.js";import U from"./StaticCoupon/StaticCoupon.js";const L=L=>{var B,G,Y,X,Q,H,z,K,$,Z,J;const W=[{id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:L.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e(g,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:r.BUY_X_GET_Y,icon:i=>e(f,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:r.FREE_SHIPPING,icon:i=>e(V,{width:24,height:24,color:i})}],[ee,ie]=n(),[te,oe]=n(),[ne,le]=n(),[re,de]=n(null!==(B=L.data)&&void 0!==B?B:"string"==typeof L.hideOption?{isStaticCoupon:"dynamic"===L.hideOption}:{isStaticCoupon:!0}),[ae,ce]=n(!0),[se,ue]=n(),[pe,Ce]=n((null===(G=L.data)||void 0===G?void 0:G.minAmount)?d.AMOUNT:(null===(Y=L.data)||void 0===Y?void 0:Y.minQuantity)?d.QUANTITY:d.NA),[be,ve]=n(a.ENTIRE_ORDER),[ye,Pe]=n(c.SPECIFIC_PRODUCTS),[me,Ie]=n(c.SPECIFIC_PRODUCTS),[he,Se]=n(void 0),[Oe,Ee]=n(void 0),[Te,fe]=n(void 0),[ge,Ve]=n(void 0),[De,_e]=n(void 0),[Ae,Ne]=n(void 0),[ke,je]=n(0),[Fe,xe]=n(""),[Re,Me]=n(W[0]),[we,qe]=n(!1),[Ue,Le]=n(s),[Be,Ge]=n(u),[Ye,Xe]=n(L.getDetailedDescription?p.FIXED_EXPIRATION:p.DYNAMIC_EXPIRATION),Qe=[{value:r.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:se===r.AMOUNT_OFF_ORDER},{value:r.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:se===r.AMOUNT_OFF_PRODUCTS},{value:r.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:se===r.BUY_X_GET_Y},{value:r.FREE_SHIPPING,label:"Free shipping",selected:se===r.FREE_SHIPPING}];l((()=>{L.makeExpiryMandatory&&qe(!0)}),[L.makeExpiryMandatory]),l((()=>{var e,i,t,o,n,l,d,s;let u;const{tempCouponData:C,discountType:b}=He();ue(b);const y=(e,i)=>{Me(C.valueType===v.FIXED_AMOUNT?W[e]:W[i])},P=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(qe(!0),(null==C?void 0:C.expireAt)&&Xe(p.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Xe(p.DYNAMIC_EXPIRATION)),b){case r.AMOUNT_OFF_ORDER:y(0,1),ve(a.ENTIRE_ORDER);break;case r.AMOUNT_OFF_PRODUCTS:y(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(a.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(a.SPECIFIC_PRODUCTS),P(null===(o=C.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,Ve)):ve(a.ENTIRE_ORDER);break;case r.BUY_X_GET_Y:Me(W[2]),(null===(n=C.entitledCollectionIds)||void 0===n?void 0:n.length)?Ie(c.SPECIFIC_COLLECTIONS):(Ie(c.SPECIFIC_PRODUCTS),P(null===(l=C.productVariableConf)||void 0===l?void 0:l.entitledProductVariable,Ve)),(null===(d=C.prerequisiteCollectionIds)||void 0===d?void 0:d.length)?Pe(c.SPECIFIC_COLLECTIONS):(Pe(c.SPECIFIC_PRODUCTS),P(null===(s=C.productVariableConf)||void 0===s?void 0:s.prerequisiteProductVariable,_e));break;case r.FREE_SHIPPING:Me(W[3])}de(Object.assign({},C)),L.hideProbability||(u=$e()),ce(R(C,pe,b,L.hideProbability||!1,u,!!C.isStaticCoupon,L.getDetailedDescription||!1)),L.hideProbability||$e()}),[]),l((()=>{let e;L.hideProbability||(e=$e()),ce(R(re,pe,se,L.hideProbability||!1,e,!!re.isStaticCoupon,L.getDetailedDescription||!1))}),[re,ke,se,pe]),l((()=>{var e,i,t,o,n,l,r;if(!L.newPickerConf&&((null===(e=L.products)||void 0===e?void 0:e.length)||(null===(i=L.collection)||void 0===i?void 0:i.length))){if(L.products&&(null===(t=L.products)||void 0===t?void 0:t.length)){if(null===(o=L.data)||void 0===o?void 0:o.entitledProductIds){const e=L.products.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}if(null===(n=L.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=L.products.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Se(e)}}if(L.collection&&L.collection.length){if(null===(l=L.data)||void 0===l?void 0:l.entitledCollectionIds){const e=L.collection.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ne(e)}if(null===(r=L.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=L.collection.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}}}}),[L.products,L.collection]),l((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=L.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&Ee(L.data.productsConf.entitledProducts),(null===(o=null===(t=L.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&Se(L.data.productsConf.prerequisiteProducts),(null===(l=null===(n=L.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ne(L.data.collectionsConf.entitledCollections),(null===(d=null===(r=L.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&fe(L.data.collectionsConf.prerequisiteCollections)}),[null===(X=L.data)||void 0===X?void 0:X.productsConf,null===(Q=L.data)||void 0===Q?void 0:Q.collectionsConf]),l((()=>{if(!Oe)return;if(L.newPickerConf){const e=[];return Object.values(Oe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}const e=Oe.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}),[Oe]),l((()=>{if(!he)return;if(L.newPickerConf){const e=[];return Object.values(he).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}const e=he.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}),[he]),l((()=>{if(!Ae)return;if(L.newPickerConf){(null==Ae?void 0:Ae.isCustom)&&delete Ae.isCustom;const e=Object.keys(Ae).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}const e=Ae.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}),[Ae]),l((()=>{if(!Te)return;if(L.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}),[Te]);const He=()=>{var e,i,t,o;let n,l=re;return re.isStaticCoupon?re.isStaticCoupon&&L.getDetailedDescription&&(re.targetType===C.SHIPPING_LINE?n=r.FREE_SHIPPING:re.targetType===C.LINE_ITEM?n=re.targetSelection===b.ENTITLED?(null===(t=re.prerequisiteProductIds)||void 0===t?void 0:t.length)||(null===(o=re.prerequisiteCollectionIds)||void 0===o?void 0:o.length)||re.prerequisiteQuantity||re.entitledQuantity?r.BUY_X_GET_Y:r.AMOUNT_OFF_PRODUCTS:r.AMOUNT_OFF_ORDER:(l=Object.assign(Object.assign({},l),{targetType:C.LINE_ITEM,targetSelection:b.ALL,valueType:v.FIXED_AMOUNT}),n=r.AMOUNT_OFF_ORDER)):re.targetType===C.SHIPPING_LINE?n=r.FREE_SHIPPING:re.targetType===C.LINE_ITEM?n=re.targetSelection===b.ENTITLED?(null===(e=re.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=re.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||re.prerequisiteQuantity||re.entitledQuantity?r.BUY_X_GET_Y:r.AMOUNT_OFF_PRODUCTS:r.AMOUNT_OFF_ORDER:(l=Object.assign(Object.assign({},l),{targetType:C.LINE_ITEM,targetSelection:b.ALL,valueType:v.FIXED_AMOUNT}),n=r.AMOUNT_OFF_ORDER),{discountType:n,tempCouponData:l}},ze=()=>{Le(s),Ge(u)},Ke=e=>{var i;const t={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(i=re.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":re.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((i=>{e[i]&&(o=t[i])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(xe(n>1?"Please add discount details":o),!0)},$e=()=>{if(!L.quadrant||!L.probability)return;const e=[...L.probability];let i=[];e.length>=L.quadrant&&e.splice(L.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(re.probability||0);return je(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ze=e=>{var i,t,o,n,l,d,a,c,s,u,p,y,P,m,I,h;const S=e.value;ue(S),Se([]),Ee([]),fe([]),Ne([]),S===r.FREE_SHIPPING?de({value:100,targetSelection:b.ALL,targetType:C.SHIPPING_LINE,valueType:v.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(i=re.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=re.expireAfter)&&void 0!==t?t:void 0,probability:re.probability,minQuantity:null!==(o=re.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(n=re.minAmount)&&void 0!==n?n:void 0}):S===r.BUY_X_GET_Y?de({value:100,targetSelection:b.ENTITLED,targetType:C.LINE_ITEM,valueType:v.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(l=re.expireAt)&&void 0!==l?l:void 0,expireAfter:null!==(d=re.expireAfter)&&void 0!==d?d:void 0,probability:re.probability,minQuantity:void 0,minAmount:void 0}):S===r.AMOUNT_OFF_ORDER?de({targetSelection:b.ALL,targetType:C.LINE_ITEM,valueType:null!==(a=re.valueType)&&void 0!==a?a:v.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(c=re.expireAt)&&void 0!==c?c:void 0,expireAfter:null!==(s=re.expireAfter)&&void 0!==s?s:void 0,probability:re.probability,value:re.value,minQuantity:null!==(u=re.minQuantity)&&void 0!==u?u:void 0,minAmount:null!==(p=re.minAmount)&&void 0!==p?p:void 0}):S===r.AMOUNT_OFF_PRODUCTS&&de({targetSelection:b.ENTITLED,targetType:C.LINE_ITEM,valueType:null!==(y=re.valueType)&&void 0!==y?y:v.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(P=re.expireAt)&&void 0!==P?P:void 0,expireAfter:null!==(m=re.expireAfter)&&void 0!==m?m:void 0,probability:re.probability,value:re.value,minQuantity:null!==(I=re.minQuantity)&&void 0!==I?I:void 0,minAmount:null!==(h=re.minAmount)&&void 0!==h?h:void 0})},Je=i=>i&&e(E,{theme:"light",tagText:i,type:"negative",LeadingIcon:_});return i(S,Object.assign({width:(ne||ee)&&L.newPickerConf?"25px":"640px",open:L.isOpen,hideCrossButton:!!te,headingTitle:ee?"Select Products":L.title,headingSubtitle:ee?void 0:L.subTitle,footerLeftCustomElement:Fe?Je(Fe):L.errorMsg?Je(L.errorMsg):!L.quadrant||L.hideProbability?e(t,{}):ke<=1?e(E,{theme:"light",tagText:`Current probability sum: ${ke}`,type:"white"}):e(T,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(E,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${ke}`,type:"negative",LeadingIcon:D})})})),headerRightCustomElement:L.allowStaticCoupon||ee?void 0:e(y,{options:Qe,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ze(e)}}),onClose:L.onClose,footerContainerStyle:{borderTop:`1px solid ${P.colorsV2.stroke.primary}`},primaryButton:ee?{buttonType:"primary",onClick:()=>{ie(void 0)},buttonText:"Add"}:ne?{buttonType:"primary",onClick:()=>{le(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(H=L.loading)&&void 0!==H&&H,onClick:()=>{var e,i,t,o,n,l,s,u,p,C;if(ze(),re.isStaticCoupon&&!L.getDetailedDescription){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=re,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!L.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(Ke(r))return void Le(r);if(ae||ke>1)return void xe(!L.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");L.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:re.title})}else if(re.isStaticCoupon&&L.getDetailedDescription){const{isStaticCoupon:l,couponCode:s,title:u,quadrant:p,probability:C}=re,b={invalidDiscountCode:!s,invalidCouponTitle:!u,invalidCouponDescription:!1,inValidProbability:!L.hideProbability&&(null!=C?C:-1)<0||(null!=C?C:0)>1||Number.isNaN(null!=C?C:0)};if(Ke(b))return void Le(b);const v={invalidCouponTitle:!re.title,inValidProbability:!L.hideProbability&&(null!==(e=re.probability)&&void 0!==e?e:-1)<=0||(null!==(i=re.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=re.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!re.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(se!==r.BUY_X_GET_Y&&pe!==d.NA){const{minAmount:e,minQuantity:i}=re;v.inValidMinimumAmount=pe===d.AMOUNT&&!e,v.inValidMinimumQuantity=pe===d.QUANTITY&&!i}if(we&&(v.inValidCouponExpiry=!re.expireAt&&!re.expireAfter),se!==r.AMOUNT_OFF_ORDER&&se!==r.AMOUNT_OFF_PRODUCTS||(be!==a.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(v.inValidProductSelection=!0,v.inValidProductVariableSelection=!0),be===a.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(v.inValidCollectionSelection=!0)),se===r.BUY_X_GET_Y&&(re.prerequisiteQuantity||(v.inValidBuyXValue=!0),re.entitledQuantity||(v.inValidGetYValue=!0),ye!==c.SPECIFIC_PRODUCTS||!he||Object.keys(he).length||De||(v.inValidBuyXProductSelection=!0,v.inValidBuyXProductVariableSelection=!0),ye===c.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(v.inValidBuyXCollectionSelection=!0),me!==c.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(v.inValidGetYProductSelection=!0,v.inValidGetYProductVariableSelection=!0),me===c.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(v.inValidGetYCollectionSelection=!0)),Ke(v))return void Ge(v);if(ae||ke>1)return void xe(!L.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");L.onSaveClicked(Object.assign(Object.assign({},re),{couponCode:s,isStaticCoupon:l,quadrant:p,description:M(re,L.currency,null!==(o=L.products)&&void 0!==o?o:[],null!==(n=L.collection)&&void 0!==n?n:[]),productsConf:{entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[]},collectionsConf:{entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=ge?ge:{},prerequisiteProductVariable:null!=De?De:{}}}))}else{const e={invalidCouponTitle:!re.title,inValidProbability:!L.hideProbability&&(null!==(l=re.probability)&&void 0!==l?l:-1)<=0||(null!==(s=re.probability)&&void 0!==s?s:-1)>1||Number.isNaN(null!==(u=re.probability)&&void 0!==u?u:-1),inValidDiscountAmount:!re.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(se!==r.BUY_X_GET_Y&&pe!==d.NA){const{minAmount:i,minQuantity:t}=re;e.inValidMinimumAmount=pe===d.AMOUNT&&!i,e.inValidMinimumQuantity=pe===d.QUANTITY&&!t}if(we&&(e.inValidCouponExpiry=!re.expireAt&&!re.expireAfter),se!==r.AMOUNT_OFF_ORDER&&se!==r.AMOUNT_OFF_PRODUCTS||(be!==a.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(e.inValidProductSelection=!0,e.inValidProductVariableSelection=!0),be===a.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(e.inValidCollectionSelection=!0)),se===r.BUY_X_GET_Y&&(re.prerequisiteQuantity||(e.inValidBuyXValue=!0),re.entitledQuantity||(e.inValidGetYValue=!0),ye!==c.SPECIFIC_PRODUCTS||!he||Object.keys(he).length||De||(e.inValidBuyXProductSelection=!0,e.inValidBuyXProductVariableSelection=!0),ye===c.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(e.inValidBuyXCollectionSelection=!0),me!==c.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(e.inValidGetYProductSelection=!0,e.inValidGetYProductVariableSelection=!0),me===c.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(e.inValidGetYCollectionSelection=!0)),Ke(e))return void Ge(e);if(ae||ke>1)return void xe(!L.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");L.onSaveClicked(Object.assign(Object.assign({},re),{isStaticCoupon:re.isStaticCoupon,description:M(re,L.currency,null!==(p=L.products)&&void 0!==p?p:[],null!==(C=L.collection)&&void 0!==C?C:[]),productsConf:{entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[]},collectionsConf:{entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=ge?ge:{},prerequisiteProductVariable:null!=De?De:{}}}))}}},secondaryButton:ee?{buttonType:"tertiaryGray",onClick:()=>{ie(void 0)},buttonText:"Back"}:ne?{buttonType:"tertiaryGray",onClick:()=>{le(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:L.onClose,buttonText:"Cancel"}},{children:[!ee&&!ne&&i(j,{children:[L.allowStaticCoupon&&!ee&&!L.hideOption&&i(F,Object.assign({selectedDiv:re.isStaticCoupon?1:2},{children:["static"===L.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{re.isStaticCoupon||(de({isStaticCoupon:!0,quadrant:re.quadrant}),xe(""),ze())}},{children:[e(m,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?P.colorsV2.content.brand:void 0}},{children:"Static Code"})),e(I,Object.assign({style:re.isStaticCoupon?{color:P.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===L.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;re.isStaticCoupon&&(ue(r.AMOUNT_OFF_ORDER),de({isStaticCoupon:!1,quadrant:re.quadrant,targetType:C.LINE_ITEM,targetSelection:b.ALL,valueType:v.FIXED_AMOUNT}),xe(""),ze(),Me({id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i}},{children:L.currency||""}))}),qe(null!==(i=L.makeExpiryMandatory)&&void 0!==i&&i),Ce(d.NA))}},{children:[e(m,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?void 0:P.colorsV2.content.brand}},{children:"Dynamic Code"})),e(I,Object.assign({style:re.isStaticCoupon?{}:{color:P.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),!L.getDetailedDescription&&e(h,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"}))," ",re.isStaticCoupon&&!ee&&!L.getDetailedDescription&&e(U,{discountData:re,setDiscountData:de,hideProbability:L.hideProbability||!1,discountAdminUrl:L.discountAdminUrl,staticDiscountValidationError:Ue,currency:L.currency}),re.isStaticCoupon&&!ee&&L.getDetailedDescription&&e(U,{discountData:re,setDiscountData:de,hideProbability:L.hideProbability||!1,discountAdminUrl:L.discountAdminUrl,staticDiscountValidationError:Ue,currency:L.currency,getDetailedDescription:!0,selectedCouponType:se,setSelectedCouponType:ue,selectedMinimumRequirement:pe,setSelectedMinimumRequirement:Ce,discountCouponAppliesTo:be,offerAppliesToBuy:ye,offerAppliesToGet:me,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:Pe,setOfferAppliesToGet:Ie,hideExpiration:L.hideExpiration||!1,onChangeCouponType:Ze,entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[],setEntitledProducts:Ee,setPrerequisiteProducts:Se,entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[],setEntitledCollections:Ne,setPrerequisiteCollections:fe,setIsProductPickerOpen:ie,setIsProductVariablePickerOpen:oe,setIsCollectionPickerOpen:le,productPickerOpen:ee,productVariablePickerOpen:te,collectionPickerOpen:ne,useNewPicker:!!L.newPickerConf,selectedDiscountDetails:Re,setSelectedDiscountDetails:Me,isProductVariableSupported:L.isProductVariableSupported,entitledProductVariable:ge,setEntitledProductVariable:Ve,preRequisiteProductVariable:De,setPreRequisiteProductVariable:_e,productVariableList:L.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:qe,dynamicDiscountValidationError:Be,setDynamicDiscountValidationError:Ge,setValidationErrorMessage:xe,resetValidationErrors:ze,discountDetailsOptions:W,selectedExpiration:Ye,setSelectedExpiration:Xe,makeExpiryMandatory:!!L.makeExpiryMandatory}),!re.isStaticCoupon&&!ee&&!ne&&e(w,{currency:L.currency,entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[],setEntitledProducts:Ee,setPrerequisiteProducts:Se,discountData:re,productPickerOpen:ee,productVariablePickerOpen:te,setIsProductPickerOpen:ie,setIsProductVariablePickerOpen:oe,setDiscountData:de,selectedCouponType:se,setSelectedCouponType:ue,selectedMinimumRequirement:pe,setSelectedMinimumRequirement:Ce,discountCouponAppliesTo:be,offerAppliesToBuy:ye,offerAppliesToGet:me,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:Pe,setOfferAppliesToGet:Ie,hideProbability:L.hideProbability||!1,hideExpiration:L.hideExpiration||!1,allowStaticCoupon:L.allowStaticCoupon,onChangeCouponType:Ze,collectionPickerOpen:ne,entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:le,setEntitledCollections:Ne,setPrerequisiteCollections:fe,useNewPicker:!!L.newPickerConf,setSelectedDiscountDetails:Me,selectedDiscountDetails:Re,isProductVariableSupported:L.isProductVariableSupported,entitledProductVariable:ge,setEntitledProductVariable:Ve,preRequisiteProductVariable:De,setPreRequisiteProductVariable:_e,productVariableList:L.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:qe,dynamicDiscountValidationError:Be,setDynamicDiscountValidationError:Ge,setValidationErrorMessage:xe,resetValidationErrors:ze,discountDetailsOptions:W,selectedExpiration:Ye,setSelectedExpiration:Xe,makeExpiryMandatory:!!L.makeExpiryMandatory})]}),!!ee&&i(t,{children:[!L.newPickerConf&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(O,{show:!0,onSave:()=>{},products:null!==(z=L.products)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{ie(void 0)},selectedProducts:null!==(K=ee===q.ENTITLED?Oe:he)&&void 0!==K?K:[],setSelectedProducts:ee===q.ENTITLED?Ee:Se,onSearchKeyChange:L.onProductSearch})})),L.newPickerConf&&e(A,{visible:!0,onClose:()=>ie(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=L.newPickerConf)||void 0===o?void 0:o.fetchCollections)?L.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=L.newPickerConf)||void 0===l?void 0:l.fetchProducts)?L.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:ee===q.ENTITLED?Oe:he,onAdd:e=>{ee===q.ENTITLED?Ee(e):Se(e),ie(void 0)},zIndex:200,storeId:L.newPickerConf.storeId,appType:L.newPickerConf.appType||o.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=L.newPickerConf)||void 0===n?void 0:n.searchInCollection)?L.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=L.newPickerConf)||void 0===o?void 0:o.searchProducts)?L.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!ne&&e("div",Object.assign({style:{padding:"12px 0"}},{children:i(t,{children:[L.newPickerConf&&e(A,{visible:!0,onClose:()=>le(void 0),collectionFetcher:L.newPickerConf.fetchCollections,productFetcher:L.newPickerConf.fetchProducts,selectedItems:ne===q.ENTITLED?Ae:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),ne===q.ENTITLED?Ne(e):fe(e),le(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:L.newPickerConf.storeId,appType:L.newPickerConf.appType||o.BIK,searchInCollectionFetcher:L.newPickerConf.searchInCollection,searchFetcher:L.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!L.newPickerConf&&e(O,{show:!0,onSave:()=>{},products:null!==($=L.collection)&&void 0!==$?$:[],title:"Select Products",onClose:()=>{le(void 0)},selectedProducts:null!==(Z=ne===q.ENTITLED?Ae:Te)&&void 0!==Z?Z:[],setSelectedProducts:ne===q.ENTITLED?Ne:fe,onSearchKeyChange:L.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),te&&e(x,{children:e("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e(k,{type:N.EMBEDDED,data:null!==(J=L.productVariableList)&&void 0!==J?J:[],showHeader:!0,onSelect:e=>{if(te===q.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Ve({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}if(te===q.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;_e({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}},onClose:()=>{oe(void 0)}})}))})]}))};export{L as DiscountModal};
1
+ import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import{ApplicationType as o}from"@bikdotai/bik-models/growth/models/bik-store";import{useState as n,useEffect as l}from"react";import{DISCOUNT_TYPES as r,MIN_PURCHASE_REQUIREMENT as d,DISCOUNT_APPLIES_TO as a,OFFER_APPLIES_TO as c,initialStaticCouponErrorState as s,initialDynamicCouponErrorState as u,COUPON_EXPIRATION as p,DISCOUNT_TARGET_TYPES as C,DISCOUNT_TARGET_SELECTION as b,DISCOUNT_VALUE_TYPES as v}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as y}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import"lodash/debounce";import{TitleSmall as P,BodyCaption as m,TitleRegular as I}from"../TypographyStyle.js";import{DEFAULT_THEME as h}from"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as S}from"../modals/styledModal.js";import{ProductPickerContent as O}from"../product-picker/ProductPickerModal.js";import{Tag as E}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import f from"../../assets/icons/gift_icon.svg.js";import g from"../../assets/icons/percentage_icon.svg.js";import V from"../../assets/icons/shipping_icon.svg.js";import D from"../../assets/icons/triangle_error.svg.js";import _ from"../../assets/icons/warning.svg.js";import{ProductPickerModal as A}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as N}from"../variable-picker-v3/model.js";import{VariablePicker as k}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as j,CouponTypeContainerStyled as F,VariablePickerContainer as x}from"./DiscountModal.styled.js";import{validateDiscountData as R,descriptionBuilder as M}from"./DiscountUtils.js";import w,{DISCOUNT_PRODUCTS as q}from"./DynamicCoupon/DynamicCoupon.js";import U from"./StaticCoupon/StaticCoupon.js";const L=L=>{var B,G,Y,X,Q,H,z,K,$,Z,J;const W=[{id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:L.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e(g,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:r.BUY_X_GET_Y,icon:i=>e(f,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:r.FREE_SHIPPING,icon:i=>e(V,{width:24,height:24,color:i})}],[ee,ie]=n(),[te,oe]=n(),[ne,le]=n(),[re,de]=n(null!==(B=L.data)&&void 0!==B?B:"string"==typeof L.hideOption?{isStaticCoupon:"dynamic"===L.hideOption}:{isStaticCoupon:!0}),[ae,ce]=n(!0),[se,ue]=n(),[pe,Ce]=n((null===(G=L.data)||void 0===G?void 0:G.minAmount)?d.AMOUNT:(null===(Y=L.data)||void 0===Y?void 0:Y.minQuantity)?d.QUANTITY:d.NA),[be,ve]=n(a.ENTIRE_ORDER),[ye,Pe]=n(c.SPECIFIC_PRODUCTS),[me,Ie]=n(c.SPECIFIC_PRODUCTS),[he,Se]=n(void 0),[Oe,Ee]=n(void 0),[Te,fe]=n(void 0),[ge,Ve]=n(void 0),[De,_e]=n(void 0),[Ae,Ne]=n(void 0),[ke,je]=n(0),[Fe,xe]=n(""),[Re,Me]=n(W[0]),[we,qe]=n(!1),[Ue,Le]=n(s),[Be,Ge]=n(u),[Ye,Xe]=n(L.getDetailedDescription?p.FIXED_EXPIRATION:p.DYNAMIC_EXPIRATION),Qe=[{value:r.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:se===r.AMOUNT_OFF_ORDER},{value:r.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:se===r.AMOUNT_OFF_PRODUCTS},{value:r.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:se===r.BUY_X_GET_Y},{value:r.FREE_SHIPPING,label:"Free shipping",selected:se===r.FREE_SHIPPING}];l((()=>{L.makeExpiryMandatory&&qe(!0)}),[L.makeExpiryMandatory]),l((()=>{var e,i,t,o,n,l,d,s;let u;const{tempCouponData:C,discountType:b}=He();ue(b);const y=(e,i)=>{Me(C.valueType===v.FIXED_AMOUNT?W[e]:W[i])},P=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(qe(!0),(null==C?void 0:C.expireAt)&&Xe(p.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Xe(p.DYNAMIC_EXPIRATION)),b){case r.AMOUNT_OFF_ORDER:y(0,1),ve(a.ENTIRE_ORDER);break;case r.AMOUNT_OFF_PRODUCTS:y(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(a.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(a.SPECIFIC_PRODUCTS),P(null===(o=C.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,Ve)):ve(a.ENTIRE_ORDER);break;case r.BUY_X_GET_Y:Me(W[2]),(null===(n=C.entitledCollectionIds)||void 0===n?void 0:n.length)?Ie(c.SPECIFIC_COLLECTIONS):(Ie(c.SPECIFIC_PRODUCTS),P(null===(l=C.productVariableConf)||void 0===l?void 0:l.entitledProductVariable,Ve)),(null===(d=C.prerequisiteCollectionIds)||void 0===d?void 0:d.length)?Pe(c.SPECIFIC_COLLECTIONS):(Pe(c.SPECIFIC_PRODUCTS),P(null===(s=C.productVariableConf)||void 0===s?void 0:s.prerequisiteProductVariable,_e));break;case r.FREE_SHIPPING:Me(W[3])}de(Object.assign({},C)),L.hideProbability||(u=$e()),ce(R(C,pe,b,L.hideProbability||!1,u,!!C.isStaticCoupon,L.getDetailedDescription||!1)),L.hideProbability||$e()}),[]),l((()=>{let e;L.hideProbability||(e=$e()),ce(R(re,pe,se,L.hideProbability||!1,e,!!re.isStaticCoupon,L.getDetailedDescription||!1))}),[re,ke,se,pe]),l((()=>{var e,i,t,o,n,l,r;if(!L.newPickerConf&&((null===(e=L.products)||void 0===e?void 0:e.length)||(null===(i=L.collection)||void 0===i?void 0:i.length))){if(L.products&&(null===(t=L.products)||void 0===t?void 0:t.length)){if(null===(o=L.data)||void 0===o?void 0:o.entitledProductIds){const e=L.products.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}if(null===(n=L.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=L.products.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Se(e)}}if(L.collection&&L.collection.length){if(null===(l=L.data)||void 0===l?void 0:l.entitledCollectionIds){const e=L.collection.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ne(e)}if(null===(r=L.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=L.collection.filter((e=>{var i,t;return null===(t=null===(i=L.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}}}}),[L.products,L.collection]),l((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=L.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&Ee(L.data.productsConf.entitledProducts),(null===(o=null===(t=L.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&Se(L.data.productsConf.prerequisiteProducts),(null===(l=null===(n=L.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ne(L.data.collectionsConf.entitledCollections),(null===(d=null===(r=L.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&fe(L.data.collectionsConf.prerequisiteCollections)}),[null===(X=L.data)||void 0===X?void 0:X.productsConf,null===(Q=L.data)||void 0===Q?void 0:Q.collectionsConf]),l((()=>{if(!Oe)return;if(L.newPickerConf){const e=[];return Object.values(Oe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}const e=Oe.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}),[Oe]),l((()=>{if(!he)return;if(L.newPickerConf){const e=[];return Object.values(he).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}const e=he.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}),[he]),l((()=>{if(!Ae)return;if(L.newPickerConf){(null==Ae?void 0:Ae.isCustom)&&delete Ae.isCustom;const e=Object.keys(Ae).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}const e=Ae.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}),[Ae]),l((()=>{if(!Te)return;if(L.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}),[Te]);const He=()=>{var e,i,t,o;let n,l=re;return re.isStaticCoupon?re.isStaticCoupon&&L.getDetailedDescription&&(re.targetType===C.SHIPPING_LINE?n=r.FREE_SHIPPING:re.targetType===C.LINE_ITEM?n=re.targetSelection===b.ENTITLED?(null===(t=re.prerequisiteProductIds)||void 0===t?void 0:t.length)||(null===(o=re.prerequisiteCollectionIds)||void 0===o?void 0:o.length)||re.prerequisiteQuantity||re.entitledQuantity?r.BUY_X_GET_Y:r.AMOUNT_OFF_PRODUCTS:r.AMOUNT_OFF_ORDER:(l=Object.assign(Object.assign({},l),{targetType:C.LINE_ITEM,targetSelection:b.ALL,valueType:v.FIXED_AMOUNT}),n=r.AMOUNT_OFF_ORDER)):re.targetType===C.SHIPPING_LINE?n=r.FREE_SHIPPING:re.targetType===C.LINE_ITEM?n=re.targetSelection===b.ENTITLED?(null===(e=re.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=re.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||re.prerequisiteQuantity||re.entitledQuantity?r.BUY_X_GET_Y:r.AMOUNT_OFF_PRODUCTS:r.AMOUNT_OFF_ORDER:(l=Object.assign(Object.assign({},l),{targetType:C.LINE_ITEM,targetSelection:b.ALL,valueType:v.FIXED_AMOUNT}),n=r.AMOUNT_OFF_ORDER),{discountType:n,tempCouponData:l}},ze=()=>{Le(s),Ge(u)},Ke=e=>{var i;const t={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(i=re.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":re.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((i=>{e[i]&&(o=t[i])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(xe(n>1?"Please add discount details":o),!0)},$e=()=>{if(!L.quadrant||!L.probability)return;const e=[...L.probability];let i=[];e.length>=L.quadrant&&e.splice(L.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(re.probability||0);return je(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ze=e=>{var i,t,o,n,l,d,a,c,s,u,p,y,P,m,I,h;const S=e.value;ue(S),Se([]),Ee([]),fe([]),Ne([]),S===r.FREE_SHIPPING?de({value:100,targetSelection:b.ALL,targetType:C.SHIPPING_LINE,valueType:v.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(i=re.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=re.expireAfter)&&void 0!==t?t:void 0,probability:re.probability,minQuantity:null!==(o=re.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(n=re.minAmount)&&void 0!==n?n:void 0}):S===r.BUY_X_GET_Y?de({value:100,targetSelection:b.ENTITLED,targetType:C.LINE_ITEM,valueType:v.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(l=re.expireAt)&&void 0!==l?l:void 0,expireAfter:null!==(d=re.expireAfter)&&void 0!==d?d:void 0,probability:re.probability,minQuantity:void 0,minAmount:void 0}):S===r.AMOUNT_OFF_ORDER?de({targetSelection:b.ALL,targetType:C.LINE_ITEM,valueType:null!==(a=re.valueType)&&void 0!==a?a:v.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(c=re.expireAt)&&void 0!==c?c:void 0,expireAfter:null!==(s=re.expireAfter)&&void 0!==s?s:void 0,probability:re.probability,value:re.value,minQuantity:null!==(u=re.minQuantity)&&void 0!==u?u:void 0,minAmount:null!==(p=re.minAmount)&&void 0!==p?p:void 0}):S===r.AMOUNT_OFF_PRODUCTS&&de({targetSelection:b.ENTITLED,targetType:C.LINE_ITEM,valueType:null!==(y=re.valueType)&&void 0!==y?y:v.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!!L.getDetailedDescription,title:re.title,couponCode:L.getDetailedDescription?re.couponCode:void 0,expireAt:null!==(P=re.expireAt)&&void 0!==P?P:void 0,expireAfter:null!==(m=re.expireAfter)&&void 0!==m?m:void 0,probability:re.probability,value:re.value,minQuantity:null!==(I=re.minQuantity)&&void 0!==I?I:void 0,minAmount:null!==(h=re.minAmount)&&void 0!==h?h:void 0})},Je=i=>i&&e(E,{theme:"light",tagText:i,type:"negative",LeadingIcon:_});return i(S,Object.assign({width:(ne||ee)&&L.newPickerConf?"25px":"640px",open:L.isOpen,hideCrossButton:!!te,headingTitle:ee?"Select Products":L.title,headingSubtitle:ee?void 0:L.subTitle,footerLeftCustomElement:Fe?Je(Fe):L.errorMsg?Je(L.errorMsg):!L.quadrant||L.hideProbability?e(t,{}):ke<=1?e(E,{theme:"light",tagText:`Current probability sum: ${ke}`,type:"white"}):e(T,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(E,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${ke}`,type:"negative",LeadingIcon:D})})})),headerRightCustomElement:L.allowStaticCoupon||ee?void 0:e(y,{options:Qe,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ze(e)}}),onClose:L.onClose,footerContainerStyle:{borderTop:`1px solid ${h.colorsV2.stroke.primary}`},primaryButton:ee?{buttonType:"primary",onClick:()=>{ie(void 0)},buttonText:"Add"}:ne?{buttonType:"primary",onClick:()=>{le(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(H=L.loading)&&void 0!==H&&H,onClick:()=>{var e,i,t,o,n,l,s,u,p,C;if(ze(),re.isStaticCoupon&&!L.getDetailedDescription){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=re,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!L.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(Ke(r))return void Le(r);if(ae||ke>1)return void xe(!L.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");L.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:re.title})}else if(re.isStaticCoupon&&L.getDetailedDescription){const{isStaticCoupon:l,couponCode:s,title:u,quadrant:p,probability:C}=re,b={invalidDiscountCode:!s,invalidCouponTitle:!u,invalidCouponDescription:!1,inValidProbability:!L.hideProbability&&(null!=C?C:-1)<0||(null!=C?C:0)>1||Number.isNaN(null!=C?C:0)};if(Ke(b))return void Le(b);const v={invalidCouponTitle:!re.title,inValidProbability:!L.hideProbability&&(null!==(e=re.probability)&&void 0!==e?e:-1)<=0||(null!==(i=re.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=re.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!re.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(se!==r.BUY_X_GET_Y&&pe!==d.NA){const{minAmount:e,minQuantity:i}=re;v.inValidMinimumAmount=pe===d.AMOUNT&&!e,v.inValidMinimumQuantity=pe===d.QUANTITY&&!i}if(we&&(v.inValidCouponExpiry=!re.expireAt&&!re.expireAfter),se!==r.AMOUNT_OFF_ORDER&&se!==r.AMOUNT_OFF_PRODUCTS||(be!==a.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(v.inValidProductSelection=!0,v.inValidProductVariableSelection=!0),be===a.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(v.inValidCollectionSelection=!0)),se===r.BUY_X_GET_Y&&(re.prerequisiteQuantity||(v.inValidBuyXValue=!0),re.entitledQuantity||(v.inValidGetYValue=!0),ye!==c.SPECIFIC_PRODUCTS||!he||Object.keys(he).length||De||(v.inValidBuyXProductSelection=!0,v.inValidBuyXProductVariableSelection=!0),ye===c.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(v.inValidBuyXCollectionSelection=!0),me!==c.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(v.inValidGetYProductSelection=!0,v.inValidGetYProductVariableSelection=!0),me===c.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(v.inValidGetYCollectionSelection=!0)),Ke(v))return void Ge(v);if(ae||ke>1)return void xe(!L.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");L.onSaveClicked(Object.assign(Object.assign({},re),{couponCode:s,isStaticCoupon:l,quadrant:p,description:M(re,L.currency,null!==(o=L.products)&&void 0!==o?o:[],null!==(n=L.collection)&&void 0!==n?n:[]),productsConf:{entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[]},collectionsConf:{entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=ge?ge:{},prerequisiteProductVariable:null!=De?De:{}}}))}else{const e={invalidCouponTitle:!re.title,inValidProbability:!L.hideProbability&&(null!==(l=re.probability)&&void 0!==l?l:-1)<=0||(null!==(s=re.probability)&&void 0!==s?s:-1)>1||Number.isNaN(null!==(u=re.probability)&&void 0!==u?u:-1),inValidDiscountAmount:!re.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(se!==r.BUY_X_GET_Y&&pe!==d.NA){const{minAmount:i,minQuantity:t}=re;e.inValidMinimumAmount=pe===d.AMOUNT&&!i,e.inValidMinimumQuantity=pe===d.QUANTITY&&!t}if(we&&(e.inValidCouponExpiry=!re.expireAt&&!re.expireAfter),se!==r.AMOUNT_OFF_ORDER&&se!==r.AMOUNT_OFF_PRODUCTS||(be!==a.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(e.inValidProductSelection=!0,e.inValidProductVariableSelection=!0),be===a.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(e.inValidCollectionSelection=!0)),se===r.BUY_X_GET_Y&&(re.prerequisiteQuantity||(e.inValidBuyXValue=!0),re.entitledQuantity||(e.inValidGetYValue=!0),ye!==c.SPECIFIC_PRODUCTS||!he||Object.keys(he).length||De||(e.inValidBuyXProductSelection=!0,e.inValidBuyXProductVariableSelection=!0),ye===c.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(e.inValidBuyXCollectionSelection=!0),me!==c.SPECIFIC_PRODUCTS||!Oe||Object.keys(Oe).length||ge||(e.inValidGetYProductSelection=!0,e.inValidGetYProductVariableSelection=!0),me===c.SPECIFIC_COLLECTIONS&&Ae&&!Object.keys(Ae).length&&(e.inValidGetYCollectionSelection=!0)),Ke(e))return void Ge(e);if(ae||ke>1)return void xe(!L.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");L.onSaveClicked(Object.assign(Object.assign({},re),{isStaticCoupon:re.isStaticCoupon,description:M(re,L.currency,null!==(p=L.products)&&void 0!==p?p:[],null!==(C=L.collection)&&void 0!==C?C:[]),productsConf:{entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[]},collectionsConf:{entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=ge?ge:{},prerequisiteProductVariable:null!=De?De:{}}}))}}},secondaryButton:ee?{buttonType:"tertiaryGray",onClick:()=>{ie(void 0)},buttonText:"Back"}:ne?{buttonType:"tertiaryGray",onClick:()=>{le(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:L.onClose,buttonText:"Cancel"}},{children:[!ee&&!ne&&i(j,{children:[L.allowStaticCoupon&&!ee&&!L.hideOption&&i(F,Object.assign({selectedDiv:re.isStaticCoupon?1:2},{children:["static"===L.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{re.isStaticCoupon||(de({isStaticCoupon:!0,quadrant:re.quadrant}),xe(""),ze())}},{children:[e(P,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?h.colorsV2.content.brand:void 0}},{children:"Static Code"})),e(m,Object.assign({style:re.isStaticCoupon?{color:h.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===L.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;re.isStaticCoupon&&(ue(r.AMOUNT_OFF_ORDER),de({isStaticCoupon:!1,quadrant:re.quadrant,targetType:C.LINE_ITEM,targetSelection:b.ALL,valueType:v.FIXED_AMOUNT}),xe(""),ze(),Me({id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i}},{children:L.currency||""}))}),qe(null!==(i=L.makeExpiryMandatory)&&void 0!==i&&i),Ce(d.NA))}},{children:[e(P,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?void 0:h.colorsV2.content.brand}},{children:"Dynamic Code"})),e(m,Object.assign({style:re.isStaticCoupon?{}:{color:h.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),!L.getDetailedDescription&&e(I,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"}))," ",re.isStaticCoupon&&!ee&&!L.getDetailedDescription&&e(U,{discountData:re,setDiscountData:de,hideProbability:L.hideProbability||!1,discountAdminUrl:L.discountAdminUrl,staticDiscountValidationError:Ue,currency:L.currency}),re.isStaticCoupon&&!ee&&L.getDetailedDescription&&e(U,{discountData:re,setDiscountData:de,hideProbability:L.hideProbability||!1,discountAdminUrl:L.discountAdminUrl,staticDiscountValidationError:Ue,currency:L.currency,getDetailedDescription:!0,selectedCouponType:se,setSelectedCouponType:ue,selectedMinimumRequirement:pe,setSelectedMinimumRequirement:Ce,discountCouponAppliesTo:be,offerAppliesToBuy:ye,offerAppliesToGet:me,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:Pe,setOfferAppliesToGet:Ie,hideExpiration:L.hideExpiration||!1,onChangeCouponType:Ze,entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[],setEntitledProducts:Ee,setPrerequisiteProducts:Se,entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[],setEntitledCollections:Ne,setPrerequisiteCollections:fe,setIsProductPickerOpen:ie,setIsProductVariablePickerOpen:oe,setIsCollectionPickerOpen:le,productPickerOpen:ee,productVariablePickerOpen:te,collectionPickerOpen:ne,useNewPicker:!!L.newPickerConf,selectedDiscountDetails:Re,setSelectedDiscountDetails:Me,isProductVariableSupported:L.isProductVariableSupported,entitledProductVariable:ge,setEntitledProductVariable:Ve,preRequisiteProductVariable:De,setPreRequisiteProductVariable:_e,productVariableList:L.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:qe,dynamicDiscountValidationError:Be,setDynamicDiscountValidationError:Ge,setValidationErrorMessage:xe,resetValidationErrors:ze,discountDetailsOptions:W,selectedExpiration:Ye,setSelectedExpiration:Xe,makeExpiryMandatory:!!L.makeExpiryMandatory}),!re.isStaticCoupon&&!ee&&!ne&&e(w,{currency:L.currency,entitledProducts:null!=Oe?Oe:[],prerequisiteProducts:null!=he?he:[],setEntitledProducts:Ee,setPrerequisiteProducts:Se,discountData:re,productPickerOpen:ee,productVariablePickerOpen:te,setIsProductPickerOpen:ie,setIsProductVariablePickerOpen:oe,setDiscountData:de,selectedCouponType:se,setSelectedCouponType:ue,selectedMinimumRequirement:pe,setSelectedMinimumRequirement:Ce,discountCouponAppliesTo:be,offerAppliesToBuy:ye,offerAppliesToGet:me,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:Pe,setOfferAppliesToGet:Ie,hideProbability:L.hideProbability||!1,hideExpiration:L.hideExpiration||!1,allowStaticCoupon:L.allowStaticCoupon,onChangeCouponType:Ze,collectionPickerOpen:ne,entitledCollections:null!=Ae?Ae:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:le,setEntitledCollections:Ne,setPrerequisiteCollections:fe,useNewPicker:!!L.newPickerConf,setSelectedDiscountDetails:Me,selectedDiscountDetails:Re,isProductVariableSupported:L.isProductVariableSupported,entitledProductVariable:ge,setEntitledProductVariable:Ve,preRequisiteProductVariable:De,setPreRequisiteProductVariable:_e,productVariableList:L.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:qe,dynamicDiscountValidationError:Be,setDynamicDiscountValidationError:Ge,setValidationErrorMessage:xe,resetValidationErrors:ze,discountDetailsOptions:W,selectedExpiration:Ye,setSelectedExpiration:Xe,makeExpiryMandatory:!!L.makeExpiryMandatory})]}),!!ee&&i(t,{children:[!L.newPickerConf&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(O,{show:!0,onSave:()=>{},products:null!==(z=L.products)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{ie(void 0)},selectedProducts:null!==(K=ee===q.ENTITLED?Oe:he)&&void 0!==K?K:[],setSelectedProducts:ee===q.ENTITLED?Ee:Se,onSearchKeyChange:L.onProductSearch})})),L.newPickerConf&&e(A,{visible:!0,onClose:()=>ie(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=L.newPickerConf)||void 0===o?void 0:o.fetchCollections)?L.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=L.newPickerConf)||void 0===l?void 0:l.fetchProducts)?L.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:ee===q.ENTITLED?Oe:he,onAdd:e=>{ee===q.ENTITLED?Ee(e):Se(e),ie(void 0)},zIndex:200,storeId:L.newPickerConf.storeId,appType:L.newPickerConf.appType||o.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=L.newPickerConf)||void 0===n?void 0:n.searchInCollection)?L.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=L.newPickerConf)||void 0===o?void 0:o.searchProducts)?L.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!ne&&e("div",Object.assign({style:{padding:"12px 0"}},{children:i(t,{children:[L.newPickerConf&&e(A,{visible:!0,onClose:()=>le(void 0),collectionFetcher:L.newPickerConf.fetchCollections,productFetcher:L.newPickerConf.fetchProducts,selectedItems:ne===q.ENTITLED?Ae:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),ne===q.ENTITLED?Ne(e):fe(e),le(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:L.newPickerConf.storeId,appType:L.newPickerConf.appType||o.BIK,searchInCollectionFetcher:L.newPickerConf.searchInCollection,searchFetcher:L.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!L.newPickerConf&&e(O,{show:!0,onSave:()=>{},products:null!==($=L.collection)&&void 0!==$?$:[],title:"Select Products",onClose:()=>{le(void 0)},selectedProducts:null!==(Z=ne===q.ENTITLED?Ae:Te)&&void 0!==Z?Z:[],setSelectedProducts:ne===q.ENTITLED?Ne:fe,onSearchKeyChange:L.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),te&&e(x,{children:e("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e(k,{type:N.EMBEDDED,data:null!==(J=L.productVariableList)&&void 0!==J?J:[],showHeader:!0,onSelect:e=>{if(te===q.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Ve({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}if(te===q.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;_e({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}},onClose:()=>{oe(void 0)}})}))})]}))};export{L as DiscountModal};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../_virtual/_tslib.js";import{jsxs as i,jsx as t,Fragment as o}from"react/jsx-runtime";import n from"../../../assets/icons/info.svg.js";import{Alert as l}from"../../alerts/Alert.js";import{ALERT_TYPES as s,CONTENT_POSITION as r}from"../../alerts/AlertHelper.js";import{Button as a}from"../../button/Button.js";import{CheckBox as d}from"../../checkBox/CheckBox.js";import{DISCOUNT_APPLIES_TO as c,OFFER_APPLIES_TO as u,DISCOUNT_TYPES as p,COUPON_EXPIRATION as m,DISCOUNT_VALUE_TYPES as C,DISCOUNT_TARGET_TYPES as E,DISCOUNT_TARGET_SELECTION as v}from"../type.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as D}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"react";import"../../zeroState/ZeroState.js";import{DEFAULT_THEME as b}from"../../../constants/Theme.js";import"lodash/debounce";import{BodySecondary as g,TitleRegular as T,TitleSmall as h}from"../../TypographyStyle.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../../icon-button/IconButton.js";import{Input as y}from"../../input/Input.js";import O from"../../../assets/icons/cross.svg.js";import"../../dropdown/MenuItem/MenuItem.js";import{RadioButton as P}from"../../radioButton/RadioButton.js";import I from"../../../assets/icons/cubeIcon.svg.js";import V from"../../../assets/icons/delete.svg.js";import S from"../../../assets/icons/edit.svg.js";import j from"../../../assets/icons/plus.svg.js";import{CouponExpiration as f}from"../CouponExpiration/CouponExpiration.js";import{DynamicCouponContainer as x}from"../DiscountModal.styled.js";import{DiscountOptionsContainer as R,DiscountDetailsOption as _,AddProductButtonsContainer as N,ProductCollectionCard as A,CubeIconContainer as F,IconContainer as L,ProductVariableCard as w}from"./DynamicCoupon.styled.js";import q from"./MinimumRequirementComponent.js";import U from"./ZeroState.js";var k;!function(e){e.ENTITLED="entitled",e.PREREQUISITE="prerequisite"}(k||(k={}));const B=B=>{var M,G,Q,X,Y,$,W,z;const Z=[{selected:B.discountCouponAppliesTo===c.ENTIRE_ORDER,label:"Entire Order",value:c.ENTIRE_ORDER},{selected:B.discountCouponAppliesTo===c.SPECIFIC_PRODUCTS,label:"Specific Product",value:c.SPECIFIC_PRODUCTS},{selected:B.discountCouponAppliesTo===c.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:c.SPECIFIC_COLLECTIONS}],H=[{selected:B.offerAppliesToBuy===u.SPECIFIC_PRODUCTS,label:"Specific Product",value:u.SPECIFIC_PRODUCTS},{selected:B.offerAppliesToBuy===u.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:u.SPECIFIC_COLLECTIONS}],J=[{selected:B.offerAppliesToGet===u.SPECIFIC_PRODUCTS,label:"Specific Product",value:u.SPECIFIC_PRODUCTS},{selected:B.offerAppliesToGet===u.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:u.SPECIFIC_COLLECTIONS}],K=(e,d,u)=>{var p,m,C,E,v,D,T,y,P,f,x,R;let _=[],q=[],U={},M={};B.useNewPicker?(U=d===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,M=null!==(p=d===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==p?p:[],(null==U?void 0:U.isCustom)&&delete U.isCustom,(null==M?void 0:M.isCustom)&&delete M.isCustom,Object.values(U).forEach((e=>{Object.keys(e.products).forEach((i=>{_.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(M).forEach((e=>{"isCustom"!==e&&q.push({id:e,name:M[e].name,image:M[e].image})}))):(_=d===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,q=null!==(m=d===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==m?m:[]);const G=[null===(C=B.dynamicDiscountValidationError)||void 0===C?void 0:C.inValidProductSelection,null===(E=B.dynamicDiscountValidationError)||void 0===E?void 0:E.inValidProductVariableSelection,null===(v=B.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidCollectionSelection],Q=[null===(D=B.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidBuyXCollectionSelection,null===(T=B.dynamicDiscountValidationError)||void 0===T?void 0:T.inValidBuyXProductSelection,null===(y=B.dynamicDiscountValidationError)||void 0===y?void 0:y.inValidBuyXProductVariableSelection],X=[null===(P=B.dynamicDiscountValidationError)||void 0===P?void 0:P.inValidGetYCollectionSelection,null===(f=B.dynamicDiscountValidationError)||void 0===f?void 0:f.inValidGetYProductSelection,null===(x=B.dynamicDiscountValidationError)||void 0===x?void 0:x.inValidGetYProductVariableSelection];let Y=!1;return"couponAppliesTo"===u&&(Y=G.some(Boolean)),"buyX"===u&&(Y=Q.some(Boolean)),"getY"===u&&(Y=X.some(Boolean)),i(o,{children:[i("div",Object.assign({style:{display:"flex",gap:18}},{children:[e===c.SPECIFIC_PRODUCTS&&0===_.length&&(d===k.ENTITLED&&!B.entitledProductVariable||d===k.PREREQUISITE&&!B.preRequisiteProductVariable)&&!(null==q?void 0:q.length)&&i(N,{children:[t("div",Object.assign({style:{width:B.isProductVariableSupported?"284px":"300px",display:"flex"}},{children:t(a,{buttonText:"Add Product(s)",buttonType:"dashRegular",LeadingIcon:j,matchParentWidth:!0,onClick:()=>{B.setIsProductPickerOpen(d)},error:Y})})),B.isProductVariableSupported&&B.productVariableList&&i(o,{children:[t(g,Object.assign({color:b.colorsV2.content.placeholder},{children:"OR"})),t(a,{buttonText:"Add Product(s) Variable",buttonType:"dashRegular",LeadingIcon:j,matchParentWidth:!0,onClick:()=>{B.setIsProductVariablePickerOpen(d)},error:Y})]})]}),e===c.SPECIFIC_COLLECTIONS&&0===q.length&&!(null==_?void 0:_.length)&&t("div",Object.assign({style:{width:"300px",display:"flex"}},{children:t(a,{buttonText:"Add collection(s)",buttonType:"dashRegular",LeadingIcon:j,matchParentWidth:!0,onClick:()=>{B.setIsCollectionPickerOpen(d)},style:{marginTop:"16px"},error:Y})}))]})),Y&&t("div",Object.assign({style:{margin:"8px 0 0"}},{children:t(l,{type:s.NEGATIVE,text:"Required Field",contentPosition:r.START,icon:()=>t(n,{width:16,height:16,color:b.colorsV2.content.negative})})})),_.length||q.length?i("div",{children:[t(g,Object.assign({style:{margin:"8px 0"}},{children:e===c.SPECIFIC_COLLECTIONS?"Collection(s)":"Product(s)"})),i(A,{children:[t(F,{children:t(I,{width:20,height:20,color:b.colorsV2.content.secondary})}),i(h,{children:[e===c.SPECIFIC_PRODUCTS?_.length:q.length," ",e===c.SPECIFIC_PRODUCTS?"Product(s)":"Collection(s)"," ","added"]}),i("div",Object.assign({style:{display:"flex",gap:4}},{children:[t(L,Object.assign({onClick:()=>{e===c.SPECIFIC_PRODUCTS?B.setIsProductPickerOpen(d):B.setIsCollectionPickerOpen(d)}},{children:t(S,{width:24,height:24,color:b.colorsV2.content.placeholder})})),t(L,Object.assign({onClick:()=>{e===c.SPECIFIC_PRODUCTS?d===k.ENTITLED?B.setEntitledProducts([]):B.setPrerequisiteProducts([]):d===k.ENTITLED?B.setEntitledCollections([]):B.setPrerequisiteCollections([])}},{children:t(V,{width:24,height:24,color:b.colorsV2.content.placeholder})}))]}))]})]}):d===k.ENTITLED&&B.entitledProductVariable?i("div",{children:[t(g,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i(w,{children:[t(h,{children:B.entitledProductVariable.displayName}),t("div",Object.assign({style:{display:"flex",gap:4}},{children:t(L,Object.assign({onClick:()=>{B.setEntitledProductVariable(void 0)}},{children:t(O,{width:24,height:24,color:b.colorsV2.content.primary})}))}))]})]}):d===k.PREREQUISITE&&(null===(R=B.preRequisiteProductVariable)||void 0===R?void 0:R.displayName)?i("div",{children:[t(g,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i(w,{children:[t(h,{children:B.preRequisiteProductVariable.displayName}),t("div",Object.assign({style:{display:"flex",gap:4}},{children:t(L,Object.assign({onClick:()=>{B.setPreRequisiteProductVariable(void 0)}},{children:t(O,{width:24,height:24,color:b.colorsV2.content.primary})}))}))]})]}):t(o,{children:" "})]})},ee=(e,o)=>{var n,l,s,r,a,d,p,m,C,E;let v=[],b=[],T={},O={};B.useNewPicker?(T=e===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,O=null!==(n=e===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==n?n:[],(null==T?void 0:T.isCustom)&&delete T.isCustom,(null==O?void 0:O.isCustom)&&delete O.isCustom,Object.values(T).forEach((e=>{Object.keys(e.products).forEach((i=>{v.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(O).forEach((e=>{"isCustom"!==e&&b.push({id:e,name:O[e].name,image:O[e].image})}))):(v=e===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,b=null!==(l=e===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==l?l:[]);const P=e===k.PREREQUISITE?B.offerAppliesToBuy:B.offerAppliesToGet,I=e===k.PREREQUISITE?k.PREREQUISITE:k.ENTITLED,V=P===u.SPECIFIC_PRODUCTS?c.SPECIFIC_PRODUCTS:c.SPECIFIC_COLLECTIONS;return i("div",{children:[t(h,Object.assign({style:{marginBottom:16}},{children:e===k.PREREQUISITE?"Customer buys":"Customer gets"})),i("div",Object.assign({style:{display:"flex"}},{children:[!o&&t("div",{children:i("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(y,{value:e===k.ENTITLED?null!==(r=null===(s=B.discountData.entitledQuantity)||void 0===s?void 0:s.toString())&&void 0!==r?r:"":null!==(d=null===(a=B.discountData.prerequisiteQuantity)||void 0===a?void 0:a.toString())&&void 0!==d?d:"",type:"number",onChangeText:i=>{e===k.ENTITLED?B.setDiscountData(Object.assign(Object.assign({},B.discountData),{entitledQuantity:parseInt(i)})):B.setDiscountData(Object.assign(Object.assign({},B.discountData),{prerequisiteQuantity:parseInt(i)}))},labelText:"Quantity of products",placeholder:"Eg. 2",width:"300px",errorMessage:e===k.PREREQUISITE&&(null===(p=B.dynamicDiscountValidationError)||void 0===p?void 0:p.inValidBuyXValue)||e===k.ENTITLED&&(null===(m=B.dynamicDiscountValidationError)||void 0===m?void 0:m.inValidGetYValue)?"Required Field":"",state:e===k.PREREQUISITE&&(null===(C=B.dynamicDiscountValidationError)||void 0===C?void 0:C.inValidBuyXValue)||e===k.ENTITLED&&(null===(E=B.dynamicDiscountValidationError)||void 0===E?void 0:E.inValidGetYValue)?"invalid":"none"})})),t("div",{className:"input__wrapper"})]}))}),i("div",{children:[t(g,Object.assign({style:{marginBottom:8}},{children:"Any items from"})),e===k.PREREQUISITE&&t(D,{width:"244px",options:H,placement:"bottom-start",onSelect:e=>{var i,t,o;B.setOfferAppliesToBuy(e.value),B.setPrerequisiteProducts([]),B.setPrerequisiteCollections([]),B.setPreRequisiteProductVariable(void 0),B.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidBuyXCollectionSelection:!1,inValidBuyXProductSelection:!1,inValidBuyXProductVariableSelection:!1}))),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:null===(i=B.discountData.collectionsConf)||void 0===i?void 0:i.entitledCollections,prerequisiteCollections:{}},productsConf:{entitledProducts:null===(t=B.discountData.productsConf)||void 0===t?void 0:t.entitledProducts,prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:null===(o=B.discountData.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,prerequisiteProductVariable:{}}}))}}),e===k.ENTITLED&&t(D,{width:"244px",options:J,placement:"bottom-start",onSelect:e=>{var i,t,o;B.setOfferAppliesToGet(e.value),B.setEntitledProducts([]),B.setEntitledCollections([]),B.setEntitledProductVariable(void 0),B.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidGetYCollectionSelection:!1,inValidGetYProductSelection:!1,inValidGetYProductVariableSelection:!1}))),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{entitledCollectionIds:[],entitledProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:null===(i=B.discountData.collectionsConf)||void 0===i?void 0:i.prerequisiteCollections},productsConf:{entitledProducts:{},prerequisiteProducts:null===(t=B.discountData.productsConf)||void 0===t?void 0:t.prerequisiteProducts},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:null===(o=B.discountData.productVariableConf)||void 0===o?void 0:o.prerequisiteProductVariable}}))}})]})]})),K(V,I,e===k.PREREQUISITE?"buyX":"getY")]})};return i(x,Object.assign({style:B.noTopMargin?{marginTop:0}:{}},{children:[i("div",{children:[i("div",Object.assign({style:{display:"flex",gap:16}},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(y,{value:null!==(M=B.discountData.title)&&void 0!==M?M:"",onChangeText:e=>{var i;B.setDiscountData(Object.assign(Object.assign({},B.discountData),{title:null!==(i=null==e?void 0:e.trim())&&void 0!==i?i:""}))},maxCharLimit:30,labelText:"Discount Coupon Title",placeholder:`Eg. “Flat ${null!==(G=B.currency)&&void 0!==G?G:""} 15 Off”`,hintText:"Will be same for everyone. Can’t be changed later",width:"300px",isRequired:!0,errorMessage:(null===(Q=B.dynamicDiscountValidationError)||void 0===Q?void 0:Q.invalidCouponTitle)?"Required Field":"",state:(null===(X=B.dynamicDiscountValidationError)||void 0===X?void 0:X.invalidCouponTitle)?"invalid":"none"})})),!B.hideProbability&&t(y,{value:null!==($=null===(Y=B.discountData.probability)||void 0===Y?void 0:Y.toString())&&void 0!==$?$:"",type:"number",onChangeText:e=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability of getting coupon ",hintText:"Enter a decimal value between 0-1",placeholder:"Eg. 0.5",maxCharLimit:4,width:"300px",isRequired:!0,errorMessage:(null===(W=B.dynamicDiscountValidationError)||void 0===W?void 0:W.inValidProbability)?"Required Field":"",state:(null===(z=B.dynamicDiscountValidationError)||void 0===z?void 0:z.inValidProbability)?"invalid":"none"})]})),t("div",{style:{height:"1px",width:"100%",background:b.colorsV2.stroke.primary,margin:"24px 0 8px"}})]}),B.allowStaticCoupon&&t((()=>i("div",{children:[t(T,{children:"Discount Details"}),t(R,{children:B.discountDetailsOptions.map((t=>{return i(_,Object.assign({selected:B.selectedDiscountDetails.id===t.id,onClick:()=>(i=>{if(B.selectedDiscountDetails.id!==i.id)if(B.resetValidationErrors(),B.setValidationErrorMessage(""),B.setDiscountCouponAppliesTo(c.ENTIRE_ORDER),B.setSelectedDiscountDetails(i),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:void 0})),B.setPreRequisiteProductVariable(void 0),B.setEntitledProductVariable(void 0),["percentage","amount"].includes(i.value)){B.onChangeCouponType({label:"Amount off on order",selected:!0,value:p.AMOUNT_OFF_ORDER});const t=Object.assign(Object.assign({},B.discountData),{valueType:"percentage"===i.value?C.PERCENTAGE:C.FIXED_AMOUNT,value:void 0,targetType:E.LINE_ITEM,targetSelection:v.ALL,entitledCollectionIds:[],entitledProductIds:[],prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:{}},productsConf:{entitledProducts:{},prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:{}}}),o=e(t,["entitledQuantity","prerequisiteQuantity"]);B.setDiscountData(o)}else B.onChangeCouponType({label:i.label,selected:!0,value:i.value})})(t)},{children:[t.icon((o=t.id,B.selectedDiscountDetails.id===o?b.colorsV2.stroke.brand:b.colorsV2.text.secondary)),t.label]}),t.id);var o}))})]})),{}),(B.selectedCouponType===p.AMOUNT_OFF_ORDER||B.selectedCouponType===p.AMOUNT_OFF_PRODUCTS)&&(()=>{var e,n,l,s,r,a;return i(o,{children:[t("div",Object.assign({className:"input__rows"},{children:t("div",Object.assign({className:"input__wrapper"},{children:t(y,{value:null!==(l=null===(n=null===(e=B.discountData)||void 0===e?void 0:e.value)||void 0===n?void 0:n.toString())&&void 0!==l?l:"",labelText:"Discount amount",type:"number",width:"300px",onChangeText:e=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:parseInt(e)}))},placeholder:"15",prefixText:B.discountData.valueType===C.FIXED_AMOUNT?null!==(s=B.currency)&&void 0!==s?s:"":void 0,suffixText:B.discountData.valueType===C.PERCENTAGE?"%":void 0,errorMessage:(null===(r=B.dynamicDiscountValidationError)||void 0===r?void 0:r.inValidDiscountAmount)?"Required Field":"",state:(null===(a=B.dynamicDiscountValidationError)||void 0===a?void 0:a.inValidDiscountAmount)?"invalid":"none"})}))})),t("div",Object.assign({style:{paddingTop:"24px",marginTop:16,borderTop:`1px solid ${b.colorsV2.stroke.primary}`}},{children:i("div",Object.assign({className:"input__wrapper"},{children:[t(T,Object.assign({style:{marginBottom:10}},{children:"Applies to"})),t("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:t(D,{width:"300px",options:Z,placement:"bottom-start",onSelect:e=>{const i="value"in e&&e.value===c.ENTIRE_ORDER?{label:"Amount off on order",selected:!0,value:p.AMOUNT_OFF_ORDER}:{label:"Amount off on products",selected:!0,value:p.AMOUNT_OFF_PRODUCTS};B.onChangeCouponType(i),B.setDiscountCouponAppliesTo(e.value),B.setEntitledProductVariable(void 0),B.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidProductVariableSelection:!1,inValidProductSelection:!1,inValidCollectionSelection:!1})))}})})),(B.discountCouponAppliesTo===c.SPECIFIC_PRODUCTS||B.discountCouponAppliesTo===c.SPECIFIC_COLLECTIONS)&&K(B.discountCouponAppliesTo,k.ENTITLED,"couponAppliesTo")]}))}))]})})(),B.selectedCouponType===p.BUY_X_GET_Y&&(()=>{var e,o,n,l,s;return i(x,Object.assign({style:{border:`1px solid ${b.colorsV2.stroke.primary}`,padding:"16px",borderRadius:"4px",margin:0}},{children:[ee(k.PREREQUISITE),t("div",{style:{width:"100%",height:"1px",backgroundColor:b.colorsV2.stroke.primary,margin:"8px 0"}}),ee(k.ENTITLED),t(g,Object.assign({style:{marginTop:"8px"}},{children:"At a discounted value"})),t("div",{children:t(P,{label:"Free",isActive:100===B.discountData.value,onValueChange:e=>{e?B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:100})):B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:void 0}))}})}),i("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[t(P,{label:"Percentage off",isActive:100!==B.discountData.value,onValueChange:()=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:void 0}))}}),100!==B.discountData.value&&t("div",Object.assign({style:{marginTop:8}},{children:t(y,{value:null!==(n=null===(o=null===(e=B.discountData)||void 0===e?void 0:e.value)||void 0===o?void 0:o.toString())&&void 0!==n?n:"",onChangeText:e=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Eg. 50",suffixText:"%",width:"300px",errorMessage:(null===(l=B.dynamicDiscountValidationError)||void 0===l?void 0:l.inValidDiscountAmount)?"Required Field":"",state:(null===(s=B.dynamicDiscountValidationError)||void 0===s?void 0:s.inValidDiscountAmount)?"invalid":"none"})}))]}))]}))})(),!B.selectedCouponType&&t(U,{}),B.allowStaticCoupon&&B.selectedCouponType!==p.BUY_X_GET_Y&&t("div",Object.assign({style:{padding:"24px 0 16px",marginTop:16,borderTop:`1px solid ${b.colorsV2.stroke.primary}`}},{children:t(q,{selectedMinimumRequirement:B.selectedMinimumRequirement,setSelectedMinimumRequirement:B.setSelectedMinimumRequirement,discountData:B.discountData,setDiscountData:B.setDiscountData,currency:B.currency,dynamicDiscountValidationError:B.dynamicDiscountValidationError})})),B.selectedCouponType&&!B.hideExpiration&&i("div",Object.assign({style:{padding:B.selectedCouponType!==p.BUY_X_GET_Y?"24px 0 16px":"8px 0",borderTop:B.selectedCouponType!==p.BUY_X_GET_Y?`1px solid ${b.colorsV2.stroke.primary}`:"none"}},{children:[t(d,{label:"Add expiration",isDisabled:!!B.makeExpiryMandatory,isChecked:B.isAddExpirationChecked,onValueChange:e=>{B.setIsAddExpirationChecked(e),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{expireAfter:void 0,expireAt:void 0})),B.setSelectedExpiration(B.isUsageFromStatic?m.FIXED_EXPIRATION:m.DYNAMIC_EXPIRATION)},boldOnChecked:!0,labelSize:"DEFAULT"}),t(g,Object.assign({style:{color:b.colorsV2.text.secondary,marginLeft:28}},{children:"Make coupon only valid till a certain time"})),B.isAddExpirationChecked&&t(f,{discountData:B.discountData,setDiscountData:B.setDiscountData,isAddExpirationChecked:B.isAddExpirationChecked,inValidCouponExpiry:B.dynamicDiscountValidationError.inValidCouponExpiry,selectedExpiration:B.selectedExpiration,setSelectedExpiration:B.setSelectedExpiration,hideExpirationOptions:B.isUsageFromStatic})]}))]}))};export{k as DISCOUNT_PRODUCTS,B as default};
1
+ import{__rest as e}from"../../../_virtual/_tslib.js";import{jsxs as i,jsx as t,Fragment as o}from"react/jsx-runtime";import n from"../../../assets/icons/info.svg.js";import{Alert as l}from"../../alerts/Alert.js";import{ALERT_TYPES as s,CONTENT_POSITION as r}from"../../alerts/AlertHelper.js";import{Button as a}from"../../button/Button.js";import{CheckBox as d}from"../../checkBox/CheckBox.js";import{DISCOUNT_APPLIES_TO as c,OFFER_APPLIES_TO as u,DISCOUNT_TYPES as p,COUPON_EXPIRATION as m,DISCOUNT_VALUE_TYPES as C,DISCOUNT_TARGET_TYPES as E,DISCOUNT_TARGET_SELECTION as v}from"../type.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as D}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"react";import"../../zeroState/ZeroState.js";import"lodash/debounce";import{BodySecondary as b,TitleRegular as g,TitleSmall as T}from"../../TypographyStyle.js";import{DEFAULT_THEME as h}from"../../../constants/Theme.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../../icon-button/IconButton.js";import{Input as y}from"../../input/Input.js";import O from"../../../assets/icons/cross.svg.js";import"../../dropdown/MenuItem/MenuItem.js";import{RadioButton as P}from"../../radioButton/RadioButton.js";import I from"../../../assets/icons/cubeIcon.svg.js";import V from"../../../assets/icons/delete.svg.js";import S from"../../../assets/icons/edit.svg.js";import j from"../../../assets/icons/plus.svg.js";import{CouponExpiration as f}from"../CouponExpiration/CouponExpiration.js";import{DynamicCouponContainer as x}from"../DiscountModal.styled.js";import{DiscountOptionsContainer as R,DiscountDetailsOption as _,AddProductButtonsContainer as N,ProductCollectionCard as A,CubeIconContainer as F,IconContainer as L,ProductVariableCard as w}from"./DynamicCoupon.styled.js";import q from"./MinimumRequirementComponent.js";import U from"./ZeroState.js";var k;!function(e){e.ENTITLED="entitled",e.PREREQUISITE="prerequisite"}(k||(k={}));const B=B=>{var M,G,Q,X,Y,$,W,z;const Z=[{selected:B.discountCouponAppliesTo===c.ENTIRE_ORDER,label:"Entire Order",value:c.ENTIRE_ORDER},{selected:B.discountCouponAppliesTo===c.SPECIFIC_PRODUCTS,label:"Specific Product",value:c.SPECIFIC_PRODUCTS},{selected:B.discountCouponAppliesTo===c.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:c.SPECIFIC_COLLECTIONS}],H=[{selected:B.offerAppliesToBuy===u.SPECIFIC_PRODUCTS,label:"Specific Product",value:u.SPECIFIC_PRODUCTS},{selected:B.offerAppliesToBuy===u.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:u.SPECIFIC_COLLECTIONS}],J=[{selected:B.offerAppliesToGet===u.SPECIFIC_PRODUCTS,label:"Specific Product",value:u.SPECIFIC_PRODUCTS},{selected:B.offerAppliesToGet===u.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:u.SPECIFIC_COLLECTIONS}],K=(e,d,u)=>{var p,m,C,E,v,D,g,y,P,f,x,R;let _=[],q=[],U={},M={};B.useNewPicker?(U=d===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,M=null!==(p=d===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==p?p:[],(null==U?void 0:U.isCustom)&&delete U.isCustom,(null==M?void 0:M.isCustom)&&delete M.isCustom,Object.values(U).forEach((e=>{Object.keys(e.products).forEach((i=>{_.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(M).forEach((e=>{"isCustom"!==e&&q.push({id:e,name:M[e].name,image:M[e].image})}))):(_=d===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,q=null!==(m=d===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==m?m:[]);const G=[null===(C=B.dynamicDiscountValidationError)||void 0===C?void 0:C.inValidProductSelection,null===(E=B.dynamicDiscountValidationError)||void 0===E?void 0:E.inValidProductVariableSelection,null===(v=B.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidCollectionSelection],Q=[null===(D=B.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidBuyXCollectionSelection,null===(g=B.dynamicDiscountValidationError)||void 0===g?void 0:g.inValidBuyXProductSelection,null===(y=B.dynamicDiscountValidationError)||void 0===y?void 0:y.inValidBuyXProductVariableSelection],X=[null===(P=B.dynamicDiscountValidationError)||void 0===P?void 0:P.inValidGetYCollectionSelection,null===(f=B.dynamicDiscountValidationError)||void 0===f?void 0:f.inValidGetYProductSelection,null===(x=B.dynamicDiscountValidationError)||void 0===x?void 0:x.inValidGetYProductVariableSelection];let Y=!1;return"couponAppliesTo"===u&&(Y=G.some(Boolean)),"buyX"===u&&(Y=Q.some(Boolean)),"getY"===u&&(Y=X.some(Boolean)),i(o,{children:[i("div",Object.assign({style:{display:"flex",gap:18}},{children:[e===c.SPECIFIC_PRODUCTS&&0===_.length&&(d===k.ENTITLED&&!B.entitledProductVariable||d===k.PREREQUISITE&&!B.preRequisiteProductVariable)&&!(null==q?void 0:q.length)&&i(N,{children:[t("div",Object.assign({style:{width:B.isProductVariableSupported?"284px":"300px",display:"flex"}},{children:t(a,{buttonText:"Add Product(s)",buttonType:"dashRegular",LeadingIcon:j,matchParentWidth:!0,onClick:()=>{B.setIsProductPickerOpen(d)},error:Y})})),B.isProductVariableSupported&&B.productVariableList&&i(o,{children:[t(b,Object.assign({color:h.colorsV2.content.placeholder},{children:"OR"})),t(a,{buttonText:"Add Product(s) Variable",buttonType:"dashRegular",LeadingIcon:j,matchParentWidth:!0,onClick:()=>{B.setIsProductVariablePickerOpen(d)},error:Y})]})]}),e===c.SPECIFIC_COLLECTIONS&&0===q.length&&!(null==_?void 0:_.length)&&t("div",Object.assign({style:{width:"300px",display:"flex"}},{children:t(a,{buttonText:"Add collection(s)",buttonType:"dashRegular",LeadingIcon:j,matchParentWidth:!0,onClick:()=>{B.setIsCollectionPickerOpen(d)},style:{marginTop:"16px"},error:Y})}))]})),Y&&t("div",Object.assign({style:{margin:"8px 0 0"}},{children:t(l,{type:s.NEGATIVE,text:"Required Field",contentPosition:r.START,icon:()=>t(n,{width:16,height:16,color:h.colorsV2.content.negative})})})),_.length||q.length?i("div",{children:[t(b,Object.assign({style:{margin:"8px 0"}},{children:e===c.SPECIFIC_COLLECTIONS?"Collection(s)":"Product(s)"})),i(A,{children:[t(F,{children:t(I,{width:20,height:20,color:h.colorsV2.content.secondary})}),i(T,{children:[e===c.SPECIFIC_PRODUCTS?_.length:q.length," ",e===c.SPECIFIC_PRODUCTS?"Product(s)":"Collection(s)"," ","added"]}),i("div",Object.assign({style:{display:"flex",gap:4}},{children:[t(L,Object.assign({onClick:()=>{e===c.SPECIFIC_PRODUCTS?B.setIsProductPickerOpen(d):B.setIsCollectionPickerOpen(d)}},{children:t(S,{width:24,height:24,color:h.colorsV2.content.placeholder})})),t(L,Object.assign({onClick:()=>{e===c.SPECIFIC_PRODUCTS?d===k.ENTITLED?B.setEntitledProducts([]):B.setPrerequisiteProducts([]):d===k.ENTITLED?B.setEntitledCollections([]):B.setPrerequisiteCollections([])}},{children:t(V,{width:24,height:24,color:h.colorsV2.content.placeholder})}))]}))]})]}):d===k.ENTITLED&&B.entitledProductVariable?i("div",{children:[t(b,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i(w,{children:[t(T,{children:B.entitledProductVariable.displayName}),t("div",Object.assign({style:{display:"flex",gap:4}},{children:t(L,Object.assign({onClick:()=>{B.setEntitledProductVariable(void 0)}},{children:t(O,{width:24,height:24,color:h.colorsV2.content.primary})}))}))]})]}):d===k.PREREQUISITE&&(null===(R=B.preRequisiteProductVariable)||void 0===R?void 0:R.displayName)?i("div",{children:[t(b,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),i(w,{children:[t(T,{children:B.preRequisiteProductVariable.displayName}),t("div",Object.assign({style:{display:"flex",gap:4}},{children:t(L,Object.assign({onClick:()=>{B.setPreRequisiteProductVariable(void 0)}},{children:t(O,{width:24,height:24,color:h.colorsV2.content.primary})}))}))]})]}):t(o,{children:" "})]})},ee=(e,o)=>{var n,l,s,r,a,d,p,m,C,E;let v=[],g=[],h={},O={};B.useNewPicker?(h=e===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,O=null!==(n=e===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==n?n:[],(null==h?void 0:h.isCustom)&&delete h.isCustom,(null==O?void 0:O.isCustom)&&delete O.isCustom,Object.values(h).forEach((e=>{Object.keys(e.products).forEach((i=>{v.push({id:i,name:e.products[i].name,image:e.products[i].image})}))})),Object.keys(O).forEach((e=>{"isCustom"!==e&&g.push({id:e,name:O[e].name,image:O[e].image})}))):(v=e===k.ENTITLED?B.entitledProducts:B.prerequisiteProducts,g=null!==(l=e===k.ENTITLED?B.entitledCollections:B.prerequisiteCollections)&&void 0!==l?l:[]);const P=e===k.PREREQUISITE?B.offerAppliesToBuy:B.offerAppliesToGet,I=e===k.PREREQUISITE?k.PREREQUISITE:k.ENTITLED,V=P===u.SPECIFIC_PRODUCTS?c.SPECIFIC_PRODUCTS:c.SPECIFIC_COLLECTIONS;return i("div",{children:[t(T,Object.assign({style:{marginBottom:16}},{children:e===k.PREREQUISITE?"Customer buys":"Customer gets"})),i("div",Object.assign({style:{display:"flex"}},{children:[!o&&t("div",{children:i("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(y,{value:e===k.ENTITLED?null!==(r=null===(s=B.discountData.entitledQuantity)||void 0===s?void 0:s.toString())&&void 0!==r?r:"":null!==(d=null===(a=B.discountData.prerequisiteQuantity)||void 0===a?void 0:a.toString())&&void 0!==d?d:"",type:"number",onChangeText:i=>{e===k.ENTITLED?B.setDiscountData(Object.assign(Object.assign({},B.discountData),{entitledQuantity:parseInt(i)})):B.setDiscountData(Object.assign(Object.assign({},B.discountData),{prerequisiteQuantity:parseInt(i)}))},labelText:"Quantity of products",placeholder:"Eg. 2",width:"300px",errorMessage:e===k.PREREQUISITE&&(null===(p=B.dynamicDiscountValidationError)||void 0===p?void 0:p.inValidBuyXValue)||e===k.ENTITLED&&(null===(m=B.dynamicDiscountValidationError)||void 0===m?void 0:m.inValidGetYValue)?"Required Field":"",state:e===k.PREREQUISITE&&(null===(C=B.dynamicDiscountValidationError)||void 0===C?void 0:C.inValidBuyXValue)||e===k.ENTITLED&&(null===(E=B.dynamicDiscountValidationError)||void 0===E?void 0:E.inValidGetYValue)?"invalid":"none"})})),t("div",{className:"input__wrapper"})]}))}),i("div",{children:[t(b,Object.assign({style:{marginBottom:8}},{children:"Any items from"})),e===k.PREREQUISITE&&t(D,{width:"244px",options:H,placement:"bottom-start",onSelect:e=>{var i,t,o;B.setOfferAppliesToBuy(e.value),B.setPrerequisiteProducts([]),B.setPrerequisiteCollections([]),B.setPreRequisiteProductVariable(void 0),B.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidBuyXCollectionSelection:!1,inValidBuyXProductSelection:!1,inValidBuyXProductVariableSelection:!1}))),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:null===(i=B.discountData.collectionsConf)||void 0===i?void 0:i.entitledCollections,prerequisiteCollections:{}},productsConf:{entitledProducts:null===(t=B.discountData.productsConf)||void 0===t?void 0:t.entitledProducts,prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:null===(o=B.discountData.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,prerequisiteProductVariable:{}}}))}}),e===k.ENTITLED&&t(D,{width:"244px",options:J,placement:"bottom-start",onSelect:e=>{var i,t,o;B.setOfferAppliesToGet(e.value),B.setEntitledProducts([]),B.setEntitledCollections([]),B.setEntitledProductVariable(void 0),B.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidGetYCollectionSelection:!1,inValidGetYProductSelection:!1,inValidGetYProductVariableSelection:!1}))),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{entitledCollectionIds:[],entitledProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:null===(i=B.discountData.collectionsConf)||void 0===i?void 0:i.prerequisiteCollections},productsConf:{entitledProducts:{},prerequisiteProducts:null===(t=B.discountData.productsConf)||void 0===t?void 0:t.prerequisiteProducts},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:null===(o=B.discountData.productVariableConf)||void 0===o?void 0:o.prerequisiteProductVariable}}))}})]})]})),K(V,I,e===k.PREREQUISITE?"buyX":"getY")]})};return i(x,Object.assign({style:B.noTopMargin?{marginTop:0}:{}},{children:[i("div",{children:[i("div",Object.assign({style:{display:"flex",gap:16}},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(y,{value:null!==(M=B.discountData.title)&&void 0!==M?M:"",onChangeText:e=>{var i;B.setDiscountData(Object.assign(Object.assign({},B.discountData),{title:null!==(i=null==e?void 0:e.trim())&&void 0!==i?i:""}))},maxCharLimit:30,labelText:"Discount Coupon Title",placeholder:`Eg. “Flat ${null!==(G=B.currency)&&void 0!==G?G:""} 15 Off”`,hintText:"Will be same for everyone. Can’t be changed later",width:"300px",isRequired:!0,errorMessage:(null===(Q=B.dynamicDiscountValidationError)||void 0===Q?void 0:Q.invalidCouponTitle)?"Required Field":"",state:(null===(X=B.dynamicDiscountValidationError)||void 0===X?void 0:X.invalidCouponTitle)?"invalid":"none"})})),!B.hideProbability&&t(y,{value:null!==($=null===(Y=B.discountData.probability)||void 0===Y?void 0:Y.toString())&&void 0!==$?$:"",type:"number",onChangeText:e=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability of getting coupon ",hintText:"Enter a decimal value between 0-1",placeholder:"Eg. 0.5",maxCharLimit:4,width:"300px",isRequired:!0,errorMessage:(null===(W=B.dynamicDiscountValidationError)||void 0===W?void 0:W.inValidProbability)?"Required Field":"",state:(null===(z=B.dynamicDiscountValidationError)||void 0===z?void 0:z.inValidProbability)?"invalid":"none"})]})),t("div",{style:{height:"1px",width:"100%",background:h.colorsV2.stroke.primary,margin:"24px 0 8px"}})]}),B.allowStaticCoupon&&t((()=>i("div",{children:[t(g,{children:"Discount Details"}),t(R,{children:B.discountDetailsOptions.map((t=>{return i(_,Object.assign({selected:B.selectedDiscountDetails.id===t.id,onClick:()=>(i=>{if(B.selectedDiscountDetails.id!==i.id)if(B.resetValidationErrors(),B.setValidationErrorMessage(""),B.setDiscountCouponAppliesTo(c.ENTIRE_ORDER),B.setSelectedDiscountDetails(i),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:void 0})),B.setPreRequisiteProductVariable(void 0),B.setEntitledProductVariable(void 0),["percentage","amount"].includes(i.value)){B.onChangeCouponType({label:"Amount off on order",selected:!0,value:p.AMOUNT_OFF_ORDER});const t=Object.assign(Object.assign({},B.discountData),{valueType:"percentage"===i.value?C.PERCENTAGE:C.FIXED_AMOUNT,value:void 0,targetType:E.LINE_ITEM,targetSelection:v.ALL,entitledCollectionIds:[],entitledProductIds:[],prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:{}},productsConf:{entitledProducts:{},prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:{}}}),o=e(t,["entitledQuantity","prerequisiteQuantity"]);B.setDiscountData(o)}else B.onChangeCouponType({label:i.label,selected:!0,value:i.value})})(t)},{children:[t.icon((o=t.id,B.selectedDiscountDetails.id===o?h.colorsV2.stroke.brand:h.colorsV2.text.secondary)),t.label]}),t.id);var o}))})]})),{}),(B.selectedCouponType===p.AMOUNT_OFF_ORDER||B.selectedCouponType===p.AMOUNT_OFF_PRODUCTS)&&(()=>{var e,n,l,s,r,a;return i(o,{children:[t("div",Object.assign({className:"input__rows"},{children:t("div",Object.assign({className:"input__wrapper"},{children:t(y,{value:null!==(l=null===(n=null===(e=B.discountData)||void 0===e?void 0:e.value)||void 0===n?void 0:n.toString())&&void 0!==l?l:"",labelText:"Discount amount",type:"number",width:"300px",onChangeText:e=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:parseInt(e)}))},placeholder:"15",prefixText:B.discountData.valueType===C.FIXED_AMOUNT?null!==(s=B.currency)&&void 0!==s?s:"":void 0,suffixText:B.discountData.valueType===C.PERCENTAGE?"%":void 0,errorMessage:(null===(r=B.dynamicDiscountValidationError)||void 0===r?void 0:r.inValidDiscountAmount)?"Required Field":"",state:(null===(a=B.dynamicDiscountValidationError)||void 0===a?void 0:a.inValidDiscountAmount)?"invalid":"none"})}))})),t("div",Object.assign({style:{paddingTop:"24px",marginTop:16,borderTop:`1px solid ${h.colorsV2.stroke.primary}`}},{children:i("div",Object.assign({className:"input__wrapper"},{children:[t(g,Object.assign({style:{marginBottom:10}},{children:"Applies to"})),t("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:t(D,{width:"300px",options:Z,placement:"bottom-start",onSelect:e=>{const i="value"in e&&e.value===c.ENTIRE_ORDER?{label:"Amount off on order",selected:!0,value:p.AMOUNT_OFF_ORDER}:{label:"Amount off on products",selected:!0,value:p.AMOUNT_OFF_PRODUCTS};B.onChangeCouponType(i),B.setDiscountCouponAppliesTo(e.value),B.setEntitledProductVariable(void 0),B.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidProductVariableSelection:!1,inValidProductSelection:!1,inValidCollectionSelection:!1})))}})})),(B.discountCouponAppliesTo===c.SPECIFIC_PRODUCTS||B.discountCouponAppliesTo===c.SPECIFIC_COLLECTIONS)&&K(B.discountCouponAppliesTo,k.ENTITLED,"couponAppliesTo")]}))}))]})})(),B.selectedCouponType===p.BUY_X_GET_Y&&(()=>{var e,o,n,l,s;return i(x,Object.assign({style:{border:`1px solid ${h.colorsV2.stroke.primary}`,padding:"16px",borderRadius:"4px",margin:0}},{children:[ee(k.PREREQUISITE),t("div",{style:{width:"100%",height:"1px",backgroundColor:h.colorsV2.stroke.primary,margin:"8px 0"}}),ee(k.ENTITLED),t(b,Object.assign({style:{marginTop:"8px"}},{children:"At a discounted value"})),t("div",{children:t(P,{label:"Free",isActive:100===B.discountData.value,onValueChange:e=>{e?B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:100})):B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:void 0}))}})}),i("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[t(P,{label:"Percentage off",isActive:100!==B.discountData.value,onValueChange:()=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:void 0}))}}),100!==B.discountData.value&&t("div",Object.assign({style:{marginTop:8}},{children:t(y,{value:null!==(n=null===(o=null===(e=B.discountData)||void 0===e?void 0:e.value)||void 0===o?void 0:o.toString())&&void 0!==n?n:"",onChangeText:e=>{B.setDiscountData(Object.assign(Object.assign({},B.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Eg. 50",suffixText:"%",width:"300px",errorMessage:(null===(l=B.dynamicDiscountValidationError)||void 0===l?void 0:l.inValidDiscountAmount)?"Required Field":"",state:(null===(s=B.dynamicDiscountValidationError)||void 0===s?void 0:s.inValidDiscountAmount)?"invalid":"none"})}))]}))]}))})(),!B.selectedCouponType&&t(U,{}),B.allowStaticCoupon&&B.selectedCouponType!==p.BUY_X_GET_Y&&t("div",Object.assign({style:{padding:"24px 0 16px",marginTop:16,borderTop:`1px solid ${h.colorsV2.stroke.primary}`}},{children:t(q,{selectedMinimumRequirement:B.selectedMinimumRequirement,setSelectedMinimumRequirement:B.setSelectedMinimumRequirement,discountData:B.discountData,setDiscountData:B.setDiscountData,currency:B.currency,dynamicDiscountValidationError:B.dynamicDiscountValidationError})})),B.selectedCouponType&&!B.hideExpiration&&i("div",Object.assign({style:{padding:B.selectedCouponType!==p.BUY_X_GET_Y?"24px 0 16px":"8px 0",borderTop:B.selectedCouponType!==p.BUY_X_GET_Y?`1px solid ${h.colorsV2.stroke.primary}`:"none"}},{children:[t(d,{label:"Add expiration",isDisabled:!!B.makeExpiryMandatory,isChecked:B.isAddExpirationChecked,onValueChange:e=>{B.setIsAddExpirationChecked(e),B.setDiscountData(Object.assign(Object.assign({},B.discountData),{expireAfter:void 0,expireAt:void 0})),B.setSelectedExpiration(B.isUsageFromStatic?m.FIXED_EXPIRATION:m.DYNAMIC_EXPIRATION)},boldOnChecked:!0,labelSize:"DEFAULT"}),t(b,Object.assign({style:{color:h.colorsV2.text.secondary,marginLeft:28}},{children:"Make coupon only valid till a certain time"})),B.isAddExpirationChecked&&t(f,{discountData:B.discountData,setDiscountData:B.setDiscountData,isAddExpirationChecked:B.isAddExpirationChecked,inValidCouponExpiry:B.dynamicDiscountValidationError.inValidCouponExpiry,selectedExpiration:B.selectedExpiration,setSelectedExpiration:B.setSelectedExpiration,hideExpirationOptions:B.isUsageFromStatic})]}))]}))};export{k as DISCOUNT_PRODUCTS,B as default};
@@ -1 +1 @@
1
- import{jsxs as e,Fragment as t,jsx as i}from"react/jsx-runtime";import{CheckBox as n}from"../../checkBox/CheckBox.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as o}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"react";import"../../zeroState/ZeroState.js";import{DEFAULT_THEME as m}from"../../../constants/Theme.js";import"../../../_virtual/_tslib.js";import"lodash/debounce";import{BodySecondary as s}from"../../TypographyStyle.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../button/Button.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../../icon-button/IconButton.js";import{Input as r}from"../../input/Input.js";import"../../dropdown/MenuItem/MenuItem.js";import{MIN_PURCHASE_REQUIREMENT as d}from"../type.js";const u=u=>{var a,l,c,p,M,j,v,D,O;const b=[{selected:u.selectedMinimumRequirement===d.AMOUNT,label:"Minimum order value",value:d.AMOUNT},{selected:u.selectedMinimumRequirement===d.QUANTITY,label:"Minimum number of items",value:d.QUANTITY}];return e(t,{children:[i(n,{label:"Minimum Purchase Requirements",isChecked:u.selectedMinimumRequirement!==d.NA,onValueChange:e=>{e?(u.setSelectedMinimumRequirement(d.AMOUNT),u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:void 0,minAmount:void 0}))):(u.setSelectedMinimumRequirement(d.NA),u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:void 0,minAmount:void 0})))},boldOnChecked:!0,labelSize:"DEFAULT"}),i(s,Object.assign({style:{color:m.colorsV2.text.secondary,marginLeft:28}},{children:"Enable coupon only after a minimum order value"})),u.selectedMinimumRequirement!==d.NA&&e("div",Object.assign({style:{margin:"16px 0 0 28px"},className:"input__rows"},{children:[e("div",Object.assign({className:"input__wrapper"},{children:[i(s,Object.assign({style:{marginBottom:10}},{children:"Requirements"})),i(o,{options:b,placement:"bottom-start",onSelect:e=>{const t=e.value;u.setSelectedMinimumRequirement(t),u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:void 0,minAmount:void 0}))},truncatedText:!1,width:"272px"})]})),i("div",Object.assign({className:"input__wrapper"},{children:i(r,{value:u.selectedMinimumRequirement===d.AMOUNT?null!==(l=null===(a=u.discountData.minAmount)||void 0===a?void 0:a.toString())&&void 0!==l?l:"":null!==(p=null===(c=u.discountData.minQuantity)||void 0===c?void 0:c.toString())&&void 0!==p?p:"",onChangeText:e=>{u.selectedMinimumRequirement===d.AMOUNT?u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minAmount:parseInt(e)})):u.selectedMinimumRequirement===d.QUANTITY&&u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:parseInt(e)}))},labelText:u.selectedMinimumRequirement===d.AMOUNT?"Minimum amount":"Minimum no. of items",prefixText:u.selectedMinimumRequirement===d.AMOUNT?null!==(M=u.currency)&&void 0!==M?M:"":void 0,type:"number",placeholder:u.selectedMinimumRequirement===d.AMOUNT?"Eg. 5000":"Eg. 5",errorMessage:(null===(j=u.dynamicDiscountValidationError)||void 0===j?void 0:j.inValidMinimumAmount)||(null===(v=u.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidMinimumQuantity)?"Required Field":"",state:(null===(D=u.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidMinimumAmount)||(null===(O=u.dynamicDiscountValidationError)||void 0===O?void 0:O.inValidMinimumQuantity)?"invalid":"none"})}))]}))]})};export{u as default};
1
+ import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import{CheckBox as i}from"../../checkBox/CheckBox.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as o}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"react";import"../../zeroState/ZeroState.js";import"lodash/debounce";import{BodySecondary as m}from"../../TypographyStyle.js";import{DEFAULT_THEME as s}from"../../../constants/Theme.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../button/Button.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../../icon-button/IconButton.js";import{Input as r}from"../../input/Input.js";import"../../dropdown/MenuItem/MenuItem.js";import{MIN_PURCHASE_REQUIREMENT as d}from"../type.js";const u=u=>{var a,c,l,p,M,j,v,D,O;const b=[{selected:u.selectedMinimumRequirement===d.AMOUNT,label:"Minimum order value",value:d.AMOUNT},{selected:u.selectedMinimumRequirement===d.QUANTITY,label:"Minimum number of items",value:d.QUANTITY}];return e(t,{children:[n(i,{label:"Minimum Purchase Requirements",isChecked:u.selectedMinimumRequirement!==d.NA,onValueChange:e=>{e?(u.setSelectedMinimumRequirement(d.AMOUNT),u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:void 0,minAmount:void 0}))):(u.setSelectedMinimumRequirement(d.NA),u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:void 0,minAmount:void 0})))},boldOnChecked:!0,labelSize:"DEFAULT"}),n(m,Object.assign({style:{color:s.colorsV2.text.secondary,marginLeft:28}},{children:"Enable coupon only after a minimum order value"})),u.selectedMinimumRequirement!==d.NA&&e("div",Object.assign({style:{margin:"16px 0 0 28px"},className:"input__rows"},{children:[e("div",Object.assign({className:"input__wrapper"},{children:[n(m,Object.assign({style:{marginBottom:10}},{children:"Requirements"})),n(o,{options:b,placement:"bottom-start",onSelect:e=>{const t=e.value;u.setSelectedMinimumRequirement(t),u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:void 0,minAmount:void 0}))},truncatedText:!1,width:"272px"})]})),n("div",Object.assign({className:"input__wrapper"},{children:n(r,{value:u.selectedMinimumRequirement===d.AMOUNT?null!==(c=null===(a=u.discountData.minAmount)||void 0===a?void 0:a.toString())&&void 0!==c?c:"":null!==(p=null===(l=u.discountData.minQuantity)||void 0===l?void 0:l.toString())&&void 0!==p?p:"",onChangeText:e=>{u.selectedMinimumRequirement===d.AMOUNT?u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minAmount:parseInt(e)})):u.selectedMinimumRequirement===d.QUANTITY&&u.setDiscountData(Object.assign(Object.assign({},u.discountData),{minQuantity:parseInt(e)}))},labelText:u.selectedMinimumRequirement===d.AMOUNT?"Minimum amount":"Minimum no. of items",prefixText:u.selectedMinimumRequirement===d.AMOUNT?null!==(M=u.currency)&&void 0!==M?M:"":void 0,type:"number",placeholder:u.selectedMinimumRequirement===d.AMOUNT?"Eg. 5000":"Eg. 5",errorMessage:(null===(j=u.dynamicDiscountValidationError)||void 0===j?void 0:j.inValidMinimumAmount)||(null===(v=u.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidMinimumQuantity)?"Required Field":"",state:(null===(D=u.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidMinimumAmount)||(null===(O=u.dynamicDiscountValidationError)||void 0===O?void 0:O.inValidMinimumQuantity)?"invalid":"none"})}))]}))]})};export{u as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import o from"../../../../assets/icons/errorInfo.svg.js";import{useCallback as n,useState as r,useRef as i,useEffect as s}from"react";import{ZeroState as l}from"../../../zeroState/ZeroState.js";import{useOutside as c}from"../../../../hooks/useOutside.js";import{COLORS as a}from"../../../../constants/Theme.js";import{useDropdown as u}from"../../hooks/useDropdown.js";import{Description as d}from"./description/Description.js";import{FreeFormMenu as p}from"./menu/FreeFormMenu.js";import{MenuList as h}from"./menu/MenuList.js";import{SelectAllMenu as g}from"./menu/SelectAllMenu.js";import f from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as m,MenuListContainer as b}from"./OpennedDropdown.styled.js";import{SearchBox as v}from"./searchbox/SearchBox.js";import{SearchZeroState as S}from"./searchbox/SearchZeroState.js";const C=304,w=290,j=t=>e("svg",Object.assign({viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t,{children:e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 2.00001C5.05448 2.00001 2.66667 4.38782 2.66667 7.33334C2.66667 10.2789 5.05448 12.6667 8 12.6667C10.4576 12.6667 12.5269 11.0047 13.1468 8.7442C13.2443 8.38895 13.6112 8.18002 13.9665 8.27748C14.3217 8.37495 14.5306 8.74189 14.4332 9.09713C13.6583 11.9238 11.0716 14 8 14C4.3181 14 1.33333 11.0152 1.33333 7.33334C1.33333 3.65144 4.3181 0.666672 8 0.666672C9.63169 0.666672 11.1266 1.25298 12.2857 2.22668V1.33334C12.2857 0.965148 12.5842 0.666672 12.9524 0.666672C13.3206 0.666672 13.6191 0.965148 13.6191 1.33334V4.00001C13.6191 4.3682 13.3206 4.66667 12.9524 4.66667H10.2857C9.91752 4.66667 9.61905 4.3682 9.61905 4.00001C9.61905 3.63182 9.91752 3.33334 10.2857 3.33334H11.7936C10.8305 2.5053 9.57787 2.00001 8 2.00001Z",fill:"currentColor"})})),O=O=>{let{options:y,isSearchable:x,isMultiSelect:k,maxSelections:D,width:L,allowFreeForm:I,height:T,onClose:M,onSelect:B,onSearch:E,version:A,skipSorting:F,headerRef:H,hideSelectAll:R,primaryButtonText:V,onInfiniteScroll:q,onMultiSelectClear:z,onDropdownItemClick:Z,buttonOptions:P,isSearchLoading:W,isOptionsLoading:$,optionsErrorState:K,disableSearchOptions:N,disableSearchedOptionExcept:U,useDefaultCursor:G,containerStyle:J={},zeroState:Q,isDraggable:X=!1,onOptionsReorder:Y,hideClearButton:_=!1}=O;var ee;const te=n((e=>{if(!X||!k)return e;const t=[],o=[];return e.forEach((e=>{if(e.options)o.push(e);else{e.selected?t.push(e):o.push(e)}})),[...t,...o]}),[X,k]),[oe,ne]=r((()=>te(y))),re=i(oe),ie=i(!1),se=i(Y);s((()=>{ne(te(y))}),[y,te]),s((()=>{re.current=oe}),[oe]),s((()=>{se.current=Y}),[Y]),s((()=>()=>{ie.current&&se.current&&se.current(re.current)}),[]);const le=n((e=>{ne(e),"2.0"===A?null==Y||Y(e):ie.current=!0}),[Y,A]),ce=X?oe:y,{dropdownOptions:ae,search:ue,searchedString:de,searchedOptions:pe,searchError:he,retrySearch:ge,onApplyHandler:fe,selectAllHandler:me,onMultiSelectClear:be,onFreeFormSelect:ve,onMultiSelectApply:Se,latestDropdownOptionsRef:Ce,getSelectedOptions:we,getCurrentSelectionCount:je}=u(A,ce,B,F||X,k,E,N,U,D),[Oe,ye]=r(null!=L?L:w),[xe,ke]=r(null),[De,Le]=r(-1),Ie=i(null),Te=i([]),Me=i(null);c(Ie,(()=>{if(ke(null),k&&"2.0"===A){const e=we(Ce.current);null==M||M(e)}else null==M||M(ae)}),[H,Te]),s((()=>{const e=setTimeout((()=>{Ie.current&&Ie.current.focus({preventScroll:!0})}),0);return()=>clearTimeout(e)}),[]);s((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const o=e;o.disabled||t.push(o)}})),t})(de&&E?pe:ae);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),Le((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=Me.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("ArrowUp"===e.key)e.preventDefault(),Le((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=Me.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("Enter"===e.key&&De>=0){e.preventDefault();const o=t[De];o&&(fe(Object.assign(Object.assign({},o),{selected:!o.selected})),Z&&Z(o))}},t=Ie.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[De,de,pe,ae,E,fe,Z]);const Be=null!=T?T:C,Ee="number"==typeof Be?x&&k?Be-96:x&&!k||!x&&k?Be-48:Be:Be;s((()=>{const e=null!=L?L:w;if(null===xe)ye(e);else if("number"==typeof e)ye(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));ye(t)}}),[xe]);const Ae=[],Fe=(e=>{if(!k||!D&&0!==D)return e;const t=je(ae)>=D;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const o=e;return Object.assign(Object.assign({},o),{disabled:o.disabled||!o.selected&&t})}})):e})((de&&E?pe:ae).map((e=>{var t,o;if(de&&!E){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(de.toLowerCase()))&&(Ae.push(!de||e.label===de),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(de.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(de.toLowerCase()))?(Ae.push(!de||e.label===de),e):null}return e})).filter((e=>null!==e))),He=!!x&&de&&0===Fe.length,Re=!de&&!!$,Ve=!de&&!!K&&!Re,qe=!(de||Fe.length||Re||Ve),ze=Re||Ve||qe,Ze=(null==Q?void 0:Q.title)||"No results found",Pe=(null==Q?void 0:Q.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance.",We=(null==K?void 0:K.title)||"Failed to load options",$e=(null==K?void 0:K.subTitle)||"Something went wrong while fetching the list. Please try again",Ke={buttonText:"Try again",buttonType:"text",size:"small",buttonTextColor:a.background.inverseLight,customIconColor:a.background.inverseLight,LeadingIcon:j},Ne=Object.assign({IconHolderStyle:{background:a.background.negative.light},Icon:e(o,{color:a.content.negative,width:24,height:24})},K);Ne.actionButton=Object.assign(Object.assign({},Ke),null!==(ee=null==K?void 0:K.actionButton)&&void 0!==ee?ee:{});const Ue=Re?void 0:Ve?Ne:Q;return t(m,Object.assign({version:A,ref:Ie,tabIndex:-1,style:Object.assign(Object.assign({width:Oe},J),{outline:"none"})},{children:[t("div",Object.assign({style:{width:xe?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!x&&e(v,{onSearch:ue,version:A}),ze?e("div",Object.assign({style:{height:Be,display:"flex",background:a.background.base}},{children:e(l,Object.assign({},null!=Ue?Ue:{},{isLoading:Re,title:Ve?We:Ze,subTitle:Ve?$e:Pe}))})):t(b,Object.assign({minHeight:Be,maxHeight:Ee,ref:Me},{children:[!!k&&!He&&!R&&e(g,{version:A,options:de&&E?pe:ae,onSelect:me}),!I&&He&&e(S,{isLoading:W,errorMessage:he,onRetry:ge,height:Ee,searchedString:de,containerWidth:L}),I&&(He||!!Ae.length&&Ae.every((e=>!1===e)))&&e(p,{version:A,isMultiSelect:k,onSelect:ve,searchedString:de}),e(h,{onInfiniteScroll:q,onDropdownItemClick:Z,version:A,onSelect:fe,showDescription:function(e,t){ke(e&&t?{title:e,description:t}:null)},isMultiSelect:k,options:Fe,useDefaultCursor:G,ref:Te,focusedIndex:De,isDraggable:X,onOptionsReorder:le})]})),!!k&&!ze&&"2.0"!==A&&e(f,{onClear:()=>{be(),null==z||z()},onApply:Se,list:de&&E?pe:ae,buttonText:V,buttonOptions:P,hideClearButton:_})]})),!!xe&&e(d,{title:xe.title,description:xe.description,version:A})]}))};export{O as OpenedDropdown};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useCallback as o,useState as n,useRef as r,useEffect as i}from"react";import{ZeroState as s}from"../../../zeroState/ZeroState.js";import{useOutside as l}from"../../../../hooks/useOutside.js";import{useDropdown as c}from"../../hooks/useDropdown.js";import{Description as u}from"./description/Description.js";import{FreeFormMenu as a}from"./menu/FreeFormMenu.js";import{MenuList as d}from"./menu/MenuList.js";import{SelectAllMenu as p}from"./menu/SelectAllMenu.js";import h from"./multiSelect/MultiSelectDropdownBottomBar.js";import{OpennedDropdownContainer as f,MenuListContainer as m}from"./OpennedDropdown.styled.js";import{SearchBox as b}from"./searchbox/SearchBox.js";import{SearchZeroState as g}from"./searchbox/SearchZeroState.js";const S=304,v=290,j=j=>{let{options:O,isSearchable:w,isMultiSelect:y,maxSelections:x,width:C,allowFreeForm:D,height:k,onClose:L,onSelect:M,onSearch:I,version:A,skipSorting:T,headerRef:E,hideSelectAll:B,primaryButtonText:F,onInfiniteScroll:H,onMultiSelectClear:R,onDropdownItemClick:q,buttonOptions:z,isSearchLoading:V,disableSearchOptions:W,disableSearchedOptionExcept:Z,useDefaultCursor:$,containerStyle:K={},zeroState:N,isDraggable:P=!1,onOptionsReorder:U,hideClearButton:G=!1}=j;const J=o((e=>{if(!P||!y)return e;const t=[],o=[];return e.forEach((e=>{if(e.options)o.push(e);else{e.selected?t.push(e):o.push(e)}})),[...t,...o]}),[P,y]),[Q,X]=n((()=>J(O))),Y=r(Q),_=r(!1),ee=r(U);i((()=>{X(J(O))}),[O,J]),i((()=>{Y.current=Q}),[Q]),i((()=>{ee.current=U}),[U]),i((()=>()=>{_.current&&ee.current&&ee.current(Y.current)}),[]);const te=o((e=>{X(e),"2.0"===A?null==U||U(e):_.current=!0}),[U,A]),oe=P?Q:O,{dropdownOptions:ne,search:re,searchedString:ie,searchedOptions:se,onApplyHandler:le,selectAllHandler:ce,onMultiSelectClear:ue,onFreeFormSelect:ae,onMultiSelectApply:de,latestDropdownOptionsRef:pe,getSelectedOptions:he,getCurrentSelectionCount:fe}=c(A,oe,M,T||P,y,I,W,Z,x),[me,be]=n(null!=C?C:v),[ge,Se]=n(null),[ve,je]=n(-1),Oe=r(null),we=r([]),ye=r(null);l(Oe,(()=>{if(Se(null),y&&"2.0"===A){const e=he(pe.current);null==L||L(e)}else null==L||L(ne)}),[E,we]),i((()=>{const e=setTimeout((()=>{Oe.current&&Oe.current.focus({preventScroll:!0})}),0);return()=>clearTimeout(e)}),[]);i((()=>{const e=e=>{const t=(e=>{const t=[];return e.forEach((e=>{if(e.options)e.options.forEach((e=>{e.disabled||t.push(e)}));else{const o=e;o.disabled||t.push(o)}})),t})(ie&&I?se:ne);if(0!==t.length)if("ArrowDown"===e.key)e.preventDefault(),je((e=>{const o=e<t.length-1?e+1:0;return setTimeout((()=>{var e;const t=null===(e=ye.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("ArrowUp"===e.key)e.preventDefault(),je((e=>{const o=e>0?e-1:t.length-1;return setTimeout((()=>{var e;const t=null===(e=ye.current)||void 0===e?void 0:e.querySelector(`[data-option-index="${o}"]`);t&&t.scrollIntoView({block:"nearest",behavior:"smooth"})}),0),o}));else if("Enter"===e.key&&ve>=0){e.preventDefault();const o=t[ve];o&&(le(Object.assign(Object.assign({},o),{selected:!o.selected})),q&&q(o))}},t=Oe.current;if(t)return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[ve,ie,se,ne,I,le,q]);const xe=null!=k?k:S,Ce="number"==typeof xe?w&&y?xe-96:w&&!y||!w&&y?xe-48:xe:xe;i((()=>{const e=null!=C?C:v;if(null===ge)be(e);else if("number"==typeof e)be(2*e);else if("string"==typeof e&&e.endsWith("px")){const t=2*parseInt(e.replace("px",""));be(t)}}),[ge]);const De=[],ke=(e=>{if(!y||!x&&0!==x)return e;const t=fe(ne)>=x;return t?e.map((e=>{if(e.options)return Object.assign(Object.assign({},e),{options:e.options.map((e=>Object.assign(Object.assign({},e),{disabled:e.disabled||!e.selected&&t})))});{const o=e;return Object.assign(Object.assign({},o),{disabled:o.disabled||!o.selected&&t})}})):e})((ie&&I?se:ne).map((e=>{var t,o;if(ie&&!I){if(e.options){const t=Object.assign({},e);return t.options=t.options.filter((e=>{var t;return!!(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(ie.toLowerCase()))&&(De.push(!ie||e.label===ie),!0)})),t.options.length>0?t:null}return(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(ie.toLowerCase()))||(null===(o=e.searchKey)||void 0===o?void 0:o.toLowerCase().includes(ie.toLowerCase()))?(De.push(!ie||e.label===ie),e):null}return e})).filter((e=>null!==e))),Le=!!w&&ie&&0===ke.length;return e(f,Object.assign({version:A,ref:Oe,tabIndex:-1,style:Object.assign(Object.assign({width:me},K),{outline:"none"})},{children:[e("div",Object.assign({style:{width:ge?"50%":"100%",display:"flex",flexDirection:"column",background:"white"}},{children:[!!w&&t(b,{onSearch:re,version:A}),ke.length||ie?e(m,Object.assign({minHeight:xe,maxHeight:Ce,ref:ye},{children:[!!y&&!Le&&!B&&t(p,{version:A,options:ie&&I?se:ne,onSelect:ce}),!D&&Le&&t(g,{isLoading:V,height:Ce,searchedString:ie,containerWidth:C}),D&&(Le||!!De.length&&De.every((e=>!1===e)))&&t(a,{version:A,isMultiSelect:y,onSelect:ae,searchedString:ie}),t(d,{onInfiniteScroll:H,onDropdownItemClick:q,version:A,onSelect:le,showDescription:function(e,t){Se(e&&t?{title:e,description:t}:null)},isMultiSelect:y,options:ke,useDefaultCursor:$,ref:we,focusedIndex:ve,isDraggable:P,onOptionsReorder:te})]})):t("div",Object.assign({style:{height:xe,display:"flex"}},{children:t(s,Object.assign({},N,{title:(null==N?void 0:N.title)||"No results found",subTitle:(null==N?void 0:N.subTitle)||"Please try again later or contact us at support@bik.ai if you require further assistance."}))})),!!y&&!(!ke.length&&!ie)&&"2.0"!==A&&t(h,{onClear:()=>{ue(),null==R||R()},onApply:de,list:ie&&I?se:ne,buttonText:F,buttonOptions:z,hideClearButton:G})]})),!!ge&&t(u,{title:ge.title,description:ge.description,version:A})]}))};export{j as OpenedDropdown};
@@ -4,6 +4,4 @@ export declare const SearchZeroState: React.FC<{
4
4
  height: number;
5
5
  isLoading?: boolean;
6
6
  containerWidth?: string;
7
- errorMessage?: string;
8
- onRetry?: () => void;
9
7
  }>;
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{ZeroState as e}from"../../../../zeroState/ZeroState.js";const o=o=>{let{searchedString:i,height:n,isLoading:r,containerWidth:s,errorMessage:a,onRetry:l}=o;const d=!!a&&!r;return t("div",Object.assign({style:{height:n,display:"flex",alignItems:"center"}},{children:t(e,{isLoading:r,title:d?"Failed to load options":"No results found",subTitle:d?a:`Sorry we could not find any results for "${null!=i?i:""}"`,actionButton:d?{buttonText:"Try again",buttonType:"text",onClick:l}:void 0,containerWidth:s})}))};export{o as SearchZeroState};
1
+ import{jsx as t}from"react/jsx-runtime";import{ZeroState as e}from"../../../../zeroState/ZeroState.js";const i=i=>{let{searchedString:r,height:n,isLoading:o,containerWidth:s}=i;return t("div",Object.assign({style:{height:n,display:"flex",alignItems:"center"}},{children:t(e,{isLoading:o,title:"No results found",subTitle:`Sorry we could not find any results for "${null!=r?r:""}"`,containerWidth:s})}))};export{i as SearchZeroState};
@@ -7,8 +7,6 @@ export declare const useDropdown: (version: string | undefined, options: Dropdow
7
7
  search: (searchKey: string) => void;
8
8
  searchedString: string;
9
9
  searchedOptions: DropdownOption[];
10
- searchError: string | undefined;
11
- retrySearch: () => void;
12
10
  onApplyHandler: (optionSelect: SingleOption, returnOnly?: boolean) => ({
13
11
  label: string;
14
12
  value: string;
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import t from"lodash/debounce";import{useState as s,useRef as n,useEffect as l,useCallback as i,useMemo as c}from"react";import{iterateOnOptionsRaw as o,iterateOnOptions as a}from"../OpenedDropdown/utils/iterationOnOptions.js";const r=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",d=arguments.length>1?arguments[1]:void 0,u=arguments.length>2?arguments[2]:void 0,v=arguments.length>3?arguments[3]:void 0,f=arguments.length>4?arguments[4]:void 0,g=arguments.length>5?arguments[5]:void 0,p=arguments.length>6?arguments[6]:void 0,b=arguments.length>7&&void 0!==arguments[7]?arguments[7]:[],O=arguments.length>8?arguments[8]:void 0;const[h,j]=s(null!=d?d:[]),[m,w]=s([]),[S,C]=s(""),[E,y]=s(void 0),F=n(h),L=n(g);l((()=>{L.current=g}),[g]),l((()=>{if(F.current=h,m.length&&S&&g){let e=[...m];const t=h.map((e=>{if(e.options)return e.options.map((e=>({value:e.value,selected:e.selected})));const t=e;return{value:t.value,selected:t.selected}})).flat();e=e.map((e=>{const s=t.find((t=>e.value===t.value));return s?Object.assign(Object.assign({},e),{selected:s.selected}):e})),p&&(e=e.map((e=>Object.assign(Object.assign({},e),{disabled:!b.includes(e.value)})))),w(f&&!v?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[h]),l((()=>{if(d){const e=[...d];j(f&&!v?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[d]);const A=e=>{const t=[];return e.forEach((e=>{if(e.options){const s=e.options.filter((e=>!0===e.selected));t.push(Object.assign(Object.assign({},e),{options:[...s]}))}else e.selected&&t.push(Object.assign({},e))})),t},x=e=>{let t=0;return e.forEach((e=>{e.options?t+=e.options.filter((e=>!0===e.selected)).length:e.selected&&t++})),t},M=e=>!(!f||!O&&0!==O)&&x(e)>=O,D=i((t=>e(void 0,void 0,void 0,(function*(){const e=L.current;if(!t||!e)return;const s=[];o(F.current,(e=>{e.selected&&!s.includes(e.value)&&s.push(e.value)}));try{const n=yield e(t);if(y(void 0),n){const e=n.map((e=>{if(e.options){const t=e;return Object.assign(Object.assign({},t),{options:t.options.map((e=>Object.assign(Object.assign({},e),{selected:s.includes(e.value)})))})}return Object.assign(Object.assign({},e),{selected:s.includes(e.value)})}));w([...e])}else w([])}catch(e){w([]),y(e instanceof Error?e.message:"Something went wrong while fetching the list. Please try again")}}))),[]),H=c((()=>t(D,300)),[D]);function R(e,t){if(f){if(e.selected&&O&&M(h))return;if(m.length&&S&&g)if(e.selected){if(O&&M(h))return;let s=!1;const n=a(h,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s||n.push(e),t)return[...n];j([...n]),"2.0"===r&&_(n)}else{let s=!1,n=a(h,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s&&(n=n.filter((t=>t.value!==e.value))),t)return[...n];j([...n]),"2.0"===r&&_(n)}else{const s=a(h,{selected:e.selected},(t=>t.value===e.value));if(t)return[...s];j([...s]),"2.0"===r&&_(s)}}else null==u||u(e)}function _(e){const t=A(null!=e?e:F.current);null==u||u([...t])}return l((()=>()=>null==H?void 0:H.cancel()),[H]),{latestDropdownOptionsRef:F,dropdownOptions:h,search:function(e){C(e),w([]),y(void 0),e?H(e):null==H||H.cancel()},searchedString:S,searchedOptions:m,searchError:E,retrySearch:function(){S&&(y(void 0),D(S))},onApplyHandler:R,selectAllHandler:function(e){if(m.length&&S&&g)"selectAll"===e?function(e){let t=[...h];if(e&&O&&O>0){const e=x(t),s=O-e;if(s<=0)return;let n=0;m.forEach((e=>{if(n>=s)return;let l=!1;t=t.map((t=>{const s=e;return t.selected||t.disabled?t:void 0!==s.value&&s.value===t.value?(l=!0,n++,Object.assign(Object.assign({},t),{selected:!0})):t})),!l&&n<s&&(e.disabled||(t.push(Object.assign(Object.assign({},e),{selected:!0})),n++))})),j([...t]),"2.0"===r&&_(t)}}(!0):function(e){let t=[...h];e?m.forEach((e=>{let s=!1;t=t.map((t=>{const n=e;return void 0!==n.value&&n.value===t.value?(s=!0,Object.assign(Object.assign({},t),{selected:!0})):t})),s||t.push(Object.assign(Object.assign({},e),{selected:!0}))})):m.forEach((e=>{t=t.map((t=>{const s=e;return void 0!==s.value&&s.value===t.value?Object.assign(Object.assign({},t),{selected:!1}):t}))})),j([...t]),"2.0"===r&&_(t)}(!1);else if("selectAll"===e)if(O&&O>0){const e=x(h),t=O-e;if(t<=0)return;let s=0;const n=h.map((e=>{var n;if(e.options){const n=e;return Object.assign(Object.assign({},n),{options:n.options.map((e=>{var n;return e.disabled||e.selected||S&&!(null===(n=e.label)||void 0===n?void 0:n.toLowerCase().includes(S.toLowerCase()))?e:s<t?(s++,Object.assign(Object.assign({},e),{selected:!0})):e}))})}{const l=e;return l.disabled||(l.selected||S&&!(null===(n=l.label)||void 0===n?void 0:n.toLowerCase().includes(S.toLowerCase())))?e:s<t?(s++,Object.assign(Object.assign({},e),{selected:!0})):e}}));j([...n]),"2.0"===r&&_(n)}else{const e=a(h,{selected:!0},(e=>{var t;return S?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(S.toLowerCase()))&&!e.disabled:!e.disabled}));j([...e]),"2.0"===r&&_(e)}else if("notSelected"===e){const e=a(h,{selected:!1},(e=>!e.disabled));j([...e]),"2.0"===r&&_(e)}},onMultiSelectClear:function(){const e=a(h,{selected:!1});j([...e]),"2.0"===r&&_(e)},onFreeFormSelect:function(e){if(!f)return void R({label:S,value:S,isFreeForm:!0,selected:!0});const t=h.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===S&&t.value===S?e:t.selected})));e&&(t.some((e=>e.label===S&&e.value===S))||t.unshift({label:S,value:S,isFreeForm:!0,selected:!0})),j([...t]),"2.0"===r&&_(t)},onMultiSelectApply:_,getSelectedOptions:A,getCurrentSelectionCount:x,isMaxSelectionsReached:M,maxSelections:O}};export{r as useDropdown};
1
+ import e from"lodash/debounce";import{useState as t,useRef as s,useEffect as l,useCallback as n,useMemo as c}from"react";import{iterateOnOptionsRaw as i,iterateOnOptions as o}from"../OpenedDropdown/utils/iterationOnOptions.js";const a=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",r=arguments.length>1?arguments[1]:void 0,u=arguments.length>2?arguments[2]:void 0,d=arguments.length>3?arguments[3]:void 0,v=arguments.length>4?arguments[4]:void 0,f=arguments.length>5?arguments[5]:void 0,p=arguments.length>6?arguments[6]:void 0,b=arguments.length>7&&void 0!==arguments[7]?arguments[7]:[],g=arguments.length>8?arguments[8]:void 0;const[O,j]=t(null!=r?r:[]),[h,m]=t([]),[w,C]=t(""),S=s(O),F=s(f);l((()=>{F.current=f}),[f]),l((()=>{if(S.current=O,h.length&&w&&f){let e=[...h];const t=O.map((e=>{if(e.options)return e.options.map((e=>({value:e.value,selected:e.selected})));const t=e;return{value:t.value,selected:t.selected}})).flat();e=e.map((e=>{const s=t.find((t=>e.value===t.value));return s?Object.assign(Object.assign({},e),{selected:s.selected}):e})),p&&(e=e.map((e=>Object.assign(Object.assign({},e),{disabled:!b.includes(e.value)})))),m(v&&!d?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[O]),l((()=>{if(r){const e=[...r];j(v&&!d?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[r]);const L=e=>{const t=[];return e.forEach((e=>{if(e.options){const s=e.options.filter((e=>!0===e.selected));t.push(Object.assign(Object.assign({},e),{options:[...s]}))}else e.selected&&t.push(Object.assign({},e))})),t},A=e=>{let t=0;return e.forEach((e=>{e.options?t+=e.options.filter((e=>!0===e.selected)).length:e.selected&&t++})),t},E=e=>!(!v||!g&&0!==g)&&A(e)>=g,x=n((e=>{const t=F.current;if(!e||!t)return;const s=[];i(S.current,(e=>{e.selected&&!s.includes(e.value)&&s.push(e.value)})),t(e).then((e=>{if(e){const t=e.map((e=>{if(e.options){const t=e;return Object.assign(Object.assign({},t),{options:t.options.map((e=>Object.assign(Object.assign({},e),{selected:s.includes(e.value)})))})}return Object.assign(Object.assign({},e),{selected:s.includes(e.value)})}));m([...t])}}))}),[]),M=c((()=>e(x,300)),[x]);function y(e,t){if(v){if(e.selected&&g&&E(O))return;if(h.length&&w&&f)if(e.selected){if(g&&E(O))return;let s=!1;const l=o(O,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s||l.push(e),t)return[...l];j([...l]),"2.0"===a&&D(l)}else{let s=!1,l=o(O,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s&&(l=l.filter((t=>t.value!==e.value))),t)return[...l];j([...l]),"2.0"===a&&D(l)}else{const s=o(O,{selected:e.selected},(t=>t.value===e.value));if(t)return[...s];j([...s]),"2.0"===a&&D(s)}}else null==u||u(e)}function D(e){const t=L(null!=e?e:S.current);null==u||u([...t])}return l((()=>()=>null==M?void 0:M.cancel()),[M]),{latestDropdownOptionsRef:S,dropdownOptions:O,search:function(e){C(e),m([]),e?M(e):null==M||M.cancel()},searchedString:w,searchedOptions:h,onApplyHandler:y,selectAllHandler:function(e){if(h.length&&w&&f)"selectAll"===e?function(e){let t=[...O];if(e&&g&&g>0){const e=A(t),s=g-e;if(s<=0)return;let l=0;h.forEach((e=>{if(l>=s)return;let n=!1;t=t.map((t=>{const s=e;return t.selected||t.disabled?t:void 0!==s.value&&s.value===t.value?(n=!0,l++,Object.assign(Object.assign({},t),{selected:!0})):t})),!n&&l<s&&(e.disabled||(t.push(Object.assign(Object.assign({},e),{selected:!0})),l++))})),j([...t]),"2.0"===a&&D(t)}}(!0):function(e){let t=[...O];e?h.forEach((e=>{let s=!1;t=t.map((t=>{const l=e;return void 0!==l.value&&l.value===t.value?(s=!0,Object.assign(Object.assign({},t),{selected:!0})):t})),s||t.push(Object.assign(Object.assign({},e),{selected:!0}))})):h.forEach((e=>{t=t.map((t=>{const s=e;return void 0!==s.value&&s.value===t.value?Object.assign(Object.assign({},t),{selected:!1}):t}))})),j([...t]),"2.0"===a&&D(t)}(!1);else if("selectAll"===e)if(g&&g>0){const e=A(O),t=g-e;if(t<=0)return;let s=0;const l=O.map((e=>{var l;if(e.options){const l=e;return Object.assign(Object.assign({},l),{options:l.options.map((e=>{var l;return e.disabled||e.selected||w&&!(null===(l=e.label)||void 0===l?void 0:l.toLowerCase().includes(w.toLowerCase()))?e:s<t?(s++,Object.assign(Object.assign({},e),{selected:!0})):e}))})}{const n=e;return n.disabled||(n.selected||w&&!(null===(l=n.label)||void 0===l?void 0:l.toLowerCase().includes(w.toLowerCase())))?e:s<t?(s++,Object.assign(Object.assign({},e),{selected:!0})):e}}));j([...l]),"2.0"===a&&D(l)}else{const e=o(O,{selected:!0},(e=>{var t;return w?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(w.toLowerCase()))&&!e.disabled:!e.disabled}));j([...e]),"2.0"===a&&D(e)}else if("notSelected"===e){const e=o(O,{selected:!1},(e=>!e.disabled));j([...e]),"2.0"===a&&D(e)}},onMultiSelectClear:function(){const e=o(O,{selected:!1});j([...e]),"2.0"===a&&D(e)},onFreeFormSelect:function(e){if(!v)return void y({label:w,value:w,isFreeForm:!0,selected:!0});const t=O.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===w&&t.value===w?e:t.selected})));e&&(t.some((e=>e.label===w&&e.value===w))||t.unshift({label:w,value:w,isFreeForm:!0,selected:!0})),j([...t]),"2.0"===a&&D(t)},onMultiSelectApply:D,getSelectedOptions:L,getCurrentSelectionCount:A,isMaxSelectionsReached:E,maxSelections:g}};export{a as useDropdown};
@@ -27,15 +27,6 @@ export interface OpenDropdownProps {
27
27
  onDropdownItemClick?: (option: DropdownOption) => void;
28
28
  buttonOptions?: ButtonOptions;
29
29
  isSearchLoading?: boolean;
30
- isOptionsLoading?: boolean;
31
- optionsErrorState?: {
32
- Icon?: React.ReactNode;
33
- IconHolderStyle?: React.CSSProperties;
34
- actionButton?: ButtonProps;
35
- buttonWidth?: number;
36
- title?: string;
37
- subTitle?: string;
38
- };
39
30
  disableSearchOptions?: boolean;
40
31
  disableSearchedOptionExcept?: string[];
41
32
  useDefaultCursor?: boolean;
@@ -1 +1 @@
1
- import{__rest as o}from"../../_virtual/_tslib.js";import{jsxs as t,jsx as n}from"react/jsx-runtime";import{DropdownPopover as r}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"react";import"../zeroState/ZeroState.js";import"../../constants/Theme.js";import"lodash/debounce";import"../TypographyStyle.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import{Button as e}from"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{SpinnerColorMap as p}from"../button/themes.js";import{Spinner as s}from"../spinner/Spinner.js";import{DropdownButtonStyle as i,LoaderContainer as d}from"./DropdownButton.style.js";const m=m=>{var u,l;const a=m.buttonProps,c=o(a,["onClick"]);return t(i,Object.assign({type:m.buttonProps.buttonType,disabled:m.buttonProps.disabled},{children:[(null===(u=m.buttonProps)||void 0===u?void 0:u.isLoading)&&n(d,{children:n(s,{className:"spinner",size:"small",color:p(m.buttonProps.buttonType||"primary",m.buttonProps.inverse)})}),n(e,Object.assign({},m.buttonProps,{isLoading:!1,style:{borderRadius:"0px",borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",borderRight:"0px"}})),n("div",{className:"dd-button-divider"}),n(r,Object.assign({},m.dropdownProps,{isChildLoading:null===(l=m.buttonProps)||void 0===l?void 0:l.isLoading},{children:n(e,Object.assign({},c,{isLoading:!1,buttonText:"",TrailingIcon:m.iconProps,style:{borderRadius:"0px",borderTopRightRadius:"4px",borderBottomRightRadius:"4px"}}))}))]}))};export{m as DropdownButton};
1
+ import{__rest as o}from"../../_virtual/_tslib.js";import{jsxs as t,jsx as n}from"react/jsx-runtime";import{DropdownPopover as r}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"react";import"../zeroState/ZeroState.js";import"lodash/debounce";import"../TypographyStyle.js";import"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import{Button as e}from"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{SpinnerColorMap as p}from"../button/themes.js";import{Spinner as s}from"../spinner/Spinner.js";import{DropdownButtonStyle as i,LoaderContainer as d}from"./DropdownButton.style.js";const m=m=>{var u,l;const a=m.buttonProps,c=o(a,["onClick"]);return t(i,Object.assign({type:m.buttonProps.buttonType,disabled:m.buttonProps.disabled},{children:[(null===(u=m.buttonProps)||void 0===u?void 0:u.isLoading)&&n(d,{children:n(s,{className:"spinner",size:"small",color:p(m.buttonProps.buttonType||"primary",m.buttonProps.inverse)})}),n(e,Object.assign({},m.buttonProps,{isLoading:!1,style:{borderRadius:"0px",borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",borderRight:"0px"}})),n("div",{className:"dd-button-divider"}),n(r,Object.assign({},m.dropdownProps,{isChildLoading:null===(l=m.buttonProps)||void 0===l?void 0:l.isLoading},{children:n(e,Object.assign({},c,{isLoading:!1,buttonText:"",TrailingIcon:m.iconProps,style:{borderRadius:"0px",borderTopRightRadius:"4px",borderBottomRightRadius:"4px"}}))}))]}))};export{m as DropdownButton};
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Placement } from "../tooltips";
3
3
  import { DropdownOption, OpenDropdownProps } from '../dropdown/type';
4
4
  import { FloaterProps } from '../floater/floater';
5
- import { InputProps } from '../input';
5
+ import { InputProps } from '../input/Input.model';
6
6
  type DropdownProps = OpenDropdownProps & {
7
7
  isLoading?: boolean;
8
8
  children?: React.ReactNode;
@@ -1,9 +1,4 @@
1
1
  import 'react-image-crop/dist/ReactCrop.css';
2
- export interface BikImageCropperProps {
3
- aspectRatio?: number;
4
- src: string;
5
- onCropComplete: (base64String: string, didChange: boolean) => void | Promise<void>;
6
- onCancel: () => void;
7
- }
2
+ import { BikImageCropperProps } from './BikImageCropper.model';
8
3
  export declare const BikImageCropper: (props: BikImageCropperProps) => import("react/jsx-runtime").JSX.Element;
9
4
  export default BikImageCropper;
@@ -0,0 +1,6 @@
1
+ export interface BikImageCropperProps {
2
+ aspectRatio?: number;
3
+ src: string;
4
+ onCropComplete: (base64String: string, didChange: boolean) => void | Promise<void>;
5
+ onCancel: () => void;
6
+ }
@@ -1,5 +1,5 @@
1
1
  import { CompressImageOptions } from "../../image-compress";
2
- import { BikImageCropperProps } from "..";
2
+ import { BikImageCropperProps } from '../BikImageCropper.model';
3
3
  /**
4
4
  * Todos
5
5
  * - Add option to pass https url in the src / edit an image
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as n,useEffect as r}from"react";import o from"react-chips";import{COLORS as i}from"../../constants/Theme.js";import{BodySecondary as l,BodyCaption as c}from"../TypographyStyle.js";import{theme as a,chipTheme as s}from"./ChipInput.styled.js";const p=p=>{let{onChipsChange:h,placeholder:m,chips:d,label:u,labelColor:y,hintText:g,hintTextColor:f,error:v,inputHeight:C,createChipKeys:b,chipsContainerCustomStyle:j,nativeID:x}=p;const[T,S]=n(!1);return r((()=>{var e,t;null===(e=document.querySelector(`#${x} input`))||void 0===e||e.addEventListener("focus",(()=>{S(!0)})),null===(t=document.querySelector(`#${x} input`))||void 0===t||t.addEventListener("blur",(()=>{S(!1)}))}),[]),e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:8},id:x},{children:[u&&t(l,Object.assign({style:{color:T?i.content.brand:v?i.content.negative:y||i.content.primary}},{children:u})),t(o,{value:d,theme:a(!!v,C,j,T),chipTheme:s,placeholder:0===d.length&&!!m&&!T&&m,onChange:e=>{h(e)},createChipKeys:b||","}),(!!g||!!v)&&t(c,Object.assign({style:{color:v?i.content.negative:f||i.content.secondary}},{children:v||g}))]}))};export{p as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r}from"react";import{COLORS as o}from"../../constants/Theme.js";import{BodySecondary as s,BodyCaption as l}from"../TypographyStyle.js";import{getContainerStyle as i,getContainerHoverStyle as c,getChipStyle as a,getChipRemoveStyle as u,getInputStyle as d}from"./ChipInput.styled.js";const p=p=>{let{onChipsChange:y,placeholder:h,chips:g,label:m,labelColor:v,hintText:b,hintTextColor:f,error:C,inputHeight:j,createChipKeys:k,chipsContainerCustomStyle:x,nativeID:T}=p;const[O,D]=n(""),[M,E]=n(!1),w=r(null),B=k||[",",188,"Enter",13],I=i(!!C,j,x,M),K=M?{}:c(),L=a(),S=u(),$=d(j);return e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:8},id:T},{children:[m&&t(s,Object.assign({style:{color:M?o.content.brand:C?o.content.negative:v||o.content.primary}},{children:m})),e("div",Object.assign({style:I,onClick:()=>{var e;null===(e=w.current)||void 0===e||e.focus()},onMouseEnter:e=>{M||Object.assign(e.currentTarget.style,K)},onMouseLeave:e=>{M||(e.currentTarget.style.border=`1px solid ${C?o.stroke.negative.vibrant:o.stroke.primary}`)}},{children:[g.map(((n,r)=>e("div",Object.assign({style:L},{children:[t("span",{children:n}),t("button",Object.assign({style:S,onClick:e=>{var t;e.stopPropagation(),t=r,y(g.filter(((e,n)=>n!==t)))},onMouseEnter:e=>{e.currentTarget.style.color=o.content.secondary},onMouseLeave:e=>{e.currentTarget.style.color=o.content.secondary},"aria-label":`Remove ${n}`},{children:"×"}))]}),r))),t("input",{ref:w,type:"text",value:O,onChange:e=>D(e.target.value),onKeyDown:e=>{if(B.includes(e.key)||B.includes(e.keyCode)||B.includes(e.which)){e.preventDefault();const t=O.trim();t&&!g.includes(t)&&(y([...g,t]),D(""))}else"Backspace"===e.key&&""===O&&g.length>0&&y(g.slice(0,-1))},onFocus:()=>{E(!0)},onBlur:()=>{E(!1);const e=O.trim();e&&!g.includes(e)&&(y([...g,e]),D(""))},placeholder:0===g.length&&h&&!M?h:void 0,style:$})]})),(!!b||!!C)&&t(l,Object.assign({style:{color:C?o.content.negative:f||o.content.secondary}},{children:C||b}))]}))};export{p as default};