@vtex/faststore 0.0.7 → 0.0.10

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 (498) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/actions.json +194 -1
  3. package/dist/catalog.json +3449 -1612
  4. package/dist/cli/index.d.ts +512 -63
  5. package/dist/cli/index.js +2098 -686
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/cli/server-runtime.js +44 -24
  8. package/dist/cli/server-runtime.js.map +1 -1
  9. package/dist/client.d.ts +5 -1
  10. package/dist/client.js +5 -1
  11. package/dist/components.d.ts +42 -10
  12. package/dist/components.js +47 -15
  13. package/dist/content-types.json +823 -0
  14. package/dist/core/dist/define-component.d.ts +12 -2
  15. package/dist/docs/account-access-gate.md +4 -4
  16. package/dist/docs/account-address-book.md +519 -0
  17. package/dist/docs/account-entry-point.md +5 -5
  18. package/dist/docs/account-menu.md +7 -7
  19. package/dist/docs/account-saved-cards.md +301 -0
  20. package/dist/docs/alert-dialog.md +2 -2
  21. package/dist/docs/billing-address.md +17 -9
  22. package/dist/docs/binding-switcher.md +154 -0
  23. package/dist/docs/card-entry.md +38 -7
  24. package/dist/docs/card-summary.md +175 -0
  25. package/dist/docs/cardholder-document.md +16 -14
  26. package/dist/docs/cart-destination.md +238 -0
  27. package/dist/docs/cart-item.md +22 -4
  28. package/dist/docs/cart-totalizer.md +1 -1
  29. package/dist/docs/cart.md +126 -19
  30. package/dist/docs/client-profile-fieldset.md +7 -5
  31. package/dist/docs/copy-text.md +84 -0
  32. package/dist/docs/document-field.md +8 -8
  33. package/dist/docs/footer-link-group.md +2 -2
  34. package/dist/docs/footer-social.md +1 -1
  35. package/dist/docs/free-shipping-progress.md +13 -9
  36. package/dist/docs/header-root.md +1 -1
  37. package/dist/docs/incentives.md +4 -4
  38. package/dist/docs/logo.md +6 -6
  39. package/dist/docs/my-account-profile.md +4 -4
  40. package/dist/docs/navigation-link-list.md +2 -2
  41. package/dist/docs/navigation-link.md +3 -3
  42. package/dist/docs/order-cancel.md +52 -0
  43. package/dist/docs/order-delivery-address.md +63 -0
  44. package/dist/docs/order-delivery-group.md +83 -0
  45. package/dist/docs/order-details-back.md +41 -0
  46. package/dist/docs/order-details-header.md +48 -0
  47. package/dist/docs/order-list-row.md +46 -0
  48. package/dist/docs/order-list-search.md +101 -0
  49. package/dist/docs/order-list-views.md +97 -0
  50. package/dist/docs/order-list.md +94 -0
  51. package/dist/docs/order-payment.md +94 -0
  52. package/dist/docs/order-placed-date.md +49 -0
  53. package/dist/docs/order-placed-payment-summary.md +13 -15
  54. package/dist/docs/order-placed.md +225 -0
  55. package/dist/docs/order-progress.md +88 -0
  56. package/dist/docs/order-status-badge.md +91 -0
  57. package/dist/docs/order-summary.md +53 -0
  58. package/dist/docs/payment-method-badges.md +16 -5
  59. package/dist/docs/payment-methods.md +1 -1
  60. package/dist/docs/place-order.md +13 -9
  61. package/dist/docs/product-information.md +2 -2
  62. package/dist/docs/product-shelf.md +7 -0
  63. package/dist/docs/saved-cards.md +2 -2
  64. package/dist/docs/select.md +22 -10
  65. package/dist/docs/session.md +1 -1
  66. package/dist/docs/shipping-address.md +1 -1
  67. package/dist/docs/sign-in-redirect.md +7 -7
  68. package/dist/docs/toast.md +35 -13
  69. package/dist/index.d.ts +7 -2
  70. package/dist/index.js +2 -1
  71. package/dist/internal/client.d.ts +9 -1
  72. package/dist/internal/client.js +10 -2
  73. package/dist/internal/server.d.ts +8 -2
  74. package/dist/internal/server.js +8 -2
  75. package/dist/matter/account-access-gate/account-access-gate.d.ts +2 -1
  76. package/dist/matter/account-access-gate/account-access-gate.js +19 -16
  77. package/dist/matter/account-access-gate/account-access-gate.js.map +1 -1
  78. package/dist/matter/account-address-book/account-address-book-delete.d.ts +60 -0
  79. package/dist/matter/account-address-book/account-address-book-delete.js +184 -0
  80. package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -0
  81. package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +19 -0
  82. package/dist/matter/account-address-book/account-address-book-deliverability.js +50 -0
  83. package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -0
  84. package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +42 -0
  85. package/dist/matter/account-address-book/account-address-book-form-parts.js +146 -0
  86. package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -0
  87. package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +25 -0
  88. package/dist/matter/account-address-book/account-address-book-profile-notice.js +72 -0
  89. package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -0
  90. package/dist/matter/account-address-book/account-address-book.d.ts +120 -0
  91. package/dist/matter/account-address-book/account-address-book.js +469 -0
  92. package/dist/matter/account-address-book/account-address-book.js.map +1 -0
  93. package/dist/matter/account-address-book/account-address-country-switch.js +59 -0
  94. package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -0
  95. package/dist/matter/account-address-book/account-address-country.d.ts +36 -0
  96. package/dist/matter/account-address-book/account-address-country.js +151 -0
  97. package/dist/matter/account-address-book/account-address-country.js.map +1 -0
  98. package/dist/matter/account-address-book/account-address-first-line.js +11 -0
  99. package/dist/matter/account-address-book/account-address-first-line.js.map +1 -0
  100. package/dist/matter/account-address-book/account-address-form-context.d.ts +55 -0
  101. package/dist/matter/account-address-book/account-address-form-context.js +14 -0
  102. package/dist/matter/account-address-book/account-address-form-context.js.map +1 -0
  103. package/dist/matter/account-address-book/account-address-form.d.ts +85 -0
  104. package/dist/matter/account-address-book/account-address-form.js +946 -0
  105. package/dist/matter/account-address-book/account-address-form.js.map +1 -0
  106. package/dist/matter/account-address-book/account-address-postal-autofill.js +189 -0
  107. package/dist/matter/account-address-book/account-address-postal-autofill.js.map +1 -0
  108. package/dist/matter/account-address-book/account-address-record.d.ts +26 -0
  109. package/dist/matter/account-address-book/account-address-record.js +138 -0
  110. package/dist/matter/account-address-book/account-address-record.js.map +1 -0
  111. package/dist/matter/account-entry-point/account-entry-point.js +11 -11
  112. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
  113. package/dist/matter/account-menu/account-menu.d.ts +7 -3
  114. package/dist/matter/account-menu/account-menu.js +69 -28
  115. package/dist/matter/account-menu/account-menu.js.map +1 -1
  116. package/dist/matter/account-saved-cards/account-saved-cards.d.ts +383 -0
  117. package/dist/matter/account-saved-cards/account-saved-cards.js +956 -0
  118. package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -0
  119. package/dist/matter/billing-address/billing-address.d.ts +30 -17
  120. package/dist/matter/billing-address/billing-address.js +128 -33
  121. package/dist/matter/billing-address/billing-address.js.map +1 -1
  122. package/dist/matter/breadcrumb/breadcrumb.js +2 -2
  123. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
  124. package/dist/matter/card-entry/card-capture.js +4 -3
  125. package/dist/matter/card-entry/card-capture.js.map +1 -1
  126. package/dist/matter/card-entry/card-entry.d.ts +5 -3
  127. package/dist/matter/card-entry/card-entry.js +77 -27
  128. package/dist/matter/card-entry/card-entry.js.map +1 -1
  129. package/dist/matter/cardholder-document/cardholder-document.d.ts +10 -9
  130. package/dist/matter/cardholder-document/cardholder-document.js +36 -16
  131. package/dist/matter/cardholder-document/cardholder-document.js.map +1 -1
  132. package/dist/matter/cart/cart-namespace.d.ts +5 -1
  133. package/dist/matter/cart/cart-namespace.js +5 -1
  134. package/dist/matter/cart/cart-namespace.js.map +1 -1
  135. package/dist/matter/cart/cart.d.ts +41 -6
  136. package/dist/matter/cart/cart.js +267 -54
  137. package/dist/matter/cart/cart.js.map +1 -1
  138. package/dist/matter/cart-destination/cart-destination.d.ts +222 -0
  139. package/dist/matter/cart-destination/cart-destination.js +613 -0
  140. package/dist/matter/cart-destination/cart-destination.js.map +1 -0
  141. package/dist/matter/cart-item/cart-item.d.ts +4 -2
  142. package/dist/matter/cart-item/cart-item.js +76 -17
  143. package/dist/matter/cart-item/cart-item.js.map +1 -1
  144. package/dist/matter/cart-totalizer/cart-totalizer.js +3 -2
  145. package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
  146. package/dist/matter/client-preferences/client-preferences-fieldset.js +1 -1
  147. package/dist/matter/client-profile-form/client-profile-fieldset.js +8 -5
  148. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
  149. package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +6 -3
  150. package/dist/matter/free-shipping-progress/free-shipping-progress.js +76 -33
  151. package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
  152. package/dist/matter/identity-edit/identity-edit.js +3 -3
  153. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  154. package/dist/matter/identity-summary/identity-summary.js +2 -2
  155. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  156. package/dist/matter/my-account-profile/my-account-profile.d.ts +3 -3
  157. package/dist/matter/my-account-profile/my-account-profile.js +4 -4
  158. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  159. package/dist/matter/order-cancel/order-cancel.d.ts +110 -0
  160. package/dist/matter/order-cancel/order-cancel.js +344 -0
  161. package/dist/matter/order-cancel/order-cancel.js.map +1 -0
  162. package/dist/matter/order-delivery-address/order-delivery-address.d.ts +73 -0
  163. package/dist/matter/order-delivery-address/order-delivery-address.js +172 -0
  164. package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -0
  165. package/dist/matter/order-delivery-group/order-delivery-group.d.ts +128 -0
  166. package/dist/matter/order-delivery-group/order-delivery-group.js +408 -0
  167. package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -0
  168. package/dist/matter/order-details-header/order-details-header.d.ts +104 -0
  169. package/dist/matter/order-details-header/order-details-header.js +190 -0
  170. package/dist/matter/order-details-header/order-details-header.js.map +1 -0
  171. package/dist/matter/order-list/customer-orders-filter.d.ts +12 -0
  172. package/dist/matter/order-list/customer-orders-filter.js +30 -0
  173. package/dist/matter/order-list/customer-orders-filter.js.map +1 -0
  174. package/dist/matter/order-list/order-list.d.ts +121 -0
  175. package/dist/matter/order-list/order-list.js +395 -0
  176. package/dist/matter/order-list/order-list.js.map +1 -0
  177. package/dist/matter/order-list-row/order-list-row.d.ts +44 -0
  178. package/dist/matter/order-list-row/order-list-row.js +127 -0
  179. package/dist/matter/order-list-row/order-list-row.js.map +1 -0
  180. package/dist/matter/order-list-search/order-list-search.d.ts +72 -0
  181. package/dist/matter/order-list-search/order-list-search.js +296 -0
  182. package/dist/matter/order-list-search/order-list-search.js.map +1 -0
  183. package/dist/matter/order-list-views/order-list-views.d.ts +65 -0
  184. package/dist/matter/order-list-views/order-list-views.js +154 -0
  185. package/dist/matter/order-list-views/order-list-views.js.map +1 -0
  186. package/dist/matter/order-payment/order-payment.d.ts +83 -0
  187. package/dist/matter/order-payment/order-payment.js +258 -0
  188. package/dist/matter/order-payment/order-payment.js.map +1 -0
  189. package/dist/matter/order-placed/order-placed-deliveries.d.ts +145 -0
  190. package/dist/matter/order-placed/order-placed-deliveries.js +380 -0
  191. package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -0
  192. package/dist/matter/order-placed/order-placed.d.ts +122 -0
  193. package/dist/matter/order-placed/order-placed.js +452 -0
  194. package/dist/matter/order-placed/order-placed.js.map +1 -0
  195. package/dist/matter/order-placed-date/order-placed-date.d.ts +45 -0
  196. package/dist/matter/order-placed-date/order-placed-date.js +92 -0
  197. package/dist/matter/order-placed-date/order-placed-date.js.map +1 -0
  198. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +5 -8
  199. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +29 -81
  200. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
  201. package/dist/matter/order-progress/order-progress.d.ts +85 -0
  202. package/dist/matter/order-progress/order-progress.js +203 -0
  203. package/dist/matter/order-progress/order-progress.js.map +1 -0
  204. package/dist/matter/order-summary/order-summary.d.ts +81 -0
  205. package/dist/matter/order-summary/order-summary.js +192 -0
  206. package/dist/matter/order-summary/order-summary.js.map +1 -0
  207. package/dist/matter/payment/cardholder-document-rule.d.ts +35 -0
  208. package/dist/matter/payment/cardholder-document-rule.js +35 -0
  209. package/dist/matter/payment/cardholder-document-rule.js.map +1 -0
  210. package/dist/matter/payment/payment-card-capture.js +38 -23
  211. package/dist/matter/payment/payment-card-capture.js.map +1 -1
  212. package/dist/matter/payment/payment-controller.js +11 -0
  213. package/dist/matter/payment/payment-controller.js.map +1 -1
  214. package/dist/matter/payment/payment-method-badges.js +4 -2
  215. package/dist/matter/payment/payment-method-badges.js.map +1 -1
  216. package/dist/matter/payment/payment.js +11 -0
  217. package/dist/matter/payment/payment.js.map +1 -1
  218. package/dist/matter/payment/use-payment-method-selection.d.ts +39 -0
  219. package/dist/matter/payment/use-payment-method-selection.js +30 -2
  220. package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
  221. package/dist/matter/payment/use-payment-submit-gate.d.ts +16 -2
  222. package/dist/matter/payment/use-payment-submit-gate.js +42 -14
  223. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
  224. package/dist/matter/place-order/place-order.d.ts +12 -7
  225. package/dist/matter/place-order/place-order.js +126 -103
  226. package/dist/matter/place-order/place-order.js.map +1 -1
  227. package/dist/matter/pricing/pricing.js +5 -5
  228. package/dist/matter/pricing/pricing.js.map +1 -1
  229. package/dist/matter/product-shelf/product-shelf.d.ts +7 -0
  230. package/dist/matter/product-shelf/product-shelf.js +115 -1
  231. package/dist/matter/product-shelf/product-shelf.js.map +1 -1
  232. package/dist/matter/region/region.js +1 -1
  233. package/dist/matter/saved-cards/saved-cards.js +26 -15
  234. package/dist/matter/saved-cards/saved-cards.js.map +1 -1
  235. package/dist/matter/session/session.js +2 -2
  236. package/dist/matter/session/session.js.map +1 -1
  237. package/dist/matter/shipping-address/country-descriptors.d.ts +1 -0
  238. package/dist/matter/shipping-address/country-descriptors.js +23 -1
  239. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  240. package/dist/matter/shipping-address/shipping-address.js +62 -14
  241. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  242. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +2 -2
  243. package/dist/matter/shipping-simulator/shipping-simulator.js +6 -2
  244. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  245. package/dist/matter/sign-in-redirect/sign-in-redirect.js +48 -10
  246. package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -1
  247. package/dist/matter/variant-selector/variant-selector.js +2 -2
  248. package/dist/matter/variant-selector/variant-selector.js.map +1 -1
  249. package/dist/particles/address-summary/address-summary.js +2 -2
  250. package/dist/particles/address-summary/address-summary.js.map +1 -1
  251. package/dist/particles/alert-dialog/alert-dialog.d.ts +5 -1
  252. package/dist/particles/alert-dialog/alert-dialog.js +5 -2
  253. package/dist/particles/alert-dialog/alert-dialog.js.map +1 -1
  254. package/dist/particles/binding-switcher/binding-switcher.d.ts +38 -0
  255. package/dist/particles/binding-switcher/binding-switcher.js +183 -0
  256. package/dist/particles/binding-switcher/binding-switcher.js.map +1 -0
  257. package/dist/particles/card-summary/card-network.d.ts +17 -0
  258. package/dist/particles/card-summary/card-network.js +25 -0
  259. package/dist/particles/card-summary/card-network.js.map +1 -0
  260. package/dist/particles/card-summary/card-summary.d.ts +83 -0
  261. package/dist/particles/card-summary/card-summary.js +188 -0
  262. package/dist/particles/card-summary/card-summary.js.map +1 -0
  263. package/dist/particles/copy-text/copy-text.d.ts +28 -0
  264. package/dist/particles/copy-text/copy-text.js +140 -0
  265. package/dist/particles/copy-text/copy-text.js.map +1 -0
  266. package/dist/particles/document-field/document-field.d.ts +34 -5
  267. package/dist/particles/document-field/document-field.js +115 -19
  268. package/dist/particles/document-field/document-field.js.map +1 -1
  269. package/dist/particles/field/field.js +1 -1
  270. package/dist/particles/field/field.js.map +1 -1
  271. package/dist/particles/footer-link-group/footer-link-group.d.ts +6 -2
  272. package/dist/particles/footer-link-group/footer-link-group.js +18 -7
  273. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
  274. package/dist/particles/footer-social/footer-social.d.ts +1 -1
  275. package/dist/particles/footer-social/footer-social.js +1 -1
  276. package/dist/particles/footer-social/footer-social.js.map +1 -1
  277. package/dist/particles/incentives/incentives.d.ts +7 -3
  278. package/dist/particles/incentives/incentives.js +8 -3
  279. package/dist/particles/incentives/incentives.js.map +1 -1
  280. package/dist/particles/logo/logo.d.ts +3 -2
  281. package/dist/particles/logo/logo.js +20 -8
  282. package/dist/particles/logo/logo.js.map +1 -1
  283. package/dist/particles/navigation-link/navigation-link.d.ts +2 -3
  284. package/dist/particles/navigation-link/navigation-link.js +4 -4
  285. package/dist/particles/navigation-link/navigation-link.js.map +1 -1
  286. package/dist/particles/navigation-link-list/navigation-link-list.d.ts +6 -2
  287. package/dist/particles/navigation-link-list/navigation-link-list.js +18 -7
  288. package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -1
  289. package/dist/particles/order-details-back/order-details-back.d.ts +28 -0
  290. package/dist/particles/order-details-back/order-details-back.js +52 -0
  291. package/dist/particles/order-details-back/order-details-back.js.map +1 -0
  292. package/dist/particles/order-status-badge/order-status-badge.d.ts +19 -0
  293. package/dist/particles/order-status-badge/order-status-badge.js +50 -0
  294. package/dist/particles/order-status-badge/order-status-badge.js.map +1 -0
  295. package/dist/particles/payment-methods/payment-methods.d.ts +1 -1
  296. package/dist/particles/payment-methods/payment-methods.js +1 -1
  297. package/dist/particles/payment-methods/payment-methods.js.map +1 -1
  298. package/dist/particles/phone-field/phone-field.js +2 -2
  299. package/dist/particles/phone-field/phone-field.js.map +1 -1
  300. package/dist/particles/select/select.js +6 -6
  301. package/dist/particles/select/select.js.map +1 -1
  302. package/dist/particles/toast/toast.d.ts +21 -7
  303. package/dist/particles/toast/toast.js +76 -8
  304. package/dist/particles/toast/toast.js.map +1 -1
  305. package/dist/schema.graphql +1376 -126
  306. package/dist/sdk/actions/address-action-provider.d.ts +16 -0
  307. package/dist/sdk/actions/address-action-provider.js +20 -0
  308. package/dist/sdk/actions/address-action-provider.js.map +1 -0
  309. package/dist/sdk/actions/analytics-action-provider.js +1 -1
  310. package/dist/sdk/actions/index.d.ts +5 -1
  311. package/dist/sdk/actions/index.js +5 -1
  312. package/dist/sdk/actions/locale-action-provider.d.ts +16 -0
  313. package/dist/sdk/actions/locale-action-provider.js +20 -0
  314. package/dist/sdk/actions/locale-action-provider.js.map +1 -0
  315. package/dist/sdk/actions/order-action-provider.d.ts +12 -0
  316. package/dist/sdk/actions/order-action-provider.js +16 -0
  317. package/dist/sdk/actions/order-action-provider.js.map +1 -0
  318. package/dist/sdk/actions/saved-card-action-provider.d.ts +12 -0
  319. package/dist/sdk/actions/saved-card-action-provider.js +16 -0
  320. package/dist/sdk/actions/saved-card-action-provider.js.map +1 -0
  321. package/dist/sdk/actions/types.d.ts +10 -2
  322. package/dist/sdk/address/address-fields.js +38 -0
  323. package/dist/sdk/address/address-fields.js.map +1 -0
  324. package/dist/sdk/address/checkout-readiness.js +17 -0
  325. package/dist/sdk/address/checkout-readiness.js.map +1 -0
  326. package/dist/sdk/address/constants.js +60 -0
  327. package/dist/sdk/address/constants.js.map +1 -0
  328. package/dist/sdk/address/country-display.js +19 -0
  329. package/dist/sdk/address/country-display.js.map +1 -0
  330. package/dist/sdk/address/country-rules.js +30 -0
  331. package/dist/sdk/address/country-rules.js.map +1 -0
  332. package/dist/sdk/address/format-address.js +18 -0
  333. package/dist/sdk/address/format-address.js.map +1 -0
  334. package/dist/sdk/address/iso-countries.js +262 -0
  335. package/dist/sdk/address/iso-countries.js.map +1 -0
  336. package/dist/sdk/address/layouts.js +56 -0
  337. package/dist/sdk/address/layouts.js.map +1 -0
  338. package/dist/sdk/address/messages.js +97 -0
  339. package/dist/sdk/address/messages.js.map +1 -0
  340. package/dist/sdk/address/operations.d.ts +54 -0
  341. package/dist/sdk/address/operations.js +83 -0
  342. package/dist/sdk/address/operations.js.map +1 -0
  343. package/dist/sdk/address/postal-code-lookup-operations.js +23 -0
  344. package/dist/sdk/address/postal-code-lookup-operations.js.map +1 -0
  345. package/dist/sdk/address/postal-code.js +11 -0
  346. package/dist/sdk/address/postal-code.js.map +1 -0
  347. package/dist/sdk/address/schema.js +14 -0
  348. package/dist/sdk/address/schema.js.map +1 -0
  349. package/dist/sdk/address/server-fields.js +25 -0
  350. package/dist/sdk/address/server-fields.js.map +1 -0
  351. package/dist/sdk/address/switch-country.js +57 -0
  352. package/dist/sdk/address/switch-country.js.map +1 -0
  353. package/dist/sdk/address/types.d.ts +26 -0
  354. package/dist/sdk/address/use-address-actions.d.ts +29 -0
  355. package/dist/sdk/address/use-address-actions.js +247 -0
  356. package/dist/sdk/address/use-address-actions.js.map +1 -0
  357. package/dist/sdk/address/use-address-by-postal-code.js +57 -0
  358. package/dist/sdk/address/use-address-by-postal-code.js.map +1 -0
  359. package/dist/sdk/address/validate-address.js +62 -0
  360. package/dist/sdk/address/validate-address.js.map +1 -0
  361. package/dist/sdk/cache/storefront-cache.js +30 -4
  362. package/dist/sdk/cache/storefront-cache.js.map +1 -1
  363. package/dist/sdk/cart/operations.d.ts +2 -1
  364. package/dist/sdk/cart/operations.js +55 -1
  365. package/dist/sdk/cart/operations.js.map +1 -1
  366. package/dist/sdk/cart/optimistic.d.ts +30 -7
  367. package/dist/sdk/cart/optimistic.js +78 -41
  368. package/dist/sdk/cart/optimistic.js.map +1 -1
  369. package/dist/sdk/cart/use-cart-actions.d.ts +7 -0
  370. package/dist/sdk/cart/use-cart-actions.js +61 -15
  371. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  372. package/dist/sdk/cart/use-cart-sync-sales-channel.js +70 -0
  373. package/dist/sdk/cart/use-cart-sync-sales-channel.js.map +1 -0
  374. package/dist/sdk/client/fetch-page-data.d.ts +11 -0
  375. package/dist/sdk/client/fetch-page-data.js +12 -1
  376. package/dist/sdk/client/fetch-page-data.js.map +1 -1
  377. package/dist/sdk/content/create-content-runtime.js +1 -8
  378. package/dist/sdk/content/create-content-runtime.js.map +1 -1
  379. package/dist/sdk/data/failed-fields.js +23 -0
  380. package/dist/sdk/data/failed-fields.js.map +1 -0
  381. package/dist/sdk/data/index.js +2 -2
  382. package/dist/sdk/data/page-reactive-data-root.d.ts +45 -7
  383. package/dist/sdk/data/page-reactive-data-root.js +88 -12
  384. package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
  385. package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
  386. package/dist/sdk/generated/fragment-types.js +2 -0
  387. package/dist/sdk/generated/fragment-types.js.map +1 -1
  388. package/dist/sdk/generated/gql.js +17 -11
  389. package/dist/sdk/generated/gql.js.map +1 -1
  390. package/dist/sdk/generated/graphql.d.ts +185 -46
  391. package/dist/sdk/generated/graphql.js +2587 -155
  392. package/dist/sdk/generated/graphql.js.map +1 -1
  393. package/dist/sdk/i18n/messages/en-US.js +157 -1
  394. package/dist/sdk/i18n/messages/en-US.json +157 -1
  395. package/dist/sdk/i18n/messages/en-US.json.d.ts +156 -0
  396. package/dist/sdk/i18n/messages/es-ES.js +157 -1
  397. package/dist/sdk/i18n/messages/es-ES.json +157 -1
  398. package/dist/sdk/i18n/messages/pt-BR.js +157 -1
  399. package/dist/sdk/i18n/messages/pt-BR.json +157 -1
  400. package/dist/sdk/i18n/provider.js +1 -1
  401. package/dist/sdk/i18n/provider.js.map +1 -1
  402. package/dist/sdk/locale/binding-switch-provider.d.ts +13 -0
  403. package/dist/sdk/locale/binding-switch-provider.js +20 -0
  404. package/dist/sdk/locale/binding-switch-provider.js.map +1 -0
  405. package/dist/sdk/locale/use-locale-actions.d.ts +16 -0
  406. package/dist/sdk/locale/use-locale-actions.js +70 -0
  407. package/dist/sdk/locale/use-locale-actions.js.map +1 -0
  408. package/dist/sdk/navigation/binding-switch.d.ts +39 -0
  409. package/dist/sdk/navigation/binding-switch.js +129 -0
  410. package/dist/sdk/navigation/binding-switch.js.map +1 -0
  411. package/dist/sdk/navigation/current-page.js +30 -0
  412. package/dist/sdk/navigation/current-page.js.map +1 -0
  413. package/dist/sdk/navigation/decode-route-params.d.ts +11 -0
  414. package/dist/sdk/navigation/decode-route-params.js +32 -0
  415. package/dist/sdk/navigation/decode-route-params.js.map +1 -0
  416. package/dist/sdk/navigation/not-found-log.d.ts +28 -0
  417. package/dist/sdk/navigation/not-found-log.js +133 -0
  418. package/dist/sdk/navigation/not-found-log.js.map +1 -0
  419. package/dist/sdk/navigation/path.js +25 -0
  420. package/dist/sdk/navigation/path.js.map +1 -0
  421. package/dist/sdk/navigation/redirect.d.ts +11 -0
  422. package/dist/sdk/navigation/redirect.js +22 -0
  423. package/dist/sdk/navigation/redirect.js.map +1 -0
  424. package/dist/sdk/navigation/report.js +70 -0
  425. package/dist/sdk/navigation/report.js.map +1 -0
  426. package/dist/sdk/navigation/resolve-storefront-href.d.ts +12 -0
  427. package/dist/sdk/navigation/resolve-storefront-href.js +214 -0
  428. package/dist/sdk/navigation/resolve-storefront-href.js.map +1 -0
  429. package/dist/sdk/navigation/route-identity-provider.d.ts +11 -0
  430. package/dist/sdk/navigation/route-identity-provider.js +20 -0
  431. package/dist/sdk/navigation/route-identity-provider.js.map +1 -0
  432. package/dist/sdk/navigation/route-map-provider.d.ts +19 -0
  433. package/dist/sdk/navigation/route-map-provider.js +29 -0
  434. package/dist/sdk/navigation/route-map-provider.js.map +1 -0
  435. package/dist/sdk/navigation/storefront-link.d.ts +16 -0
  436. package/dist/sdk/navigation/storefront-link.js +66 -0
  437. package/dist/sdk/navigation/storefront-link.js.map +1 -0
  438. package/dist/sdk/navigation/types.d.ts +45 -0
  439. package/dist/sdk/navigation/use-storefront-navigation.d.ts +26 -0
  440. package/dist/sdk/navigation/use-storefront-navigation.js +73 -0
  441. package/dist/sdk/navigation/use-storefront-navigation.js.map +1 -0
  442. package/dist/sdk/navigation/use-storefront-route.d.ts +26 -0
  443. package/dist/sdk/navigation/use-storefront-route.js +87 -0
  444. package/dist/sdk/navigation/use-storefront-route.js.map +1 -0
  445. package/dist/sdk/navigation/use-storefront-search-params.d.ts +11 -0
  446. package/dist/sdk/navigation/use-storefront-search-params.js +16 -0
  447. package/dist/sdk/navigation/use-storefront-search-params.js.map +1 -0
  448. package/dist/sdk/orders/completion-badge.d.ts +8 -0
  449. package/dist/sdk/orders/completion-badge.js +47 -0
  450. package/dist/sdk/orders/completion-badge.js.map +1 -0
  451. package/dist/sdk/orders/order-operations.d.ts +19 -0
  452. package/dist/sdk/orders/order-operations.js +21 -0
  453. package/dist/sdk/orders/order-operations.js.map +1 -0
  454. package/dist/sdk/orders/use-order-actions.d.ts +23 -0
  455. package/dist/sdk/orders/use-order-actions.js +62 -0
  456. package/dist/sdk/orders/use-order-actions.js.map +1 -0
  457. package/dist/sdk/payment/gateway-origin.js +26 -13
  458. package/dist/sdk/payment/gateway-origin.js.map +1 -1
  459. package/dist/sdk/payment/gateway.d.ts +14 -2
  460. package/dist/sdk/payment/gateway.js +32 -14
  461. package/dist/sdk/payment/gateway.js.map +1 -1
  462. package/dist/sdk/payment/operations.js +11 -0
  463. package/dist/sdk/payment/operations.js.map +1 -1
  464. package/dist/sdk/payment/submission-registry.d.ts +2 -1
  465. package/dist/sdk/payment/submission-registry.js +12 -8
  466. package/dist/sdk/payment/submission-registry.js.map +1 -1
  467. package/dist/sdk/payment/use-payment-actions.d.ts +5 -3
  468. package/dist/sdk/payment/use-payment-actions.js +5 -2
  469. package/dist/sdk/payment/use-payment-actions.js.map +1 -1
  470. package/dist/sdk/payment/use-place-order.d.ts +6 -3
  471. package/dist/sdk/payment/use-place-order.js +333 -143
  472. package/dist/sdk/payment/use-place-order.js.map +1 -1
  473. package/dist/sdk/saved-cards/operations.d.ts +16 -0
  474. package/dist/sdk/saved-cards/operations.js +41 -0
  475. package/dist/sdk/saved-cards/operations.js.map +1 -0
  476. package/dist/sdk/saved-cards/use-saved-card-actions.d.ts +26 -0
  477. package/dist/sdk/saved-cards/use-saved-card-actions.js +86 -0
  478. package/dist/sdk/saved-cards/use-saved-card-actions.js.map +1 -0
  479. package/dist/sdk/seo/page-alternates.d.ts +57 -0
  480. package/dist/sdk/seo/page-alternates.js +127 -0
  481. package/dist/sdk/seo/page-alternates.js.map +1 -0
  482. package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
  483. package/dist/sdk/shipping/shipping-operations.js +13 -0
  484. package/dist/sdk/shipping/shipping-operations.js.map +1 -1
  485. package/dist/sdk/state/cart.d.ts +9 -2
  486. package/dist/sdk/state/cart.js +9 -2
  487. package/dist/sdk/state/cart.js.map +1 -1
  488. package/dist/utils/own-value.js +19 -0
  489. package/dist/utils/own-value.js.map +1 -0
  490. package/dist/utils/safe-href.d.ts +4 -4
  491. package/dist/utils/safe-href.js +31 -22
  492. package/dist/utils/safe-href.js.map +1 -1
  493. package/package.json +5 -1
  494. package/skills/storefront-asset/SKILL.md +111 -0
  495. package/skills/storefront-asset/references/api-side.md +153 -0
  496. package/skills/storefront-asset/references/findings.md +40 -0
  497. package/skills/storefront-asset/references/ui-side.md +94 -0
  498. package/src/styles/tailwind.css +28 -2
@@ -1 +1 @@
1
- {"version":3,"file":"shipping-simulator.js","names":[],"sources":["../../../src/matter/shipping-simulator/shipping-simulator.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { FormattedMessage, type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { CartShippingSimulateInput } from '../../sdk/shipping/cart-operations.js';\nimport type { ShippingSimulateInput } from '../../sdk/shipping/operations.js';\nimport { useCartShippingSimulation } from '../../sdk/shipping/use-cart-shipping-simulation.js';\nimport { useShippingSimulation } from '../../sdk/shipping/use-shipping-simulation.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingSimulatorData on Query {\n productBySlug(slug: $slug) {\n variants(first: 1) {\n edges {\n node {\n id\n sellers {\n id\n isDefault\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data types (shape of the fragment result)\n// ---------------------------------------------------------------------------\n\ntype RawShippingSimulatorData = {\n variants: {\n edges: Array<{\n node: {\n id: string;\n sellers: Array<{\n id: string;\n isDefault: boolean;\n }>;\n };\n }>;\n };\n};\n\n// ---------------------------------------------------------------------------\n// Domain types (mirror the shippingSimulation GraphQL contract)\n// ---------------------------------------------------------------------------\n\ntype MoneyValue = { amount: number; currencyCode: string };\n\ntype DeliveryChannel = 'DELIVERY' | 'PICKUP' | 'UNKNOWN';\n\ntype ShippingEstimateUnit = 'BUSINESS_DAYS' | 'DAYS' | 'HOURS' | 'MINUTES';\n\ntype ShippingEstimate = { value: number; unit: ShippingEstimateUnit };\n\n// Exported alongside `ShippingSimulatorContextValue` so `DeliveryOptionsRoot`\n// (matter/delivery-options) can type against the exact shape the reused leaves expect, with no\n// structural duplication (docs/storefront-core/reference-free-particle-model.md § Read side — state).\nexport type ShippingOption = {\n id: string;\n name: string;\n channel: DeliveryChannel;\n shippingEstimate: ShippingEstimate;\n price: MoneyValue;\n listPrice: MoneyValue;\n};\n\ntype ShippingSimulateErrorCode = 'INVALID_POSTAL_CODE' | 'UNKNOWN';\n\n// Exported with `ShippingSimulationPayload` so the `./client` entry can name the simulate callback's\n// whole contract — the SDK hooks return it and a store writing its own `onSimulate` has to name it.\nexport type ShippingSimulateError = {\n code: ShippingSimulateErrorCode;\n message: string;\n};\n\nexport type ShippingSimulationPayload = {\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n};\n\ntype Status = 'idle' | 'loading' | 'success' | 'error';\n\nexport type ShippingSimulatorContextValue = {\n postalCode: string;\n setPostalCode: (value: string) => void;\n status: Status;\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n submit: () => void;\n};\n\nconst SHIPPING_SIMULATOR_CONTEXT_UNSET = Symbol('ShippingSimulatorContextUnset');\n\nexport type ShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n quantity?: number;\n variantId?: string;\n seller?: string;\n $data?: RawShippingSimulatorData | null;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: ShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type CartShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: CartShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type ShippingSimulatorFormProps = ComponentPropsWithRef<'form'>;\n\nexport type ShippingSimulatorInputProps = Omit<ComponentPropsWithRef<'input'>, 'value' | 'onChange'> & {\n format?: boolean;\n};\n\nexport type ShippingSimulatorSubmitProps = ComponentPropsWithRef<'button'>;\n\nexport type ShippingSimulatorLoadingProps = ComponentPropsWithRef<'output'>;\n\nexport type ShippingSimulatorErrorProps = ComponentPropsWithRef<'div'>;\n\nexport type ShippingSimulatorOptionsProps = ComponentPropsWithRef<'ul'> & {\n sortBy?: 'price' | 'estimate';\n maxOptions?: number;\n};\n\nexport type ShippingSimulatorOptionProps = ComponentPropsWithRef<'li'>;\n\nexport type ShippingSimulatorOptionNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionEstimateProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionFreeBadgeProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorEmptyProps = ComponentPropsWithRef<'output'>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n// Exported so `DeliveryOptionsRoot` can become a third provider by importing these same Context\n// objects directly (context matching is by identity, not shape). The two hooks below stay\n// module-private — providers need the objects, not the consumer API (Decision 2).\nexport const ShippingSimulatorContext = createContext<\n ShippingSimulatorContextValue | typeof SHIPPING_SIMULATOR_CONTEXT_UNSET\n>(SHIPPING_SIMULATOR_CONTEXT_UNSET);\n\nexport const OptionItemContext = createContext<ShippingOption | null>(null);\n\nfunction useShippingSimulator(): ShippingSimulatorContextValue {\n const ctx = useContext(ShippingSimulatorContext);\n if (ctx === SHIPPING_SIMULATOR_CONTEXT_UNSET) {\n throw new Error('ShippingSimulator components must be used inside ShippingSimulatorRoot.');\n }\n return ctx;\n}\n\nfunction useOptionItem(): ShippingOption {\n const ctx = useContext(OptionItemContext);\n if (!ctx) {\n throw new Error('ShippingSimulatorOption components must be used inside ShippingSimulatorOptions.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Each unit's whole sentence, and the variable that sentence names.\n//\n// Whole sentence, not a unit fragment interpolated into a wrapper: interpolating a translated\n// fragment into a translated wrapper freezes \"preposition + noun\" order into every language, and\n// hands the translator `em {estimate}` with no way to agree preposition, article or case with a noun\n// they cannot see. The variable is named after what it counts (`{days}`, `{hours}`) rather than a\n// generic `{count}`, for the same reason.\n//\n// A `Record` and not a `switch` with a default: a fifth unit arriving in the GraphQL schema is a\n// type error here, not a silent fallback to the wrong sentence.\n//\n// `variable` is the union of the names those sentences read, never `string`: widened, a typo passes\n// typecheck, lint and every test, and the shopper gets the raw ICU pattern because `onIntlError` is\n// silent in production. The parity assertion in the test file closes the other half of the gap — that\n// the name written here is the one the catalog's message actually names.\nexport const ESTIMATE_MESSAGE: Record<ShippingEstimateUnit, { id: MessageId; variable: 'days' | 'hours' | 'minutes' }> =\n {\n BUSINESS_DAYS: { id: 'fs/shipping.estimate.in-business-days', variable: 'days' },\n DAYS: { id: 'fs/shipping.estimate.in-days', variable: 'days' },\n HOURS: { id: 'fs/shipping.estimate.in-hours', variable: 'hours' },\n MINUTES: { id: 'fs/shipping.estimate.in-minutes', variable: 'minutes' },\n };\n\n// Business days weigh the same as calendar days: exact wall-clock conversion is unknowable and\n// the ranking only needs a consistent order.\nconst ESTIMATE_UNIT_MINUTES: Record<ShippingEstimateUnit, number> = {\n MINUTES: 1,\n HOURS: 60,\n DAYS: 1440,\n BUSINESS_DAYS: 1440,\n};\n\nfunction sortShippingOptions(options: readonly ShippingOption[], sortBy: 'price' | 'estimate'): ShippingOption[] {\n const rank =\n sortBy === 'price'\n ? (option: ShippingOption) => Number(option.price.amount)\n : (option: ShippingOption) => option.shippingEstimate.value * ESTIMATE_UNIT_MINUTES[option.shippingEstimate.unit];\n return [...options].sort((a, b) => rank(a) - rank(b));\n}\n\nfunction normalizePostalCode(value: string): string {\n return value.replace(/\\D/g, '').slice(0, 8);\n}\n\nfunction formatPostalCode(value: string): string {\n const digits = normalizePostalCode(value);\n return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;\n}\n\nfunction extractProductFromData(data: RawShippingSimulatorData | null | undefined): {\n variantId: string | null;\n seller: string | null;\n} {\n if (!data) return { variantId: null, seller: null };\n const edge = data.variants?.edges?.[0];\n if (!edge) return { variantId: null, seller: null };\n const { id, sellers } = edge.node;\n const defaultSeller = sellers?.find((s) => s.isDefault) ?? sellers?.[0];\n return { variantId: id ?? null, seller: defaultSeller?.id ?? null };\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulatorRootDefinition = defineComponent<ShippingSimulatorRootProps>({\n name: 'ShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n quantity: { type: 'number', default: 1, label: 'Quantity' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the PDP shipping simulator: a shopper types a postal code and sees a shipping preview for ONE product on a product detail page. Backed by shippingSimulation and a product fragment (productBySlug(slug: $slug)), so it must live on a page with a $slug variable. Use CartShippingSimulatorRoot instead for a whole-cart calculator in the cart/mini-cart. All other ShippingSimulator components must be descendants of this one.',\n});\n\nexport const CartShippingSimulatorRootDefinition = defineComponent<CartShippingSimulatorRootProps>({\n name: 'CartShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: CartShippingSimulatorRoot,\n editor: { label: 'Cart Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the cart/mini-cart shipping calculator: the shopper types a postal code and sees the shipping options for the WHOLE cart. Backed by cartShippingSimulation (cart sourced server-side via x-order-form-id); needs no CartRoot ancestor and no product fragment. Use ShippingSimulatorRoot instead for a single-product shipping preview on a PDP. All other CartShippingSimulator components must be descendants of this one.',\n});\n\nexport const ShippingSimulatorFormDefinition = defineComponent<ShippingSimulatorFormProps>({\n name: 'ShippingSimulatorForm',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorForm,\n editor: { label: 'Shipping Simulator Form', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Form wrapper that holds ShippingSimulatorInput and ShippingSimulatorSubmit; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorInputDefinition = defineComponent<ShippingSimulatorInputProps>({\n name: 'ShippingSimulatorInput',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorInput,\n editor: { label: 'Shipping Simulator Input', category: 'action' },\n schema: {\n format: { type: 'boolean', default: false, label: 'Auto-format CEP (00000-000)' },\n },\n requiresContext: 'shipping-simulator',\n guideline:\n 'Postal-code text input; enable `format` to auto-hyphenate the CEP as the user types (e.g. 01310-100). The placeholder comes from the message catalog. Must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorSubmitDefinition = defineComponent<ShippingSimulatorSubmitProps>({\n name: 'ShippingSimulatorSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorSubmit,\n editor: { label: 'Shipping Simulator Submit', category: 'action' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline: 'Submit button for the postal-code form; must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorLoadingDefinition = defineComponent<ShippingSimulatorLoadingProps>({\n name: 'ShippingSimulatorLoading',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorLoading,\n editor: { label: 'Shipping Simulator Loading', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Loading indicator shown while a simulation is in progress; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorErrorDefinition = defineComponent<ShippingSimulatorErrorProps>({\n name: 'ShippingSimulatorError',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorError,\n editor: { label: 'Shipping Simulator Error', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Error banner shown when the simulation returns validation errors; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorOptionsDefinition = defineComponent<ShippingSimulatorOptionsProps>({\n name: 'ShippingSimulatorOptions',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptions,\n editor: { label: 'Shipping Simulator Options', category: 'commerce' },\n schema: {\n sortBy: { type: ['price', 'estimate'] as const, label: 'Sort by' },\n maxOptions: { type: 'number', label: 'Max options' },\n },\n requiresContext: 'shipping-simulator',\n providesContext: 'shipping-simulator-option',\n guideline:\n 'List that renders one ShippingSimulatorOption per available shipping option; must be a descendant of a shipping-simulator Root (PDP or cart). Renders every option in API order by default; set sortBy (\"price\" = cheapest first, \"estimate\" = fastest first) and maxOptions to cap the list — sortBy=\"price\" with maxOptions=1 shows only the cheapest option. See shipping-simulator.md.',\n});\n\nexport const ShippingSimulatorOptionDefinition = defineComponent<ShippingSimulatorOptionProps>({\n name: 'ShippingSimulatorOption',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOption,\n editor: { label: 'Shipping Simulator Option', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Container for a single shipping option row; holds ShippingSimulatorOptionName, ShippingSimulatorOptionEstimate, and ShippingSimulatorOptionPrice. Must be a descendant of ShippingSimulatorOptions.',\n});\n\nexport const ShippingSimulatorOptionNameDefinition = defineComponent<ShippingSimulatorOptionNameProps>({\n name: 'ShippingSimulatorOptionName',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionName,\n editor: { label: 'Option Name', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping option name (e.g. \"Entrega Normal\"); must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionEstimateDefinition = defineComponent<ShippingSimulatorOptionEstimateProps>({\n name: 'ShippingSimulatorOptionEstimate',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionEstimate,\n editor: { label: 'Option Estimate', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the delivery estimate in the active locale, one whole sentence per unit from the message catalog; a zero-value estimate (any unit) reads as an arrival-today message instead, since \"chega em 0 dias úteis\" reads wrong. Must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionPriceDefinition = defineComponent<ShippingSimulatorOptionPriceProps>({\n name: 'ShippingSimulatorOptionPrice',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionPrice,\n editor: { label: 'Option Price', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping price, showing the free-shipping label from the message catalog when the amount is zero; must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionFreeBadgeDefinition = defineComponent<ShippingSimulatorOptionFreeBadgeProps>({\n name: 'ShippingSimulatorOptionFreeBadge',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionFreeBadge,\n editor: { label: 'Option Free Badge', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Badge shown only when the current option price is zero (free shipping); renders nothing otherwise. Must be a descendant of ShippingSimulatorOption. Orthogonal to the free-price replacement text owned by ShippingSimulatorOptionPrice.',\n});\n\nexport const ShippingSimulatorEmptyDefinition = defineComponent<ShippingSimulatorEmptyProps>({\n name: 'ShippingSimulatorEmpty',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorEmpty,\n editor: { label: 'Shipping Simulator Empty', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Message shown when a simulation ran and returned no shipping options (e.g. no carrier common to the whole cart). Renders nothing before the first submit and nothing when options or an error are present. The copy comes from the message catalog; pass children to override. Must be a descendant of a shipping-simulator Root.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ShippingSimulatorRoot({\n country = 'BRA',\n quantity = 1,\n variantId: variantIdProp,\n seller: sellerProp,\n $data: $dataProp,\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: ShippingSimulatorRootProps) {\n const defaultSimulate = useShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const $data = useDataOverride($dataProp);\n const extracted = extractProductFromData($data);\n const variantId = variantIdProp ?? extracted.variantId;\n const seller = sellerProp ?? extracted.seller;\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n if (!onSimulate || !variantId || !seller) return;\n\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country, variantId, quantity, seller })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode, quantity, seller, variantId]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function CartShippingSimulatorRoot({\n country = 'BRA',\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: CartShippingSimulatorRootProps) {\n const defaultSimulate = useCartShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function ShippingSimulatorForm({ className, children, ...props }: ShippingSimulatorFormProps) {\n const { submit } = useShippingSimulator();\n\n return (\n <form\n {...props}\n className={className}\n data-fs-shipping-simulator-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n );\n}\n\nexport function ShippingSimulatorInput({\n className,\n placeholder,\n 'aria-label': ariaLabel,\n format = false,\n ...props\n}: ShippingSimulatorInputProps) {\n const { postalCode, setPostalCode } = useShippingSimulator();\n const intl = useIntl();\n const displayValue = format ? formatPostalCode(postalCode) : postalCode;\n\n return (\n <input\n {...props}\n aria-label={ariaLabel ?? intl.formatMessage({ id: 'fs/shipping.postal-code.aria-label' })}\n className={className}\n data-fs-shipping-simulator-input=\"\"\n type=\"text\"\n value={displayValue}\n onChange={(event) => setPostalCode(normalizePostalCode(event.target.value))}\n placeholder={placeholder ?? intl.formatMessage({ id: 'fs/shipping.postal-code.placeholder' })}\n pattern=\"\\d{5}-?\\d{3}\"\n maxLength={9}\n inputMode=\"numeric\"\n required\n />\n );\n}\n\nexport function ShippingSimulatorSubmit({ className, children, disabled, ...props }: ShippingSimulatorSubmitProps) {\n const { status } = useShippingSimulator();\n const isLoading = status === 'loading';\n\n return (\n <button\n {...props}\n type=\"submit\"\n className={className}\n data-fs-shipping-simulator-submit=\"\"\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n >\n {children}\n </button>\n );\n}\n\nexport function ShippingSimulatorLoading({ className, children, ...props }: ShippingSimulatorLoadingProps) {\n const { status } = useShippingSimulator();\n if (status !== 'loading') return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-loading=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.calculating\" />}\n </output>\n );\n}\n\nexport function ShippingSimulatorError({ className, children, ...props }: ShippingSimulatorErrorProps) {\n const { userErrors } = useShippingSimulator();\n const [firstError] = userErrors;\n if (!firstError) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-shipping-simulator-error=\"\">\n {children ?? firstError.message}\n </div>\n );\n}\n\nexport function ShippingSimulatorOptions({\n sortBy,\n maxOptions,\n className,\n children,\n ...props\n}: ShippingSimulatorOptionsProps) {\n const { shippingOptions } = useShippingSimulator();\n\n const visibleOptions = useMemo(() => {\n if (!shippingOptions) return null;\n const sorted = sortBy ? sortShippingOptions(shippingOptions, sortBy) : shippingOptions;\n return maxOptions && maxOptions > 0 ? sorted.slice(0, maxOptions) : sorted;\n }, [shippingOptions, sortBy, maxOptions]);\n\n if (!visibleOptions || visibleOptions.length === 0) return null;\n\n return (\n <ul {...props} className={className} data-fs-shipping-simulator-options=\"\">\n {visibleOptions.map((option) => (\n <OptionItemContext key={option.id} value={option}>\n {children}\n </OptionItemContext>\n ))}\n </ul>\n );\n}\n\nexport function ShippingSimulatorOption({ className, children, ...props }: ShippingSimulatorOptionProps) {\n const option = useOptionItem();\n\n return (\n <li\n {...props}\n className={className}\n data-fs-shipping-simulator-option=\"\"\n data-fs-shipping-simulator-option-channel={option.channel}\n >\n {children}\n </li>\n );\n}\n\nexport function ShippingSimulatorOptionName({ className, children, ...props }: ShippingSimulatorOptionNameProps) {\n const option = useOptionItem();\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-name=\"\">\n {children ?? option.name}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionEstimate({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionEstimateProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { value, unit } = option.shippingEstimate;\n const { id, variable } = ESTIMATE_MESSAGE[unit];\n const text =\n value === 0\n ? intl.formatMessage({ id: 'fs/shipping.estimate.today' })\n : intl.formatMessage({ id }, { [variable]: value });\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-estimate=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionPrice({ className, children, ...props }: ShippingSimulatorOptionPriceProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { locale, currency } = useStorefrontContext();\n const text =\n option.price.amount === 0\n ? intl.formatMessage({ id: 'fs/shipping.free-price' })\n : formatPrice(option.price.amount, locale, currency);\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-price=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionFreeBadge({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionFreeBadgeProps) {\n const option = useOptionItem();\n if (option.price.amount !== 0) return null;\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-free-badge=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.free-badge\" />}\n </span>\n );\n}\n\nexport function ShippingSimulatorEmpty({ className, children, ...props }: ShippingSimulatorEmptyProps) {\n const { shippingOptions, userErrors } = useShippingSimulator();\n // Idle (null) → nothing; error → nothing (Error owns it); options present → nothing.\n const simulatedEmpty = Array.isArray(shippingOptions) && shippingOptions.length === 0 && userErrors.length === 0;\n if (!simulatedEmpty) return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-empty=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.no-options\" />}\n </output>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulator = {\n Root: ShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n\nexport const CartShippingSimulator = {\n Root: CartShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,WAAyB;;;;;;;;;;;;;;;;;AAqF/B,MAAM,mCAAmC,OAAO,+BAA+B;AA0D/E,MAAa,2BAA2B,cAEtC,gCAAgC;AAElC,MAAa,oBAAoB,cAAqC,IAAI;AAE1E,SAAS,uBAAsD;CA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;AAEZ;AAMA,MAAa,oBAAoB;CAC/B,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,OAAO;AACT;AAEA,MAAa,wBAAwB;CACnC,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,OAAO;AACT"}
1
+ {"version":3,"file":"shipping-simulator.js","names":[],"sources":["../../../src/matter/shipping-simulator/shipping-simulator.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { FormattedMessage, type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { CartShippingSimulateInput } from '../../sdk/shipping/cart-operations.js';\nimport type { ShippingSimulateInput } from '../../sdk/shipping/operations.js';\nimport { useCartShippingSimulation } from '../../sdk/shipping/use-cart-shipping-simulation.js';\nimport { useShippingSimulation } from '../../sdk/shipping/use-shipping-simulation.js';\nimport { isFiniteAmount } from '../cart/cart.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingSimulatorData on Query {\n productBySlug(slug: $slug) {\n variants(first: 1) {\n edges {\n node {\n id\n sellers {\n id\n isDefault\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data types (shape of the fragment result)\n// ---------------------------------------------------------------------------\n\ntype RawShippingSimulatorData = {\n variants: {\n edges: Array<{\n node: {\n id: string;\n sellers: Array<{\n id: string;\n isDefault: boolean;\n }>;\n };\n }>;\n };\n};\n\n// ---------------------------------------------------------------------------\n// Domain types (mirror the shippingSimulation GraphQL contract)\n// ---------------------------------------------------------------------------\n\ntype MoneyValue = { amount: string; currencyCode: string };\n\ntype DeliveryChannel = 'DELIVERY' | 'PICKUP' | 'UNKNOWN';\n\nexport type ShippingEstimateUnit = 'BUSINESS_DAYS' | 'DAYS' | 'HOURS' | 'MINUTES';\n\ntype ShippingEstimate = { value: number; unit: ShippingEstimateUnit };\n\n// Exported alongside `ShippingSimulatorContextValue` so `DeliveryOptionsRoot`\n// (matter/delivery-options) can type against the exact shape the reused leaves expect, with no\n// structural duplication (docs/storefront-core/reference-free-particle-model.md § Read side — state).\nexport type ShippingOption = {\n id: string;\n name: string;\n channel: DeliveryChannel;\n shippingEstimate: ShippingEstimate;\n price: MoneyValue;\n listPrice: MoneyValue;\n};\n\ntype ShippingSimulateErrorCode = 'INVALID_POSTAL_CODE' | 'UNKNOWN';\n\n// Exported with `ShippingSimulationPayload` so the `./client` entry can name the simulate callback's\n// whole contract — the SDK hooks return it and a store writing its own `onSimulate` has to name it.\nexport type ShippingSimulateError = {\n code: ShippingSimulateErrorCode;\n message: string;\n};\n\nexport type ShippingSimulationPayload = {\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n};\n\ntype Status = 'idle' | 'loading' | 'success' | 'error';\n\nexport type ShippingSimulatorContextValue = {\n postalCode: string;\n setPostalCode: (value: string) => void;\n status: Status;\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n submit: () => void;\n};\n\nconst SHIPPING_SIMULATOR_CONTEXT_UNSET = Symbol('ShippingSimulatorContextUnset');\n\nexport type ShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n quantity?: number;\n variantId?: string;\n seller?: string;\n $data?: RawShippingSimulatorData | null;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: ShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type CartShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: CartShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type ShippingSimulatorFormProps = ComponentPropsWithRef<'form'>;\n\nexport type ShippingSimulatorInputProps = Omit<ComponentPropsWithRef<'input'>, 'value' | 'onChange'> & {\n format?: boolean;\n};\n\nexport type ShippingSimulatorSubmitProps = ComponentPropsWithRef<'button'>;\n\nexport type ShippingSimulatorLoadingProps = ComponentPropsWithRef<'output'>;\n\nexport type ShippingSimulatorErrorProps = ComponentPropsWithRef<'div'>;\n\nexport type ShippingSimulatorOptionsProps = ComponentPropsWithRef<'ul'> & {\n sortBy?: 'price' | 'estimate';\n maxOptions?: number;\n};\n\nexport type ShippingSimulatorOptionProps = ComponentPropsWithRef<'li'>;\n\nexport type ShippingSimulatorOptionNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionEstimateProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionFreeBadgeProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorEmptyProps = ComponentPropsWithRef<'output'>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n// Exported so `DeliveryOptionsRoot` can become a third provider by importing these same Context\n// objects directly (context matching is by identity, not shape). The two hooks below stay\n// module-private — providers need the objects, not the consumer API (Decision 2).\nexport const ShippingSimulatorContext = createContext<\n ShippingSimulatorContextValue | typeof SHIPPING_SIMULATOR_CONTEXT_UNSET\n>(SHIPPING_SIMULATOR_CONTEXT_UNSET);\n\nexport const OptionItemContext = createContext<ShippingOption | null>(null);\n\nfunction useShippingSimulator(): ShippingSimulatorContextValue {\n const ctx = useContext(ShippingSimulatorContext);\n if (ctx === SHIPPING_SIMULATOR_CONTEXT_UNSET) {\n throw new Error('ShippingSimulator components must be used inside ShippingSimulatorRoot.');\n }\n return ctx;\n}\n\nfunction useOptionItem(): ShippingOption {\n const ctx = useContext(OptionItemContext);\n if (!ctx) {\n throw new Error('ShippingSimulatorOption components must be used inside ShippingSimulatorOptions.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Each unit's whole sentence, and the variable that sentence names.\n//\n// Whole sentence, not a unit fragment interpolated into a wrapper: interpolating a translated\n// fragment into a translated wrapper freezes \"preposition + noun\" order into every language, and\n// hands the translator `em {estimate}` with no way to agree preposition, article or case with a noun\n// they cannot see. The variable is named after what it counts (`{days}`, `{hours}`) rather than a\n// generic `{count}`, for the same reason.\n//\n// A `Record` and not a `switch` with a default: a fifth unit arriving in the GraphQL schema is a\n// type error here, not a silent fallback to the wrong sentence.\n//\n// `variable` is the union of the names those sentences read, never `string`: widened, a typo passes\n// typecheck, lint and every test, and the shopper gets the raw ICU pattern because `onIntlError` is\n// silent in production. The parity assertion in the test file closes the other half of the gap — that\n// the name written here is the one the catalog's message actually names.\nexport const ESTIMATE_MESSAGE: Record<ShippingEstimateUnit, { id: MessageId; variable: 'days' | 'hours' | 'minutes' }> =\n {\n BUSINESS_DAYS: { id: 'fs/shipping.estimate.in-business-days', variable: 'days' },\n DAYS: { id: 'fs/shipping.estimate.in-days', variable: 'days' },\n HOURS: { id: 'fs/shipping.estimate.in-hours', variable: 'hours' },\n MINUTES: { id: 'fs/shipping.estimate.in-minutes', variable: 'minutes' },\n };\n\n// Business days weigh the same as calendar days: exact wall-clock conversion is unknowable and\n// the ranking only needs a consistent order.\nconst ESTIMATE_UNIT_MINUTES: Record<ShippingEstimateUnit, number> = {\n MINUTES: 1,\n HOURS: 60,\n DAYS: 1440,\n BUSINESS_DAYS: 1440,\n};\n\nfunction sortShippingOptions(options: readonly ShippingOption[], sortBy: 'price' | 'estimate'): ShippingOption[] {\n const rank =\n sortBy === 'price'\n ? (option: ShippingOption) => Number(option.price.amount)\n : (option: ShippingOption) => option.shippingEstimate.value * ESTIMATE_UNIT_MINUTES[option.shippingEstimate.unit];\n return [...options].sort((a, b) => rank(a) - rank(b));\n}\n\nfunction normalizePostalCode(value: string): string {\n return value.replace(/\\D/g, '').slice(0, 8);\n}\n\nfunction formatPostalCode(value: string): string {\n const digits = normalizePostalCode(value);\n return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;\n}\n\nfunction extractProductFromData(data: RawShippingSimulatorData | null | undefined): {\n variantId: string | null;\n seller: string | null;\n} {\n if (!data) return { variantId: null, seller: null };\n const edge = data.variants?.edges?.[0];\n if (!edge) return { variantId: null, seller: null };\n const { id, sellers } = edge.node;\n const defaultSeller = sellers?.find((s) => s.isDefault) ?? sellers?.[0];\n return { variantId: id ?? null, seller: defaultSeller?.id ?? null };\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulatorRootDefinition = defineComponent<ShippingSimulatorRootProps>({\n name: 'ShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n quantity: { type: 'number', default: 1, label: 'Quantity' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the PDP shipping simulator: a shopper types a postal code and sees a shipping preview for ONE product on a product detail page. Backed by shippingSimulation and a product fragment (productBySlug(slug: $slug)), so it must live on a page with a $slug variable. Use CartShippingSimulatorRoot instead for a whole-cart calculator in the cart/mini-cart. All other ShippingSimulator components must be descendants of this one.',\n});\n\nexport const CartShippingSimulatorRootDefinition = defineComponent<CartShippingSimulatorRootProps>({\n name: 'CartShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: CartShippingSimulatorRoot,\n editor: { label: 'Cart Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the cart/mini-cart shipping calculator: the shopper types a postal code and sees the shipping options for the WHOLE cart. Backed by cartShippingSimulation (cart sourced server-side via x-order-form-id); needs no CartRoot ancestor and no product fragment. Use ShippingSimulatorRoot instead for a single-product shipping preview on a PDP. All other CartShippingSimulator components must be descendants of this one.',\n});\n\nexport const ShippingSimulatorFormDefinition = defineComponent<ShippingSimulatorFormProps>({\n name: 'ShippingSimulatorForm',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorForm,\n editor: { label: 'Shipping Simulator Form', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Form wrapper that holds ShippingSimulatorInput and ShippingSimulatorSubmit; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorInputDefinition = defineComponent<ShippingSimulatorInputProps>({\n name: 'ShippingSimulatorInput',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorInput,\n editor: { label: 'Shipping Simulator Input', category: 'action' },\n schema: {\n format: { type: 'boolean', default: false, label: 'Auto-format CEP (00000-000)' },\n },\n requiresContext: 'shipping-simulator',\n guideline:\n 'Postal-code text input; enable `format` to auto-hyphenate the CEP as the user types (e.g. 01310-100). The placeholder comes from the message catalog. Must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorSubmitDefinition = defineComponent<ShippingSimulatorSubmitProps>({\n name: 'ShippingSimulatorSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorSubmit,\n editor: { label: 'Shipping Simulator Submit', category: 'action' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline: 'Submit button for the postal-code form; must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorLoadingDefinition = defineComponent<ShippingSimulatorLoadingProps>({\n name: 'ShippingSimulatorLoading',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorLoading,\n editor: { label: 'Shipping Simulator Loading', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Loading indicator shown while a simulation is in progress; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorErrorDefinition = defineComponent<ShippingSimulatorErrorProps>({\n name: 'ShippingSimulatorError',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorError,\n editor: { label: 'Shipping Simulator Error', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Error banner shown when the simulation returns validation errors; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorOptionsDefinition = defineComponent<ShippingSimulatorOptionsProps>({\n name: 'ShippingSimulatorOptions',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptions,\n editor: { label: 'Shipping Simulator Options', category: 'commerce' },\n schema: {\n sortBy: { type: ['price', 'estimate'] as const, label: 'Sort by' },\n maxOptions: { type: 'number', label: 'Max options' },\n },\n requiresContext: 'shipping-simulator',\n providesContext: 'shipping-simulator-option',\n guideline:\n 'List that renders one ShippingSimulatorOption per available shipping option; must be a descendant of a shipping-simulator Root (PDP or cart). Renders every option in API order by default; set sortBy (\"price\" = cheapest first, \"estimate\" = fastest first) and maxOptions to cap the list — sortBy=\"price\" with maxOptions=1 shows only the cheapest option. See shipping-simulator.md.',\n});\n\nexport const ShippingSimulatorOptionDefinition = defineComponent<ShippingSimulatorOptionProps>({\n name: 'ShippingSimulatorOption',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOption,\n editor: { label: 'Shipping Simulator Option', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Container for a single shipping option row; holds ShippingSimulatorOptionName, ShippingSimulatorOptionEstimate, and ShippingSimulatorOptionPrice. Must be a descendant of ShippingSimulatorOptions.',\n});\n\nexport const ShippingSimulatorOptionNameDefinition = defineComponent<ShippingSimulatorOptionNameProps>({\n name: 'ShippingSimulatorOptionName',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionName,\n editor: { label: 'Option Name', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping option name (e.g. \"Entrega Normal\"); must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionEstimateDefinition = defineComponent<ShippingSimulatorOptionEstimateProps>({\n name: 'ShippingSimulatorOptionEstimate',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionEstimate,\n editor: { label: 'Option Estimate', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the delivery estimate in the active locale, one whole sentence per unit from the message catalog; a zero-value estimate (any unit) reads as an arrival-today message instead, since \"chega em 0 dias úteis\" reads wrong. Must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionPriceDefinition = defineComponent<ShippingSimulatorOptionPriceProps>({\n name: 'ShippingSimulatorOptionPrice',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionPrice,\n editor: { label: 'Option Price', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping price, showing the free-shipping label from the message catalog when the amount is zero; must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionFreeBadgeDefinition = defineComponent<ShippingSimulatorOptionFreeBadgeProps>({\n name: 'ShippingSimulatorOptionFreeBadge',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionFreeBadge,\n editor: { label: 'Option Free Badge', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Badge shown only when the current option price is zero (free shipping); renders nothing otherwise. Must be a descendant of ShippingSimulatorOption. Orthogonal to the free-price replacement text owned by ShippingSimulatorOptionPrice.',\n});\n\nexport const ShippingSimulatorEmptyDefinition = defineComponent<ShippingSimulatorEmptyProps>({\n name: 'ShippingSimulatorEmpty',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorEmpty,\n editor: { label: 'Shipping Simulator Empty', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Message shown when a simulation ran and returned no shipping options (e.g. no carrier common to the whole cart). Renders nothing before the first submit and nothing when options or an error are present. The copy comes from the message catalog; pass children to override. Must be a descendant of a shipping-simulator Root.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ShippingSimulatorRoot({\n country = 'BRA',\n quantity = 1,\n variantId: variantIdProp,\n seller: sellerProp,\n $data: $dataProp,\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: ShippingSimulatorRootProps) {\n const defaultSimulate = useShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const $data = useDataOverride($dataProp);\n const extracted = extractProductFromData($data);\n const variantId = variantIdProp ?? extracted.variantId;\n const seller = sellerProp ?? extracted.seller;\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n if (!onSimulate || !variantId || !seller) return;\n\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country, variantId, quantity, seller })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode, quantity, seller, variantId]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function CartShippingSimulatorRoot({\n country = 'BRA',\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: CartShippingSimulatorRootProps) {\n const defaultSimulate = useCartShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function ShippingSimulatorForm({ className, children, ...props }: ShippingSimulatorFormProps) {\n const { submit } = useShippingSimulator();\n\n return (\n <form\n {...props}\n className={className}\n data-fs-shipping-simulator-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n );\n}\n\nexport function ShippingSimulatorInput({\n className,\n placeholder,\n 'aria-label': ariaLabel,\n format = false,\n ...props\n}: ShippingSimulatorInputProps) {\n const { postalCode, setPostalCode } = useShippingSimulator();\n const intl = useIntl();\n const displayValue = format ? formatPostalCode(postalCode) : postalCode;\n\n return (\n <input\n {...props}\n aria-label={ariaLabel ?? intl.formatMessage({ id: 'fs/shipping.postal-code.aria-label' })}\n className={className}\n data-fs-shipping-simulator-input=\"\"\n type=\"text\"\n value={displayValue}\n onChange={(event) => setPostalCode(normalizePostalCode(event.target.value))}\n placeholder={placeholder ?? intl.formatMessage({ id: 'fs/shipping.postal-code.placeholder' })}\n pattern=\"\\d{5}-?\\d{3}\"\n maxLength={9}\n inputMode=\"numeric\"\n required\n />\n );\n}\n\nexport function ShippingSimulatorSubmit({ className, children, disabled, ...props }: ShippingSimulatorSubmitProps) {\n const { status } = useShippingSimulator();\n const isLoading = status === 'loading';\n\n return (\n <button\n {...props}\n type=\"submit\"\n className={className}\n data-fs-shipping-simulator-submit=\"\"\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n >\n {children}\n </button>\n );\n}\n\nexport function ShippingSimulatorLoading({ className, children, ...props }: ShippingSimulatorLoadingProps) {\n const { status } = useShippingSimulator();\n if (status !== 'loading') return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-loading=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.calculating\" />}\n </output>\n );\n}\n\nexport function ShippingSimulatorError({ className, children, ...props }: ShippingSimulatorErrorProps) {\n const { userErrors } = useShippingSimulator();\n const [firstError] = userErrors;\n if (!firstError) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-shipping-simulator-error=\"\">\n {children ?? firstError.message}\n </div>\n );\n}\n\nexport function ShippingSimulatorOptions({\n sortBy,\n maxOptions,\n className,\n children,\n ...props\n}: ShippingSimulatorOptionsProps) {\n const { shippingOptions } = useShippingSimulator();\n\n const visibleOptions = useMemo(() => {\n if (!shippingOptions) return null;\n const sorted = sortBy ? sortShippingOptions(shippingOptions, sortBy) : shippingOptions;\n return maxOptions && maxOptions > 0 ? sorted.slice(0, maxOptions) : sorted;\n }, [shippingOptions, sortBy, maxOptions]);\n\n if (!visibleOptions || visibleOptions.length === 0) return null;\n\n return (\n <ul {...props} className={className} data-fs-shipping-simulator-options=\"\">\n {visibleOptions.map((option) => (\n <OptionItemContext key={option.id} value={option}>\n {children}\n </OptionItemContext>\n ))}\n </ul>\n );\n}\n\nexport function ShippingSimulatorOption({ className, children, ...props }: ShippingSimulatorOptionProps) {\n const option = useOptionItem();\n\n return (\n <li\n {...props}\n className={className}\n data-fs-shipping-simulator-option=\"\"\n data-fs-shipping-simulator-option-channel={option.channel}\n >\n {children}\n </li>\n );\n}\n\nexport function ShippingSimulatorOptionName({ className, children, ...props }: ShippingSimulatorOptionNameProps) {\n const option = useOptionItem();\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-name=\"\">\n {children ?? option.name}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionEstimate({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionEstimateProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { value, unit } = option.shippingEstimate;\n const { id, variable } = ESTIMATE_MESSAGE[unit];\n const text =\n value === 0\n ? intl.formatMessage({ id: 'fs/shipping.estimate.today' })\n : intl.formatMessage({ id }, { [variable]: value });\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-estimate=\"\">\n {children ?? text}\n </span>\n );\n}\n\nfunction isFreeAmount(amount: unknown): boolean {\n return isFiniteAmount(amount) && Number(amount) === 0;\n}\n\nexport function ShippingSimulatorOptionPrice({ className, children, ...props }: ShippingSimulatorOptionPriceProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { locale, currency } = useStorefrontContext();\n const text = isFreeAmount(option.price.amount)\n ? intl.formatMessage({ id: 'fs/shipping.free-price' })\n : formatPrice(Number(option.price.amount), locale, currency);\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-price=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionFreeBadge({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionFreeBadgeProps) {\n const option = useOptionItem();\n if (!isFreeAmount(option.price.amount)) return null;\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-free-badge=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.free-badge\" />}\n </span>\n );\n}\n\nexport function ShippingSimulatorEmpty({ className, children, ...props }: ShippingSimulatorEmptyProps) {\n const { shippingOptions, userErrors } = useShippingSimulator();\n // Idle (null) → nothing; error → nothing (Error owns it); options present → nothing.\n const simulatedEmpty = Array.isArray(shippingOptions) && shippingOptions.length === 0 && userErrors.length === 0;\n if (!simulatedEmpty) return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-empty=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.no-options\" />}\n </output>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulator = {\n Root: ShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n\nexport const CartShippingSimulator = {\n Root: CartShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAM,WAAyB;;;;;;;;;;;;;;;;;AAqF/B,MAAM,mCAAmC,OAAO,+BAA+B;AA0D/E,MAAa,2BAA2B,cAEtC,gCAAgC;AAElC,MAAa,oBAAoB,cAAqC,IAAI;AAE1E,SAAS,uBAAsD;CAC7D,MAAM,MAAM,WAAW,wBAAwB;CAC/C,IAAI,QAAQ,kCACV,MAAM,IAAI,MAAM,yEAAyE;CAE3F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0B,CAAA;CACtD,CAAA;AAEZ;AAMA,MAAa,oBAAoB;CAC/B,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,OAAO;AACT;AAEA,MAAa,wBAAwB;CACnC,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,OAAO;AACT"}
@@ -2,7 +2,11 @@
2
2
  import { defineComponent } from "../../core/dist/define-component.js";
3
3
  import { defineContentType } from "../../core/dist/define-content-type.js";
4
4
  import "../../core/dist/index.js";
5
- import { RETURN_URL_PARAM, isSignInRoute, resolveLoginAddressHref, resolveReturnHref } from "../../utils/safe-href.js";
5
+ import { RETURN_URL_PARAM, SIGN_IN_PAGE, isSignInRoute, resolveLoginAddressHref, resolveReturnHref } from "../../utils/safe-href.js";
6
+ import { withoutBasePath } from "../../sdk/navigation/path.js";
7
+ import { resolveStorefrontHref } from "../../sdk/navigation/resolve-storefront-href.js";
8
+ import { useStorefrontContext } from "../../sdk/context/storefront-context.js";
9
+ import { useRouteMap } from "../../sdk/navigation/route-map-provider.js";
6
10
  import { useEffect, useRef } from "react";
7
11
  import { jsx } from "react/jsx-runtime";
8
12
  //#region src/matter/sign-in-redirect/sign-in-redirect.tsx
@@ -39,19 +43,37 @@ const SignInRedirectDefinition = defineComponent({
39
43
  label: "Waiting Message"
40
44
  }
41
45
  },
42
- guideline: "The whole of the /login route: on mount it replaces the document with the account's platform login, forwarding a validated returnUrl from the incoming query. It is a handover, not a block — place it alone on its own page, never inside a header, drawer, or any page a shopper is meant to read, because anything composed beside it is navigated away from before it can be seen. Never place it under an account shell or behind AccountAccessGate, whose redirect targets this route. It renders no sign-in fields of its own and collects no credentials — the shopper types them on the platform, after this component has already left the page. platformLoginUrl is required and per-account (absolute URL or site-relative path), and must not be the storefront's own /login, which would hand this route to itself — with no usable value the component renders nothing and warns."
46
+ guideline: "The whole of the sign-in page: on mount it replaces the document with the account's platform login, forwarding a validated returnUrl from the incoming query. It is a handover, not a block — place it alone on its own page, never inside a header, drawer, or any page a shopper is meant to read, because anything composed beside it is navigated away from before it can be seen. Never place it under an account shell or behind AccountAccessGate, whose redirect targets this page. It renders no sign-in fields of its own and collects no credentials — the shopper types them on the platform, after this component has already left the page. platformLoginUrl is required and per-account (absolute URL or site-relative path), and must not be the storefront's own sign-in page, which would hand this page to itself — with no usable value the component renders nothing and warns."
43
47
  });
44
48
  function SignInRedirect({ platformLoginUrl, loadingLabel, $content, className, ref, ...props }) {
45
49
  const handedOverRef = useRef(false);
50
+ const { bindingId, basePath } = useStorefrontContext();
51
+ const { routeMap } = useRouteMap();
52
+ const signInPath = resolveStorefrontHref({
53
+ bindingId,
54
+ basePath: "/"
55
+ }, routeMap, SIGN_IN_PAGE).href;
56
+ const publicSignInPath = resolveStorefrontHref({
57
+ bindingId,
58
+ basePath
59
+ }, routeMap, SIGN_IN_PAGE).href;
46
60
  const warnedForRef = useRef(null);
47
61
  const entryLoadingLabel = $content?.loadingLabel?.trim() ? $content.loadingLabel : loadingLabel;
48
- const address = platformLoginUrl?.trim() ? resolveLoginAddressHref(platformLoginUrl) : null;
62
+ const address = platformLoginUrl?.trim() ? resolveLoginAddressHref(platformLoginUrl, publicSignInPath) : null;
49
63
  const loginHref = address?.safe ? address.href : null;
50
64
  const rejection = address !== null && !address.safe ? address.reason : null;
51
65
  useEffect(() => {
52
66
  if (loginHref !== null) {
53
67
  if (handedOverRef.current) return;
54
- const handover = composeHandover(loginHref);
68
+ const handover = composeHandover(loginHref, {
69
+ binding: {
70
+ bindingId,
71
+ basePath
72
+ },
73
+ routeMap,
74
+ signInPath,
75
+ publicSignInPath
76
+ });
55
77
  if (handover === null) {
56
78
  if (warnedForRef.current !== "sign-in-route") {
57
79
  warnedForRef.current = "sign-in-route";
@@ -71,7 +93,15 @@ function SignInRedirect({ platformLoginUrl, loadingLabel, $content, className, r
71
93
  return;
72
94
  }
73
95
  console.warn("[SignInRedirect] no platform login address authored");
74
- }, [loginHref, rejection]);
96
+ }, [
97
+ loginHref,
98
+ rejection,
99
+ bindingId,
100
+ basePath,
101
+ routeMap,
102
+ signInPath,
103
+ publicSignInPath
104
+ ]);
75
105
  if (loginHref === null) return null;
76
106
  return /* @__PURE__ */ jsx(SignInRedirectLoading, {
77
107
  ...props,
@@ -85,25 +115,33 @@ function SignInRedirect({ platformLoginUrl, loadingLabel, $content, className, r
85
115
  * Builds the address the document is handed over to: the authored one, carrying the shopper's return
86
116
  * when the arriving value survives revalidation.
87
117
  *
88
- * Revalidating here rather than trusting the sender is the boundary — `/login` is reachable by a
118
+ * Revalidating here rather than trusting the sender is the boundary — the page is reachable by a
89
119
  * hand-crafted link, so the value is shopper-supplied whoever produced it. Only this one parameter
90
120
  * crosses; anything else on the incoming URL is dropped rather than forwarded into an auth URL.
91
121
  *
122
+ * The arriving value is a logical path, so it is prefixed with the binding's base path before it
123
+ * travels. A value that cannot be prefixed drops the parameter, like a refused one.
124
+ *
92
125
  * `null` when the address resolves back to this route, which is a handover that would reload the same
93
126
  * document and mount the same handover again. The site-relative spelling of that is already refused
94
127
  * while rendering; the absolute one needs the document's own origin, which exists only here.
95
128
  */
96
- function composeHandover(loginHref) {
129
+ function composeHandover(loginHref, { binding, routeMap, signInPath, publicSignInPath }) {
97
130
  const destination = new URL(loginHref, globalThis.location.origin);
98
- if (destination.origin === globalThis.location.origin && isSignInRoute(destination.pathname)) return null;
131
+ if (destination.origin === globalThis.location.origin && isSignInRoute(destination.pathname, publicSignInPath)) return null;
99
132
  const arriving = new URLSearchParams(globalThis.location.search).get(RETURN_URL_PARAM);
100
133
  if (arriving === null) return destination.toString();
101
- const returnHref = resolveReturnHref(arriving);
134
+ const returnHref = resolveReturnHref(withoutBasePath(arriving, binding.basePath), signInPath);
102
135
  if (!returnHref.safe) {
103
136
  console.warn("[SignInRedirect] return destination rejected", { reason: returnHref.reason });
104
137
  return destination.toString();
105
138
  }
106
- const value = destination.origin === globalThis.location.origin ? returnHref.href : new URL(returnHref.href, globalThis.location.origin).toString();
139
+ const publicReturn = resolveStorefrontHref(binding, routeMap, returnHref.href);
140
+ if (publicReturn.href === null) {
141
+ console.warn("[SignInRedirect] return destination rejected", { reason: publicReturn.reason });
142
+ return destination.toString();
143
+ }
144
+ const value = destination.origin === globalThis.location.origin ? publicReturn.href : new URL(publicReturn.href, globalThis.location.origin).toString();
107
145
  destination.searchParams.set(RETURN_URL_PARAM, value);
108
146
  return destination.toString();
109
147
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sign-in-redirect.js","names":[],"sources":["../../../src/matter/sign-in-redirect/sign-in-redirect.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, useEffect, useRef } from 'react';\nimport { isSignInRoute, RETURN_URL_PARAM, resolveLoginAddressHref, resolveReturnHref } from '../../utils/safe-href.js';\n\n// Nothing is required, following the shipped entry point: an entry may author any subset, and a slice\n// missing a required property is shape-invalid, which drops the whole element rather than the one field.\n// The address is deliberately absent — schema is developer-owned and lands through review, while an\n// entry is editable at runtime, and the runtime channel is the one that could misroute an auth flow.\nexport const SignInRedirectContent = defineContentType({\n id: 'sign-in-redirect',\n title: 'Sign In Redirect',\n description: 'Waiting message shown while the shopper is handed over to the platform login.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n loadingLabel: { type: 'string', minLength: 1, title: 'Waiting message' },\n },\n },\n});\n\n/** Props for {@link SignInRedirect}. Extends native `<output>` attributes (the rendered root). */\nexport type SignInRedirectProps = Omit<ComponentPropsWithRef<'output'>, 'children'> & {\n /** The platform login address, per account. Absolute URL or site-relative path; both are spellings\n * example stores use. Optional in the type only because schema props are; the render gate requires\n * a resolved value. */\n platformLoginUrl?: string;\n /** Text shown while the handover is pending. */\n loadingLabel?: string;\n /** Merchant-authored waiting message, sliced from the page content entry; wins over the prop when\n * present. Absent in a non-CMS store — the prop is the fallback. */\n $content?: ContentValue<typeof SignInRedirectContent>;\n};\n\n/** Props for {@link SignInRedirectLoading}. Extends native `<output>` attributes. */\nexport type SignInRedirectLoadingProps = ComponentPropsWithRef<'output'>;\n\nexport const SignInRedirectDefinition = defineComponent<SignInRedirectProps>({\n name: 'SignInRedirect',\n importPath: '@vtex/faststore/components',\n component: SignInRedirect,\n content: SignInRedirectContent,\n editor: { label: 'Sign In Redirect', category: 'identity' },\n schema: {\n platformLoginUrl: { type: 'string', label: 'Platform Login URL' },\n // Mirrored from the content model on purpose, as every content-bearing component in the library\n // does: the entry wins when published, and this is the value a store without a CMS authors.\n loadingLabel: { type: 'string', label: 'Waiting Message' },\n },\n guideline:\n \"The whole of the /login route: on mount it replaces the document with the account's platform login, forwarding a validated returnUrl from the incoming query. It is a handover, not a block — place it alone on its own page, never inside a header, drawer, or any page a shopper is meant to read, because anything composed beside it is navigated away from before it can be seen. Never place it under an account shell or behind AccountAccessGate, whose redirect targets this route. It renders no sign-in fields of its own and collects no credentials — the shopper types them on the platform, after this component has already left the page. platformLoginUrl is required and per-account (absolute URL or site-relative path), and must not be the storefront's own /login, which would hand this route to itself — with no usable value the component renders nothing and warns.\",\n});\n\nexport function SignInRedirect({\n platformLoginUrl,\n loadingLabel,\n $content,\n className,\n ref,\n ...props\n}: SignInRedirectProps) {\n // StrictMode mounts an effect twice, and a second handover on a document already leaving is a race\n // with the navigation rather than a no-op.\n const handedOverRef = useRef(false);\n // The problem already reported. Warnings belong to the effect rather than the render body, and a\n // render is repeatable, so without this one unusable address would log on every pass.\n const warnedForRef = useRef<string | null>(null);\n\n // A blank entry field falls through, so clearing one in the Admin reads as unauthored.\n const entryLoadingLabel = $content?.loadingLabel?.trim() ? $content.loadingLabel : loadingLabel;\n\n // The only gate between an authored value and `location.replace`. A blank prop is the unauthored case\n // and reads as absent rather than as a refusal, so the two warn differently.\n const address = platformLoginUrl?.trim() ? resolveLoginAddressHref(platformLoginUrl) : null;\n const loginHref = address?.safe ? address.href : null;\n // Carried as the reason alone, so the effect depends on primitives and not on a per-render object.\n const rejection = address !== null && !address.safe ? address.reason : null;\n\n useEffect(() => {\n if (loginHref !== null) {\n if (handedOverRef.current) {\n return;\n }\n const handover = composeHandover(loginHref);\n // An address that resolves back to this very route, in the one spelling the render gate cannot\n // judge. Reported under the reason the gate would have used, so both spellings read alike.\n if (handover === null) {\n if (warnedForRef.current !== 'sign-in-route') {\n warnedForRef.current = 'sign-in-route';\n console.warn('[SignInRedirect] platform login address rejected', { reason: 'sign-in-route' });\n }\n return;\n }\n handedOverRef.current = true;\n globalThis.location.replace(handover);\n return;\n }\n\n // Keyed by the problem rather than raised once, so an address edited into a different unusable\n // value is still reported, and one that becomes usable still hands over above. `unauthored` names\n // the case with no rejection reason, and is outside the reason union it shares this slot with.\n const problem = rejection ?? 'unauthored';\n if (warnedForRef.current === problem) {\n return;\n }\n warnedForRef.current = problem;\n\n if (rejection !== null) {\n // A bounded reason and no authored value, the convention the content runtime's own log follows.\n console.warn('[SignInRedirect] platform login address rejected', { reason: rejection });\n return;\n }\n console.warn('[SignInRedirect] no platform login address authored');\n }, [loginHref, rejection]);\n\n // Both unusable cases render nothing; the effect above is what tells them apart in the log.\n if (loginHref === null) {\n return null;\n }\n\n // The waiting look is this component's only element, so it carries both hooks: its own, and the\n // component's identity, which a store targets by name the way every other component is targeted.\n // Rendered standalone the part keeps only its own, because standalone it is not the route.\n return (\n <SignInRedirectLoading {...props} ref={ref} className={className} data-fs-sign-in-redirect=\"\">\n {entryLoadingLabel}\n </SignInRedirectLoading>\n );\n}\n\n/**\n * Builds the address the document is handed over to: the authored one, carrying the shopper's return\n * when the arriving value survives revalidation.\n *\n * Revalidating here rather than trusting the sender is the boundary — `/login` is reachable by a\n * hand-crafted link, so the value is shopper-supplied whoever produced it. Only this one parameter\n * crosses; anything else on the incoming URL is dropped rather than forwarded into an auth URL.\n *\n * `null` when the address resolves back to this route, which is a handover that would reload the same\n * document and mount the same handover again. The site-relative spelling of that is already refused\n * while rendering; the absolute one needs the document's own origin, which exists only here.\n */\nfunction composeHandover(loginHref: string): string | null {\n // Accepts both authored spellings, resolving the relative one against the store's own origin.\n const destination = new URL(loginHref, globalThis.location.origin);\n\n // A cross-origin login page whose path happens to be `/login` is a different page, and travels.\n if (destination.origin === globalThis.location.origin && isSignInRoute(destination.pathname)) {\n return null;\n }\n\n // Read from the document rather than through `useSearchParams()`, which would require a `Suspense`\n // boundary the generator does not emit on a prerendered route.\n const arriving = new URLSearchParams(globalThis.location.search).get(RETURN_URL_PARAM);\n if (arriving === null) {\n return destination.toString();\n }\n\n const returnHref = resolveReturnHref(arriving);\n if (!returnHref.safe) {\n console.warn('[SignInRedirect] return destination rejected', { reason: returnHref.reason });\n return destination.toString();\n }\n\n // A path alone cannot say which origin it belongs to, and the store author is the one who decides\n // whether the receiver shares ours. A same-origin endpoint takes the path as it arrived, the way\n // legacy hands its own endpoint a bare `returnUrl`; a cross-origin one would resolve that path\n // against its own domain, so it is absolutized — always against the storefront, never the address.\n const sameOrigin = destination.origin === globalThis.location.origin;\n const value = sameOrigin ? returnHref.href : new URL(returnHref.href, globalThis.location.origin).toString();\n destination.searchParams.set(RETURN_URL_PARAM, value);\n\n return destination.toString();\n}\n\n/**\n * The waiting look, and the page's only content while the handover is pending. A real part with its own\n * hook rather than an ad hoc spinner, so a store can style it and a story can render it — mounting the\n * component itself would navigate the frame away.\n */\nexport function SignInRedirectLoading({ className, children, ...props }: SignInRedirectLoadingProps) {\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-sign-in-redirect-loading=\"\">\n {children}\n </output>\n );\n}\n"],"mappings":";;;;;;;;AAUA,MAAa,wBAAwB,kBAAkB;CACrD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY,EAC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,MAChB,OAAO;CAMT,OACE,oBAAC,uBAAD;EAAuB,GAAI;EAAY;EAAgB;EAAW,4BAAyB;EACxF,UAAA;CACoB,CAAA;AAE3B;;;;;;;;;;;;;AAcA,SAAS,gBAAgB,WAAkC;CAEzD,MAAM,cAAc,IAAI,IAAI,WAAW,WAAW,SAAS,MAAM;CAGjE,IAAI,YAAY,WAAW,WAAW,SAAS,UAAU,cAAc,YAAY,QAAQ,GACzF,OAAO;CAKT,MAAM,WAAW,IAAI,gBAAgB,WAAW,SAAS,MAAM,CAAC,CAAC,IAAI,gBAAgB;CACrF,IAAI,aAAa,MACf,OAAO,YAAY,SAAS;CAG9B,MAAM,aAAa,kBAAkB,QAAQ;CAC7C,IAAI,CAAC,WAAW,MAAM;EACpB,QAAQ,KAAK,gDAAgD,EAAE,QAAQ,WAAW,OAAO,CAAC;EAC1F,OAAO,YAAY,SAAS;CAC9B;CAOA,MAAM,QADa,YAAY,WAAW,WAAW,SAAS,SACnC,WAAW,OAAO,IAAI,IAAI,WAAW,MAAM,WAAW,SAAS,MAAM,CAAC,CAAC,SAAS;CAC3G,YAAY,aAAa,IAAI,kBAAkB,KAAK;CAEpD,OAAO,YAAY,SAAS;AAC9B;;;;;;AAOA,SAAgB,sBAAsB,EAAE,WAAW,UAAU,GAAG,SAAqC;CACnG,OACE,oBAAC,UAAD;EAAQ,GAAI;EAAO,aAAU;EAAoB;EAAW,oCAAiC;EAC1F;CACK,CAAA;AAEZ"}
1
+ {"version":3,"file":"sign-in-redirect.js","names":[],"sources":["../../../src/matter/sign-in-redirect/sign-in-redirect.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, useEffect, useRef } from 'react';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { withoutBasePath } from '../../sdk/navigation/path.js';\nimport { resolveStorefrontHref } from '../../sdk/navigation/resolve-storefront-href.js';\nimport { useRouteMap } from '../../sdk/navigation/route-map-provider.js';\nimport type { RouteMap } from '../../sdk/navigation/types.js';\nimport {\n isSignInRoute,\n RETURN_URL_PARAM,\n resolveLoginAddressHref,\n resolveReturnHref,\n SIGN_IN_PAGE,\n} from '../../utils/safe-href.js';\n\n// Nothing is required, following the shipped entry point: an entry may author any subset, and a slice\n// missing a required property is shape-invalid, which drops the whole element rather than the one field.\n// The address is deliberately absent — schema is developer-owned and lands through review, while an\n// entry is editable at runtime, and the runtime channel is the one that could misroute an auth flow.\nexport const SignInRedirectContent = defineContentType({\n id: 'sign-in-redirect',\n title: 'Sign In Redirect',\n description: 'Waiting message shown while the shopper is handed over to the platform login.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n loadingLabel: { type: 'string', minLength: 1, title: 'Waiting message' },\n },\n },\n});\n\n/** Props for {@link SignInRedirect}. Extends native `<output>` attributes (the rendered root). */\nexport type SignInRedirectProps = Omit<ComponentPropsWithRef<'output'>, 'children'> & {\n /** The platform login address, per account. Absolute URL or site-relative path; both are spellings\n * example stores use. Optional in the type only because schema props are; the render gate requires\n * a resolved value. */\n platformLoginUrl?: string;\n /** Text shown while the handover is pending. */\n loadingLabel?: string;\n /** Merchant-authored waiting message, sliced from the page content entry; wins over the prop when\n * present. Absent in a non-CMS store — the prop is the fallback. */\n $content?: ContentValue<typeof SignInRedirectContent>;\n};\n\n/** Props for {@link SignInRedirectLoading}. Extends native `<output>` attributes. */\nexport type SignInRedirectLoadingProps = ComponentPropsWithRef<'output'>;\n\nexport const SignInRedirectDefinition = defineComponent<SignInRedirectProps>({\n name: 'SignInRedirect',\n importPath: '@vtex/faststore/components',\n component: SignInRedirect,\n content: SignInRedirectContent,\n editor: { label: 'Sign In Redirect', category: 'identity' },\n schema: {\n platformLoginUrl: { type: 'string', label: 'Platform Login URL' },\n // Mirrored from the content model on purpose, as every content-bearing component in the library\n // does: the entry wins when published, and this is the value a store without a CMS authors.\n loadingLabel: { type: 'string', label: 'Waiting Message' },\n },\n guideline:\n \"The whole of the sign-in page: on mount it replaces the document with the account's platform login, forwarding a validated returnUrl from the incoming query. It is a handover, not a block — place it alone on its own page, never inside a header, drawer, or any page a shopper is meant to read, because anything composed beside it is navigated away from before it can be seen. Never place it under an account shell or behind AccountAccessGate, whose redirect targets this page. It renders no sign-in fields of its own and collects no credentials — the shopper types them on the platform, after this component has already left the page. platformLoginUrl is required and per-account (absolute URL or site-relative path), and must not be the storefront's own sign-in page, which would hand this page to itself — with no usable value the component renders nothing and warns.\",\n});\n\nexport function SignInRedirect({\n platformLoginUrl,\n loadingLabel,\n $content,\n className,\n ref,\n ...props\n}: SignInRedirectProps) {\n // StrictMode mounts an effect twice, and a second handover on a document already leaving is a race\n // with the navigation rather than a no-op.\n const handedOverRef = useRef(false);\n const { bindingId, basePath } = useStorefrontContext();\n const { routeMap } = useRouteMap();\n // `returnUrl` travels as a logical path and the authored address is a document URL, so the sign-in\n // page is compared in both spellings. `null` is a store without a sign-in page.\n const signInPath = resolveStorefrontHref({ bindingId, basePath: '/' }, routeMap, SIGN_IN_PAGE).href;\n const publicSignInPath = resolveStorefrontHref({ bindingId, basePath }, routeMap, SIGN_IN_PAGE).href;\n // The problem already reported. Warnings belong to the effect rather than the render body, and a\n // render is repeatable, so without this one unusable address would log on every pass.\n const warnedForRef = useRef<string | null>(null);\n\n // A blank entry field falls through, so clearing one in the Admin reads as unauthored.\n const entryLoadingLabel = $content?.loadingLabel?.trim() ? $content.loadingLabel : loadingLabel;\n\n // The only gate between an authored value and `location.replace`. A blank prop is the unauthored case\n // and reads as absent rather than as a refusal, so the two warn differently.\n const address = platformLoginUrl?.trim() ? resolveLoginAddressHref(platformLoginUrl, publicSignInPath) : null;\n const loginHref = address?.safe ? address.href : null;\n // Carried as the reason alone, so the effect depends on primitives and not on a per-render object.\n const rejection = address !== null && !address.safe ? address.reason : null;\n\n useEffect(() => {\n if (loginHref !== null) {\n if (handedOverRef.current) {\n return;\n }\n const handover = composeHandover(loginHref, {\n binding: { bindingId, basePath },\n routeMap,\n signInPath,\n publicSignInPath,\n });\n // An address that resolves back to this very route, in the one spelling the render gate cannot\n // judge. Reported under the reason the gate would have used, so both spellings read alike.\n if (handover === null) {\n if (warnedForRef.current !== 'sign-in-route') {\n warnedForRef.current = 'sign-in-route';\n console.warn('[SignInRedirect] platform login address rejected', { reason: 'sign-in-route' });\n }\n return;\n }\n handedOverRef.current = true;\n globalThis.location.replace(handover);\n return;\n }\n\n // Keyed by the problem rather than raised once, so an address edited into a different unusable\n // value is still reported, and one that becomes usable still hands over above. `unauthored` names\n // the case with no rejection reason, and is outside the reason union it shares this slot with.\n const problem = rejection ?? 'unauthored';\n if (warnedForRef.current === problem) {\n return;\n }\n warnedForRef.current = problem;\n\n if (rejection !== null) {\n // A bounded reason and no authored value, the convention the content runtime's own log follows.\n console.warn('[SignInRedirect] platform login address rejected', { reason: rejection });\n return;\n }\n console.warn('[SignInRedirect] no platform login address authored');\n }, [loginHref, rejection, bindingId, basePath, routeMap, signInPath, publicSignInPath]);\n\n // Both unusable cases render nothing; the effect above is what tells them apart in the log.\n if (loginHref === null) {\n return null;\n }\n\n // The waiting look is this component's only element, so it carries both hooks: its own, and the\n // component's identity, which a store targets by name the way every other component is targeted.\n // Rendered standalone the part keeps only its own, because standalone it is not the route.\n return (\n <SignInRedirectLoading {...props} ref={ref} className={className} data-fs-sign-in-redirect=\"\">\n {entryLoadingLabel}\n </SignInRedirectLoading>\n );\n}\n\n/**\n * Builds the address the document is handed over to: the authored one, carrying the shopper's return\n * when the arriving value survives revalidation.\n *\n * Revalidating here rather than trusting the sender is the boundary — the page is reachable by a\n * hand-crafted link, so the value is shopper-supplied whoever produced it. Only this one parameter\n * crosses; anything else on the incoming URL is dropped rather than forwarded into an auth URL.\n *\n * The arriving value is a logical path, so it is prefixed with the binding's base path before it\n * travels. A value that cannot be prefixed drops the parameter, like a refused one.\n *\n * `null` when the address resolves back to this route, which is a handover that would reload the same\n * document and mount the same handover again. The site-relative spelling of that is already refused\n * while rendering; the absolute one needs the document's own origin, which exists only here.\n */\nfunction composeHandover(\n loginHref: string,\n {\n binding,\n routeMap,\n signInPath,\n publicSignInPath,\n }: {\n binding: { bindingId: string; basePath: string };\n routeMap: RouteMap;\n signInPath: string | null;\n publicSignInPath: string | null;\n },\n): string | null {\n // Accepts both authored spellings, resolving the relative one against the store's own origin.\n const destination = new URL(loginHref, globalThis.location.origin);\n\n // A cross-origin login page whose path happens to be the sign-in page's is a different page, and travels.\n if (destination.origin === globalThis.location.origin && isSignInRoute(destination.pathname, publicSignInPath)) {\n return null;\n }\n\n // Read from the document rather than through `useSearchParams()`, which would require a `Suspense`\n // boundary the generator does not emit on a prerendered route.\n const arriving = new URLSearchParams(globalThis.location.search).get(RETURN_URL_PARAM);\n if (arriving === null) {\n return destination.toString();\n }\n\n const returnHref = resolveReturnHref(withoutBasePath(arriving, binding.basePath), signInPath);\n if (!returnHref.safe) {\n console.warn('[SignInRedirect] return destination rejected', { reason: returnHref.reason });\n return destination.toString();\n }\n // The pure resolver rather than `hrefFor`: a return equal to a page pattern is not a suspicious path.\n const publicReturn = resolveStorefrontHref(binding, routeMap, returnHref.href);\n if (publicReturn.href === null) {\n console.warn('[SignInRedirect] return destination rejected', { reason: publicReturn.reason });\n return destination.toString();\n }\n\n // A path alone cannot say which origin it belongs to, and the store author is the one who decides\n // whether the receiver shares ours. A same-origin endpoint takes the path as it arrived, the way\n // legacy hands its own endpoint a bare `returnUrl`; a cross-origin one would resolve that path\n // against its own domain, so it is absolutized — always against the storefront, never the address.\n const sameOrigin = destination.origin === globalThis.location.origin;\n const value = sameOrigin ? publicReturn.href : new URL(publicReturn.href, globalThis.location.origin).toString();\n destination.searchParams.set(RETURN_URL_PARAM, value);\n\n return destination.toString();\n}\n\n/**\n * The waiting look, and the page's only content while the handover is pending. A real part with its own\n * hook rather than an ad hoc spinner, so a store can style it and a story can render it — mounting the\n * component itself would navigate the frame away.\n */\nexport function SignInRedirectLoading({ className, children, ...props }: SignInRedirectLoadingProps) {\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-sign-in-redirect-loading=\"\">\n {children}\n </output>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,wBAAwB,kBAAkB;CACrD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY,EACV,cAAc;GAAE,MAAM;GAAU,WAAW;GAAG,OAAO;EAAkB,EACzE;CACF;AACF,CAAC;AAkBD,MAAa,2BAA2B,gBAAqC;CAC3E,MAAM;CACN,YAAY;CACZ,WAAW;CACX,SAAS;CACT,QAAQ;EAAE,OAAO;EAAoB,UAAU;CAAW;CAC1D,QAAQ;EACN,kBAAkB;GAAE,MAAM;GAAU,OAAO;EAAqB;EAGhE,cAAc;GAAE,MAAM;GAAU,OAAO;EAAkB;CAC3D;CACA,WACE;AACJ,CAAC;AAED,SAAgB,eAAe,EAC7B,kBACA,cACA,UACA,WACA,KACA,GAAG,SACmB;CAGtB,MAAM,gBAAgB,OAAO,KAAK;CAClC,MAAM,EAAE,WAAW,aAAa,qBAAqB;CACrD,MAAM,EAAE,aAAa,YAAY;CAGjC,MAAM,aAAa,sBAAsB;EAAE;EAAW,UAAU;CAAI,GAAG,UAAU,YAAY,CAAC,CAAC;CAC/F,MAAM,mBAAmB,sBAAsB;EAAE;EAAW;CAAS,GAAG,UAAU,YAAY,CAAC,CAAC;CAGhG,MAAM,eAAe,OAAsB,IAAI;CAG/C,MAAM,oBAAoB,UAAU,cAAc,KAAK,IAAI,SAAS,eAAe;CAInF,MAAM,UAAU,kBAAkB,KAAK,IAAI,wBAAwB,kBAAkB,gBAAgB,IAAI;CACzG,MAAM,YAAY,SAAS,OAAO,QAAQ,OAAO;CAEjD,MAAM,YAAY,YAAY,QAAQ,CAAC,QAAQ,OAAO,QAAQ,SAAS;CAEvE,gBAAgB;EACd,IAAI,cAAc,MAAM;GACtB,IAAI,cAAc,SAChB;GAEF,MAAM,WAAW,gBAAgB,WAAW;IAC1C,S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AAS,MAAM;EAC9B,QAAQ,KAAK,gDAAgD,EAAE,QAAQ,aAAa,OAAO,CAAC;EAC5F,OAAO,YAAY,SAAS;CAC9B;CAOA,MAAM,QADa,YAAY,WAAW,WAAW,SAAS,SACnC,aAAa,OAAO,IAAI,IAAI,aAAa,MAAM,WAAW,SAAS,MAAM,CAAC,CAAC,SAAS;CAC/G,YAAY,aAAa,IAAI,kBAAkB,KAAK;CAEpD,OAAO,YAAY,SAAS;AAC9B;;;;;;AAOA,SAAgB,sBAAsB,EAAE,WAAW,UAAU,GAAG,SAAqC;CACnG,OACE,oBAAC,UAAD;EAAQ,GAAI;EAAO,aAAU;EAAoB;EAAW,oCAAiC;EAC1F;CACK,CAAA;AAEZ"}
@@ -7,7 +7,7 @@ import { RadioGroup } from "../../particles/radio/radio.js";
7
7
  import { publishedVariantIdFor, selectedVariantVar } from "../../sdk/state/variant-selector.js";
8
8
  import { useReactiveVar } from "@apollo/client/react";
9
9
  import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
10
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
11
11
  import { Radio } from "@base-ui/react/radio";
12
12
  //#region src/matter/variant-selector/variant-selector.tsx
13
13
  const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
@@ -190,7 +190,7 @@ function ColorSwatchContent({ swatch, value, Image }) {
190
190
  * the ring and `-indicator` as the dot.
191
191
  */
192
192
  function RadioSwatchContent({ value }) {
193
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
193
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
194
194
  "data-fs-variant-selector-option-control": "",
195
195
  "aria-hidden": "true",
196
196
  children: /* @__PURE__ */ jsx(Radio.Indicator, { "data-fs-variant-selector-option-indicator": "" })