@salla.sa/twilight-theme-engine 1.0.94 → 1.0.96

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 (353) hide show
  1. package/dist/{AddToCartForm-MASXVJOI.js → AddToCartForm-DASRXMY7.js} +3 -3
  2. package/dist/{AddToCartForm-MASXVJOI.js.map → AddToCartForm-DASRXMY7.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-KRT7MRTC.js → BlogAuthorPage-WFZGYSUB.js} +26 -24
  4. package/dist/BlogAuthorPage-WFZGYSUB.js.map +1 -0
  5. package/dist/{BlogCategoryPage-OP3ETAMT.js → BlogCategoryPage-23PFOVVP.js} +26 -24
  6. package/dist/BlogCategoryPage-23PFOVVP.js.map +1 -0
  7. package/dist/{BlogPage-RGAQVUDI.js → BlogPage-4RFI56TW.js} +24 -22
  8. package/dist/BlogPage-4RFI56TW.js.map +1 -0
  9. package/dist/{BlogSinglePage-VG4UXBTL.js → BlogSinglePage-KMGBQUG5.js} +24 -22
  10. package/dist/BlogSinglePage-KMGBQUG5.js.map +1 -0
  11. package/dist/{BlogTagPage-G4IVHJD5.js → BlogTagPage-ZPQJKPBO.js} +26 -24
  12. package/dist/BlogTagPage-ZPQJKPBO.js.map +1 -0
  13. package/dist/{BrandsPage-2JMPPOOU.js → BrandsPage-FIHOZYMB.js} +25 -23
  14. package/dist/BrandsPage-FIHOZYMB.js.map +1 -0
  15. package/dist/{Breadcrumb-I3ZOGG2Y.js → Breadcrumb-2IXFQL6L.js} +24 -22
  16. package/dist/Breadcrumb-2IXFQL6L.js.map +1 -0
  17. package/dist/{CartItem-YTPYETW6.js → CartItem-GRFH5BED.js} +24 -22
  18. package/dist/CartItem-GRFH5BED.js.map +1 -0
  19. package/dist/{CartSummary-DND7BO26.js → CartSummary-IOCZJL26.js} +24 -22
  20. package/dist/CartSummary-IOCZJL26.js.map +1 -0
  21. package/dist/{Copyright-RWML3BQV.js → Copyright-MDKYCKML.js} +3 -3
  22. package/dist/{Copyright-RWML3BQV.js.map → Copyright-MDKYCKML.js.map} +1 -1
  23. package/dist/{CustomerLayout-HCYVBODI.js → CustomerLayout-4737YCAK.js} +24 -22
  24. package/dist/CustomerLayout-4737YCAK.js.map +1 -0
  25. package/dist/{Footer-3GEKWEQD.js → Footer-2F652QDB.js} +4 -4
  26. package/dist/{Footer-3GEKWEQD.js.map → Footer-2F652QDB.js.map} +1 -1
  27. package/dist/Header-4OATF4LX.js +22 -0
  28. package/dist/{Header-QG4UO3MF.js.map → Header-4OATF4LX.js.map} +1 -1
  29. package/dist/{LoyaltyPage-ZMFYQMQY.js → LoyaltyPage-POFUTIPB.js} +24 -22
  30. package/dist/LoyaltyPage-POFUTIPB.js.map +1 -0
  31. package/dist/{LoyaltyPointsPage-5PB6IFLY.js → LoyaltyPointsPage-L4S4NZA2.js} +8 -7
  32. package/dist/LoyaltyPointsPage-L4S4NZA2.js.map +1 -0
  33. package/dist/{MainMenu-SAUMNMBF.js → MainMenu-ROGX37TG.js} +7 -6
  34. package/dist/MainMenu-ROGX37TG.js.map +1 -0
  35. package/dist/{MasterLayout-TY223YR7.js → MasterLayout-PGL5YU2B.js} +24 -22
  36. package/dist/{MasterLayout-TY223YR7.js.map → MasterLayout-PGL5YU2B.js.map} +1 -1
  37. package/dist/{MobileMenu-2WOWOFQB.js → MobileMenu-VGXWJHEF.js} +25 -23
  38. package/dist/MobileMenu-VGXWJHEF.js.map +1 -0
  39. package/dist/{NotificationsPage-6FX4SOZU.js → NotificationsPage-PZAEKKJO.js} +24 -22
  40. package/dist/NotificationsPage-PZAEKKJO.js.map +1 -0
  41. package/dist/{OrderSinglePage-RUMSJIFD.js → OrderSinglePage-KTKLXTUX.js} +25 -23
  42. package/dist/OrderSinglePage-KTKLXTUX.js.map +1 -0
  43. package/dist/{OrdersPage-B4Q4QIEM.js → OrdersPage-BY6LYV5M.js} +24 -22
  44. package/dist/OrdersPage-BY6LYV5M.js.map +1 -0
  45. package/dist/{PageSingle-F4TDNKUM.js → PageSingle-CJRT3HJZ.js} +6 -5
  46. package/dist/PageSingle-CJRT3HJZ.js.map +1 -0
  47. package/dist/{ProductDetails-BNVVUDBH.js → ProductDetails-O2VJVIZC.js} +7 -6
  48. package/dist/ProductDetails-O2VJVIZC.js.map +1 -0
  49. package/dist/{ProfilePage-OJSAXSC2.js → ProfilePage-TB7PBODI.js} +24 -22
  50. package/dist/ProfilePage-TB7PBODI.js.map +1 -0
  51. package/dist/{RenderWhenVisible-F44J5MMG.js → RenderWhenVisible-KWAXEJOJ.js} +8 -5
  52. package/dist/RenderWhenVisible-KWAXEJOJ.js.map +1 -0
  53. package/dist/{ReviewsPage-3IJKJKTY.js → ReviewsPage-5KGCKLFR.js} +3 -3
  54. package/dist/{ReviewsPage-3IJKJKTY.js.map → ReviewsPage-5KGCKLFR.js.map} +1 -1
  55. package/dist/{SeoCartWidget-4PN2DW54.js → SeoCartWidget-6BU7WCTP.js} +24 -22
  56. package/dist/SeoCartWidget-6BU7WCTP.js.map +1 -0
  57. package/dist/{SettingsPage-BCRNV4GU.js → SettingsPage-G55AM2KS.js} +24 -22
  58. package/dist/SettingsPage-G55AM2KS.js.map +1 -0
  59. package/dist/{StoreClosedNotification-IRUTRLIH.js → StoreClosedNotification-C3BBFGAA.js} +25 -23
  60. package/dist/{StoreClosedNotification-IRUTRLIH.js.map → StoreClosedNotification-C3BBFGAA.js.map} +1 -1
  61. package/dist/{TestimonialsPage-YU4PLOLR.js → TestimonialsPage-EA4PSO7E.js} +6 -5
  62. package/dist/TestimonialsPage-EA4PSO7E.js.map +1 -0
  63. package/dist/{ThankYouPage-MUDELEIQ.js → ThankYouPage-R2OEK7ZZ.js} +24 -22
  64. package/dist/ThankYouPage-R2OEK7ZZ.js.map +1 -0
  65. package/dist/{WalletPage-2I4KTR5E.js → WalletPage-MEWHIHUE.js} +25 -23
  66. package/dist/WalletPage-MEWHIHUE.js.map +1 -0
  67. package/dist/{WishlistPage-7AYL3RUD.js → WishlistPage-YFKG7CXU.js} +26 -24
  68. package/dist/WishlistPage-YFKG7CXU.js.map +1 -0
  69. package/dist/ambient/virtual-modules.d.ts +43 -1
  70. package/dist/api/advertisement.js +4 -3
  71. package/dist/api/apps.js +4 -3
  72. package/dist/api/blog.js +6 -5
  73. package/dist/api/brands.js +6 -5
  74. package/dist/api/cart.js +6 -5
  75. package/dist/api/category.js +6 -5
  76. package/dist/api/client.js +3 -2
  77. package/dist/api/home.js +4 -3
  78. package/dist/api/loyalty.js +6 -5
  79. package/dist/api/menu.js +4 -3
  80. package/dist/api/notification.js +4 -3
  81. package/dist/api/order.js +6 -5
  82. package/dist/api/page.js +6 -5
  83. package/dist/api/product.js +6 -5
  84. package/dist/api/profile.js +3 -2
  85. package/dist/api/profile.js.map +1 -1
  86. package/dist/api/store.js +4 -3
  87. package/dist/api/translations.js +4 -3
  88. package/dist/api/user.js +4 -3
  89. package/dist/api/wallet.js +4 -3
  90. package/dist/api/wishlist.js +7 -6
  91. package/dist/{chunk-LA7KZ2XY.js → chunk-2D5TFSVG.js} +8 -8
  92. package/dist/{chunk-LA7KZ2XY.js.map → chunk-2D5TFSVG.js.map} +1 -1
  93. package/dist/{chunk-HQAFPDJK.js → chunk-2FDLEB5J.js} +3 -3
  94. package/dist/{chunk-HQAFPDJK.js.map → chunk-2FDLEB5J.js.map} +1 -1
  95. package/dist/chunk-2FKZAAV7.js +90 -0
  96. package/dist/chunk-2FKZAAV7.js.map +1 -0
  97. package/dist/{chunk-YDFOJBEY.js → chunk-3GW3VFR6.js} +3 -3
  98. package/dist/{chunk-YDFOJBEY.js.map → chunk-3GW3VFR6.js.map} +1 -1
  99. package/dist/{chunk-CEYT3JER.js → chunk-56T47K7P.js} +4 -4
  100. package/dist/{chunk-CEYT3JER.js.map → chunk-56T47K7P.js.map} +1 -1
  101. package/dist/{chunk-LPQ5FUMJ.js → chunk-5SDCUGYR.js} +4 -4
  102. package/dist/{chunk-LPQ5FUMJ.js.map → chunk-5SDCUGYR.js.map} +1 -1
  103. package/dist/{chunk-QGOPTVV5.js → chunk-6EQ7G3SZ.js} +4 -3
  104. package/dist/chunk-6EQ7G3SZ.js.map +1 -0
  105. package/dist/{chunk-H7CVJFTK.js → chunk-6RHU4TEF.js} +7 -7
  106. package/dist/{chunk-H7CVJFTK.js.map → chunk-6RHU4TEF.js.map} +1 -1
  107. package/dist/{chunk-FZYR4BA2.js → chunk-7WTUA4WY.js} +3 -3
  108. package/dist/{chunk-FZYR4BA2.js.map → chunk-7WTUA4WY.js.map} +1 -1
  109. package/dist/{chunk-3PXONLUK.js → chunk-BH7YNCYB.js} +3 -3
  110. package/dist/{chunk-3PXONLUK.js.map → chunk-BH7YNCYB.js.map} +1 -1
  111. package/dist/{chunk-DBW7XXNE.js → chunk-BPL5H33B.js} +4 -4
  112. package/dist/{chunk-DBW7XXNE.js.map → chunk-BPL5H33B.js.map} +1 -1
  113. package/dist/{chunk-66K5P5ZX.js → chunk-CNUBL24W.js} +3 -3
  114. package/dist/{chunk-66K5P5ZX.js.map → chunk-CNUBL24W.js.map} +1 -1
  115. package/dist/chunk-COJH52VR.js +443 -0
  116. package/dist/chunk-COJH52VR.js.map +1 -0
  117. package/dist/{chunk-6OOTDFC7.js → chunk-D56TVNOG.js} +3 -3
  118. package/dist/{chunk-6OOTDFC7.js.map → chunk-D56TVNOG.js.map} +1 -1
  119. package/dist/{chunk-Y7XVWQXG.js → chunk-DNPQ2JBM.js} +4 -4
  120. package/dist/{chunk-Y7XVWQXG.js.map → chunk-DNPQ2JBM.js.map} +1 -1
  121. package/dist/{chunk-JJARU7YP.js → chunk-EWLVLDRP.js} +3 -3
  122. package/dist/{chunk-JJARU7YP.js.map → chunk-EWLVLDRP.js.map} +1 -1
  123. package/dist/{chunk-Y357MBJI.js → chunk-FNHZEBA5.js} +9 -8
  124. package/dist/chunk-FNHZEBA5.js.map +1 -0
  125. package/dist/{chunk-HSWRYXC7.js → chunk-FO4WVGUQ.js} +3 -88
  126. package/dist/chunk-FO4WVGUQ.js.map +1 -0
  127. package/dist/{chunk-BNI6SKFL.js → chunk-G3UTLICK.js} +4 -4
  128. package/dist/{chunk-BNI6SKFL.js.map → chunk-G3UTLICK.js.map} +1 -1
  129. package/dist/{chunk-C4RXPVDF.js → chunk-GMXI6V2D.js} +6 -5
  130. package/dist/chunk-GMXI6V2D.js.map +1 -0
  131. package/dist/{chunk-RKQH63G2.js → chunk-GXHJXZBG.js} +4 -4
  132. package/dist/{chunk-RKQH63G2.js.map → chunk-GXHJXZBG.js.map} +1 -1
  133. package/dist/{chunk-43D2CG4F.js → chunk-IBSQO6LW.js} +4 -4
  134. package/dist/{chunk-43D2CG4F.js.map → chunk-IBSQO6LW.js.map} +1 -1
  135. package/dist/{chunk-ZVZGLEZ6.js → chunk-IU4KTCS3.js} +3 -3
  136. package/dist/{chunk-ZVZGLEZ6.js.map → chunk-IU4KTCS3.js.map} +1 -1
  137. package/dist/{chunk-ZFNLX3F7.js → chunk-J3G4ZD76.js} +13 -12
  138. package/dist/chunk-J3G4ZD76.js.map +1 -0
  139. package/dist/{chunk-ENJ3CM5M.js → chunk-J5X4LXNM.js} +3 -3
  140. package/dist/{chunk-ENJ3CM5M.js.map → chunk-J5X4LXNM.js.map} +1 -1
  141. package/dist/{chunk-TJF6YZ5I.js → chunk-JKBLG344.js} +8 -7
  142. package/dist/chunk-JKBLG344.js.map +1 -0
  143. package/dist/{chunk-RPDMNNRW.js → chunk-JVIPOD6M.js} +20 -19
  144. package/dist/chunk-JVIPOD6M.js.map +1 -0
  145. package/dist/{chunk-4WAUITU2.js → chunk-KNIGLCRV.js} +3 -3
  146. package/dist/{chunk-4WAUITU2.js.map → chunk-KNIGLCRV.js.map} +1 -1
  147. package/dist/{chunk-OMKLPCBA.js → chunk-KQW6I5CD.js} +4 -4
  148. package/dist/{chunk-OMKLPCBA.js.map → chunk-KQW6I5CD.js.map} +1 -1
  149. package/dist/{chunk-HR3QJ3LW.js → chunk-LXNS6CMT.js} +4 -4
  150. package/dist/{chunk-HR3QJ3LW.js.map → chunk-LXNS6CMT.js.map} +1 -1
  151. package/dist/chunk-MGDCJQ5P.js +14 -0
  152. package/dist/{chunk-KZM7HXJ3.js.map → chunk-MGDCJQ5P.js.map} +1 -1
  153. package/dist/chunk-N45X7D55.js +63 -0
  154. package/dist/chunk-N45X7D55.js.map +1 -0
  155. package/dist/{chunk-OH2L4U2C.js → chunk-NZRJOAA7.js} +3 -3
  156. package/dist/{chunk-OH2L4U2C.js.map → chunk-NZRJOAA7.js.map} +1 -1
  157. package/dist/{chunk-TEOVJ6WU.js → chunk-O7B5JL6H.js} +4 -4
  158. package/dist/{chunk-TEOVJ6WU.js.map → chunk-O7B5JL6H.js.map} +1 -1
  159. package/dist/{chunk-UURVAJ42.js → chunk-OZP2FID7.js} +4 -4
  160. package/dist/{chunk-UURVAJ42.js.map → chunk-OZP2FID7.js.map} +1 -1
  161. package/dist/{chunk-HCA2TE4G.js → chunk-PGUKRWOY.js} +5 -5
  162. package/dist/{chunk-HCA2TE4G.js.map → chunk-PGUKRWOY.js.map} +1 -1
  163. package/dist/{chunk-3MIFT4VQ.js → chunk-Q62YEBIA.js} +4 -4
  164. package/dist/{chunk-3MIFT4VQ.js.map → chunk-Q62YEBIA.js.map} +1 -1
  165. package/dist/{chunk-6DMNJPLW.js → chunk-QS4EDTEX.js} +3 -3
  166. package/dist/{chunk-6DMNJPLW.js.map → chunk-QS4EDTEX.js.map} +1 -1
  167. package/dist/{chunk-SAGXF3MU.js → chunk-QZEQOVA5.js} +3 -3
  168. package/dist/{chunk-SAGXF3MU.js.map → chunk-QZEQOVA5.js.map} +1 -1
  169. package/dist/{chunk-JTOVO3ZU.js → chunk-RWBTMHLR.js} +5 -5
  170. package/dist/{chunk-JTOVO3ZU.js.map → chunk-RWBTMHLR.js.map} +1 -1
  171. package/dist/{chunk-DV6SJHL5.js → chunk-S34G5DL4.js} +4 -4
  172. package/dist/{chunk-DV6SJHL5.js.map → chunk-S34G5DL4.js.map} +1 -1
  173. package/dist/{chunk-MKVCFBVF.js → chunk-TIPR4JUO.js} +4 -4
  174. package/dist/{chunk-MKVCFBVF.js.map → chunk-TIPR4JUO.js.map} +1 -1
  175. package/dist/{chunk-WHJZP3QJ.js → chunk-ULMSO2XZ.js} +7 -7
  176. package/dist/{chunk-WHJZP3QJ.js.map → chunk-ULMSO2XZ.js.map} +1 -1
  177. package/dist/{chunk-IVBOLREE.js → chunk-VWVCSD3N.js} +3 -3
  178. package/dist/{chunk-IVBOLREE.js.map → chunk-VWVCSD3N.js.map} +1 -1
  179. package/dist/{chunk-5G7NYNX6.js → chunk-W2LNKEBF.js} +3 -3
  180. package/dist/{chunk-5G7NYNX6.js.map → chunk-W2LNKEBF.js.map} +1 -1
  181. package/dist/{chunk-AV6AAVNU.js → chunk-XGNML7XM.js} +7 -7
  182. package/dist/{chunk-AV6AAVNU.js.map → chunk-XGNML7XM.js.map} +1 -1
  183. package/dist/{chunk-46NBPXAI.js → chunk-XT6CLGF5.js} +3 -3
  184. package/dist/{chunk-46NBPXAI.js.map → chunk-XT6CLGF5.js.map} +1 -1
  185. package/dist/{chunk-SFZ7IIWL.js → chunk-ZEGNYJOR.js} +4 -4
  186. package/dist/{chunk-SFZ7IIWL.js.map → chunk-ZEGNYJOR.js.map} +1 -1
  187. package/dist/{chunk-OM26SAHA.js → chunk-ZPVLBXDY.js} +4 -4
  188. package/dist/{chunk-OM26SAHA.js.map → chunk-ZPVLBXDY.js.map} +1 -1
  189. package/dist/components/cart/index.js +1 -1
  190. package/dist/components/common/RenderWhenVisible.d.ts +3 -1
  191. package/dist/components/common/RenderWhenVisible.d.ts.map +1 -1
  192. package/dist/components/common/index.js +1 -1
  193. package/dist/components/common/lazy.d.ts +1 -1
  194. package/dist/components/common/lazy.d.ts.map +1 -1
  195. package/dist/components/drawer/index.js +22 -20
  196. package/dist/components/home/HomePageRenderer.d.ts.map +1 -1
  197. package/dist/components/home/index.js +26 -24
  198. package/dist/components/layout/index.js +6 -5
  199. package/dist/components/product/index.js +23 -21
  200. package/dist/components/store/index.js +24 -22
  201. package/dist/components/store/index.js.map +1 -1
  202. package/dist/components/toast/index.js +4 -3
  203. package/dist/components/toast/index.js.map +1 -1
  204. package/dist/components/tracking/index.js +1 -1
  205. package/dist/dev/DevSettingsWidget.d.ts +6 -7
  206. package/dist/dev/DevSettingsWidget.d.ts.map +1 -1
  207. package/dist/dev/dev-settings-store.d.ts +89 -46
  208. package/dist/dev/dev-settings-store.d.ts.map +1 -1
  209. package/dist/dev/editor/AddElementDrawer.d.ts +17 -0
  210. package/dist/dev/editor/AddElementDrawer.d.ts.map +1 -0
  211. package/dist/dev/editor/BuilderPanel.d.ts +23 -0
  212. package/dist/dev/editor/BuilderPanel.d.ts.map +1 -0
  213. package/dist/dev/editor/SettingsPanel.d.ts +9 -0
  214. package/dist/dev/editor/SettingsPanel.d.ts.map +1 -0
  215. package/dist/dev/editor/ThemeEditor.d.ts +20 -0
  216. package/dist/dev/editor/ThemeEditor.d.ts.map +1 -0
  217. package/dist/dev/editor/catalog.d.ts +10 -0
  218. package/dist/dev/editor/catalog.d.ts.map +1 -0
  219. package/dist/dev/editor/fields.d.ts +18 -0
  220. package/dist/dev/editor/fields.d.ts.map +1 -0
  221. package/dist/dev/editor/i18n.d.ts +72 -0
  222. package/dist/dev/editor/i18n.d.ts.map +1 -0
  223. package/dist/dev/editor/icons.d.ts +21 -0
  224. package/dist/dev/editor/icons.d.ts.map +1 -0
  225. package/dist/dev/editor/index.d.ts +8 -0
  226. package/dist/dev/editor/index.d.ts.map +1 -0
  227. package/dist/dev/editor/index.js +2059 -0
  228. package/dist/dev/editor/index.js.map +1 -0
  229. package/dist/dev/editor/lookup.d.ts +22 -0
  230. package/dist/dev/editor/lookup.d.ts.map +1 -0
  231. package/dist/dev/editor/mount.d.ts +4 -0
  232. package/dist/dev/editor/mount.d.ts.map +1 -0
  233. package/dist/dev/editor/paths.d.ts +44 -0
  234. package/dist/dev/editor/paths.d.ts.map +1 -0
  235. package/dist/dev/editor/pickers.d.ts +12 -0
  236. package/dist/dev/editor/pickers.d.ts.map +1 -0
  237. package/dist/dev/editor/styles.d.ts +8 -0
  238. package/dist/dev/editor/styles.d.ts.map +1 -0
  239. package/dist/dev/index.d.ts +1 -1
  240. package/dist/dev/index.d.ts.map +1 -1
  241. package/dist/dev/index.js +35 -309
  242. package/dist/dev/index.js.map +1 -1
  243. package/dist/dev/schema-types.d.ts +124 -4
  244. package/dist/dev/schema-types.d.ts.map +1 -1
  245. package/dist/dev/store-lookup.d.ts +13 -0
  246. package/dist/dev/store-lookup.d.ts.map +1 -0
  247. package/dist/document-class-2RROXH4K.js +29 -0
  248. package/dist/{document-class-AJGI7GKJ.js.map → document-class-2RROXH4K.js.map} +1 -1
  249. package/dist/hooks/index.js +22 -20
  250. package/dist/hooks/useComments.js +3 -2
  251. package/dist/hooks/useGtm.js +22 -20
  252. package/dist/hooks/useMoney.js +22 -20
  253. package/dist/hooks/useProduct.js +3 -2
  254. package/dist/hooks/useStore.js +22 -20
  255. package/dist/hooks/useUser.js +5 -4
  256. package/dist/hooks/useWishlist.js +3 -2
  257. package/dist/index.js +22 -20
  258. package/dist/index.js.map +1 -1
  259. package/dist/native-app/index.js +3 -2
  260. package/dist/{navigation-KTFJWOWI.js → navigation-JB2CJXBF.js} +7 -6
  261. package/dist/navigation-JB2CJXBF.js.map +1 -0
  262. package/dist/navigation-KTMLD4VB.js +14 -0
  263. package/dist/{navigation-BARZWXJZ.js.map → navigation-KTMLD4VB.js.map} +1 -1
  264. package/dist/{not-found-NK6ZFJ7H.js → not-found-ZM6VIELR.js} +25 -23
  265. package/dist/not-found-ZM6VIELR.js.map +1 -0
  266. package/dist/providers/index.js +22 -20
  267. package/dist/routes/account/orders.js +7 -6
  268. package/dist/routes/account.js +16 -15
  269. package/dist/routes/account.js.map +1 -1
  270. package/dist/routes/blog.js +11 -10
  271. package/dist/routes/blog.js.map +1 -1
  272. package/dist/routes/brands.js +7 -6
  273. package/dist/routes/brands.js.map +1 -1
  274. package/dist/routes/cart.js +30 -28
  275. package/dist/routes/cart.js.map +1 -1
  276. package/dist/routes/home/HomePage.d.ts.map +1 -1
  277. package/dist/routes/home.js +27 -25
  278. package/dist/routes/index.js +6 -5
  279. package/dist/routes/loyalty.js +8 -7
  280. package/dist/routes/loyalty.js.map +1 -1
  281. package/dist/routes/page.js +7 -6
  282. package/dist/routes/page.js.map +1 -1
  283. package/dist/routes/product-listing/index.d.ts +27 -0
  284. package/dist/routes/product-listing/index.d.ts.map +1 -1
  285. package/dist/routes/product-listing.js +52 -27
  286. package/dist/routes/product-listing.js.map +1 -1
  287. package/dist/routes/product.js +26 -24
  288. package/dist/routes/product.js.map +1 -1
  289. package/dist/routes/seo-redirects.js +6 -5
  290. package/dist/routes/testimonials.js +2 -2
  291. package/dist/routes/thank-you.js +7 -6
  292. package/dist/routes/thank-you.js.map +1 -1
  293. package/dist/skeleton.js +27 -25
  294. package/dist/store-lookup-T4TK7CKA.js +114 -0
  295. package/dist/store-lookup-T4TK7CKA.js.map +1 -0
  296. package/dist/tanstack.js +17 -16
  297. package/dist/tanstack.js.map +1 -1
  298. package/dist/utils/index.js +6 -5
  299. package/dist/utils/index.js.map +1 -1
  300. package/dist/vite/adapters/tanstack.adapter.d.ts.map +1 -1
  301. package/dist/vite/index.js +424 -47
  302. package/dist/vite/index.js.map +1 -1
  303. package/dist/vite/plugins/twilight-schema.d.ts +7 -2
  304. package/dist/vite/plugins/twilight-schema.d.ts.map +1 -1
  305. package/dist/vite/plugins/twilight-schema.plugin.d.ts +26 -0
  306. package/dist/vite/plugins/twilight-schema.plugin.d.ts.map +1 -1
  307. package/package.json +5 -1
  308. package/tailwind/components/common/RenderWhenVisible.tsx.txt +9 -2
  309. package/tailwind/components/home/HomePageRenderer.tsx.txt +2 -0
  310. package/tailwind/routes/home/HomePage.tsx.txt +7 -6
  311. package/tailwind/routes/product-listing/index.tsx.txt +42 -0
  312. package/dist/BlogAuthorPage-KRT7MRTC.js.map +0 -1
  313. package/dist/BlogCategoryPage-OP3ETAMT.js.map +0 -1
  314. package/dist/BlogPage-RGAQVUDI.js.map +0 -1
  315. package/dist/BlogSinglePage-VG4UXBTL.js.map +0 -1
  316. package/dist/BlogTagPage-G4IVHJD5.js.map +0 -1
  317. package/dist/BrandsPage-2JMPPOOU.js.map +0 -1
  318. package/dist/Breadcrumb-I3ZOGG2Y.js.map +0 -1
  319. package/dist/CartItem-YTPYETW6.js.map +0 -1
  320. package/dist/CartSummary-DND7BO26.js.map +0 -1
  321. package/dist/CustomerLayout-HCYVBODI.js.map +0 -1
  322. package/dist/Header-QG4UO3MF.js +0 -21
  323. package/dist/LoyaltyPage-ZMFYQMQY.js.map +0 -1
  324. package/dist/LoyaltyPointsPage-5PB6IFLY.js.map +0 -1
  325. package/dist/MainMenu-SAUMNMBF.js.map +0 -1
  326. package/dist/MobileMenu-2WOWOFQB.js.map +0 -1
  327. package/dist/NotificationsPage-6FX4SOZU.js.map +0 -1
  328. package/dist/OrderSinglePage-RUMSJIFD.js.map +0 -1
  329. package/dist/OrdersPage-B4Q4QIEM.js.map +0 -1
  330. package/dist/PageSingle-F4TDNKUM.js.map +0 -1
  331. package/dist/ProductDetails-BNVVUDBH.js.map +0 -1
  332. package/dist/ProfilePage-OJSAXSC2.js.map +0 -1
  333. package/dist/RenderWhenVisible-F44J5MMG.js.map +0 -1
  334. package/dist/SeoCartWidget-4PN2DW54.js.map +0 -1
  335. package/dist/SettingsPage-BCRNV4GU.js.map +0 -1
  336. package/dist/TestimonialsPage-YU4PLOLR.js.map +0 -1
  337. package/dist/ThankYouPage-MUDELEIQ.js.map +0 -1
  338. package/dist/WalletPage-2I4KTR5E.js.map +0 -1
  339. package/dist/WishlistPage-7AYL3RUD.js.map +0 -1
  340. package/dist/chunk-2JV6WZ6O.js +0 -136
  341. package/dist/chunk-2JV6WZ6O.js.map +0 -1
  342. package/dist/chunk-C4RXPVDF.js.map +0 -1
  343. package/dist/chunk-HSWRYXC7.js.map +0 -1
  344. package/dist/chunk-KZM7HXJ3.js +0 -14
  345. package/dist/chunk-QGOPTVV5.js.map +0 -1
  346. package/dist/chunk-RPDMNNRW.js.map +0 -1
  347. package/dist/chunk-TJF6YZ5I.js.map +0 -1
  348. package/dist/chunk-Y357MBJI.js.map +0 -1
  349. package/dist/chunk-ZFNLX3F7.js.map +0 -1
  350. package/dist/document-class-AJGI7GKJ.js +0 -28
  351. package/dist/navigation-BARZWXJZ.js +0 -13
  352. package/dist/navigation-KTFJWOWI.js.map +0 -1
  353. package/dist/not-found-NK6ZFJ7H.js.map +0 -1
@@ -0,0 +1,63 @@
1
+ // src/dev/schema-types.ts
2
+ var DEV_LOOKUP_TIMEOUT_MS = 8e3;
3
+ var DEV_LOOKUP_BUDGET_MS = 5e3;
4
+ function conditionScalar(value) {
5
+ const first = Array.isArray(value) ? value[0] : value;
6
+ return first && typeof first === "object" ? first.value : first;
7
+ }
8
+ function conditionsMet(field, valueOf) {
9
+ return (field.conditions ?? []).every(({ id, operation, value }) => {
10
+ const equal = String(conditionScalar(valueOf(id))) === String(conditionScalar(value));
11
+ if (operation === "=" || operation === "==") return equal;
12
+ if (operation === "!=") return !equal;
13
+ return true;
14
+ });
15
+ }
16
+ var DEV_EDITOR_PATH = "/__twilight/editor";
17
+ var DEV_EDITOR_FRAME_ATTR = "data-twilight-editor";
18
+ function isEditorFrame() {
19
+ if (typeof window === "undefined") return false;
20
+ try {
21
+ return window.frameElement?.hasAttribute(DEV_EDITOR_FRAME_ATTR) ?? false;
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+ var DEV_PREVIEW_ENDPOINT = "/__twilight/preview";
27
+ var DEV_PREVIEW_IMAGE_ENDPOINT = `${DEV_PREVIEW_ENDPOINT}/image`;
28
+ var DEV_PREVIEW_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
29
+ var DEV_PREVIEW_EVENT = "twilight:preview";
30
+ var DEV_PREVIEW_GLOBAL = "__twilightDevPreview__";
31
+ var EMPTY_PREVIEW_STATE = { enabled: false, settings: {}, layout: null };
32
+ function isRecord(value) {
33
+ return typeof value === "object" && value !== null && !Array.isArray(value);
34
+ }
35
+ function normalizePreviewState(raw) {
36
+ if (!isRecord(raw)) return null;
37
+ const layout = Array.isArray(raw.layout) ? raw.layout.flatMap(
38
+ (entry, index) => isRecord(entry) && typeof entry.path === "string" && entry.path ? [
39
+ {
40
+ id: typeof entry.id === "string" && entry.id ? entry.id : `block-${index}`,
41
+ path: entry.path.replace(/^home\./, ""),
42
+ fields: isRecord(entry.fields) ? entry.fields : {}
43
+ }
44
+ ] : []
45
+ ) : null;
46
+ return {
47
+ enabled: raw.enabled === true,
48
+ settings: isRecord(raw.settings) ? raw.settings : {},
49
+ layout
50
+ };
51
+ }
52
+ var EMPTY_DEV_SCHEMA = {
53
+ settings: [],
54
+ components: [],
55
+ settingsDefaults: {},
56
+ componentDefaults: {},
57
+ blockDefaults: {},
58
+ preview: null
59
+ };
60
+
61
+ export { DEV_EDITOR_FRAME_ATTR, DEV_EDITOR_PATH, DEV_LOOKUP_BUDGET_MS, DEV_LOOKUP_TIMEOUT_MS, DEV_PREVIEW_ENDPOINT, DEV_PREVIEW_EVENT, DEV_PREVIEW_GLOBAL, DEV_PREVIEW_IMAGE_ENDPOINT, DEV_PREVIEW_IMAGE_MAX_BYTES, EMPTY_DEV_SCHEMA, EMPTY_PREVIEW_STATE, conditionsMet, isEditorFrame, normalizePreviewState };
62
+ //# sourceMappingURL=chunk-N45X7D55.js.map
63
+ //# sourceMappingURL=chunk-N45X7D55.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dev/schema-types.ts"],"names":[],"mappings":";AAyBO,IAAM,qBAAA,GAAwB;AAO9B,IAAM,oBAAA,GAAuB;AA6DpC,SAAS,gBAAgB,KAAA,EAAyB;AAChD,EAAA,MAAM,QAAQ,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAI,KAAA,CAAM,CAAC,CAAA,GAAI,KAAA;AAChD,EAAA,OAAO,KAAA,IA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AAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,sBAAsB,GAAA,EAAsC;AAC1E,EAAA,IAAI,CAAC,QAAA,CAAS,GAAG,CAAA,EAAG,OAAO,IAAA;AAC3B,EAAA,MAAM,SAAmC,KAAA,CAAM,OAAA,CAAQ,IAAI,MAAM,CAAA,GAC7D,IAAI,MAAA,CAAO,OAAA;AAAA,IAAQ,CAAC,KAAA,EAAgB,KAAA,KAClC,QAAA,CAAS,KAAK,CAAA,IAAK,OAAO,KAAA,CAAM,IAAA,KAAS,QAAA,IAAY,KAAA,CAAM,IAAA,GACvD;AAAA,MACE;AAAA,QACE,EAAA,EAAI,OAAO,KAAA,CAAM,EAAA,KAAO,QAAA,IAAY,MAAM,EAAA,GAAK,KAAA,CAAM,EAAA,GAAK,CAAA,MAAA,EAAS,KAAK,CAAA,CAAA;AAAA,QACxE,IAAA,EAAM,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,WAAW,EAAE,CAAA;AAAA,QACtC,QAAQ,QAAA,CAAS,KAAA,CAAM,MAAM,CAAA,GAAI,KAAA,CAAM,SAAS;AAAC;AACnD,QAEF;AAAC,GACP,GACA,IAAA;AACJ,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,IAAI,OAAA,KAAY,IAAA;AAAA,IACzB,UAAU,QAAA,CAAS,GAAA,CAAI,QAAQ,CAAA,GAAI,GAAA,CAAI,WAAW,EAAC;AAAA,IACnD;AAAA,GACF;AACF;AAGO,IAAM,gBAAA,GAA8B;AAAA,EACzC,UAAU,EAAC;AAAA,EACX,YAAY,EAAC;AAAA,EACb,kBAAkB,EAAC;AAAA,EACnB,mBAAmB,EAAC;AAAA,EACpB,eAAe,EAAC;AAAA,EAChB,OAAA,EAAS;AACX","file":"chunk-N45X7D55.js","sourcesContent":["/**\n * Shared, browser-safe types for the dev-mode twilight.json settings/components\n * editor. Produced (in Node) by `buildTwilightSchema` and consumed (in the\n * browser) by the dev store and `DevSettingsWidget`. Kept free of any Node or\n * React imports so both sides can share it.\n */\n\n/** How a single setting/field is rendered in the dev editor. */\nexport type DevFieldKind =\n | 'toggle'\n | 'select'\n | 'text'\n | 'textarea'\n | 'number'\n | 'image'\n | 'collection'\n | 'entities'\n | 'link'\n | 'readonly';\n\n/** What a picker can look up in the store (or fall back to samples for). */\nexport type DevLookupSource =\n 'products' | 'categories' | 'brands' | 'blog_articles' | 'blog_categories';\n\n/** How long the editor waits for its frame to answer a store lookup. */\nexport const DEV_LOOKUP_TIMEOUT_MS = 8000;\n\n/**\n * How long a lookup may keep reading further pages: well inside\n * {@link DEV_LOOKUP_TIMEOUT_MS}, so the frame answers with what it has found\n * before the editor stops waiting, and stops fetching once it has answered.\n */\nexport const DEV_LOOKUP_BUDGET_MS = 5000;\n\n/** One thing a picker found. `data` is what gets saved, shaped like the API sends it to a block. */\nexport interface DevLookupItem {\n id: string | number;\n name: string;\n image?: string;\n url?: string;\n data: Record<string, unknown>;\n}\n\nexport interface DevSchemaOption {\n label: string;\n value: string;\n}\n\n/** One twilight.json `conditions` entry: the field shows only while `id`'s value passes. */\nexport interface DevFieldCondition {\n /** The other field's id (inside a collection, without the `<collection>.` prefix). */\n id: string;\n /** `=` (also `==`) or `!=`. Any other operator is ignored, so it never hides a field. */\n operation: string;\n value: unknown;\n}\n\nexport interface DevSchemaField {\n /**\n * twilight.json entry `id` — also the key used for overrides. Inside a\n * collection, the `<collection>.` prefix is dropped (`slides.image` → `image`),\n * matching the rows the API hands a block.\n */\n id: string;\n label: string;\n kind: DevFieldKind;\n /** Default value taken from twilight.json (`null` for readonly fields; rows for a collection). */\n default: unknown;\n /** Present for `select`. */\n options?: DevSchemaOption[];\n /** For `readonly`: why it can't be edited yet (e.g. \"collection\", \"remote\"). */\n note?: string;\n /** twilight.json `description`, shown under the field. */\n description?: string;\n placeholder?: string;\n /** `number`: `minimum`/`maximum`. `collection`: `minLength`/`maxLength` (item count). */\n min?: number;\n max?: number;\n /** `collection`: the fields of one item. */\n fields?: DevSchemaField[];\n /** `collection`: what one item is called (`item_label`), e.g. \"Slide\". */\n itemLabel?: string;\n /** `entities`: which store list it picks from. */\n source?: Extract<DevLookupSource, 'products' | 'categories' | 'brands'>;\n /** `entities`: more than one (`multichoice`). */\n multiple?: boolean;\n /** `link`: the kinds of link it offers (`sources`), e.g. product, category, external. */\n linkSources?: DevSchemaOption[];\n /** twilight.json `conditions`: the field shows only while every one holds. */\n conditions?: DevFieldCondition[];\n}\n\n/** A select may hold its choice as `[{ value }]`; compare on the bare value. */\nfunction conditionScalar(value: unknown): unknown {\n const first = Array.isArray(value) ? value[0] : value;\n return first && typeof first === 'object' ? (first as { value?: unknown }).value : first;\n}\n\n/**\n * Whether a field should show: true when it has no `conditions`, or when each\n * one holds against `valueOf` (the current value of the field it names, its\n * default included). Values compare as strings, so `true` matches `\"true\"`.\n */\nexport function conditionsMet(\n field: Pick<DevSchemaField, 'conditions'>,\n valueOf: (id: string) => unknown\n): boolean {\n return (field.conditions ?? []).every(({ id, operation, value }) => {\n const equal = String(conditionScalar(valueOf(id))) === String(conditionScalar(value));\n if (operation === '=' || operation === '==') return equal;\n if (operation === '!=') return !equal;\n return true;\n });\n}\n\nexport interface DevSchemaComponent {\n /** e.g. \"home.enhanced-slider\" — the natural component key. */\n path: string;\n /** twilight.json catalog id, sent as a block's `key` like the API does. */\n key?: string;\n title: string;\n /** `title` per language when twilight.json gives `{ ar, en }`. */\n titles?: Record<string, string>;\n /** twilight.json `image`: a preview of the component, shown when adding one. */\n image?: string;\n /** twilight.json `icon`: a Salla icon class, e.g. `sicon-image`. */\n icon?: string;\n fields: DevSchemaField[];\n}\n\nexport interface DevSchema {\n /** twilight.json `name`, per language (a plain string is filed under both). */\n themeName?: Record<string, string>;\n /** Editable + readonly theme settings, in declaration order. */\n settings: DevSchemaField[];\n /** Store components with their fields. */\n components: DevSchemaComponent[];\n /** `{ [settingId]: default }` for every non-readonly setting. */\n settingsDefaults: Record<string, unknown>;\n /** `{ [componentPath]: { [fieldId]: default } }`. */\n componentDefaults: Record<string, Record<string, unknown>>;\n /**\n * `{ [componentPath]: data }`: everything a newly added block starts with,\n * readonly fields included, shaped the way the API delivers block data\n * (collection rows lose their `<collection>.` key prefix). Optional so a\n * schema from an older engine build still type-checks.\n */\n blockDefaults?: Record<string, Record<string, unknown>>;\n /** The saved preview state (`twilight.preview.json`), `null` when there is none. */\n preview?: DevPreviewState | null;\n}\n\n/** One home block in a dev-owned layout. */\nexport interface DevPreviewBlock {\n /** Stable id for React keys and edits; unrelated to the API. */\n id: string;\n /** Home loader spelling, without the `home.` prefix (e.g. \"main-links\"). */\n path: string;\n /** The block's data, spread onto `{ path }` when it renders. */\n fields: Record<string, unknown>;\n}\n\n/**\n * Everything the dev editor saves, persisted to `twilight.preview.json` by the\n * dev server so the server render and every tab start from the same values.\n */\nexport interface DevPreviewState {\n /** Master switch: when false the theme uses the real store's values. */\n enabled: boolean;\n /** Sparse `{ [settingId]: value }` overrides for theme settings. */\n settings: Record<string, unknown>;\n /** The home page's blocks, in order. `null` renders the store's own blocks. */\n layout: DevPreviewBlock[] | null;\n}\n\n/** Dev-server page that hosts the theme editor. */\nexport const DEV_EDITOR_PATH = '/__twilight/editor';\n\n/** Marks the iframe the editor frames the storefront in. */\nexport const DEV_EDITOR_FRAME_ATTR = 'data-twilight-editor';\n\n/** True inside the editor's frame, where the storefront hides its own dev button. */\nexport function isEditorFrame(): boolean {\n if (typeof window === 'undefined') return false;\n try {\n return window.frameElement?.hasAttribute(DEV_EDITOR_FRAME_ATTR) ?? false;\n } catch {\n return false; // Framed by another origin: not our editor.\n }\n}\n\n/** Dev-server endpoint the editor saves through. */\nexport const DEV_PREVIEW_ENDPOINT = '/__twilight/preview';\n\n/**\n * Where a picked image goes: the dev server keeps it in `twilight-preview-assets/`\n * (gitignored, next to twilight.json) and serves it back from under this path,\n * so the saved state holds a short URL rather than the image itself.\n */\nexport const DEV_PREVIEW_IMAGE_ENDPOINT = `${DEV_PREVIEW_ENDPOINT}/image`;\nexport const DEV_PREVIEW_IMAGE_MAX_BYTES = 5 * 1024 * 1024;\n\n/** Dev-server event that hands a save to the other open tabs. */\nexport const DEV_PREVIEW_EVENT = 'twilight:preview';\n\n/** Where `virtual:twilight/schema` puts the saved state before the app renders. */\nexport const DEV_PREVIEW_GLOBAL = '__twilightDevPreview__';\n\nexport const EMPTY_PREVIEW_STATE: DevPreviewState = { enabled: false, settings: {}, layout: null };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Coerce anything (a hand-edited file, a request body) into a valid state, or\n * `null` when it isn't one at all. Blocks without a path are dropped and\n * missing ids are filled, so a bad entry can't break the home page.\n */\nexport function normalizePreviewState(raw: unknown): DevPreviewState | null {\n if (!isRecord(raw)) return null;\n const layout: DevPreviewBlock[] | null = Array.isArray(raw.layout)\n ? raw.layout.flatMap((entry: unknown, index) =>\n isRecord(entry) && typeof entry.path === 'string' && entry.path\n ? [\n {\n id: typeof entry.id === 'string' && entry.id ? entry.id : `block-${index}`,\n path: entry.path.replace(/^home\\./, ''),\n fields: isRecord(entry.fields) ? entry.fields : {},\n },\n ]\n : []\n )\n : null;\n return {\n enabled: raw.enabled === true,\n settings: isRecord(raw.settings) ? raw.settings : {},\n layout,\n };\n}\n\n/** The shape the vite plugin ships when there is no schema (prod / missing file). */\nexport const EMPTY_DEV_SCHEMA: DevSchema = {\n settings: [],\n components: [],\n settingsDefaults: {},\n componentDefaults: {},\n blockDefaults: {},\n preview: null,\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { filesCdn, cdn } from './chunk-QGOPTVV5.js';
1
+ import { filesCdn, cdn } from './chunk-6EQ7G3SZ.js';
2
2
  import { storeTranslationsQueryKey, translationsQueryKey, composeMessages, isPlainObject } from './chunk-N2S25NXP.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
@@ -126,5 +126,5 @@ var translations = {
126
126
  };
127
127
 
128
128
  export { commonTranslationsPath, storeTranslationsPath, translations };
129
- //# sourceMappingURL=chunk-OH2L4U2C.js.map
130
- //# sourceMappingURL=chunk-OH2L4U2C.js.map
129
+ //# sourceMappingURL=chunk-NZRJOAA7.js.map
130
+ //# sourceMappingURL=chunk-NZRJOAA7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;AACtC;AAWO,SAAS,qBAAA,CAAsB,SAA0B,MAAA,EAAwB;AACtF,EAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,CAAA;AAC1C;AAUA,eAAe,eACb,IAAA,EACA,EAAE,aAAa,KAAA,EAAM,GAA8B,EAAC,EAC1B;AAE1B,EAAA,MAAM,UAAA,GAAa,CAAC,MAAA,EAAgB,KAAA,KAA0B;AAC5D,IAAA,IAAI,UAAA,EAAY,MAAM,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,EAAI,EAAE,KAAA,EAAO,CAAA;AAC9E,IAAA,OAAA,CAAQ,IAAA,CAAK,gBAAA,EAAkB,MAAA,EAAQ,IAAA,EAAM,SAAS,EAAE,CAAA;AACxD,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,MAAM,QAAA,CAAS,GAAA,CAAI,IAAA,EAAM,EAAE,eAAA,EAAiB,KAAA,EAAO,OAAA,EAAS,GAAA,EAAM,CAAA;AACnF,IAAA,IAAI,QAAA,CAAS,MAAA,KAAW,GAAA,EAAK,OAAO,IAAA;AAEpC,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,OAAO,UAAA,CAAW,CAAA,SAAA,EAAY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AAM,CAAA,MAAA,CAAQ,GAAG,IAAA,EAA+B;AAAA,EAC/D,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,QAAA,EAAU,OAAO,OAAA,EAA0B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQzC,cAAA,CAAe,sBAAsB,OAAA,EAAS,MAAM,GAAG,EAAE,UAAA,EAAY,MAAM;AAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc7E,KAAA,EAAO,CACL,MAAA,EACA,SAAA,EACA,WAC+B,eAAA,CAAgB,MAAA,EAAQ,SAAA,EAAW,MAAM,CAAA,IAAK,IAAA;AAAA,EAE/E,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBP,QAAA,EAAU,CAAC,MAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,qBAAqB,MAAM,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,YAAA,CAAa,GAAA,CAAI,MAAM;AAAA,KACvC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWH,OAAA,EAAS,CAAC,OAAA,EAA0B,MAAA,KAClC,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,yBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAAA,MACnD,OAAA,EAAS,MAAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-OH2L4U2C.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;A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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc7E,KAAA,EAAO,CACL,MAAA,EACA,SAAA,EACA,WAC+B,eAAA,CAAgB,MAAA,EAAQ,SAAA,EAAW,MAAM,CAAA,IAAK,IAAA;AAAA,EAE/E,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBP,QAAA,EAAU,CAAC,MAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,qBAAqB,MAAM,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,YAAA,CAAa,GAAA,CAAI,MAAM;AAAA,KACvC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWH,OAAA,EAAS,CAAC,OAAA,EAA0B,MAAA,KAClC,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,yBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAAA,MACnD,OAAA,EAAS,MAAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-NZRJOAA7.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow, orUnauthorized } from './chunk-JTOVO3ZU.js';
2
- import { api } from './chunk-QGOPTVV5.js';
1
+ import { orThrow, orUnauthorized } from './chunk-RWBTMHLR.js';
2
+ import { api } from './chunk-6EQ7G3SZ.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var order = {
@@ -78,5 +78,5 @@ var order = {
78
78
  };
79
79
 
80
80
  export { order };
81
- //# sourceMappingURL=chunk-TEOVJ6WU.js.map
82
- //# sourceMappingURL=chunk-TEOVJ6WU.js.map
81
+ //# sourceMappingURL=chunk-O7B5JL6H.js.map
82
+ //# sourceMappingURL=chunk-O7B5JL6H.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/order.ts"],"names":[],"mappings":";;;;AAoDO,IAAM,KAAA,GAAQ;AAAA,EACnB,IAA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AC,CAAA;AAAA,EAEjC,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,CAAC,MAAA,KACL,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,MAAA,EAAQ,MAAM,CAAA;AAAA,MACnC,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,KAAA,CAAM,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC1D,CAAA;AAAA,IACH,IAAA,EAAM,CAAC,EAAA,KACL,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,QAAA,EAAU,EAAE,CAAA;AAAA,MACjC,OAAA,EAAS,MAAM,KAAA,CAAM,IAAA,CAAK,EAAE;AAAA,KAC7B,CAAA;AAAA,IACH,SAAA,EAAW,CAAC,OAAA,KACV,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,WAAA,EAAa,OAAO,CAAA;AAAA,MACzC,OAAA,EAAS,MAAM,KAAA,CAAM,SAAA,CAAU,OAAO;AAAA,KACvC,CAAA;AAAA,IACH,OAAA,EAAS,CAAC,OAAA,KACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,SAAA,EAAW,OAAO,CAAA;AAAA,MACvC,OAAA,EAAS,MAAM,KAAA,CAAM,OAAA,CAAQ,OAAO;AAAA,KACrC,CAAA;AAAA,IACH,QAAA,EAAU,CAAC,OAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,UAAA,EAAY,OAAO,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,OAAO;AAAA,KACtC;AAAA;AAEP","file":"chunk-TEOVJ6WU.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type {\n Order,\n OrderListItem,\n OrderShipmentItem,\n OrderRatingItem,\n} from '../routes/account/types';\nimport type { Pagination } from './types';\nimport { orThrow, orUnauthorized } from '../providers/NavigationProvider';\n\nexport interface OrderDetailResponse {\n order: Order;\n}\n\n/**\n * The order in the shape the Twilight web components read (`salla-order-details`,\n * `salla-order-totals-card`) and the Twig themes render: the API answers `orders/{id}` this\n * way when the request does not say it comes from a React theme (`s-theme-type`).\n */\nexport interface TwilightOrder {\n items: Array<{\n name: string;\n quantity: number;\n product?: { id: number; url?: string; type?: string; image?: { url?: string } };\n options?: unknown[];\n }>;\n [key: string]: unknown;\n}\n\nexport interface CheckoutThankYouData {\n thank_you_title?: string;\n messages?: string[];\n share_message?: string;\n short_share_message?: string;\n}\n\nexport interface OrdersListResponse {\n data: OrderListItem[];\n cursor?: Pagination;\n}\n\nexport interface OrdersListParams {\n page?: number;\n cursor?: string | null;\n status?: string;\n feedback_status?: string;\n /** When set, the list payload includes each order's `items[]` (`with_items=1`). */\n with_items?: boolean | number;\n signal?: AbortSignal;\n}\n\nexport const order = {\n list: async (params?: OrdersListParams): Promise<OrdersListResponse> => {\n const {\n page,\n cursor,\n status,\n feedback_status: feedbackStatus,\n with_items: withItems,\n signal,\n } = params ?? {};\n\n const searchParams = new URLSearchParams();\n if (page !== undefined) searchParams.set('page', String(page));\n if (cursor) searchParams.set('cursor', cursor);\n if (status) searchParams.set('status', status);\n if (feedbackStatus) searchParams.set('feedback_status', feedbackStatus);\n if (withItems) searchParams.set('with_items', '1');\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`orders?${searchParams.toString()}`, options as any)\n .json<{ data: OrderListItem[] | null; cursor?: Pagination }>();\n\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n find: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n findForComponents: async (id: string): Promise<TwilightOrder> => {\n const response = await api\n .get(`orders/${id}`, {\n hooks: {\n // Runs after the client's own hook, which marks every request as from a React theme.\n beforeRequest: [({ request }) => request.headers.delete('s-theme-type')],\n },\n })\n .json<{ data: TwilightOrder }>();\n return response.data;\n },\n\n shipments: async (orderId: string): Promise<OrderShipmentItem[]> => {\n const response = await api\n .get(`orders/${orderId}/shipments`)\n .json<{ data: OrderShipmentItem[] }>();\n return response.data ?? [];\n },\n\n ratings: async (orderId: string): Promise<OrderRatingItem[]> => {\n const response = await api.get(`orders/${orderId}/ratings`).json<{ data: OrderRatingItem[] }>();\n return response.data ?? [];\n },\n\n findOrThrow: (id: string): Promise<OrderDetailResponse> =>\n orThrow(orUnauthorized(order.find(id))),\n\n thankYou: async (orderId: string): Promise<CheckoutThankYouData> => {\n const { data } = await api\n .get(`checkout/thank-you/${orderId}`)\n .json<{ data: CheckoutThankYouData }>();\n return data;\n },\n\n thankYouOrThrow: (orderId: string): Promise<CheckoutThankYouData> =>\n orThrow(order.thankYou(orderId)),\n\n queries: {\n list: (params?: Omit<OrdersListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['orders', 'list', params],\n queryFn: ({ signal }) => order.list({ ...params, signal }),\n }),\n find: (id: string) =>\n queryOptions({\n queryKey: ['orders', 'detail', id],\n queryFn: () => order.find(id),\n }),\n shipments: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'shipments', orderId],\n queryFn: () => order.shipments(orderId),\n }),\n ratings: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'ratings', orderId],\n queryFn: () => order.ratings(orderId),\n }),\n thankYou: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'thankYou', orderId],\n queryFn: () => order.thankYou(orderId),\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/order.ts"],"names":[],"mappings":";;;;AAoDO,IAAM,KAAA,GAAQ;AAAA,EACnB,IAAA,EAAM,OAAO,MAAA,KAA2D;AACtE,IAAA,MAAM;AAAA,MACJ,IAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA,EAAiB,cAAA;AAAA,MACjB,UAAA,EAAY,SAAA;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,MACnC,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,KAAA,CAAM,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC1D,CAAA;AAAA,IACH,IAAA,EAAM,CAAC,EAAA,KACL,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,QAAA,EAAU,EAAE,CAAA;AAAA,MACjC,OAAA,EAAS,MAAM,KAAA,CAAM,IAAA,CAAK,EAAE;AAAA,KAC7B,CAAA;AAAA,IACH,SAAA,EAAW,CAAC,OAAA,KACV,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,WAAA,EAAa,OAAO,CAAA;AAAA,MACzC,OAAA,EAAS,MAAM,KAAA,CAAM,SAAA,CAAU,OAAO;AAAA,KACvC,CAAA;AAAA,IACH,OAAA,EAAS,CAAC,OAAA,KACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,SAAA,EAAW,OAAO,CAAA;AAAA,MACvC,OAAA,EAAS,MAAM,KAAA,CAAM,OAAA,CAAQ,OAAO;AAAA,KACrC,CAAA;AAAA,IACH,QAAA,EAAU,CAAC,OAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,UAAA,EAAY,OAAO,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,OAAO;AAAA,KACtC;AAAA;AAEP","file":"chunk-O7B5JL6H.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type {\n Order,\n OrderListItem,\n OrderShipmentItem,\n OrderRatingItem,\n} from '../routes/account/types';\nimport type { Pagination } from './types';\nimport { orThrow, orUnauthorized } from '../providers/NavigationProvider';\n\nexport interface OrderDetailResponse {\n order: Order;\n}\n\n/**\n * The order in the shape the Twilight web components read (`salla-order-details`,\n * `salla-order-totals-card`) and the Twig themes render: the API answers `orders/{id}` this\n * way when the request does not say it comes from a React theme (`s-theme-type`).\n */\nexport interface TwilightOrder {\n items: Array<{\n name: string;\n quantity: number;\n product?: { id: number; url?: string; type?: string; image?: { url?: string } };\n options?: unknown[];\n }>;\n [key: string]: unknown;\n}\n\nexport interface CheckoutThankYouData {\n thank_you_title?: string;\n messages?: string[];\n share_message?: string;\n short_share_message?: string;\n}\n\nexport interface OrdersListResponse {\n data: OrderListItem[];\n cursor?: Pagination;\n}\n\nexport interface OrdersListParams {\n page?: number;\n cursor?: string | null;\n status?: string;\n feedback_status?: string;\n /** When set, the list payload includes each order's `items[]` (`with_items=1`). */\n with_items?: boolean | number;\n signal?: AbortSignal;\n}\n\nexport const order = {\n list: async (params?: OrdersListParams): Promise<OrdersListResponse> => {\n const {\n page,\n cursor,\n status,\n feedback_status: feedbackStatus,\n with_items: withItems,\n signal,\n } = params ?? {};\n\n const searchParams = new URLSearchParams();\n if (page !== undefined) searchParams.set('page', String(page));\n if (cursor) searchParams.set('cursor', cursor);\n if (status) searchParams.set('status', status);\n if (feedbackStatus) searchParams.set('feedback_status', feedbackStatus);\n if (withItems) searchParams.set('with_items', '1');\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`orders?${searchParams.toString()}`, options as any)\n .json<{ data: OrderListItem[] | null; cursor?: Pagination }>();\n\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n find: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n findForComponents: async (id: string): Promise<TwilightOrder> => {\n const response = await api\n .get(`orders/${id}`, {\n hooks: {\n // Runs after the client's own hook, which marks every request as from a React theme.\n beforeRequest: [({ request }) => request.headers.delete('s-theme-type')],\n },\n })\n .json<{ data: TwilightOrder }>();\n return response.data;\n },\n\n shipments: async (orderId: string): Promise<OrderShipmentItem[]> => {\n const response = await api\n .get(`orders/${orderId}/shipments`)\n .json<{ data: OrderShipmentItem[] }>();\n return response.data ?? [];\n },\n\n ratings: async (orderId: string): Promise<OrderRatingItem[]> => {\n const response = await api.get(`orders/${orderId}/ratings`).json<{ data: OrderRatingItem[] }>();\n return response.data ?? [];\n },\n\n findOrThrow: (id: string): Promise<OrderDetailResponse> =>\n orThrow(orUnauthorized(order.find(id))),\n\n thankYou: async (orderId: string): Promise<CheckoutThankYouData> => {\n const { data } = await api\n .get(`checkout/thank-you/${orderId}`)\n .json<{ data: CheckoutThankYouData }>();\n return data;\n },\n\n thankYouOrThrow: (orderId: string): Promise<CheckoutThankYouData> =>\n orThrow(order.thankYou(orderId)),\n\n queries: {\n list: (params?: Omit<OrdersListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['orders', 'list', params],\n queryFn: ({ signal }) => order.list({ ...params, signal }),\n }),\n find: (id: string) =>\n queryOptions({\n queryKey: ['orders', 'detail', id],\n queryFn: () => order.find(id),\n }),\n shipments: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'shipments', orderId],\n queryFn: () => order.shipments(orderId),\n }),\n ratings: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'ratings', orderId],\n queryFn: () => order.ratings(orderId),\n }),\n thankYou: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'thankYou', orderId],\n queryFn: () => order.thankYou(orderId),\n }),\n },\n};\n"]}
@@ -1,5 +1,5 @@
1
- import { rememberProductPreview } from './chunk-CEYT3JER.js';
2
- import { getActiveScope, api } from './chunk-QGOPTVV5.js';
1
+ import { rememberProductPreview } from './chunk-56T47K7P.js';
2
+ import { getActiveScope, api } from './chunk-6EQ7G3SZ.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var wishlist = {
@@ -31,5 +31,5 @@ var wishlist = {
31
31
  };
32
32
 
33
33
  export { wishlist };
34
- //# sourceMappingURL=chunk-UURVAJ42.js.map
35
- //# sourceMappingURL=chunk-UURVAJ42.js.map
34
+ //# sourceMappingURL=chunk-OZP2FID7.js.map
35
+ //# s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,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,UAAA,EAAY,MAAA,EAAQ,QAAQ,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AAAA,MAClE,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,QAAA,CAAS,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC7D;AAAA;AAEP","file":"chunk-UURVAJ42.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport {\n rememberProductPreview,\n type ProductsListResult,\n type ProductsListResponse,\n} from './product';\n\nexport interface WishlistListParams {\n page?: number;\n perPage?: number;\n filterable?: boolean;\n signal?: AbortSignal;\n}\n\n/**\n * Wishlist API — page-based pagination only.\n * Kept separate from product.list to avoid mixing cursor and page pagination strategies.\n */\nexport const wishlist = {\n list: async (params: WishlistListParams = {}): Promise<ProductsListResult> => {\n const { page = 1, perPage = 15, filterable, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('source', 'wishlist');\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n const items = response.data ?? [];\n for (const item of items) rememberProductPreview(item);\n\n return {\n items,\n next: response.cursor?.next ?? null,\n };\n },\n\n queries: {\n list: (params: Omit<WishlistListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['wishlist', 'list', params, { scope: getActiveScope() }],\n queryFn: ({ signal }) => wishlist.list({ ...params, signal }),\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/wishlist.ts"],"names":[],"mappings":";;;;AAmBO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,MAAA,GAA6B,EAAC,KAAmC;AAC5E,IAAA,MA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AK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC7D;AAAA;AAEP","file":"chunk-OZP2FID7.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport {\n rememberProductPreview,\n type ProductsListResult,\n type ProductsListResponse,\n} from './product';\n\nexport interface WishlistListParams {\n page?: number;\n perPage?: number;\n filterable?: boolean;\n signal?: AbortSignal;\n}\n\n/**\n * Wishlist API — page-based pagination only.\n * Kept separate from product.list to avoid mixing cursor and page pagination strategies.\n */\nexport const wishlist = {\n list: async (params: WishlistListParams = {}): Promise<ProductsListResult> => {\n const { page = 1, perPage = 15, filterable, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('source', 'wishlist');\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n const items = response.data ?? [];\n for (const item of items) rememberProductPreview(item);\n\n return {\n items,\n next: response.cursor?.next ?? null,\n };\n },\n\n queries: {\n list: (params: Omit<WishlistListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['wishlist', 'list', params, { scope: getActiveScope() }],\n queryFn: ({ signal }) => wishlist.list({ ...params, signal }),\n }),\n },\n};\n"]}
@@ -1,6 +1,6 @@
1
- import { orThrow } from './chunk-JTOVO3ZU.js';
2
- import { api } from './chunk-QGOPTVV5.js';
3
- import { getSallaSDK } from './chunk-HSWRYXC7.js';
1
+ import { orThrow } from './chunk-RWBTMHLR.js';
2
+ import { api } from './chunk-6EQ7G3SZ.js';
3
+ import { getSallaSDK } from './chunk-2FKZAAV7.js';
4
4
  import { queryOptions } from '@tanstack/react-query';
5
5
 
6
6
  function normalizeCartResponse(data) {
@@ -44,5 +44,5 @@ var cart = {
44
44
  };
45
45
 
46
46
  export { cart };
47
- //# sourceMappingURL=chunk-HCA2TE4G.js.map
48
- //# sourceMappingURL=chunk-HCA2TE4G.js.map
47
+ //# sourceMappingURL=chunk-PGUKRWOY.js.map
48
+ //# sourceMappingURL=chunk-PGUKRWOY.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/cart.ts"],"names":[],"mappings":";;;;;AAaA,SAAS,sBAAsB,IAAA,EAAoC;AACjE,EAAA,IAAI,CAAC,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACvB,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CAAK,IAAA;AAAA,IACR,OAAA,EAAS,KAAK,OAAA,IAAW,IAAA;AAAA;AAAA,IAEzB,IAAA,EAAM,IAAA,CAAK,IAAA,IAAQ,IAAA,CAAK,KAAK,IAAA,IAAQ;AAAA,GACvC;AACF;AAEO,IAAM,IAAA,GAAO;AAAA,EAClB,GAAA,EAAK,OAAO,MAAA,KAAyC;AACnD,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAAgC;AACjF,IAAA,OAAO,sBAAsB,IAAI,CAAA;AAAA,EACnC,CAAA;AAAA,EAEA,YAAY,CAAC,MAAA,KAAyC,QAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAC,CAAA;AAAA;AAAA,EAG9E,cAAc,YAAoC;AAChD,IAAA,MAAM,QAAQ,WAAA,EAAY;AAC1B,IAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AAEnB,IAAA,MAAM,KAAA,CAAM,OAAA,EAAQ,CAAE,KAAA,CAAM,MAAM,MAAS,CAAA;AAC3C,IAAA,OAAO,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,gBAAA,EAAiB;AAAA,EACzC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,MAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,MACzB,OAAA,EAAS,MAAM,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA;AAAA;AAAA,MAE9B,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,IACH,SAAA,EAAW,MACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,YAAA,EAAa;AAAA;AAAA,MAEjC,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT;AAAA;AAEP","file":"chunk-HCA2TE4G.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Cart } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getSallaSDK } from '../utils/sdk-helpers';\n\nexport interface CartApiResponse {\n /** Absent once the cart was turned into an order (the body then carries a top-level `redirect`). */\n cart?: Omit<Cart, 'loyalty'>;\n loyalty?: Cart['loyalty'];\n gift?: Cart['gift'];\n}\n\nfunction normalizeCartResponse(data: CartApiResponse): Cart | null {\n if (!data.cart) return null;\n return {\n ...data.cart,\n loyalty: data.loyalty ?? null,\n // The API sends `gift` inside `cart`.\n gift: data.gift ?? data.cart.gift ?? null,\n } as Cart;\n}\n\nexport const cart = {\n get: async (cartId: number): Promise<Cart | null> => {\n const { data } = await api.get(`cart/${cartId}`).json<{ data: CartApiResponse }>();\n return normalizeCartResponse(data);\n },\n\n getOrThrow: (cartId: number): Promise<Cart | null> => orThrow(cart.get(cartId)),\n\n /** The visitor's cart id, which only the Salla SDK knows; `null` outside the browser. */\n getCurrentId: async (): Promise<number | null> => {\n const salla = getSallaSDK();\n if (!salla) return null;\n // The app bundle can run before the SDK module, when `salla` is still the head stub.\n await salla.onReady().catch(() => undefined);\n return salla.cart.api.getCurrentCartId();\n },\n\n queries: {\n detail: (cartId: number) =>\n queryOptions({\n queryKey: ['cart', cartId],\n queryFn: () => cart.get(cartId),\n // The SDK changes the cart from any page, so a cached copy is never safe to show.\n staleTime: 0,\n gcTime: 0,\n }),\n currentId: () =>\n queryOptions({\n queryKey: ['cart', 'current-id'],\n queryFn: () => cart.getCurrentId(),\n // Completing an order starts a new cart, so an earlier id is never reused.\n staleTime: 0,\n gcTime: 0,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/cart.ts"],"names":[],"mappings":";;;;;AAaA,SAAS,sBAAsB,IAAA,EAAoC;AACjE,EAAA,IAAI,CAAC,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACvB,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CAAK,IAAA;AAAA,IACR,OAAA,EAAS,KAAK,OAAA,IAAW,IAAA;AAAA;AAAA,IAEzB,IAAA,EAAM,IAAA,CAAK,IAAA,IAAQ,IAAA,CAAK,KAAK,IAAA,IAAQ;AAAA,GACvC;AACF;AAEO,IAAM,IAAA,GAAO;AAAA,EAClB,GAAA,EAAK,OAAO,MAAA,KAAyC;AACnD,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAAgC;AACjF,IAAA,OAAO,sBAAsB,IAAI,CAAA;AAAA,EACnC,CAAA;AAAA,EAEA,YAAY,CAAC,MAAA,KAAyC,QAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAC,CAAA;AAAA;AAAA,EAG9E,cAAc,YAAoC;AAChD,IAAA,MAAM,QAAQ,WAAA,EAAY;AAC1B,IAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AAEnB,IAAA,MAAM,KAAA,CAAM,OAAA,EAAQ,CAAE,KAAA,CAAM,MAAM,MAAS,CAAA;AAC3C,IAAA,OAAO,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,gBAAA,EAAiB;AAAA,EACzC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,MAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,MACzB,OAAA,EAAS,MAAM,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA;AAAA;AAAA,MAE9B,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,IACH,SAAA,EAAW,MACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,YAAA,EAAa;AAAA;AAAA,MAEjC,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT;AAAA;AAEP","file":"chunk-PGUKRWOY.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Cart } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getSallaSDK } from '../utils/sdk-helpers';\n\nexport interface CartApiResponse {\n /** Absent once the cart was turned into an order (the body then carries a top-level `redirect`). */\n cart?: Omit<Cart, 'loyalty'>;\n loyalty?: Cart['loyalty'];\n gift?: Cart['gift'];\n}\n\nfunction normalizeCartResponse(data: CartApiResponse): Cart | null {\n if (!data.cart) return null;\n return {\n ...data.cart,\n loyalty: data.loyalty ?? null,\n // The API sends `gift` inside `cart`.\n gift: data.gift ?? data.cart.gift ?? null,\n } as Cart;\n}\n\nexport const cart = {\n get: async (cartId: number): Promise<Cart | null> => {\n const { data } = await api.get(`cart/${cartId}`).json<{ data: CartApiResponse }>();\n return normalizeCartResponse(data);\n },\n\n getOrThrow: (cartId: number): Promise<Cart | null> => orThrow(cart.get(cartId)),\n\n /** The visitor's cart id, which only the Salla SDK knows; `null` outside the browser. */\n getCurrentId: async (): Promise<number | null> => {\n const salla = getSallaSDK();\n if (!salla) return null;\n // The app bundle can run before the SDK module, when `salla` is still the head stub.\n await salla.onReady().catch(() => undefined);\n return salla.cart.api.getCurrentCartId();\n },\n\n queries: {\n detail: (cartId: number) =>\n queryOptions({\n queryKey: ['cart', cartId],\n queryFn: () => cart.get(cartId),\n // The SDK changes the cart from any page, so a cached copy is never safe to show.\n staleTime: 0,\n gcTime: 0,\n }),\n currentId: () =>\n queryOptions({\n queryKey: ['cart', 'current-id'],\n queryFn: () => cart.getCurrentId(),\n // Completing an order starts a new cart, so an earlier id is never reused.\n staleTime: 0,\n gcTime: 0,\n }),\n },\n};\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow } from './chunk-JTOVO3ZU.js';
2
- import { getAuthToken, api } from './chunk-QGOPTVV5.js';
1
+ import { orThrow } from './chunk-RWBTMHLR.js';
2
+ import { getAuthToken, api } from './chunk-6EQ7G3SZ.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var loyalty = {
@@ -29,5 +29,5 @@ var loyalty = {
29
29
  };
30
30
 
31
31
  export { loyalty };
32
- //# sourceMappingURL=chunk-3MIFT4VQ.js.map
33
- //# sourceMappingURL=chunk-3MIFT4VQ.js.map
32
+ //# sourceMappingURL=chunk-Q62YEBIA.js.map
33
+ //# sourceMappingURL=chunk-Q62YEBIA.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/loyalty.ts"],"names":[],"mappings":";;;;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,KAAK,YAA8B;AACjC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,SAAS,EAAE,IAAA,EAAwB;AAClE,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,UAAA,EAAY,MAAwB,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,EAEzD,kBAAkB,YAA6B;AAC7C,IAAA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,gBAAgB,EAAE,IAAA,EAA2B;AAC5E,IAAA,OAAO,QAAA,CAAS,OAAA;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,MACpB,OAAA,EAAS,MAAM,OAAA,CAAQ,GAAA;AAAI,KAC5B,CAAA;AAAA,IACH,MAAA,EAAQ,MACN,YAAA,CAA4B;AAAA,MAC1B,QAAA,EAAU,CAAC,SAAA,EAAW,QAAQ,CAAA;AAAA,MAC9B,OAAA,EAAS,MAAM,OAAA,CAAQ,gBAAA,EAAiB;AAAA;AAAA;AAAA,MAGxC,OAAA,EAAS,CAAC,CAAC,YAAA,EAAa;AAAA,MACxB,SAAA,EAAW;AAAA,KACZ;AAAA;AAEP","file":"chunk-3MIFT4VQ.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getAuthToken } from './client';\nimport type { Loyalty, PointBalanceResponse } from '../routes/loyalty/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const loyalty = {\n get: async (): Promise<Loyalty> => {\n const { data } = await api.get('loyalty').json<{ data: Loyalty }>();\n return data;\n },\n\n getOrThrow: (): Promise<Loyalty> => orThrow(loyalty.get()),\n\n getPointsBalance: async (): Promise<number> => {\n const response = await api.get('balance/points').json<PointBalanceResponse>();\n return response.balance;\n },\n\n queries: {\n detail: () =>\n queryOptions({\n queryKey: ['loyalty'],\n queryFn: () => loyalty.get(),\n }),\n points: () =>\n queryOptions<number | null>({\n queryKey: ['loyalty', 'points'],\n queryFn: () => loyalty.getPointsBalance(),\n // Points are customer-scoped; skip for guests (no token) — the request would\n // otherwise 400 with `token_not_provided`.\n enabled: !!getAuthToken(),\n staleTime: 30_000,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/loyalty.ts"],"names":[],"mappings":";;;;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,KAAK,YAA8B;AACjC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,SAAS,EAAE,IAAA,EAAwB;AAClE,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,UAAA,EAAY,MAAwB,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,EAEzD,kBAAkB,YAA6B;AAC7C,IAAA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,gBAAgB,EAAE,IAAA,EAA2B;AAC5E,IAAA,OAAO,QAAA,CAAS,OAAA;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,MACpB,OAAA,EAAS,MAAM,OAAA,CAAQ,GAAA;AAAI,KAC5B,CAAA;AAAA,IACH,MAAA,EAAQ,MACN,YAAA,CAA4B;AAAA,MAC1B,QAAA,EAAU,CAAC,SAAA,EAAW,QAAQ,CAAA;AAAA,MAC9B,OAAA,EAAS,MAAM,OAAA,CAAQ,gBAAA,EAAiB;AAAA;AAAA;AAAA,MAGxC,OAAA,EAAS,CAAC,CAAC,YAAA,EAAa;AAAA,MACxB,SAAA,EAAW;AAAA,KACZ;AAAA;AAEP","file":"chunk-Q62YEBIA.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getAuthToken } from './client';\nimport type { Loyalty, PointBalanceResponse } from '../routes/loyalty/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const loyalty = {\n get: async (): Promise<Loyalty> => {\n const { data } = await api.get('loyalty').json<{ data: Loyalty }>();\n return data;\n },\n\n getOrThrow: (): Promise<Loyalty> => orThrow(loyalty.get()),\n\n getPointsBalance: async (): Promise<number> => {\n const response = await api.get('balance/points').json<PointBalanceResponse>();\n return response.balance;\n },\n\n queries: {\n detail: () =>\n queryOptions({\n queryKey: ['loyalty'],\n queryFn: () => loyalty.get(),\n }),\n points: () =>\n queryOptions<number | null>({\n queryKey: ['loyalty', 'points'],\n queryFn: () => loyalty.getPointsBalance(),\n // Points are customer-scoped; skip for guests (no token) — the request would\n // otherwise 400 with `token_not_provided`.\n enabled: !!getAuthToken(),\n staleTime: 30_000,\n }),\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-QGOPTVV5.js';
1
+ import { api } from './chunk-6EQ7G3SZ.js';
2
2
  import { getTwilightContext } from './chunk-N2S25NXP.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
@@ -23,5 +23,5 @@ var menu = {
23
23
  };
24
24
 
25
25
  export { menu };
26
- //# sourceMappingURL=chunk-6DMNJPLW.js.map
27
- //# sourceMappingURL=chunk-6DMNJPLW.js.map
26
+ //# sourceMappingURL=chunk-QS4EDTEX.js.map
27
+ //# sourceMappingURL=chunk-QS4EDTEX.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/menu.ts"],"names":[],"mappings":";;;;AAKO,IAAM,IAAA,GAAO;AAAA,EAClB,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,UAAU,CAAC,OAAA,EAAS,QAAA,EAAU,kBAAA,GAAqB,MAAM,CAAA;AAAA,MACzD,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,EAAO;AAAA,MAC3B,SAAA,EAAW,IAAI,EAAA,GAAK;AAAA,KACrB;AAAA;AAEP","file":"chunk-6DMNJPLW.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport { getTwilightContext } from '../twilight/context';\nimport type { MenuItem } from '../types';\n\nexport const menu = {\n header: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/header?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n footer: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/footer?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n queries: {\n header: () =>\n queryOptions({\n queryKey: ['menus', 'header', getTwilightContext().locale],\n queryFn: () => menu.header(),\n staleTime: 5 * 60 * 1000,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/menu.ts"],"names":[],"mappings":";;;;AAKO,IAAM,IAAA,GAAO;AAAA,EAClB,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,UAAU,CAAC,OAAA,EAAS,QAAA,EAAU,kBAAA,GAAqB,MAAM,CAAA;AAAA,MACzD,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,EAAO;AAAA,MAC3B,SAAA,EAAW,IAAI,EAAA,GAAK;AAAA,KACrB;AAAA;AAEP","file":"chunk-QS4EDTEX.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport { getTwilightContext } from '../twilight/context';\nimport type { MenuItem } from '../types';\n\nexport const menu = {\n header: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/header?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n footer: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/footer?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n queries: {\n header: () =>\n queryOptions({\n queryKey: ['menus', 'header', getTwilightContext().locale],\n queryFn: () => menu.header(),\n staleTime: 5 * 60 * 1000,\n }),\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { onSallaEvent } from './chunk-HSWRYXC7.js';
1
+ import { onSallaEvent } from './chunk-2FKZAAV7.js';
2
2
  import { useState, useCallback, useEffect } from 'react';
3
3
 
4
4
  function useComments() {
@@ -16,5 +16,5 @@ function useComments() {
16
16
  }
17
17
 
18
18
  export { useComments };
19
- //# sourceMappingURL=chunk-SAGXF3MU.js.map
20
- //# sourceMappingURL=chunk-SAGXF3MU.js.map
19
+ //# sourceMappingURL=chunk-QZEQOVA5.js.map
20
+ //# sourceMappingURL=chunk-QZEQOVA5.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useComments.ts"],"names":[],"mappings":";;;AAuCO,SAAS,WAAA,GAAiC;AAC/C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,IACnC,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,kBAAkB,kBAAkB,CAAA;AAAA,EAC1D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,aAAa,OAAA,EAAQ;AAChC","file":"chunk-SAGXF3MU.js","sourcesContent":["import { useState, useEffect, useCallback } from 'react';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseCommentsResult - Return type for useComments hook\n *\n * @property commentsKey - Key to pass to salla-comments component for re-render\n * @property refresh - Function to manually trigger a comments refresh\n */\nexport interface UseCommentsResult {\n commentsKey: number;\n refresh: () => void;\n}\n\n/**\n * useComments - Hook for managing salla-comments web component re-renders\n *\n * Listens to the Salla SDK's comment added events and automatically\n * increments a re-render key for the salla-comments component. This\n * eliminates the need for full page reloads when comments are added.\n *\n * @returns Object with comments key for component re-rendering and manual refresh function\n *\n * @example\n * ```tsx\n * function ProductPage({ product }) {\n * const { commentsKey } = useComments();\n *\n * return (\n * <salla-comments\n * key={commentsKey}\n * item-id={product.id}\n * type=\"product\"\n * />\n * );\n * }\n * ```\n */\n\nexport function useComments(): UseCommentsResult {\n const [commentsKey, setCommentsKey] = useState(0);\n\n const refresh = useCallback(() => {\n setCommentsKey((prev) => prev + 1);\n }, []);\n\n useEffect(() => {\n const handleCommentAdded = () => {\n setCommentsKey((prev) => prev + 1);\n };\n\n return onSallaEvent('comment::added', handleCommentAdded);\n }, []);\n\n return { commentsKey, refresh };\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/useComments.ts"],"names":[],"mappings":";;;AAuCO,SAAS,WAAA,GAAiC;AAC/C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,MAAM,OAAA,GAAU,YAAY,MAAM;AAChC,IAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,EACnC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,cAAA,CAAe,CAAC,IAAA,KAAS,IAAA,GAAO,CAAC,CAAA;AAAA,IACnC,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,kBAAkB,kBAAkB,CAAA;AAAA,EAC1D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,aAAa,OAAA,EAAQ;AAChC","file":"chunk-QZEQOVA5.js","sourcesContent":["import { useState, useEffect, useCallback } from 'react';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseCommentsResult - Return type for useComments hook\n *\n * @property commentsKey - Key to pass to salla-comments component for re-render\n * @property refresh - Function to manually trigger a comments refresh\n */\nexport interface UseCommentsResult {\n commentsKey: number;\n refresh: () => void;\n}\n\n/**\n * useComments - Hook for managing salla-comments web component re-renders\n *\n * Listens to the Salla SDK's comment added events and automatically\n * increments a re-render key for the salla-comments component. This\n * eliminates the need for full page reloads when comments are added.\n *\n * @returns Object with comments key for component re-rendering and manual refresh function\n *\n * @example\n * ```tsx\n * function ProductPage({ product }) {\n * const { commentsKey } = useComments();\n *\n * return (\n * <salla-comments\n * key={commentsKey}\n * item-id={product.id}\n * type=\"product\"\n * />\n * );\n * }\n * ```\n */\n\nexport function useComments(): UseCommentsResult {\n const [commentsKey, setCommentsKey] = useState(0);\n\n const refresh = useCallback(() => {\n setCommentsKey((prev) => prev + 1);\n }, []);\n\n useEffect(() => {\n const handleCommentAdded = () => {\n setCommentsKey((prev) => prev + 1);\n };\n\n return onSallaEvent('comment::added', handleCommentAdded);\n }, []);\n\n return { commentsKey, refresh };\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { RouteId } from './chunk-OUW6WESU.js';
2
- import { getActiveScope } from './chunk-QGOPTVV5.js';
3
- import { openNativeBrowser } from './chunk-JJARU7YP.js';
4
- import { withoutStoreUrlBase, extractScopeFromUrl } from './chunk-HSWRYXC7.js';
2
+ import { getActiveScope } from './chunk-6EQ7G3SZ.js';
3
+ import { openNativeBrowser } from './chunk-EWLVLDRP.js';
4
+ import { withoutStoreUrlBase, extractScopeFromUrl } from './chunk-FO4WVGUQ.js';
5
5
  import { subscribeTwilight, getTwilightContext } from './chunk-N2S25NXP.js';
6
6
  import { useTwilight } from './chunk-DF6FBKDN.js';
7
7
  import { createContext, createElement, useContext, useSyncExternalStore, useRef, useEffect, useCallback } from 'react';
@@ -303,5 +303,5 @@ function useNavigationInterceptor(navigate, storeUrl, username) {
303
303
  }
304
304
 
305
305
  export { NavigationInterceptor, NavigationProvider, NotFoundError, RedirectError, UnauthorizedError, configureNavigation, defaultNavigate, notFound, orThrow, orUnauthorized, redirect, resolveRelativePath, unauthorized, useIsBlog, useIsBrands, useIsCart, useIsCustomer, useIsHome, useIsProduct, useIsSearch, useLocation, useNavigate, useRouteId };
306
- //# sourceMappingURL=chunk-JTOVO3ZU.js.map
307
- //# sourceMappingURL=chunk-JTOVO3ZU.js.map
306
+ //# sourceMappingURL=chunk-RWBTMHLR.js.map
307
+ //# sourceMappingURL=chunk-RWBTMHLR.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/providers/NavigationProvider.ts"],"names":[],"mappings":";;;;;;;;AA6BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,WAAA,CACS,IAAA,EACA,OAAA,GAAU,KAAA,EACjB;AACA,IAAA,KAAA,CAAM,CAAA,YAAA,EAAe,IAAI,CAAA,CAAE,CAAA;AAHpB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,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AAa,EAAE,OAAA,EAAS,MAAM,CAAA;AACpE,MAAA,QAAA,CAAS,mBAAA,CAAoB,eAAe,iBAAiB,CAAA;AAC7D,MAAA,QAAA,CAAS,mBAAA,CAAoB,aAAa,eAAe,CAAA;AACzD,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,IAAI;AACF,UAAA,MAAA,CAAO,SAAS,MAAA,GAAS,UAAA;AAAA,QAC3B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AACA,MAAA,IAAI,cAAA,EAAgB;AAClB,QAAA,IAAI;AACF,UAAA,MAAA,CAAO,SAAS,OAAA,GAAU,WAAA;AAAA,QAC5B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AAClB","file":"chunk-JTOVO3ZU.js","sourcesContent":["import {\n createElement,\n createContext,\n useContext,\n useCallback,\n useRef,\n useEffect,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { useTwilight } from './twilight-context';\nimport { getTwilightContext, subscribeTwilight, type TwilightLocation } from '../twilight/context';\nimport { RouteId } from '../router/route-ids';\nimport { withoutStoreUrlBase } from '../utils/store-base';\nimport { extractScopeFromUrl } from '../utils/cookies';\nimport { getActiveScope } from '../api/client';\nimport { openNativeBrowser } from '../native-app';\n\n// Re-export RouteId from centralized location\nexport { RouteId } from '../router/route-ids';\nexport type { RouteIdType } from '../router/route-ids';\n\n// Re-export TwilightLocation as Location for convenience\nexport type { TwilightLocation as Location } from '../twilight/context';\n\nexport type NavigateOptions = { replace?: boolean };\nexport type NavigateFn = (to: string, opts?: NavigateOptions) => void;\n\n/** Redirect error - thrown to trigger a redirect */\nexport class RedirectError extends Error {\n constructor(\n public path: string,\n public replace = false\n ) {\n super(`Redirect to ${path}`);\n this.name = 'RedirectError';\n }\n}\n\n/** NotFound error - thrown to trigger 404 */\nexport class NotFoundError extends Error {\n constructor(message?: string) {\n super(message ?? 'Not Found');\n this.name = 'NotFoundError';\n }\n}\n\n/** Unauthorized error - thrown to trigger 401 */\nexport class UnauthorizedError extends Error {\n constructor(message?: string) {\n super(message ?? 'Unauthorized');\n this.name = 'UnauthorizedError';\n }\n}\n\nexport { SettingsError } from '../utils/errors';\n\nexport const defaultNavigate: NavigateFn = (to, opts) => {\n if (opts?.replace) window.location.replace(to);\n else window.location.href = to;\n};\n\nexport interface RedirectOptions {\n replace?: boolean;\n /** HTTP status of a server redirect, e.g. 301 for a URL that moved for good. Defaults to 307. */\n statusCode?: number;\n}\n\n/** Default redirect - throws RedirectError with browser navigation as fallback */\nexport const defaultRedirect = (path: string, opts?: RedirectOptions): never => {\n const replace = opts?.replace ?? false;\n\n // In browser, perform actual navigation before throwing\n if (typeof window !== 'undefined') {\n if (replace) window.location.replace(path);\n else window.location.href = path;\n }\n\n throw new RedirectError(path, replace);\n};\n\n/** Default notFound - throws generic error */\nexport const defaultNotFound = (message?: string): never => {\n throw new NotFoundError(message);\n};\n\n/** Default unauthorized - throws generic error */\nexport const defaultUnauthorized = (message?: string): never => {\n throw new UnauthorizedError(message);\n};\n\n// ─── Framework-agnostic functions for loaders (outside React context) ──────\n\ninterface NavigationHandlers {\n notFound: (message?: string) => never;\n redirect: (path: string, opts?: RedirectOptions) => never;\n unauthorized: (message?: string) => never;\n}\n\n// One set per isolate, so a loader in another copy of this module (a separate\n// package entry, a dev reload) still throws what the framework adapter configured.\nconst HANDLERS_KEY = Symbol.for('salla.twilight.navigation.handlers');\nconst registry = globalThis as { [HANDLERS_KEY]?: NavigationHandlers };\nconst handlers: NavigationHandlers = (registry[HANDLERS_KEY] ??= {\n notFound: defaultNotFound,\n redirect: defaultRedirect,\n unauthorized: defaultUnauthorized,\n});\n\n/**\n * Throw a notFound error. Use in route loaders.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * // In loader\n * import { notFound } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!data) throw notFound();\n * ```\n */\nexport function notFound(message?: string): never {\n return handlers.notFound(message);\n}\n\n/**\n * Throw an unauthorized error. Use in route loaders to protect authenticated routes.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * import { unauthorized } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!user) throw unauthorized();\n * ```\n */\nexport function unauthorized(message?: string): never {\n return handlers.unauthorized(message);\n}\n\n/**\n * Throw a redirect. Use in route loaders.\n * Framework adapters will override this to throw framework-specific redirects.\n *\n * @param path - Path to redirect to\n * @param opts - Redirect options\n *\n * @example\n * ```ts\n * // In loader\n * import { redirect } from '@salla.sa/twilight-theme-engine/providers';\n *\n * throw redirect('/ar/cart');\n * ```\n */\nexport function redirect(path: string, opts?: RedirectOptions): never {\n return handlers.redirect(path, opts);\n}\n\n/**\n * Configure navigation functions for a specific framework.\n * Called by framework adapters during setup.\n */\nexport function configureNavigation(config: {\n notFound?: (message?: string) => never;\n redirect?: (path: string, opts?: RedirectOptions) => never;\n unauthorized?: (_message?: string) => never;\n}): void {\n if (config.notFound) handlers.notFound = config.notFound;\n if (config.redirect) handlers.redirect = config.redirect;\n if (config.unauthorized) handlers.unauthorized = config.unauthorized;\n}\n\n// ─── Loader Error Handling Helpers ─────────────────────────────────────────────\n\n/**\n * Wraps an API promise with error handling for route loaders.\n * On a 404/410 response throws notFound(); other errors propagate.\n *\n * @example\n * ```ts\n * findOrThrow: (id, locale) => orThrow(product.find(id, locale)),\n * const data = await product.findOrThrow(id, locale);\n * ```\n */\nexport async function orThrow<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n console.debug('[loader error]', error);\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n // The API answers a missing resource with 410, sometimes 404.\n if (status === 404 || status === 410) return notFound();\n throw error;\n }\n}\n\n/**\n * Wraps an API promise with error handling for authenticated route loaders.\n * On a 401/403 response throws unauthorized(); other errors propagate.\n *\n * @example\n * ```ts\n * const data = await orUnauthorized(order.find(id, locale));\n * ```\n */\nexport async function orUnauthorized<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n if (status === 401 || status === 403) {\n throw unauthorized();\n }\n throw error;\n }\n}\n\n// ─── Navigation Context ──────────────────────────────────────────────────────\n\ninterface NavigationContextValue {\n navigate: NavigateFn;\n}\n\nconst NavigationContext = createContext<NavigationContextValue>({\n navigate: defaultNavigate,\n});\n\nexport function NavigationProvider({\n navigate,\n children,\n}: {\n navigate: NavigateFn;\n children: ReactNode;\n}) {\n return createElement(NavigationContext.Provider, { value: { navigate } }, children);\n}\n\n// ─── Primary Hooks (High Compatibility) ───────────────────────────────────────\n\n/**\n * Get the navigate function.\n * Matches React Router, TanStack Router, and Remix naming convention.\n *\n * @returns Navigate function\n *\n * @example\n * ```tsx\n * const navigate = useNavigate();\n * navigate('/cart');\n * navigate('/cart', { replace: true });\n * ```\n */\nexport function useNavigate(): NavigateFn {\n return useContext(NavigationContext).navigate;\n}\n\n/**\n * Get the current route ID.\n * Used for route detection (isHome, isProduct, etc.)\n *\n * @returns Current route ID string\n *\n * @example\n * ```tsx\n * const routeId = useRouteId();\n * if (routeId === RouteId.INDEX) { ... }\n * ```\n */\nexport function useRouteId(): string {\n return useSyncExternalStore(\n subscribeTwilight,\n () => getTwilightContext().routeId,\n () => getTwilightContext().routeId\n );\n}\n\n/**\n * Get the current location (TanStack Router compatible).\n * Reads from the router context for SSR compatibility.\n *\n * @returns Location object matching TanStack's ParsedLocation\n *\n * @example\n * ```tsx\n * const location = useLocation();\n * console.log(location.pathname); // '/ar/products'\n * console.log(location.searchStr); // '?q=shoes&page=2'\n * console.log(location.search); // { q: 'shoes', page: '2' }\n * console.log(location.href); // 'https://store.com/ar/products?q=shoes'\n * console.log(location.hash); // '#section-1'\n * console.log(location.state); // { scrollY: 100 }\n * ```\n */\nexport function useLocation<TSearch = Record<string, unknown>>(): TwilightLocation<TSearch> {\n useTwilight();\n return getTwilightContext().location as TwilightLocation<TSearch>;\n}\n\n// ─── Selector Hooks ───────────────────────────────────────────────────────────\n\n/**\n * Check if current page is homepage */\nexport function useIsHome(): boolean {\n return useRouteId() === RouteId.INDEX;\n}\n\n/** Check if current page is product detail */\nexport function useIsProduct(): boolean {\n return useRouteId() === RouteId.PRODUCT_SINGLE;\n}\n\n/** Check if current page is cart */\nexport function useIsCart(): boolean {\n return useRouteId() === RouteId.CART;\n}\n\n/** Check if current page is in customer area */\nexport function useIsCustomer(): boolean {\n return useRouteId().startsWith('customer');\n}\n\n/** Check if current page is blog related */\nexport function useIsBlog(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BLOG_INDEX || routeId === RouteId.BLOG_SINGLE;\n}\n\n/** Check if current page is brands related */\nexport function useIsBrands(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BRANDS_INDEX || routeId === RouteId.BRANDS_SINGLE;\n}\n\n/** Check if current page is search */\nexport function useIsSearch(): boolean {\n return useRouteId() === RouteId.SEARCH;\n}\n\n// ─── Navigation Interceptor ──────────────────────────────────────────────────\n\n/**\n * NavigationInterceptor - Framework-agnostic SPA navigation interceptor.\n *\n * Uses navigate function from NavigationProvider context and store URL\n * from TwilightProvider to intercept same-origin navigations.\n */\nexport function NavigationInterceptor(): null {\n const navigate = useNavigate();\n const { store } = useTwilight();\n useNavigationInterceptor(navigate, store?.url, store?.username);\n return null;\n}\n\n/**\n * resolveRelativePath - Resolve href to store-relative path\n *\n * Returns `null` when the URL is not on the same origin as the store,\n * keeping this helper safe against open-redirect misuse.\n *\n * The path is the application's, not the address on Salla's host: a store served\n * under its username there (`https://demostore.salla.sa/ar/dev-…/`) hands out links\n * carrying that segment, and it is removed. On a host where the store is the root\n * of every URL, the router adds its own segment back when it navigates.\n *\n * @param href - The URL to resolve\n * @param storeUrl - The store's base URL\n * @param username - The store's username, which tells that segment apart from a\n * locale spelled the same way (see `withoutStoreUrlBase`)\n * @returns The relative path string, or null if the URL is external\n */\nexport function resolveRelativePath(\n href: string,\n storeUrl: string,\n username?: string | null\n): string | null {\n try {\n const target = new URL(href, window.location.href);\n const base = new URL(storeUrl);\n\n if (target.origin !== base.origin) return null;\n\n const pathname = withoutStoreUrlBase(target.pathname, base.pathname, username);\n const path = pathname + target.search + target.hash;\n return path || '/';\n } catch {\n return null;\n }\n}\n\n/**\n * EXTERNAL_TARGETS - Target attribute values that indicate external navigation\n */\nconst EXTERNAL_TARGETS = new Set(['_blank', '_parent', '_top']);\n\n/**\n * shouldIntercept - Determine if an anchor click should be intercepted by SPA router\n *\n * Follows browser conventions: modifier keys, external targets, downloads,\n * and non-HTTP(S) protocols are left to the browser's default behavior.\n *\n * @param anchor - The anchor element that was clicked\n * @param event - The click event\n * @returns true if the click should be intercepted by the router\n */\nexport function shouldIntercept(anchor: HTMLAnchorElement, event: MouseEvent): boolean {\n if (event.defaultPrevented) return false;\n\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return false;\n\n const targetAttr = anchor.getAttribute('target');\n if (targetAttr && EXTERNAL_TARGETS.has(targetAttr)) return false;\n\n if (anchor.hasAttribute('download')) return false;\n\n const rel = (anchor.getAttribute('rel') ?? '').split(/\\s+/);\n if (rel.includes('external')) return false;\n\n const href = anchor.getAttribute('href') ?? '';\n if (!href) return false;\n\n try {\n const url = new URL(href, window.location.href);\n if (url.protocol.startsWith('javascript:')) return false;\n } catch {\n return false;\n }\n\n return true;\n}\n\n/**\n * Whether `href` switches market: its `?scope=` names another scope than the active one,\n * or the same scope with another branch (`allocation_type` / `allocation_id`).\n *\n * Twig switches market with a full load (the SDK's scopes modal calls\n * `location.replace('?scope=<id>')`), and only a document request lets the server render\n * the new market and record it in the `scope` cookie. Left to the browser, not the router.\n */\nexport function switchesScope(href: string): boolean {\n let url: URL;\n try {\n url = new URL(href, window.location.href);\n } catch {\n return false;\n }\n const requested = extractScopeFromUrl(url.href);\n if (!requested) return false;\n const active = getActiveScope();\n if (requested.id !== active?.id) return true;\n return (\n requested.allocation_id != null &&\n (requested.allocation_id !== active.allocation_id ||\n requested.allocation_type !== active.allocation_type)\n );\n}\n\n/**\n * Whether an untouched tap on `anchor` would load a page off the store: an\n * http(s) link to neither this page's origin nor the store's. `mailto:`, `tel:`\n * and the like are the device's to handle, and are left alone.\n */\nexport function leavesStore(\n anchor: HTMLAnchorElement,\n event: MouseEvent,\n storeUrl: string | undefined\n): boolean {\n if (event.defaultPrevented || anchor.hasAttribute('download')) return false;\n let url: URL;\n try {\n url = new URL(anchor.getAttribute('href') ?? '', window.location.href);\n } catch {\n return false;\n }\n if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;\n if (url.origin === window.location.origin) return false;\n try {\n return !storeUrl || url.origin !== new URL(storeUrl).origin;\n } catch {\n return true;\n }\n}\n\nfunction isSamePage(href: string): boolean {\n const url = new URL(href, window.location.href);\n return url.pathname === window.location.pathname && url.search === window.location.search;\n}\n\nfunction closeEnclosingModal(path: EventTarget[]): void {\n const modal = path.find(\n (el): el is HTMLElement & { close?: () => unknown } =>\n el instanceof HTMLElement && el.localName === 'salla-modal'\n );\n void modal?.close?.();\n}\n\n// ─── Navigation Interceptor Hook (framework-agnostic) ─────────────────────────\n\n/**\n * Hook for navigation interception using framework-agnostic navigate function.\n * Framework adapters call this with their navigate implementation.\n */\nexport function useNavigationInterceptor(\n navigate: NavigateFn,\n storeUrl: string | undefined,\n username?: string\n): void {\n const storeUrlRef = useRef<string | undefined>(storeUrl);\n const usernameRef = useRef<string | undefined>(username);\n\n useEffect(() => {\n storeUrlRef.current = storeUrl;\n usernameRef.current = username;\n }, [storeUrl, username]);\n\n const tryNavigate = useCallback(\n (href: string, replace = false): boolean => {\n const currentStoreUrl = storeUrlRef.current;\n if (!currentStoreUrl || switchesScope(href)) return false;\n\n const relativePath = resolveRelativePath(href, currentStoreUrl, usernameRef.current);\n if (!relativePath) return false;\n\n navigate(relativePath, { replace });\n return true;\n },\n [navigate]\n );\n\n useEffect(() => {\n // ── Pointer movement tracking ────────────────────────────────────────────\n // Detect drag/scroll gestures to avoid intercepting clicks from swipes.\n let pointerStartX = 0;\n let pointerStartY = 0;\n let pointerSwiped = false;\n const MOVE_THRESHOLD = 10;\n\n function handlePointerDown(event: PointerEvent): void {\n pointerStartX = event.clientX;\n pointerStartY = event.clientY;\n pointerSwiped = false;\n }\n\n function handlePointerUp(event: PointerEvent): void {\n const dx = Math.abs(event.clientX - pointerStartX);\n const dy = Math.abs(event.clientY - pointerStartY);\n pointerSwiped = dx > MOVE_THRESHOLD || dy > MOVE_THRESHOLD;\n }\n\n // ── Anchor click interception ────────────────────────────────────────────\n function handleClick(event: MouseEvent): void {\n // Ignore clicks that resulted from swipe/drag gestures.\n if (pointerSwiped) {\n pointerSwiped = false;\n return;\n }\n\n const path = event.composedPath();\n const anchor = path.find((el): el is HTMLAnchorElement => el instanceof HTMLAnchorElement);\n\n // Inside the Salla app, a link that leaves the store opens in the device's\n // browser; loaded in the app's webview it would strand the shopper there.\n if (\n anchor &&\n leavesStore(anchor, event, storeUrlRef.current) &&\n openNativeBrowser(anchor.href)\n ) {\n event.preventDefault();\n return;\n }\n\n if (!anchor || !shouldIntercept(anchor, event)) return;\n\n const samePage = isSamePage(anchor.href);\n if (tryNavigate(anchor.href, false)) {\n event.preventDefault();\n // A page load would close a web component's modal; an in-app navigation leaves it open.\n if (!samePage) closeEnclosingModal(path);\n }\n }\n\n // ── window.location.assign patch ─────────────────────────────────────────\n const origAssign = window.location.assign;\n function patchedAssign(url: string): void {\n if (!tryNavigate(url, false)) origAssign.call(window.location, url);\n }\n\n // ── window.location.replace patch ────────────────────────────────────────\n const origReplace = window.location.replace;\n function patchedReplace(url: string): void {\n if (!tryNavigate(url, true)) origReplace.call(window.location, url);\n }\n\n let assignPatched = false;\n let replacePatched = false;\n try {\n window.location.assign = patchedAssign;\n assignPatched = true;\n } catch {\n /* non-writable in this environment */\n }\n try {\n window.location.replace = patchedReplace;\n replacePatched = true;\n } catch {\n /* non-writable in this environment */\n }\n\n document.addEventListener('click', handleClick, { capture: true });\n document.addEventListener('pointerdown', handlePointerDown, { passive: true });\n document.addEventListener('pointerup', handlePointerUp, { passive: true });\n\n return () => {\n document.removeEventListener('click', handleClick, { capture: true });\n document.removeEventListener('pointerdown', handlePointerDown);\n document.removeEventListener('pointerup', handlePointerUp);\n if (assignPatched) {\n try {\n window.location.assign = origAssign;\n } catch {\n /* ignore */\n }\n }\n if (replacePatched) {\n try {\n window.location.replace = origReplace;\n } catch {\n /* ignore */\n }\n }\n };\n }, [tryNavigate]);\n}\n\n// ─── Client navigation config ─────────────────────────────────────────────────\n\nexport interface ClientNav {\n /** Framework adapter to use for client-side navigation. @default 'tanstack' */\n framework?: 'tanstack' | 'nextjs';\n /**\n * Intercept same-origin `<a>` clicks and `window.location` calls from web\n * components and route them through the framework router.\n * @default true\n */\n interceptLinks?: boolean;\n}\n\n// Framework adapter setups are registered in navigation-setups.ts to avoid circular imports.\n"]}
1
+ {"version":3,"sources":["../src/providers/NavigationProvider.ts"],"names":[],"mappings":";;;;;;;;AA6BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,WAAA,CACS,IAAA,EACA,OAAA,GAAU,KAAA,EACjB;AACA,IAAA,KAAA,CAAM,CAAA,YAAA,EAAe,IAAI,CAAA,CAAE,CAAA;AAHpB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EACd;AACF;AAGO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,YAAY,OAAA,EAAkB;AAC5B,IAAA,KAAA,CAAM,WAAW,WAAW,CAAA;AAC5B,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EACd;AACF;AAGO,IAAM,iBAAA,GAAN,cAAgC,KAAA,CAAM;AAAA,EAC3C,YAAY,OAAA,EAAkB;AAC5B,IAAA,KAAA,CAAM,WAAW,cAAc,CA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A,GAAU,WAAA;AAAA,QAC5B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AAClB","file":"chunk-RWBTMHLR.js","sourcesContent":["import {\n createElement,\n createContext,\n useContext,\n useCallback,\n useRef,\n useEffect,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { useTwilight } from './twilight-context';\nimport { getTwilightContext, subscribeTwilight, type TwilightLocation } from '../twilight/context';\nimport { RouteId } from '../router/route-ids';\nimport { withoutStoreUrlBase } from '../utils/store-base';\nimport { extractScopeFromUrl } from '../utils/cookies';\nimport { getActiveScope } from '../api/client';\nimport { openNativeBrowser } from '../native-app';\n\n// Re-export RouteId from centralized location\nexport { RouteId } from '../router/route-ids';\nexport type { RouteIdType } from '../router/route-ids';\n\n// Re-export TwilightLocation as Location for convenience\nexport type { TwilightLocation as Location } from '../twilight/context';\n\nexport type NavigateOptions = { replace?: boolean };\nexport type NavigateFn = (to: string, opts?: NavigateOptions) => void;\n\n/** Redirect error - thrown to trigger a redirect */\nexport class RedirectError extends Error {\n constructor(\n public path: string,\n public replace = false\n ) {\n super(`Redirect to ${path}`);\n this.name = 'RedirectError';\n }\n}\n\n/** NotFound error - thrown to trigger 404 */\nexport class NotFoundError extends Error {\n constructor(message?: string) {\n super(message ?? 'Not Found');\n this.name = 'NotFoundError';\n }\n}\n\n/** Unauthorized error - thrown to trigger 401 */\nexport class UnauthorizedError extends Error {\n constructor(message?: string) {\n super(message ?? 'Unauthorized');\n this.name = 'UnauthorizedError';\n }\n}\n\nexport { SettingsError } from '../utils/errors';\n\nexport const defaultNavigate: NavigateFn = (to, opts) => {\n if (opts?.replace) window.location.replace(to);\n else window.location.href = to;\n};\n\nexport interface RedirectOptions {\n replace?: boolean;\n /** HTTP status of a server redirect, e.g. 301 for a URL that moved for good. Defaults to 307. */\n statusCode?: number;\n}\n\n/** Default redirect - throws RedirectError with browser navigation as fallback */\nexport const defaultRedirect = (path: string, opts?: RedirectOptions): never => {\n const replace = opts?.replace ?? false;\n\n // In browser, perform actual navigation before throwing\n if (typeof window !== 'undefined') {\n if (replace) window.location.replace(path);\n else window.location.href = path;\n }\n\n throw new RedirectError(path, replace);\n};\n\n/** Default notFound - throws generic error */\nexport const defaultNotFound = (message?: string): never => {\n throw new NotFoundError(message);\n};\n\n/** Default unauthorized - throws generic error */\nexport const defaultUnauthorized = (message?: string): never => {\n throw new UnauthorizedError(message);\n};\n\n// ─── Framework-agnostic functions for loaders (outside React context) ──────\n\ninterface NavigationHandlers {\n notFound: (message?: string) => never;\n redirect: (path: string, opts?: RedirectOptions) => never;\n unauthorized: (message?: string) => never;\n}\n\n// One set per isolate, so a loader in another copy of this module (a separate\n// package entry, a dev reload) still throws what the framework adapter configured.\nconst HANDLERS_KEY = Symbol.for('salla.twilight.navigation.handlers');\nconst registry = globalThis as { [HANDLERS_KEY]?: NavigationHandlers };\nconst handlers: NavigationHandlers = (registry[HANDLERS_KEY] ??= {\n notFound: defaultNotFound,\n redirect: defaultRedirect,\n unauthorized: defaultUnauthorized,\n});\n\n/**\n * Throw a notFound error. Use in route loaders.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * // In loader\n * import { notFound } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!data) throw notFound();\n * ```\n */\nexport function notFound(message?: string): never {\n return handlers.notFound(message);\n}\n\n/**\n * Throw an unauthorized error. Use in route loaders to protect authenticated routes.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * import { unauthorized } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!user) throw unauthorized();\n * ```\n */\nexport function unauthorized(message?: string): never {\n return handlers.unauthorized(message);\n}\n\n/**\n * Throw a redirect. Use in route loaders.\n * Framework adapters will override this to throw framework-specific redirects.\n *\n * @param path - Path to redirect to\n * @param opts - Redirect options\n *\n * @example\n * ```ts\n * // In loader\n * import { redirect } from '@salla.sa/twilight-theme-engine/providers';\n *\n * throw redirect('/ar/cart');\n * ```\n */\nexport function redirect(path: string, opts?: RedirectOptions): never {\n return handlers.redirect(path, opts);\n}\n\n/**\n * Configure navigation functions for a specific framework.\n * Called by framework adapters during setup.\n */\nexport function configureNavigation(config: {\n notFound?: (message?: string) => never;\n redirect?: (path: string, opts?: RedirectOptions) => never;\n unauthorized?: (_message?: string) => never;\n}): void {\n if (config.notFound) handlers.notFound = config.notFound;\n if (config.redirect) handlers.redirect = config.redirect;\n if (config.unauthorized) handlers.unauthorized = config.unauthorized;\n}\n\n// ─── Loader Error Handling Helpers ─────────────────────────────────────────────\n\n/**\n * Wraps an API promise with error handling for route loaders.\n * On a 404/410 response throws notFound(); other errors propagate.\n *\n * @example\n * ```ts\n * findOrThrow: (id, locale) => orThrow(product.find(id, locale)),\n * const data = await product.findOrThrow(id, locale);\n * ```\n */\nexport async function orThrow<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n console.debug('[loader error]', error);\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n // The API answers a missing resource with 410, sometimes 404.\n if (status === 404 || status === 410) return notFound();\n throw error;\n }\n}\n\n/**\n * Wraps an API promise with error handling for authenticated route loaders.\n * On a 401/403 response throws unauthorized(); other errors propagate.\n *\n * @example\n * ```ts\n * const data = await orUnauthorized(order.find(id, locale));\n * ```\n */\nexport async function orUnauthorized<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n if (status === 401 || status === 403) {\n throw unauthorized();\n }\n throw error;\n }\n}\n\n// ─── Navigation Context ──────────────────────────────────────────────────────\n\ninterface NavigationContextValue {\n navigate: NavigateFn;\n}\n\nconst NavigationContext = createContext<NavigationContextValue>({\n navigate: defaultNavigate,\n});\n\nexport function NavigationProvider({\n navigate,\n children,\n}: {\n navigate: NavigateFn;\n children: ReactNode;\n}) {\n return createElement(NavigationContext.Provider, { value: { navigate } }, children);\n}\n\n// ─── Primary Hooks (High Compatibility) ───────────────────────────────────────\n\n/**\n * Get the navigate function.\n * Matches React Router, TanStack Router, and Remix naming convention.\n *\n * @returns Navigate function\n *\n * @example\n * ```tsx\n * const navigate = useNavigate();\n * navigate('/cart');\n * navigate('/cart', { replace: true });\n * ```\n */\nexport function useNavigate(): NavigateFn {\n return useContext(NavigationContext).navigate;\n}\n\n/**\n * Get the current route ID.\n * Used for route detection (isHome, isProduct, etc.)\n *\n * @returns Current route ID string\n *\n * @example\n * ```tsx\n * const routeId = useRouteId();\n * if (routeId === RouteId.INDEX) { ... }\n * ```\n */\nexport function useRouteId(): string {\n return useSyncExternalStore(\n subscribeTwilight,\n () => getTwilightContext().routeId,\n () => getTwilightContext().routeId\n );\n}\n\n/**\n * Get the current location (TanStack Router compatible).\n * Reads from the router context for SSR compatibility.\n *\n * @returns Location object matching TanStack's ParsedLocation\n *\n * @example\n * ```tsx\n * const location = useLocation();\n * console.log(location.pathname); // '/ar/products'\n * console.log(location.searchStr); // '?q=shoes&page=2'\n * console.log(location.search); // { q: 'shoes', page: '2' }\n * console.log(location.href); // 'https://store.com/ar/products?q=shoes'\n * console.log(location.hash); // '#section-1'\n * console.log(location.state); // { scrollY: 100 }\n * ```\n */\nexport function useLocation<TSearch = Record<string, unknown>>(): TwilightLocation<TSearch> {\n useTwilight();\n return getTwilightContext().location as TwilightLocation<TSearch>;\n}\n\n// ─── Selector Hooks ───────────────────────────────────────────────────────────\n\n/**\n * Check if current page is homepage */\nexport function useIsHome(): boolean {\n return useRouteId() === RouteId.INDEX;\n}\n\n/** Check if current page is product detail */\nexport function useIsProduct(): boolean {\n return useRouteId() === RouteId.PRODUCT_SINGLE;\n}\n\n/** Check if current page is cart */\nexport function useIsCart(): boolean {\n return useRouteId() === RouteId.CART;\n}\n\n/** Check if current page is in customer area */\nexport function useIsCustomer(): boolean {\n return useRouteId().startsWith('customer');\n}\n\n/** Check if current page is blog related */\nexport function useIsBlog(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BLOG_INDEX || routeId === RouteId.BLOG_SINGLE;\n}\n\n/** Check if current page is brands related */\nexport function useIsBrands(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BRANDS_INDEX || routeId === RouteId.BRANDS_SINGLE;\n}\n\n/** Check if current page is search */\nexport function useIsSearch(): boolean {\n return useRouteId() === RouteId.SEARCH;\n}\n\n// ─── Navigation Interceptor ──────────────────────────────────────────────────\n\n/**\n * NavigationInterceptor - Framework-agnostic SPA navigation interceptor.\n *\n * Uses navigate function from NavigationProvider context and store URL\n * from TwilightProvider to intercept same-origin navigations.\n */\nexport function NavigationInterceptor(): null {\n const navigate = useNavigate();\n const { store } = useTwilight();\n useNavigationInterceptor(navigate, store?.url, store?.username);\n return null;\n}\n\n/**\n * resolveRelativePath - Resolve href to store-relative path\n *\n * Returns `null` when the URL is not on the same origin as the store,\n * keeping this helper safe against open-redirect misuse.\n *\n * The path is the application's, not the address on Salla's host: a store served\n * under its username there (`https://demostore.salla.sa/ar/dev-…/`) hands out links\n * carrying that segment, and it is removed. On a host where the store is the root\n * of every URL, the router adds its own segment back when it navigates.\n *\n * @param href - The URL to resolve\n * @param storeUrl - The store's base URL\n * @param username - The store's username, which tells that segment apart from a\n * locale spelled the same way (see `withoutStoreUrlBase`)\n * @returns The relative path string, or null if the URL is external\n */\nexport function resolveRelativePath(\n href: string,\n storeUrl: string,\n username?: string | null\n): string | null {\n try {\n const target = new URL(href, window.location.href);\n const base = new URL(storeUrl);\n\n if (target.origin !== base.origin) return null;\n\n const pathname = withoutStoreUrlBase(target.pathname, base.pathname, username);\n const path = pathname + target.search + target.hash;\n return path || '/';\n } catch {\n return null;\n }\n}\n\n/**\n * EXTERNAL_TARGETS - Target attribute values that indicate external navigation\n */\nconst EXTERNAL_TARGETS = new Set(['_blank', '_parent', '_top']);\n\n/**\n * shouldIntercept - Determine if an anchor click should be intercepted by SPA router\n *\n * Follows browser conventions: modifier keys, external targets, downloads,\n * and non-HTTP(S) protocols are left to the browser's default behavior.\n *\n * @param anchor - The anchor element that was clicked\n * @param event - The click event\n * @returns true if the click should be intercepted by the router\n */\nexport function shouldIntercept(anchor: HTMLAnchorElement, event: MouseEvent): boolean {\n if (event.defaultPrevented) return false;\n\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return false;\n\n const targetAttr = anchor.getAttribute('target');\n if (targetAttr && EXTERNAL_TARGETS.has(targetAttr)) return false;\n\n if (anchor.hasAttribute('download')) return false;\n\n const rel = (anchor.getAttribute('rel') ?? '').split(/\\s+/);\n if (rel.includes('external')) return false;\n\n const href = anchor.getAttribute('href') ?? '';\n if (!href) return false;\n\n try {\n const url = new URL(href, window.location.href);\n if (url.protocol.startsWith('javascript:')) return false;\n } catch {\n return false;\n }\n\n return true;\n}\n\n/**\n * Whether `href` switches market: its `?scope=` names another scope than the active one,\n * or the same scope with another branch (`allocation_type` / `allocation_id`).\n *\n * Twig switches market with a full load (the SDK's scopes modal calls\n * `location.replace('?scope=<id>')`), and only a document request lets the server render\n * the new market and record it in the `scope` cookie. Left to the browser, not the router.\n */\nexport function switchesScope(href: string): boolean {\n let url: URL;\n try {\n url = new URL(href, window.location.href);\n } catch {\n return false;\n }\n const requested = extractScopeFromUrl(url.href);\n if (!requested) return false;\n const active = getActiveScope();\n if (requested.id !== active?.id) return true;\n return (\n requested.allocation_id != null &&\n (requested.allocation_id !== active.allocation_id ||\n requested.allocation_type !== active.allocation_type)\n );\n}\n\n/**\n * Whether an untouched tap on `anchor` would load a page off the store: an\n * http(s) link to neither this page's origin nor the store's. `mailto:`, `tel:`\n * and the like are the device's to handle, and are left alone.\n */\nexport function leavesStore(\n anchor: HTMLAnchorElement,\n event: MouseEvent,\n storeUrl: string | undefined\n): boolean {\n if (event.defaultPrevented || anchor.hasAttribute('download')) return false;\n let url: URL;\n try {\n url = new URL(anchor.getAttribute('href') ?? '', window.location.href);\n } catch {\n return false;\n }\n if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;\n if (url.origin === window.location.origin) return false;\n try {\n return !storeUrl || url.origin !== new URL(storeUrl).origin;\n } catch {\n return true;\n }\n}\n\nfunction isSamePage(href: string): boolean {\n const url = new URL(href, window.location.href);\n return url.pathname === window.location.pathname && url.search === window.location.search;\n}\n\nfunction closeEnclosingModal(path: EventTarget[]): void {\n const modal = path.find(\n (el): el is HTMLElement & { close?: () => unknown } =>\n el instanceof HTMLElement && el.localName === 'salla-modal'\n );\n void modal?.close?.();\n}\n\n// ─── Navigation Interceptor Hook (framework-agnostic) ─────────────────────────\n\n/**\n * Hook for navigation interception using framework-agnostic navigate function.\n * Framework adapters call this with their navigate implementation.\n */\nexport function useNavigationInterceptor(\n navigate: NavigateFn,\n storeUrl: string | undefined,\n username?: string\n): void {\n const storeUrlRef = useRef<string | undefined>(storeUrl);\n const usernameRef = useRef<string | undefined>(username);\n\n useEffect(() => {\n storeUrlRef.current = storeUrl;\n usernameRef.current = username;\n }, [storeUrl, username]);\n\n const tryNavigate = useCallback(\n (href: string, replace = false): boolean => {\n const currentStoreUrl = storeUrlRef.current;\n if (!currentStoreUrl || switchesScope(href)) return false;\n\n const relativePath = resolveRelativePath(href, currentStoreUrl, usernameRef.current);\n if (!relativePath) return false;\n\n navigate(relativePath, { replace });\n return true;\n },\n [navigate]\n );\n\n useEffect(() => {\n // ── Pointer movement tracking ────────────────────────────────────────────\n // Detect drag/scroll gestures to avoid intercepting clicks from swipes.\n let pointerStartX = 0;\n let pointerStartY = 0;\n let pointerSwiped = false;\n const MOVE_THRESHOLD = 10;\n\n function handlePointerDown(event: PointerEvent): void {\n pointerStartX = event.clientX;\n pointerStartY = event.clientY;\n pointerSwiped = false;\n }\n\n function handlePointerUp(event: PointerEvent): void {\n const dx = Math.abs(event.clientX - pointerStartX);\n const dy = Math.abs(event.clientY - pointerStartY);\n pointerSwiped = dx > MOVE_THRESHOLD || dy > MOVE_THRESHOLD;\n }\n\n // ── Anchor click interception ────────────────────────────────────────────\n function handleClick(event: MouseEvent): void {\n // Ignore clicks that resulted from swipe/drag gestures.\n if (pointerSwiped) {\n pointerSwiped = false;\n return;\n }\n\n const path = event.composedPath();\n const anchor = path.find((el): el is HTMLAnchorElement => el instanceof HTMLAnchorElement);\n\n // Inside the Salla app, a link that leaves the store opens in the device's\n // browser; loaded in the app's webview it would strand the shopper there.\n if (\n anchor &&\n leavesStore(anchor, event, storeUrlRef.current) &&\n openNativeBrowser(anchor.href)\n ) {\n event.preventDefault();\n return;\n }\n\n if (!anchor || !shouldIntercept(anchor, event)) return;\n\n const samePage = isSamePage(anchor.href);\n if (tryNavigate(anchor.href, false)) {\n event.preventDefault();\n // A page load would close a web component's modal; an in-app navigation leaves it open.\n if (!samePage) closeEnclosingModal(path);\n }\n }\n\n // ── window.location.assign patch ─────────────────────────────────────────\n const origAssign = window.location.assign;\n function patchedAssign(url: string): void {\n if (!tryNavigate(url, false)) origAssign.call(window.location, url);\n }\n\n // ── window.location.replace patch ────────────────────────────────────────\n const origReplace = window.location.replace;\n function patchedReplace(url: string): void {\n if (!tryNavigate(url, true)) origReplace.call(window.location, url);\n }\n\n let assignPatched = false;\n let replacePatched = false;\n try {\n window.location.assign = patchedAssign;\n assignPatched = true;\n } catch {\n /* non-writable in this environment */\n }\n try {\n window.location.replace = patchedReplace;\n replacePatched = true;\n } catch {\n /* non-writable in this environment */\n }\n\n document.addEventListener('click', handleClick, { capture: true });\n document.addEventListener('pointerdown', handlePointerDown, { passive: true });\n document.addEventListener('pointerup', handlePointerUp, { passive: true });\n\n return () => {\n document.removeEventListener('click', handleClick, { capture: true });\n document.removeEventListener('pointerdown', handlePointerDown);\n document.removeEventListener('pointerup', handlePointerUp);\n if (assignPatched) {\n try {\n window.location.assign = origAssign;\n } catch {\n /* ignore */\n }\n }\n if (replacePatched) {\n try {\n window.location.replace = origReplace;\n } catch {\n /* ignore */\n }\n }\n };\n }, [tryNavigate]);\n}\n\n// ─── Client navigation config ─────────────────────────────────────────────────\n\nexport interface ClientNav {\n /** Framework adapter to use for client-side navigation. @default 'tanstack' */\n framework?: 'tanstack' | 'nextjs';\n /**\n * Intercept same-origin `<a>` clicks and `window.location` calls from web\n * components and route them through the framework router.\n * @default true\n */\n interceptLinks?: boolean;\n}\n\n// Framework adapter setups are registered in navigation-setups.ts to avoid circular imports.\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow } from './chunk-JTOVO3ZU.js';
2
- import { api } from './chunk-QGOPTVV5.js';
1
+ import { orThrow } from './chunk-RWBTMHLR.js';
2
+ import { api } from './chunk-6EQ7G3SZ.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var blog = {
@@ -63,5 +63,5 @@ var blog = {
63
63
  };
64
64
 
65
65
  export { blog };
66
- //# sourceMappingURL=chunk-DV6SJHL5.js.map
67
- //# sourceMappingURL=chunk-DV6SJHL5.js.map
66
+ //# sourceMappingURL=chunk-S34G5DL4.js.map
67
+ //# sourceMappingURL=chunk-S34G5DL4.js.map