@merchi/cart 1.4.4

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 (372) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -0
  3. package/esm/Cart.js +62 -0
  4. package/esm/CartAlert.js +47 -0
  5. package/esm/CartHeader.js +29 -0
  6. package/esm/CartProvider.js +1101 -0
  7. package/esm/CartTotals.js +89 -0
  8. package/esm/assets/merchi-monster-loader.gif +0 -0
  9. package/esm/assets/merchi-swipe-outline.png +0 -0
  10. package/esm/assets/product-not-found.png +0 -0
  11. package/esm/assets/stripe-payment-secure.png +0 -0
  12. package/esm/buttons/Button.js +23 -0
  13. package/esm/buttons/ButtonBack.js +35 -0
  14. package/esm/buttons/ButtonClearCart.js +17 -0
  15. package/esm/buttons/ButtonInvoiceDownload.js +88 -0
  16. package/esm/buttons/ButtonNext.js +39 -0
  17. package/esm/buttons/ButtonNextDynamic.js +19 -0
  18. package/esm/buttons/ButtonOpenCartMerchiCartModal.js +47 -0
  19. package/esm/buttons/ButtonPay.js +26 -0
  20. package/esm/buttons/ButtonShipmentTabNext.js +28 -0
  21. package/esm/buttons/index.js +7 -0
  22. package/esm/components/Alert.js +26 -0
  23. package/esm/components/CartBody.js +14 -0
  24. package/esm/components/CartClient.js +62 -0
  25. package/esm/components/CartFooter.js +12 -0
  26. package/esm/components/CartItemRow.js +230 -0
  27. package/esm/components/CartPaymentSettingsInvalid.js +13 -0
  28. package/esm/components/CartShipment.js +52 -0
  29. package/esm/components/CartTabContent.js +12 -0
  30. package/esm/components/CartTabPanel.js +25 -0
  31. package/esm/components/CartTableContainer.js +12 -0
  32. package/esm/components/CartTitle.js +26 -0
  33. package/esm/components/CartTotalsListGroup.js +71 -0
  34. package/esm/components/Collapse.js +32 -0
  35. package/esm/components/CustomCartProductForm.js +128 -0
  36. package/esm/components/CustomerCheckoutMethodTabs.js +94 -0
  37. package/esm/components/DiscountInputGroup.js +293 -0
  38. package/esm/components/LoadingTemplate.js +23 -0
  39. package/esm/components/NoCartItems.js +20 -0
  40. package/esm/components/ShipmentGroupCard.js +207 -0
  41. package/esm/components/Table.js +13 -0
  42. package/esm/components/containers.js +31 -0
  43. package/esm/components/index.js +18 -0
  44. package/esm/components/product-form-sdk-externals.js +36 -0
  45. package/esm/forms/FormNewCustomer.js +243 -0
  46. package/esm/forms/FormReturningCustomer.js +165 -0
  47. package/esm/forms/FormShipmentAddressAndNotes.js +195 -0
  48. package/esm/forms/FormSquarePayment.js +19 -0
  49. package/esm/forms/FormStripePayment.js +19 -0
  50. package/esm/forms/FormWhatsappCustomer.js +253 -0
  51. package/esm/forms/InputAcceptUserTermsAndConditions.js +35 -0
  52. package/esm/forms/InputError.js +16 -0
  53. package/esm/forms/InputSelect.js +48 -0
  54. package/esm/forms/InputText.js +56 -0
  55. package/esm/forms/InputsAddress.js +476 -0
  56. package/esm/forms/index.js +8 -0
  57. package/esm/index.js +13 -0
  58. package/esm/modals.js +51 -0
  59. package/esm/panels/PanelCartItems.js +49 -0
  60. package/esm/panels/PanelCartShipment.js +66 -0
  61. package/esm/panels/PanelClearCart.js +56 -0
  62. package/esm/panels/PanelClientCheckout.js +81 -0
  63. package/esm/panels/PanelEditCartItem.js +199 -0
  64. package/esm/panels/PanelPaymentSuccess.js +63 -0
  65. package/esm/panels/index.js +7 -0
  66. package/esm/square/SquareCard.js +106 -0
  67. package/esm/stripe/LegacyStripeCardForm.js +157 -0
  68. package/esm/stripe/StripeCardFields.js +126 -0
  69. package/esm/stripe/StripeCardForm.js +33 -0
  70. package/esm/stripe/StripePaymentButtons.js +98 -0
  71. package/esm/stripe/actions.js +192 -0
  72. package/esm/stripe/utils.js +20 -0
  73. package/esm/styles/globals.css +463 -0
  74. package/esm/styles/globals.css.map +1 -0
  75. package/esm/tabs/CartNav.js +28 -0
  76. package/esm/tabs/NavTab.js +31 -0
  77. package/esm/types/assets.d.js +0 -0
  78. package/esm/types/index.js +1 -0
  79. package/esm/types/merchi_product_form/index.d.js +0 -0
  80. package/esm/types/merchi_sdk_ts/index.d.js +0 -0
  81. package/esm/types/react-redux/index.d.js +0 -0
  82. package/esm/utilities/address.js +457 -0
  83. package/esm/utilities/area.js +297 -0
  84. package/esm/utilities/cart.js +95 -0
  85. package/esm/utilities/company.js +6 -0
  86. package/esm/utilities/cookie.js +156 -0
  87. package/esm/utilities/currency.js +219 -0
  88. package/esm/utilities/customForm.js +57 -0
  89. package/esm/utilities/helpers.js +229 -0
  90. package/esm/utilities/index.js +14 -0
  91. package/esm/utilities/invoice.js +112 -0
  92. package/esm/utilities/job.js +9 -0
  93. package/esm/utilities/local_storage.js +85 -0
  94. package/esm/utilities/product.js +13 -0
  95. package/esm/utilities/shipment.js +11 -0
  96. package/esm/utilities/tabs.js +51 -0
  97. package/esm/utilities/user.js +65 -0
  98. package/esm/utilities/variations.js +58 -0
  99. package/lib/Cart.d.ts +9 -0
  100. package/lib/Cart.js +69 -0
  101. package/lib/CartAlert.d.ts +3 -0
  102. package/lib/CartAlert.js +53 -0
  103. package/lib/CartHeader.d.ts +3 -0
  104. package/lib/CartHeader.js +37 -0
  105. package/lib/CartProvider.d.ts +236 -0
  106. package/lib/CartProvider.js +1107 -0
  107. package/lib/CartTotals.d.ts +7 -0
  108. package/lib/CartTotals.js +96 -0
  109. package/lib/assets/merchi-monster-loader.gif +0 -0
  110. package/lib/assets/merchi-swipe-outline.png +0 -0
  111. package/lib/assets/product-not-found.png +0 -0
  112. package/lib/assets/stripe-payment-secure.png +0 -0
  113. package/lib/buttons/Button.d.ts +11 -0
  114. package/lib/buttons/Button.js +31 -0
  115. package/lib/buttons/ButtonBack.d.ts +6 -0
  116. package/lib/buttons/ButtonBack.js +44 -0
  117. package/lib/buttons/ButtonClearCart.d.ts +3 -0
  118. package/lib/buttons/ButtonClearCart.js +24 -0
  119. package/lib/buttons/ButtonInvoiceDownload.d.ts +3 -0
  120. package/lib/buttons/ButtonInvoiceDownload.js +96 -0
  121. package/lib/buttons/ButtonNext.d.ts +3 -0
  122. package/lib/buttons/ButtonNext.js +48 -0
  123. package/lib/buttons/ButtonNextDynamic.d.ts +3 -0
  124. package/lib/buttons/ButtonNextDynamic.js +28 -0
  125. package/lib/buttons/ButtonOpenCartMerchiCartModal.d.ts +9 -0
  126. package/lib/buttons/ButtonOpenCartMerchiCartModal.js +57 -0
  127. package/lib/buttons/ButtonPay.d.ts +7 -0
  128. package/lib/buttons/ButtonPay.js +35 -0
  129. package/lib/buttons/ButtonShipmentTabNext.d.ts +2 -0
  130. package/lib/buttons/ButtonShipmentTabNext.js +37 -0
  131. package/lib/buttons/index.d.ts +7 -0
  132. package/lib/buttons/index.js +48 -0
  133. package/lib/components/Alert.d.ts +7 -0
  134. package/lib/components/Alert.js +34 -0
  135. package/lib/components/CartBody.d.ts +7 -0
  136. package/lib/components/CartBody.js +22 -0
  137. package/lib/components/CartClient.d.ts +4 -0
  138. package/lib/components/CartClient.js +71 -0
  139. package/lib/components/CartFooter.d.ts +6 -0
  140. package/lib/components/CartFooter.js +20 -0
  141. package/lib/components/CartItemRow.d.ts +7 -0
  142. package/lib/components/CartItemRow.js +236 -0
  143. package/lib/components/CartPaymentSettingsInvalid.d.ts +2 -0
  144. package/lib/components/CartPaymentSettingsInvalid.js +21 -0
  145. package/lib/components/CartShipment.d.ts +6 -0
  146. package/lib/components/CartShipment.js +59 -0
  147. package/lib/components/CartTabContent.d.ts +6 -0
  148. package/lib/components/CartTabContent.js +20 -0
  149. package/lib/components/CartTabPanel.d.ts +7 -0
  150. package/lib/components/CartTabPanel.js +31 -0
  151. package/lib/components/CartTableContainer.d.ts +6 -0
  152. package/lib/components/CartTableContainer.js +20 -0
  153. package/lib/components/CartTitle.d.ts +2 -0
  154. package/lib/components/CartTitle.js +34 -0
  155. package/lib/components/CartTotalsListGroup.d.ts +3 -0
  156. package/lib/components/CartTotalsListGroup.js +78 -0
  157. package/lib/components/Collapse.d.ts +3 -0
  158. package/lib/components/Collapse.js +40 -0
  159. package/lib/components/CustomCartProductForm.d.ts +18 -0
  160. package/lib/components/CustomCartProductForm.js +136 -0
  161. package/lib/components/CustomerCheckoutMethodTabs.d.ts +6 -0
  162. package/lib/components/CustomerCheckoutMethodTabs.js +103 -0
  163. package/lib/components/DiscountInputGroup.d.ts +2 -0
  164. package/lib/components/DiscountInputGroup.js +301 -0
  165. package/lib/components/LoadingTemplate.d.ts +7 -0
  166. package/lib/components/LoadingTemplate.js +30 -0
  167. package/lib/components/NoCartItems.d.ts +3 -0
  168. package/lib/components/NoCartItems.js +27 -0
  169. package/lib/components/ShipmentGroupCard.d.ts +7 -0
  170. package/lib/components/ShipmentGroupCard.js +215 -0
  171. package/lib/components/Table.d.ts +7 -0
  172. package/lib/components/Table.js +19 -0
  173. package/lib/components/containers.d.ts +14 -0
  174. package/lib/components/containers.js +40 -0
  175. package/lib/components/index.d.ts +18 -0
  176. package/lib/components/index.js +133 -0
  177. package/lib/components/product-form-sdk-externals.d.ts +46 -0
  178. package/lib/components/product-form-sdk-externals.js +43 -0
  179. package/lib/forms/FormNewCustomer.d.ts +4 -0
  180. package/lib/forms/FormNewCustomer.js +252 -0
  181. package/lib/forms/FormReturningCustomer.d.ts +3 -0
  182. package/lib/forms/FormReturningCustomer.js +173 -0
  183. package/lib/forms/FormShipmentAddressAndNotes.d.ts +15 -0
  184. package/lib/forms/FormShipmentAddressAndNotes.js +203 -0
  185. package/lib/forms/FormSquarePayment.d.ts +3 -0
  186. package/lib/forms/FormSquarePayment.js +27 -0
  187. package/lib/forms/FormStripePayment.d.ts +3 -0
  188. package/lib/forms/FormStripePayment.js +27 -0
  189. package/lib/forms/FormWhatsappCustomer.d.ts +3 -0
  190. package/lib/forms/FormWhatsappCustomer.js +261 -0
  191. package/lib/forms/InputAcceptUserTermsAndConditions.d.ts +7 -0
  192. package/lib/forms/InputAcceptUserTermsAndConditions.js +41 -0
  193. package/lib/forms/InputError.d.ts +8 -0
  194. package/lib/forms/InputError.js +24 -0
  195. package/lib/forms/InputSelect.d.ts +14 -0
  196. package/lib/forms/InputSelect.js +55 -0
  197. package/lib/forms/InputText.d.ts +12 -0
  198. package/lib/forms/InputText.js +63 -0
  199. package/lib/forms/InputsAddress.d.ts +11 -0
  200. package/lib/forms/InputsAddress.js +485 -0
  201. package/lib/forms/index.d.ts +8 -0
  202. package/lib/forms/index.js +63 -0
  203. package/lib/index.d.ts +13 -0
  204. package/lib/index.js +93 -0
  205. package/lib/modals.d.ts +17 -0
  206. package/lib/modals.js +59 -0
  207. package/lib/panels/PanelCartItems.d.ts +3 -0
  208. package/lib/panels/PanelCartItems.js +56 -0
  209. package/lib/panels/PanelCartShipment.d.ts +3 -0
  210. package/lib/panels/PanelCartShipment.js +72 -0
  211. package/lib/panels/PanelClearCart.d.ts +3 -0
  212. package/lib/panels/PanelClearCart.js +62 -0
  213. package/lib/panels/PanelClientCheckout.d.ts +3 -0
  214. package/lib/panels/PanelClientCheckout.js +88 -0
  215. package/lib/panels/PanelEditCartItem.d.ts +6 -0
  216. package/lib/panels/PanelEditCartItem.js +206 -0
  217. package/lib/panels/PanelPaymentSuccess.d.ts +3 -0
  218. package/lib/panels/PanelPaymentSuccess.js +69 -0
  219. package/lib/panels/index.d.ts +7 -0
  220. package/lib/panels/index.js +48 -0
  221. package/lib/square/SquareCard.d.ts +3 -0
  222. package/lib/square/SquareCard.js +114 -0
  223. package/lib/stripe/LegacyStripeCardForm.d.ts +3 -0
  224. package/lib/stripe/LegacyStripeCardForm.js +166 -0
  225. package/lib/stripe/StripeCardFields.d.ts +15 -0
  226. package/lib/stripe/StripeCardFields.js +135 -0
  227. package/lib/stripe/StripeCardForm.d.ts +2 -0
  228. package/lib/stripe/StripeCardForm.js +42 -0
  229. package/lib/stripe/StripePaymentButtons.d.ts +8 -0
  230. package/lib/stripe/StripePaymentButtons.js +106 -0
  231. package/lib/stripe/actions.d.ts +4 -0
  232. package/lib/stripe/actions.js +200 -0
  233. package/lib/stripe/utils.d.ts +18 -0
  234. package/lib/stripe/utils.js +27 -0
  235. package/lib/styles/globals.css +463 -0
  236. package/lib/styles/globals.css.map +1 -0
  237. package/lib/tabs/CartNav.d.ts +3 -0
  238. package/lib/tabs/CartNav.js +36 -0
  239. package/lib/tabs/NavTab.d.ts +9 -0
  240. package/lib/tabs/NavTab.js +39 -0
  241. package/lib/types/index.d.ts +13 -0
  242. package/lib/types/index.js +1 -0
  243. package/lib/utilities/address.d.ts +30 -0
  244. package/lib/utilities/address.js +468 -0
  245. package/lib/utilities/area.d.ts +77 -0
  246. package/lib/utilities/area.js +328 -0
  247. package/lib/utilities/cart.d.ts +9 -0
  248. package/lib/utilities/cart.js +108 -0
  249. package/lib/utilities/company.d.ts +2 -0
  250. package/lib/utilities/company.js +13 -0
  251. package/lib/utilities/cookie.d.ts +4 -0
  252. package/lib/utilities/cookie.js +165 -0
  253. package/lib/utilities/currency.d.ts +5 -0
  254. package/lib/utilities/currency.js +229 -0
  255. package/lib/utilities/customForm.d.ts +17 -0
  256. package/lib/utilities/customForm.js +64 -0
  257. package/lib/utilities/helpers.d.ts +24 -0
  258. package/lib/utilities/helpers.js +240 -0
  259. package/lib/utilities/index.d.ts +14 -0
  260. package/lib/utilities/index.js +159 -0
  261. package/lib/utilities/invoice.d.ts +3 -0
  262. package/lib/utilities/invoice.js +118 -0
  263. package/lib/utilities/job.d.ts +1 -0
  264. package/lib/utilities/job.js +15 -0
  265. package/lib/utilities/local_storage.d.ts +31 -0
  266. package/lib/utilities/local_storage.js +96 -0
  267. package/lib/utilities/product.d.ts +2 -0
  268. package/lib/utilities/product.js +21 -0
  269. package/lib/utilities/shipment.d.ts +2 -0
  270. package/lib/utilities/shipment.js +18 -0
  271. package/lib/utilities/tabs.d.ts +14 -0
  272. package/lib/utilities/tabs.js +60 -0
  273. package/lib/utilities/user.d.ts +5 -0
  274. package/lib/utilities/user.js +75 -0
  275. package/lib/utilities/variations.d.ts +18 -0
  276. package/lib/utilities/variations.js +66 -0
  277. package/package.json +109 -0
  278. package/src/Cart.tsx +96 -0
  279. package/src/CartAlert.tsx +35 -0
  280. package/src/CartHeader.tsx +28 -0
  281. package/src/CartProvider.tsx +992 -0
  282. package/src/CartTotals.tsx +102 -0
  283. package/src/assets/merchi-monster-loader.gif +0 -0
  284. package/src/assets/merchi-swipe-outline.png +0 -0
  285. package/src/assets/product-not-found.png +0 -0
  286. package/src/assets/stripe-payment-secure.png +0 -0
  287. package/src/buttons/Button.tsx +35 -0
  288. package/src/buttons/ButtonBack.tsx +42 -0
  289. package/src/buttons/ButtonClearCart.tsx +17 -0
  290. package/src/buttons/ButtonInvoiceDownload.tsx +60 -0
  291. package/src/buttons/ButtonNext.tsx +35 -0
  292. package/src/buttons/ButtonNextDynamic.tsx +31 -0
  293. package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -0
  294. package/src/buttons/ButtonPay.tsx +32 -0
  295. package/src/buttons/ButtonShipmentTabNext.tsx +24 -0
  296. package/src/buttons/index.ts +15 -0
  297. package/src/components/Alert.tsx +31 -0
  298. package/src/components/CartBody.tsx +16 -0
  299. package/src/components/CartClient.tsx +52 -0
  300. package/src/components/CartFooter.tsx +15 -0
  301. package/src/components/CartItemRow.tsx +212 -0
  302. package/src/components/CartPaymentSettingsInvalid.tsx +12 -0
  303. package/src/components/CartShipment.tsx +56 -0
  304. package/src/components/CartTabContent.tsx +15 -0
  305. package/src/components/CartTabPanel.tsx +25 -0
  306. package/src/components/CartTableContainer.tsx +15 -0
  307. package/src/components/CartTitle.tsx +22 -0
  308. package/src/components/CartTotalsListGroup.tsx +58 -0
  309. package/src/components/Collapse.tsx +23 -0
  310. package/src/components/CustomCartProductForm.tsx +123 -0
  311. package/src/components/CustomerCheckoutMethodTabs.tsx +106 -0
  312. package/src/components/DiscountInputGroup.tsx +160 -0
  313. package/src/components/LoadingTemplate.tsx +22 -0
  314. package/src/components/NoCartItems.tsx +20 -0
  315. package/src/components/ShipmentGroupCard.tsx +170 -0
  316. package/src/components/Table.tsx +15 -0
  317. package/src/components/containers.tsx +40 -0
  318. package/src/components/index.ts +38 -0
  319. package/src/components/product-form-sdk-externals.ts +67 -0
  320. package/src/forms/FormNewCustomer.tsx +170 -0
  321. package/src/forms/FormReturningCustomer.tsx +117 -0
  322. package/src/forms/FormShipmentAddressAndNotes.tsx +165 -0
  323. package/src/forms/FormSquarePayment.tsx +19 -0
  324. package/src/forms/FormStripePayment.tsx +19 -0
  325. package/src/forms/FormWhatsappCustomer.tsx +179 -0
  326. package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -0
  327. package/src/forms/InputError.tsx +23 -0
  328. package/src/forms/InputSelect.tsx +58 -0
  329. package/src/forms/InputText.tsx +56 -0
  330. package/src/forms/InputsAddress.tsx +438 -0
  331. package/src/forms/index.ts +18 -0
  332. package/src/index.ts +31 -0
  333. package/src/modals.tsx +65 -0
  334. package/src/panels/PanelCartItems.tsx +56 -0
  335. package/src/panels/PanelCartShipment.tsx +86 -0
  336. package/src/panels/PanelClearCart.tsx +50 -0
  337. package/src/panels/PanelClientCheckout.tsx +102 -0
  338. package/src/panels/PanelEditCartItem.tsx +172 -0
  339. package/src/panels/PanelPaymentSuccess.tsx +66 -0
  340. package/src/panels/index.ts +15 -0
  341. package/src/square/SquareCard.tsx +84 -0
  342. package/src/stripe/LegacyStripeCardForm.tsx +91 -0
  343. package/src/stripe/StripeCardFields.tsx +173 -0
  344. package/src/stripe/StripeCardForm.tsx +18 -0
  345. package/src/stripe/StripePaymentButtons.tsx +117 -0
  346. package/src/stripe/actions.ts +94 -0
  347. package/src/stripe/utils.ts +22 -0
  348. package/src/styles/globals.scss +475 -0
  349. package/src/tabs/CartNav.tsx +18 -0
  350. package/src/tabs/NavTab.tsx +36 -0
  351. package/src/types/assets.d.ts +4 -0
  352. package/src/types/index.ts +15 -0
  353. package/src/types/merchi_product_form/index.d.ts +1 -0
  354. package/src/types/merchi_sdk_ts/index.d.ts +1 -0
  355. package/src/types/react-redux/index.d.ts +0 -0
  356. package/src/utilities/address.ts +463 -0
  357. package/src/utilities/area.ts +359 -0
  358. package/src/utilities/cart.ts +80 -0
  359. package/src/utilities/company.ts +8 -0
  360. package/src/utilities/cookie.ts +58 -0
  361. package/src/utilities/currency.ts +216 -0
  362. package/src/utilities/customForm.ts +71 -0
  363. package/src/utilities/helpers.ts +213 -0
  364. package/src/utilities/index.ts +14 -0
  365. package/src/utilities/invoice.ts +60 -0
  366. package/src/utilities/job.ts +13 -0
  367. package/src/utilities/local_storage.ts +130 -0
  368. package/src/utilities/product.ts +14 -0
  369. package/src/utilities/shipment.ts +11 -0
  370. package/src/utilities/tabs.ts +38 -0
  371. package/src/utilities/user.ts +33 -0
  372. package/src/utilities/variations.ts +80 -0
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.activeDisplayUnit = activeDisplayUnit;
7
+ exports.clamp = clamp;
8
+ exports.clampWithAspectRatio = clampWithAspectRatio;
9
+ exports.defaultAreaStep = defaultAreaStep;
10
+ exports.defaultModalityForAreaUnit = defaultModalityForAreaUnit;
11
+ exports.displayToMm = displayToMm;
12
+ exports.estimateAreaCosts = estimateAreaCosts;
13
+ exports.formatAreaParts = formatAreaParts;
14
+ exports.formatAreaSummary = formatAreaSummary;
15
+ exports.formatAreaValue = formatAreaValue;
16
+ exports.formatLengthFromMm = formatLengthFromMm;
17
+ exports.inchesToMm = inchesToMm;
18
+ exports.isImperialUnit = isImperialUnit;
19
+ exports.localePrefersImperial = localePrefersImperial;
20
+ exports.metricDisplayToMm = metricDisplayToMm;
21
+ exports.metricUnitFactor = metricUnitFactor;
22
+ exports.mmToDisplay = mmToDisplay;
23
+ exports.mmToInches = mmToInches;
24
+ exports.mmToMetricDisplay = mmToMetricDisplay;
25
+ exports.mmToUnit = mmToUnit;
26
+ exports.normaliseAreaUnit = normaliseAreaUnit;
27
+ exports.parseAreaValue = parseAreaValue;
28
+ exports.stepInDisplayUnit = stepInDisplayUnit;
29
+ exports.unitFactorMm = unitFactorMm;
30
+ exports.unitLabel = unitLabel;
31
+ exports.unitToMm = unitToMm;
32
+ /** Shared helpers for Area (height × width) variation fields. Stored value is always millimetres. */
33
+
34
+ var MM_PER_INCH = 25.4;
35
+ var MM_PER_FOOT = 304.8;
36
+ var MM_PER_CM = 10;
37
+ var MM_PER_M = 1000;
38
+ function parseAreaValue(value) {
39
+ if (value == null) return null;
40
+ var text = String(value).trim();
41
+ if (!text) return null;
42
+ var parts = text.split(',').map(function (p) {
43
+ return p.trim();
44
+ });
45
+ if (parts.length !== 2) return null;
46
+ var heightMm = Number(parts[0]);
47
+ var widthMm = Number(parts[1]);
48
+ if (!Number.isFinite(heightMm) || !Number.isFinite(widthMm)) return null;
49
+ if (heightMm <= 0 || widthMm <= 0) return null;
50
+ return {
51
+ heightMm: heightMm,
52
+ widthMm: widthMm
53
+ };
54
+ }
55
+ function formatAreaValue(heightMm, widthMm) {
56
+ var h = Number(heightMm);
57
+ var w = Number(widthMm);
58
+ if (!Number.isFinite(h) || !Number.isFinite(w) || h <= 0 || w <= 0) return '';
59
+ return "".concat(trimNum(h), ",").concat(trimNum(w));
60
+ }
61
+ function trimNum(n) {
62
+ return String(Number(n.toFixed(6)));
63
+ }
64
+ function isImperialUnit(unit) {
65
+ var u = String(unit || 'mm').toLowerCase();
66
+ return u === 'in' || u === 'ft';
67
+ }
68
+ function normaliseAreaUnit(unit) {
69
+ var u = String(unit || 'mm').toLowerCase();
70
+ if (u === 'cm' || u === 'm' || u === 'in' || u === 'ft' || u === 'mm') {
71
+ return u;
72
+ }
73
+ return 'mm';
74
+ }
75
+
76
+ /** Imperial for en-US / en-LR / en-MM; otherwise metric (incl. en-GB). */
77
+ function localePrefersImperial(locale) {
78
+ var lang = locale || (typeof navigator !== 'undefined' ? navigator.language : undefined) || '';
79
+ var normalized = lang.toLowerCase().replace('_', '-');
80
+ return normalized === 'en-us' || normalized === 'en-lr' || normalized === 'en-mm' || normalized.endsWith('-us') || normalized.endsWith('-lr') || normalized.endsWith('-mm');
81
+ }
82
+
83
+ /** Millimetres per one unit of the given area unit. */
84
+ function unitFactorMm() {
85
+ var unit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'mm';
86
+ switch (normaliseAreaUnit(unit)) {
87
+ case 'cm':
88
+ return MM_PER_CM;
89
+ case 'm':
90
+ return MM_PER_M;
91
+ case 'in':
92
+ return MM_PER_INCH;
93
+ case 'ft':
94
+ return MM_PER_FOOT;
95
+ default:
96
+ return 1;
97
+ }
98
+ }
99
+
100
+ /** @deprecated use unitFactorMm */
101
+ function metricUnitFactor() {
102
+ var unit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'mm';
103
+ return unitFactorMm(unit);
104
+ }
105
+ function mmToUnit(mm) {
106
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'mm';
107
+ return mm / unitFactorMm(unit);
108
+ }
109
+ function unitToMm(value) {
110
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'mm';
111
+ return value * unitFactorMm(unit);
112
+ }
113
+
114
+ /** @deprecated use mmToUnit */
115
+ function mmToMetricDisplay(mm) {
116
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'mm';
117
+ return mmToUnit(mm, unit);
118
+ }
119
+
120
+ /** @deprecated use unitToMm */
121
+ function metricDisplayToMm(value) {
122
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'mm';
123
+ return unitToMm(value, unit);
124
+ }
125
+ function mmToInches(mm) {
126
+ return mm / MM_PER_INCH;
127
+ }
128
+ function inchesToMm(inches) {
129
+ return inches * MM_PER_INCH;
130
+ }
131
+
132
+ /**
133
+ * Unit shown for the current buyer modality.
134
+ * Metric → field unit if metric, else mm.
135
+ * Imperial → field unit if imperial, else inches.
136
+ */
137
+ function activeDisplayUnit(modality) {
138
+ var areaUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'mm';
139
+ var unit = normaliseAreaUnit(areaUnit);
140
+ if (modality === 'imperial') {
141
+ return isImperialUnit(unit) ? unit : 'in';
142
+ }
143
+ return isImperialUnit(unit) ? 'mm' : unit;
144
+ }
145
+ function defaultModalityForAreaUnit() {
146
+ var areaUnit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'mm';
147
+ if (isImperialUnit(areaUnit)) return 'imperial';
148
+ return localePrefersImperial() ? 'imperial' : 'metric';
149
+ }
150
+ function mmToDisplay(mm, modality) {
151
+ var areaUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mm';
152
+ return mmToUnit(mm, activeDisplayUnit(modality, areaUnit));
153
+ }
154
+ function displayToMm(value, modality) {
155
+ var areaUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mm';
156
+ return unitToMm(value, activeDisplayUnit(modality, areaUnit));
157
+ }
158
+ function unitLabel(modality) {
159
+ var areaUnit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'mm';
160
+ return activeDisplayUnit(modality, areaUnit);
161
+ }
162
+ function defaultAreaStep() {
163
+ var unit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'mm';
164
+ switch (normaliseAreaUnit(unit)) {
165
+ case 'm':
166
+ return 0.001;
167
+ case 'cm':
168
+ return 0.1;
169
+ case 'in':
170
+ return 0.125;
171
+ case 'ft':
172
+ return 0.01;
173
+ default:
174
+ return 1;
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Step for inputs/sliders in the current display unit.
180
+ * `stepMm` is the admin-configured step stored in millimetres.
181
+ */
182
+ function stepInDisplayUnit(stepMm, modality) {
183
+ var areaUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mm';
184
+ var unit = activeDisplayUnit(modality, areaUnit);
185
+ var raw = Number(stepMm);
186
+ if (Number.isFinite(raw) && raw > 0) {
187
+ return raw / unitFactorMm(unit);
188
+ }
189
+ return defaultAreaStep(unit);
190
+ }
191
+ function decimalsForUnit(unit) {
192
+ if (unit === 'm') return 4;
193
+ if (unit === 'ft') return 3;
194
+ if (unit === 'in' || unit === 'cm') return 2;
195
+ return 2;
196
+ }
197
+
198
+ /** Format a length in mm for buyer-facing summary. */
199
+ function formatLengthFromMm(mm, modality) {
200
+ var areaUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mm';
201
+ var unit = activeDisplayUnit(modality, areaUnit);
202
+ if (unit === 'ft') {
203
+ var feet = mmToUnit(mm, 'ft');
204
+ return "".concat(trimNum(Number(feet.toFixed(3))), " ft");
205
+ }
206
+ if (unit === 'in') {
207
+ var inches = mmToInches(mm);
208
+ if (inches >= 12) {
209
+ var _feet = Math.floor(inches / 12);
210
+ var rem = inches - _feet * 12;
211
+ if (rem < 0.05) return "".concat(_feet, " ft");
212
+ return "".concat(_feet, " ft ").concat(trimNum(Number(rem.toFixed(2))), " in");
213
+ }
214
+ return "".concat(trimNum(Number(inches.toFixed(2))), " in");
215
+ }
216
+ var display = mmToUnit(mm, unit);
217
+ return "".concat(trimNum(Number(display.toFixed(decimalsForUnit(unit)))), " ").concat(unit);
218
+ }
219
+ function formatAreaParts(value) {
220
+ var modality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'metric';
221
+ var areaUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mm';
222
+ var parsed = parseAreaValue(value);
223
+ if (!parsed) return null;
224
+ var heightMm = parsed.heightMm,
225
+ widthMm = parsed.widthMm;
226
+ var height = formatLengthFromMm(heightMm, modality, areaUnit);
227
+ var width = formatLengthFromMm(widthMm, modality, areaUnit);
228
+ var areaMm2 = heightMm * widthMm;
229
+ var unit = activeDisplayUnit(modality, areaUnit);
230
+ var areaLabel;
231
+ if (unit === 'ft') {
232
+ var sqFt = areaMm2 / (MM_PER_FOOT * MM_PER_FOOT);
233
+ areaLabel = "".concat(trimNum(Number(sqFt.toFixed(3))), " sq ft");
234
+ } else if (unit === 'in') {
235
+ var sqIn = areaMm2 / (MM_PER_INCH * MM_PER_INCH);
236
+ if (sqIn >= 144) {
237
+ areaLabel = "".concat(trimNum(Number((sqIn / 144).toFixed(3))), " sq ft");
238
+ } else {
239
+ areaLabel = "".concat(trimNum(Number(sqIn.toFixed(2))), " sq in");
240
+ }
241
+ } else if (unit === 'm') {
242
+ areaLabel = "".concat(trimNum(Number((areaMm2 / 1000000).toFixed(4))), " m\xB2");
243
+ } else if (unit === 'cm') {
244
+ areaLabel = "".concat(trimNum(Number((areaMm2 / 100).toFixed(2))), " cm\xB2");
245
+ } else {
246
+ areaLabel = "".concat(trimNum(Number(areaMm2.toFixed(2))), " mm\xB2");
247
+ }
248
+ return {
249
+ width: width,
250
+ height: height,
251
+ areaLabel: areaLabel
252
+ };
253
+ }
254
+ function formatAreaSummary(value) {
255
+ var modality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'metric';
256
+ var areaUnit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mm';
257
+ var parts = formatAreaParts(value, modality, areaUnit);
258
+ if (!parts) return null;
259
+ // Width × height (landscape-first) to match the buyer control order.
260
+ return "Width ".concat(parts.width, " \xD7 Height ").concat(parts.height, " (").concat(parts.areaLabel, ")");
261
+ }
262
+ function clamp(n, min, max) {
263
+ var v = n;
264
+ if (min != null && Number.isFinite(min)) v = Math.max(v, min);
265
+ if (max != null && Number.isFinite(max)) v = Math.min(v, max);
266
+ return v;
267
+ }
268
+
269
+ /**
270
+ * Client-side Area cost estimate (pre-discount), matching API formula:
271
+ * onceOff = heightCost × widthCost × height_u × width_u
272
+ * unitCost = heightUnit × widthUnit × height_u × width_u
273
+ * (dimensions expressed in the field's areaUnit)
274
+ */
275
+ function estimateAreaCosts(variationField, value) {
276
+ var _ref, _variationField$areaU, _variationField$heigh, _variationField$width, _variationField$heigh2, _variationField$width2;
277
+ var parsed = parseAreaValue(value);
278
+ if (!parsed) return null;
279
+ var areaUnit = normaliseAreaUnit((_ref = (_variationField$areaU = variationField === null || variationField === void 0 ? void 0 : variationField.areaUnit) !== null && _variationField$areaU !== void 0 ? _variationField$areaU : variationField === null || variationField === void 0 ? void 0 : variationField.area_unit) !== null && _ref !== void 0 ? _ref : 'mm');
280
+ var heightU = mmToUnit(parsed.heightMm, areaUnit);
281
+ var widthU = mmToUnit(parsed.widthMm, areaUnit);
282
+ var area = heightU * widthU;
283
+ var heightCost = Number((_variationField$heigh = variationField === null || variationField === void 0 ? void 0 : variationField.heightVariationCost) !== null && _variationField$heigh !== void 0 ? _variationField$heigh : variationField === null || variationField === void 0 ? void 0 : variationField.height_variation_cost) || 0;
284
+ var widthCost = Number((_variationField$width = variationField === null || variationField === void 0 ? void 0 : variationField.widthVariationCost) !== null && _variationField$width !== void 0 ? _variationField$width : variationField === null || variationField === void 0 ? void 0 : variationField.width_variation_cost) || 0;
285
+ var heightUnit = Number((_variationField$heigh2 = variationField === null || variationField === void 0 ? void 0 : variationField.heightVariationUnitCost) !== null && _variationField$heigh2 !== void 0 ? _variationField$heigh2 : variationField === null || variationField === void 0 ? void 0 : variationField.height_variation_unit_cost) || 0;
286
+ var widthUnit = Number((_variationField$width2 = variationField === null || variationField === void 0 ? void 0 : variationField.widthVariationUnitCost) !== null && _variationField$width2 !== void 0 ? _variationField$width2 : variationField === null || variationField === void 0 ? void 0 : variationField.width_variation_unit_cost) || 0;
287
+ var onceOffCost = heightCost * widthCost * area;
288
+ var unitCost = heightUnit * widthUnit * area;
289
+ if (!(onceOffCost > 0) && !(unitCost > 0)) return null;
290
+ return {
291
+ onceOffCost: Number(onceOffCost.toFixed(3)),
292
+ unitCost: Number(unitCost.toFixed(3))
293
+ };
294
+ }
295
+
296
+ /**
297
+ * Keep width/height linked by aspectRatio (width/height).
298
+ * `changed` indicates which dimension the user edited.
299
+ */
300
+ function clampWithAspectRatio(args) {
301
+ var ratio = args.aspectRatio;
302
+ if (!Number.isFinite(ratio) || ratio <= 0) {
303
+ return {
304
+ heightMm: clamp(args.heightMm, args.heightMin, args.heightMax),
305
+ widthMm: clamp(args.widthMm, args.widthMin, args.widthMax)
306
+ };
307
+ }
308
+ var heightMm = args.heightMm;
309
+ var widthMm = args.widthMm;
310
+ if (args.changed === 'height') {
311
+ heightMm = clamp(heightMm, args.heightMin, args.heightMax);
312
+ widthMm = heightMm * ratio;
313
+ widthMm = clamp(widthMm, args.widthMin, args.widthMax);
314
+ heightMm = widthMm / ratio;
315
+ heightMm = clamp(heightMm, args.heightMin, args.heightMax);
316
+ widthMm = heightMm * ratio;
317
+ } else {
318
+ widthMm = clamp(widthMm, args.widthMin, args.widthMax);
319
+ heightMm = widthMm / ratio;
320
+ heightMm = clamp(heightMm, args.heightMin, args.heightMax);
321
+ widthMm = heightMm * ratio;
322
+ widthMm = clamp(widthMm, args.widthMin, args.widthMax);
323
+ }
324
+ return {
325
+ heightMm: heightMm,
326
+ widthMm: widthMm
327
+ };
328
+ }
@@ -0,0 +1,9 @@
1
+ export declare const makeCart: (json: any, makeDirty?: boolean, cartToken?: string) => any;
2
+ export declare const makeCartItem: (cartItemJson: any, makeDirty?: boolean, cartToken?: string) => any;
3
+ export declare function makeDiscountItem(itemJson: any, makeDirty?: boolean): any;
4
+ export declare function makeCartShipmentQuote(json: any, makeDirty?: boolean): any;
5
+ export declare function cartHasSelectedQuotes(cart: any): boolean;
6
+ export declare function getCartShipmentGroupsAndQuotes(cart: any): Promise<any>;
7
+ export declare function hasStripeLegacyAccount(cart: any): boolean;
8
+ export declare function stripeIsValidAndActive(cart: any): boolean;
9
+ export declare function cartRequiresShipment(cart: any): boolean;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cartHasSelectedQuotes = cartHasSelectedQuotes;
7
+ exports.cartRequiresShipment = cartRequiresShipment;
8
+ exports.getCartShipmentGroupsAndQuotes = getCartShipmentGroupsAndQuotes;
9
+ exports.hasStripeLegacyAccount = hasStripeLegacyAccount;
10
+ exports.makeCartItem = exports.makeCart = void 0;
11
+ exports.makeCartShipmentQuote = makeCartShipmentQuote;
12
+ exports.makeDiscountItem = makeDiscountItem;
13
+ exports.stripeIsValidAndActive = stripeIsValidAndActive;
14
+ var _sdk = require("@merchi/sdk");
15
+ var _company = require("./company");
16
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
17
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
18
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
19
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
20
+ var merchi = new _sdk.Merchi();
21
+ var makeCart = exports.makeCart = function makeCart(json, makeDirty, cartToken) {
22
+ if (cartToken) merchi.cartToken = cartToken;
23
+ var cart = new merchi.Cart();
24
+ return cart.fromJson(json, {
25
+ makeDirty: makeDirty
26
+ });
27
+ };
28
+ var makeCartItem = exports.makeCartItem = function makeCartItem(cartItemJson, makeDirty, cartToken) {
29
+ if (cartToken) merchi.cartToken = cartToken;
30
+ var cartItem = new merchi.CartItem();
31
+ return cartItem.fromJson(cartItemJson, {
32
+ makeDirty: makeDirty
33
+ });
34
+ };
35
+ function makeDiscountItem(itemJson, makeDirty) {
36
+ var item = new merchi.Item();
37
+ if (makeDirty) {
38
+ return item.fromJson(itemJson, {
39
+ makeDirty: true
40
+ });
41
+ } else {
42
+ return item.fromJson(itemJson);
43
+ }
44
+ }
45
+ function makeCartShipmentQuote(json, makeDirty) {
46
+ var cartShipmentQuote = new merchi.CartShipmentQuote();
47
+ return cartShipmentQuote.fromJson(json, {
48
+ makeDirty: makeDirty
49
+ });
50
+ }
51
+ function cartHasSelectedQuotes(cart) {
52
+ var _cart$shipmentGroups = cart.shipmentGroups,
53
+ shipmentGroups = _cart$shipmentGroups === void 0 ? [] : _cart$shipmentGroups;
54
+ if (shipmentGroups.length) {
55
+ var selected = shipmentGroups.filter(function (g) {
56
+ return !!g.selectedQuote;
57
+ });
58
+ return selected.length === shipmentGroups.length;
59
+ }
60
+ return false;
61
+ }
62
+ function getCartShipmentGroupsAndQuotes(_x) {
63
+ return _getCartShipmentGroupsAndQuotes.apply(this, arguments);
64
+ }
65
+ function _getCartShipmentGroupsAndQuotes() {
66
+ _getCartShipmentGroupsAndQuotes = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(cart) {
67
+ var query;
68
+ return _regenerator().w(function (_context) {
69
+ while (1) switch (_context.n) {
70
+ case 0:
71
+ query = [];
72
+ query.push(['cart_token', cart.token]);
73
+ return _context.a(2, merchi.authenticatedFetch("/generate-cart-shipment-quotes/".concat(cart.id, "/"), {
74
+ method: 'GET',
75
+ query: query
76
+ }));
77
+ }
78
+ }, _callee);
79
+ }));
80
+ return _getCartShipmentGroupsAndQuotes.apply(this, arguments);
81
+ }
82
+ function cartCompany(cart) {
83
+ return cart && cart.domain && cart.domain.company ? cart.domain.company : null;
84
+ }
85
+ function hasStripeLegacyAccount(cart) {
86
+ var company = cartCompany(cart);
87
+ return Boolean(company && (0, _company.companyStripePubKeyOrTestPubKey)(company));
88
+ }
89
+ function hasStripeConnectAccount(cart) {
90
+ var company = cartCompany(cart);
91
+ return Boolean(company && company.isStripeAccountEnabled);
92
+ }
93
+ function stripeIsValidAndActive(cart) {
94
+ var company = cartCompany(cart);
95
+ var hasStripe = hasStripeLegacyAccount(cart) || hasStripeConnectAccount(cart);
96
+ return Boolean(hasStripe && company && company.acceptStripe);
97
+ }
98
+ function cartRequiresShipment(cart) {
99
+ var _cart$cartItems = cart.cartItems,
100
+ cartItems = _cart$cartItems === void 0 ? [] : _cart$cartItems;
101
+ for (var i = 0; i < cartItems.length; i++) {
102
+ var item = cartItems[i];
103
+ if (item && item.product && item.product.needsShipping) {
104
+ return true;
105
+ }
106
+ }
107
+ return false;
108
+ }
@@ -0,0 +1,2 @@
1
+ export declare function companyPrimaryAddress(company: any): any;
2
+ export declare function companyStripePubKeyOrTestPubKey(company: any): any;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.companyPrimaryAddress = companyPrimaryAddress;
7
+ exports.companyStripePubKeyOrTestPubKey = companyStripePubKeyOrTestPubKey;
8
+ function companyPrimaryAddress(company) {
9
+ return company && company.addresses ? company.addresses[0] : undefined;
10
+ }
11
+ function companyStripePubKeyOrTestPubKey(company) {
12
+ return company.isTesting ? company.stripePublishableTestKey : company.stripePublishableKey;
13
+ }
@@ -0,0 +1,4 @@
1
+ export declare function getCookie(name: string, defaultValue: any): Promise<any>;
2
+ export declare function getCartCookie(domainId: number | string): Promise<string[]>;
3
+ export declare function getCartCookieToken(domainId: number | string): Promise<string>;
4
+ export declare const setCartCookie: (storeId: number, cart: any, domain?: any) => Promise<void>;
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCartCookie = getCartCookie;
7
+ exports.getCartCookieToken = getCartCookieToken;
8
+ exports.getCookie = getCookie;
9
+ exports.setCartCookie = void 0;
10
+ var _browserOrNode = require("browser-or-node");
11
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
12
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
13
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
14
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
15
+ function getCookie(_x, _x2) {
16
+ return _getCookie.apply(this, arguments);
17
+ }
18
+ function _getCookie() {
19
+ _getCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(name, defaultValue) {
20
+ var searchPrefix, cookies, i, cookie;
21
+ return _regenerator().w(function (_context2) {
22
+ while (1) switch (_context2.n) {
23
+ case 0:
24
+ if (_browserOrNode.isBrowser) {
25
+ _context2.n = 1;
26
+ break;
27
+ }
28
+ return _context2.a(2, '');
29
+ case 1:
30
+ searchPrefix = name + '=';
31
+ cookies = document.cookie.split(';');
32
+ i = 0;
33
+ case 2:
34
+ if (!(i < cookies.length)) {
35
+ _context2.n = 4;
36
+ break;
37
+ }
38
+ cookie = cookies[i];
39
+ cookie = cookie.replace(/^\s*/, '');
40
+ if (!(cookie.indexOf(searchPrefix) === 0)) {
41
+ _context2.n = 3;
42
+ break;
43
+ }
44
+ return _context2.a(2, cookie.substring(searchPrefix.length, cookie.length));
45
+ case 3:
46
+ ++i;
47
+ _context2.n = 2;
48
+ break;
49
+ case 4:
50
+ if (!(defaultValue === undefined)) {
51
+ _context2.n = 5;
52
+ break;
53
+ }
54
+ throw 'no such cookie present';
55
+ case 5:
56
+ return _context2.a(2, defaultValue);
57
+ case 6:
58
+ return _context2.a(2);
59
+ }
60
+ }, _callee2);
61
+ }));
62
+ return _getCookie.apply(this, arguments);
63
+ }
64
+ function getCartCookie(_x3) {
65
+ return _getCartCookie.apply(this, arguments);
66
+ }
67
+ function _getCartCookie() {
68
+ _getCartCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(domainId) {
69
+ var idAndToken;
70
+ return _regenerator().w(function (_context3) {
71
+ while (1) switch (_context3.n) {
72
+ case 0:
73
+ _context3.n = 1;
74
+ return getCookie("cart-".concat(domainId), null);
75
+ case 1:
76
+ idAndToken = _context3.v;
77
+ return _context3.a(2, idAndToken ? idAndToken.split(',') : null);
78
+ }
79
+ }, _callee3);
80
+ }));
81
+ return _getCartCookie.apply(this, arguments);
82
+ }
83
+ function getCartCookieToken(_x4) {
84
+ return _getCartCookieToken.apply(this, arguments);
85
+ }
86
+ function _getCartCookieToken() {
87
+ _getCartCookieToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(domainId) {
88
+ var cartIdAndToken, _t;
89
+ return _regenerator().w(function (_context4) {
90
+ while (1) switch (_context4.n) {
91
+ case 0:
92
+ if (!domainId) {
93
+ _context4.n = 2;
94
+ break;
95
+ }
96
+ _context4.n = 1;
97
+ return getCartCookie(Number(domainId));
98
+ case 1:
99
+ _t = _context4.v;
100
+ _context4.n = 3;
101
+ break;
102
+ case 2:
103
+ _t = undefined;
104
+ case 3:
105
+ cartIdAndToken = _t;
106
+ return _context4.a(2, cartIdAndToken && cartIdAndToken[1] || undefined);
107
+ }
108
+ }, _callee4);
109
+ }));
110
+ return _getCartCookieToken.apply(this, arguments);
111
+ }
112
+ function setSessionCookie(_x5, _x6, _x7) {
113
+ return _setSessionCookie.apply(this, arguments);
114
+ }
115
+ function _setSessionCookie() {
116
+ _setSessionCookie = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(name, value, domain) {
117
+ var cookie, n;
118
+ return _regenerator().w(function (_context5) {
119
+ while (1) switch (_context5.n) {
120
+ case 0:
121
+ if (_browserOrNode.isBrowser) {
122
+ _context5.n = 1;
123
+ break;
124
+ }
125
+ return _context5.a(2);
126
+ case 1:
127
+ cookie = name + '=' + value;
128
+ if (!!domain) {
129
+ // remove port, if it exists
130
+ n = domain.indexOf(':');
131
+ domain = domain.substring(0, n != -1 ? n : domain.length);
132
+ // remove trailing slash and path, if they exists
133
+ n = domain.indexOf('/');
134
+ domain = domain.substring(0, n != -1 ? n : domain.length);
135
+ cookie += '; Domain=' + domain;
136
+ } else {
137
+ cookie += '; Domain=' + '.' + location.hostname;
138
+ }
139
+ cookie += '; path=/';
140
+ document.cookie = cookie;
141
+ case 2:
142
+ return _context5.a(2);
143
+ }
144
+ }, _callee5);
145
+ }));
146
+ return _setSessionCookie.apply(this, arguments);
147
+ }
148
+ var setCartCookie = exports.setCartCookie = /*#__PURE__*/function () {
149
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(storeId, cart, domain) {
150
+ var cookieValue;
151
+ return _regenerator().w(function (_context) {
152
+ while (1) switch (_context.n) {
153
+ case 0:
154
+ cookieValue = cart ? cart.id + ',' + cart.token : '';
155
+ _context.n = 1;
156
+ return setSessionCookie('cart-' + String(storeId), cookieValue, domain);
157
+ case 1:
158
+ return _context.a(2);
159
+ }
160
+ }, _callee);
161
+ }));
162
+ return function setCartCookie(_x8, _x9, _x0) {
163
+ return _ref.apply(this, arguments);
164
+ };
165
+ }();
@@ -0,0 +1,5 @@
1
+ export declare const currencyMap: any;
2
+ export declare function formatCurrency(amount: any, options: any): any;
3
+ export declare function calculateTotalWithTax(total: number, tax: any): number;
4
+ export declare function cartItemCurrencyAndCost(cartItem: any): string;
5
+ export declare function currencyTaxAndCost(currency: string, tax: any, theCost: number): string;