@justifi/webcomponents 5.4.3 → 5.5.0

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 (842) hide show
  1. package/dist/cjs/Api-KMweahmp.js +74 -0
  2. package/dist/cjs/{Business-d88b77fd.js → Business-DyiDiIuO.js} +1 -1
  3. package/dist/cjs/{Checkout-5352009d.js → Checkout-RAGvjVPj.js} +1 -1
  4. package/dist/cjs/{ComponentError-233ac749.js → ComponentError-C4MdBBMe.js} +1 -0
  5. package/dist/cjs/{Payment-bccd8f7d.js → Payment-CQCmj3Ck.js} +2 -2
  6. package/dist/cjs/{SubAccount-2a302ead.js → Refund-DpKGhW3o.js} +25 -1
  7. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +10 -0
  8. package/dist/cjs/additional-questions-details_5.cjs.entry.js +5 -11
  9. package/dist/cjs/{badge-364e6311.js → badge-BXpCpcer.js} +2 -2
  10. package/dist/cjs/bank-account-document-form-inputs_4.cjs.entry.js +25 -43
  11. package/dist/cjs/bank-account-form_9.cjs.entry.js +93 -97
  12. package/dist/cjs/{business-additional-questions-schema-8568cb79.js → business-additional-questions-schema-mzZ2gYHQ.js} +2 -2
  13. package/dist/cjs/business-details-core.cjs.entry.js +6 -10
  14. package/dist/cjs/{business-form-options-62e9c8ab.js → business-form-options-BCj0efiD.js} +1 -1
  15. package/dist/cjs/{business-identity-schema-518ab6eb.js → business-identity-schema-dt0zCW0R.js} +2 -2
  16. package/dist/cjs/{business.service-6e8a29a2.js → business.service-Crmkeulk.js} +23 -8
  17. package/dist/cjs/{button-4a9fd41e.js → button-KWTLx2LP.js} +2 -2
  18. package/dist/cjs/{check-pkg-version-64d3381a.js → check-pkg-version-CLsX6cK5.js} +3 -3
  19. package/dist/cjs/{checkout.service-0a7835dc.js → checkout.service-r90INf2g.js} +13 -10
  20. package/dist/cjs/checkouts-list-core.cjs.entry.js +25 -31
  21. package/dist/cjs/{payments-list-params-state-442d9944.js → checkouts-list-params-state-Cmfy_CND.js} +1 -1
  22. package/dist/cjs/{checkouts-table-8a1b49ff.js → checkouts-table-5jU4JUcM.js} +4 -4
  23. package/dist/cjs/custom-popper_4.cjs.entry.js +27 -52
  24. package/dist/cjs/{dispute.service-6efc7d7f.js → dispute.service-CGgfmGU-.js} +20 -11
  25. package/dist/cjs/{event-types-5a6ce2b0.js → event-types-CJapDsYA.js} +3 -3
  26. package/dist/cjs/form-alert_5.cjs.entry.js +10 -19
  27. package/dist/cjs/form-control-checkbox.cjs.entry.js +9 -18
  28. package/dist/cjs/form-control-date.cjs.entry.js +9 -19
  29. package/dist/cjs/{form-control-error-text-3cff9b7b.js → form-control-error-text-D19AMaOO.js} +2 -2
  30. package/dist/cjs/form-control-file-v2_2.cjs.entry.js +11 -30
  31. package/dist/cjs/{form-control-help-text-94ffed2c.js → form-control-help-text-CbrDvt9D.js} +2 -2
  32. package/dist/cjs/form-control-help-text.cjs.entry.js +1 -5
  33. package/dist/cjs/form-control-monetary-provisioning.cjs.entry.js +13 -22
  34. package/dist/cjs/form-control-monetary.cjs.entry.js +13 -22
  35. package/dist/cjs/form-control-number-masked_2.cjs.entry.js +12 -25
  36. package/dist/cjs/form-control-number.cjs.entry.js +9 -18
  37. package/dist/cjs/form-control-radio.cjs.entry.js +7 -17
  38. package/dist/cjs/{get-business-d8f5db51.js → get-business-BBzGEPBG.js} +3 -3
  39. package/dist/cjs/get-payment-details-CKg1Lb3_.js +42 -0
  40. package/dist/cjs/{get-payout-csv-7607c71e.js → get-payout-csv-DD9C5yMw.js} +11 -11
  41. package/dist/cjs/{get-subaccounts-ae5b35a8.js → get-subaccounts-YlFT-fBr.js} +11 -10
  42. package/dist/cjs/gross-payment-chart-core.cjs.entry.js +262 -270
  43. package/dist/cjs/{header-1-43b2b905.js → header-1-ZNnpq6yT.js} +2 -2
  44. package/dist/cjs/{header-3-eb250a04.js → header-3-D6LxdW_A.js} +2 -2
  45. package/dist/cjs/{helpers-602962eb.js → helpers-B5OCqlIM.js} +1 -1
  46. package/dist/cjs/{iframe-input-styles-state-d0de0b24.js → iframe-input-styles-state-CQL59u0d.js} +2 -2
  47. package/dist/cjs/iframe-input.cjs.entry.js +1640 -0
  48. package/dist/cjs/{index-750475a3.js → index-1MT3Z4XI.js} +1 -1
  49. package/dist/cjs/{index-d2d0b181.js → index-DhcqPIbT.js} +4 -5
  50. package/dist/cjs/{index-5b9a3b5f.js → index-DtkhH7sB.js} +460 -271
  51. package/dist/cjs/index.esm-CVuJLXJZ.js +11807 -0
  52. package/dist/cjs/{input-handlers-cff032bb.js → input-handlers-DYl_0IwC.js} +1 -1
  53. package/dist/cjs/{insurance-state-71f8b653.js → insurance-state-q5eNmjIK.js} +3 -3
  54. package/dist/cjs/justifi-additional-questions-form-step-core_6.cjs.entry.js +64 -94
  55. package/dist/cjs/justifi-additional-questions-form-step_9.cjs.entry.js +36 -86
  56. package/dist/cjs/justifi-additional-statement_8.cjs.entry.js +36 -54
  57. package/dist/cjs/justifi-business-details.cjs.entry.js +16 -20
  58. package/dist/cjs/justifi-business-form.cjs.entry.js +34 -38
  59. package/dist/cjs/justifi-business-representative-form-inputs.cjs.entry.js +6 -11
  60. package/dist/cjs/justifi-checkout-core.cjs.entry.js +31 -34
  61. package/dist/cjs/justifi-checkout.cjs.entry.js +23 -29
  62. package/dist/cjs/justifi-checkouts-list-filters.cjs.entry.js +15 -18
  63. package/dist/cjs/justifi-checkouts-list.cjs.entry.js +25 -30
  64. package/dist/cjs/justifi-details.cjs.entry.js +3 -6
  65. package/dist/cjs/justifi-dispute-management-core.cjs.entry.js +5 -11
  66. package/dist/cjs/justifi-dispute-management.cjs.entry.js +19 -23
  67. package/dist/cjs/justifi-dispute-notification_3.cjs.entry.js +38 -52
  68. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +13 -16
  69. package/dist/cjs/justifi-order-terminals.cjs.entry.js +30 -39
  70. package/dist/cjs/justifi-owner-form_3.cjs.entry.js +29 -52
  71. package/dist/cjs/justifi-payment-details.cjs.entry.js +24 -52
  72. package/dist/cjs/justifi-payment-provisioning-core.cjs.entry.js +15 -23
  73. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +15 -16
  74. package/dist/cjs/justifi-payments-list-filters.cjs.entry.js +11 -17
  75. package/dist/cjs/justifi-payments-list.cjs.entry.js +25 -29
  76. package/dist/cjs/justifi-payout-details.cjs.entry.js +21 -26
  77. package/dist/cjs/justifi-payouts-list-filters.cjs.entry.js +9 -12
  78. package/dist/cjs/justifi-payouts-list.cjs.entry.js +27 -33
  79. package/dist/cjs/justifi-refund-payment.cjs.entry.js +189 -69
  80. package/dist/cjs/justifi-season-interruption-insurance-core.cjs.entry.js +10 -27
  81. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +24 -35
  82. package/dist/cjs/justifi-terminal-orders-list-filters.cjs.entry.js +24 -26
  83. package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +29 -29
  84. package/dist/cjs/justifi-terminals-list-filters.cjs.entry.js +21 -25
  85. package/dist/cjs/justifi-terminals-list.cjs.entry.js +26 -31
  86. package/dist/cjs/justifi-tokenize-payment-method.cjs.entry.js +24 -28
  87. package/dist/cjs/loader.cjs.js +3 -5
  88. package/dist/cjs/lodash-CvSCBJ_8.js +17216 -0
  89. package/dist/cjs/package-5B4P3NpD.js +9 -0
  90. package/dist/cjs/pagination-menu.cjs.entry.js +3 -5
  91. package/dist/cjs/{parts-5ca90f9a.js → parts-D_uKOPFe.js} +3 -1
  92. package/dist/cjs/payment-details-core.cjs.entry.js +19 -22
  93. package/dist/cjs/{payment-provisioning-actions-382ab48c.js → payment-provisioning-actions-BkWSDJQQ.js} +2 -2
  94. package/dist/cjs/payment.service-BrHUGHYs.js +23 -0
  95. package/dist/cjs/payments-list-core.cjs.entry.js +25 -30
  96. package/dist/cjs/{terminal-orders-list-params-state-c419078f.js → payments-list-params-state-Cmfy_CND.js} +1 -1
  97. package/dist/cjs/{payments-status-075aad0a.js → payments-status-DAzq_Z13.js} +2 -2
  98. package/dist/cjs/{payments-table-a076755a.js → payments-table-BEpL6oJQ.js} +4 -4
  99. package/dist/cjs/payout-details-core.cjs.entry.js +14 -18
  100. package/dist/cjs/payouts-list-core.cjs.entry.js +26 -33
  101. package/dist/cjs/{checkouts-list-params-state-644d3639.js → payouts-list-params-state-Cmfy_CND.js} +1 -1
  102. package/dist/cjs/{payouts-status-ced97c2b.js → payouts-status-CYrKPRld.js} +2 -2
  103. package/dist/cjs/{payouts-table-aedce326.js → payouts-table-Bbi23U5v.js} +4 -4
  104. package/dist/cjs/{schema-validations-a7cefbdf.js → schema-validations-p4OCdblz.js} +4 -4
  105. package/dist/cjs/{skeleton-e8aa41d0.js → skeleton-C59M0QK2.js} +2 -2
  106. package/dist/cjs/{spinner-580453f2.js → spinner-736baCoH.js} +2 -2
  107. package/dist/cjs/{styled-host-94309bab.js → styled-host-JifnTMIV.js} +2 -3
  108. package/dist/cjs/table-filters-menu.cjs.entry.js +4 -10
  109. package/dist/cjs/terminal-orders-list-core.cjs.entry.js +24 -29
  110. package/dist/cjs/{payouts-list-params-state-033b76d6.js → terminal-orders-list-params-state-Cmfy_CND.js} +1 -1
  111. package/dist/cjs/{terminal-orders-table-3b247193.js → terminal-orders-table-w4Yaf83b.js} +35 -5
  112. package/dist/cjs/terminal-quantity-selector.cjs.entry.js +6 -12
  113. package/dist/cjs/{terminal.service-ab62c344.js → terminal.service-BjSo5Cm4.js} +11 -11
  114. package/dist/cjs/terminals-list-core.cjs.entry.js +25 -31
  115. package/dist/cjs/terminals-list-params-state-Cmfy_CND.js +22 -0
  116. package/dist/cjs/{terminals-table-6710a76c.js → terminals-table-F6pkR97i.js} +6 -6
  117. package/dist/cjs/{utils-f8714daa.js → utils-D3seTk2e.js} +2 -2
  118. package/dist/cjs/utils-DmZ8Dia3.js +23987 -0
  119. package/dist/cjs/{utils-7a478c37.js → utils-l0veqT9y.js} +1 -1
  120. package/dist/cjs/webcomponents.cjs.js +7 -7
  121. package/dist/collection/actions/payment/get-payment-details.js +5 -2
  122. package/dist/collection/actions/refund/refund-actions.js +31 -0
  123. package/dist/collection/api/Api.js +32 -13
  124. package/dist/collection/api/ComponentError.js +1 -0
  125. package/dist/collection/api/Refund.js +32 -0
  126. package/dist/collection/api/TerminalOrder.js +3 -0
  127. package/dist/collection/api/index.js +1 -0
  128. package/dist/collection/api/services/analytics.service.js +1 -1
  129. package/dist/collection/api/services/business.service.js +22 -7
  130. package/dist/collection/api/services/checkout.service.js +6 -3
  131. package/dist/collection/api/services/dispute.service.js +13 -4
  132. package/dist/collection/api/services/insurance.service.js +8 -2
  133. package/dist/collection/api/services/payment.service.js +3 -3
  134. package/dist/collection/api/services/payout.service.js +3 -3
  135. package/dist/collection/api/services/provision.service.js +4 -1
  136. package/dist/collection/api/services/refund.service.js +10 -0
  137. package/dist/collection/api/services/reports.service.js +1 -1
  138. package/dist/collection/api/services/subaccounts.service.js +1 -1
  139. package/dist/collection/api/services/terminal.service.js +4 -4
  140. package/dist/collection/api/services/terminal_orders.service.js +5 -1
  141. package/dist/collection/collection-manifest.json +3 -5
  142. package/dist/collection/components/business-details/additional-questions-details/additional-questions-details.js +4 -4
  143. package/dist/collection/components/business-details/business-details-core.js +4 -3
  144. package/dist/collection/components/business-details/business-details.js +6 -8
  145. package/dist/collection/components/business-details/generic-info-details/generic-info-details.js +4 -4
  146. package/dist/collection/components/business-details/legal-address-details/legal-address-details.js +4 -4
  147. package/dist/collection/components/business-details/owner-details/owner-details.js +4 -4
  148. package/dist/collection/components/business-details/representative-details/representative-details.js +4 -4
  149. package/dist/collection/components/business-forms/business-form/additional-questions/additional-questions.js +4 -2
  150. package/dist/collection/components/business-forms/business-form/business-core-info/business-core-info.js +4 -2
  151. package/dist/collection/components/business-forms/business-form/business-form.js +20 -13
  152. package/dist/collection/components/business-forms/business-form/business-representative/business-representative.js +6 -4
  153. package/dist/collection/components/business-forms/business-form/legal-address-form/legal-address-form.js +4 -3
  154. package/dist/collection/components/business-forms/owner-form/identity-address/identity-address-form.js +11 -7
  155. package/dist/collection/components/business-forms/owner-form/owner-form-core.js +34 -22
  156. package/dist/collection/components/business-forms/owner-form/owner-form-inputs.js +10 -6
  157. package/dist/collection/components/business-forms/owner-form/owner-form.js +22 -19
  158. package/dist/collection/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step-core.js +15 -11
  159. package/dist/collection/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step.js +9 -10
  160. package/dist/collection/components/business-forms/payment-provisioning/bank-account/bank-account-document-inputs.js +11 -8
  161. package/dist/collection/components/business-forms/payment-provisioning/bank-account/bank-account-form-inputs.js +13 -10
  162. package/dist/collection/components/business-forms/payment-provisioning/bank-account/business-bank-account-form-step-core.js +23 -16
  163. package/dist/collection/components/business-forms/payment-provisioning/bank-account/business-bank-account-form-step.js +9 -12
  164. package/dist/collection/components/business-forms/payment-provisioning/bank-account/business-documents-on-file.js +6 -2
  165. package/dist/collection/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step-core.js +17 -12
  166. package/dist/collection/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step.js +9 -10
  167. package/dist/collection/components/business-forms/payment-provisioning/business-owners/business-owners-form-step-core.js +20 -14
  168. package/dist/collection/components/business-forms/payment-provisioning/business-owners/business-owners-form-step.js +9 -10
  169. package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-inputs.js +10 -6
  170. package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-step-core.js +14 -10
  171. package/dist/collection/components/business-forms/payment-provisioning/business-representative/business-representative-form-step.js +9 -10
  172. package/dist/collection/components/business-forms/payment-provisioning/form-control-monetary-provisioning.js +31 -21
  173. package/dist/collection/components/business-forms/payment-provisioning/legal-address-form/legal-address-form-step-core.js +14 -10
  174. package/dist/collection/components/business-forms/payment-provisioning/legal-address-form/legal-address-form-step.js +9 -10
  175. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-core.js +24 -16
  176. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-form-buttons.js +20 -14
  177. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning-form-steps.js +21 -12
  178. package/dist/collection/components/business-forms/payment-provisioning/payment-provisioning.js +12 -8
  179. package/dist/collection/components/business-forms/payment-provisioning/terms-and-conditions/business-terms-conditions-form-step.js +13 -13
  180. package/dist/collection/components/checkout/bank-account-form/bank-account-form.js +3 -2
  181. package/dist/collection/components/checkout/billing-form/billing-form-schema.js +21 -0
  182. package/dist/collection/components/checkout/billing-form/billing-form.js +203 -0
  183. package/dist/collection/components/checkout/card-form/card-form.js +5 -4
  184. package/dist/collection/components/checkout/checkout-core.js +88 -37
  185. package/dist/collection/components/checkout/checkout.js +70 -28
  186. package/dist/collection/components/checkout/new-payment-method.js +110 -30
  187. package/dist/collection/components/checkout/payment-method-options.js +91 -36
  188. package/dist/collection/components/checkout/saved-payment-method.js +7 -4
  189. package/dist/collection/components/checkout/sezzle-payment-method.js +19 -15
  190. package/dist/collection/components/checkouts-list/checkouts-list-core.js +17 -14
  191. package/dist/collection/components/checkouts-list/checkouts-list-filters.js +7 -5
  192. package/dist/collection/components/checkouts-list/checkouts-list.js +16 -12
  193. package/dist/collection/components/dispute-management/dispute-management-core.js +11 -8
  194. package/dist/collection/components/dispute-management/dispute-management.js +12 -9
  195. package/dist/collection/components/dispute-management/dispute-notification.js +11 -9
  196. package/dist/collection/components/dispute-management/dispute-response/additional-statement.js +10 -9
  197. package/dist/collection/components/dispute-management/dispute-response/cancellation-policy.js +10 -8
  198. package/dist/collection/components/dispute-management/dispute-response/customer-details.js +10 -8
  199. package/dist/collection/components/dispute-management/dispute-response/dispute-response-core.js +21 -14
  200. package/dist/collection/components/dispute-management/dispute-response/dispute-response.js +16 -13
  201. package/dist/collection/components/dispute-management/dispute-response/duplicate-charge.js +10 -8
  202. package/dist/collection/components/dispute-management/dispute-response/electronic-evidence.js +10 -8
  203. package/dist/collection/components/dispute-management/dispute-response/product-or-service.js +10 -8
  204. package/dist/collection/components/dispute-management/dispute-response/refund-policy.js +10 -8
  205. package/dist/collection/components/dispute-management/dispute-response/shipping-details.js +10 -8
  206. package/dist/collection/components/gross-payment-chart/gross-payment-chart-core.js +5 -4
  207. package/dist/collection/components/gross-payment-chart/gross-payment-chart.js +7 -6
  208. package/dist/collection/components/insurance/season-interruption/season-interruption-insurance-core.js +44 -30
  209. package/dist/collection/components/insurance/season-interruption/season-interruption-insurance.js +40 -32
  210. package/dist/collection/components/order-terminals/order-terminals.js +20 -16
  211. package/dist/collection/components/order-terminals/terminal-quantity-selector/terminal-quantity-selector.js +19 -13
  212. package/dist/collection/components/payment-details/payment-details-core.js +13 -12
  213. package/dist/collection/components/payment-details/payment-details.js +29 -6
  214. package/dist/collection/components/payments-list/payments-list-core.js +12 -11
  215. package/dist/collection/components/payments-list/payments-list-filters.js +17 -12
  216. package/dist/collection/components/payments-list/payments-list.js +16 -11
  217. package/dist/collection/components/payout-details/payout-details-core.js +11 -8
  218. package/dist/collection/components/payout-details/payout-details.js +11 -9
  219. package/dist/collection/components/payouts-list/payouts-list-core.js +21 -16
  220. package/dist/collection/components/payouts-list/payouts-list-filters.js +8 -6
  221. package/dist/collection/components/payouts-list/payouts-list.js +16 -13
  222. package/dist/collection/components/refund-payment/refund-loading.js +6 -0
  223. package/dist/collection/components/refund-payment/refund-payment-schema.js +26 -11
  224. package/dist/collection/components/refund-payment/refund-payment.js +157 -57
  225. package/dist/collection/components/terminal-orders-list/terminal-order-status.js +15 -0
  226. package/dist/collection/components/terminal-orders-list/terminal-orders-list-core.js +12 -11
  227. package/dist/collection/components/terminal-orders-list/terminal-orders-list-filters.js +18 -11
  228. package/dist/collection/components/terminal-orders-list/terminal-orders-list.js +16 -11
  229. package/dist/collection/components/terminal-orders-list/terminal-orders-table.js +11 -1
  230. package/dist/collection/components/terminals-list/terminals-list-core.js +17 -14
  231. package/dist/collection/components/terminals-list/terminals-list-filters.js +10 -7
  232. package/dist/collection/components/terminals-list/terminals-list.js +16 -12
  233. package/dist/collection/components/terminals-list/terminals-table.js +2 -2
  234. package/dist/collection/components/tokenize-payment-method/tokenize-payment-method.js +71 -19
  235. package/dist/collection/styles/parts.js +2 -1
  236. package/dist/collection/ui-components/custom-popper/custom-popper.js +19 -8
  237. package/dist/collection/ui-components/details/details.js +3 -4
  238. package/dist/collection/ui-components/filters/table-filters-menu.js +8 -7
  239. package/dist/collection/ui-components/form/form-control-checkbox.js +25 -17
  240. package/dist/collection/ui-components/form/form-control-date.js +32 -21
  241. package/dist/collection/ui-components/form/form-control-file-v2.js +23 -18
  242. package/dist/collection/ui-components/form/form-control-file.js +28 -21
  243. package/dist/collection/ui-components/form/form-control-monetary.js +35 -23
  244. package/dist/collection/ui-components/form/form-control-number-masked.js +28 -19
  245. package/dist/collection/ui-components/form/form-control-number.js +25 -17
  246. package/dist/collection/ui-components/form/form-control-radio.js +28 -19
  247. package/dist/collection/ui-components/form/form-control-select.js +29 -19
  248. package/dist/collection/ui-components/form/form-control-text.js +32 -21
  249. package/dist/collection/ui-components/form/form-control-textarea.js +32 -21
  250. package/dist/collection/ui-components/form/form-helpers/form-alert/form-alert.js +6 -6
  251. package/dist/collection/ui-components/form/form-helpers/form-control-help-text/form-control-help-text.js +6 -6
  252. package/dist/collection/ui-components/form/form-helpers/form-control-tooltip/form-control-tooltip.js +3 -6
  253. package/dist/collection/ui-components/form/hidden-input.js +1 -1
  254. package/dist/collection/ui-components/form/iframe-input.js +14 -12
  255. package/dist/collection/ui-components/pagination-menu/pagination-menu.js +6 -0
  256. package/dist/collection/utils/utils.js +8 -0
  257. package/dist/docs.d.ts +8 -0
  258. package/dist/docs.json +1844 -905
  259. package/dist/esm/Api-C9CDE-UM.js +72 -0
  260. package/dist/esm/{Business-0855931c.js → Business-D6XNzizo.js} +2 -2
  261. package/dist/esm/{Checkout-18d8bf94.js → Checkout-Dfpql997.js} +1 -1
  262. package/dist/esm/{ComponentError-c61dce41.js → ComponentError-SdntD1xf.js} +2 -1
  263. package/dist/esm/{Document-1907c0d4.js → Document-Ct-uNz2r.js} +1 -1
  264. package/dist/esm/{Payment-806af354.js → Payment-BADkZFaz.js} +2 -2
  265. package/dist/esm/{SubAccount-7520271c.js → Refund-t_P1yy9d.js} +25 -2
  266. package/dist/esm/_commonjsHelpers-BFTU3MAI.js +7 -0
  267. package/dist/esm/additional-questions-details_5.entry.js +5 -9
  268. package/dist/esm/{badge-1be14e8c.js → badge-C4TzL9CB.js} +3 -3
  269. package/dist/esm/bank-account-document-form-inputs_4.entry.js +25 -41
  270. package/dist/esm/bank-account-form_9.entry.js +91 -93
  271. package/dist/esm/{business-additional-questions-schema-56308a54.js → business-additional-questions-schema-W6okG5Xu.js} +2 -2
  272. package/dist/esm/business-details-core.entry.js +6 -8
  273. package/dist/esm/{business-form-options-86a13078.js → business-form-options-Bn05PRR4.js} +1 -1
  274. package/dist/esm/{business-identity-schema-24fcc4ef.js → business-identity-schema-lqdJS3MT.js} +2 -2
  275. package/dist/esm/{business.service-999196a4.js → business.service-B136meVo.js} +23 -8
  276. package/dist/esm/{button-fcee4da7.js → button-CI85Rqy5.js} +2 -2
  277. package/dist/esm/{check-pkg-version-bbd75fa0.js → check-pkg-version-Wd4E_Njt.js} +3 -3
  278. package/dist/esm/{checkout.service-e38e477f.js → checkout.service-4tnXBKGq.js} +13 -10
  279. package/dist/esm/checkouts-list-core.entry.js +25 -29
  280. package/dist/esm/{checkouts-list-params-state-7bdf00bd.js → checkouts-list-params-state-Gbxdxjoi.js} +1 -1
  281. package/dist/esm/{checkouts-table-39a031a0.js → checkouts-table-CHM4YCCZ.js} +4 -4
  282. package/dist/esm/custom-popper_4.entry.js +27 -50
  283. package/dist/esm/{dispute.service-7ba6d5a4.js → dispute.service-Bwh8pBe9.js} +20 -11
  284. package/dist/esm/{event-types-1bc52f1f.js → event-types-CooIFpFI.js} +3 -3
  285. package/dist/esm/form-alert_5.entry.js +10 -17
  286. package/dist/esm/form-control-checkbox.entry.js +9 -16
  287. package/dist/esm/form-control-date.entry.js +9 -17
  288. package/dist/esm/{form-control-error-text-176d20d8.js → form-control-error-text-3q5yVuMQ.js} +2 -2
  289. package/dist/esm/form-control-file-v2_2.entry.js +11 -28
  290. package/dist/esm/{form-control-help-text-83764e14.js → form-control-help-text-BplkZkPF.js} +2 -2
  291. package/dist/esm/form-control-help-text.entry.js +1 -3
  292. package/dist/esm/form-control-monetary-provisioning.entry.js +13 -20
  293. package/dist/esm/form-control-monetary.entry.js +13 -20
  294. package/dist/esm/form-control-number-masked_2.entry.js +12 -23
  295. package/dist/esm/form-control-number.entry.js +9 -16
  296. package/dist/esm/form-control-radio.entry.js +7 -15
  297. package/dist/esm/{get-business-b7511690.js → get-business-B3c5gg1D.js} +3 -3
  298. package/dist/esm/get-payment-details-BbZmEGge.js +40 -0
  299. package/dist/esm/{get-payout-csv-fa34f40b.js → get-payout-csv-BKq22mOI.js} +11 -11
  300. package/dist/esm/{get-subaccounts-3c6b9e84.js → get-subaccounts-58LQOtEI.js} +10 -9
  301. package/dist/esm/gross-payment-chart-core.entry.js +262 -268
  302. package/dist/esm/{header-1-215a146f.js → header-1-BX6i3__G.js} +2 -2
  303. package/dist/esm/{header-3-afd16f23.js → header-3-D0Sy-7DJ.js} +2 -2
  304. package/dist/esm/{helpers-96ea3464.js → helpers-Mu7LQT-w.js} +2 -2
  305. package/dist/esm/{iframe-input-styles-state-ff730fe5.js → iframe-input-styles-state-DyXIZw1A.js} +3 -3
  306. package/dist/esm/iframe-input.entry.js +1638 -0
  307. package/dist/esm/{index-29fcfdf5.js → index-BUM1DfV9.js} +459 -250
  308. package/dist/esm/{index-d9a73ce3.js → index-Ce_F4E0f.js} +1 -1
  309. package/dist/esm/{index-a47fdc7f.js → index-Cuk6aIda.js} +4 -5
  310. package/dist/esm/index.esm-BCNUj0Dx.js +11801 -0
  311. package/dist/esm/{input-handlers-270ac806.js → input-handlers-CX6mSvOM.js} +1 -1
  312. package/dist/esm/{insurance-state-d2df8e88.js → insurance-state-BhklYgGK.js} +3 -3
  313. package/dist/esm/justifi-additional-questions-form-step-core_6.entry.js +64 -92
  314. package/dist/esm/justifi-additional-questions-form-step_9.entry.js +36 -84
  315. package/dist/esm/justifi-additional-statement_8.entry.js +36 -52
  316. package/dist/esm/justifi-business-details.entry.js +16 -18
  317. package/dist/esm/justifi-business-form.entry.js +34 -36
  318. package/dist/esm/justifi-business-representative-form-inputs.entry.js +6 -9
  319. package/dist/esm/justifi-checkout-core.entry.js +31 -32
  320. package/dist/esm/justifi-checkout.entry.js +23 -27
  321. package/dist/esm/justifi-checkouts-list-filters.entry.js +15 -16
  322. package/dist/esm/justifi-checkouts-list.entry.js +25 -28
  323. package/dist/esm/justifi-details.entry.js +3 -4
  324. package/dist/esm/justifi-dispute-management-core.entry.js +5 -9
  325. package/dist/esm/justifi-dispute-management.entry.js +19 -21
  326. package/dist/esm/justifi-dispute-notification_3.entry.js +38 -50
  327. package/dist/esm/justifi-gross-payment-chart.entry.js +13 -14
  328. package/dist/esm/justifi-order-terminals.entry.js +27 -34
  329. package/dist/esm/justifi-owner-form_3.entry.js +29 -50
  330. package/dist/esm/justifi-payment-details.entry.js +22 -48
  331. package/dist/esm/justifi-payment-provisioning-core.entry.js +15 -21
  332. package/dist/esm/justifi-payment-provisioning.entry.js +15 -14
  333. package/dist/esm/justifi-payments-list-filters.entry.js +11 -15
  334. package/dist/esm/justifi-payments-list.entry.js +25 -27
  335. package/dist/esm/justifi-payout-details.entry.js +20 -23
  336. package/dist/esm/justifi-payouts-list-filters.entry.js +9 -10
  337. package/dist/esm/justifi-payouts-list.entry.js +26 -30
  338. package/dist/esm/justifi-refund-payment.entry.js +189 -67
  339. package/dist/esm/justifi-season-interruption-insurance-core.entry.js +10 -25
  340. package/dist/esm/justifi-season-interruption-insurance.entry.js +24 -33
  341. package/dist/esm/justifi-terminal-orders-list-filters.entry.js +19 -19
  342. package/dist/esm/justifi-terminal-orders-list.entry.js +28 -26
  343. package/dist/esm/justifi-terminals-list-filters.entry.js +17 -19
  344. package/dist/esm/justifi-terminals-list.entry.js +25 -28
  345. package/dist/esm/justifi-tokenize-payment-method.entry.js +24 -26
  346. package/dist/esm/loader.js +4 -4
  347. package/dist/esm/lodash-BqWxUrkh.js +17214 -0
  348. package/dist/esm/package-gAO-RwrF.js +7 -0
  349. package/dist/esm/pagination-menu.entry.js +3 -3
  350. package/dist/esm/{parts-fd740f54.js → parts-CB88j97I.js} +3 -2
  351. package/dist/esm/payment-details-core.entry.js +19 -20
  352. package/dist/esm/{payment-provisioning-actions-beadac34.js → payment-provisioning-actions-CZYFFdTf.js} +3 -3
  353. package/dist/esm/payment.service-Co_fPTvK.js +21 -0
  354. package/dist/esm/payments-list-core.entry.js +25 -28
  355. package/dist/esm/{payments-list-params-state-d05b24aa.js → payments-list-params-state-Gbxdxjoi.js} +1 -1
  356. package/dist/esm/{payments-status-74d22728.js → payments-status-BLhcMfnC.js} +2 -2
  357. package/dist/esm/{payments-table-8134f5e1.js → payments-table-VcaC77NC.js} +4 -4
  358. package/dist/esm/payout-details-core.entry.js +14 -16
  359. package/dist/esm/payouts-list-core.entry.js +26 -31
  360. package/dist/esm/{payouts-list-params-state-ebcee300.js → payouts-list-params-state-Gbxdxjoi.js} +1 -1
  361. package/dist/esm/{payouts-status-29d31099.js → payouts-status-B9SSljnL.js} +2 -2
  362. package/dist/esm/{payouts-table-c1ced46a.js → payouts-table-DWBaNPmV.js} +4 -4
  363. package/dist/esm/{schema-validations-5af4266a.js → schema-validations-BsbYeDDR.js} +5 -5
  364. package/dist/esm/{skeleton-ab3f676e.js → skeleton-B-oFGeeG.js} +2 -2
  365. package/dist/esm/{spinner-27479716.js → spinner-ptEcaLdc.js} +2 -2
  366. package/dist/esm/{styled-host-32228b45.js → styled-host-BHVh70Zk.js} +2 -3
  367. package/dist/esm/table-filters-menu.entry.js +4 -8
  368. package/dist/esm/terminal-orders-list-core.entry.js +24 -27
  369. package/dist/esm/{terminal-orders-list-params-state-8fec0a0b.js → terminal-orders-list-params-state-Gbxdxjoi.js} +1 -1
  370. package/dist/esm/{terminal-orders-table-93e84d25.js → terminal-orders-table-fuxIpfJ2.js} +35 -5
  371. package/dist/esm/terminal-quantity-selector.entry.js +6 -10
  372. package/dist/esm/{terminal.service-d173566d.js → terminal.service-BLOZ-ZlR.js} +11 -11
  373. package/dist/esm/terminals-list-core.entry.js +25 -29
  374. package/dist/esm/terminals-list-params-state-Gbxdxjoi.js +16 -0
  375. package/dist/esm/{terminals-table-5eb287ca.js → terminals-table-Dn71oQMb.js} +6 -6
  376. package/dist/esm/{utils-96d9c205.js → utils-B4pV3GWr.js} +2 -2
  377. package/dist/esm/utils-BWcTxbSg.js +23969 -0
  378. package/dist/esm/{utils-fd99b806.js → utils-Dccsn9BY.js} +2 -2
  379. package/dist/esm/webcomponents.js +6 -5
  380. package/dist/module/Api.js +32 -76
  381. package/dist/module/Business.js +2 -2
  382. package/dist/module/ComponentError.js +2 -1
  383. package/dist/module/Document.js +1 -1
  384. package/dist/module/{SubAccount.js → Refund.js} +24 -1
  385. package/dist/module/_commonjsHelpers.js +7 -0
  386. package/dist/module/additional-questions-details2.js +1 -2
  387. package/dist/module/additional-questions.js +2 -3
  388. package/dist/module/additional-statement.js +6 -9
  389. package/dist/module/badge.js +1 -1
  390. package/dist/module/bank-account-document-inputs.js +4 -6
  391. package/dist/module/bank-account-form-inputs2.js +1 -5
  392. package/dist/module/bank-account-form2.js +0 -1
  393. package/dist/module/billing-form.js +122 -4
  394. package/dist/module/business-additional-questions-form-step-core.js +7 -11
  395. package/dist/module/business-additional-questions-form-step.js +1 -6
  396. package/dist/module/business-additional-questions-schema.js +1 -1
  397. package/dist/module/business-address-schema.js +1 -1
  398. package/dist/module/business-bank-account-form-step-core.js +13 -18
  399. package/dist/module/business-bank-account-form-step.js +3 -9
  400. package/dist/module/business-core-info-form-step-core.js +6 -11
  401. package/dist/module/business-core-info-form-step.js +1 -6
  402. package/dist/module/business-core-info-schema.js +1 -1
  403. package/dist/module/business-core-info.js +2 -3
  404. package/dist/module/business-details-core2.js +1 -3
  405. package/dist/module/business-documents-on-file2.js +1 -1
  406. package/dist/module/business-form-options.js +1 -1
  407. package/dist/module/business-identity-schema.js +1 -1
  408. package/dist/module/business-owners-form-step-core.js +5 -11
  409. package/dist/module/business-owners-form-step.js +1 -6
  410. package/dist/module/business-representative-form-inputs.js +1 -4
  411. package/dist/module/business-representative-form-step-core.js +5 -9
  412. package/dist/module/business-representative-form-step.js +1 -6
  413. package/dist/module/business-representative.js +3 -4
  414. package/dist/module/business-terms-conditions-form-step.js +6 -12
  415. package/dist/module/business.service.js +22 -7
  416. package/dist/module/button.js +1 -1
  417. package/dist/module/cancellation-policy.js +6 -8
  418. package/dist/module/card-form2.js +2 -3
  419. package/dist/module/check-pkg-version.js +1 -1
  420. package/dist/module/checkout-core.js +57 -69
  421. package/dist/module/checkout.service.js +7 -4
  422. package/dist/module/checkouts-list-core2.js +12 -17
  423. package/dist/module/custom-popper2.js +13 -16
  424. package/dist/module/customer-details.js +6 -8
  425. package/dist/module/details.js +0 -1
  426. package/dist/module/dispute-management-core.js +4 -8
  427. package/dist/module/dispute-notification.js +3 -6
  428. package/dist/module/dispute-response-actions.js +16 -7
  429. package/dist/module/dispute-response-core.js +12 -16
  430. package/dist/module/dispute-response.js +6 -12
  431. package/dist/module/duplicate-charge.js +6 -8
  432. package/dist/module/electronic-evidence.js +5 -7
  433. package/dist/module/event-types2.js +21 -61
  434. package/dist/module/event-types3.js +61 -21
  435. package/dist/module/form-alert2.js +1 -3
  436. package/dist/module/form-control-checkbox2.js +6 -13
  437. package/dist/module/form-control-date2.js +6 -14
  438. package/dist/module/form-control-file-v22.js +2 -10
  439. package/dist/module/form-control-file2.js +5 -15
  440. package/dist/module/form-control-help-text.js +1 -1
  441. package/dist/module/form-control-help-text2.js +30 -9
  442. package/dist/module/form-control-help-text3.js +9 -32
  443. package/dist/module/form-control-monetary-provisioning2.js +8 -15
  444. package/dist/module/form-control-monetary2.js +9 -17
  445. package/dist/module/form-control-number-masked2.js +4 -12
  446. package/dist/module/form-control-number.js +6 -13
  447. package/dist/module/form-control-radio2.js +6 -14
  448. package/dist/module/form-control-select2.js +5 -13
  449. package/dist/module/form-control-text2.js +5 -14
  450. package/dist/module/form-control-textarea2.js +7 -16
  451. package/dist/module/form-control-tooltip2.js +0 -3
  452. package/dist/module/form.js +9773 -903
  453. package/dist/module/generic-info-details2.js +0 -1
  454. package/dist/module/get-business.js +2 -2
  455. package/dist/module/get-payment-details.js +40 -0
  456. package/dist/module/get-payout-csv.js +6 -6
  457. package/dist/module/get-subaccounts.js +5 -4
  458. package/dist/module/gross-payment-chart-core2.js +257 -264
  459. package/dist/module/helpers.js +1 -1
  460. package/dist/module/hidden-input2.js +3 -3
  461. package/dist/module/identity-address-form.js +2 -5
  462. package/dist/module/iframe-input-styles-state.js +2 -2
  463. package/dist/module/iframe-input2.js +1481 -1478
  464. package/dist/module/index2.js +3 -4
  465. package/dist/module/index3.js +1 -1
  466. package/dist/module/{billing-form.d.ts → justifi-billing-form.d.ts} +4 -4
  467. package/dist/module/justifi-billing-form.js +6 -0
  468. package/dist/module/justifi-business-details.js +1 -5
  469. package/dist/module/justifi-business-form.js +7 -10
  470. package/dist/module/justifi-checkout.js +47 -62
  471. package/dist/module/justifi-checkouts-list-filters.js +4 -5
  472. package/dist/module/justifi-checkouts-list.js +8 -11
  473. package/dist/module/justifi-dispute-management.js +6 -9
  474. package/dist/module/justifi-gross-payment-chart.js +4 -7
  475. package/dist/module/justifi-order-terminals.js +7 -15
  476. package/dist/module/justifi-payment-details.js +6 -38
  477. package/dist/module/justifi-payment-provisioning.js +5 -6
  478. package/dist/module/justifi-payments-list-filters.js +6 -11
  479. package/dist/module/justifi-payments-list.js +8 -10
  480. package/dist/module/justifi-payout-details.js +6 -9
  481. package/dist/module/justifi-payouts-list-filters.js +4 -6
  482. package/dist/module/justifi-payouts-list.js +8 -12
  483. package/dist/module/justifi-refund-payment.js +184 -61
  484. package/dist/module/justifi-season-interruption-insurance.js +13 -23
  485. package/dist/module/justifi-terminal-orders-list-filters.js +8 -9
  486. package/dist/module/justifi-terminal-orders-list.js +13 -11
  487. package/dist/module/justifi-terminals-list-filters.js +6 -8
  488. package/dist/module/justifi-terminals-list.js +8 -11
  489. package/dist/module/justifi-tokenize-payment-method.js +46 -58
  490. package/dist/module/legal-address-details2.js +1 -2
  491. package/dist/module/legal-address-form-step-core.js +6 -10
  492. package/dist/module/legal-address-form-step.js +1 -6
  493. package/dist/module/legal-address-form.js +1 -3
  494. package/dist/module/lodash.js +17201 -17191
  495. package/dist/module/new-payment-method.js +43 -55
  496. package/dist/module/owner-details2.js +0 -1
  497. package/dist/module/owner-form-core2.js +8 -18
  498. package/dist/module/owner-form-inputs2.js +1 -4
  499. package/dist/module/owner-form.js +1 -11
  500. package/dist/module/package.js +3 -77
  501. package/dist/module/pagination-menu2.js +1 -1
  502. package/dist/module/parts.js +3 -2
  503. package/dist/module/payment-details-core2.js +11 -13
  504. package/dist/module/payment-method-options.js +43 -61
  505. package/dist/module/payment-provisioning-actions.js +2 -2
  506. package/dist/module/payment-provisioning-core.js +8 -14
  507. package/dist/module/payment-provisioning-form-buttons.js +2 -8
  508. package/dist/module/payment-provisioning-form-steps.js +2 -7
  509. package/dist/module/payment.service.js +4 -4
  510. package/dist/module/payments-list-core2.js +10 -14
  511. package/dist/module/payout-details-core2.js +6 -9
  512. package/dist/module/payouts-list-core2.js +14 -20
  513. package/dist/module/product-or-service.js +5 -7
  514. package/dist/module/refund-policy.js +6 -8
  515. package/dist/module/representative-details2.js +0 -1
  516. package/dist/module/saved-payment-method.js +4 -6
  517. package/dist/module/schema-validations.js +2 -2
  518. package/dist/module/season-interruption-insurance-core.js +4 -20
  519. package/dist/module/sezzle-payment-method.js +3 -12
  520. package/dist/module/shipping-details.js +6 -8
  521. package/dist/module/spinner.js +1 -1
  522. package/dist/module/styled-host.js +1 -2
  523. package/dist/module/table-filters-menu2.js +3 -7
  524. package/dist/module/terminal-orders-list-core2.js +35 -15
  525. package/dist/module/terminal-quantity-selector2.js +4 -8
  526. package/dist/module/terminal.service.js +5 -5
  527. package/dist/module/terminals-list-core2.js +14 -19
  528. package/dist/module/utils.js +1 -1
  529. package/dist/module/utils2.js +23787 -3819
  530. package/dist/module/utils4.js +2 -2
  531. package/dist/types/actions/payment/get-payment-details.d.ts +4 -2
  532. package/dist/types/actions/refund/refund-actions.d.ts +12 -0
  533. package/dist/types/api/Api.d.ts +30 -5
  534. package/dist/types/api/ComponentError.d.ts +2 -1
  535. package/dist/types/api/Payment.d.ts +1 -11
  536. package/dist/types/api/Refund.d.ts +45 -0
  537. package/dist/types/api/TerminalOrder.d.ts +4 -1
  538. package/dist/types/api/index.d.ts +1 -0
  539. package/dist/types/api/services/payment.service.d.ts +2 -2
  540. package/dist/types/api/services/refund.service.d.ts +7 -0
  541. package/dist/types/components/business-forms/payment-provisioning/form-control-monetary-provisioning.d.ts +1 -1
  542. package/dist/types/components/business-forms/schemas/business-form-schema.d.ts +3 -3
  543. package/dist/types/components/business-forms/schemas/business-identity-schema.d.ts +1 -1
  544. package/dist/types/components/checkout/{billing-forms → billing-form}/billing-form-schema.d.ts +1 -11
  545. package/dist/types/components/checkout/{billing-forms/billing-form → billing-form}/billing-form.d.ts +8 -6
  546. package/dist/types/components/checkout/checkout-core.d.ts +6 -2
  547. package/dist/types/components/checkout/checkout.d.ts +6 -2
  548. package/dist/types/components/checkout/new-payment-method.d.ts +7 -3
  549. package/dist/types/components/checkout/payment-method-options.d.ts +6 -2
  550. package/dist/types/components/order-terminals/order-terminals.d.ts +0 -1
  551. package/dist/types/components/payment-details/payment-details.d.ts +1 -0
  552. package/dist/types/components/refund-payment/refund-loading.d.ts +1 -0
  553. package/dist/types/components/refund-payment/refund-payment-schema.d.ts +6 -6
  554. package/dist/types/components/refund-payment/refund-payment.d.ts +18 -12
  555. package/dist/types/components/terminal-orders-list/terminal-orders-list-filters.d.ts +1 -1
  556. package/dist/types/components/terminals-list/terminals-table.d.ts +2 -2
  557. package/dist/types/components/tokenize-payment-method/tokenize-payment-method.d.ts +4 -0
  558. package/dist/types/components.d.ts +45 -74
  559. package/dist/types/stencil-public-runtime.d.ts +9 -0
  560. package/dist/types/styles/parts.d.ts +6 -5
  561. package/dist/types/ui-components/form/form-control-monetary.d.ts +1 -1
  562. package/dist/types/utils/utils.d.ts +1 -0
  563. package/dist/webcomponents/{p-701a13ca.js → p-01wziNa9.js} +1 -1
  564. package/dist/webcomponents/p-063dd981.entry.js +1 -0
  565. package/dist/webcomponents/p-08d5b491.entry.js +1 -0
  566. package/dist/webcomponents/p-0czqizJW.js +1 -0
  567. package/dist/webcomponents/p-1049c0c5.entry.js +1 -0
  568. package/dist/webcomponents/p-1ydcg9ti.js +1 -0
  569. package/dist/webcomponents/p-2c2f6743.entry.js +1 -0
  570. package/dist/webcomponents/p-2d80f427.entry.js +1 -0
  571. package/dist/webcomponents/p-2f6c0a07.entry.js +1 -0
  572. package/dist/webcomponents/p-2fe9576b.entry.js +1 -0
  573. package/dist/webcomponents/p-307a0db6.entry.js +1 -0
  574. package/dist/webcomponents/p-3147bfe2.entry.js +1 -0
  575. package/dist/webcomponents/p-332ce001.entry.js +1 -0
  576. package/dist/webcomponents/p-34cfafed.entry.js +1 -0
  577. package/dist/webcomponents/p-3995c8b8.entry.js +1 -0
  578. package/dist/webcomponents/p-3e084a0e.entry.js +1 -0
  579. package/dist/webcomponents/p-43c1c278.entry.js +1 -0
  580. package/dist/webcomponents/p-456f8c0a.entry.js +1 -0
  581. package/dist/webcomponents/p-4addd069.entry.js +1 -0
  582. package/dist/webcomponents/p-4ee6482d.entry.js +1 -0
  583. package/dist/webcomponents/p-507f7a31.entry.js +1 -0
  584. package/dist/webcomponents/p-50aa4e4d.entry.js +1 -0
  585. package/dist/webcomponents/p-5a07a84c.entry.js +1 -0
  586. package/dist/webcomponents/p-5dc3a795.entry.js +1 -0
  587. package/dist/webcomponents/p-62bdcca1.entry.js +1 -0
  588. package/dist/webcomponents/p-65345bd4.entry.js +1 -0
  589. package/dist/webcomponents/p-6a54d69b.entry.js +1 -0
  590. package/dist/webcomponents/p-6c4927e7.entry.js +1 -0
  591. package/dist/webcomponents/p-6d2a48f5.entry.js +1 -0
  592. package/dist/webcomponents/p-7414b942.entry.js +1 -0
  593. package/dist/webcomponents/p-7ddd7122.entry.js +20 -0
  594. package/dist/webcomponents/p-80dca817.entry.js +1 -0
  595. package/dist/webcomponents/p-815937bb.entry.js +1 -0
  596. package/dist/webcomponents/p-86fdc0a1.entry.js +1 -0
  597. package/dist/webcomponents/p-98111d03.entry.js +1 -0
  598. package/dist/webcomponents/p-9a9bb294.entry.js +1 -0
  599. package/dist/webcomponents/p-9bbfde16.entry.js +1 -0
  600. package/dist/webcomponents/p-B7ErpLYA.js +1 -0
  601. package/dist/webcomponents/p-BBsCnePk.js +1 -0
  602. package/dist/webcomponents/p-BFTU3MAI.js +1 -0
  603. package/dist/webcomponents/p-BHHWVg32.js +1 -0
  604. package/dist/webcomponents/p-BHbsXXRt.js +1 -0
  605. package/dist/webcomponents/p-BM61p7vG.js +1 -0
  606. package/dist/webcomponents/p-BODr6HXb.js +1 -0
  607. package/dist/webcomponents/p-BUM1DfV9.js +2 -0
  608. package/dist/webcomponents/p-BVwkHwTc.js +1 -0
  609. package/dist/webcomponents/p-BWFriesi.js +1 -0
  610. package/dist/webcomponents/p-Bde7dY9t.js +9 -0
  611. package/dist/webcomponents/{p-1366a019.js → p-BjB_yKBJ.js} +1 -1
  612. package/dist/webcomponents/p-Bo92MHrs.js +1 -0
  613. package/dist/webcomponents/p-BoPxMyJA.js +1 -0
  614. package/dist/webcomponents/{p-5d1d2fd7.js → p-BrvbVMVq.js} +1 -1
  615. package/dist/webcomponents/{p-a5579f53.js → p-BuYnqWwT.js} +1 -1
  616. package/dist/webcomponents/p-BxPlB-C5.js +1 -0
  617. package/dist/webcomponents/{p-3f5e6602.js → p-Bxs6fi7a.js} +1 -1
  618. package/dist/webcomponents/{p-bfe9748b.js → p-C3nDCvFQ.js} +1 -1
  619. package/dist/webcomponents/{p-87f8c596.js → p-C5RuuShs.js} +1 -1
  620. package/dist/webcomponents/p-CB88j97I.js +1 -0
  621. package/dist/webcomponents/p-CGz3XHQc.js +1 -0
  622. package/dist/webcomponents/p-CLBRsaLx.js +1 -0
  623. package/dist/webcomponents/{p-4cc3c7f9.js → p-CTBH4Lj9.js} +1 -1
  624. package/dist/webcomponents/p-CYsU0lEI.js +1 -0
  625. package/dist/webcomponents/p-CjunQqer.js +1 -0
  626. package/dist/webcomponents/{p-12074378.js → p-CnyMKcfC.js} +1 -1
  627. package/dist/webcomponents/p-CpTwq2jw.js +1 -0
  628. package/dist/webcomponents/{p-61f0a2ce.js → p-Ct-uNz2r.js} +1 -1
  629. package/dist/webcomponents/p-CwHcfOV7.js +1 -0
  630. package/dist/webcomponents/p-Cy4aIACq.js +1 -0
  631. package/dist/webcomponents/p-D7s2671S.js +1 -0
  632. package/dist/webcomponents/{p-ca6cdfe6.js → p-D89x2FYg.js} +1 -1
  633. package/dist/webcomponents/p-D9t-X0IY.js +1 -0
  634. package/dist/webcomponents/p-DLpKiPxJ.js +1 -0
  635. package/dist/webcomponents/p-DVnVdicA.js +1 -0
  636. package/dist/webcomponents/p-DhEfW-kS.js +1 -0
  637. package/dist/webcomponents/p-DhQ2XlhY.js +1 -0
  638. package/dist/webcomponents/p-Dna7whFY.js +1 -0
  639. package/dist/webcomponents/p-DoH48u6u.js +1 -0
  640. package/dist/webcomponents/p-Dt-vy9Le.js +1 -0
  641. package/dist/webcomponents/p-DzPbgN8M.js +1 -0
  642. package/dist/webcomponents/{p-c9b78275.js → p-IA90llLO.js} +1 -1
  643. package/dist/webcomponents/p-JcczGkik.js +1 -0
  644. package/dist/webcomponents/p-QYQ4VLoz.js +1 -0
  645. package/dist/webcomponents/{p-9dd8685c.js → p-SdntD1xf.js} +1 -1
  646. package/dist/webcomponents/p-ZUQEru6m.js +1 -0
  647. package/dist/webcomponents/p-a22974fd.entry.js +1 -0
  648. package/dist/webcomponents/p-a2bf5919.entry.js +1 -0
  649. package/dist/webcomponents/p-a9eff0f2.entry.js +1 -0
  650. package/dist/webcomponents/p-ab99e4c6.entry.js +1 -0
  651. package/dist/webcomponents/p-b7053613.entry.js +1 -0
  652. package/dist/webcomponents/p-bb8f7062.entry.js +1 -0
  653. package/dist/webcomponents/p-be04a09c.entry.js +1 -0
  654. package/dist/webcomponents/p-bplwtwD3.js +1 -0
  655. package/dist/webcomponents/p-c38c742e.entry.js +1 -0
  656. package/dist/webcomponents/p-c558725e.entry.js +1 -0
  657. package/dist/webcomponents/p-c6534f5f.entry.js +1 -0
  658. package/dist/webcomponents/p-c6cf707c.entry.js +1 -0
  659. package/dist/webcomponents/p-c70dcec1.entry.js +1 -0
  660. package/dist/webcomponents/p-c8d608a1.entry.js +1 -0
  661. package/dist/webcomponents/p-ce20d709.entry.js +1 -0
  662. package/dist/webcomponents/p-cf8f69de.entry.js +1 -0
  663. package/dist/webcomponents/p-d5675bf5.entry.js +1 -0
  664. package/dist/webcomponents/p-def42fc7.entry.js +1 -0
  665. package/dist/webcomponents/p-dfcf19f2.entry.js +1 -0
  666. package/dist/webcomponents/p-e0896deb.entry.js +1 -0
  667. package/dist/webcomponents/p-e3962860.entry.js +1 -0
  668. package/dist/webcomponents/p-e3cd72ad.entry.js +1 -0
  669. package/dist/webcomponents/p-e52d5ead.entry.js +1 -0
  670. package/dist/webcomponents/p-eYaGyUvS.js +1 -0
  671. package/dist/webcomponents/p-eb31e5c7.entry.js +1 -0
  672. package/dist/webcomponents/p-eb677eb2.entry.js +1 -0
  673. package/dist/webcomponents/p-f0301d11.entry.js +1 -0
  674. package/dist/webcomponents/p-f51e4213.entry.js +1 -0
  675. package/dist/webcomponents/p-gAO-RwrF.js +1 -0
  676. package/dist/webcomponents/p-hkXaxw9l.js +1 -0
  677. package/dist/webcomponents/p-p7aAf5_m.js +1 -0
  678. package/dist/webcomponents/p-sXe3gn-5.js +1 -0
  679. package/dist/webcomponents/p-y-Ys7Rd-.js +1 -0
  680. package/dist/webcomponents/p-z1GJDdMW.js +1 -0
  681. package/dist/webcomponents/webcomponents.esm.js +1 -1
  682. package/package.json +6 -7
  683. package/dist/cjs/Api-83d93333.js +0 -118
  684. package/dist/cjs/billing-form_3.cjs.entry.js +0 -1733
  685. package/dist/cjs/index.esm-544c08fd.js +0 -2937
  686. package/dist/cjs/lodash-dbf6a6a4.js +0 -17206
  687. package/dist/cjs/package-99f9fc82.js +0 -83
  688. package/dist/cjs/payment.service-537e049d.js +0 -23
  689. package/dist/cjs/terminals-list-params-state-236f06f6.js +0 -22
  690. package/dist/cjs/utils-4120664c.js +0 -4018
  691. package/dist/collection/components/checkout/billing-forms/billing-form/billing-form.js +0 -137
  692. package/dist/collection/components/checkout/billing-forms/billing-form-schema.js +0 -26
  693. package/dist/collection/components/checkout/billing-forms/billing-form-wrapper.js +0 -183
  694. package/dist/collection/components/checkout/billing-forms/postal-form/postal-form.js +0 -136
  695. package/dist/esm/Api-52242eb0.js +0 -116
  696. package/dist/esm/billing-form_3.entry.js +0 -1727
  697. package/dist/esm/index.esm-feedf26f.js +0 -2931
  698. package/dist/esm/lodash-faeb5a52.js +0 -17204
  699. package/dist/esm/package-01997353.js +0 -81
  700. package/dist/esm/payment.service-af5bd8be.js +0 -21
  701. package/dist/esm/terminals-list-params-state-e4b2ec23.js +0 -16
  702. package/dist/esm/utils-ec50661e.js +0 -4001
  703. package/dist/loader/package.json +0 -11
  704. package/dist/module/billing-form-schema.js +0 -16
  705. package/dist/module/billing-form-wrapper.js +0 -114
  706. package/dist/module/billing-form2.js +0 -90
  707. package/dist/module/justifi-billing-form-wrapper.d.ts +0 -11
  708. package/dist/module/justifi-billing-form-wrapper.js +0 -6
  709. package/dist/module/postal-form.d.ts +0 -11
  710. package/dist/module/postal-form.js +0 -6
  711. package/dist/module/postal-form2.js +0 -83
  712. package/dist/types/components/checkout/billing-forms/billing-form-wrapper.d.ts +0 -19
  713. package/dist/types/components/checkout/billing-forms/postal-form/postal-form.d.ts +0 -20
  714. package/dist/webcomponents/p-01033194.js +0 -1
  715. package/dist/webcomponents/p-07fbeff3.entry.js +0 -1
  716. package/dist/webcomponents/p-092515e0.js +0 -1
  717. package/dist/webcomponents/p-0b61d4d3.entry.js +0 -1
  718. package/dist/webcomponents/p-0c7ec110.entry.js +0 -1
  719. package/dist/webcomponents/p-0f0020e1.entry.js +0 -1
  720. package/dist/webcomponents/p-0fa216eb.entry.js +0 -1
  721. package/dist/webcomponents/p-0fc1d3bb.entry.js +0 -1
  722. package/dist/webcomponents/p-1134e1d3.entry.js +0 -1
  723. package/dist/webcomponents/p-13717638.entry.js +0 -1
  724. package/dist/webcomponents/p-142bfae3.js +0 -1
  725. package/dist/webcomponents/p-1c38ec65.entry.js +0 -1
  726. package/dist/webcomponents/p-1ce63001.entry.js +0 -1
  727. package/dist/webcomponents/p-1ff8810b.js +0 -1
  728. package/dist/webcomponents/p-2123c150.js +0 -1
  729. package/dist/webcomponents/p-23cd76af.entry.js +0 -1
  730. package/dist/webcomponents/p-25b82529.entry.js +0 -1
  731. package/dist/webcomponents/p-27546fa9.entry.js +0 -1
  732. package/dist/webcomponents/p-275c3dc9.js +0 -1
  733. package/dist/webcomponents/p-2783e363.js +0 -2
  734. package/dist/webcomponents/p-290fa30d.entry.js +0 -1
  735. package/dist/webcomponents/p-2a9d7f6b.js +0 -1
  736. package/dist/webcomponents/p-2b8aaa7d.entry.js +0 -1
  737. package/dist/webcomponents/p-3188f72a.js +0 -1
  738. package/dist/webcomponents/p-31dcaeaf.entry.js +0 -1
  739. package/dist/webcomponents/p-373a19fe.entry.js +0 -1
  740. package/dist/webcomponents/p-375657fe.entry.js +0 -1
  741. package/dist/webcomponents/p-3cc7527a.entry.js +0 -1
  742. package/dist/webcomponents/p-3cf317d3.entry.js +0 -1
  743. package/dist/webcomponents/p-4598482c.entry.js +0 -1
  744. package/dist/webcomponents/p-536497fe.entry.js +0 -1
  745. package/dist/webcomponents/p-536fb8e2.js +0 -1
  746. package/dist/webcomponents/p-537bce77.js +0 -1
  747. package/dist/webcomponents/p-54556fc6.js +0 -1
  748. package/dist/webcomponents/p-56c7fc8d.js +0 -1
  749. package/dist/webcomponents/p-58ee6ce9.js +0 -1
  750. package/dist/webcomponents/p-5a9d7ca0.entry.js +0 -1
  751. package/dist/webcomponents/p-5b76dbe1.entry.js +0 -1
  752. package/dist/webcomponents/p-5f6b4bc9.js +0 -1
  753. package/dist/webcomponents/p-645db2cb.entry.js +0 -1
  754. package/dist/webcomponents/p-65cb72e4.entry.js +0 -1
  755. package/dist/webcomponents/p-673c1bca.js +0 -1
  756. package/dist/webcomponents/p-6a5eab1f.entry.js +0 -1
  757. package/dist/webcomponents/p-753d983c.entry.js +0 -1
  758. package/dist/webcomponents/p-76549a24.js +0 -1
  759. package/dist/webcomponents/p-7b793901.entry.js +0 -1
  760. package/dist/webcomponents/p-7c333590.entry.js +0 -1
  761. package/dist/webcomponents/p-7d85af5c.js +0 -1
  762. package/dist/webcomponents/p-81a6c3e2.entry.js +0 -1
  763. package/dist/webcomponents/p-86605101.js +0 -1
  764. package/dist/webcomponents/p-87a4fb5b.js +0 -1
  765. package/dist/webcomponents/p-88a37837.js +0 -1
  766. package/dist/webcomponents/p-8a6a06e6.entry.js +0 -1
  767. package/dist/webcomponents/p-8d4a0192.entry.js +0 -1
  768. package/dist/webcomponents/p-927cb6df.js +0 -1
  769. package/dist/webcomponents/p-953e9dba.js +0 -1
  770. package/dist/webcomponents/p-96c23cda.entry.js +0 -1
  771. package/dist/webcomponents/p-9a9732e1.js +0 -1
  772. package/dist/webcomponents/p-9fecad5a.js +0 -1
  773. package/dist/webcomponents/p-a07e021f.entry.js +0 -1
  774. package/dist/webcomponents/p-a3cced75.entry.js +0 -1
  775. package/dist/webcomponents/p-a5f5cc2e.entry.js +0 -1
  776. package/dist/webcomponents/p-a6976c9c.entry.js +0 -1
  777. package/dist/webcomponents/p-a8c69f51.entry.js +0 -1
  778. package/dist/webcomponents/p-ab3a8004.entry.js +0 -1
  779. package/dist/webcomponents/p-ab45511e.js +0 -1
  780. package/dist/webcomponents/p-adecb91a.entry.js +0 -1
  781. package/dist/webcomponents/p-ae7edce5.js +0 -1
  782. package/dist/webcomponents/p-ae891abb.entry.js +0 -1
  783. package/dist/webcomponents/p-af3315b5.entry.js +0 -1
  784. package/dist/webcomponents/p-b082f07a.entry.js +0 -1
  785. package/dist/webcomponents/p-b218af87.entry.js +0 -1
  786. package/dist/webcomponents/p-b84ee6d8.js +0 -1
  787. package/dist/webcomponents/p-b979fcb0.entry.js +0 -1
  788. package/dist/webcomponents/p-bb4b3f79.entry.js +0 -1
  789. package/dist/webcomponents/p-beec0b60.js +0 -1
  790. package/dist/webcomponents/p-bf12999f.js +0 -1
  791. package/dist/webcomponents/p-bf195b35.js +0 -1
  792. package/dist/webcomponents/p-bfc2d88a.js +0 -1
  793. package/dist/webcomponents/p-c6be72b0.js +0 -10
  794. package/dist/webcomponents/p-c8b78136.js +0 -1
  795. package/dist/webcomponents/p-caa29469.entry.js +0 -1
  796. package/dist/webcomponents/p-cbad44b7.js +0 -1
  797. package/dist/webcomponents/p-cc2f75a3.entry.js +0 -1
  798. package/dist/webcomponents/p-ccb9ee53.js +0 -1
  799. package/dist/webcomponents/p-cd93c62b.entry.js +0 -19
  800. package/dist/webcomponents/p-d757fcf5.js +0 -1
  801. package/dist/webcomponents/p-dbc1a95b.js +0 -1
  802. package/dist/webcomponents/p-dd2938d3.entry.js +0 -1
  803. package/dist/webcomponents/p-dec18cc4.js +0 -1
  804. package/dist/webcomponents/p-e3855f51.entry.js +0 -1
  805. package/dist/webcomponents/p-e73be1b9.entry.js +0 -1
  806. package/dist/webcomponents/p-e817d131.entry.js +0 -1
  807. package/dist/webcomponents/p-e9867f8b.entry.js +0 -1
  808. package/dist/webcomponents/p-f20466f7.entry.js +0 -1
  809. package/dist/webcomponents/p-f20b6ce1.js +0 -1
  810. package/dist/webcomponents/p-f4739d31.js +0 -1
  811. package/dist/webcomponents/p-f4aeb100.js +0 -1
  812. package/dist/webcomponents/p-f8fccf44.js +0 -1
  813. package/dist/webcomponents/p-f930504f.entry.js +0 -1
  814. package/dist/webcomponents/p-faa35b47.entry.js +0 -1
  815. package/dist/webcomponents/p-fb2db8da.entry.js +0 -1
  816. package/dist/webcomponents/p-fca89e9b.entry.js +0 -1
  817. /package/dist/cjs/{Dispute-eb6bad54.js → Dispute-CruQTF6_.js} +0 -0
  818. /package/dist/cjs/{Document-0b828345.js → Document-rXGBUaOh.js} +0 -0
  819. /package/dist/cjs/{Pagination-0da8f095.js → Pagination-Dediz133.js} +0 -0
  820. /package/dist/cjs/{app-globals-3a1e7e63.js → app-globals-V2Kpy_OQ.js} +0 -0
  821. /package/dist/cjs/{event-types-8edaabbb.js → event-types-BWQT2lwu.js} +0 -0
  822. /package/dist/cjs/{event-types-180a85a9.js → event-types-DNOUef41.js} +0 -0
  823. /package/dist/cjs/{form-input-masks-0879c139.js → form-input-masks-DgXd0f4V.js} +0 -0
  824. /package/dist/cjs/{state-options-4fbcb48a.js → state-options-CIT9xdTz.js} +0 -0
  825. /package/dist/cjs/{utils-bc03ca40.js → utils-DAyWinG2.js} +0 -0
  826. /package/dist/esm/{Dispute-5fd28ec9.js → Dispute-7MWRbTXI.js} +0 -0
  827. /package/dist/esm/{Pagination-afc8f96d.js → Pagination-CLHwhyvu.js} +0 -0
  828. /package/dist/esm/{app-globals-0f993ce5.js → app-globals-DQuL1Twl.js} +0 -0
  829. /package/dist/esm/{event-types-07cdb9a0.js → event-types-Bg2SZArf.js} +0 -0
  830. /package/dist/esm/{event-types-5c87de02.js → event-types-XYgDHrVL.js} +0 -0
  831. /package/dist/esm/{form-input-masks-0e18300f.js → form-input-masks-B-iV5cYd.js} +0 -0
  832. /package/dist/esm/{state-options-a356fb11.js → state-options-BX8GieXu.js} +0 -0
  833. /package/dist/esm/{utils-20cdf321.js → utils-BnjCmwMr.js} +0 -0
  834. /package/dist/webcomponents/{p-abdbcd8e.js → p-7MWRbTXI.js} +0 -0
  835. /package/dist/webcomponents/{p-525db3e8.js → p-B-iV5cYd.js} +0 -0
  836. /package/dist/webcomponents/{p-6078a370.js → p-BX8GieXu.js} +0 -0
  837. /package/dist/webcomponents/{p-667ebd79.js → p-Bg2SZArf.js} +0 -0
  838. /package/dist/webcomponents/{p-e3c22aa9.js → p-BnjCmwMr.js} +0 -0
  839. /package/dist/webcomponents/{p-56f6ce4c.js → p-CLHwhyvu.js} +0 -0
  840. /package/dist/webcomponents/{p-1ad5995e.js → p-Ce_F4E0f.js} +0 -0
  841. /package/dist/webcomponents/{p-e1255160.js → p-DQuL1Twl.js} +0 -0
  842. /package/dist/webcomponents/{p-73f9be7c.js → p-XYgDHrVL.js} +0 -0
@@ -1,4001 +0,0 @@
1
- function _typeof$1(o) {
2
- "@babel/helpers - typeof";
3
-
4
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5
- return typeof o;
6
- } : function (o) {
7
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
- }, _typeof$1(o);
9
- }
10
-
11
- function toInteger(dirtyNumber) {
12
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
13
- return NaN;
14
- }
15
- var number = Number(dirtyNumber);
16
- if (isNaN(number)) {
17
- return number;
18
- }
19
- return number < 0 ? Math.ceil(number) : Math.floor(number);
20
- }
21
-
22
- function requiredArgs(required, args) {
23
- if (args.length < required) {
24
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
25
- }
26
- }
27
-
28
- /**
29
- * @name toDate
30
- * @category Common Helpers
31
- * @summary Convert the given argument to an instance of Date.
32
- *
33
- * @description
34
- * Convert the given argument to an instance of Date.
35
- *
36
- * If the argument is an instance of Date, the function returns its clone.
37
- *
38
- * If the argument is a number, it is treated as a timestamp.
39
- *
40
- * If the argument is none of the above, the function returns Invalid Date.
41
- *
42
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
43
- *
44
- * @param {Date|Number} argument - the value to convert
45
- * @returns {Date} the parsed date in the local time zone
46
- * @throws {TypeError} 1 argument required
47
- *
48
- * @example
49
- * // Clone the date:
50
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
51
- * //=> Tue Feb 11 2014 11:30:30
52
- *
53
- * @example
54
- * // Convert the timestamp to date:
55
- * const result = toDate(1392098430000)
56
- * //=> Tue Feb 11 2014 11:30:30
57
- */
58
- function toDate(argument) {
59
- requiredArgs(1, arguments);
60
- var argStr = Object.prototype.toString.call(argument);
61
-
62
- // Clone the date
63
- if (argument instanceof Date || _typeof$1(argument) === 'object' && argStr === '[object Date]') {
64
- // Prevent the date to lose the milliseconds when passed to new Date() in IE10
65
- return new Date(argument.getTime());
66
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
67
- return new Date(argument);
68
- } else {
69
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
70
- // eslint-disable-next-line no-console
71
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
72
- // eslint-disable-next-line no-console
73
- console.warn(new Error().stack);
74
- }
75
- return new Date(NaN);
76
- }
77
- }
78
-
79
- /**
80
- * @name addMilliseconds
81
- * @category Millisecond Helpers
82
- * @summary Add the specified number of milliseconds to the given date.
83
- *
84
- * @description
85
- * Add the specified number of milliseconds to the given date.
86
- *
87
- * @param {Date|Number} date - the date to be changed
88
- * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
89
- * @returns {Date} the new date with the milliseconds added
90
- * @throws {TypeError} 2 arguments required
91
- *
92
- * @example
93
- * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
94
- * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
95
- * //=> Thu Jul 10 2014 12:45:30.750
96
- */
97
- function addMilliseconds(dirtyDate, dirtyAmount) {
98
- requiredArgs(2, arguments);
99
- var timestamp = toDate(dirtyDate).getTime();
100
- var amount = toInteger(dirtyAmount);
101
- return new Date(timestamp + amount);
102
- }
103
-
104
- var defaultOptions = {};
105
- function getDefaultOptions() {
106
- return defaultOptions;
107
- }
108
-
109
- /**
110
- * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
111
- * They usually appear for dates that denote time before the timezones were introduced
112
- * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
113
- * and GMT+01:00:00 after that date)
114
- *
115
- * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
116
- * which would lead to incorrect calculations.
117
- *
118
- * This function returns the timezone offset in milliseconds that takes seconds in account.
119
- */
120
- function getTimezoneOffsetInMilliseconds(date) {
121
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
122
- utcDate.setUTCFullYear(date.getFullYear());
123
- return date.getTime() - utcDate.getTime();
124
- }
125
-
126
- /**
127
- * @name isDate
128
- * @category Common Helpers
129
- * @summary Is the given value a date?
130
- *
131
- * @description
132
- * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
133
- *
134
- * @param {*} value - the value to check
135
- * @returns {boolean} true if the given value is a date
136
- * @throws {TypeError} 1 arguments required
137
- *
138
- * @example
139
- * // For a valid date:
140
- * const result = isDate(new Date())
141
- * //=> true
142
- *
143
- * @example
144
- * // For an invalid date:
145
- * const result = isDate(new Date(NaN))
146
- * //=> true
147
- *
148
- * @example
149
- * // For some value:
150
- * const result = isDate('2014-02-31')
151
- * //=> false
152
- *
153
- * @example
154
- * // For an object:
155
- * const result = isDate({})
156
- * //=> false
157
- */
158
- function isDate(value) {
159
- requiredArgs(1, arguments);
160
- return value instanceof Date || _typeof$1(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
161
- }
162
-
163
- /**
164
- * @name isValid
165
- * @category Common Helpers
166
- * @summary Is the given date valid?
167
- *
168
- * @description
169
- * Returns false if argument is Invalid Date and true otherwise.
170
- * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
171
- * Invalid Date is a Date, whose time value is NaN.
172
- *
173
- * Time value of Date: http://es5.github.io/#x15.9.1.1
174
- *
175
- * @param {*} date - the date to check
176
- * @returns {Boolean} the date is valid
177
- * @throws {TypeError} 1 argument required
178
- *
179
- * @example
180
- * // For the valid date:
181
- * const result = isValid(new Date(2014, 1, 31))
182
- * //=> true
183
- *
184
- * @example
185
- * // For the value, convertable into a date:
186
- * const result = isValid(1393804800000)
187
- * //=> true
188
- *
189
- * @example
190
- * // For the invalid date:
191
- * const result = isValid(new Date(''))
192
- * //=> false
193
- */
194
- function isValid(dirtyDate) {
195
- requiredArgs(1, arguments);
196
- if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
197
- return false;
198
- }
199
- var date = toDate(dirtyDate);
200
- return !isNaN(Number(date));
201
- }
202
-
203
- /**
204
- * @name subMilliseconds
205
- * @category Millisecond Helpers
206
- * @summary Subtract the specified number of milliseconds from the given date.
207
- *
208
- * @description
209
- * Subtract the specified number of milliseconds from the given date.
210
- *
211
- * @param {Date|Number} date - the date to be changed
212
- * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
213
- * @returns {Date} the new date with the milliseconds subtracted
214
- * @throws {TypeError} 2 arguments required
215
- *
216
- * @example
217
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
218
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
219
- * //=> Thu Jul 10 2014 12:45:29.250
220
- */
221
- function subMilliseconds(dirtyDate, dirtyAmount) {
222
- requiredArgs(2, arguments);
223
- var amount = toInteger(dirtyAmount);
224
- return addMilliseconds(dirtyDate, -amount);
225
- }
226
-
227
- var MILLISECONDS_IN_DAY = 86400000;
228
- function getUTCDayOfYear(dirtyDate) {
229
- requiredArgs(1, arguments);
230
- var date = toDate(dirtyDate);
231
- var timestamp = date.getTime();
232
- date.setUTCMonth(0, 1);
233
- date.setUTCHours(0, 0, 0, 0);
234
- var startOfYearTimestamp = date.getTime();
235
- var difference = timestamp - startOfYearTimestamp;
236
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
237
- }
238
-
239
- function startOfUTCISOWeek(dirtyDate) {
240
- requiredArgs(1, arguments);
241
- var weekStartsOn = 1;
242
- var date = toDate(dirtyDate);
243
- var day = date.getUTCDay();
244
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
245
- date.setUTCDate(date.getUTCDate() - diff);
246
- date.setUTCHours(0, 0, 0, 0);
247
- return date;
248
- }
249
-
250
- function getUTCISOWeekYear(dirtyDate) {
251
- requiredArgs(1, arguments);
252
- var date = toDate(dirtyDate);
253
- var year = date.getUTCFullYear();
254
- var fourthOfJanuaryOfNextYear = new Date(0);
255
- fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
256
- fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
257
- var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
258
- var fourthOfJanuaryOfThisYear = new Date(0);
259
- fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
260
- fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
261
- var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
262
- if (date.getTime() >= startOfNextYear.getTime()) {
263
- return year + 1;
264
- } else if (date.getTime() >= startOfThisYear.getTime()) {
265
- return year;
266
- } else {
267
- return year - 1;
268
- }
269
- }
270
-
271
- function startOfUTCISOWeekYear(dirtyDate) {
272
- requiredArgs(1, arguments);
273
- var year = getUTCISOWeekYear(dirtyDate);
274
- var fourthOfJanuary = new Date(0);
275
- fourthOfJanuary.setUTCFullYear(year, 0, 4);
276
- fourthOfJanuary.setUTCHours(0, 0, 0, 0);
277
- var date = startOfUTCISOWeek(fourthOfJanuary);
278
- return date;
279
- }
280
-
281
- var MILLISECONDS_IN_WEEK$1 = 604800000;
282
- function getUTCISOWeek(dirtyDate) {
283
- requiredArgs(1, arguments);
284
- var date = toDate(dirtyDate);
285
- var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
286
-
287
- // Round the number of days to the nearest integer
288
- // because the number of milliseconds in a week is not constant
289
- // (e.g. it's different in the week of the daylight saving time clock shift)
290
- return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
291
- }
292
-
293
- function startOfUTCWeek(dirtyDate, options) {
294
- var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
295
- requiredArgs(1, arguments);
296
- var defaultOptions = getDefaultOptions();
297
- var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
298
-
299
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
300
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
301
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
302
- }
303
- var date = toDate(dirtyDate);
304
- var day = date.getUTCDay();
305
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
306
- date.setUTCDate(date.getUTCDate() - diff);
307
- date.setUTCHours(0, 0, 0, 0);
308
- return date;
309
- }
310
-
311
- function getUTCWeekYear(dirtyDate, options) {
312
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
313
- requiredArgs(1, arguments);
314
- var date = toDate(dirtyDate);
315
- var year = date.getUTCFullYear();
316
- var defaultOptions = getDefaultOptions();
317
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
318
-
319
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
320
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
321
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
322
- }
323
- var firstWeekOfNextYear = new Date(0);
324
- firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
325
- firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
326
- var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
327
- var firstWeekOfThisYear = new Date(0);
328
- firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
329
- firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
330
- var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
331
- if (date.getTime() >= startOfNextYear.getTime()) {
332
- return year + 1;
333
- } else if (date.getTime() >= startOfThisYear.getTime()) {
334
- return year;
335
- } else {
336
- return year - 1;
337
- }
338
- }
339
-
340
- function startOfUTCWeekYear(dirtyDate, options) {
341
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
342
- requiredArgs(1, arguments);
343
- var defaultOptions = getDefaultOptions();
344
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
345
- var year = getUTCWeekYear(dirtyDate, options);
346
- var firstWeek = new Date(0);
347
- firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
348
- firstWeek.setUTCHours(0, 0, 0, 0);
349
- var date = startOfUTCWeek(firstWeek, options);
350
- return date;
351
- }
352
-
353
- var MILLISECONDS_IN_WEEK = 604800000;
354
- function getUTCWeek(dirtyDate, options) {
355
- requiredArgs(1, arguments);
356
- var date = toDate(dirtyDate);
357
- var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
358
-
359
- // Round the number of days to the nearest integer
360
- // because the number of milliseconds in a week is not constant
361
- // (e.g. it's different in the week of the daylight saving time clock shift)
362
- return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
363
- }
364
-
365
- function addLeadingZeros(number, targetLength) {
366
- var sign = number < 0 ? '-' : '';
367
- var output = Math.abs(number).toString();
368
- while (output.length < targetLength) {
369
- output = '0' + output;
370
- }
371
- return sign + output;
372
- }
373
-
374
- /*
375
- * | | Unit | | Unit |
376
- * |-----|--------------------------------|-----|--------------------------------|
377
- * | a | AM, PM | A* | |
378
- * | d | Day of month | D | |
379
- * | h | Hour [1-12] | H | Hour [0-23] |
380
- * | m | Minute | M | Month |
381
- * | s | Second | S | Fraction of second |
382
- * | y | Year (abs) | Y | |
383
- *
384
- * Letters marked by * are not implemented but reserved by Unicode standard.
385
- */
386
- var formatters$2 = {
387
- // Year
388
- y: function y(date, token) {
389
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
390
- // | Year | y | yy | yyy | yyyy | yyyyy |
391
- // |----------|-------|----|-------|-------|-------|
392
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
393
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
394
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
395
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
396
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
397
-
398
- var signedYear = date.getUTCFullYear();
399
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
400
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
401
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
402
- },
403
- // Month
404
- M: function M(date, token) {
405
- var month = date.getUTCMonth();
406
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
407
- },
408
- // Day of the month
409
- d: function d(date, token) {
410
- return addLeadingZeros(date.getUTCDate(), token.length);
411
- },
412
- // AM or PM
413
- a: function a(date, token) {
414
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
415
- switch (token) {
416
- case 'a':
417
- case 'aa':
418
- return dayPeriodEnumValue.toUpperCase();
419
- case 'aaa':
420
- return dayPeriodEnumValue;
421
- case 'aaaaa':
422
- return dayPeriodEnumValue[0];
423
- case 'aaaa':
424
- default:
425
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
426
- }
427
- },
428
- // Hour [1-12]
429
- h: function h(date, token) {
430
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
431
- },
432
- // Hour [0-23]
433
- H: function H(date, token) {
434
- return addLeadingZeros(date.getUTCHours(), token.length);
435
- },
436
- // Minute
437
- m: function m(date, token) {
438
- return addLeadingZeros(date.getUTCMinutes(), token.length);
439
- },
440
- // Second
441
- s: function s(date, token) {
442
- return addLeadingZeros(date.getUTCSeconds(), token.length);
443
- },
444
- // Fraction of second
445
- S: function S(date, token) {
446
- var numberOfDigits = token.length;
447
- var milliseconds = date.getUTCMilliseconds();
448
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
449
- return addLeadingZeros(fractionalSeconds, token.length);
450
- }
451
- };
452
- const formatters$3 = formatters$2;
453
-
454
- var dayPeriodEnum = {
455
- am: 'am',
456
- pm: 'pm',
457
- midnight: 'midnight',
458
- noon: 'noon',
459
- morning: 'morning',
460
- afternoon: 'afternoon',
461
- evening: 'evening',
462
- night: 'night'
463
- };
464
- /*
465
- * | | Unit | | Unit |
466
- * |-----|--------------------------------|-----|--------------------------------|
467
- * | a | AM, PM | A* | Milliseconds in day |
468
- * | b | AM, PM, noon, midnight | B | Flexible day period |
469
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
470
- * | d | Day of month | D | Day of year |
471
- * | e | Local day of week | E | Day of week |
472
- * | f | | F* | Day of week in month |
473
- * | g* | Modified Julian day | G | Era |
474
- * | h | Hour [1-12] | H | Hour [0-23] |
475
- * | i! | ISO day of week | I! | ISO week of year |
476
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
477
- * | k | Hour [1-24] | K | Hour [0-11] |
478
- * | l* | (deprecated) | L | Stand-alone month |
479
- * | m | Minute | M | Month |
480
- * | n | | N | |
481
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
482
- * | p! | Long localized time | P! | Long localized date |
483
- * | q | Stand-alone quarter | Q | Quarter |
484
- * | r* | Related Gregorian year | R! | ISO week-numbering year |
485
- * | s | Second | S | Fraction of second |
486
- * | t! | Seconds timestamp | T! | Milliseconds timestamp |
487
- * | u | Extended year | U* | Cyclic year |
488
- * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
489
- * | w | Local week of year | W* | Week of month |
490
- * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
491
- * | y | Year (abs) | Y | Local week-numbering year |
492
- * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
493
- *
494
- * Letters marked by * are not implemented but reserved by Unicode standard.
495
- *
496
- * Letters marked by ! are non-standard, but implemented by date-fns:
497
- * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
498
- * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
499
- * i.e. 7 for Sunday, 1 for Monday, etc.
500
- * - `I` is ISO week of year, as opposed to `w` which is local week of year.
501
- * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
502
- * `R` is supposed to be used in conjunction with `I` and `i`
503
- * for universal ISO week-numbering date, whereas
504
- * `Y` is supposed to be used in conjunction with `w` and `e`
505
- * for week-numbering date specific to the locale.
506
- * - `P` is long localized date format
507
- * - `p` is long localized time format
508
- */
509
-
510
- var formatters = {
511
- // Era
512
- G: function G(date, token, localize) {
513
- var era = date.getUTCFullYear() > 0 ? 1 : 0;
514
- switch (token) {
515
- // AD, BC
516
- case 'G':
517
- case 'GG':
518
- case 'GGG':
519
- return localize.era(era, {
520
- width: 'abbreviated'
521
- });
522
- // A, B
523
- case 'GGGGG':
524
- return localize.era(era, {
525
- width: 'narrow'
526
- });
527
- // Anno Domini, Before Christ
528
- case 'GGGG':
529
- default:
530
- return localize.era(era, {
531
- width: 'wide'
532
- });
533
- }
534
- },
535
- // Year
536
- y: function y(date, token, localize) {
537
- // Ordinal number
538
- if (token === 'yo') {
539
- var signedYear = date.getUTCFullYear();
540
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
541
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
542
- return localize.ordinalNumber(year, {
543
- unit: 'year'
544
- });
545
- }
546
- return formatters$3.y(date, token);
547
- },
548
- // Local week-numbering year
549
- Y: function Y(date, token, localize, options) {
550
- var signedWeekYear = getUTCWeekYear(date, options);
551
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
552
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
553
-
554
- // Two digit year
555
- if (token === 'YY') {
556
- var twoDigitYear = weekYear % 100;
557
- return addLeadingZeros(twoDigitYear, 2);
558
- }
559
-
560
- // Ordinal number
561
- if (token === 'Yo') {
562
- return localize.ordinalNumber(weekYear, {
563
- unit: 'year'
564
- });
565
- }
566
-
567
- // Padding
568
- return addLeadingZeros(weekYear, token.length);
569
- },
570
- // ISO week-numbering year
571
- R: function R(date, token) {
572
- var isoWeekYear = getUTCISOWeekYear(date);
573
-
574
- // Padding
575
- return addLeadingZeros(isoWeekYear, token.length);
576
- },
577
- // Extended year. This is a single number designating the year of this calendar system.
578
- // The main difference between `y` and `u` localizers are B.C. years:
579
- // | Year | `y` | `u` |
580
- // |------|-----|-----|
581
- // | AC 1 | 1 | 1 |
582
- // | BC 1 | 1 | 0 |
583
- // | BC 2 | 2 | -1 |
584
- // Also `yy` always returns the last two digits of a year,
585
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
586
- u: function u(date, token) {
587
- var year = date.getUTCFullYear();
588
- return addLeadingZeros(year, token.length);
589
- },
590
- // Quarter
591
- Q: function Q(date, token, localize) {
592
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
593
- switch (token) {
594
- // 1, 2, 3, 4
595
- case 'Q':
596
- return String(quarter);
597
- // 01, 02, 03, 04
598
- case 'QQ':
599
- return addLeadingZeros(quarter, 2);
600
- // 1st, 2nd, 3rd, 4th
601
- case 'Qo':
602
- return localize.ordinalNumber(quarter, {
603
- unit: 'quarter'
604
- });
605
- // Q1, Q2, Q3, Q4
606
- case 'QQQ':
607
- return localize.quarter(quarter, {
608
- width: 'abbreviated',
609
- context: 'formatting'
610
- });
611
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
612
- case 'QQQQQ':
613
- return localize.quarter(quarter, {
614
- width: 'narrow',
615
- context: 'formatting'
616
- });
617
- // 1st quarter, 2nd quarter, ...
618
- case 'QQQQ':
619
- default:
620
- return localize.quarter(quarter, {
621
- width: 'wide',
622
- context: 'formatting'
623
- });
624
- }
625
- },
626
- // Stand-alone quarter
627
- q: function q(date, token, localize) {
628
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
629
- switch (token) {
630
- // 1, 2, 3, 4
631
- case 'q':
632
- return String(quarter);
633
- // 01, 02, 03, 04
634
- case 'qq':
635
- return addLeadingZeros(quarter, 2);
636
- // 1st, 2nd, 3rd, 4th
637
- case 'qo':
638
- return localize.ordinalNumber(quarter, {
639
- unit: 'quarter'
640
- });
641
- // Q1, Q2, Q3, Q4
642
- case 'qqq':
643
- return localize.quarter(quarter, {
644
- width: 'abbreviated',
645
- context: 'standalone'
646
- });
647
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
648
- case 'qqqqq':
649
- return localize.quarter(quarter, {
650
- width: 'narrow',
651
- context: 'standalone'
652
- });
653
- // 1st quarter, 2nd quarter, ...
654
- case 'qqqq':
655
- default:
656
- return localize.quarter(quarter, {
657
- width: 'wide',
658
- context: 'standalone'
659
- });
660
- }
661
- },
662
- // Month
663
- M: function M(date, token, localize) {
664
- var month = date.getUTCMonth();
665
- switch (token) {
666
- case 'M':
667
- case 'MM':
668
- return formatters$3.M(date, token);
669
- // 1st, 2nd, ..., 12th
670
- case 'Mo':
671
- return localize.ordinalNumber(month + 1, {
672
- unit: 'month'
673
- });
674
- // Jan, Feb, ..., Dec
675
- case 'MMM':
676
- return localize.month(month, {
677
- width: 'abbreviated',
678
- context: 'formatting'
679
- });
680
- // J, F, ..., D
681
- case 'MMMMM':
682
- return localize.month(month, {
683
- width: 'narrow',
684
- context: 'formatting'
685
- });
686
- // January, February, ..., December
687
- case 'MMMM':
688
- default:
689
- return localize.month(month, {
690
- width: 'wide',
691
- context: 'formatting'
692
- });
693
- }
694
- },
695
- // Stand-alone month
696
- L: function L(date, token, localize) {
697
- var month = date.getUTCMonth();
698
- switch (token) {
699
- // 1, 2, ..., 12
700
- case 'L':
701
- return String(month + 1);
702
- // 01, 02, ..., 12
703
- case 'LL':
704
- return addLeadingZeros(month + 1, 2);
705
- // 1st, 2nd, ..., 12th
706
- case 'Lo':
707
- return localize.ordinalNumber(month + 1, {
708
- unit: 'month'
709
- });
710
- // Jan, Feb, ..., Dec
711
- case 'LLL':
712
- return localize.month(month, {
713
- width: 'abbreviated',
714
- context: 'standalone'
715
- });
716
- // J, F, ..., D
717
- case 'LLLLL':
718
- return localize.month(month, {
719
- width: 'narrow',
720
- context: 'standalone'
721
- });
722
- // January, February, ..., December
723
- case 'LLLL':
724
- default:
725
- return localize.month(month, {
726
- width: 'wide',
727
- context: 'standalone'
728
- });
729
- }
730
- },
731
- // Local week of year
732
- w: function w(date, token, localize, options) {
733
- var week = getUTCWeek(date, options);
734
- if (token === 'wo') {
735
- return localize.ordinalNumber(week, {
736
- unit: 'week'
737
- });
738
- }
739
- return addLeadingZeros(week, token.length);
740
- },
741
- // ISO week of year
742
- I: function I(date, token, localize) {
743
- var isoWeek = getUTCISOWeek(date);
744
- if (token === 'Io') {
745
- return localize.ordinalNumber(isoWeek, {
746
- unit: 'week'
747
- });
748
- }
749
- return addLeadingZeros(isoWeek, token.length);
750
- },
751
- // Day of the month
752
- d: function d(date, token, localize) {
753
- if (token === 'do') {
754
- return localize.ordinalNumber(date.getUTCDate(), {
755
- unit: 'date'
756
- });
757
- }
758
- return formatters$3.d(date, token);
759
- },
760
- // Day of year
761
- D: function D(date, token, localize) {
762
- var dayOfYear = getUTCDayOfYear(date);
763
- if (token === 'Do') {
764
- return localize.ordinalNumber(dayOfYear, {
765
- unit: 'dayOfYear'
766
- });
767
- }
768
- return addLeadingZeros(dayOfYear, token.length);
769
- },
770
- // Day of week
771
- E: function E(date, token, localize) {
772
- var dayOfWeek = date.getUTCDay();
773
- switch (token) {
774
- // Tue
775
- case 'E':
776
- case 'EE':
777
- case 'EEE':
778
- return localize.day(dayOfWeek, {
779
- width: 'abbreviated',
780
- context: 'formatting'
781
- });
782
- // T
783
- case 'EEEEE':
784
- return localize.day(dayOfWeek, {
785
- width: 'narrow',
786
- context: 'formatting'
787
- });
788
- // Tu
789
- case 'EEEEEE':
790
- return localize.day(dayOfWeek, {
791
- width: 'short',
792
- context: 'formatting'
793
- });
794
- // Tuesday
795
- case 'EEEE':
796
- default:
797
- return localize.day(dayOfWeek, {
798
- width: 'wide',
799
- context: 'formatting'
800
- });
801
- }
802
- },
803
- // Local day of week
804
- e: function e(date, token, localize, options) {
805
- var dayOfWeek = date.getUTCDay();
806
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
807
- switch (token) {
808
- // Numerical value (Nth day of week with current locale or weekStartsOn)
809
- case 'e':
810
- return String(localDayOfWeek);
811
- // Padded numerical value
812
- case 'ee':
813
- return addLeadingZeros(localDayOfWeek, 2);
814
- // 1st, 2nd, ..., 7th
815
- case 'eo':
816
- return localize.ordinalNumber(localDayOfWeek, {
817
- unit: 'day'
818
- });
819
- case 'eee':
820
- return localize.day(dayOfWeek, {
821
- width: 'abbreviated',
822
- context: 'formatting'
823
- });
824
- // T
825
- case 'eeeee':
826
- return localize.day(dayOfWeek, {
827
- width: 'narrow',
828
- context: 'formatting'
829
- });
830
- // Tu
831
- case 'eeeeee':
832
- return localize.day(dayOfWeek, {
833
- width: 'short',
834
- context: 'formatting'
835
- });
836
- // Tuesday
837
- case 'eeee':
838
- default:
839
- return localize.day(dayOfWeek, {
840
- width: 'wide',
841
- context: 'formatting'
842
- });
843
- }
844
- },
845
- // Stand-alone local day of week
846
- c: function c(date, token, localize, options) {
847
- var dayOfWeek = date.getUTCDay();
848
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
849
- switch (token) {
850
- // Numerical value (same as in `e`)
851
- case 'c':
852
- return String(localDayOfWeek);
853
- // Padded numerical value
854
- case 'cc':
855
- return addLeadingZeros(localDayOfWeek, token.length);
856
- // 1st, 2nd, ..., 7th
857
- case 'co':
858
- return localize.ordinalNumber(localDayOfWeek, {
859
- unit: 'day'
860
- });
861
- case 'ccc':
862
- return localize.day(dayOfWeek, {
863
- width: 'abbreviated',
864
- context: 'standalone'
865
- });
866
- // T
867
- case 'ccccc':
868
- return localize.day(dayOfWeek, {
869
- width: 'narrow',
870
- context: 'standalone'
871
- });
872
- // Tu
873
- case 'cccccc':
874
- return localize.day(dayOfWeek, {
875
- width: 'short',
876
- context: 'standalone'
877
- });
878
- // Tuesday
879
- case 'cccc':
880
- default:
881
- return localize.day(dayOfWeek, {
882
- width: 'wide',
883
- context: 'standalone'
884
- });
885
- }
886
- },
887
- // ISO day of week
888
- i: function i(date, token, localize) {
889
- var dayOfWeek = date.getUTCDay();
890
- var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
891
- switch (token) {
892
- // 2
893
- case 'i':
894
- return String(isoDayOfWeek);
895
- // 02
896
- case 'ii':
897
- return addLeadingZeros(isoDayOfWeek, token.length);
898
- // 2nd
899
- case 'io':
900
- return localize.ordinalNumber(isoDayOfWeek, {
901
- unit: 'day'
902
- });
903
- // Tue
904
- case 'iii':
905
- return localize.day(dayOfWeek, {
906
- width: 'abbreviated',
907
- context: 'formatting'
908
- });
909
- // T
910
- case 'iiiii':
911
- return localize.day(dayOfWeek, {
912
- width: 'narrow',
913
- context: 'formatting'
914
- });
915
- // Tu
916
- case 'iiiiii':
917
- return localize.day(dayOfWeek, {
918
- width: 'short',
919
- context: 'formatting'
920
- });
921
- // Tuesday
922
- case 'iiii':
923
- default:
924
- return localize.day(dayOfWeek, {
925
- width: 'wide',
926
- context: 'formatting'
927
- });
928
- }
929
- },
930
- // AM or PM
931
- a: function a(date, token, localize) {
932
- var hours = date.getUTCHours();
933
- var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
934
- switch (token) {
935
- case 'a':
936
- case 'aa':
937
- return localize.dayPeriod(dayPeriodEnumValue, {
938
- width: 'abbreviated',
939
- context: 'formatting'
940
- });
941
- case 'aaa':
942
- return localize.dayPeriod(dayPeriodEnumValue, {
943
- width: 'abbreviated',
944
- context: 'formatting'
945
- }).toLowerCase();
946
- case 'aaaaa':
947
- return localize.dayPeriod(dayPeriodEnumValue, {
948
- width: 'narrow',
949
- context: 'formatting'
950
- });
951
- case 'aaaa':
952
- default:
953
- return localize.dayPeriod(dayPeriodEnumValue, {
954
- width: 'wide',
955
- context: 'formatting'
956
- });
957
- }
958
- },
959
- // AM, PM, midnight, noon
960
- b: function b(date, token, localize) {
961
- var hours = date.getUTCHours();
962
- var dayPeriodEnumValue;
963
- if (hours === 12) {
964
- dayPeriodEnumValue = dayPeriodEnum.noon;
965
- } else if (hours === 0) {
966
- dayPeriodEnumValue = dayPeriodEnum.midnight;
967
- } else {
968
- dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
969
- }
970
- switch (token) {
971
- case 'b':
972
- case 'bb':
973
- return localize.dayPeriod(dayPeriodEnumValue, {
974
- width: 'abbreviated',
975
- context: 'formatting'
976
- });
977
- case 'bbb':
978
- return localize.dayPeriod(dayPeriodEnumValue, {
979
- width: 'abbreviated',
980
- context: 'formatting'
981
- }).toLowerCase();
982
- case 'bbbbb':
983
- return localize.dayPeriod(dayPeriodEnumValue, {
984
- width: 'narrow',
985
- context: 'formatting'
986
- });
987
- case 'bbbb':
988
- default:
989
- return localize.dayPeriod(dayPeriodEnumValue, {
990
- width: 'wide',
991
- context: 'formatting'
992
- });
993
- }
994
- },
995
- // in the morning, in the afternoon, in the evening, at night
996
- B: function B(date, token, localize) {
997
- var hours = date.getUTCHours();
998
- var dayPeriodEnumValue;
999
- if (hours >= 17) {
1000
- dayPeriodEnumValue = dayPeriodEnum.evening;
1001
- } else if (hours >= 12) {
1002
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
1003
- } else if (hours >= 4) {
1004
- dayPeriodEnumValue = dayPeriodEnum.morning;
1005
- } else {
1006
- dayPeriodEnumValue = dayPeriodEnum.night;
1007
- }
1008
- switch (token) {
1009
- case 'B':
1010
- case 'BB':
1011
- case 'BBB':
1012
- return localize.dayPeriod(dayPeriodEnumValue, {
1013
- width: 'abbreviated',
1014
- context: 'formatting'
1015
- });
1016
- case 'BBBBB':
1017
- return localize.dayPeriod(dayPeriodEnumValue, {
1018
- width: 'narrow',
1019
- context: 'formatting'
1020
- });
1021
- case 'BBBB':
1022
- default:
1023
- return localize.dayPeriod(dayPeriodEnumValue, {
1024
- width: 'wide',
1025
- context: 'formatting'
1026
- });
1027
- }
1028
- },
1029
- // Hour [1-12]
1030
- h: function h(date, token, localize) {
1031
- if (token === 'ho') {
1032
- var hours = date.getUTCHours() % 12;
1033
- if (hours === 0) hours = 12;
1034
- return localize.ordinalNumber(hours, {
1035
- unit: 'hour'
1036
- });
1037
- }
1038
- return formatters$3.h(date, token);
1039
- },
1040
- // Hour [0-23]
1041
- H: function H(date, token, localize) {
1042
- if (token === 'Ho') {
1043
- return localize.ordinalNumber(date.getUTCHours(), {
1044
- unit: 'hour'
1045
- });
1046
- }
1047
- return formatters$3.H(date, token);
1048
- },
1049
- // Hour [0-11]
1050
- K: function K(date, token, localize) {
1051
- var hours = date.getUTCHours() % 12;
1052
- if (token === 'Ko') {
1053
- return localize.ordinalNumber(hours, {
1054
- unit: 'hour'
1055
- });
1056
- }
1057
- return addLeadingZeros(hours, token.length);
1058
- },
1059
- // Hour [1-24]
1060
- k: function k(date, token, localize) {
1061
- var hours = date.getUTCHours();
1062
- if (hours === 0) hours = 24;
1063
- if (token === 'ko') {
1064
- return localize.ordinalNumber(hours, {
1065
- unit: 'hour'
1066
- });
1067
- }
1068
- return addLeadingZeros(hours, token.length);
1069
- },
1070
- // Minute
1071
- m: function m(date, token, localize) {
1072
- if (token === 'mo') {
1073
- return localize.ordinalNumber(date.getUTCMinutes(), {
1074
- unit: 'minute'
1075
- });
1076
- }
1077
- return formatters$3.m(date, token);
1078
- },
1079
- // Second
1080
- s: function s(date, token, localize) {
1081
- if (token === 'so') {
1082
- return localize.ordinalNumber(date.getUTCSeconds(), {
1083
- unit: 'second'
1084
- });
1085
- }
1086
- return formatters$3.s(date, token);
1087
- },
1088
- // Fraction of second
1089
- S: function S(date, token) {
1090
- return formatters$3.S(date, token);
1091
- },
1092
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1093
- X: function X(date, token, _localize, options) {
1094
- var originalDate = options._originalDate || date;
1095
- var timezoneOffset = originalDate.getTimezoneOffset();
1096
- if (timezoneOffset === 0) {
1097
- return 'Z';
1098
- }
1099
- switch (token) {
1100
- // Hours and optional minutes
1101
- case 'X':
1102
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1103
-
1104
- // Hours, minutes and optional seconds without `:` delimiter
1105
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1106
- // so this token always has the same output as `XX`
1107
- case 'XXXX':
1108
- case 'XX':
1109
- // Hours and minutes without `:` delimiter
1110
- return formatTimezone(timezoneOffset);
1111
-
1112
- // Hours, minutes and optional seconds with `:` delimiter
1113
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1114
- // so this token always has the same output as `XXX`
1115
- case 'XXXXX':
1116
- case 'XXX': // Hours and minutes with `:` delimiter
1117
- default:
1118
- return formatTimezone(timezoneOffset, ':');
1119
- }
1120
- },
1121
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1122
- x: function x(date, token, _localize, options) {
1123
- var originalDate = options._originalDate || date;
1124
- var timezoneOffset = originalDate.getTimezoneOffset();
1125
- switch (token) {
1126
- // Hours and optional minutes
1127
- case 'x':
1128
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1129
-
1130
- // Hours, minutes and optional seconds without `:` delimiter
1131
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1132
- // so this token always has the same output as `xx`
1133
- case 'xxxx':
1134
- case 'xx':
1135
- // Hours and minutes without `:` delimiter
1136
- return formatTimezone(timezoneOffset);
1137
-
1138
- // Hours, minutes and optional seconds with `:` delimiter
1139
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1140
- // so this token always has the same output as `xxx`
1141
- case 'xxxxx':
1142
- case 'xxx': // Hours and minutes with `:` delimiter
1143
- default:
1144
- return formatTimezone(timezoneOffset, ':');
1145
- }
1146
- },
1147
- // Timezone (GMT)
1148
- O: function O(date, token, _localize, options) {
1149
- var originalDate = options._originalDate || date;
1150
- var timezoneOffset = originalDate.getTimezoneOffset();
1151
- switch (token) {
1152
- // Short
1153
- case 'O':
1154
- case 'OO':
1155
- case 'OOO':
1156
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1157
- // Long
1158
- case 'OOOO':
1159
- default:
1160
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1161
- }
1162
- },
1163
- // Timezone (specific non-location)
1164
- z: function z(date, token, _localize, options) {
1165
- var originalDate = options._originalDate || date;
1166
- var timezoneOffset = originalDate.getTimezoneOffset();
1167
- switch (token) {
1168
- // Short
1169
- case 'z':
1170
- case 'zz':
1171
- case 'zzz':
1172
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1173
- // Long
1174
- case 'zzzz':
1175
- default:
1176
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1177
- }
1178
- },
1179
- // Seconds timestamp
1180
- t: function t(date, token, _localize, options) {
1181
- var originalDate = options._originalDate || date;
1182
- var timestamp = Math.floor(originalDate.getTime() / 1000);
1183
- return addLeadingZeros(timestamp, token.length);
1184
- },
1185
- // Milliseconds timestamp
1186
- T: function T(date, token, _localize, options) {
1187
- var originalDate = options._originalDate || date;
1188
- var timestamp = originalDate.getTime();
1189
- return addLeadingZeros(timestamp, token.length);
1190
- }
1191
- };
1192
- function formatTimezoneShort(offset, dirtyDelimiter) {
1193
- var sign = offset > 0 ? '-' : '+';
1194
- var absOffset = Math.abs(offset);
1195
- var hours = Math.floor(absOffset / 60);
1196
- var minutes = absOffset % 60;
1197
- if (minutes === 0) {
1198
- return sign + String(hours);
1199
- }
1200
- var delimiter = dirtyDelimiter || '';
1201
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1202
- }
1203
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1204
- if (offset % 60 === 0) {
1205
- var sign = offset > 0 ? '-' : '+';
1206
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1207
- }
1208
- return formatTimezone(offset, dirtyDelimiter);
1209
- }
1210
- function formatTimezone(offset, dirtyDelimiter) {
1211
- var delimiter = dirtyDelimiter || '';
1212
- var sign = offset > 0 ? '-' : '+';
1213
- var absOffset = Math.abs(offset);
1214
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1215
- var minutes = addLeadingZeros(absOffset % 60, 2);
1216
- return sign + hours + delimiter + minutes;
1217
- }
1218
- const formatters$1 = formatters;
1219
-
1220
- var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1221
- switch (pattern) {
1222
- case 'P':
1223
- return formatLong.date({
1224
- width: 'short'
1225
- });
1226
- case 'PP':
1227
- return formatLong.date({
1228
- width: 'medium'
1229
- });
1230
- case 'PPP':
1231
- return formatLong.date({
1232
- width: 'long'
1233
- });
1234
- case 'PPPP':
1235
- default:
1236
- return formatLong.date({
1237
- width: 'full'
1238
- });
1239
- }
1240
- };
1241
- var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1242
- switch (pattern) {
1243
- case 'p':
1244
- return formatLong.time({
1245
- width: 'short'
1246
- });
1247
- case 'pp':
1248
- return formatLong.time({
1249
- width: 'medium'
1250
- });
1251
- case 'ppp':
1252
- return formatLong.time({
1253
- width: 'long'
1254
- });
1255
- case 'pppp':
1256
- default:
1257
- return formatLong.time({
1258
- width: 'full'
1259
- });
1260
- }
1261
- };
1262
- var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1263
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
1264
- var datePattern = matchResult[1];
1265
- var timePattern = matchResult[2];
1266
- if (!timePattern) {
1267
- return dateLongFormatter(pattern, formatLong);
1268
- }
1269
- var dateTimeFormat;
1270
- switch (datePattern) {
1271
- case 'P':
1272
- dateTimeFormat = formatLong.dateTime({
1273
- width: 'short'
1274
- });
1275
- break;
1276
- case 'PP':
1277
- dateTimeFormat = formatLong.dateTime({
1278
- width: 'medium'
1279
- });
1280
- break;
1281
- case 'PPP':
1282
- dateTimeFormat = formatLong.dateTime({
1283
- width: 'long'
1284
- });
1285
- break;
1286
- case 'PPPP':
1287
- default:
1288
- dateTimeFormat = formatLong.dateTime({
1289
- width: 'full'
1290
- });
1291
- break;
1292
- }
1293
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1294
- };
1295
- var longFormatters = {
1296
- p: timeLongFormatter,
1297
- P: dateTimeLongFormatter
1298
- };
1299
- const longFormatters$1 = longFormatters;
1300
-
1301
- var protectedDayOfYearTokens = ['D', 'DD'];
1302
- var protectedWeekYearTokens = ['YY', 'YYYY'];
1303
- function isProtectedDayOfYearToken(token) {
1304
- return protectedDayOfYearTokens.indexOf(token) !== -1;
1305
- }
1306
- function isProtectedWeekYearToken(token) {
1307
- return protectedWeekYearTokens.indexOf(token) !== -1;
1308
- }
1309
- function throwProtectedError(token, format, input) {
1310
- if (token === 'YYYY') {
1311
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1312
- } else if (token === 'YY') {
1313
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1314
- } else if (token === 'D') {
1315
- throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1316
- } else if (token === 'DD') {
1317
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1318
- }
1319
- }
1320
-
1321
- var formatDistanceLocale = {
1322
- lessThanXSeconds: {
1323
- one: 'less than a second',
1324
- other: 'less than {{count}} seconds'
1325
- },
1326
- xSeconds: {
1327
- one: '1 second',
1328
- other: '{{count}} seconds'
1329
- },
1330
- halfAMinute: 'half a minute',
1331
- lessThanXMinutes: {
1332
- one: 'less than a minute',
1333
- other: 'less than {{count}} minutes'
1334
- },
1335
- xMinutes: {
1336
- one: '1 minute',
1337
- other: '{{count}} minutes'
1338
- },
1339
- aboutXHours: {
1340
- one: 'about 1 hour',
1341
- other: 'about {{count}} hours'
1342
- },
1343
- xHours: {
1344
- one: '1 hour',
1345
- other: '{{count}} hours'
1346
- },
1347
- xDays: {
1348
- one: '1 day',
1349
- other: '{{count}} days'
1350
- },
1351
- aboutXWeeks: {
1352
- one: 'about 1 week',
1353
- other: 'about {{count}} weeks'
1354
- },
1355
- xWeeks: {
1356
- one: '1 week',
1357
- other: '{{count}} weeks'
1358
- },
1359
- aboutXMonths: {
1360
- one: 'about 1 month',
1361
- other: 'about {{count}} months'
1362
- },
1363
- xMonths: {
1364
- one: '1 month',
1365
- other: '{{count}} months'
1366
- },
1367
- aboutXYears: {
1368
- one: 'about 1 year',
1369
- other: 'about {{count}} years'
1370
- },
1371
- xYears: {
1372
- one: '1 year',
1373
- other: '{{count}} years'
1374
- },
1375
- overXYears: {
1376
- one: 'over 1 year',
1377
- other: 'over {{count}} years'
1378
- },
1379
- almostXYears: {
1380
- one: 'almost 1 year',
1381
- other: 'almost {{count}} years'
1382
- }
1383
- };
1384
- var formatDistance = function formatDistance(token, count, options) {
1385
- var result;
1386
- var tokenValue = formatDistanceLocale[token];
1387
- if (typeof tokenValue === 'string') {
1388
- result = tokenValue;
1389
- } else if (count === 1) {
1390
- result = tokenValue.one;
1391
- } else {
1392
- result = tokenValue.other.replace('{{count}}', count.toString());
1393
- }
1394
- if (options !== null && options !== void 0 && options.addSuffix) {
1395
- if (options.comparison && options.comparison > 0) {
1396
- return 'in ' + result;
1397
- } else {
1398
- return result + ' ago';
1399
- }
1400
- }
1401
- return result;
1402
- };
1403
- const formatDistance$1 = formatDistance;
1404
-
1405
- function buildFormatLongFn(args) {
1406
- return function () {
1407
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1408
- // TODO: Remove String()
1409
- var width = options.width ? String(options.width) : args.defaultWidth;
1410
- var format = args.formats[width] || args.formats[args.defaultWidth];
1411
- return format;
1412
- };
1413
- }
1414
-
1415
- var dateFormats = {
1416
- full: 'EEEE, MMMM do, y',
1417
- long: 'MMMM do, y',
1418
- medium: 'MMM d, y',
1419
- short: 'MM/dd/yyyy'
1420
- };
1421
- var timeFormats = {
1422
- full: 'h:mm:ss a zzzz',
1423
- long: 'h:mm:ss a z',
1424
- medium: 'h:mm:ss a',
1425
- short: 'h:mm a'
1426
- };
1427
- var dateTimeFormats = {
1428
- full: "{{date}} 'at' {{time}}",
1429
- long: "{{date}} 'at' {{time}}",
1430
- medium: '{{date}}, {{time}}',
1431
- short: '{{date}}, {{time}}'
1432
- };
1433
- var formatLong = {
1434
- date: buildFormatLongFn({
1435
- formats: dateFormats,
1436
- defaultWidth: 'full'
1437
- }),
1438
- time: buildFormatLongFn({
1439
- formats: timeFormats,
1440
- defaultWidth: 'full'
1441
- }),
1442
- dateTime: buildFormatLongFn({
1443
- formats: dateTimeFormats,
1444
- defaultWidth: 'full'
1445
- })
1446
- };
1447
- const formatLong$1 = formatLong;
1448
-
1449
- var formatRelativeLocale = {
1450
- lastWeek: "'last' eeee 'at' p",
1451
- yesterday: "'yesterday at' p",
1452
- today: "'today at' p",
1453
- tomorrow: "'tomorrow at' p",
1454
- nextWeek: "eeee 'at' p",
1455
- other: 'P'
1456
- };
1457
- var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1458
- return formatRelativeLocale[token];
1459
- };
1460
- const formatRelative$1 = formatRelative;
1461
-
1462
- function buildLocalizeFn(args) {
1463
- return function (dirtyIndex, options) {
1464
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1465
- var valuesArray;
1466
- if (context === 'formatting' && args.formattingValues) {
1467
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1468
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1469
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1470
- } else {
1471
- var _defaultWidth = args.defaultWidth;
1472
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1473
- valuesArray = args.values[_width] || args.values[_defaultWidth];
1474
- }
1475
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1476
- // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1477
- return valuesArray[index];
1478
- };
1479
- }
1480
-
1481
- var eraValues = {
1482
- narrow: ['B', 'A'],
1483
- abbreviated: ['BC', 'AD'],
1484
- wide: ['Before Christ', 'Anno Domini']
1485
- };
1486
- var quarterValues = {
1487
- narrow: ['1', '2', '3', '4'],
1488
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1489
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1490
- };
1491
-
1492
- // Note: in English, the names of days of the week and months are capitalized.
1493
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1494
- // Generally, formatted dates should look like they are in the middle of a sentence,
1495
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
1496
- var monthValues = {
1497
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1498
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1499
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1500
- };
1501
- var dayValues = {
1502
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1503
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1504
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1505
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1506
- };
1507
- var dayPeriodValues = {
1508
- narrow: {
1509
- am: 'a',
1510
- pm: 'p',
1511
- midnight: 'mi',
1512
- noon: 'n',
1513
- morning: 'morning',
1514
- afternoon: 'afternoon',
1515
- evening: 'evening',
1516
- night: 'night'
1517
- },
1518
- abbreviated: {
1519
- am: 'AM',
1520
- pm: 'PM',
1521
- midnight: 'midnight',
1522
- noon: 'noon',
1523
- morning: 'morning',
1524
- afternoon: 'afternoon',
1525
- evening: 'evening',
1526
- night: 'night'
1527
- },
1528
- wide: {
1529
- am: 'a.m.',
1530
- pm: 'p.m.',
1531
- midnight: 'midnight',
1532
- noon: 'noon',
1533
- morning: 'morning',
1534
- afternoon: 'afternoon',
1535
- evening: 'evening',
1536
- night: 'night'
1537
- }
1538
- };
1539
- var formattingDayPeriodValues = {
1540
- narrow: {
1541
- am: 'a',
1542
- pm: 'p',
1543
- midnight: 'mi',
1544
- noon: 'n',
1545
- morning: 'in the morning',
1546
- afternoon: 'in the afternoon',
1547
- evening: 'in the evening',
1548
- night: 'at night'
1549
- },
1550
- abbreviated: {
1551
- am: 'AM',
1552
- pm: 'PM',
1553
- midnight: 'midnight',
1554
- noon: 'noon',
1555
- morning: 'in the morning',
1556
- afternoon: 'in the afternoon',
1557
- evening: 'in the evening',
1558
- night: 'at night'
1559
- },
1560
- wide: {
1561
- am: 'a.m.',
1562
- pm: 'p.m.',
1563
- midnight: 'midnight',
1564
- noon: 'noon',
1565
- morning: 'in the morning',
1566
- afternoon: 'in the afternoon',
1567
- evening: 'in the evening',
1568
- night: 'at night'
1569
- }
1570
- };
1571
- var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1572
- var number = Number(dirtyNumber);
1573
-
1574
- // If ordinal numbers depend on context, for example,
1575
- // if they are different for different grammatical genders,
1576
- // use `options.unit`.
1577
- //
1578
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1579
- // 'day', 'hour', 'minute', 'second'.
1580
-
1581
- var rem100 = number % 100;
1582
- if (rem100 > 20 || rem100 < 10) {
1583
- switch (rem100 % 10) {
1584
- case 1:
1585
- return number + 'st';
1586
- case 2:
1587
- return number + 'nd';
1588
- case 3:
1589
- return number + 'rd';
1590
- }
1591
- }
1592
- return number + 'th';
1593
- };
1594
- var localize = {
1595
- ordinalNumber: ordinalNumber,
1596
- era: buildLocalizeFn({
1597
- values: eraValues,
1598
- defaultWidth: 'wide'
1599
- }),
1600
- quarter: buildLocalizeFn({
1601
- values: quarterValues,
1602
- defaultWidth: 'wide',
1603
- argumentCallback: function argumentCallback(quarter) {
1604
- return quarter - 1;
1605
- }
1606
- }),
1607
- month: buildLocalizeFn({
1608
- values: monthValues,
1609
- defaultWidth: 'wide'
1610
- }),
1611
- day: buildLocalizeFn({
1612
- values: dayValues,
1613
- defaultWidth: 'wide'
1614
- }),
1615
- dayPeriod: buildLocalizeFn({
1616
- values: dayPeriodValues,
1617
- defaultWidth: 'wide',
1618
- formattingValues: formattingDayPeriodValues,
1619
- defaultFormattingWidth: 'wide'
1620
- })
1621
- };
1622
- const localize$1 = localize;
1623
-
1624
- function buildMatchFn(args) {
1625
- return function (string) {
1626
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1627
- var width = options.width;
1628
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1629
- var matchResult = string.match(matchPattern);
1630
- if (!matchResult) {
1631
- return null;
1632
- }
1633
- var matchedString = matchResult[0];
1634
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1635
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1636
- return pattern.test(matchedString);
1637
- }) : findKey(parsePatterns, function (pattern) {
1638
- return pattern.test(matchedString);
1639
- });
1640
- var value;
1641
- value = args.valueCallback ? args.valueCallback(key) : key;
1642
- value = options.valueCallback ? options.valueCallback(value) : value;
1643
- var rest = string.slice(matchedString.length);
1644
- return {
1645
- value: value,
1646
- rest: rest
1647
- };
1648
- };
1649
- }
1650
- function findKey(object, predicate) {
1651
- for (var key in object) {
1652
- if (object.hasOwnProperty(key) && predicate(object[key])) {
1653
- return key;
1654
- }
1655
- }
1656
- return undefined;
1657
- }
1658
- function findIndex(array, predicate) {
1659
- for (var key = 0; key < array.length; key++) {
1660
- if (predicate(array[key])) {
1661
- return key;
1662
- }
1663
- }
1664
- return undefined;
1665
- }
1666
-
1667
- function buildMatchPatternFn(args) {
1668
- return function (string) {
1669
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1670
- var matchResult = string.match(args.matchPattern);
1671
- if (!matchResult) return null;
1672
- var matchedString = matchResult[0];
1673
- var parseResult = string.match(args.parsePattern);
1674
- if (!parseResult) return null;
1675
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1676
- value = options.valueCallback ? options.valueCallback(value) : value;
1677
- var rest = string.slice(matchedString.length);
1678
- return {
1679
- value: value,
1680
- rest: rest
1681
- };
1682
- };
1683
- }
1684
-
1685
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1686
- var parseOrdinalNumberPattern = /\d+/i;
1687
- var matchEraPatterns = {
1688
- narrow: /^(b|a)/i,
1689
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1690
- wide: /^(before christ|before common era|anno domini|common era)/i
1691
- };
1692
- var parseEraPatterns = {
1693
- any: [/^b/i, /^(a|c)/i]
1694
- };
1695
- var matchQuarterPatterns = {
1696
- narrow: /^[1234]/i,
1697
- abbreviated: /^q[1234]/i,
1698
- wide: /^[1234](th|st|nd|rd)? quarter/i
1699
- };
1700
- var parseQuarterPatterns = {
1701
- any: [/1/i, /2/i, /3/i, /4/i]
1702
- };
1703
- var matchMonthPatterns = {
1704
- narrow: /^[jfmasond]/i,
1705
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1706
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1707
- };
1708
- var parseMonthPatterns = {
1709
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
1710
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
1711
- };
1712
- var matchDayPatterns = {
1713
- narrow: /^[smtwf]/i,
1714
- short: /^(su|mo|tu|we|th|fr|sa)/i,
1715
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1716
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1717
- };
1718
- var parseDayPatterns = {
1719
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1720
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1721
- };
1722
- var matchDayPeriodPatterns = {
1723
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1724
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1725
- };
1726
- var parseDayPeriodPatterns = {
1727
- any: {
1728
- am: /^a/i,
1729
- pm: /^p/i,
1730
- midnight: /^mi/i,
1731
- noon: /^no/i,
1732
- morning: /morning/i,
1733
- afternoon: /afternoon/i,
1734
- evening: /evening/i,
1735
- night: /night/i
1736
- }
1737
- };
1738
- var match = {
1739
- ordinalNumber: buildMatchPatternFn({
1740
- matchPattern: matchOrdinalNumberPattern,
1741
- parsePattern: parseOrdinalNumberPattern,
1742
- valueCallback: function valueCallback(value) {
1743
- return parseInt(value, 10);
1744
- }
1745
- }),
1746
- era: buildMatchFn({
1747
- matchPatterns: matchEraPatterns,
1748
- defaultMatchWidth: 'wide',
1749
- parsePatterns: parseEraPatterns,
1750
- defaultParseWidth: 'any'
1751
- }),
1752
- quarter: buildMatchFn({
1753
- matchPatterns: matchQuarterPatterns,
1754
- defaultMatchWidth: 'wide',
1755
- parsePatterns: parseQuarterPatterns,
1756
- defaultParseWidth: 'any',
1757
- valueCallback: function valueCallback(index) {
1758
- return index + 1;
1759
- }
1760
- }),
1761
- month: buildMatchFn({
1762
- matchPatterns: matchMonthPatterns,
1763
- defaultMatchWidth: 'wide',
1764
- parsePatterns: parseMonthPatterns,
1765
- defaultParseWidth: 'any'
1766
- }),
1767
- day: buildMatchFn({
1768
- matchPatterns: matchDayPatterns,
1769
- defaultMatchWidth: 'wide',
1770
- parsePatterns: parseDayPatterns,
1771
- defaultParseWidth: 'any'
1772
- }),
1773
- dayPeriod: buildMatchFn({
1774
- matchPatterns: matchDayPeriodPatterns,
1775
- defaultMatchWidth: 'any',
1776
- parsePatterns: parseDayPeriodPatterns,
1777
- defaultParseWidth: 'any'
1778
- })
1779
- };
1780
- const match$1 = match;
1781
-
1782
- /**
1783
- * @type {Locale}
1784
- * @category Locales
1785
- * @summary English locale (United States).
1786
- * @language English
1787
- * @iso-639-2 eng
1788
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1789
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1790
- */
1791
- var locale = {
1792
- code: 'en-US',
1793
- formatDistance: formatDistance$1,
1794
- formatLong: formatLong$1,
1795
- formatRelative: formatRelative$1,
1796
- localize: localize$1,
1797
- match: match$1,
1798
- options: {
1799
- weekStartsOn: 0 /* Sunday */,
1800
- firstWeekContainsDate: 1
1801
- }
1802
- };
1803
- const defaultLocale = locale;
1804
-
1805
- // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1806
- // (one of the certain letters followed by `o`)
1807
- // - (\w)\1* matches any sequences of the same letter
1808
- // - '' matches two quote characters in a row
1809
- // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1810
- // except a single quote symbol, which ends the sequence.
1811
- // Two quote characters do not end the sequence.
1812
- // If there is no matching single quote
1813
- // then the sequence will continue until the end of the string.
1814
- // - . matches any single character unmatched by previous parts of the RegExps
1815
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
1816
-
1817
- // This RegExp catches symbols escaped by quotes, and also
1818
- // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
1819
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1820
- var escapedStringRegExp = /^'([^]*?)'?$/;
1821
- var doubleQuoteRegExp = /''/g;
1822
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1823
-
1824
- /**
1825
- * @name format
1826
- * @category Common Helpers
1827
- * @summary Format the date.
1828
- *
1829
- * @description
1830
- * Return the formatted date string in the given format. The result may vary by locale.
1831
- *
1832
- * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1833
- * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
1834
- *
1835
- * The characters wrapped between two single quotes characters (') are escaped.
1836
- * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
1837
- * (see the last example)
1838
- *
1839
- * Format of the string is based on Unicode Technical Standard #35:
1840
- * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1841
- * with a few additions (see note 7 below the table).
1842
- *
1843
- * Accepted patterns:
1844
- * | Unit | Pattern | Result examples | Notes |
1845
- * |---------------------------------|---------|-----------------------------------|-------|
1846
- * | Era | G..GGG | AD, BC | |
1847
- * | | GGGG | Anno Domini, Before Christ | 2 |
1848
- * | | GGGGG | A, B | |
1849
- * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
1850
- * | | yo | 44th, 1st, 0th, 17th | 5,7 |
1851
- * | | yy | 44, 01, 00, 17 | 5 |
1852
- * | | yyy | 044, 001, 1900, 2017 | 5 |
1853
- * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
1854
- * | | yyyyy | ... | 3,5 |
1855
- * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
1856
- * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
1857
- * | | YY | 44, 01, 00, 17 | 5,8 |
1858
- * | | YYY | 044, 001, 1900, 2017 | 5 |
1859
- * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
1860
- * | | YYYYY | ... | 3,5 |
1861
- * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
1862
- * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
1863
- * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
1864
- * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
1865
- * | | RRRRR | ... | 3,5,7 |
1866
- * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
1867
- * | | uu | -43, 01, 1900, 2017 | 5 |
1868
- * | | uuu | -043, 001, 1900, 2017 | 5 |
1869
- * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
1870
- * | | uuuuu | ... | 3,5 |
1871
- * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
1872
- * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
1873
- * | | QQ | 01, 02, 03, 04 | |
1874
- * | | QQQ | Q1, Q2, Q3, Q4 | |
1875
- * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
1876
- * | | QQQQQ | 1, 2, 3, 4 | 4 |
1877
- * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
1878
- * | | qo | 1st, 2nd, 3rd, 4th | 7 |
1879
- * | | qq | 01, 02, 03, 04 | |
1880
- * | | qqq | Q1, Q2, Q3, Q4 | |
1881
- * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
1882
- * | | qqqqq | 1, 2, 3, 4 | 4 |
1883
- * | Month (formatting) | M | 1, 2, ..., 12 | |
1884
- * | | Mo | 1st, 2nd, ..., 12th | 7 |
1885
- * | | MM | 01, 02, ..., 12 | |
1886
- * | | MMM | Jan, Feb, ..., Dec | |
1887
- * | | MMMM | January, February, ..., December | 2 |
1888
- * | | MMMMM | J, F, ..., D | |
1889
- * | Month (stand-alone) | L | 1, 2, ..., 12 | |
1890
- * | | Lo | 1st, 2nd, ..., 12th | 7 |
1891
- * | | LL | 01, 02, ..., 12 | |
1892
- * | | LLL | Jan, Feb, ..., Dec | |
1893
- * | | LLLL | January, February, ..., December | 2 |
1894
- * | | LLLLL | J, F, ..., D | |
1895
- * | Local week of year | w | 1, 2, ..., 53 | |
1896
- * | | wo | 1st, 2nd, ..., 53th | 7 |
1897
- * | | ww | 01, 02, ..., 53 | |
1898
- * | ISO week of year | I | 1, 2, ..., 53 | 7 |
1899
- * | | Io | 1st, 2nd, ..., 53th | 7 |
1900
- * | | II | 01, 02, ..., 53 | 7 |
1901
- * | Day of month | d | 1, 2, ..., 31 | |
1902
- * | | do | 1st, 2nd, ..., 31st | 7 |
1903
- * | | dd | 01, 02, ..., 31 | |
1904
- * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
1905
- * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
1906
- * | | DD | 01, 02, ..., 365, 366 | 9 |
1907
- * | | DDD | 001, 002, ..., 365, 366 | |
1908
- * | | DDDD | ... | 3 |
1909
- * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
1910
- * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
1911
- * | | EEEEE | M, T, W, T, F, S, S | |
1912
- * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
1913
- * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
1914
- * | | io | 1st, 2nd, ..., 7th | 7 |
1915
- * | | ii | 01, 02, ..., 07 | 7 |
1916
- * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
1917
- * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
1918
- * | | iiiii | M, T, W, T, F, S, S | 7 |
1919
- * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
1920
- * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
1921
- * | | eo | 2nd, 3rd, ..., 1st | 7 |
1922
- * | | ee | 02, 03, ..., 01 | |
1923
- * | | eee | Mon, Tue, Wed, ..., Sun | |
1924
- * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
1925
- * | | eeeee | M, T, W, T, F, S, S | |
1926
- * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
1927
- * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
1928
- * | | co | 2nd, 3rd, ..., 1st | 7 |
1929
- * | | cc | 02, 03, ..., 01 | |
1930
- * | | ccc | Mon, Tue, Wed, ..., Sun | |
1931
- * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
1932
- * | | ccccc | M, T, W, T, F, S, S | |
1933
- * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
1934
- * | AM, PM | a..aa | AM, PM | |
1935
- * | | aaa | am, pm | |
1936
- * | | aaaa | a.m., p.m. | 2 |
1937
- * | | aaaaa | a, p | |
1938
- * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
1939
- * | | bbb | am, pm, noon, midnight | |
1940
- * | | bbbb | a.m., p.m., noon, midnight | 2 |
1941
- * | | bbbbb | a, p, n, mi | |
1942
- * | Flexible day period | B..BBB | at night, in the morning, ... | |
1943
- * | | BBBB | at night, in the morning, ... | 2 |
1944
- * | | BBBBB | at night, in the morning, ... | |
1945
- * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
1946
- * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
1947
- * | | hh | 01, 02, ..., 11, 12 | |
1948
- * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
1949
- * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
1950
- * | | HH | 00, 01, 02, ..., 23 | |
1951
- * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
1952
- * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
1953
- * | | KK | 01, 02, ..., 11, 00 | |
1954
- * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
1955
- * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
1956
- * | | kk | 24, 01, 02, ..., 23 | |
1957
- * | Minute | m | 0, 1, ..., 59 | |
1958
- * | | mo | 0th, 1st, ..., 59th | 7 |
1959
- * | | mm | 00, 01, ..., 59 | |
1960
- * | Second | s | 0, 1, ..., 59 | |
1961
- * | | so | 0th, 1st, ..., 59th | 7 |
1962
- * | | ss | 00, 01, ..., 59 | |
1963
- * | Fraction of second | S | 0, 1, ..., 9 | |
1964
- * | | SS | 00, 01, ..., 99 | |
1965
- * | | SSS | 000, 001, ..., 999 | |
1966
- * | | SSSS | ... | 3 |
1967
- * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
1968
- * | | XX | -0800, +0530, Z | |
1969
- * | | XXX | -08:00, +05:30, Z | |
1970
- * | | XXXX | -0800, +0530, Z, +123456 | 2 |
1971
- * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
1972
- * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
1973
- * | | xx | -0800, +0530, +0000 | |
1974
- * | | xxx | -08:00, +05:30, +00:00 | 2 |
1975
- * | | xxxx | -0800, +0530, +0000, +123456 | |
1976
- * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
1977
- * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
1978
- * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
1979
- * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
1980
- * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
1981
- * | Seconds timestamp | t | 512969520 | 7 |
1982
- * | | tt | ... | 3,7 |
1983
- * | Milliseconds timestamp | T | 512969520900 | 7 |
1984
- * | | TT | ... | 3,7 |
1985
- * | Long localized date | P | 04/29/1453 | 7 |
1986
- * | | PP | Apr 29, 1453 | 7 |
1987
- * | | PPP | April 29th, 1453 | 7 |
1988
- * | | PPPP | Friday, April 29th, 1453 | 2,7 |
1989
- * | Long localized time | p | 12:00 AM | 7 |
1990
- * | | pp | 12:00:00 AM | 7 |
1991
- * | | ppp | 12:00:00 AM GMT+2 | 7 |
1992
- * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
1993
- * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
1994
- * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
1995
- * | | PPPppp | April 29th, 1453 at ... | 7 |
1996
- * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
1997
- * Notes:
1998
- * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
1999
- * are the same as "stand-alone" units, but are different in some languages.
2000
- * "Formatting" units are declined according to the rules of the language
2001
- * in the context of a date. "Stand-alone" units are always nominative singular:
2002
- *
2003
- * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2004
- *
2005
- * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2006
- *
2007
- * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2008
- * the single quote characters (see below).
2009
- * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2010
- * the output will be the same as default pattern for this unit, usually
2011
- * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2012
- * are marked with "2" in the last column of the table.
2013
- *
2014
- * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2015
- *
2016
- * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2017
- *
2018
- * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2019
- *
2020
- * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2021
- *
2022
- * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2023
- *
2024
- * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2025
- * The output will be padded with zeros to match the length of the pattern.
2026
- *
2027
- * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2028
- *
2029
- * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2030
- * These tokens represent the shortest form of the quarter.
2031
- *
2032
- * 5. The main difference between `y` and `u` patterns are B.C. years:
2033
- *
2034
- * | Year | `y` | `u` |
2035
- * |------|-----|-----|
2036
- * | AC 1 | 1 | 1 |
2037
- * | BC 1 | 1 | 0 |
2038
- * | BC 2 | 2 | -1 |
2039
- *
2040
- * Also `yy` always returns the last two digits of a year,
2041
- * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2042
- *
2043
- * | Year | `yy` | `uu` |
2044
- * |------|------|------|
2045
- * | 1 | 01 | 01 |
2046
- * | 14 | 14 | 14 |
2047
- * | 376 | 76 | 376 |
2048
- * | 1453 | 53 | 1453 |
2049
- *
2050
- * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2051
- * except local week-numbering years are dependent on `options.weekStartsOn`
2052
- * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2053
- * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2054
- *
2055
- * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2056
- * so right now these tokens fall back to GMT timezones.
2057
- *
2058
- * 7. These patterns are not in the Unicode Technical Standard #35:
2059
- * - `i`: ISO day of week
2060
- * - `I`: ISO week of year
2061
- * - `R`: ISO week-numbering year
2062
- * - `t`: seconds timestamp
2063
- * - `T`: milliseconds timestamp
2064
- * - `o`: ordinal number modifier
2065
- * - `P`: long localized date
2066
- * - `p`: long localized time
2067
- *
2068
- * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2069
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2070
- *
2071
- * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2072
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2073
- *
2074
- * @param {Date|Number} date - the original date
2075
- * @param {String} format - the string of tokens
2076
- * @param {Object} [options] - an object with options.
2077
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2078
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2079
- * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2080
- * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2081
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2082
- * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2083
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2084
- * @returns {String} the formatted date string
2085
- * @throws {TypeError} 2 arguments required
2086
- * @throws {RangeError} `date` must not be Invalid Date
2087
- * @throws {RangeError} `options.locale` must contain `localize` property
2088
- * @throws {RangeError} `options.locale` must contain `formatLong` property
2089
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2090
- * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2091
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2092
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2093
- * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2094
- * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2095
- * @throws {RangeError} format string contains an unescaped latin alphabet character
2096
- *
2097
- * @example
2098
- * // Represent 11 February 2014 in middle-endian format:
2099
- * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2100
- * //=> '02/11/2014'
2101
- *
2102
- * @example
2103
- * // Represent 2 July 2014 in Esperanto:
2104
- * import { eoLocale } from 'date-fns/locale/eo'
2105
- * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2106
- * locale: eoLocale
2107
- * })
2108
- * //=> '2-a de julio 2014'
2109
- *
2110
- * @example
2111
- * // Escape string by single quote characters:
2112
- * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2113
- * //=> "3 o'clock"
2114
- */
2115
-
2116
- function format(dirtyDate, dirtyFormatStr, options) {
2117
- var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2118
- requiredArgs(2, arguments);
2119
- var formatStr = String(dirtyFormatStr);
2120
- var defaultOptions = getDefaultOptions();
2121
- var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;
2122
- var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2123
-
2124
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2125
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2126
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2127
- }
2128
- var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2129
-
2130
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2131
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2132
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2133
- }
2134
- if (!locale.localize) {
2135
- throw new RangeError('locale must contain localize property');
2136
- }
2137
- if (!locale.formatLong) {
2138
- throw new RangeError('locale must contain formatLong property');
2139
- }
2140
- var originalDate = toDate(dirtyDate);
2141
- if (!isValid(originalDate)) {
2142
- throw new RangeError('Invalid time value');
2143
- }
2144
-
2145
- // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2146
- // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2147
- // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2148
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2149
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
2150
- var formatterOptions = {
2151
- firstWeekContainsDate: firstWeekContainsDate,
2152
- weekStartsOn: weekStartsOn,
2153
- locale: locale,
2154
- _originalDate: originalDate
2155
- };
2156
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2157
- var firstCharacter = substring[0];
2158
- if (firstCharacter === 'p' || firstCharacter === 'P') {
2159
- var longFormatter = longFormatters$1[firstCharacter];
2160
- return longFormatter(substring, locale.formatLong);
2161
- }
2162
- return substring;
2163
- }).join('').match(formattingTokensRegExp).map(function (substring) {
2164
- // Replace two single quote characters with one single quote character
2165
- if (substring === "''") {
2166
- return "'";
2167
- }
2168
- var firstCharacter = substring[0];
2169
- if (firstCharacter === "'") {
2170
- return cleanEscapedString(substring);
2171
- }
2172
- var formatter = formatters$1[firstCharacter];
2173
- if (formatter) {
2174
- if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2175
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2176
- }
2177
- if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2178
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2179
- }
2180
- return formatter(utcDate, substring, locale.localize, formatterOptions);
2181
- }
2182
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2183
- throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2184
- }
2185
- return substring;
2186
- }).join('');
2187
- return result;
2188
- }
2189
- function cleanEscapedString(input) {
2190
- var matched = input.match(escapedStringRegExp);
2191
- if (!matched) {
2192
- return input;
2193
- }
2194
- return matched[1].replace(doubleQuoteRegExp, "'");
2195
- }
2196
-
2197
- /**
2198
- * Default values for all Dinero objects.
2199
- *
2200
- * You can override default values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
2201
- * Existing instances won't be affected.
2202
- *
2203
- * @property {Number} defaultAmount - The default amount for new Dinero objects (see {@link module:Dinero Dinero} for format).
2204
- * @property {String} defaultCurrency - The default currency for new Dinero objects (see {@link module:Dinero Dinero} for format).
2205
- * @property {Number} defaultPrecision - The default precision for new Dinero objects (see {@link module:Dinero Dinero} for format).
2206
- *
2207
- * @example
2208
- * // Will set currency to 'EUR' for all Dinero objects.
2209
- * Dinero.defaultCurrency = 'EUR'
2210
- *
2211
- * @type {Object}
2212
- */
2213
- var Defaults = {
2214
- defaultAmount: 0,
2215
- defaultCurrency: 'USD',
2216
- defaultPrecision: 2
2217
- };
2218
- /**
2219
- * Global settings for all Dinero objects.
2220
- *
2221
- * You can override global values for all subsequent Dinero objects by changing them directly on the global `Dinero` object.
2222
- * Existing instances won't be affected.
2223
- *
2224
- * @property {String} globalLocale - The global locale for new Dinero objects (see {@link module:Dinero~setLocale setLocale} for format).
2225
- * @property {String} globalFormat - The global format for new Dinero objects (see {@link module:Dinero~toFormat toFormat} for format).
2226
- * @property {String} globalRoundingMode - The global rounding mode for new Dinero objects (see {@link module:Dinero~multiply multiply} or {@link module:Dinero~divide divide} for format).
2227
- * @property {String} globalFormatRoundingMode - The global rounding mode to format new Dinero objects (see {@link module:Dinero~toFormat toFormat} or {@link module:Dinero~toRoundedUnit toRoundedUnit} for format).
2228
- * @property {(String|Promise)} globalExchangeRatesApi.endpoint - The global exchange rate API endpoint for new Dinero objects, or the global promise that resolves to the exchanges rates (see {@link module:Dinero~convert convert} for format).
2229
- * @property {String} globalExchangeRatesApi.propertyPath - The global exchange rate API property path for new Dinero objects (see {@link module:Dinero~convert convert} for format).
2230
- * @property {Object} globalExchangeRatesApi.headers - The global exchange rate API headers for new Dinero objects (see {@link module:Dinero~convert convert} for format).
2231
- *
2232
- * @example
2233
- * // Will set locale to 'fr-FR' for all Dinero objects.
2234
- * Dinero.globalLocale = 'fr-FR'
2235
- * @example
2236
- * // Will set global exchange rate API parameters for all Dinero objects.
2237
- * Dinero.globalExchangeRatesApi = {
2238
- * endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
2239
- * propertyPath: 'data.rates.{{to}}',
2240
- * headers: {
2241
- * 'user-key': 'xxxxxxxxx'
2242
- * }
2243
- * }
2244
- *
2245
- * @type {Object}
2246
- */
2247
-
2248
- var Globals = {
2249
- globalLocale: 'en-US',
2250
- globalFormat: '$0,0.00',
2251
- globalRoundingMode: 'HALF_EVEN',
2252
- globalFormatRoundingMode: 'HALF_AWAY_FROM_ZERO',
2253
- globalExchangeRatesApi: {
2254
- endpoint: undefined,
2255
- headers: undefined,
2256
- propertyPath: undefined
2257
- }
2258
- };
2259
-
2260
- function _typeof(obj) {
2261
- "@babel/helpers - typeof";
2262
-
2263
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
2264
- _typeof = function (obj) {
2265
- return typeof obj;
2266
- };
2267
- } else {
2268
- _typeof = function (obj) {
2269
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2270
- };
2271
- }
2272
-
2273
- return _typeof(obj);
2274
- }
2275
-
2276
- function _toArray(arr) {
2277
- return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
2278
- }
2279
-
2280
- function _arrayWithHoles(arr) {
2281
- if (Array.isArray(arr)) return arr;
2282
- }
2283
-
2284
- function _iterableToArray(iter) {
2285
- if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
2286
- }
2287
-
2288
- function _unsupportedIterableToArray(o, minLen) {
2289
- if (!o) return;
2290
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2291
- var n = Object.prototype.toString.call(o).slice(8, -1);
2292
- if (n === "Object" && o.constructor) n = o.constructor.name;
2293
- if (n === "Map" || n === "Set") return Array.from(o);
2294
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2295
- }
2296
-
2297
- function _arrayLikeToArray(arr, len) {
2298
- if (len == null || len > arr.length) len = arr.length;
2299
-
2300
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2301
-
2302
- return arr2;
2303
- }
2304
-
2305
- function _nonIterableRest() {
2306
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2307
- }
2308
-
2309
- /**
2310
- * Static methods for Dinero.
2311
- * @ignore
2312
- *
2313
- * @type {Object}
2314
- */
2315
- var Static = {
2316
- /**
2317
- * Returns an array of Dinero objects, normalized to the same precision (the highest).
2318
- *
2319
- * @memberof module:Dinero
2320
- * @method
2321
- *
2322
- * @param {Dinero[]} objects - An array of Dinero objects
2323
- *
2324
- * @example
2325
- * // returns an array of Dinero objects
2326
- * // both with a precision of 3
2327
- * // and an amount of 1000
2328
- * Dinero.normalizePrecision([
2329
- * Dinero({ amount: 100, precision: 2 }),
2330
- * Dinero({ amount: 1000, precision: 3 })
2331
- * ])
2332
- *
2333
- * @return {Dinero[]}
2334
- */
2335
- normalizePrecision: function normalizePrecision(objects) {
2336
- var highestPrecision = objects.reduce(function (a, b) {
2337
- return Math.max(a.getPrecision(), b.getPrecision());
2338
- });
2339
- return objects.map(function (object) {
2340
- return object.getPrecision() !== highestPrecision ? object.convertPrecision(highestPrecision) : object;
2341
- });
2342
- },
2343
-
2344
- /**
2345
- * Returns the smallest Dinero object from an array of Dinero objects
2346
- *
2347
- * @memberof module:Dinero
2348
- * @method
2349
- *
2350
- * @param {Dinero[]} objects - An array of Dinero objects
2351
- *
2352
- * @example
2353
- * // returns the smallest Dinero object with amount of 500 from an array of Dinero objects with different precisions
2354
- * Dinero.minimum([
2355
- * Dinero({ amount: 500, precision: 3 }),
2356
- * Dinero({ amount: 100, precision: 2 })
2357
- * ])
2358
- * @example
2359
- * // returns the smallest Dinero object with amount of 50 from an array of Dinero objects
2360
- * Dinero.minimum([
2361
- * Dinero({ amount: 50 }),
2362
- * Dinero({ amount: 100 })
2363
- * ])
2364
- *
2365
- * @return {Dinero[]}
2366
- */
2367
- minimum: function minimum(objects) {
2368
- var _objects = _toArray(objects),
2369
- firstObject = _objects[0],
2370
- tailObjects = _objects.slice(1);
2371
-
2372
- var currentMinimum = firstObject;
2373
- tailObjects.forEach(function (obj) {
2374
- currentMinimum = currentMinimum.lessThan(obj) ? currentMinimum : obj;
2375
- });
2376
- return currentMinimum;
2377
- },
2378
-
2379
- /**
2380
- * Returns the biggest Dinero object from an array of Dinero objects
2381
- *
2382
- * @memberof module:Dinero
2383
- * @method
2384
- *
2385
- * @param {Dinero[]} objects - An array of Dinero objects
2386
- *
2387
- * @example
2388
- * // returns the biggest Dinero object with amount of 20, from an array of Dinero objects with different precisions
2389
- * Dinero.maximum([
2390
- * Dinero({ amount: 20, precision: 2 }),
2391
- * Dinero({ amount: 150, precision: 3 })
2392
- * ])
2393
- * @example
2394
- * // returns the biggest Dinero object with amount of 100, from an array of Dinero objects
2395
- * Dinero.maximum([
2396
- * Dinero({ amount: 100 }),
2397
- * Dinero({ amount: 50 })
2398
- * ])
2399
- *
2400
- * @return {Dinero[]}
2401
- */
2402
- maximum: function maximum(objects) {
2403
- var _objects2 = _toArray(objects),
2404
- firstObject = _objects2[0],
2405
- tailObjects = _objects2.slice(1);
2406
-
2407
- var currentMaximum = firstObject;
2408
- tailObjects.forEach(function (obj) {
2409
- currentMaximum = currentMaximum.greaterThan(obj) ? currentMaximum : obj;
2410
- });
2411
- return currentMaximum;
2412
- }
2413
- };
2414
-
2415
- /**
2416
- * Returns whether a value is numeric.
2417
- * @ignore
2418
- *
2419
- * @param {} value - The value to test.
2420
- *
2421
- * @return {Boolean}
2422
- */
2423
- function isNumeric(value) {
2424
- return !isNaN(parseInt(value)) && isFinite(value);
2425
- }
2426
- /**
2427
- * Returns whether a value is a percentage.
2428
- * @ignore
2429
- *
2430
- * @param {} percentage - The percentage to test.
2431
- *
2432
- * @return {Boolean}
2433
- */
2434
-
2435
- function isPercentage(percentage) {
2436
- return isNumeric(percentage) && percentage <= 100 && percentage >= 0;
2437
- }
2438
- /**
2439
- * Returns whether an array of ratios is valid.
2440
- * @ignore
2441
- *
2442
- * @param {} ratios - The ratios to test.
2443
- *
2444
- * @return {Boolean}
2445
- */
2446
-
2447
- function areValidRatios(ratios) {
2448
- return ratios.length > 0 && ratios.every(function (ratio) {
2449
- return ratio >= 0;
2450
- }) && ratios.some(function (ratio) {
2451
- return ratio > 0;
2452
- });
2453
- }
2454
- /**
2455
- * Returns whether a value is even.
2456
- * @ignore
2457
- *
2458
- * @param {Number} value - The value to test.
2459
- *
2460
- * @return {Boolean}
2461
- */
2462
-
2463
- function isEven(value) {
2464
- return value % 2 === 0;
2465
- }
2466
- /**
2467
- * Returns whether a value is a float.
2468
- * @ignore
2469
- *
2470
- * @param {} value - The value to test.
2471
- *
2472
- * @return {Boolean}
2473
- */
2474
-
2475
- function isFloat(value) {
2476
- return isNumeric(value) && !Number.isInteger(value);
2477
- }
2478
- /**
2479
- * Returns how many fraction digits a number has.
2480
- * @ignore
2481
- *
2482
- * @param {Number} [number=0] - The number to test.
2483
- *
2484
- * @return {Number}
2485
- */
2486
-
2487
- function countFractionDigits() {
2488
- var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2489
- var stringRepresentation = number.toString();
2490
-
2491
- if (stringRepresentation.indexOf('e-') > 0) {
2492
- // It's too small for a normal string representation, e.g. 1e-7 instead of 0.00000001
2493
- return parseInt(stringRepresentation.split('e-')[1]);
2494
- } else {
2495
- var fractionDigits = stringRepresentation.split('.')[1];
2496
- return fractionDigits ? fractionDigits.length : 0;
2497
- }
2498
- }
2499
- /**
2500
- * Returns whether a number is half.
2501
- * @ignore
2502
- *
2503
- * @param {Number} number - The number to test.
2504
- *
2505
- * @return {Number}
2506
- */
2507
-
2508
- function isHalf(number) {
2509
- return Math.abs(number) % 1 === 0.5;
2510
- }
2511
- /**
2512
- * Fetches a JSON resource.
2513
- * @ignore
2514
- *
2515
- * @param {String} url - The resource to fetch.
2516
- * @param {Object} [options.headers] - The headers to pass.
2517
- *
2518
- * @throws {Error} If `request.status` is lesser than 200 or greater or equal to 400.
2519
- * @throws {Error} If network fails.
2520
- *
2521
- * @return {JSON}
2522
- */
2523
-
2524
- function getJSON(url) {
2525
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2526
- return new Promise(function (resolve, reject) {
2527
- var request = Object.assign(new XMLHttpRequest(), {
2528
- onreadystatechange: function onreadystatechange() {
2529
- if (request.readyState === 4) {
2530
- if (request.status >= 200 && request.status < 400) resolve(JSON.parse(request.responseText));else reject(new Error(request.statusText));
2531
- }
2532
- },
2533
- onerror: function onerror() {
2534
- reject(new Error('Network error'));
2535
- }
2536
- });
2537
- request.open('GET', url, true);
2538
- setXHRHeaders(request, options.headers);
2539
- request.send();
2540
- });
2541
- }
2542
- /**
2543
- * Returns an XHR object with attached headers.
2544
- * @ignore
2545
- *
2546
- * @param {XMLHttpRequest} xhr - The XHR request to set headers to.
2547
- * @param {Object} headers - The headers to set.
2548
- *
2549
- * @return {XMLHttpRequest}
2550
- */
2551
-
2552
- function setXHRHeaders(xhr) {
2553
- var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2554
-
2555
- for (var header in headers) {
2556
- xhr.setRequestHeader(header, headers[header]);
2557
- }
2558
-
2559
- return xhr;
2560
- }
2561
- /**
2562
- * Returns whether a value is undefined.
2563
- * @ignore
2564
- *
2565
- * @param {} value - The value to test.
2566
- *
2567
- * @return {Boolean}
2568
- */
2569
-
2570
- function isUndefined(value) {
2571
- return typeof value === 'undefined';
2572
- }
2573
- /**
2574
- * Returns an object flattened to one level deep.
2575
- * @ignore
2576
- *
2577
- * @param {Object} object - The object to flatten.
2578
- * @param {String} separator - The separator to use between flattened nodes.
2579
- *
2580
- * @return {Object}
2581
- */
2582
-
2583
- function flattenObject(object) {
2584
- var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
2585
- var finalObject = {};
2586
- Object.entries(object).forEach(function (item) {
2587
- if (_typeof(item[1]) === 'object') {
2588
- var flatObject = flattenObject(item[1]);
2589
- Object.entries(flatObject).forEach(function (node) {
2590
- finalObject[item[0] + separator + node[0]] = node[1];
2591
- });
2592
- } else {
2593
- finalObject[item[0]] = item[1];
2594
- }
2595
- });
2596
- return finalObject;
2597
- }
2598
- /**
2599
- * Returns whether a value is thenable.
2600
- * @ignore
2601
- *
2602
- * @param {} value - The value to test.
2603
- *
2604
- * @return {Boolean}
2605
- */
2606
-
2607
- function isThenable(value) {
2608
- return Boolean(value) && (_typeof(value) === 'object' || typeof value === 'function') && typeof value.then === 'function';
2609
- }
2610
-
2611
- function Calculator() {
2612
- var floatMultiply = function floatMultiply(a, b) {
2613
- var getFactor = function getFactor(number) {
2614
- return Math.pow(10, countFractionDigits(number));
2615
- };
2616
-
2617
- var factor = Math.max(getFactor(a), getFactor(b));
2618
- return Math.round(a * factor) * Math.round(b * factor) / (factor * factor);
2619
- };
2620
-
2621
- var roundingModes = {
2622
- HALF_ODD: function HALF_ODD(number) {
2623
- var rounded = Math.round(number);
2624
- return isHalf(number) ? isEven(rounded) ? rounded - 1 : rounded : rounded;
2625
- },
2626
- HALF_EVEN: function HALF_EVEN(number) {
2627
- var rounded = Math.round(number);
2628
- return isHalf(number) ? isEven(rounded) ? rounded : rounded - 1 : rounded;
2629
- },
2630
- HALF_UP: function HALF_UP(number) {
2631
- return Math.round(number);
2632
- },
2633
- HALF_DOWN: function HALF_DOWN(number) {
2634
- return isHalf(number) ? Math.floor(number) : Math.round(number);
2635
- },
2636
- HALF_TOWARDS_ZERO: function HALF_TOWARDS_ZERO(number) {
2637
- return isHalf(number) ? Math.sign(number) * Math.floor(Math.abs(number)) : Math.round(number);
2638
- },
2639
- HALF_AWAY_FROM_ZERO: function HALF_AWAY_FROM_ZERO(number) {
2640
- return isHalf(number) ? Math.sign(number) * Math.ceil(Math.abs(number)) : Math.round(number);
2641
- },
2642
- DOWN: function DOWN(number) {
2643
- return Math.floor(number);
2644
- }
2645
- };
2646
- return {
2647
- /**
2648
- * Returns the sum of two numbers.
2649
- * @ignore
2650
- *
2651
- * @param {Number} a - The first number to add.
2652
- * @param {Number} b - The second number to add.
2653
- *
2654
- * @return {Number}
2655
- */
2656
- add: function add(a, b) {
2657
- return a + b;
2658
- },
2659
-
2660
- /**
2661
- * Returns the difference of two numbers.
2662
- * @ignore
2663
- *
2664
- * @param {Number} a - The first number to subtract.
2665
- * @param {Number} b - The second number to subtract.
2666
- *
2667
- * @return {Number}
2668
- */
2669
- subtract: function subtract(a, b) {
2670
- return a - b;
2671
- },
2672
-
2673
- /**
2674
- * Returns the product of two numbers.
2675
- * @ignore
2676
- *
2677
- * @param {Number} a - The first number to multiply.
2678
- * @param {Number} b - The second number to multiply.
2679
- *
2680
- * @return {Number}
2681
- */
2682
- multiply: function multiply(a, b) {
2683
- return isFloat(a) || isFloat(b) ? floatMultiply(a, b) : a * b;
2684
- },
2685
-
2686
- /**
2687
- * Returns the quotient of two numbers.
2688
- * @ignore
2689
- *
2690
- * @param {Number} a - The first number to divide.
2691
- * @param {Number} b - The second number to divide.
2692
- *
2693
- * @return {Number}
2694
- */
2695
- divide: function divide(a, b) {
2696
- return a / b;
2697
- },
2698
-
2699
- /**
2700
- * Returns the remainder of two numbers.
2701
- * @ignore
2702
- *
2703
- * @param {Number} a - The first number to divide.
2704
- * @param {Number} b - The second number to divide.
2705
- *
2706
- * @return {Number}
2707
- */
2708
- modulo: function modulo(a, b) {
2709
- return a % b;
2710
- },
2711
-
2712
- /**
2713
- * Returns a rounded number based off a specific rounding mode.
2714
- * @ignore
2715
- *
2716
- * @param {Number} number - The number to round.
2717
- * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use.
2718
- *
2719
- * @returns {Number}
2720
- */
2721
- round: function round(number) {
2722
- var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HALF_EVEN';
2723
- return roundingModes[roundingMode](number);
2724
- }
2725
- };
2726
- }
2727
-
2728
- var calculator = Calculator();
2729
- function Format(format) {
2730
- var matches = /^(?:(\$|USD)?0(?:(,)0)?(\.)?(0+)?|0(?:(,)0)?(\.)?(0+)?\s?(dollar)?)$/gm.exec(format);
2731
- return {
2732
- /**
2733
- * Returns the matches.
2734
- * @ignore
2735
- *
2736
- * @return {Array}
2737
- */
2738
- getMatches: function getMatches() {
2739
- return matches !== null ? matches.slice(1).filter(function (match) {
2740
- return !isUndefined(match);
2741
- }) : [];
2742
- },
2743
-
2744
- /**
2745
- * Returns the amount of fraction digits to display.
2746
- * @ignore
2747
- *
2748
- * @return {Number}
2749
- */
2750
- getMinimumFractionDigits: function getMinimumFractionDigits() {
2751
- var decimalPosition = function decimalPosition(match) {
2752
- return match === '.';
2753
- };
2754
-
2755
- return !isUndefined(this.getMatches().find(decimalPosition)) ? this.getMatches()[calculator.add(this.getMatches().findIndex(decimalPosition), 1)].split('').length : 0;
2756
- },
2757
-
2758
- /**
2759
- * Returns the currency display mode.
2760
- * @ignore
2761
- *
2762
- * @return {String}
2763
- */
2764
- getCurrencyDisplay: function getCurrencyDisplay() {
2765
- var modes = {
2766
- USD: 'code',
2767
- dollar: 'name',
2768
- $: 'symbol'
2769
- };
2770
- return modes[this.getMatches().find(function (match) {
2771
- return match === 'USD' || match === 'dollar' || match === '$';
2772
- })];
2773
- },
2774
-
2775
- /**
2776
- * Returns the formatting style.
2777
- * @ignore
2778
- *
2779
- * @return {String}
2780
- */
2781
- getStyle: function getStyle() {
2782
- return !isUndefined(this.getCurrencyDisplay(this.getMatches())) ? 'currency' : 'decimal';
2783
- },
2784
-
2785
- /**
2786
- * Returns whether grouping should be used or not.
2787
- * @ignore
2788
- *
2789
- * @return {Boolean}
2790
- */
2791
- getUseGrouping: function getUseGrouping() {
2792
- return !isUndefined(this.getMatches().find(function (match) {
2793
- return match === ',';
2794
- }));
2795
- }
2796
- };
2797
- }
2798
-
2799
- function CurrencyConverter(options) {
2800
- /* istanbul ignore next */
2801
- var mergeTags = function mergeTags() {
2802
- var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2803
- var tags = arguments.length > 1 ? arguments[1] : undefined;
2804
-
2805
- for (var tag in tags) {
2806
- string = string.replace("{{".concat(tag, "}}"), tags[tag]);
2807
- }
2808
-
2809
- return string;
2810
- };
2811
- /* istanbul ignore next */
2812
-
2813
-
2814
- var getRatesFromRestApi = function getRatesFromRestApi(from, to) {
2815
- return getJSON(mergeTags(options.endpoint, {
2816
- from: from,
2817
- to: to
2818
- }), {
2819
- headers: options.headers
2820
- });
2821
- };
2822
-
2823
- return {
2824
- /**
2825
- * Returns the exchange rate.
2826
- * @ignore
2827
- *
2828
- * @param {String} from - The base currency.
2829
- * @param {String} to - The destination currency.
2830
- *
2831
- * @return {Promise}
2832
- */
2833
- getExchangeRate: function getExchangeRate(from, to) {
2834
- return (isThenable(options.endpoint) ? options.endpoint : getRatesFromRestApi(from, to)).then(function (data) {
2835
- return flattenObject(data)[mergeTags(options.propertyPath, {
2836
- from: from,
2837
- to: to
2838
- })];
2839
- });
2840
- }
2841
- };
2842
- }
2843
-
2844
- /**
2845
- * Performs an assertion.
2846
- * @ignore
2847
- *
2848
- * @param {Boolean} condition - The expression to assert.
2849
- * @param {String} errorMessage - The message to throw if the assertion fails
2850
- * @param {ErrorConstructor} [ErrorType=Error] - The error to throw if the assertion fails.
2851
- *
2852
- * @throws {Error} If `condition` returns `false`.
2853
- */
2854
-
2855
- function assert(condition, errorMessage) {
2856
- var ErrorType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Error;
2857
- if (!condition) throw new ErrorType(errorMessage);
2858
- }
2859
- /**
2860
- * Asserts a value is a percentage.
2861
- * @ignore
2862
- *
2863
- * @param {} percentage - The percentage to test.
2864
- *
2865
- * @throws {RangeError} If `percentage` is out of range.
2866
- */
2867
-
2868
- function assertPercentage(percentage) {
2869
- assert(isPercentage(percentage), 'You must provide a numeric value between 0 and 100.', RangeError);
2870
- }
2871
- /**
2872
- * Asserts an array of ratios is valid.
2873
- * @ignore
2874
- *
2875
- * @param {} ratios - The ratios to test.
2876
- *
2877
- * @throws {TypeError} If `ratios` are invalid.
2878
- */
2879
-
2880
- function assertValidRatios(ratios) {
2881
- assert(areValidRatios(ratios), 'You must provide a non-empty array of numeric values greater than 0.', TypeError);
2882
- }
2883
- /**
2884
- * Asserts a value is an integer.
2885
- * @ignore
2886
- *
2887
- * @param {} number - The value to test.
2888
- *
2889
- * @throws {TypeError}
2890
- */
2891
-
2892
- function assertInteger(number) {
2893
- assert(Number.isInteger(number), 'You must provide an integer.', TypeError);
2894
- }
2895
-
2896
- var calculator$1 = Calculator();
2897
- /**
2898
- * A Dinero object is an immutable data structure representing a specific monetary value.
2899
- * It comes with methods for creating, parsing, manipulating, testing, transforming and formatting them.
2900
- *
2901
- * A Dinero object has:
2902
- *
2903
- * * An `amount`, expressed in minor currency units, as an integer.
2904
- * * A `currency`, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
2905
- * * A `precision`, expressed as an integer, to represent the number of decimal places in the `amount`.
2906
- * This is helpful when you want to represent fractional minor currency units (e.g.: $10.4545).
2907
- * You can also use it to represent a currency with a different [exponent](https://en.wikipedia.org/wiki/ISO_4217#Treatment_of_minor_currency_units_.28the_.22exponent.22.29) than `2` (e.g.: Iraqi dinar with 1000 fils in 1 dinar (exponent of `3`), Japanese yen with no sub-units (exponent of `0`)).
2908
- * * An optional `locale` property that affects how output strings are formatted.
2909
- *
2910
- * Here's an overview of the public API:
2911
- *
2912
- * * **Access:** {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~getCurrency getCurrency}, {@link module:Dinero~getLocale getLocale} and {@link module:Dinero~getPrecision getPrecision}.
2913
- * * **Manipulation:** {@link module:Dinero~add add}, {@link module:Dinero~subtract subtract}, {@link module:Dinero~multiply multiply}, {@link module:Dinero~divide divide}, {@link module:Dinero~percentage percentage}, {@link module:Dinero~allocate allocate} and {@link module:Dinero~convert convert}.
2914
- * * **Testing:** {@link module:Dinero~equalsTo equalsTo}, {@link module:Dinero~lessThan lessThan}, {@link module:Dinero~lessThanOrEqual lessThanOrEqual}, {@link module:Dinero~greaterThan greaterThan}, {@link module:Dinero~greaterThanOrEqual greaterThanOrEqual}, {@link module:Dinero~isZero isZero}, {@link module:Dinero~isPositive isPositive}, {@link module:Dinero~isNegative isNegative}, {@link module:Dinero~hasSubUnits hasSubUnits}, {@link module:Dinero~hasSameCurrency hasSameCurrency} and {@link module:Dinero~hasSameAmount hasSameAmount}.
2915
- * * **Configuration:** {@link module:Dinero~setLocale setLocale}.
2916
- * * **Conversion & formatting:** {@link module:Dinero~toFormat toFormat}, {@link module:Dinero~toUnit toUnit}, {@link module:Dinero~toRoundedUnit toRoundedUnit}, {@link module:Dinero~toObject toObject}, {@link module:Dinero~toJSON toJSON}, {@link module:Dinero~convertPrecision convertPrecision} and {@link module:Dinero.normalizePrecision normalizePrecision}.
2917
- *
2918
- * Dinero.js uses `number`s under the hood, so it's constrained by the [double-precision floating-point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format). Using values over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) will yield unpredictable results.
2919
- * Same goes with performing calculations: once the internal `amount` value exceeds those limits, precision is no longer guaranteed.
2920
- *
2921
- * @module Dinero
2922
- * @param {Number} [options.amount=0] - The amount in minor currency units (as an integer).
2923
- * @param {String} [options.currency='USD'] - An ISO 4217 currency code.
2924
- * @param {String} [options.precision=2] - The number of decimal places to represent.
2925
- *
2926
- * @throws {TypeError} If `amount` or `precision` is invalid. Integers over [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MAX_SAFE_INTEGER) or below [`Number.MIN_SAFE_INTEGER`](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Number/MIN_SAFE_INTEGER) are considered valid, even though they can lead to imprecise amounts.
2927
- *
2928
- * @return {Object}
2929
- */
2930
-
2931
- var Dinero = function Dinero(options) {
2932
- var _Object$assign = Object.assign({}, {
2933
- amount: Dinero.defaultAmount,
2934
- currency: Dinero.defaultCurrency,
2935
- precision: Dinero.defaultPrecision
2936
- }, options),
2937
- amount = _Object$assign.amount,
2938
- currency = _Object$assign.currency,
2939
- precision = _Object$assign.precision;
2940
-
2941
- assertInteger(amount);
2942
- assertInteger(precision);
2943
- var globalLocale = Dinero.globalLocale,
2944
- globalFormat = Dinero.globalFormat,
2945
- globalRoundingMode = Dinero.globalRoundingMode,
2946
- globalFormatRoundingMode = Dinero.globalFormatRoundingMode;
2947
- var globalExchangeRatesApi = Object.assign({}, Dinero.globalExchangeRatesApi);
2948
- /**
2949
- * Uses ES5 function notation so `this` can be passed through call, apply and bind
2950
- * @ignore
2951
- */
2952
-
2953
- var create = function create(options) {
2954
- var obj = Object.assign({}, Object.assign({}, {
2955
- amount: amount,
2956
- currency: currency,
2957
- precision: precision
2958
- }, options), Object.assign({}, {
2959
- locale: this.locale
2960
- }, options));
2961
- return Object.assign(Dinero({
2962
- amount: obj.amount,
2963
- currency: obj.currency,
2964
- precision: obj.precision
2965
- }), {
2966
- locale: obj.locale
2967
- });
2968
- };
2969
- /**
2970
- * Uses ES5 function notation so `this` can be passed through call, apply and bind
2971
- * @ignore
2972
- */
2973
-
2974
-
2975
- var assertSameCurrency = function assertSameCurrency(comparator) {
2976
- assert(this.hasSameCurrency(comparator), 'You must provide a Dinero instance with the same currency.', TypeError);
2977
- };
2978
-
2979
- return {
2980
- /**
2981
- * Returns the amount.
2982
- *
2983
- * @example
2984
- * // returns 500
2985
- * Dinero({ amount: 500 }).getAmount()
2986
- *
2987
- * @return {Number}
2988
- */
2989
- getAmount: function getAmount() {
2990
- return amount;
2991
- },
2992
-
2993
- /**
2994
- * Returns the currency.
2995
- *
2996
- * @example
2997
- * // returns 'EUR'
2998
- * Dinero({ currency: 'EUR' }).getCurrency()
2999
- *
3000
- * @return {String}
3001
- */
3002
- getCurrency: function getCurrency() {
3003
- return currency;
3004
- },
3005
-
3006
- /**
3007
- * Returns the locale.
3008
- *
3009
- * @example
3010
- * // returns 'fr-FR'
3011
- * Dinero().setLocale('fr-FR').getLocale()
3012
- *
3013
- * @return {String}
3014
- */
3015
- getLocale: function getLocale() {
3016
- return this.locale || globalLocale;
3017
- },
3018
-
3019
- /**
3020
- * Returns a new Dinero object with an embedded locale.
3021
- *
3022
- * @param {String} newLocale - The new locale as an {@link http://tools.ietf.org/html/rfc5646 BCP 47 language tag}.
3023
- *
3024
- * @example
3025
- * // Returns a Dinero object with locale 'ja-JP'
3026
- * Dinero().setLocale('ja-JP')
3027
- *
3028
- * @return {Dinero}
3029
- */
3030
- setLocale: function setLocale(newLocale) {
3031
- return create.call(this, {
3032
- locale: newLocale
3033
- });
3034
- },
3035
-
3036
- /**
3037
- * Returns the precision.
3038
- *
3039
- * @example
3040
- * // returns 3
3041
- * Dinero({ precision: 3 }).getPrecision()
3042
- *
3043
- * @return {Number}
3044
- */
3045
- getPrecision: function getPrecision() {
3046
- return precision;
3047
- },
3048
-
3049
- /**
3050
- * Returns a new Dinero object with a new precision and a converted amount.
3051
- *
3052
- * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3053
- * This can be necessary when you need to convert objects to a smaller precision.
3054
- *
3055
- * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent conversions for safer results.
3056
- * You can also specify a different `roundingMode` to better fit your needs.
3057
- *
3058
- * @param {Number} newPrecision - The new precision.
3059
- * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3060
- *
3061
- * @example
3062
- * // Returns a Dinero object with precision 3 and amount 1000
3063
- * Dinero({ amount: 100, precision: 2 }).convertPrecision(3)
3064
- *
3065
- * @throws {TypeError} If `newPrecision` is invalid.
3066
- *
3067
- * @return {Dinero}
3068
- */
3069
- convertPrecision: function convertPrecision(newPrecision) {
3070
- var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3071
- assertInteger(newPrecision);
3072
- var precision = this.getPrecision();
3073
- var isNewPrecisionLarger = newPrecision > precision;
3074
- var operation = isNewPrecisionLarger ? calculator$1.multiply : calculator$1.divide;
3075
- var terms = isNewPrecisionLarger ? [newPrecision, precision] : [precision, newPrecision];
3076
- var factor = Math.pow(10, calculator$1.subtract.apply(calculator$1, terms));
3077
- return create.call(this, {
3078
- amount: calculator$1.round(operation(this.getAmount(), factor), roundingMode),
3079
- precision: newPrecision
3080
- });
3081
- },
3082
-
3083
- /**
3084
- * Returns a new Dinero object that represents the sum of this and an other Dinero object.
3085
- *
3086
- * If Dinero objects have a different `precision`, they will be first converted to the highest.
3087
- *
3088
- * @param {Dinero} addend - The Dinero object to add.
3089
- *
3090
- * @example
3091
- * // returns a Dinero object with amount 600
3092
- * Dinero({ amount: 400 }).add(Dinero({ amount: 200 }))
3093
- * @example
3094
- * // returns a Dinero object with amount 144545 and precision 4
3095
- * Dinero({ amount: 400 }).add(Dinero({ amount: 104545, precision: 4 }))
3096
- *
3097
- * @throws {TypeError} If `addend` has a different currency.
3098
- *
3099
- * @return {Dinero}
3100
- */
3101
- add: function add(addend) {
3102
- assertSameCurrency.call(this, addend);
3103
- var addends = Dinero.normalizePrecision([this, addend]);
3104
- return create.call(this, {
3105
- amount: calculator$1.add(addends[0].getAmount(), addends[1].getAmount()),
3106
- precision: addends[0].getPrecision()
3107
- });
3108
- },
3109
-
3110
- /**
3111
- * Returns a new Dinero object that represents the difference of this and an other Dinero object.
3112
- *
3113
- * If Dinero objects have a different `precision`, they will be first converted to the highest.
3114
- *
3115
- * @param {Dinero} subtrahend - The Dinero object to subtract.
3116
- *
3117
- * @example
3118
- * // returns a Dinero object with amount 200
3119
- * Dinero({ amount: 400 }).subtract(Dinero({ amount: 200 }))
3120
- * @example
3121
- * // returns a Dinero object with amount 64545 and precision 4
3122
- * Dinero({ amount: 104545, precision: 4 }).subtract(Dinero({ amount: 400 }))
3123
- *
3124
- * @throws {TypeError} If `subtrahend` has a different currency.
3125
- *
3126
- * @return {Dinero}
3127
- */
3128
- subtract: function subtract(subtrahend) {
3129
- assertSameCurrency.call(this, subtrahend);
3130
- var subtrahends = Dinero.normalizePrecision([this, subtrahend]);
3131
- return create.call(this, {
3132
- amount: calculator$1.subtract(subtrahends[0].getAmount(), subtrahends[1].getAmount()),
3133
- precision: subtrahends[0].getPrecision()
3134
- });
3135
- },
3136
-
3137
- /**
3138
- * Returns a new Dinero object that represents the multiplied value by the given factor.
3139
- *
3140
- * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3141
- *
3142
- * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
3143
- * You can also specify a different `roundingMode` to better fit your needs.
3144
- *
3145
- * @param {Number} multiplier - The factor to multiply by.
3146
- * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3147
- *
3148
- * @example
3149
- * // returns a Dinero object with amount 1600
3150
- * Dinero({ amount: 400 }).multiply(4)
3151
- * @example
3152
- * // returns a Dinero object with amount 800
3153
- * Dinero({ amount: 400 }).multiply(2.001)
3154
- * @example
3155
- * // returns a Dinero object with amount 801
3156
- * Dinero({ amount: 400 }).multiply(2.00125, 'HALF_UP')
3157
- *
3158
- * @return {Dinero}
3159
- */
3160
- multiply: function multiply(multiplier) {
3161
- var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3162
- return create.call(this, {
3163
- amount: calculator$1.round(calculator$1.multiply(this.getAmount(), multiplier), roundingMode)
3164
- });
3165
- },
3166
-
3167
- /**
3168
- * Returns a new Dinero object that represents the divided value by the given factor.
3169
- *
3170
- * By default, fractional minor currency units are rounded using the **half to even** rule ([banker's rounding](http://wiki.c2.com/?BankersRounding)).
3171
- *
3172
- * Rounding *can* lead to accuracy issues as you chain many times. Consider a minimal amount of subsequent calculations for safer results.
3173
- * You can also specify a different `roundingMode` to better fit your needs.
3174
- *
3175
- * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
3176
- *
3177
- * @param {Number} divisor - The factor to divide by.
3178
- * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3179
- *
3180
- * @example
3181
- * // returns a Dinero object with amount 100
3182
- * Dinero({ amount: 400 }).divide(4)
3183
- * @example
3184
- * // returns a Dinero object with amount 52
3185
- * Dinero({ amount: 105 }).divide(2)
3186
- * @example
3187
- * // returns a Dinero object with amount 53
3188
- * Dinero({ amount: 105 }).divide(2, 'HALF_UP')
3189
- *
3190
- * @return {Dinero}
3191
- */
3192
- divide: function divide(divisor) {
3193
- var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3194
- return create.call(this, {
3195
- amount: calculator$1.round(calculator$1.divide(this.getAmount(), divisor), roundingMode)
3196
- });
3197
- },
3198
-
3199
- /**
3200
- * Returns a new Dinero object that represents a percentage of this.
3201
- *
3202
- * As rounding is applied, precision may be lost in the process. If you want to accurately split a Dinero object, use {@link module:Dinero~allocate allocate} instead.
3203
- *
3204
- * @param {Number} percentage - The percentage to extract (between 0 and 100).
3205
- * @param {String} [roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3206
- *
3207
- * @example
3208
- * // returns a Dinero object with amount 5000
3209
- * Dinero({ amount: 10000 }).percentage(50)
3210
- * @example
3211
- * // returns a Dinero object with amount 29
3212
- * Dinero({ amount: 57 }).percentage(50, "HALF_ODD")
3213
- *
3214
- * @throws {RangeError} If `percentage` is out of range.
3215
- *
3216
- * @return {Dinero}
3217
- */
3218
- percentage: function percentage(_percentage) {
3219
- var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalRoundingMode;
3220
- assertPercentage(_percentage);
3221
- return this.multiply(calculator$1.divide(_percentage, 100), roundingMode);
3222
- },
3223
-
3224
- /**
3225
- * Allocates the amount of a Dinero object according to a list of ratios.
3226
- *
3227
- * Sometimes you need to split monetary values but percentages can't cut it without adding or losing pennies.
3228
- * A good example is invoicing: let's say you need to bill $1,000.03 and you want a 50% downpayment.
3229
- * If you use {@link module:Dinero~percentage percentage}, you'll get an accurate Dinero object but the amount won't be billable: you can't split a penny.
3230
- * If you round it, you'll bill a penny extra.
3231
- * With {@link module:Dinero~allocate allocate}, you can split a monetary amount then distribute the remainder as evenly as possible.
3232
- *
3233
- * You can use percentage style or ratio style for `ratios`: `[25, 75]` and `[1, 3]` will do the same thing.
3234
- *
3235
- * Since v1.8.0, you can use zero ratios (such as [0, 50, 50]). If there's a remainder to distribute, zero ratios are skipped and return a Dinero object with amount zero.
3236
- *
3237
- * @param {Number[]} ratios - The ratios to allocate the money to.
3238
- *
3239
- * @example
3240
- * // returns an array of two Dinero objects
3241
- * // the first one with an amount of 502
3242
- * // the second one with an amount of 501
3243
- * Dinero({ amount: 1003 }).allocate([50, 50])
3244
- * @example
3245
- * // returns an array of two Dinero objects
3246
- * // the first one with an amount of 25
3247
- * // the second one with an amount of 75
3248
- * Dinero({ amount: 100 }).allocate([1, 3])
3249
- * @example
3250
- * // since version 1.8.0
3251
- * // returns an array of three Dinero objects
3252
- * // the first one with an amount of 0
3253
- * // the second one with an amount of 502
3254
- * // the third one with an amount of 501
3255
- * Dinero({ amount: 1003 }).allocate([0, 50, 50])
3256
- *
3257
- * @throws {TypeError} If ratios are invalid.
3258
- *
3259
- * @return {Dinero[]}
3260
- */
3261
- allocate: function allocate(ratios) {
3262
- var _this = this;
3263
-
3264
- assertValidRatios(ratios);
3265
- var total = ratios.reduce(function (a, b) {
3266
- return calculator$1.add(a, b);
3267
- });
3268
- var remainder = this.getAmount();
3269
- var shares = ratios.map(function (ratio) {
3270
- var share = Math.floor(calculator$1.divide(calculator$1.multiply(_this.getAmount(), ratio), total));
3271
- remainder = calculator$1.subtract(remainder, share);
3272
- return create.call(_this, {
3273
- amount: share
3274
- });
3275
- });
3276
- var i = 0;
3277
-
3278
- while (remainder > 0) {
3279
- if (ratios[i] > 0) {
3280
- shares[i] = shares[i].add(create.call(this, {
3281
- amount: 1
3282
- }));
3283
- remainder = calculator$1.subtract(remainder, 1);
3284
- }
3285
-
3286
- i += 1;
3287
- }
3288
-
3289
- return shares;
3290
- },
3291
-
3292
- /**
3293
- * Returns a Promise containing a new Dinero object converted to another currency.
3294
- *
3295
- * You have two options to provide the exchange rates:
3296
- *
3297
- * 1. **Use an exchange rate REST API, and let Dinero handle the fetching and conversion.**
3298
- * This is a simple option if you have access to an exchange rate REST API and want Dinero to do the rest.
3299
- * 2. **Fetch the exchange rates on your own and provide them directly.**
3300
- * This is useful if you're fetching your rates from somewhere else (a file, a database), use a different protocol or query language than REST (SOAP, GraphQL) or want to fetch rates once and cache them instead of making new requests every time.
3301
- *
3302
- * **If you want to use a REST API**, you must provide a third-party endpoint yourself. Dinero doesn't come bundled with an exchange rates endpoint.
3303
- *
3304
- * Here are some exchange rate APIs you can use:
3305
- *
3306
- * * [Fixer](https://fixer.io)
3307
- * * [Open Exchange Rates](https://openexchangerates.org)
3308
- * * [Coinbase](https://api.coinbase.com/v2/exchange-rates)
3309
- * * More [foreign](https://github.com/toddmotto/public-apis#currency-exchange) and [crypto](https://github.com/toddmotto/public-apis#cryptocurrency) exchange rate APIs.
3310
- *
3311
- * **If you want to fetch your own rates and provide them directly**, you need to pass a promise that resolves to the exchanges rates.
3312
- *
3313
- * In both cases, you need to specify at least:
3314
- *
3315
- * * a **destination currency**: the currency in which you want to convert your Dinero object. You can specify it with `currency`.
3316
- * * an **endpoint**: the API URL to query exchange rates, with parameters, or a promise that resolves to the exchange rates. You can specify it with `options.endpoint`.
3317
- * * a **property path**: the path to access the wanted rate in your API's JSON response (or the custom promise's payload). For example, with a response of:
3318
- * ```json
3319
- * {
3320
- * "data": {
3321
- * "base": "USD",
3322
- * "destination": "EUR",
3323
- * "rate": "0.827728919"
3324
- * }
3325
- * }
3326
- * ```
3327
- * Then the property path is `'data.rate'`. You can specify it with `options.propertyPath`.
3328
- *
3329
- * The base currency (the one of your Dinero object) and the destination currency can be used as "merge tags" with the mustache syntax, respectively `{{from}}` and `{{to}}`.
3330
- * You can use these tags to refer to these values in `options.endpoint` and `options.propertyPath`.
3331
- *
3332
- * For example, if you need to specify the base currency as a query parameter, you can do the following:
3333
- *
3334
- * ```js
3335
- * {
3336
- * endpoint: 'https://yourexchangerates.api/latest?base={{from}}'
3337
- * }
3338
- * ```
3339
- *
3340
- * @param {String} currency - The destination currency, expressed as an {@link https://en.wikipedia.org/wiki/ISO_4217#Active_codes ISO 4217 currency code}.
3341
- * @param {(String|Promise)} options.endpoint - The API endpoint to retrieve exchange rates. You can substitute this with a promise that resolves to the exchanges rates if you already have them.
3342
- * @param {String} [options.propertyPath='rates.{{to}}'] - The property path to the rate.
3343
- * @param {Object} [options.headers] - The HTTP headers to provide, if needed.
3344
- * @param {String} [options.roundingMode='HALF_EVEN'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3345
- *
3346
- * @example
3347
- * // your global API parameters
3348
- * Dinero.globalExchangeRatesApi = { ... }
3349
- *
3350
- * // returns a Promise containing a Dinero object with the destination currency
3351
- * // and the initial amount converted to the new currency.
3352
- * Dinero({ amount: 500 }).convert('EUR')
3353
- * @example
3354
- * // returns a Promise containing a Dinero object,
3355
- * // with specific API parameters and rounding mode for this specific instance.
3356
- * Dinero({ amount: 500 })
3357
- * .convert('XBT', {
3358
- * endpoint: 'https://yourexchangerates.api/latest?base={{from}}',
3359
- * propertyPath: 'data.rates.{{to}}',
3360
- * headers: {
3361
- * 'user-key': 'xxxxxxxxx'
3362
- * },
3363
- * roundingMode: 'HALF_UP'
3364
- * })
3365
- * @example
3366
- * // usage with exchange rates provided as a custom promise
3367
- * // using the default `propertyPath` format (so it doesn't have to be specified)
3368
- * const rates = {
3369
- * rates: {
3370
- * EUR: 0.81162
3371
- * }
3372
- * }
3373
- *
3374
- * Dinero({ amount: 500 })
3375
- * .convert('EUR', {
3376
- * endpoint: new Promise(resolve => resolve(rates))
3377
- * })
3378
- * @example
3379
- * // usage with Promise.prototype.then and Promise.prototype.catch
3380
- * Dinero({ amount: 500 })
3381
- * .convert('EUR')
3382
- * .then(dinero => {
3383
- * dinero.getCurrency() // returns 'EUR'
3384
- * })
3385
- * .catch(err => {
3386
- * // handle errors
3387
- * })
3388
- * @example
3389
- * // usage with async/await
3390
- * (async () => {
3391
- * const price = await Dinero({ amount: 500 }).convert('EUR')
3392
- * price.getCurrency() // returns 'EUR'
3393
- * })()
3394
- *
3395
- * @return {Promise}
3396
- */
3397
- convert: function convert(currency) {
3398
- var _this2 = this;
3399
-
3400
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
3401
- _ref$endpoint = _ref.endpoint,
3402
- endpoint = _ref$endpoint === void 0 ? globalExchangeRatesApi.endpoint : _ref$endpoint,
3403
- _ref$propertyPath = _ref.propertyPath,
3404
- propertyPath = _ref$propertyPath === void 0 ? globalExchangeRatesApi.propertyPath || 'rates.{{to}}' : _ref$propertyPath,
3405
- _ref$headers = _ref.headers,
3406
- headers = _ref$headers === void 0 ? globalExchangeRatesApi.headers : _ref$headers,
3407
- _ref$roundingMode = _ref.roundingMode,
3408
- roundingMode = _ref$roundingMode === void 0 ? globalRoundingMode : _ref$roundingMode;
3409
-
3410
- var options = Object.assign({}, {
3411
- endpoint: endpoint,
3412
- propertyPath: propertyPath,
3413
- headers: headers,
3414
- roundingMode: roundingMode
3415
- });
3416
- return CurrencyConverter(options).getExchangeRate(this.getCurrency(), currency).then(function (rate) {
3417
- assert(!isUndefined(rate), "No rate was found for the destination currency \"".concat(currency, "\"."), TypeError);
3418
- return create.call(_this2, {
3419
- amount: calculator$1.round(calculator$1.multiply(_this2.getAmount(), parseFloat(rate)), options.roundingMode),
3420
- currency: currency
3421
- });
3422
- });
3423
- },
3424
-
3425
- /**
3426
- * Checks whether the value represented by this object equals to the other.
3427
- *
3428
- * @param {Dinero} comparator - The Dinero object to compare to.
3429
- *
3430
- * @example
3431
- * // returns true
3432
- * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
3433
- * @example
3434
- * // returns false
3435
- * Dinero({ amount: 500, currency: 'EUR' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
3436
- * @example
3437
- * // returns false
3438
- * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 500, currency: 'EUR' }))
3439
- * @example
3440
- * // returns false
3441
- * Dinero({ amount: 500, currency: 'USD' }).equalsTo(Dinero({ amount: 800, currency: 'EUR' }))
3442
- * @example
3443
- * // returns true
3444
- * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
3445
- * @example
3446
- * // returns false
3447
- * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).equalsTo(Dinero({ amount: 10000, currency: 'EUR', precision: 3 }))
3448
- *
3449
- * @return {Boolean}
3450
- */
3451
- equalsTo: function equalsTo(comparator) {
3452
- return this.hasSameAmount(comparator) && this.hasSameCurrency(comparator);
3453
- },
3454
-
3455
- /**
3456
- * Checks whether the value represented by this object is less than the other.
3457
- *
3458
- * @param {Dinero} comparator - The Dinero object to compare to.
3459
- *
3460
- * @example
3461
- * // returns true
3462
- * Dinero({ amount: 500 }).lessThan(Dinero({ amount: 800 }))
3463
- * @example
3464
- * // returns false
3465
- * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 500 }))
3466
- * @example
3467
- * // returns true
3468
- * Dinero({ amount: 5000, precision: 3 }).lessThan(Dinero({ amount: 800 }))
3469
- * @example
3470
- * // returns false
3471
- * Dinero({ amount: 800 }).lessThan(Dinero({ amount: 5000, precision: 3 }))
3472
- *
3473
- * @throws {TypeError} If `comparator` has a different currency.
3474
- *
3475
- * @return {Boolean}
3476
- */
3477
- lessThan: function lessThan(comparator) {
3478
- assertSameCurrency.call(this, comparator);
3479
- var comparators = Dinero.normalizePrecision([this, comparator]);
3480
- return comparators[0].getAmount() < comparators[1].getAmount();
3481
- },
3482
-
3483
- /**
3484
- * Checks whether the value represented by this object is less than or equal to the other.
3485
- *
3486
- * @param {Dinero} comparator - The Dinero object to compare to.
3487
- *
3488
- * @example
3489
- * // returns true
3490
- * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 800 }))
3491
- * @example
3492
- * // returns true
3493
- * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 500 }))
3494
- * @example
3495
- * // returns false
3496
- * Dinero({ amount: 500 }).lessThanOrEqual(Dinero({ amount: 300 }))
3497
- * @example
3498
- * // returns true
3499
- * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 800 }))
3500
- * @example
3501
- * // returns true
3502
- * Dinero({ amount: 5000, precision: 3 }).lessThanOrEqual(Dinero({ amount: 500 }))
3503
- * @example
3504
- * // returns false
3505
- * Dinero({ amount: 800 }).lessThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3506
- *
3507
- * @throws {TypeError} If `comparator` has a different currency.
3508
- *
3509
- * @return {Boolean}
3510
- */
3511
- lessThanOrEqual: function lessThanOrEqual(comparator) {
3512
- assertSameCurrency.call(this, comparator);
3513
- var comparators = Dinero.normalizePrecision([this, comparator]);
3514
- return comparators[0].getAmount() <= comparators[1].getAmount();
3515
- },
3516
-
3517
- /**
3518
- * Checks whether the value represented by this object is greater than the other.
3519
- *
3520
- * @param {Dinero} comparator - The Dinero object to compare to.
3521
- *
3522
- * @example
3523
- * // returns false
3524
- * Dinero({ amount: 500 }).greaterThan(Dinero({ amount: 800 }))
3525
- * @example
3526
- * // returns true
3527
- * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 500 }))
3528
- * @example
3529
- * // returns true
3530
- * Dinero({ amount: 800 }).greaterThan(Dinero({ amount: 5000, precision: 3 }))
3531
- * @example
3532
- * // returns false
3533
- * Dinero({ amount: 5000, precision: 3 }).greaterThan(Dinero({ amount: 800 }))
3534
- *
3535
- * @throws {TypeError} If `comparator` has a different currency.
3536
- *
3537
- * @return {Boolean}
3538
- */
3539
- greaterThan: function greaterThan(comparator) {
3540
- assertSameCurrency.call(this, comparator);
3541
- var comparators = Dinero.normalizePrecision([this, comparator]);
3542
- return comparators[0].getAmount() > comparators[1].getAmount();
3543
- },
3544
-
3545
- /**
3546
- * Checks whether the value represented by this object is greater than or equal to the other.
3547
- *
3548
- * @param {Dinero} comparator - The Dinero object to compare to.
3549
- *
3550
- * @example
3551
- * // returns true
3552
- * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 300 }))
3553
- * @example
3554
- * // returns true
3555
- * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 500 }))
3556
- * @example
3557
- * // returns false
3558
- * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 800 }))
3559
- * @example
3560
- * // returns true
3561
- * Dinero({ amount: 800 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3562
- * @example
3563
- * // returns true
3564
- * Dinero({ amount: 500 }).greaterThanOrEqual(Dinero({ amount: 5000, precision: 3 }))
3565
- * @example
3566
- * // returns false
3567
- * Dinero({ amount: 5000, precision: 3 }).greaterThanOrEqual(Dinero({ amount: 800 }))
3568
- *
3569
- * @throws {TypeError} If `comparator` has a different currency.
3570
- *
3571
- * @return {Boolean}
3572
- */
3573
- greaterThanOrEqual: function greaterThanOrEqual(comparator) {
3574
- assertSameCurrency.call(this, comparator);
3575
- var comparators = Dinero.normalizePrecision([this, comparator]);
3576
- return comparators[0].getAmount() >= comparators[1].getAmount();
3577
- },
3578
-
3579
- /**
3580
- * Checks if the value represented by this object is zero.
3581
- *
3582
- * @example
3583
- * // returns true
3584
- * Dinero({ amount: 0 }).isZero()
3585
- * @example
3586
- * // returns false
3587
- * Dinero({ amount: 100 }).isZero()
3588
- *
3589
- * @return {Boolean}
3590
- */
3591
- isZero: function isZero() {
3592
- return this.getAmount() === 0;
3593
- },
3594
-
3595
- /**
3596
- * Checks if the value represented by this object is positive.
3597
- *
3598
- * @example
3599
- * // returns false
3600
- * Dinero({ amount: -10 }).isPositive()
3601
- * @example
3602
- * // returns true
3603
- * Dinero({ amount: 10 }).isPositive()
3604
- * @example
3605
- * // returns true
3606
- * Dinero({ amount: 0 }).isPositive()
3607
- *
3608
- * @return {Boolean}
3609
- */
3610
- isPositive: function isPositive() {
3611
- return this.getAmount() >= 0;
3612
- },
3613
-
3614
- /**
3615
- * Checks if the value represented by this object is negative.
3616
- *
3617
- * @example
3618
- * // returns true
3619
- * Dinero({ amount: -10 }).isNegative()
3620
- * @example
3621
- * // returns false
3622
- * Dinero({ amount: 10 }).isNegative()
3623
- * @example
3624
- * // returns false
3625
- * Dinero({ amount: 0 }).isNegative()
3626
- *
3627
- * @return {Boolean}
3628
- */
3629
- isNegative: function isNegative() {
3630
- return this.getAmount() < 0;
3631
- },
3632
-
3633
- /**
3634
- * Checks if this has minor currency units.
3635
- * Deprecates {@link module:Dinero~hasCents hasCents}.
3636
- *
3637
- * @example
3638
- * // returns false
3639
- * Dinero({ amount: 1100 }).hasSubUnits()
3640
- * @example
3641
- * // returns true
3642
- * Dinero({ amount: 1150 }).hasSubUnits()
3643
- *
3644
- * @return {Boolean}
3645
- */
3646
- hasSubUnits: function hasSubUnits() {
3647
- return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
3648
- },
3649
-
3650
- /**
3651
- * Checks if this has minor currency units.
3652
- *
3653
- * @deprecated since version 1.4.0, will be removed in 2.0.0
3654
- * Use {@link module:Dinero~hasSubUnits hasSubUnits} instead.
3655
- *
3656
- * @example
3657
- * // returns false
3658
- * Dinero({ amount: 1100 }).hasCents()
3659
- * @example
3660
- * // returns true
3661
- * Dinero({ amount: 1150 }).hasCents()
3662
- *
3663
- * @return {Boolean}
3664
- */
3665
- hasCents: function hasCents() {
3666
- return calculator$1.modulo(this.getAmount(), Math.pow(10, precision)) !== 0;
3667
- },
3668
-
3669
- /**
3670
- * Checks whether the currency represented by this object equals to the other.
3671
- *
3672
- * @param {Dinero} comparator - The Dinero object to compare to.
3673
- *
3674
- * @example
3675
- * // returns true
3676
- * Dinero({ amount: 2000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'EUR' }))
3677
- * @example
3678
- * // returns false
3679
- * Dinero({ amount: 1000, currency: 'EUR' }).hasSameCurrency(Dinero({ amount: 1000, currency: 'USD' }))
3680
- *
3681
- * @return {Boolean}
3682
- */
3683
- hasSameCurrency: function hasSameCurrency(comparator) {
3684
- return this.getCurrency() === comparator.getCurrency();
3685
- },
3686
-
3687
- /**
3688
- * Checks whether the amount represented by this object equals to the other.
3689
- *
3690
- * @param {Dinero} comparator - The Dinero object to compare to.
3691
- *
3692
- * @example
3693
- * // returns true
3694
- * Dinero({ amount: 1000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000 }))
3695
- * @example
3696
- * // returns false
3697
- * Dinero({ amount: 2000, currency: 'EUR' }).hasSameAmount(Dinero({ amount: 1000, currency: 'EUR' }))
3698
- * @example
3699
- * // returns true
3700
- * Dinero({ amount: 1000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
3701
- * @example
3702
- * // returns false
3703
- * Dinero({ amount: 10000, currency: 'EUR', precision: 2 }).hasSameAmount(Dinero({ amount: 10000, precision: 3 }))
3704
- *
3705
- * @return {Boolean}
3706
- */
3707
- hasSameAmount: function hasSameAmount(comparator) {
3708
- var comparators = Dinero.normalizePrecision([this, comparator]);
3709
- return comparators[0].getAmount() === comparators[1].getAmount();
3710
- },
3711
-
3712
- /**
3713
- * Returns this object formatted as a string.
3714
- *
3715
- * The format is a mask which defines how the output string will be formatted.
3716
- * It defines whether to display a currency, in what format, how many fraction digits to display and whether to use grouping separators.
3717
- * The output is formatted according to the applying locale.
3718
- *
3719
- * Object | Format | String
3720
- * :--------------------------- | :---------------- | :---
3721
- * `Dinero({ amount: 500050 })` | `'$0,0.00'` | $5,000.50
3722
- * `Dinero({ amount: 500050 })` | `'$0,0'` | $5,001
3723
- * `Dinero({ amount: 500050 })` | `'$0'` | $5001
3724
- * `Dinero({ amount: 500050 })` | `'$0.0'` | $5000.5
3725
- * `Dinero({ amount: 500050 })` | `'USD0,0.0'` | USD5,000.5
3726
- * `Dinero({ amount: 500050 })` | `'0,0.0 dollar'` | 5,000.5 dollars
3727
- *
3728
- * Don't try to substitute the `$` sign or the `USD` code with your target currency, nor adapt the format string to the exact format you want.
3729
- * The format is a mask which defines a pattern and returns a valid, localized currency string.
3730
- * If you want to display the object in a custom way, either use {@link module:Dinero~getAmount getAmount}, {@link module:Dinero~toUnit toUnit} or {@link module:Dinero~toRoundedUnit toRoundedUnit} and manipulate the output string as you wish.
3731
- *
3732
- * {@link module:Dinero~toFormat toFormat} wraps around `Number.prototype.toLocaleString`. For that reason, **format will vary depending on how it's implemented in the end user's environment**.
3733
- *
3734
- * You can also use `toLocaleString` directly:
3735
- * `Dinero().toRoundedUnit(digits, roundingMode).toLocaleString(locale, options)`.
3736
- *
3737
- * By default, amounts are rounded using the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
3738
- * You can also specify a different `roundingMode` to better fit your needs.
3739
- *
3740
- * @param {String} [format='$0,0.00'] - The format mask to format to.
3741
- * @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3742
- *
3743
- * @example
3744
- * // returns $2,000
3745
- * Dinero({ amount: 200000 }).toFormat('$0,0')
3746
- * @example
3747
- * // returns €50.5
3748
- * Dinero({ amount: 5050, currency: 'EUR' }).toFormat('$0,0.0')
3749
- * @example
3750
- * // returns 100 euros
3751
- * Dinero({ amount: 10000, currency: 'EUR' }).setLocale('fr-FR').toFormat('0,0 dollar')
3752
- * @example
3753
- * // returns 2000
3754
- * Dinero({ amount: 200000, currency: 'EUR' }).toFormat()
3755
- * @example
3756
- * // returns $10
3757
- * Dinero({ amount: 1050 }).toFormat('$0', 'HALF_EVEN')
3758
- *
3759
- * @return {String}
3760
- */
3761
- toFormat: function toFormat() {
3762
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalFormat;
3763
- var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3764
- var formatter = Format(format);
3765
- return this.toRoundedUnit(formatter.getMinimumFractionDigits(), roundingMode).toLocaleString(this.getLocale(), {
3766
- currencyDisplay: formatter.getCurrencyDisplay(),
3767
- useGrouping: formatter.getUseGrouping(),
3768
- minimumFractionDigits: formatter.getMinimumFractionDigits(),
3769
- style: formatter.getStyle(),
3770
- currency: this.getCurrency()
3771
- });
3772
- },
3773
-
3774
- /**
3775
- * Returns the amount represented by this object in units.
3776
- *
3777
- * @example
3778
- * // returns 10.5
3779
- * Dinero({ amount: 1050 }).toUnit()
3780
- * @example
3781
- * // returns 10.545
3782
- * Dinero({ amount: 10545, precision: 3 }).toUnit()
3783
- *
3784
- * @return {Number}
3785
- */
3786
- toUnit: function toUnit() {
3787
- return calculator$1.divide(this.getAmount(), Math.pow(10, precision));
3788
- },
3789
-
3790
- /**
3791
- * Returns the amount represented by this object in rounded units.
3792
- *
3793
- * By default, the method uses the **half away from zero** rule ([commercial rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero)).
3794
- * You can also specify a different `roundingMode` to better fit your needs.
3795
- *
3796
- * @example
3797
- * // returns 10.6
3798
- * Dinero({ amount: 1055 }).toRoundedUnit(1)
3799
- * @example
3800
- * // returns 10
3801
- * Dinero({ amount: 1050 }).toRoundedUnit(0, 'HALF_EVEN')
3802
- *
3803
- * @param {Number} digits - The number of fraction digits to round to.
3804
- * @param {String} [roundingMode='HALF_AWAY_FROM_ZERO'] - The rounding mode to use: `'HALF_ODD'`, `'HALF_EVEN'`, `'HALF_UP'`, `'HALF_DOWN'`, `'HALF_TOWARDS_ZERO'`, `'HALF_AWAY_FROM_ZERO'` or `'DOWN'`.
3805
- *
3806
- * @return {Number}
3807
- */
3808
- toRoundedUnit: function toRoundedUnit(digits) {
3809
- var roundingMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : globalFormatRoundingMode;
3810
- var factor = Math.pow(10, digits);
3811
- return calculator$1.divide(calculator$1.round(calculator$1.multiply(this.toUnit(), factor), roundingMode), factor);
3812
- },
3813
-
3814
- /**
3815
- * Returns the object's data as an object literal.
3816
- *
3817
- * @example
3818
- * // returns { amount: 500, currency: 'EUR', precision: 2 }
3819
- * Dinero({ amount: 500, currency: 'EUR', precision: 2 }).toObject()
3820
- *
3821
- * @return {Object}
3822
- */
3823
- toObject: function toObject() {
3824
- return {
3825
- amount: amount,
3826
- currency: currency,
3827
- precision: precision
3828
- };
3829
- },
3830
-
3831
- /**
3832
- * Returns the object's data as an object literal.
3833
- *
3834
- * Alias of {@link module:Dinero~toObject toObject}.
3835
- * It is defined so that calling `JSON.stringify` on a Dinero object will automatically extract the relevant data.
3836
- *
3837
- * @example
3838
- * // returns '{"amount":500,"currency":"EUR","precision":2}'
3839
- * JSON.stringify(Dinero({ amount: 500, currency: 'EUR', precision: 2 }))
3840
- *
3841
- * @return {Object}
3842
- */
3843
- toJSON: function toJSON() {
3844
- return this.toObject();
3845
- }
3846
- };
3847
- };
3848
-
3849
- var dinero = Object.assign(Dinero, Defaults, Globals, Static);
3850
-
3851
- // Currency Formatting
3852
- const formatCurrency = (amount, currency, omitSymbols = false) => {
3853
- if (!amount)
3854
- amount = 0;
3855
- const formattedString = omitSymbols ? '0,0.00' : '$0,0.00';
3856
- const formattedCurrency = currency === null || currency === void 0 ? void 0 : currency.toUpperCase();
3857
- const formattedAmount = dinero({ amount: amount }).toFormat(formattedString);
3858
- return currency ? `${formattedAmount} ${formattedCurrency}` : formattedAmount;
3859
- };
3860
- // Date Formatting and Conversion
3861
- function formatDate(dateString) {
3862
- if (!dateString)
3863
- return '';
3864
- const date = new Date(dateString);
3865
- return format(date, 'MMM d, yyyy');
3866
- }
3867
- function formatMediumDate(input) {
3868
- // Check if input is a string and convert to Date object
3869
- if (typeof input === 'string') {
3870
- input = new Date(input);
3871
- }
3872
- // Check if input is a valid date
3873
- if (Object.prototype.toString.call(input) === '[object Date]') {
3874
- if (isNaN(input.getTime())) {
3875
- return 'Invalid date';
3876
- }
3877
- }
3878
- else {
3879
- return 'Invalid input';
3880
- }
3881
- const options = {
3882
- year: 'numeric',
3883
- month: 'short',
3884
- day: 'numeric',
3885
- };
3886
- return input.toLocaleDateString('en-US', options);
3887
- }
3888
- function formatDisplayDate(value, endDate) {
3889
- const isEndingDate = value === endDate;
3890
- return isEndingDate
3891
- ? 'Today'
3892
- : format(new Date(value.replace(/-/g, '/')), 'MMM d');
3893
- }
3894
- function formatTime(dateString) {
3895
- if (!dateString)
3896
- return '';
3897
- const date = new Date(dateString);
3898
- return format(date, 'h:mmaaa');
3899
- }
3900
- function formatTimeSeconds(dateString) {
3901
- if (!dateString)
3902
- return '';
3903
- const date = new Date(dateString);
3904
- return format(date, 'h:mm:ssaaa');
3905
- }
3906
- const convertToUTC = (dateString, options) => {
3907
- const { setEndOfDay, setExactTime } = options;
3908
- if (!dateString)
3909
- return '';
3910
- const dateObj = new Date(dateString);
3911
- if (setEndOfDay) {
3912
- // Adjust the time to be at the very end of the day
3913
- dateObj.setUTCHours(23, 59, 59, 999);
3914
- return new Date(dateObj.toUTCString()).toISOString();
3915
- }
3916
- else if (setExactTime) {
3917
- return new Date(dateObj.toUTCString()).toISOString();
3918
- }
3919
- };
3920
- const convertToLocal = (dateString, options) => {
3921
- const { showDisplayDate, showInputDate, showTime, showInputDateTime } = options;
3922
- if (!dateString)
3923
- return '';
3924
- const dateObj = new Date(dateString);
3925
- const localDate = new Date(dateObj.toLocaleString('en-US', {
3926
- timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
3927
- }));
3928
- if (showDisplayDate) {
3929
- return format(localDate, 'MMM d, yyyy');
3930
- }
3931
- else if (showInputDate) {
3932
- return format(localDate, 'yyyy-MM-dd');
3933
- }
3934
- else if (showTime) {
3935
- return format(localDate, 'h:mmaaa');
3936
- }
3937
- else if (showInputDateTime) {
3938
- return format(localDate, "yyyy-MM-dd'T'HH:mm");
3939
- }
3940
- };
3941
- // String Manipulation
3942
- function capitalFirstLetter(str) {
3943
- if (!str)
3944
- return '';
3945
- return str.charAt(0).toUpperCase() + str.slice(1);
3946
- }
3947
- function snakeCaseToHumanReadable(snakeCaseStr) {
3948
- if (!snakeCaseStr)
3949
- return '';
3950
- return snakeCaseStr
3951
- .split('_')
3952
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
3953
- .join(' ');
3954
- }
3955
- function snakeToCamel(str) {
3956
- if (!str)
3957
- return '';
3958
- return str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', ''));
3959
- }
3960
- // Object Utilities
3961
- function isEmptyObject(obj) {
3962
- return Object.keys(obj).length === 0 && obj.constructor === Object;
3963
- }
3964
- function removeAttribute(htmlString, attribute) {
3965
- const tempDiv = document.createElement('div');
3966
- tempDiv.innerHTML = htmlString;
3967
- const elementsWithStyle = tempDiv.querySelectorAll(`[${attribute}]`);
3968
- elementsWithStyle.forEach((element) => {
3969
- element.removeAttribute(attribute);
3970
- });
3971
- return tempDiv.innerHTML;
3972
- }
3973
- function addAttribute(htmlString, tagName, attribute, value) {
3974
- const tempDiv = document.createElement('div');
3975
- tempDiv.innerHTML = htmlString;
3976
- const elements = tempDiv.getElementsByTagName(tagName);
3977
- Array.from(elements).forEach((element) => {
3978
- element.setAttribute(attribute, value);
3979
- });
3980
- return tempDiv.innerHTML;
3981
- }
3982
- function processHTML(htmlString, functions) {
3983
- let processedHTML = htmlString;
3984
- functions.forEach((func) => {
3985
- processedHTML = func(processedHTML);
3986
- });
3987
- return processedHTML;
3988
- }
3989
- function formatPhoneNumber(number) {
3990
- // Remove all non-numeric characters
3991
- let cleaned = ('' + number).replace(/\D/g, '');
3992
- // Check if the number has the correct length
3993
- if (cleaned.length !== 10) {
3994
- return 'Invalid number';
3995
- }
3996
- // Format the number (XXX) XXX-XXXX
3997
- let formatted = cleaned.replace(/(\d{3})(\d{3})(\d{4})/, '($1) $2-$3');
3998
- return formatted;
3999
- }
4000
-
4001
- export { formatTime as a, formatDate as b, formatPhoneNumber as c, convertToLocal as d, convertToUTC as e, formatCurrency as f, capitalFirstLetter as g, formatDisplayDate as h, addAttribute as i, isEmptyObject as j, formatMediumDate as k, snakeToCamel as l, formatTimeSeconds as m, processHTML as p, removeAttribute as r, snakeCaseToHumanReadable as s };