@vtex/faststore 0.0.10 → 0.0.12

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 (509) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +0 -1
  3. package/dist/_virtual/_rolldown/runtime.js +4 -0
  4. package/dist/actions.json +6 -1
  5. package/dist/catalog.json +789 -1701
  6. package/dist/cli/index.d.ts +66 -28
  7. package/dist/cli/index.js +7371 -512
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/cli/server-runtime.js +41 -60
  10. package/dist/cli/server-runtime.js.map +1 -1
  11. package/dist/client.d.ts +3 -3
  12. package/dist/client.js +2 -2
  13. package/dist/components.d.ts +63 -57
  14. package/dist/components.js +60 -54
  15. package/dist/content-types.json +5785 -754
  16. package/dist/core/dist/define-component.d.ts +1 -1
  17. package/dist/core/dist/define-content-type.d.ts +50 -2
  18. package/dist/core/dist/define-content-type.js +107 -3
  19. package/dist/core/dist/define-content-type.js.map +1 -1
  20. package/dist/core/dist/index.d.ts +2 -2
  21. package/dist/docs/access-code-field.md +1 -1
  22. package/dist/docs/access-code-sign-in.md +126 -77
  23. package/dist/docs/account-address-book.md +210 -95
  24. package/dist/docs/account-menu.md +14 -15
  25. package/dist/docs/account-saved-cards.md +44 -39
  26. package/dist/docs/alert-dialog.md +3 -1
  27. package/dist/docs/avatar.md +4 -2
  28. package/dist/docs/billing-address.md +99 -30
  29. package/dist/docs/binding-switcher.md +5 -2
  30. package/dist/docs/buy-button.md +7 -8
  31. package/dist/docs/card-entry.md +39 -26
  32. package/dist/docs/card-summary.md +18 -8
  33. package/dist/docs/cardholder-document.md +5 -3
  34. package/dist/docs/carousel.md +5 -4
  35. package/dist/docs/cart-destination.md +39 -26
  36. package/dist/docs/cart-item.md +29 -14
  37. package/dist/docs/cart-totalizer.md +7 -5
  38. package/dist/docs/cart.md +135 -41
  39. package/dist/docs/challenge-return.md +135 -0
  40. package/dist/docs/client-preferences-fieldset.md +10 -5
  41. package/dist/docs/client-preferences.md +31 -8
  42. package/dist/docs/client-profile-fieldset.md +20 -6
  43. package/dist/docs/client-profile.md +12 -3
  44. package/dist/docs/copy-text.md +9 -7
  45. package/dist/docs/document-field.md +1 -1
  46. package/dist/docs/email-field.md +2 -1
  47. package/dist/docs/email-identification.md +12 -2
  48. package/dist/docs/footer-copyright.md +4 -2
  49. package/dist/docs/form.md +54 -18
  50. package/dist/docs/free-shipping-progress.md +6 -5
  51. package/dist/docs/identity-edit.md +8 -2
  52. package/dist/docs/identity-summary.md +18 -5
  53. package/dist/docs/installments.md +46 -32
  54. package/dist/docs/my-account-profile.md +16 -11
  55. package/dist/docs/navigation-link.md +5 -3
  56. package/dist/docs/order-cancel.md +3 -1
  57. package/dist/docs/order-delivery-address.md +7 -5
  58. package/dist/docs/order-delivery-group.md +1 -3
  59. package/dist/docs/order-details-back.md +1 -1
  60. package/dist/docs/order-details-header.md +1 -4
  61. package/dist/docs/order-invoice-download.md +60 -0
  62. package/dist/docs/order-list-row.md +1 -1
  63. package/dist/docs/order-list-search.md +13 -20
  64. package/dist/docs/order-list-views.md +11 -17
  65. package/dist/docs/order-list.md +12 -5
  66. package/dist/docs/order-payment.md +9 -7
  67. package/dist/docs/order-placed-date.md +1 -1
  68. package/dist/docs/order-placed-payment-summary.md +28 -15
  69. package/dist/docs/order-placed.md +49 -14
  70. package/dist/docs/order-progress.md +1 -1
  71. package/dist/docs/order-status-badge.md +20 -9
  72. package/dist/docs/order-summary.md +2 -2
  73. package/dist/docs/order-tracking-link.md +58 -0
  74. package/dist/docs/payment-method-badges.md +30 -4
  75. package/dist/docs/payment-methods.md +1 -1
  76. package/dist/docs/payment.md +36 -17
  77. package/dist/docs/phone-field.md +4 -4
  78. package/dist/docs/place-order.md +84 -36
  79. package/dist/docs/postal-code-field.md +3 -1
  80. package/dist/docs/pricing.md +21 -23
  81. package/dist/docs/product-gallery.md +19 -20
  82. package/dist/docs/product-information.md +13 -9
  83. package/dist/docs/product-list.md +7 -6
  84. package/dist/docs/product-shelf.md +0 -1
  85. package/dist/docs/promotion.md +4 -2
  86. package/dist/docs/region.md +23 -15
  87. package/dist/docs/save-card.md +7 -6
  88. package/dist/docs/saved-cards.md +65 -36
  89. package/dist/docs/shipping-address.md +57 -21
  90. package/dist/docs/shipping-simulator.md +53 -15
  91. package/dist/docs/sign-in-disclosure.md +176 -0
  92. package/dist/docs/sign-in-form.md +78 -47
  93. package/dist/docs/sign-in-redirect.md +4 -2
  94. package/dist/docs/sign-in.md +173 -0
  95. package/dist/docs/toast.md +15 -4
  96. package/dist/docs/variant-selector.md +15 -11
  97. package/dist/domain-logic/dist/checkout/rules.js +33 -0
  98. package/dist/domain-logic/dist/checkout/rules.js.map +1 -0
  99. package/dist/graphql/types.d.ts +4 -14
  100. package/dist/index.d.ts +2 -2
  101. package/dist/internal/client.d.ts +1 -3
  102. package/dist/internal/client.js +1 -1
  103. package/dist/internal/server.d.ts +7 -4
  104. package/dist/internal/server.js +7 -4
  105. package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +250 -66
  106. package/dist/matter/access-code-sign-in/access-code-sign-in.js +459 -188
  107. package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
  108. package/dist/matter/account-address-book/account-address-book-delete.d.ts +78 -40
  109. package/dist/matter/account-address-book/account-address-book-delete.js +86 -50
  110. package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -1
  111. package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +21 -4
  112. package/dist/matter/account-address-book/account-address-book-deliverability.js +45 -17
  113. package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -1
  114. package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +74 -19
  115. package/dist/matter/account-address-book/account-address-book-form-parts.js +77 -26
  116. package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -1
  117. package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +27 -6
  118. package/dist/matter/account-address-book/account-address-book-profile-notice.js +55 -28
  119. package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -1
  120. package/dist/matter/account-address-book/account-address-book.d.ts +67 -14
  121. package/dist/matter/account-address-book/account-address-book.js +74 -33
  122. package/dist/matter/account-address-book/account-address-book.js.map +1 -1
  123. package/dist/matter/account-address-book/account-address-country-switch.js +3 -3
  124. package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -1
  125. package/dist/matter/account-address-book/account-address-country.d.ts +66 -20
  126. package/dist/matter/account-address-book/account-address-country.js +83 -49
  127. package/dist/matter/account-address-book/account-address-country.js.map +1 -1
  128. package/dist/matter/account-address-book/account-address-form-context.d.ts +8 -4
  129. package/dist/matter/account-address-book/account-address-form-context.js.map +1 -1
  130. package/dist/matter/account-address-book/account-address-form.d.ts +468 -45
  131. package/dist/matter/account-address-book/account-address-form.js +518 -155
  132. package/dist/matter/account-address-book/account-address-form.js.map +1 -1
  133. package/dist/matter/account-address-book/account-address-record.d.ts +27 -6
  134. package/dist/matter/account-address-book/account-address-record.js +32 -17
  135. package/dist/matter/account-address-book/account-address-record.js.map +1 -1
  136. package/dist/matter/account-menu/account-menu.d.ts +34 -17
  137. package/dist/matter/account-menu/account-menu.js +46 -54
  138. package/dist/matter/account-menu/account-menu.js.map +1 -1
  139. package/dist/matter/account-menu-identity/account-menu-identity.js +1 -1
  140. package/dist/matter/account-saved-cards/account-saved-cards.d.ts +108 -28
  141. package/dist/matter/account-saved-cards/account-saved-cards.js +177 -122
  142. package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -1
  143. package/dist/matter/billing-address/billing-address.d.ts +156 -74
  144. package/dist/matter/billing-address/billing-address.js +227 -156
  145. package/dist/matter/billing-address/billing-address.js.map +1 -1
  146. package/dist/matter/breadcrumb/breadcrumb.d.ts +21 -3
  147. package/dist/matter/breadcrumb/breadcrumb.js +24 -9
  148. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
  149. package/dist/matter/buy-button/buy-button.d.ts +8 -11
  150. package/dist/matter/buy-button/buy-button.js +10 -19
  151. package/dist/matter/buy-button/buy-button.js.map +1 -1
  152. package/dist/matter/card-entry/card-capture.js +12 -4
  153. package/dist/matter/card-entry/card-capture.js.map +1 -1
  154. package/dist/matter/card-entry/card-entry.d.ts +123 -32
  155. package/dist/matter/card-entry/card-entry.js +348 -221
  156. package/dist/matter/card-entry/card-entry.js.map +1 -1
  157. package/dist/matter/cart/cart-namespace.d.ts +7 -1
  158. package/dist/matter/cart/cart-namespace.js +7 -1
  159. package/dist/matter/cart/cart-namespace.js.map +1 -1
  160. package/dist/matter/cart/cart.d.ts +402 -61
  161. package/dist/matter/cart/cart.js +624 -153
  162. package/dist/matter/cart/cart.js.map +1 -1
  163. package/dist/matter/cart-destination/cart-destination.d.ts +30 -19
  164. package/dist/matter/cart-destination/cart-destination.js +160 -70
  165. package/dist/matter/cart-destination/cart-destination.js.map +1 -1
  166. package/dist/matter/cart-item/cart-item.d.ts +144 -17
  167. package/dist/matter/cart-item/cart-item.js +166 -49
  168. package/dist/matter/cart-item/cart-item.js.map +1 -1
  169. package/dist/matter/cart-item-compositions/cart-item-compositions.js +1 -1
  170. package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -1
  171. package/dist/matter/cart-item-customizations/cart-item-customizations.js +1 -1
  172. package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -1
  173. package/dist/matter/cart-item-discounts/cart-item-discounts.js +1 -1
  174. package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -1
  175. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +1 -1
  176. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -1
  177. package/dist/matter/cart-item-variations/cart-item-variations.js +1 -1
  178. package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -1
  179. package/dist/matter/cart-totalizer/cart-totalizer.d.ts +43 -9
  180. package/dist/matter/cart-totalizer/cart-totalizer.js +46 -17
  181. package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
  182. package/dist/matter/challenge-return/challenge-return.d.ts +62 -0
  183. package/dist/matter/challenge-return/challenge-return.js +241 -0
  184. package/dist/matter/challenge-return/challenge-return.js.map +1 -0
  185. package/dist/matter/client-preferences/client-preferences-fieldset.d.ts +86 -17
  186. package/dist/matter/client-preferences/client-preferences-fieldset.js +126 -54
  187. package/dist/matter/client-preferences/client-preferences-fieldset.js.map +1 -1
  188. package/dist/matter/client-preferences/client-preferences.d.ts +50 -7
  189. package/dist/matter/client-preferences/client-preferences.js +84 -15
  190. package/dist/matter/client-preferences/client-preferences.js.map +1 -1
  191. package/dist/matter/client-profile/client-profile.d.ts +44 -9
  192. package/dist/matter/client-profile/client-profile.js +64 -24
  193. package/dist/matter/client-profile/client-profile.js.map +1 -1
  194. package/dist/matter/client-profile-form/client-profile-fieldset.d.ts +119 -22
  195. package/dist/matter/client-profile-form/client-profile-fieldset.js +161 -73
  196. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
  197. package/dist/matter/delivery-options/delivery-options-accordion.d.ts +49 -4
  198. package/dist/matter/delivery-options/delivery-options-accordion.js +67 -14
  199. package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -1
  200. package/dist/matter/delivery-options/delivery-options-controller.d.ts +69 -9
  201. package/dist/matter/delivery-options/delivery-options-controller.js +80 -14
  202. package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -1
  203. package/dist/matter/delivery-options/delivery-options.d.ts +37 -2
  204. package/dist/matter/delivery-options/delivery-options.js +75 -12
  205. package/dist/matter/delivery-options/delivery-options.js.map +1 -1
  206. package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +1 -0
  207. package/dist/matter/delivery-options/use-delivery-option-selection.js +1 -1
  208. package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -1
  209. package/dist/matter/email-identification/email-identification.d.ts +25 -3
  210. package/dist/matter/email-identification/email-identification.js +49 -12
  211. package/dist/matter/email-identification/email-identification.js.map +1 -1
  212. package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +79 -7
  213. package/dist/matter/free-shipping-progress/free-shipping-progress.js +77 -20
  214. package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
  215. package/dist/matter/identity-edit/identity-edit.d.ts +52 -10
  216. package/dist/matter/identity-edit/identity-edit.js +47 -19
  217. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  218. package/dist/matter/identity-summary/identity-summary.d.ts +76 -22
  219. package/dist/matter/identity-summary/identity-summary.js +95 -45
  220. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  221. package/dist/matter/installments/installments-select.d.ts +98 -16
  222. package/dist/matter/installments/installments-select.js +156 -48
  223. package/dist/matter/installments/installments-select.js.map +1 -1
  224. package/dist/matter/installments/installments.d.ts +96 -16
  225. package/dist/matter/installments/installments.js +115 -40
  226. package/dist/matter/installments/installments.js.map +1 -1
  227. package/dist/matter/installments/use-installments-selection.d.ts +1 -0
  228. package/dist/matter/installments/use-installments-selection.js +8 -3
  229. package/dist/matter/installments/use-installments-selection.js.map +1 -1
  230. package/dist/matter/my-account-profile/my-account-profile.d.ts +358 -103
  231. package/dist/matter/my-account-profile/my-account-profile.js +370 -174
  232. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  233. package/dist/matter/order-cancel/order-cancel.d.ts +65 -19
  234. package/dist/matter/order-cancel/order-cancel.js +118 -51
  235. package/dist/matter/order-cancel/order-cancel.js.map +1 -1
  236. package/dist/matter/order-delivery-address/order-delivery-address.d.ts +8 -18
  237. package/dist/matter/order-delivery-address/order-delivery-address.js +14 -23
  238. package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -1
  239. package/dist/matter/order-delivery-group/order-delivery-group.d.ts +40 -24
  240. package/dist/matter/order-delivery-group/order-delivery-group.js +64 -74
  241. package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -1
  242. package/dist/matter/order-details-header/order-details-header.d.ts +32 -15
  243. package/dist/matter/order-details-header/order-details-header.js +66 -58
  244. package/dist/matter/order-details-header/order-details-header.js.map +1 -1
  245. package/dist/matter/order-invoice-download/order-invoice-download.d.ts +78 -0
  246. package/dist/matter/order-invoice-download/order-invoice-download.js +173 -0
  247. package/dist/matter/order-invoice-download/order-invoice-download.js.map +1 -0
  248. package/dist/matter/order-list/order-list.d.ts +164 -19
  249. package/dist/matter/order-list/order-list.js +229 -87
  250. package/dist/matter/order-list/order-list.js.map +1 -1
  251. package/dist/matter/order-list-row/order-list-row.d.ts +6 -1
  252. package/dist/matter/order-list-row/order-list-row.js +3 -2
  253. package/dist/matter/order-list-row/order-list-row.js.map +1 -1
  254. package/dist/matter/order-list-search/order-list-search.d.ts +18 -26
  255. package/dist/matter/order-list-search/order-list-search.js +30 -69
  256. package/dist/matter/order-list-search/order-list-search.js.map +1 -1
  257. package/dist/matter/order-list-views/order-list-views.d.ts +15 -22
  258. package/dist/matter/order-list-views/order-list-views.js +22 -68
  259. package/dist/matter/order-list-views/order-list-views.js.map +1 -1
  260. package/dist/matter/order-payment/order-payment.d.ts +33 -10
  261. package/dist/matter/order-payment/order-payment.js +44 -39
  262. package/dist/matter/order-payment/order-payment.js.map +1 -1
  263. package/dist/matter/order-placed/order-placed-deliveries.d.ts +144 -12
  264. package/dist/matter/order-placed/order-placed-deliveries.js +115 -40
  265. package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -1
  266. package/dist/matter/order-placed/order-placed.d.ts +198 -31
  267. package/dist/matter/order-placed/order-placed.js +230 -139
  268. package/dist/matter/order-placed/order-placed.js.map +1 -1
  269. package/dist/matter/order-placed-date/order-placed-date.d.ts +5 -8
  270. package/dist/matter/order-placed-date/order-placed-date.js +7 -8
  271. package/dist/matter/order-placed-date/order-placed-date.js.map +1 -1
  272. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +90 -17
  273. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +93 -117
  274. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
  275. package/dist/matter/order-progress/order-progress.d.ts +19 -8
  276. package/dist/matter/order-progress/order-progress.js +37 -45
  277. package/dist/matter/order-progress/order-progress.js.map +1 -1
  278. package/dist/matter/order-summary/order-summary.d.ts +19 -9
  279. package/dist/matter/order-summary/order-summary.js +38 -44
  280. package/dist/matter/order-summary/order-summary.js.map +1 -1
  281. package/dist/matter/order-tracking-link/order-tracking-link.d.ts +43 -0
  282. package/dist/matter/order-tracking-link/order-tracking-link.js +107 -0
  283. package/dist/matter/order-tracking-link/order-tracking-link.js.map +1 -0
  284. package/dist/matter/payment/payment-card-capture.js +17 -10
  285. package/dist/matter/payment/payment-card-capture.js.map +1 -1
  286. package/dist/matter/payment/payment-controller.d.ts +4 -2
  287. package/dist/matter/payment/payment-controller.js +30 -9
  288. package/dist/matter/payment/payment-controller.js.map +1 -1
  289. package/dist/matter/payment/payment-method-badges.js +1 -1
  290. package/dist/matter/payment/payment.d.ts +69 -19
  291. package/dist/matter/payment/payment.js +101 -35
  292. package/dist/matter/payment/payment.js.map +1 -1
  293. package/dist/matter/payment/use-payment-method-selection.d.ts +25 -4
  294. package/dist/matter/payment/use-payment-method-selection.js +94 -32
  295. package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
  296. package/dist/matter/payment/use-payment-submit-gate.d.ts +14 -3
  297. package/dist/matter/payment/use-payment-submit-gate.js +47 -8
  298. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
  299. package/dist/matter/place-order/place-order.d.ts +171 -57
  300. package/dist/matter/place-order/place-order.js +376 -185
  301. package/dist/matter/place-order/place-order.js.map +1 -1
  302. package/dist/matter/pricing/pricing.d.ts +152 -13
  303. package/dist/matter/pricing/pricing.js +153 -52
  304. package/dist/matter/pricing/pricing.js.map +1 -1
  305. package/dist/matter/product-information/product-information.d.ts +27 -4
  306. package/dist/matter/product-information/product-information.js +32 -15
  307. package/dist/matter/product-information/product-information.js.map +1 -1
  308. package/dist/matter/product-list/product-list.d.ts +24 -6
  309. package/dist/matter/product-list/product-list.js +32 -26
  310. package/dist/matter/product-list/product-list.js.map +1 -1
  311. package/dist/matter/product-shelf/product-shelf.d.ts +1 -3
  312. package/dist/matter/product-shelf/product-shelf.js +2 -15
  313. package/dist/matter/product-shelf/product-shelf.js.map +1 -1
  314. package/dist/matter/region/region.d.ts +33 -16
  315. package/dist/matter/region/region.js +59 -52
  316. package/dist/matter/region/region.js.map +1 -1
  317. package/dist/matter/save-card/save-card.d.ts +43 -8
  318. package/dist/matter/save-card/save-card.js +61 -23
  319. package/dist/matter/save-card/save-card.js.map +1 -1
  320. package/dist/matter/saved-cards/saved-cards.d.ts +113 -21
  321. package/dist/matter/saved-cards/saved-cards.js +349 -77
  322. package/dist/matter/saved-cards/saved-cards.js.map +1 -1
  323. package/dist/matter/shipping-address/address-payload.js +25 -0
  324. package/dist/matter/shipping-address/address-payload.js.map +1 -0
  325. package/dist/matter/shipping-address/country-descriptors.js +71 -71
  326. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  327. package/dist/matter/shipping-address/library-country-descriptors.js +136 -0
  328. package/dist/matter/shipping-address/library-country-descriptors.js.map +1 -0
  329. package/dist/matter/shipping-address/shipping-address.d.ts +312 -45
  330. package/dist/matter/shipping-address/shipping-address.js +443 -188
  331. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  332. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +250 -24
  333. package/dist/matter/shipping-simulator/shipping-simulator.js +257 -51
  334. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  335. package/dist/matter/sign-in/sign-in.d.ts +108 -0
  336. package/dist/matter/sign-in/sign-in.js +285 -0
  337. package/dist/matter/sign-in/sign-in.js.map +1 -0
  338. package/dist/matter/sign-in-disclosure/sign-in-disclosure.d.ts +81 -0
  339. package/dist/matter/sign-in-disclosure/sign-in-disclosure.js +232 -0
  340. package/dist/matter/sign-in-disclosure/sign-in-disclosure.js.map +1 -0
  341. package/dist/matter/sign-in-form/sign-in-form.d.ts +93 -62
  342. package/dist/matter/sign-in-form/sign-in-form.js +134 -144
  343. package/dist/matter/sign-in-form/sign-in-form.js.map +1 -1
  344. package/dist/particles/binding-switcher/binding-switcher.d.ts +29 -8
  345. package/dist/particles/binding-switcher/binding-switcher.js +37 -26
  346. package/dist/particles/binding-switcher/binding-switcher.js.map +1 -1
  347. package/dist/particles/card-summary/card-summary.d.ts +38 -8
  348. package/dist/particles/card-summary/card-summary.js +55 -22
  349. package/dist/particles/card-summary/card-summary.js.map +1 -1
  350. package/dist/particles/carousel/carousel.d.ts +99 -11
  351. package/dist/particles/carousel/carousel.js +103 -35
  352. package/dist/particles/carousel/carousel.js.map +1 -1
  353. package/dist/particles/copy-text/copy-text.js +5 -15
  354. package/dist/particles/copy-text/copy-text.js.map +1 -1
  355. package/dist/particles/dialog/dialog.d.ts +14 -6
  356. package/dist/particles/dialog/dialog.js +6 -3
  357. package/dist/particles/dialog/dialog.js.map +1 -1
  358. package/dist/particles/drawer/drawer.js +1 -1
  359. package/dist/particles/drawer/drawer.js.map +1 -1
  360. package/dist/particles/email-field/email-field.d.ts +2 -1
  361. package/dist/particles/email-field/email-field.js +2 -1
  362. package/dist/particles/email-field/email-field.js.map +1 -1
  363. package/dist/particles/footer-link-group/footer-link-group.js +1 -0
  364. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
  365. package/dist/particles/form/form.d.ts +85 -13
  366. package/dist/particles/form/form.js +91 -42
  367. package/dist/particles/form/form.js.map +1 -1
  368. package/dist/particles/gallery/gallery.d.ts +129 -12
  369. package/dist/particles/gallery/gallery.js +121 -34
  370. package/dist/particles/gallery/gallery.js.map +1 -1
  371. package/dist/particles/order-details-back/order-details-back.d.ts +5 -3
  372. package/dist/particles/order-details-back/order-details-back.js +8 -10
  373. package/dist/particles/order-details-back/order-details-back.js.map +1 -1
  374. package/dist/particles/order-status-badge/order-status-badge.d.ts +3 -3
  375. package/dist/particles/order-status-badge/order-status-badge.js +4 -20
  376. package/dist/particles/order-status-badge/order-status-badge.js.map +1 -1
  377. package/dist/particles/password-field/password-field.d.ts +1 -1
  378. package/dist/particles/password-field/password-field.js +2 -4
  379. package/dist/particles/password-field/password-field.js.map +1 -1
  380. package/dist/particles/phone-field/phone-field.d.ts +4 -4
  381. package/dist/particles/phone-field/phone-field.js +8 -11
  382. package/dist/particles/phone-field/phone-field.js.map +1 -1
  383. package/dist/particles/spinner/spinner.d.ts +24 -4
  384. package/dist/particles/spinner/spinner.js +25 -9
  385. package/dist/particles/spinner/spinner.js.map +1 -1
  386. package/dist/particles/switch/switch.d.ts +4 -1
  387. package/dist/particles/switch/switch.js +3 -1
  388. package/dist/particles/switch/switch.js.map +1 -1
  389. package/dist/particles/toast/toast.d.ts +29 -3
  390. package/dist/particles/toast/toast.js +34 -10
  391. package/dist/particles/toast/toast.js.map +1 -1
  392. package/dist/schema.graphql +164 -56
  393. package/dist/sdk/address/address-fields.js +4 -4
  394. package/dist/sdk/address/address-fields.js.map +1 -1
  395. package/dist/sdk/address/constants.js +1 -6
  396. package/dist/sdk/address/constants.js.map +1 -1
  397. package/dist/sdk/address/messages.js +44 -44
  398. package/dist/sdk/address/messages.js.map +1 -1
  399. package/dist/sdk/address/postal-code.js +15 -2
  400. package/dist/sdk/address/postal-code.js.map +1 -1
  401. package/dist/sdk/address/types.d.ts +5 -3
  402. package/dist/sdk/address/validate-address.js +3 -3
  403. package/dist/sdk/address/validate-address.js.map +1 -1
  404. package/dist/sdk/analytics/use-analytics-actions.d.ts +1 -1
  405. package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
  406. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  407. package/dist/sdk/data/index.js +2 -2
  408. package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
  409. package/dist/sdk/generated/gql.js +1 -1
  410. package/dist/sdk/generated/gql.js.map +1 -1
  411. package/dist/sdk/generated/graphql.d.ts +20 -5
  412. package/dist/sdk/generated/graphql.js +6 -0
  413. package/dist/sdk/generated/graphql.js.map +1 -1
  414. package/dist/sdk/i18n/format-error-code.js +23 -0
  415. package/dist/sdk/i18n/format-error-code.js.map +1 -0
  416. package/dist/sdk/i18n/message-formatter.d.ts +22 -0
  417. package/dist/sdk/i18n/message-formatter.js +140 -0
  418. package/dist/sdk/i18n/message-formatter.js.map +1 -0
  419. package/dist/sdk/i18n/use-message-formatter.d.ts +8 -0
  420. package/dist/sdk/i18n/use-message-formatter.js +18 -0
  421. package/dist/sdk/i18n/use-message-formatter.js.map +1 -0
  422. package/dist/sdk/identity/use-identity-actions.js.map +1 -1
  423. package/dist/sdk/navigation/redirect.d.ts +2 -0
  424. package/dist/sdk/navigation/redirect.js +19 -1
  425. package/dist/sdk/navigation/redirect.js.map +1 -1
  426. package/dist/sdk/navigation/types.d.ts +13 -0
  427. package/dist/sdk/payment/bin-format.js +21 -0
  428. package/dist/sdk/payment/bin-format.js.map +1 -0
  429. package/dist/sdk/payment/challenge-return.js +37 -0
  430. package/dist/sdk/payment/challenge-return.js.map +1 -0
  431. package/dist/sdk/payment/confirmation-last-four.js +39 -0
  432. package/dist/sdk/payment/confirmation-last-four.js.map +1 -0
  433. package/dist/sdk/payment/gateway.d.ts +1 -1
  434. package/dist/sdk/payment/gateway.js +8 -2
  435. package/dist/sdk/payment/gateway.js.map +1 -1
  436. package/dist/sdk/payment/operations.d.ts +1 -0
  437. package/dist/sdk/payment/operations.js +28 -6
  438. package/dist/sdk/payment/operations.js.map +1 -1
  439. package/dist/sdk/payment/resumed-purchase.d.ts +1 -0
  440. package/dist/sdk/payment/resumed-purchase.js +119 -0
  441. package/dist/sdk/payment/resumed-purchase.js.map +1 -0
  442. package/dist/sdk/payment/security-code-mask.js +16 -23
  443. package/dist/sdk/payment/security-code-mask.js.map +1 -1
  444. package/dist/sdk/payment/submission-registry.js +6 -2
  445. package/dist/sdk/payment/submission-registry.js.map +1 -1
  446. package/dist/sdk/payment/use-payment-actions.d.ts +18 -3
  447. package/dist/sdk/payment/use-payment-actions.js +23 -4
  448. package/dist/sdk/payment/use-payment-actions.js.map +1 -1
  449. package/dist/sdk/payment/use-place-order.d.ts +10 -2
  450. package/dist/sdk/payment/use-place-order.js +138 -76
  451. package/dist/sdk/payment/use-place-order.js.map +1 -1
  452. package/dist/sdk/provider/storefront-provider.d.ts +1 -7
  453. package/dist/sdk/provider/storefront-provider.js +4 -11
  454. package/dist/sdk/provider/storefront-provider.js.map +1 -1
  455. package/dist/sdk/seo/entity-landing.d.ts +24 -0
  456. package/dist/sdk/seo/entity-landing.js +30 -0
  457. package/dist/sdk/seo/entity-landing.js.map +1 -0
  458. package/dist/sdk/seo/page-alternates.d.ts +3 -2
  459. package/dist/sdk/seo/page-alternates.js +4 -2
  460. package/dist/sdk/seo/page-alternates.js.map +1 -1
  461. package/dist/sdk/seo/search-landing.d.ts +42 -0
  462. package/dist/sdk/seo/search-landing.js +85 -0
  463. package/dist/sdk/seo/search-landing.js.map +1 -0
  464. package/dist/sdk/session/mock-session.d.ts +9 -0
  465. package/dist/sdk/session/mock-session.js +31 -0
  466. package/dist/sdk/session/mock-session.js.map +1 -0
  467. package/dist/sdk/session/read-server-session.d.ts +3 -0
  468. package/dist/sdk/session/read-server-session.js +5 -0
  469. package/dist/sdk/session/read-server-session.js.map +1 -1
  470. package/dist/sdk/session/return-path-segment.d.ts +10 -0
  471. package/dist/sdk/session/return-path-segment.js +15 -0
  472. package/dist/sdk/session/return-path-segment.js.map +1 -0
  473. package/dist/sdk/session/use-session-actions.js.map +1 -1
  474. package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -1
  475. package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
  476. package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -1
  477. package/dist/utils/safe-href.d.ts +2 -0
  478. package/package.json +4 -3
  479. package/skills/storefront-asset/SKILL.md +2 -2
  480. package/skills/storefront-asset/references/api-side.md +27 -14
  481. package/skills/storefront-asset/references/findings.md +5 -2
  482. package/src/styles/tailwind.css +8 -0
  483. package/dist/matter/shipping-address/country-descriptors.d.ts +0 -1
  484. package/dist/message-locales.json +0 -7
  485. package/dist/sdk/i18n/client.d.ts +0 -4
  486. package/dist/sdk/i18n/client.js +0 -4
  487. package/dist/sdk/i18n/locales.d.ts +0 -8
  488. package/dist/sdk/i18n/locales.js +0 -57
  489. package/dist/sdk/i18n/locales.js.map +0 -1
  490. package/dist/sdk/i18n/messages/en-US.js +0 -183
  491. package/dist/sdk/i18n/messages/en-US.js.map +0 -1
  492. package/dist/sdk/i18n/messages/en-US.json +0 -178
  493. package/dist/sdk/i18n/messages/en-US.json.d.ts +0 -182
  494. package/dist/sdk/i18n/messages/es-ES.js +0 -183
  495. package/dist/sdk/i18n/messages/es-ES.js.map +0 -1
  496. package/dist/sdk/i18n/messages/es-ES.json +0 -178
  497. package/dist/sdk/i18n/messages/pt-BR.js +0 -183
  498. package/dist/sdk/i18n/messages/pt-BR.js.map +0 -1
  499. package/dist/sdk/i18n/messages/pt-BR.json +0 -178
  500. package/dist/sdk/i18n/provider.d.ts +0 -1
  501. package/dist/sdk/i18n/provider.js +0 -30
  502. package/dist/sdk/i18n/provider.js.map +0 -1
  503. package/dist/sdk/i18n/server.d.ts +0 -28
  504. package/dist/sdk/i18n/server.js +0 -59
  505. package/dist/sdk/i18n/server.js.map +0 -1
  506. package/dist/utils/resolve-authored-copy.js +0 -18
  507. package/dist/utils/resolve-authored-copy.js.map +0 -1
  508. package/dist/utils/substitute-template.js +0 -33
  509. package/dist/utils/substitute-template.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { ContentValue, MessageLocaleProp } from "../../core/dist/define-content-type.js";
1
2
  import { ComponentDefinition } from "../../core/dist/define-component.js";
2
3
  import "../../core/dist/index.js";
3
4
  import { CartTotalizer, Money } from "../../sdk/cart/operations.js";
@@ -37,7 +38,7 @@ export type CartDiscountKind = 'PROMOTION' | 'COUPON' | 'OTHER';
37
38
  * One cart-level discount line from `Cart.discounts`. `value` is the absolute amount discounted
38
39
  * (a positive `Money`); the negative sign is applied on render by the locale's currency format.
39
40
  * `amount` is typed `number` but is a string at runtime, so it is `Number()`-coerced before formatting.
40
- * `name` is null for the OTHER residual and for an unnamed promotion — the `otherLabel` prop names those.
41
+ * `name` is null for the OTHER residual and for an unnamed promotion — the `otherLabel` message names those.
41
42
  */
42
43
  export type CartDiscountEntry = {
43
44
  name: string | null;
@@ -51,14 +52,31 @@ export type CartDiscountEntry = {
51
52
  type CartDiscountLinesSlice = {
52
53
  discounts: CartDiscountEntry[];
53
54
  };
54
- export type CartDiscountLineProps = ComponentPropsWithRef<'div'> & {
55
- /** Label for lines the API cannot name: the OTHER residual and an unnamed featured promotion. */
56
- otherLabel?: string;
55
+ export declare const CartDiscountLineContent: {
56
+ readonly id: "cart-discount-line";
57
+ readonly title: "Cart Discount Line";
58
+ readonly description: "Label for the discount lines the API cannot name.";
59
+ readonly schema: {
60
+ readonly type: "object";
61
+ readonly additionalProperties: false;
62
+ readonly properties: {
63
+ readonly otherLabel: {
64
+ readonly type: "string";
65
+ readonly title: "Unnamed discount label";
66
+ readonly description: "Names the OTHER residual and an unnamed featured promotion.";
67
+ readonly format: "icu-message";
68
+ readonly messageSource: "Other discounts";
69
+ };
70
+ };
71
+ };
72
+ };
73
+ export type CartDiscountLineProps = ComponentPropsWithRef<'div'> & MessageLocaleProp & {
57
74
  /** Cart discount slice forwarded by the reactive runtime; injected/overridden by the runtime or in tests. */
58
75
  $data?: CartDiscountLinesSlice | null;
76
+ $content?: ContentValue<typeof CartDiscountLineContent>;
59
77
  };
60
78
  export declare const CartDiscountLineDefinition: ComponentDefinition<CartDiscountLineProps>;
61
- export declare function CartDiscountLine({ otherLabel, className, $data: $dataProp, ...props }: CartDiscountLineProps): import("react/jsx-runtime").JSX.Element | null;
79
+ export declare function CartDiscountLine({ className, $data: $dataProp, $content, $locale, ...props }: CartDiscountLineProps): import("react/jsx-runtime").JSX.Element | null;
62
80
  /** Cart slice forwarded by the reactive runtime — the value of the top-level `cart` field. */
63
81
  type CartMarkdownSlice = {
64
82
  itemMarkdownTotal: {
@@ -66,13 +84,29 @@ type CartMarkdownSlice = {
66
84
  currencyCode: string;
67
85
  };
68
86
  };
69
- export type CartMarkdownLineProps = ComponentPropsWithRef<'div'> & {
70
- /** Row label for the aggregate item-level markdown. Interim operational default until the i18n catalog lands. */
71
- label?: string;
87
+ export declare const CartMarkdownLineContent: {
88
+ readonly id: "cart-markdown-line";
89
+ readonly title: "Cart Markdown Line";
90
+ readonly description: "Label for the aggregate item-level markdown row.";
91
+ readonly schema: {
92
+ readonly type: "object";
93
+ readonly additionalProperties: false;
94
+ readonly properties: {
95
+ readonly label: {
96
+ readonly type: "string";
97
+ readonly title: "Markdown label";
98
+ readonly format: "icu-message";
99
+ readonly messageSource: "Item discounts";
100
+ };
101
+ };
102
+ };
103
+ };
104
+ export type CartMarkdownLineProps = ComponentPropsWithRef<'div'> & MessageLocaleProp & {
72
105
  /** Cart markdown slice forwarded by the reactive runtime; injected/overridden by the runtime or in tests. */
73
106
  $data?: CartMarkdownSlice | null;
107
+ $content?: ContentValue<typeof CartMarkdownLineContent>;
74
108
  };
75
109
  export declare const CartMarkdownLineDefinition: ComponentDefinition<CartMarkdownLineProps>;
76
- export declare function CartMarkdownLine({ label, className, $data: $dataProp, ...props }: CartMarkdownLineProps): import("react/jsx-runtime").JSX.Element | null;
110
+ export declare function CartMarkdownLine({ className, $data: $dataProp, $content, $locale, ...props }: CartMarkdownLineProps): import("react/jsx-runtime").JSX.Element | null;
77
111
  //#endregion
78
112
  //# sourceMappingURL=cart-totalizer.d.ts.map
@@ -1,7 +1,9 @@
1
1
  "use client";
2
2
  import { defineComponent } from "../../core/dist/define-component.js";
3
+ import { defineContentType } from "../../core/dist/define-content-type.js";
3
4
  import "../../core/dist/index.js";
4
5
  import { useStorefrontContext } from "../../sdk/context/storefront-context.js";
6
+ import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
5
7
  import { graphql } from "../../sdk/generated/gql.js";
6
8
  import { useDataOverride } from "../../sdk/data/data-override-context.js";
7
9
  import { CartTotalValueContext, formatPrice, isFiniteAmount } from "../cart/cart.js";
@@ -124,26 +126,40 @@ const cartDiscountLinesFragment = graphql(`
124
126
  }
125
127
  }
126
128
  `);
129
+ const CartDiscountLineContent = defineContentType({
130
+ id: "cart-discount-line",
131
+ title: "Cart Discount Line",
132
+ description: "Label for the discount lines the API cannot name.",
133
+ schema: {
134
+ type: "object",
135
+ additionalProperties: false,
136
+ properties: { otherLabel: {
137
+ type: "string",
138
+ title: "Unnamed discount label",
139
+ description: "Names the OTHER residual and an unnamed featured promotion.",
140
+ format: "icu-message",
141
+ messageSource: "Other discounts"
142
+ } }
143
+ }
144
+ });
127
145
  const CartDiscountLineDefinition = defineComponent({
128
146
  name: "CartDiscountLine",
129
147
  importPath: "@vtex/faststore/components",
130
148
  component: CartDiscountLine,
131
149
  fragment: cartDiscountLinesFragment,
132
150
  fetchStrategy: "reactive",
151
+ content: CartDiscountLineContent,
133
152
  editor: {
134
153
  label: "Cart Discount Line",
135
154
  category: "commerce"
136
155
  },
137
- schema: { otherLabel: {
138
- type: "string",
139
- default: "Other discounts",
140
- label: "Unnamed discount label"
141
- } },
142
- guideline: "Itemized order-summary discounts: renders one line per entry in cart.discounts (one per promotion and per coupon, plus a residual \"other\" line), each as label + negative amount. Renders nothing when the cart has no discounts. This is the itemized alternative to CartTotalizerLine totalizerId=\"Discounts\": the entries sum to that same aggregate, so compose this OR that line, never both (both would double-count the same money). Place it in the order summary, typically inside CartTotalizerRoot. Set otherLabel for the residual and any unnamed promotion. See cart-totalizer.md."
156
+ schema: {},
157
+ guideline: "Itemized order-summary discounts: renders one line per entry in cart.discounts (one per promotion and per coupon, plus a residual \"other\" line), each as label + negative amount. Renders nothing when the cart has no discounts. This is the itemized alternative to CartTotalizerLine totalizerId=\"Discounts\": the entries sum to that same aggregate, so compose this OR that line, never both (both would double-count the same money). Place it in the order summary, typically inside CartTotalizerRoot. The $content field otherLabel names the residual and any unnamed promotion. See cart-totalizer.md."
143
158
  });
144
- function CartDiscountLine({ otherLabel = "Other discounts", className, $data: $dataProp, ...props }) {
159
+ function CartDiscountLine({ className, $data: $dataProp, $content, $locale, ...props }) {
145
160
  const slice = useDataOverride($dataProp);
146
161
  const { locale, currency } = useStorefrontContext();
162
+ const { format } = useMessageFormatter(CartDiscountLineContent, $content);
147
163
  const discounts = slice?.discounts;
148
164
  if (!discounts || discounts.length === 0) return null;
149
165
  return /* @__PURE__ */ jsx("div", {
@@ -152,7 +168,7 @@ function CartDiscountLine({ otherLabel = "Other discounts", className, $data: $d
152
168
  "data-fs-cart-discount-lines": "",
153
169
  children: discounts.map((discount, index) => {
154
170
  const amount = Number(discount.value.amount);
155
- const label = discount.name ?? otherLabel;
171
+ const label = discount.name ?? format("otherLabel");
156
172
  return /* @__PURE__ */ jsxs("div", {
157
173
  "data-fs-cart-discount-line": "",
158
174
  "data-fs-cart-discount-line-kind": discount.kind.toLowerCase(),
@@ -179,26 +195,39 @@ const cartMarkdownFragment = graphql(`
179
195
  }
180
196
  }
181
197
  `);
198
+ const CartMarkdownLineContent = defineContentType({
199
+ id: "cart-markdown-line",
200
+ title: "Cart Markdown Line",
201
+ description: "Label for the aggregate item-level markdown row.",
202
+ schema: {
203
+ type: "object",
204
+ additionalProperties: false,
205
+ properties: { label: {
206
+ type: "string",
207
+ title: "Markdown label",
208
+ format: "icu-message",
209
+ messageSource: "Item discounts"
210
+ } }
211
+ }
212
+ });
182
213
  const CartMarkdownLineDefinition = defineComponent({
183
214
  name: "CartMarkdownLine",
184
215
  importPath: "@vtex/faststore/components",
185
216
  component: CartMarkdownLine,
186
217
  fragment: cartMarkdownFragment,
187
218
  fetchStrategy: "reactive",
219
+ content: CartMarkdownLineContent,
188
220
  editor: {
189
221
  label: "Cart Markdown Line",
190
222
  category: "commerce"
191
223
  },
192
- schema: { label: {
193
- type: "string",
194
- default: "Item discounts",
195
- label: "Markdown label"
196
- } },
197
- guideline: "Aggregate item-level catalog markdown: renders Cart.itemMarkdownTotal (the sum of listPrice − price across the cart, the \"de/por\" catalog savings) as a single negative line. Renders nothing when the cart has no markdown. This is DISTINCT money from CartDiscountLine and CartTotalizerLine totalizerId=\"Discounts\" (those are cart-level promotions/coupons, price − sellingPrice) — it may be shown ALONGSIDE them, not instead of them, and does not double-count. Place it in the order summary, typically inside CartTotalizerRoot. Set label to word the row. See cart-totalizer.md."
224
+ schema: {},
225
+ guideline: "Aggregate item-level catalog markdown: renders Cart.itemMarkdownTotal (the sum of listPrice − price across the cart, the \"de/por\" catalog savings) as a single negative line. Renders nothing when the cart has no markdown. This is DISTINCT money from CartDiscountLine and CartTotalizerLine totalizerId=\"Discounts\" (those are cart-level promotions/coupons, price − sellingPrice) — it may be shown ALONGSIDE them, not instead of them, and does not double-count. Place it in the order summary, typically inside CartTotalizerRoot. The $content field label words the row. See cart-totalizer.md."
198
226
  });
199
- function CartMarkdownLine({ label = "Item discounts", className, $data: $dataProp, ...props }) {
227
+ function CartMarkdownLine({ className, $data: $dataProp, $content, $locale, ...props }) {
200
228
  const slice = useDataOverride($dataProp);
201
229
  const { locale, currency } = useStorefrontContext();
230
+ const { format } = useMessageFormatter(CartMarkdownLineContent, $content);
202
231
  const amount = Number(slice?.itemMarkdownTotal?.amount ?? 0);
203
232
  if (!amount) return null;
204
233
  return /* @__PURE__ */ jsxs("div", {
@@ -208,7 +237,7 @@ function CartMarkdownLine({ label = "Item discounts", className, $data: $dataPro
208
237
  "data-fs-text": "",
209
238
  children: [/* @__PURE__ */ jsx("span", {
210
239
  "data-fs-cart-markdown-line-label": "",
211
- children: label
240
+ children: format("label")
212
241
  }), /* @__PURE__ */ jsx("span", {
213
242
  "data-fs-cart-markdown-line-value": "",
214
243
  children: formatPrice(-amount, locale, currency)
@@ -216,6 +245,6 @@ function CartMarkdownLine({ label = "Item discounts", className, $data: $dataPro
216
245
  });
217
246
  }
218
247
  //#endregion
219
- export { CartDiscountLine, CartDiscountLineDefinition, CartMarkdownLine, CartMarkdownLineDefinition, CartTotalizerLine, CartTotalizerLineDefinition, CartTotalizerRoot, CartTotalizerRootDefinition, useCartTotalizers };
248
+ export { CartDiscountLine, CartDiscountLineContent, CartDiscountLineDefinition, CartMarkdownLine, CartMarkdownLineContent, CartMarkdownLineDefinition, CartTotalizerLine, CartTotalizerLineDefinition, CartTotalizerRoot, CartTotalizerRootDefinition, useCartTotalizers };
220
249
 
221
250
  //# sourceMappingURL=cart-totalizer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cart-totalizer.js","names":[],"sources":["../../../src/matter/cart-totalizer/cart-totalizer.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext, useMemo } from 'react';\nimport type { Money, CartTotalizer as Totalizer } from '../../sdk/cart/operations.js';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport { CartTotalValueContext, formatPrice, isFiniteAmount } from '../cart/cart.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — narrow cart slice (totalizers + total)\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment CartTotalizerData on Query {\n cart {\n __typename\n id\n totalizers {\n __typename\n id\n name\n value {\n ...MoneyFragment\n }\n }\n total {\n ...MoneyFragment\n }\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Context — totalizers list, provided by CartTotalizerRoot for CartTotalizerLine\n// ---------------------------------------------------------------------------\n\ntype CartTotalizerContextValue = Readonly<{\n totalizers: readonly Totalizer[];\n}>;\n\nconst CART_TOTALIZER_UNSET = Symbol('CartTotalizerContextUnset');\n\nconst CartTotalizerContextInternal = createContext<CartTotalizerContextValue | typeof CART_TOTALIZER_UNSET>(\n CART_TOTALIZER_UNSET,\n);\n\nexport function useCartTotalizers(): CartTotalizerContextValue {\n const ctx = useContext(CartTotalizerContextInternal);\n if (ctx === CART_TOTALIZER_UNSET) {\n throw new Error('useCartTotalizers() must be used inside a <CartTotalizerRoot> subtree.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type CartTotalizerRootProps = ComponentPropsWithRef<'div'> & {\n /**\n * Cart totalizer slice forwarded by the reactive runtime (`ReactiveDataProvider`) — it is the\n * value of the `cart` top-level field on `CartTotalizerData on Query`, not the wrapping\n * `{ cart: … }` shape. Receives `null` when the cart has not yet resolved.\n */\n $data?: { totalizers: readonly Totalizer[]; total: Money } | null;\n};\n\nexport type CartTotalizerLineProps = ComponentPropsWithRef<'div'> & {\n /** Which `cart.totalizers` entry to render, selected by `id` (e.g. \"Items\", \"Shipping\", \"Discounts\"). */\n totalizerId: string;\n /** Optional label override; defaults to the totalizer's `name`. */\n label?: string;\n /** Styling hook → `data-fs-cart-totalizer-line-variant`. The F9 discounts line uses `'discount'`. */\n variant?: 'default' | 'discount';\n /** Text rendered in place of the value when the amount is exactly zero (e.g. \"Free\" for shipping — Decision 5). */\n zeroLabel?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const CartTotalizerRootDefinition = defineComponent<CartTotalizerRootProps>({\n name: 'CartTotalizerRoot',\n importPath: '@vtex/faststore/components',\n component: CartTotalizerRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Cart Totalizer Root', category: 'commerce' },\n schema: {},\n guideline:\n 'Focused reactive provider for cart totalizers + total (narrower than CartRoot); merges with CartRoot into one cart query when both are present on the page (e.g. CartRoot wrapping the mini-cart drawer, CartTotalizerRoot composing its footer). Use it to compose an order summary — in a mini-cart drawer footer or a checkout summary panel: wrap a CartTotalizerLine totalizerId=\"Items\" (subtotal), a CartTotalizerLine totalizerId=\"Discounts\" variant=\"discount\" (auto-hides at zero), a CartTotalizerLine totalizerId=\"Shipping\" zeroLabel=\"Grátis\", and a CartTotal for the grand total (set CartTotal label for a labeled total row). CartTotal is root-agnostic and reads the total from this root — there is no CartTotalizerTotal.',\n});\n\nexport const CartTotalizerLineDefinition = defineComponent<CartTotalizerLineProps>({\n name: 'CartTotalizerLine',\n importPath: '@vtex/faststore/components',\n component: CartTotalizerLine,\n editor: { label: 'Cart Totalizer Line', category: 'commerce' },\n schema: {\n totalizerId: { type: 'string', label: 'Totalizer Id' },\n label: { type: 'string', label: 'Label' },\n variant: { type: ['default', 'discount'] as const, default: 'default', label: 'Variant' },\n zeroLabel: { type: 'string', label: 'Zero Label' },\n },\n guideline:\n 'Renders one cart totalizer row (label + value) selected by totalizerId. The canonical order-summary lines are totalizerId=\"Items\" (the subtotal), totalizerId=\"Discounts\" (the discount), and totalizerId=\"Shipping\" (the shipping cost). For the discounts line set variant=\"discount\" — it hides itself when the value is zero (no active discount). The Core API returns a negative amount for discounts; the formatted value displays as-is (e.g. \"-R$ 40,00\"). Set zeroLabel=\"Grátis\" for the shipping line so a zero amount renders the label instead of R$ 0,00. A line whose totalizerId is absent from the cart renders nothing (no empty row). Must be inside CartTotalizerRoot.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function CartTotalizerRoot({ $data: $dataProp, className, children, ...props }: CartTotalizerRootProps) {\n const $data = useDataOverride($dataProp);\n\n const totalizerValue: CartTotalizerContextValue = useMemo(\n () => ({ totalizers: $data?.totalizers ?? [] }),\n [$data?.totalizers],\n );\n\n return (\n <CartTotalValueContext value={$data?.total ?? null}>\n <CartTotalizerContextInternal value={totalizerValue}>\n <div {...props} className={className} data-fs-cart-totalizer-root=\"\">\n {children}\n </div>\n </CartTotalizerContextInternal>\n </CartTotalValueContext>\n );\n}\n\nexport function CartTotalizerLine({\n totalizerId,\n label,\n variant = 'default',\n zeroLabel,\n className,\n children,\n ...props\n}: CartTotalizerLineProps) {\n const { totalizers } = useCartTotalizers();\n const { locale, currency } = useStorefrontContext();\n const totalizer = totalizers.find((t) => t.id === totalizerId);\n\n if (!totalizer) return null;\n\n if (!isFiniteAmount(totalizer.value.amount)) return null;\n\n const amount = Number(totalizer.value.amount);\n\n if (variant === 'discount' && amount === 0) return null;\n\n const valueContent = amount === 0 && zeroLabel != null ? zeroLabel : formatPrice(amount, locale, currency);\n\n return (\n <div {...props} className={className} data-fs-cart-totalizer-line=\"\" data-fs-cart-totalizer-line-variant={variant}>\n <span>{label ?? totalizer.name}</span>\n <span>{children ?? valueContent}</span>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// CartDiscountLine — itemized discount breakdown (F11)\n// ---------------------------------------------------------------------------\n\n// Owns its own `Cart.discounts` slice (ADR-0011 data ownership): the field is fetched only when this\n// leaf is placed and merges with any CartTotalizerRoot / CartRoot cart selection into one query. The\n// entries are the itemized companion to the aggregate \"Discounts\" totalizer and sum to it, so a store\n// composes this OR CartTotalizerLine totalizerId=\"Discounts\", never both.\nconst cartDiscountLinesFragment = graphql(`\n fragment CartDiscountLinesData on Query {\n cart {\n __typename\n id\n discounts {\n name\n value {\n ...MoneyFragment\n }\n kind\n }\n }\n }\n`);\n\nexport type CartDiscountKind = 'PROMOTION' | 'COUPON' | 'OTHER';\n\n/**\n * One cart-level discount line from `Cart.discounts`. `value` is the absolute amount discounted\n * (a positive `Money`); the negative sign is applied on render by the locale's currency format.\n * `amount` is typed `number` but is a string at runtime, so it is `Number()`-coerced before formatting.\n * `name` is null for the OTHER residual and for an unnamed promotion — the `otherLabel` prop names those.\n */\nexport type CartDiscountEntry = {\n name: string | null;\n value: { amount: number; currencyCode: string };\n kind: CartDiscountKind;\n};\n\n/** Cart slice forwarded by the reactive runtime — the value of the top-level `cart` field. */\ntype CartDiscountLinesSlice = { discounts: CartDiscountEntry[] };\n\nexport type CartDiscountLineProps = ComponentPropsWithRef<'div'> & {\n /** Label for lines the API cannot name: the OTHER residual and an unnamed featured promotion. */\n otherLabel?: string;\n /** Cart discount slice forwarded by the reactive runtime; injected/overridden by the runtime or in tests. */\n $data?: CartDiscountLinesSlice | null;\n};\n\nexport const CartDiscountLineDefinition = defineComponent<CartDiscountLineProps>({\n name: 'CartDiscountLine',\n importPath: '@vtex/faststore/components',\n component: CartDiscountLine,\n fragment: cartDiscountLinesFragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Cart Discount Line', category: 'commerce' },\n schema: {\n otherLabel: { type: 'string', default: 'Other discounts', label: 'Unnamed discount label' },\n },\n guideline:\n 'Itemized order-summary discounts: renders one line per entry in cart.discounts (one per promotion ' +\n 'and per coupon, plus a residual \"other\" line), each as label + negative amount. Renders nothing ' +\n 'when the cart has no discounts. This is the itemized alternative to CartTotalizerLine ' +\n 'totalizerId=\"Discounts\": the entries sum to that same aggregate, so compose this OR that line, ' +\n 'never both (both would double-count the same money). Place it in the order summary, typically ' +\n 'inside CartTotalizerRoot. Set otherLabel for the residual and any unnamed promotion. See cart-totalizer.md.',\n});\n\nexport function CartDiscountLine({\n otherLabel = 'Other discounts',\n className,\n $data: $dataProp,\n ...props\n}: CartDiscountLineProps) {\n const slice = useDataOverride<CartDiscountLinesSlice | null | undefined>($dataProp);\n const { locale, currency } = useStorefrontContext();\n const discounts = slice?.discounts;\n\n if (!discounts || discounts.length === 0) {\n return null;\n }\n\n return (\n <div {...props} className={className} data-fs-cart-discount-lines=\"\">\n {discounts.map((discount, index) => {\n const amount = Number(discount.value.amount);\n const label = discount.name ?? otherLabel;\n\n return (\n <div\n key={`${discount.kind}-${discount.name}-${index}`}\n data-fs-cart-discount-line=\"\"\n data-fs-cart-discount-line-kind={discount.kind.toLowerCase()}\n data-fs-text=\"\"\n >\n <span data-fs-cart-discount-line-label=\"\">{label}</span>\n {/* Negate the positive magnitude and let the currency format sign it — no hardcoded glyph. */}\n <span data-fs-cart-discount-line-value=\"\">{formatPrice(-amount, locale, currency)}</span>\n </div>\n );\n })}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// CartMarkdownLine — aggregate item-level catalog markdown (F11 scenario 1)\n// ---------------------------------------------------------------------------\n\n// Renders Cart.itemMarkdownTotal — Σ(listPrice − price) × qty across non-gift lines, computed\n// server-side — as one negative summary line, self-hiding when zero. This is the catalog \"de/por\"\n// markdown that sits ABOVE the Items subtotal, so it is DISTINCT money from the cart-level promotions\n// on the Discounts totalizer / CartDiscountLine (price − sellingPrice): the two coexist in a summary,\n// they do not substitute. Owns its own slice (ADR-0011): the field is fetched only when this leaf is\n// placed and merges with any CartTotalizerRoot / CartRoot cart selection into one query.\nconst cartMarkdownFragment = graphql(`\n fragment CartMarkdownData on Query {\n cart {\n __typename\n id\n itemMarkdownTotal {\n ...MoneyFragment\n }\n }\n }\n`);\n\n/** Cart slice forwarded by the reactive runtime — the value of the top-level `cart` field. */\ntype CartMarkdownSlice = { itemMarkdownTotal: { amount: number; currencyCode: string } };\n\nexport type CartMarkdownLineProps = ComponentPropsWithRef<'div'> & {\n /** Row label for the aggregate item-level markdown. Interim operational default until the i18n catalog lands. */\n label?: string;\n /** Cart markdown slice forwarded by the reactive runtime; injected/overridden by the runtime or in tests. */\n $data?: CartMarkdownSlice | null;\n};\n\nexport const CartMarkdownLineDefinition = defineComponent<CartMarkdownLineProps>({\n name: 'CartMarkdownLine',\n importPath: '@vtex/faststore/components',\n component: CartMarkdownLine,\n fragment: cartMarkdownFragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Cart Markdown Line', category: 'commerce' },\n schema: {\n label: { type: 'string', default: 'Item discounts', label: 'Markdown label' },\n },\n guideline:\n 'Aggregate item-level catalog markdown: renders Cart.itemMarkdownTotal (the sum of listPrice − price ' +\n 'across the cart, the \"de/por\" catalog savings) as a single negative line. Renders nothing when the ' +\n 'cart has no markdown. This is DISTINCT money from CartDiscountLine and CartTotalizerLine ' +\n 'totalizerId=\"Discounts\" (those are cart-level promotions/coupons, price − sellingPrice) — it may be ' +\n 'shown ALONGSIDE them, not instead of them, and does not double-count. Place it in the order summary, ' +\n 'typically inside CartTotalizerRoot. Set label to word the row. See cart-totalizer.md.',\n});\n\nexport function CartMarkdownLine({\n label = 'Item discounts',\n className,\n $data: $dataProp,\n ...props\n}: CartMarkdownLineProps) {\n const slice = useDataOverride<CartMarkdownSlice | null | undefined>($dataProp);\n const { locale, currency } = useStorefrontContext();\n // `amount` is a string at runtime; coerce before checking/formatting. A zero markdown self-hides.\n const amount = Number(slice?.itemMarkdownTotal?.amount ?? 0);\n\n if (!amount) {\n return null;\n }\n\n return (\n <div {...props} className={className} data-fs-cart-markdown-line=\"\" data-fs-text=\"\">\n <span data-fs-cart-markdown-line-label=\"\">{label}</span>\n {/* Negate the positive magnitude and let the currency format sign it — no hardcoded glyph. */}\n <span data-fs-cart-markdown-line-value=\"\">{formatPrice(-amount, locale, currency)}</span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAcA,MAAM,WAAW,QAAQ;;;;;;;;;;;;;;;;;;CAkBxB;AAUD,MAAM,uBAAuB,OAAO,2BAA2B;AAE/D,MAAM,+BAA+B,cACnC,oBACF;AAEA,SAAgB,oBAA+C;CAC7D,MAAM,MAAM,WAAW,4BAA4B;CACnD,IAAI,QAAQ,sBACV,MAAM,IAAI,MAAM,wEAAwE;CAE1F,OAAO;AACT;AA8BA,MAAa,8BAA8B,gBAAwC;CACjF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,QAAQ;EAAE,OAAO;EAAuB,UAAU;CAAW;CAC7D,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,MAAa,8BAA8B,gBAAwC;CACjF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAAuB,UAAU;CAAW;CAC7D,QAAQ;EACN,aAAa;GAAE,MAAM;GAAU,OAAO;EAAe;EACrD,OAAO;GAAE,MAAM;GAAU,OAAO;EAAQ;EACxC,SAAS;GAAE,MAAM,CAAC,WAAW,UAAU;GAAY,SAAS;GAAW,OAAO;EAAU;EACxF,WAAW;GAAE,MAAM;GAAU,OAAO;EAAa;CACnD;CACA,WACE;AACJ,CAAC;AAMD,SAAgB,kBAAkB,EAAE,OAAO,WAAW,WAAW,UAAU,GAAG,SAAiC;CAC7G,MAAM,QAAQ,gBAAgB,SAAS;CA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qBAAC,OAAD;EAAK,GAAI;EAAkB;EAAW,8BAA2B;EAAG,gBAAa;EAAjF,UAAA,CACE,oBAAC,QAAD;GAAM,oCAAiC;GAAI,UAAA;EAAY,CAAA,GAEvD,oBAAC,QAAD;GAAM,oCAAiC;GAAI,UAAA,YAAY,CAAC,QAAQ,QAAQ,QAAQ;EAAQ,CAAA,CACrF;;AAET"}
1
+ {"version":3,"file":"cart-totalizer.js","names":[],"sources":["../../../src/matter/cart-totalizer/cart-totalizer.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType, type MessageLocaleProp } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext, useMemo } from 'react';\nimport type { Money, CartTotalizer as Totalizer } from '../../sdk/cart/operations.js';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport { useMessageFormatter } from '../../sdk/i18n/use-message-formatter.js';\nimport { CartTotalValueContext, formatPrice, isFiniteAmount } from '../cart/cart.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — narrow cart slice (totalizers + total)\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment CartTotalizerData on Query {\n cart {\n __typename\n id\n totalizers {\n __typename\n id\n name\n value {\n ...MoneyFragment\n }\n }\n total {\n ...MoneyFragment\n }\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Context — totalizers list, provided by CartTotalizerRoot for CartTotalizerLine\n// ---------------------------------------------------------------------------\n\ntype CartTotalizerContextValue = Readonly<{\n totalizers: readonly Totalizer[];\n}>;\n\nconst CART_TOTALIZER_UNSET = Symbol('CartTotalizerContextUnset');\n\nconst CartTotalizerContextInternal = createContext<CartTotalizerContextValue | typeof CART_TOTALIZER_UNSET>(\n CART_TOTALIZER_UNSET,\n);\n\nexport function useCartTotalizers(): CartTotalizerContextValue {\n const ctx = useContext(CartTotalizerContextInternal);\n if (ctx === CART_TOTALIZER_UNSET) {\n throw new Error('useCartTotalizers() must be used inside a <CartTotalizerRoot> subtree.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type CartTotalizerRootProps = ComponentPropsWithRef<'div'> & {\n /**\n * Cart totalizer slice forwarded by the reactive runtime (`ReactiveDataProvider`) — it is the\n * value of the `cart` top-level field on `CartTotalizerData on Query`, not the wrapping\n * `{ cart: … }` shape. Receives `null` when the cart has not yet resolved.\n */\n $data?: { totalizers: readonly Totalizer[]; total: Money } | null;\n};\n\nexport type CartTotalizerLineProps = ComponentPropsWithRef<'div'> & {\n /** Which `cart.totalizers` entry to render, selected by `id` (e.g. \"Items\", \"Shipping\", \"Discounts\"). */\n totalizerId: string;\n /** Optional label override; defaults to the totalizer's `name`. */\n label?: string;\n /** Styling hook → `data-fs-cart-totalizer-line-variant`. The F9 discounts line uses `'discount'`. */\n variant?: 'default' | 'discount';\n /** Text rendered in place of the value when the amount is exactly zero (e.g. \"Free\" for shipping — Decision 5). */\n zeroLabel?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const CartTotalizerRootDefinition = defineComponent<CartTotalizerRootProps>({\n name: 'CartTotalizerRoot',\n importPath: '@vtex/faststore/components',\n component: CartTotalizerRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Cart Totalizer Root', category: 'commerce' },\n schema: {},\n guideline:\n 'Focused reactive provider for cart totalizers + total (narrower than CartRoot); merges with CartRoot into one cart query when both are present on the page (e.g. CartRoot wrapping the mini-cart drawer, CartTotalizerRoot composing its footer). Use it to compose an order summary — in a mini-cart drawer footer or a checkout summary panel: wrap a CartTotalizerLine totalizerId=\"Items\" (subtotal), a CartTotalizerLine totalizerId=\"Discounts\" variant=\"discount\" (auto-hides at zero), a CartTotalizerLine totalizerId=\"Shipping\" zeroLabel=\"Grátis\", and a CartTotal for the grand total (set CartTotal label for a labeled total row). CartTotal is root-agnostic and reads the total from this root — there is no CartTotalizerTotal.',\n});\n\nexport const CartTotalizerLineDefinition = defineComponent<CartTotalizerLineProps>({\n name: 'CartTotalizerLine',\n importPath: '@vtex/faststore/components',\n component: CartTotalizerLine,\n editor: { label: 'Cart Totalizer Line', category: 'commerce' },\n schema: {\n totalizerId: { type: 'string', label: 'Totalizer Id' },\n label: { type: 'string', label: 'Label' },\n variant: { type: ['default', 'discount'] as const, default: 'default', label: 'Variant' },\n zeroLabel: { type: 'string', label: 'Zero Label' },\n },\n guideline:\n 'Renders one cart totalizer row (label + value) selected by totalizerId. The canonical order-summary lines are totalizerId=\"Items\" (the subtotal), totalizerId=\"Discounts\" (the discount), and totalizerId=\"Shipping\" (the shipping cost). For the discounts line set variant=\"discount\" — it hides itself when the value is zero (no active discount). The Core API returns a negative amount for discounts; the formatted value displays as-is (e.g. \"-R$ 40,00\"). Set zeroLabel=\"Grátis\" for the shipping line so a zero amount renders the label instead of R$ 0,00. A line whose totalizerId is absent from the cart renders nothing (no empty row). Must be inside CartTotalizerRoot.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function CartTotalizerRoot({ $data: $dataProp, className, children, ...props }: CartTotalizerRootProps) {\n const $data = useDataOverride($dataProp);\n\n const totalizerValue: CartTotalizerContextValue = useMemo(\n () => ({ totalizers: $data?.totalizers ?? [] }),\n [$data?.totalizers],\n );\n\n return (\n <CartTotalValueContext value={$data?.total ?? null}>\n <CartTotalizerContextInternal value={totalizerValue}>\n <div {...props} className={className} data-fs-cart-totalizer-root=\"\">\n {children}\n </div>\n </CartTotalizerContextInternal>\n </CartTotalValueContext>\n );\n}\n\nexport function CartTotalizerLine({\n totalizerId,\n label,\n variant = 'default',\n zeroLabel,\n className,\n children,\n ...props\n}: CartTotalizerLineProps) {\n const { totalizers } = useCartTotalizers();\n const { locale, currency } = useStorefrontContext();\n const totalizer = totalizers.find((t) => t.id === totalizerId);\n\n if (!totalizer) return null;\n\n if (!isFiniteAmount(totalizer.value.amount)) return null;\n\n const amount = Number(totalizer.value.amount);\n\n if (variant === 'discount' && amount === 0) return null;\n\n const valueContent = amount === 0 && zeroLabel != null ? zeroLabel : formatPrice(amount, locale, currency);\n\n return (\n <div {...props} className={className} data-fs-cart-totalizer-line=\"\" data-fs-cart-totalizer-line-variant={variant}>\n <span>{label ?? totalizer.name}</span>\n <span>{children ?? valueContent}</span>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// CartDiscountLine — itemized discount breakdown (F11)\n// ---------------------------------------------------------------------------\n\n// Owns its own `Cart.discounts` slice (ADR-0011 data ownership): the field is fetched only when this\n// leaf is placed and merges with any CartTotalizerRoot / CartRoot cart selection into one query. The\n// entries are the itemized companion to the aggregate \"Discounts\" totalizer and sum to it, so a store\n// composes this OR CartTotalizerLine totalizerId=\"Discounts\", never both.\nconst cartDiscountLinesFragment = graphql(`\n fragment CartDiscountLinesData on Query {\n cart {\n __typename\n id\n discounts {\n name\n value {\n ...MoneyFragment\n }\n kind\n }\n }\n }\n`);\n\nexport type CartDiscountKind = 'PROMOTION' | 'COUPON' | 'OTHER';\n\n/**\n * One cart-level discount line from `Cart.discounts`. `value` is the absolute amount discounted\n * (a positive `Money`); the negative sign is applied on render by the locale's currency format.\n * `amount` is typed `number` but is a string at runtime, so it is `Number()`-coerced before formatting.\n * `name` is null for the OTHER residual and for an unnamed promotion — the `otherLabel` message names those.\n */\nexport type CartDiscountEntry = {\n name: string | null;\n value: { amount: number; currencyCode: string };\n kind: CartDiscountKind;\n};\n\n/** Cart slice forwarded by the reactive runtime — the value of the top-level `cart` field. */\ntype CartDiscountLinesSlice = { discounts: CartDiscountEntry[] };\n\nexport const CartDiscountLineContent = defineContentType({\n id: 'cart-discount-line',\n title: 'Cart Discount Line',\n description: 'Label for the discount lines the API cannot name.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n otherLabel: {\n type: 'string',\n title: 'Unnamed discount label',\n description: 'Names the OTHER residual and an unnamed featured promotion.',\n format: 'icu-message',\n messageSource: 'Other discounts',\n },\n },\n },\n});\n\nexport type CartDiscountLineProps = ComponentPropsWithRef<'div'> &\n MessageLocaleProp & {\n /** Cart discount slice forwarded by the reactive runtime; injected/overridden by the runtime or in tests. */\n $data?: CartDiscountLinesSlice | null;\n $content?: ContentValue<typeof CartDiscountLineContent>;\n };\n\nexport const CartDiscountLineDefinition = defineComponent<CartDiscountLineProps>({\n name: 'CartDiscountLine',\n importPath: '@vtex/faststore/components',\n component: CartDiscountLine,\n fragment: cartDiscountLinesFragment,\n fetchStrategy: 'reactive',\n content: CartDiscountLineContent,\n editor: { label: 'Cart Discount Line', category: 'commerce' },\n schema: {},\n guideline:\n 'Itemized order-summary discounts: renders one line per entry in cart.discounts (one per promotion ' +\n 'and per coupon, plus a residual \"other\" line), each as label + negative amount. Renders nothing ' +\n 'when the cart has no discounts. This is the itemized alternative to CartTotalizerLine ' +\n 'totalizerId=\"Discounts\": the entries sum to that same aggregate, so compose this OR that line, ' +\n 'never both (both would double-count the same money). Place it in the order summary, typically ' +\n 'inside CartTotalizerRoot. The $content field otherLabel names the residual and any unnamed promotion. ' +\n 'See cart-totalizer.md.',\n});\n\nexport function CartDiscountLine({ className, $data: $dataProp, $content, $locale, ...props }: CartDiscountLineProps) {\n const slice = useDataOverride<CartDiscountLinesSlice | null | undefined>($dataProp);\n const { locale, currency } = useStorefrontContext();\n const { format } = useMessageFormatter(CartDiscountLineContent, $content);\n const discounts = slice?.discounts;\n\n if (!discounts || discounts.length === 0) {\n return null;\n }\n\n return (\n <div {...props} className={className} data-fs-cart-discount-lines=\"\">\n {discounts.map((discount, index) => {\n const amount = Number(discount.value.amount);\n const label = discount.name ?? format('otherLabel');\n\n return (\n <div\n key={`${discount.kind}-${discount.name}-${index}`}\n data-fs-cart-discount-line=\"\"\n data-fs-cart-discount-line-kind={discount.kind.toLowerCase()}\n data-fs-text=\"\"\n >\n <span data-fs-cart-discount-line-label=\"\">{label}</span>\n {/* Negate the positive magnitude and let the currency format sign it — no hardcoded glyph. */}\n <span data-fs-cart-discount-line-value=\"\">{formatPrice(-amount, locale, currency)}</span>\n </div>\n );\n })}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// CartMarkdownLine — aggregate item-level catalog markdown (F11 scenario 1)\n// ---------------------------------------------------------------------------\n\n// Renders Cart.itemMarkdownTotal — Σ(listPrice − price) × qty across non-gift lines, computed\n// server-side — as one negative summary line, self-hiding when zero. This is the catalog \"de/por\"\n// markdown that sits ABOVE the Items subtotal, so it is DISTINCT money from the cart-level promotions\n// on the Discounts totalizer / CartDiscountLine (price − sellingPrice): the two coexist in a summary,\n// they do not substitute. Owns its own slice (ADR-0011): the field is fetched only when this leaf is\n// placed and merges with any CartTotalizerRoot / CartRoot cart selection into one query.\nconst cartMarkdownFragment = graphql(`\n fragment CartMarkdownData on Query {\n cart {\n __typename\n id\n itemMarkdownTotal {\n ...MoneyFragment\n }\n }\n }\n`);\n\n/** Cart slice forwarded by the reactive runtime — the value of the top-level `cart` field. */\ntype CartMarkdownSlice = { itemMarkdownTotal: { amount: number; currencyCode: string } };\n\nexport const CartMarkdownLineContent = defineContentType({\n id: 'cart-markdown-line',\n title: 'Cart Markdown Line',\n description: 'Label for the aggregate item-level markdown row.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Markdown label', format: 'icu-message', messageSource: 'Item discounts' },\n },\n },\n});\n\nexport type CartMarkdownLineProps = ComponentPropsWithRef<'div'> &\n MessageLocaleProp & {\n /** Cart markdown slice forwarded by the reactive runtime; injected/overridden by the runtime or in tests. */\n $data?: CartMarkdownSlice | null;\n $content?: ContentValue<typeof CartMarkdownLineContent>;\n };\n\nexport const CartMarkdownLineDefinition = defineComponent<CartMarkdownLineProps>({\n name: 'CartMarkdownLine',\n importPath: '@vtex/faststore/components',\n component: CartMarkdownLine,\n fragment: cartMarkdownFragment,\n fetchStrategy: 'reactive',\n content: CartMarkdownLineContent,\n editor: { label: 'Cart Markdown Line', category: 'commerce' },\n schema: {},\n guideline:\n 'Aggregate item-level catalog markdown: renders Cart.itemMarkdownTotal (the sum of listPrice − price ' +\n 'across the cart, the \"de/por\" catalog savings) as a single negative line. Renders nothing when the ' +\n 'cart has no markdown. This is DISTINCT money from CartDiscountLine and CartTotalizerLine ' +\n 'totalizerId=\"Discounts\" (those are cart-level promotions/coupons, price − sellingPrice) — it may be ' +\n 'shown ALONGSIDE them, not instead of them, and does not double-count. Place it in the order summary, ' +\n 'typically inside CartTotalizerRoot. The $content field label words the row. See cart-totalizer.md.',\n});\n\nexport function CartMarkdownLine({ className, $data: $dataProp, $content, $locale, ...props }: CartMarkdownLineProps) {\n const slice = useDataOverride<CartMarkdownSlice | null | undefined>($dataProp);\n const { locale, currency } = useStorefrontContext();\n const { format } = useMessageFormatter(CartMarkdownLineContent, $content);\n // `amount` is a string at runtime; coerce before checking/formatting. A zero markdown self-hides.\n const amount = Number(slice?.itemMarkdownTotal?.amount ?? 0);\n\n if (!amount) {\n return null;\n }\n\n return (\n <div {...props} className={className} data-fs-cart-markdown-line=\"\" data-fs-text=\"\">\n <span data-fs-cart-markdown-line-label=\"\">{format('label')}</span>\n {/* Negate the positive magnitude and let the currency format sign it — no hardcoded glyph. */}\n <span data-fs-cart-markdown-line-value=\"\">{formatPrice(-amount, locale, currency)}</span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,WAAW,QAAQ;;;;;;;;;;;;;;;;;;CAkBxB;AAUD,MAAM,uBAAuB,OAAO,2BAA2B;AAE/D,MAAM,+BAA+B,cACnC,oBACF;AAEA,SAAgB,oBAA+C;CAC7D,MAAM,MAAM,WAAW,4BAA4B;CACnD,IAAI,QAAQ,sBACV,MAAM,IAAI,MAAM,wEAAwE;CAE1F,OAAO;AACT;AA8BA,MAAa,8BAA8B,gBAAwC;CACjF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,QAAQ;EAAE,OA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Prop } from "../../core/dist/define-content-type.js";
2
+ import { ComponentDefinition } from "../../core/dist/define-component.js";
3
+ import "../../core/dist/index.js";
4
+ import { PageRef } from "../../sdk/navigation/types.js";
5
+ import { ComponentActions } from "../../sdk/actions/types.js";
6
+ import { ComponentPropsWithRef } from "react";
7
+ //#region src/matter/challenge-return/challenge-return.d.ts
8
+ export declare const ChallengeReturnContent: {
9
+ readonly id: "challenge-return";
10
+ readonly title: "Challenge Return";
11
+ readonly description: "Copy for the page the bank sends the shopper back to after a 3D Secure challenge.";
12
+ readonly schema: {
13
+ readonly type: "object";
14
+ readonly additionalProperties: false;
15
+ readonly properties: {
16
+ readonly resumingMessage: {
17
+ readonly type: "string";
18
+ readonly title: "Message while finishing the order";
19
+ readonly format: "icu-message";
20
+ readonly messageSource: "Finishing your order...";
21
+ };
22
+ readonly lateReturnMessage: {
23
+ readonly type: "string";
24
+ readonly title: "Message when the verification lapsed";
25
+ readonly description: "Shown in an alert when the callback answered a refusal: the order was not placed.";
26
+ readonly format: "icu-message";
27
+ readonly messageSource: "3D Secure expired. Go back to the checkout to place your order again.";
28
+ };
29
+ readonly unconfirmedMessage: {
30
+ readonly type: "string";
31
+ readonly title: "Message when the order could not be confirmed";
32
+ readonly description: "Shown as a status when the callback gave no answer: the payment may still be processing.";
33
+ readonly format: "icu-message";
34
+ readonly messageSource: "We could not confirm your order yet. Your payment may still be processing, so please do not pay again.";
35
+ };
36
+ readonly checkoutLabel: {
37
+ readonly type: "string";
38
+ readonly title: "Back to the checkout label";
39
+ readonly description: "Label of the link back to the checkout, shown with the late-return message.";
40
+ readonly format: "icu-message";
41
+ readonly messageSource: "Back to the checkout";
42
+ };
43
+ };
44
+ };
45
+ };
46
+ export type ChallengeReturnProps = ComponentPropsWithRef<'div'> & MessageLocaleProp & {
47
+ /** Where the late-return link goes. e.g. `{ standard: 'checkout' }` */
48
+ checkoutHref?: PageRef | string;
49
+ /**
50
+ * Where the shopper lands once the order is finished. A page reference gets the order's Node id as its
51
+ * `orderId` param. e.g. `{ standard: 'order-placed' }`
52
+ */
53
+ successHref?: PageRef | string;
54
+ /** Merchant-authored copy for each state the page can end on. */
55
+ $content?: ContentValue<typeof ChallengeReturnContent>;
56
+ /** Compiler-injected action surface; carries `payment.gatewayCallback` and `analytics.track`. */
57
+ $actions?: ComponentActions;
58
+ };
59
+ export declare const ChallengeReturnDefinition: ComponentDefinition<ChallengeReturnProps>;
60
+ export declare function ChallengeReturn({ $content, $locale, checkoutHref, successHref, $actions: $actionsProp, className, ref, ...props }: ChallengeReturnProps): import("react/jsx-runtime").JSX.Element;
61
+ //#endregion
62
+ //# sourceMappingURL=challenge-return.d.ts.map
@@ -0,0 +1,241 @@
1
+ "use client";
2
+ import { defineComponent } from "../../core/dist/define-component.js";
3
+ import { defineContentType } from "../../core/dist/define-content-type.js";
4
+ import "../../core/dist/index.js";
5
+ import { resolveSiteRelativeHref } from "../../utils/safe-href.js";
6
+ import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
7
+ import { useStorefrontNavigation } from "../../sdk/navigation/use-storefront-navigation.js";
8
+ import { StorefrontLink } from "../../sdk/navigation/storefront-link.js";
9
+ import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
10
+ import { PAYMENT_NETWORK_ERROR_CODE } from "../../sdk/payment/operations.js";
11
+ import { readChallengeReturn } from "../../sdk/payment/challenge-return.js";
12
+ import { emitPurchaseForOrder, useSettledOrderRead } from "../../sdk/payment/resumed-purchase.js";
13
+ import { useEffect, useRef, useState } from "react";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ //#region src/matter/challenge-return/challenge-return.tsx
16
+ /**
17
+ * The page a shopper lands on when the bank sends them back from a 3D Secure challenge (T208). It finishes
18
+ * the order with no click: one `gatewayCallback` for the order group in its own URL, one read of the settled
19
+ * order, one `purchase`, and a replace to the confirmation page. A whole-page handover component, like
20
+ * `SignInRedirect`: it does its work in an effect and renders only the state it is in.
21
+ *
22
+ * **A return never pays.** This page reaches `payment.gatewayCallback` and nothing else of the payment
23
+ * actions, and renders no field of any kind: the card was handed to the gateway before the shopper left.
24
+ *
25
+ * The query is read from the document in the effect, never through `useSearchParams()`, which would need a
26
+ * `Suspense` boundary the generator does not emit on a prerendered route; a prerender has no query at all,
27
+ * so the first paint is the resuming state and the effect decides.
28
+ */
29
+ const CHECKOUT_PAGE = { standard: "checkout" };
30
+ const ORDER_PLACED_PAGE = { standard: "order-placed" };
31
+ const ChallengeReturnContent = defineContentType({
32
+ id: "challenge-return",
33
+ title: "Challenge Return",
34
+ description: "Copy for the page the bank sends the shopper back to after a 3D Secure challenge.",
35
+ schema: {
36
+ type: "object",
37
+ additionalProperties: false,
38
+ properties: {
39
+ resumingMessage: {
40
+ type: "string",
41
+ title: "Message while finishing the order",
42
+ format: "icu-message",
43
+ messageSource: "Finishing your order..."
44
+ },
45
+ lateReturnMessage: {
46
+ type: "string",
47
+ title: "Message when the verification lapsed",
48
+ description: "Shown in an alert when the callback answered a refusal: the order was not placed.",
49
+ format: "icu-message",
50
+ messageSource: "3D Secure expired. Go back to the checkout to place your order again."
51
+ },
52
+ unconfirmedMessage: {
53
+ type: "string",
54
+ title: "Message when the order could not be confirmed",
55
+ description: "Shown as a status when the callback gave no answer: the payment may still be processing.",
56
+ format: "icu-message",
57
+ messageSource: "We could not confirm your order yet. Your payment may still be processing, so please do not pay again."
58
+ },
59
+ checkoutLabel: {
60
+ type: "string",
61
+ title: "Back to the checkout label",
62
+ description: "Label of the link back to the checkout, shown with the late-return message.",
63
+ format: "icu-message",
64
+ messageSource: "Back to the checkout"
65
+ }
66
+ }
67
+ }
68
+ });
69
+ const ChallengeReturnDefinition = defineComponent({
70
+ name: "ChallengeReturn",
71
+ importPath: "@vtex/faststore/components",
72
+ component: ChallengeReturn,
73
+ actions: {
74
+ payment: ["gatewayCallback"],
75
+ analytics: ["track"]
76
+ },
77
+ content: ChallengeReturnContent,
78
+ editor: {
79
+ label: "Challenge Return",
80
+ category: "commerce"
81
+ },
82
+ schema: {
83
+ checkoutHref: {
84
+ type: "link",
85
+ default: { standard: "checkout" },
86
+ label: "Checkout page"
87
+ },
88
+ successHref: {
89
+ type: "link",
90
+ default: { standard: "order-placed" },
91
+ fills: ["orderId"],
92
+ label: "Confirmation Page"
93
+ }
94
+ },
95
+ guideline: "The whole of the page the bank sends the shopper back to after a 3D Secure challenge: on mount it finishes the order with no click (one gateway callback for the order group in the URL, one read of the order, one purchase event) and replaces the page with the order confirmation. Place it alone on its own page, named by PlaceOrder's challengeReturnHref, never beside anything the shopper is meant to read. It renders no payment field and never pays: a shopper who returns after the verification lapsed reads an alert with a link back to the checkout, and one whose order could not be confirmed reads a status that says not to pay again, with no such link. See challenge-return.md."
96
+ });
97
+ /** What a result with no readable `userErrors` collapses to: this package's own code, which says nothing about the order. */
98
+ const PAYMENT_NETWORK_ERROR_CODE_ENTRY = {
99
+ code: PAYMENT_NETWORK_ERROR_CODE,
100
+ message: "Unable to complete the request. Please try again."
101
+ };
102
+ /** True when the entry carries a code the server sent: an answer about this payment, not this package's own collapse. */
103
+ function carriesServerCode(userErrors) {
104
+ return userErrors.some((userError) => typeof userError?.code === "string" && userError.code !== "NETWORK_ERROR");
105
+ }
106
+ /** The confirmation target: the authored page filled with the Node id, or a site-relative path of the store. */
107
+ function confirmationTarget(successHref, orderNodeId) {
108
+ if (typeof successHref !== "string") return {
109
+ ...successHref,
110
+ params: {
111
+ ...successHref.params,
112
+ orderId: orderNodeId
113
+ }
114
+ };
115
+ const destination = resolveSiteRelativeHref(successHref);
116
+ if (destination.safe && !destination.href.includes("{")) return destination.href;
117
+ if (process.env.NODE_ENV !== "production") console.warn("[ChallengeReturn] successHref is not a path of this store; going to the confirmation page instead.");
118
+ return {
119
+ ...ORDER_PLACED_PAGE,
120
+ params: { orderId: orderNodeId }
121
+ };
122
+ }
123
+ /** The order node id the callback settled, or the state the page ends on when it did not. */
124
+ async function callGateway(callback, orderGroup) {
125
+ let result;
126
+ try {
127
+ result = await callback(orderGroup, { acceptChallenges: true });
128
+ } catch {
129
+ return { failedState: "unconfirmed" };
130
+ }
131
+ const userErrors = Array.isArray(result?.userErrors) ? result.userErrors : [PAYMENT_NETWORK_ERROR_CODE_ENTRY];
132
+ if (userErrors.length > 0) return { failedState: carriesServerCode(userErrors) ? "late" : "unconfirmed" };
133
+ const orderNodeId = result.orderNodeId ?? null;
134
+ return orderNodeId === null ? { failedState: "unconfirmed" } : { orderNodeId };
135
+ }
136
+ /** Reports the purchase and goes to the confirmation page; the state the page ends on. */
137
+ async function reportAndConfirm({ track, readOrder, replace, hrefFor, successHref }, orderNodeId) {
138
+ await emitPurchaseForOrder({
139
+ track,
140
+ readOrder,
141
+ orderNodeId
142
+ });
143
+ const confirmation = confirmationTarget(successHref, orderNodeId);
144
+ if (hrefFor(confirmation) === null) return "unconfirmed";
145
+ try {
146
+ replace(confirmation);
147
+ } catch {
148
+ console.error("[ChallengeReturn] could not go to the confirmation page");
149
+ return "unconfirmed";
150
+ }
151
+ return "done";
152
+ }
153
+ async function finishChallengeReturn({ gatewayCallback, settle, ...rest }) {
154
+ const returned = readChallengeReturn(globalThis.location.search);
155
+ if (returned === null) {
156
+ settle("late");
157
+ return;
158
+ }
159
+ if (!gatewayCallback) {
160
+ console.error("[ChallengeReturn] the payment action namespace is not injected");
161
+ settle("unconfirmed");
162
+ return;
163
+ }
164
+ const outcome = await callGateway(gatewayCallback, returned.orderGroup);
165
+ if ("failedState" in outcome) {
166
+ settle(outcome.failedState);
167
+ return;
168
+ }
169
+ settle(await reportAndConfirm(rest, outcome.orderNodeId));
170
+ }
171
+ function ChallengeReturn({ $content, $locale, checkoutHref = CHECKOUT_PAGE, successHref = ORDER_PLACED_PAGE, $actions: $actionsProp, className, ref, ...props }) {
172
+ const $actions = useActionsOverride($actionsProp);
173
+ const { format } = useMessageFormatter(ChallengeReturnContent, $content);
174
+ const gatewayCallback = $actions?.payment?.gatewayCallback;
175
+ const track = $actions?.analytics?.track;
176
+ const readOrder = useSettledOrderRead();
177
+ const { replace, hrefFor } = useStorefrontNavigation();
178
+ const [state, setState] = useState("resuming");
179
+ const startedRef = useRef(false);
180
+ const mountedRef = useRef(false);
181
+ useEffect(() => {
182
+ mountedRef.current = true;
183
+ if (!startedRef.current) {
184
+ startedRef.current = true;
185
+ const settle = (next) => {
186
+ if (mountedRef.current) setState(next);
187
+ };
188
+ finishChallengeReturn({
189
+ gatewayCallback,
190
+ track,
191
+ readOrder,
192
+ replace,
193
+ hrefFor,
194
+ successHref,
195
+ settle
196
+ });
197
+ }
198
+ return () => {
199
+ mountedRef.current = false;
200
+ };
201
+ }, [
202
+ gatewayCallback,
203
+ track,
204
+ readOrder,
205
+ replace,
206
+ hrefFor,
207
+ successHref
208
+ ]);
209
+ return /* @__PURE__ */ jsxs("div", {
210
+ ...props,
211
+ ref,
212
+ className,
213
+ "data-fs-challenge-return": "",
214
+ children: [
215
+ state === "resuming" ? /* @__PURE__ */ jsx("output", {
216
+ "data-fs-challenge-return-resuming": "",
217
+ children: format("resumingMessage")
218
+ }) : null,
219
+ state === "late" ? /* @__PURE__ */ jsxs("div", {
220
+ role: "alert",
221
+ "data-fs-challenge-return-late": "",
222
+ children: [/* @__PURE__ */ jsx("span", {
223
+ "data-fs-challenge-return-message": "",
224
+ children: format("lateReturnMessage")
225
+ }), /* @__PURE__ */ jsx(StorefrontLink, {
226
+ href: checkoutHref,
227
+ "data-fs-challenge-return-checkout-link": "",
228
+ children: format("checkoutLabel")
229
+ })]
230
+ }) : null,
231
+ state === "unconfirmed" ? /* @__PURE__ */ jsx("output", {
232
+ "data-fs-challenge-return-unconfirmed": "",
233
+ children: format("unconfirmedMessage")
234
+ }) : null
235
+ ]
236
+ });
237
+ }
238
+ //#endregion
239
+ export { ChallengeReturn, ChallengeReturnContent, ChallengeReturnDefinition };
240
+
241
+ //# sourceMappingURL=challenge-return.js.map