@salla.sa/twilight-theme-engine 1.0.210 → 1.0.212

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 (246) hide show
  1. package/dist/{AddToCartForm-EG7HATAR.js → AddToCartForm-6B45JALK.js} +3 -3
  2. package/dist/{AddToCartForm-EG7HATAR.js.map → AddToCartForm-6B45JALK.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-HTOIPQQ4.js → BlogAuthorPage-NUIE33SI.js} +19 -19
  4. package/dist/{BlogAuthorPage-HTOIPQQ4.js.map → BlogAuthorPage-NUIE33SI.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-UAHYSE7T.js → BlogCategoryPage-NI7GRGIT.js} +19 -19
  6. package/dist/{BlogCategoryPage-UAHYSE7T.js.map → BlogCategoryPage-NI7GRGIT.js.map} +1 -1
  7. package/dist/{BlogPage-YGVOS4NV.js → BlogPage-EMGJ3RSW.js} +17 -17
  8. package/dist/{BlogPage-YGVOS4NV.js.map → BlogPage-EMGJ3RSW.js.map} +1 -1
  9. package/dist/{BlogSinglePage-3YH2K6NA.js → BlogSinglePage-27XZ6GHV.js} +17 -17
  10. package/dist/{BlogSinglePage-3YH2K6NA.js.map → BlogSinglePage-27XZ6GHV.js.map} +1 -1
  11. package/dist/{BlogTagPage-43GOS5A6.js → BlogTagPage-6NTZP2JR.js} +19 -19
  12. package/dist/{BlogTagPage-43GOS5A6.js.map → BlogTagPage-6NTZP2JR.js.map} +1 -1
  13. package/dist/{BrandsPage-COEINBDY.js → BrandsPage-CD556YCT.js} +18 -18
  14. package/dist/{BrandsPage-COEINBDY.js.map → BrandsPage-CD556YCT.js.map} +1 -1
  15. package/dist/{Breadcrumb-W4E43JGX.js → Breadcrumb-DH25AXCC.js} +17 -17
  16. package/dist/{Breadcrumb-W4E43JGX.js.map → Breadcrumb-DH25AXCC.js.map} +1 -1
  17. package/dist/{CanvasOverlay-G2LSKB6E.js → CanvasOverlay-32RQIQKU.js} +3 -3
  18. package/dist/{CanvasOverlay-G2LSKB6E.js.map → CanvasOverlay-32RQIQKU.js.map} +1 -1
  19. package/dist/{CartItem-EBTOA2JO.js → CartItem-ZCL5CW3F.js} +17 -17
  20. package/dist/{CartItem-EBTOA2JO.js.map → CartItem-ZCL5CW3F.js.map} +1 -1
  21. package/dist/{CartSummary-WOZKSBAB.js → CartSummary-HFPWKARM.js} +17 -17
  22. package/dist/{CartSummary-WOZKSBAB.js.map → CartSummary-HFPWKARM.js.map} +1 -1
  23. package/dist/{Copyright-2656CBLY.js → Copyright-4J2OAPEG.js} +3 -3
  24. package/dist/{Copyright-2656CBLY.js.map → Copyright-4J2OAPEG.js.map} +1 -1
  25. package/dist/{CustomerLayout-FBO4W4Z5.js → CustomerLayout-4RSNDRPC.js} +17 -17
  26. package/dist/{CustomerLayout-FBO4W4Z5.js.map → CustomerLayout-4RSNDRPC.js.map} +1 -1
  27. package/dist/{Footer-P3773ZM6.js → Footer-GQMU5B7W.js} +3 -3
  28. package/dist/{Footer-P3773ZM6.js.map → Footer-GQMU5B7W.js.map} +1 -1
  29. package/dist/GoogleTag-2RBGGJG3.js +15 -0
  30. package/dist/{GoogleTag-OPCZNE4C.js.map → GoogleTag-2RBGGJG3.js.map} +1 -1
  31. package/dist/{Header-DSAOP3FS.js → Header-KYCJOGUR.js} +8 -8
  32. package/dist/{Header-DSAOP3FS.js.map → Header-KYCJOGUR.js.map} +1 -1
  33. package/dist/{LatestProducts-GCFPSGAG.js → LatestProducts-JTKG7N7C.js} +19 -19
  34. package/dist/{LatestProducts-GCFPSGAG.js.map → LatestProducts-JTKG7N7C.js.map} +1 -1
  35. package/dist/{LoyaltyPage-TL6BMGCI.js → LoyaltyPage-DLNKNRPG.js} +17 -17
  36. package/dist/{LoyaltyPage-TL6BMGCI.js.map → LoyaltyPage-DLNKNRPG.js.map} +1 -1
  37. package/dist/{LoyaltyPointsPage-2XEY2ZLT.js → LoyaltyPointsPage-JUPZGVJG.js} +6 -6
  38. package/dist/{LoyaltyPointsPage-2XEY2ZLT.js.map → LoyaltyPointsPage-JUPZGVJG.js.map} +1 -1
  39. package/dist/{MainMenu-75YH3CH4.js → MainMenu-YU3QUJ3J.js} +5 -5
  40. package/dist/{MainMenu-75YH3CH4.js.map → MainMenu-YU3QUJ3J.js.map} +1 -1
  41. package/dist/{MasterLayout-65LIO6OE.js → MasterLayout-27562HUX.js} +17 -17
  42. package/dist/{MasterLayout-65LIO6OE.js.map → MasterLayout-27562HUX.js.map} +1 -1
  43. package/dist/{MobileMenu-YWQ7BHEF.js → MobileMenu-CSSJWHOF.js} +18 -18
  44. package/dist/{MobileMenu-YWQ7BHEF.js.map → MobileMenu-CSSJWHOF.js.map} +1 -1
  45. package/dist/{NotificationsPage-3UQ3APM2.js → NotificationsPage-XUQXWPRU.js} +17 -17
  46. package/dist/{NotificationsPage-3UQ3APM2.js.map → NotificationsPage-XUQXWPRU.js.map} +1 -1
  47. package/dist/{OrderSinglePage-GUEL6HB7.js → OrderSinglePage-Q76JD52G.js} +20 -20
  48. package/dist/{OrderSinglePage-GUEL6HB7.js.map → OrderSinglePage-Q76JD52G.js.map} +1 -1
  49. package/dist/{OrdersPage-EOD6GG4U.js → OrdersPage-3MDI2IPJ.js} +17 -17
  50. package/dist/{OrdersPage-EOD6GG4U.js.map → OrdersPage-3MDI2IPJ.js.map} +1 -1
  51. package/dist/{PageSingle-EOLJMQHB.js → PageSingle-YDCMHODA.js} +3 -3
  52. package/dist/{PageSingle-EOLJMQHB.js.map → PageSingle-YDCMHODA.js.map} +1 -1
  53. package/dist/{ProductDetails-RM7MPTMF.js → ProductDetails-2EVEP5SX.js} +5 -5
  54. package/dist/{ProductDetails-RM7MPTMF.js.map → ProductDetails-2EVEP5SX.js.map} +1 -1
  55. package/dist/{ProfilePage-XUF24BHS.js → ProfilePage-LAXMD2WO.js} +17 -17
  56. package/dist/{ProfilePage-XUF24BHS.js.map → ProfilePage-LAXMD2WO.js.map} +1 -1
  57. package/dist/{ReviewsPage-OUUEO3XC.js → ReviewsPage-HPTWKBPH.js} +3 -3
  58. package/dist/{ReviewsPage-OUUEO3XC.js.map → ReviewsPage-HPTWKBPH.js.map} +1 -1
  59. package/dist/{SeoCartWidget-TKQPPASG.js → SeoCartWidget-KBEVGXJI.js} +17 -17
  60. package/dist/{SeoCartWidget-TKQPPASG.js.map → SeoCartWidget-KBEVGXJI.js.map} +1 -1
  61. package/dist/{SettingsPage-VIRPJ2FB.js → SettingsPage-Q52PZLUI.js} +17 -17
  62. package/dist/{SettingsPage-VIRPJ2FB.js.map → SettingsPage-Q52PZLUI.js.map} +1 -1
  63. package/dist/{StoreClosedNotification-SXRGM42Z.js → StoreClosedNotification-PTZVNCCV.js} +18 -18
  64. package/dist/{StoreClosedNotification-SXRGM42Z.js.map → StoreClosedNotification-PTZVNCCV.js.map} +1 -1
  65. package/dist/{TestimonialsPage-MFRJFBBZ.js → TestimonialsPage-BZEUUKNO.js} +3 -3
  66. package/dist/{TestimonialsPage-MFRJFBBZ.js.map → TestimonialsPage-BZEUUKNO.js.map} +1 -1
  67. package/dist/{ThankYouPage-M656TZDL.js → ThankYouPage-RFY2WWN5.js} +17 -17
  68. package/dist/{ThankYouPage-M656TZDL.js.map → ThankYouPage-RFY2WWN5.js.map} +1 -1
  69. package/dist/{WalletPage-RYZACLWW.js → WalletPage-MF2DTE3D.js} +18 -18
  70. package/dist/{WalletPage-RYZACLWW.js.map → WalletPage-MF2DTE3D.js.map} +1 -1
  71. package/dist/{WebMcpTools-75A7UJP2.js → WebMcpTools-FRDG7FRV.js} +5 -5
  72. package/dist/{WebMcpTools-75A7UJP2.js.map → WebMcpTools-FRDG7FRV.js.map} +1 -1
  73. package/dist/{WishlistPage-ICTLFZPO.js → WishlistPage-K2MI4KFF.js} +19 -19
  74. package/dist/{WishlistPage-ICTLFZPO.js.map → WishlistPage-K2MI4KFF.js.map} +1 -1
  75. package/dist/api/advertisement.js +2 -2
  76. package/dist/api/apps.js +2 -2
  77. package/dist/api/blog.js +3 -3
  78. package/dist/api/brands.js +3 -3
  79. package/dist/api/cart.js +3 -3
  80. package/dist/api/category.js +3 -3
  81. package/dist/api/client.js +1 -1
  82. package/dist/api/custom-url.js +2 -2
  83. package/dist/api/home.js +2 -2
  84. package/dist/api/loyalty.js +3 -3
  85. package/dist/api/menu.js +2 -2
  86. package/dist/api/notification.js +2 -2
  87. package/dist/api/order.js +3 -3
  88. package/dist/api/page.js +3 -3
  89. package/dist/api/product.js +3 -3
  90. package/dist/api/profile.js +1 -1
  91. package/dist/api/store.js +2 -2
  92. package/dist/api/translations.js +2 -2
  93. package/dist/api/user.js +2 -2
  94. package/dist/api/wallet.js +2 -2
  95. package/dist/api/wishlist.js +4 -4
  96. package/dist/{chunk-MUJEGFLE.js → chunk-2DUC5HPY.js} +3 -3
  97. package/dist/{chunk-MUJEGFLE.js.map → chunk-2DUC5HPY.js.map} +1 -1
  98. package/dist/{chunk-AVJSCOYE.js → chunk-4IISS5KO.js} +3 -3
  99. package/dist/{chunk-AVJSCOYE.js.map → chunk-4IISS5KO.js.map} +1 -1
  100. package/dist/{chunk-YXSKW2QR.js → chunk-5B23EENL.js} +3 -3
  101. package/dist/{chunk-YXSKW2QR.js.map → chunk-5B23EENL.js.map} +1 -1
  102. package/dist/{chunk-VBXLB7A2.js → chunk-6FAUK2WT.js} +4 -4
  103. package/dist/{chunk-VBXLB7A2.js.map → chunk-6FAUK2WT.js.map} +1 -1
  104. package/dist/{chunk-H3PNVKBQ.js → chunk-6KARAWOF.js} +4 -4
  105. package/dist/{chunk-H3PNVKBQ.js.map → chunk-6KARAWOF.js.map} +1 -1
  106. package/dist/{chunk-YB6QLCDQ.js → chunk-6RWMVAOC.js} +5 -5
  107. package/dist/{chunk-YB6QLCDQ.js.map → chunk-6RWMVAOC.js.map} +1 -1
  108. package/dist/{chunk-GTNCHLXK.js → chunk-7326LK5W.js} +3 -3
  109. package/dist/{chunk-GTNCHLXK.js.map → chunk-7326LK5W.js.map} +1 -1
  110. package/dist/{chunk-NAZ7AXD3.js → chunk-7CZXUN6C.js} +5 -5
  111. package/dist/{chunk-NAZ7AXD3.js.map → chunk-7CZXUN6C.js.map} +1 -1
  112. package/dist/{chunk-FD4QTGWX.js → chunk-7XEF3ITQ.js} +3 -3
  113. package/dist/{chunk-FD4QTGWX.js.map → chunk-7XEF3ITQ.js.map} +1 -1
  114. package/dist/{chunk-TZ3DCT3S.js → chunk-BUXWWPX4.js} +3 -3
  115. package/dist/{chunk-TZ3DCT3S.js.map → chunk-BUXWWPX4.js.map} +1 -1
  116. package/dist/{chunk-Z7SE66QV.js → chunk-C2MAZFIT.js} +3 -3
  117. package/dist/{chunk-Z7SE66QV.js.map → chunk-C2MAZFIT.js.map} +1 -1
  118. package/dist/{chunk-OVYHHD2Q.js → chunk-CBZR37Z7.js} +3 -3
  119. package/dist/{chunk-OVYHHD2Q.js.map → chunk-CBZR37Z7.js.map} +1 -1
  120. package/dist/{chunk-WFTPOJUF.js → chunk-DGPHTEZE.js} +4 -4
  121. package/dist/{chunk-WFTPOJUF.js.map → chunk-DGPHTEZE.js.map} +1 -1
  122. package/dist/{chunk-3CZYFTKP.js → chunk-DIYLHIAT.js} +3 -3
  123. package/dist/{chunk-3CZYFTKP.js.map → chunk-DIYLHIAT.js.map} +1 -1
  124. package/dist/{chunk-XHXOKYMY.js → chunk-E22CFO2G.js} +4 -4
  125. package/dist/{chunk-XHXOKYMY.js.map → chunk-E22CFO2G.js.map} +1 -1
  126. package/dist/{chunk-MDI42JZX.js → chunk-E42GOEFC.js} +4 -4
  127. package/dist/{chunk-MDI42JZX.js.map → chunk-E42GOEFC.js.map} +1 -1
  128. package/dist/{chunk-UBU4OIGW.js → chunk-EJNBREFC.js} +2 -2
  129. package/dist/{chunk-UBU4OIGW.js.map → chunk-EJNBREFC.js.map} +1 -1
  130. package/dist/{chunk-4EAQH3WA.js → chunk-ENA4XT5H.js} +4 -4
  131. package/dist/{chunk-4EAQH3WA.js.map → chunk-ENA4XT5H.js.map} +1 -1
  132. package/dist/{chunk-QD3RBSKF.js → chunk-F27WIIXS.js} +14 -14
  133. package/dist/{chunk-QD3RBSKF.js.map → chunk-F27WIIXS.js.map} +1 -1
  134. package/dist/{chunk-V323S3U7.js → chunk-GAZBRWMD.js} +4 -4
  135. package/dist/{chunk-V323S3U7.js.map → chunk-GAZBRWMD.js.map} +1 -1
  136. package/dist/{chunk-P5AFKVVA.js → chunk-HMPWFSWG.js} +4 -4
  137. package/dist/{chunk-P5AFKVVA.js.map → chunk-HMPWFSWG.js.map} +1 -1
  138. package/dist/{chunk-6O2TYPUP.js → chunk-HYARGOSU.js} +3 -3
  139. package/dist/{chunk-6O2TYPUP.js.map → chunk-HYARGOSU.js.map} +1 -1
  140. package/dist/{chunk-E5HVD4JY.js → chunk-HZECUTW5.js} +4 -4
  141. package/dist/{chunk-E5HVD4JY.js.map → chunk-HZECUTW5.js.map} +1 -1
  142. package/dist/{chunk-NSCZTGJU.js → chunk-IIWQCEAD.js} +3 -3
  143. package/dist/{chunk-NSCZTGJU.js.map → chunk-IIWQCEAD.js.map} +1 -1
  144. package/dist/{chunk-6QEKTZWT.js → chunk-IOQLDBXY.js} +6 -6
  145. package/dist/{chunk-6QEKTZWT.js.map → chunk-IOQLDBXY.js.map} +1 -1
  146. package/dist/{chunk-FY36SODO.js → chunk-JBKUYGDE.js} +3 -3
  147. package/dist/{chunk-FY36SODO.js.map → chunk-JBKUYGDE.js.map} +1 -1
  148. package/dist/{chunk-5DRX6ZKG.js → chunk-JR5EDVZU.js} +3 -3
  149. package/dist/{chunk-5DRX6ZKG.js.map → chunk-JR5EDVZU.js.map} +1 -1
  150. package/dist/{chunk-YUTDUIB5.js → chunk-JY4EI4ZA.js} +3 -3
  151. package/dist/{chunk-YUTDUIB5.js.map → chunk-JY4EI4ZA.js.map} +1 -1
  152. package/dist/{chunk-KYOGYOMA.js → chunk-K5EIRY5R.js} +4 -4
  153. package/dist/{chunk-KYOGYOMA.js.map → chunk-K5EIRY5R.js.map} +1 -1
  154. package/dist/{chunk-V6ZHJMFD.js → chunk-KM3KK4KZ.js} +4 -4
  155. package/dist/{chunk-V6ZHJMFD.js.map → chunk-KM3KK4KZ.js.map} +1 -1
  156. package/dist/{chunk-I6FORV4B.js → chunk-KUROVEJP.js} +3 -3
  157. package/dist/{chunk-I6FORV4B.js.map → chunk-KUROVEJP.js.map} +1 -1
  158. package/dist/{chunk-AUFCS374.js → chunk-KVEINIFK.js} +4 -4
  159. package/dist/{chunk-AUFCS374.js.map → chunk-KVEINIFK.js.map} +1 -1
  160. package/dist/{chunk-7IL5RSR5.js → chunk-LC3M4HW7.js} +3 -3
  161. package/dist/{chunk-7IL5RSR5.js.map → chunk-LC3M4HW7.js.map} +1 -1
  162. package/dist/{chunk-EWK6SZPV.js → chunk-OVRXYL5B.js} +4 -4
  163. package/dist/{chunk-EWK6SZPV.js.map → chunk-OVRXYL5B.js.map} +1 -1
  164. package/dist/{chunk-Q7FJ4XKY.js → chunk-P3E64ITB.js} +7 -7
  165. package/dist/{chunk-Q7FJ4XKY.js.map → chunk-P3E64ITB.js.map} +1 -1
  166. package/dist/{chunk-5ZARPSEZ.js → chunk-P5BIPOJ4.js} +3 -3
  167. package/dist/{chunk-5ZARPSEZ.js.map → chunk-P5BIPOJ4.js.map} +1 -1
  168. package/dist/{chunk-3FGCLNM6.js → chunk-PWUOIH5V.js} +7 -7
  169. package/dist/{chunk-3FGCLNM6.js.map → chunk-PWUOIH5V.js.map} +1 -1
  170. package/dist/{chunk-EEZQQMD4.js → chunk-RFPIGVAO.js} +4 -4
  171. package/dist/{chunk-EEZQQMD4.js.map → chunk-RFPIGVAO.js.map} +1 -1
  172. package/dist/{chunk-5XM72SGI.js → chunk-SF5AFS3A.js} +4 -4
  173. package/dist/{chunk-5XM72SGI.js.map → chunk-SF5AFS3A.js.map} +1 -1
  174. package/dist/{chunk-VRXZFMMN.js → chunk-SIDYR6LZ.js} +4 -4
  175. package/dist/{chunk-VRXZFMMN.js.map → chunk-SIDYR6LZ.js.map} +1 -1
  176. package/dist/{chunk-P3OYCAO3.js → chunk-SL4VKTNK.js} +5 -5
  177. package/dist/{chunk-P3OYCAO3.js.map → chunk-SL4VKTNK.js.map} +1 -1
  178. package/dist/{chunk-6H6QX2XF.js → chunk-TH6HPT3K.js} +7 -7
  179. package/dist/{chunk-6H6QX2XF.js.map → chunk-TH6HPT3K.js.map} +1 -1
  180. package/dist/{chunk-WOIUGEN7.js → chunk-UM3G3Q25.js} +3 -3
  181. package/dist/{chunk-WOIUGEN7.js.map → chunk-UM3G3Q25.js.map} +1 -1
  182. package/dist/{chunk-6DTT6DFS.js → chunk-V4ZRPTFE.js} +20 -20
  183. package/dist/chunk-V4ZRPTFE.js.map +1 -0
  184. package/dist/{chunk-DBFVTN4C.js → chunk-VIUK32MB.js} +3 -3
  185. package/dist/{chunk-DBFVTN4C.js.map → chunk-VIUK32MB.js.map} +1 -1
  186. package/dist/{chunk-7557N22C.js → chunk-XCWRUMLQ.js} +4 -4
  187. package/dist/{chunk-7557N22C.js.map → chunk-XCWRUMLQ.js.map} +1 -1
  188. package/dist/{chunk-SD3XCDUI.js → chunk-Y7SL553A.js} +3 -3
  189. package/dist/{chunk-SD3XCDUI.js.map → chunk-Y7SL553A.js.map} +1 -1
  190. package/dist/{chunk-G4XPYZ4D.js → chunk-YZVWVS3N.js} +3 -3
  191. package/dist/{chunk-G4XPYZ4D.js.map → chunk-YZVWVS3N.js.map} +1 -1
  192. package/dist/{chunk-CTU6VJN7.js → chunk-ZC5TVFLI.js} +3 -3
  193. package/dist/{chunk-CTU6VJN7.js.map → chunk-ZC5TVFLI.js.map} +1 -1
  194. package/dist/{chunk-XTJ45UWF.js → chunk-ZLKCJBF7.js} +5 -5
  195. package/dist/{chunk-XTJ45UWF.js.map → chunk-ZLKCJBF7.js.map} +1 -1
  196. package/dist/components/cart/index.js +1 -1
  197. package/dist/components/common/index.js +1 -1
  198. package/dist/components/drawer/index.js +15 -15
  199. package/dist/components/home/index.js +20 -20
  200. package/dist/components/layout/index.js +4 -4
  201. package/dist/components/product/index.js +17 -17
  202. package/dist/components/store/index.js +16 -16
  203. package/dist/components/tracking/index.js +6 -6
  204. package/dist/{custom-urls-762MPX4D.js → custom-urls-QAOALCNQ.js} +7 -7
  205. package/dist/{custom-urls-762MPX4D.js.map → custom-urls-QAOALCNQ.js.map} +1 -1
  206. package/dist/dev/editor/index.js +1 -1
  207. package/dist/dev/index.js +1 -1
  208. package/dist/{document-class-FVT5XMGM.js → document-class-SMU7XYXA.js} +17 -17
  209. package/dist/{document-class-FVT5XMGM.js.map → document-class-SMU7XYXA.js.map} +1 -1
  210. package/dist/hooks/index.js +15 -15
  211. package/dist/hooks/useGtm.js +15 -15
  212. package/dist/hooks/useMoney.d.ts.map +1 -1
  213. package/dist/hooks/useMoney.js +15 -15
  214. package/dist/hooks/useStore.js +15 -15
  215. package/dist/hooks/useUser.js +3 -3
  216. package/dist/index.js +15 -15
  217. package/dist/{navigation-TG3EJBXL.js → navigation-2SB3WXJN.js} +4 -4
  218. package/dist/{navigation-TG3EJBXL.js.map → navigation-2SB3WXJN.js.map} +1 -1
  219. package/dist/{navigation-GU5SVIEI.js → navigation-DAGDU4UL.js} +5 -5
  220. package/dist/{navigation-GU5SVIEI.js.map → navigation-DAGDU4UL.js.map} +1 -1
  221. package/dist/{not-found-SPUNA3MH.js → not-found-25S7XQ6X.js} +18 -18
  222. package/dist/{not-found-SPUNA3MH.js.map → not-found-25S7XQ6X.js.map} +1 -1
  223. package/dist/providers/index.js +15 -15
  224. package/dist/routes/account/orders.js +4 -4
  225. package/dist/routes/account.js +13 -13
  226. package/dist/routes/blog.js +8 -8
  227. package/dist/routes/brands.js +4 -4
  228. package/dist/routes/cart.js +25 -25
  229. package/dist/routes/home.js +21 -21
  230. package/dist/routes/index.js +8 -8
  231. package/dist/routes/loyalty.js +5 -5
  232. package/dist/routes/page.js +4 -4
  233. package/dist/routes/product-listing.js +25 -25
  234. package/dist/routes/product.js +24 -24
  235. package/dist/routes/seo-redirects.js +8 -8
  236. package/dist/routes/testimonials.js +2 -2
  237. package/dist/routes/thank-you.js +4 -4
  238. package/dist/skeleton.js +23 -23
  239. package/dist/{store-lookup-5SQT7FXZ.js → store-lookup-ZSSUTV64.js} +8 -8
  240. package/dist/{store-lookup-5SQT7FXZ.js.map → store-lookup-ZSSUTV64.js.map} +1 -1
  241. package/dist/tanstack.js +17 -17
  242. package/dist/utils/index.js +2 -2
  243. package/package.json +1 -1
  244. package/tailwind/routes/account/orders/single/OrderItemRow.tsx.txt +2 -2
  245. package/dist/GoogleTag-OPCZNE4C.js +0 -15
  246. package/dist/chunk-6DTT6DFS.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":["id"],"mappings":";;;;;;;;AAwBA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,QAAA,CAAS,CAAA,EAAG,MAAM,CAAA,QAAA,EAAW,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,EAAE,UAAA,EAAY,GAAA,EAAK,CAAA;AACzE;AAOA,eAAsB,4BACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,8BAAA,CAAgC,CAAA;AAC3D;AAGA,eAAsB,qBACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,e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AAI,GAAG,MAAM,CAAA,CAAA,EAAI,EAAE,UAAA,EAAY,KAAK,CAAA;AAAA,EAC5F;AACA,EAAA,IAAI,CAAC,OAAA,CAAQ,WAAA,IAAe,WAAA,CAAY,QAAQ,CAAA,EAAG;AACnD,EAAA,MAAM,EAAE,iBAAA,EAAkB,GAAI,MAAM,OAAO,2BAAe,CAAA;AAC1D,EAAA,MAAM,iBAAA,CAAkB,UAAU,MAAA,EAAQ;AAAA,IACxC,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,cAAc,OAAA,CAAQ;AAAA,GACvB,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-VBXLB7A2.js","sourcesContent":["import { useEffect } from 'react';\nimport type { QueryClient } from '@tanstack/react-query';\nimport { isMissingResource, redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { productKeyOfId } from '../router/product-key-urls';\nimport { CATEGORY_SLUG_ROUTE_ID, PRODUCT_SLUG_ROUTE_ID } from '../router/slug-routes';\nimport { clearAuthTokenCookie } from '../utils/cookies';\nimport { parseShortLinkPath } from './short-link-path';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\n/**\n * Twig's brand address, `/{slug}/brand-{id}`, the one its pages link and search engines indexed,\n * moved for good to the engine's `/brands/{id}`: a 301, so the brand page keeps its ranking at the\n * new address (a 307 keeps the old one indexed). No locale in the URL stays without one: the\n * locale layout adds it only where the store has several, so a single-language store is one hop.\n */\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/brands/${ctx.params.id}`, { statusCode: 301 });\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/**\n * `/rating/{id}` and `/account/rating/{id}`: the rate-your-order link in the order email and SMS,\n * sent like Twig to the order with its rating popup. The id goes as it came: the orders API\n * decodes it the way Store's `rateOrder` does (optimus when numeric, else the hash).\n */\nexport async function orderRatingRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams & { id: string };\n /** The incoming query string, `token` included: the SDK signs the visitor in with it. */\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.set('show-rating-popup', 'true');\n throw redirect(`${prefix}/account/orders/${encodeURIComponent(ctx.params.id)}?${query}`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\nexport { resolveProductKeyPage } from './product/key';\nexport { publicProductKeyPath } from '../router/product-key-urls';\n\n/** Routes a Twig URL lands on by accident: a locale bound as `$slug`, or an id that is no number. */\nconst SLUG_ROUTES = new Set([PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID]);\n\n/** `/p{id}` or `/p{id}-{name}`, with or without a leading segment; the id capped as in `./product/id`. */\nconst TWIG_PRODUCT_URL = /^(?:\\/([^/]+))?\\/p(\\d{1,18})(?:-[^/]*)?\\/?$/;\n/** `/category/{hash}`, with or without a leading segment. */\nconst TWIG_CATEGORY_URL = /^(?:\\/([^/]+))?\\/category\\/([A-Za-z0-9]+)\\/?$/;\n/**\n * `/p/{slug}`, with or without a leading segment: Twig's page address (`PageController@show`), the\n * one a store without SEO URLs lists in its sitemap. Twig renders it there, or 301s it to the page's\n * `/{slug}/page-{id}` on a store with SEO URLs.\n */\nconst TWIG_PAGE_URL = /^(?:\\/([^/]+))?\\/p\\/([^/]+)\\/?$/;\n\n/** The page the router matched, as the locale layout's `beforeLoad` sees it. */\nexport interface MatchedPage {\n routeId: string;\n params: Record<string, string | undefined>;\n}\n\nfunction rendersNoPage({ routeId, params }: MatchedPage): boolean {\n // A first segment that is no language binds as the locale, of the layout or of the home page.\n if (routeId === '/{-$locale}' || (params.locale && !isLocale(params.locale))) return true;\n if (!SLUG_ROUTES.has(routeId)) return false;\n // A SKU-link address the router's rewrite gave the product route (`router/product-key-urls`).\n if (productKeyOfId(params.id)) return false;\n return (!params.locale && isLocale(params.slug)) || !/^\\d+$/.test(params.id ?? '');\n}\n\nexport interface TwigUrlRedirectOptions {\n /**\n * The language segment the target takes, given the one the address had. The locale layout\n * knows how the store addresses its pages, so the redirect lands there in one hop: `/-/p1`\n * on a store with several languages was sent on again to `/ar/-/p1`, and that second request\n * also fetched the product, because the server starts every loader at once. Without it the\n * address's own segment is kept.\n */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n /**\n * The request's query client. The category lookup is then shared between a hover preload and\n * the click.\n */\n queryClient?: QueryClient;\n}\n\n/** The category's numeric id for its Twig hash, or `undefined` when the API has no such category. */\nasync function categoryIdOf(hash: string, queryClient?: QueryClient): Promise<string | undefined> {\n const { category } = await import('../api/category');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(category.queries.detail(hash))\n : await category.find(hash);\n // Only the id is taken. The category is never filed under its id for the category page:\n // this lookup ran in the address's language (Arabic when it has none, the fallback), and\n // the page may be in another (`/en/-/c…` on an English-only store), while a category's\n // cache key carries no language.\n return String(found.id_ ?? found.id);\n } catch (error) {\n if (isMissingResource(error)) return undefined;\n throw error;\n }\n}\n\n/**\n * The product id behind a short link (`/KjQrpE`). A store without SEO URLs gives every product\n * that address, in its sitemap and in the API's `url`, and the API takes the code in place of\n * the id. Any failure counts as \"no such product\": a bare `/{code}` is also every scanner's\n * `/admin`, so an API error must not turn those into 500s. The not-found page's\n * `useProductShortLink` asks again from the browser, as it did before.\n */\nasync function shortLinkProductId(\n code: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { product } = await import('../api/product');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(product.queries.detail(code))\n : await product.find(code);\n return found?.id ? String(found.id) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A slug as Twig compares it: decoded, trimmed, case aside. */\nfunction comparableSlug(slug: string): string {\n let decoded = slug;\n try {\n decoded = decodeURIComponent(slug);\n } catch {\n // Not percent-encoded as a whole: compared as it came.\n }\n return decoded.trim().toLowerCase();\n}\n\n/**\n * The address of the page Twig calls `/p/{slug}`, found in the store's page list by its slug (the\n * page API takes only an id). Any failure counts as \"no such page\", as for a short link: the\n * address then stays the not-found page, after the merchant's custom URLs are asked.\n */\nasync function legacyPagePath(\n slug: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { page } = await import('../api/page');\n try {\n const pages = queryClient\n ? await queryClient.ensureQueryData(page.queries.list())\n : await page.list();\n const wanted = comparableSlug(slug);\n const found = pages.find((listed) => listed.slug && comparableSlug(listed.slug) === wanted);\n return found ? `/${encodeURIComponent(found.slug.trim())}/page-${found.id}` : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Where a Twig URL's page is now, and the language its address carried. */\n/**\n * A Twig product or category URL: `/p{id}…` or `/category/{hash}`, bare or under a language. Under\n * any other first segment it is no Twig route, so the Store's catch-all would have it.\n */\nfunction twigPageUrl(\n pathname: string\n): { kind: 'p' | 'c'; ref: string; locale?: string } | undefined {\n const productUrl = TWIG_PRODUCT_URL.exec(pathname);\n const match = productUrl ?? TWIG_CATEGORY_URL.exec(pathname);\n if (!match || (match[1] && !isLocale(match[1]))) return undefined;\n return { kind: productUrl ? 'p' : 'c', ref: match[2], locale: match[1] };\n}\n\nasync function twigTarget(\n pathname: string,\n queryClient?: QueryClient\n): Promise<{ path: string; locale?: string } | undefined> {\n const pageUrl = twigPageUrl(pathname);\n if (pageUrl) {\n if (pageUrl.kind === 'p') return { path: `/-/p${pageUrl.ref}`, locale: pageUrl.locale };\n const id = await categoryIdOf(pageUrl.ref, queryClient);\n return id ? { path: `/-/c${id}`, locale: pageUrl.locale } : undefined;\n }\n const legacyPage = TWIG_PAGE_URL.exec(pathname);\n if (legacyPage && (!legacyPage[1] || isLocale(legacyPage[1]))) {\n const path = await legacyPagePath(legacyPage[2], queryClient);\n return path ? { path, locale: legacyPage[1] } : undefined;\n }\n const shortLink = parseShortLinkPath(pathname);\n if (!shortLink) return undefined;\n const id = await shortLinkProductId(shortLink.code, queryClient);\n return id ? { path: `/-/p${id}`, locale: shortLink.locale } : undefined;\n}\n\n/**\n * Twig's product, category and page URLs, each with or without a locale, sent to the page that\n * has them now: `/p{id}`, `/p{id}-{name}`, `/category/{hash}`, the product short link `/{code}` and\n * a page's `/p/{slug}`.\n * Run by the locale layout's `beforeLoad`, only for an address no page answers: the router binds\n * `/ar/p1` to `$slug/p{$id}` (slug `ar`) and `/p1` to the locale.\n *\n * A product URL carries its id, so it is redirected without asking the API: a product that is\n * gone is the product page's not-found, one hop on. A category hash or a short code only the API\n * can turn into the id; one that is gone stays the not-found page at its address.\n *\n * Any other address no page answers, a short code that names no product included, may be one of\n * the merchant's custom URLs, which Twig's catch-all answers last (`./custom-urls`). A gone\n * category's Twig URL is not: Twig's category route answers it.\n */\nexport async function twigUrlRedirect(\n pathname: string,\n search: string,\n page: MatchedPage | undefined,\n options: TwigUrlRedirectOptions = {}\n): Promise<void> {\n if (!page || !rendersNoPage(page)) return;\n const target = await twigTarget(pathname, options.queryClient);\n if (target) {\n const locale = options.targetLocale ? await options.targetLocale(target.locale) : target.locale;\n throw redirect(`${locale ? `/${locale}` : ''}${target.path}${search}`, { statusCode: 301 });\n }\n if (!options.queryClient || twigPageUrl(pathname)) return;\n const { customUrlRedirect } = await import('./custom-urls');\n await customUrlRedirect(pathname, search, {\n queryClient: options.queryClient,\n targetLocale: options.targetLocale,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":["id"],"mappings":";;;;;;;;AAwBA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,QAAA,CAAS,CAAA,EAAG,MAAM,CAAA,QAAA,EAAW,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,EAAE,UAAA,EAAY,GAAA,EAAK,CAAA;AACzE;AAOA,eAAsB,4BACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,8BAAA,CAAgC,CAAA;AAC3D;AAGA,eAAsB,qBACpB,GAAA,GAA+C,EAAE,MAAA,EAAQ,IAAG,EAC5C;AAChB,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,QAAA,CAAS,CAAA,CAAA,EAAI,MAAM,CAAA,eAAA,CAAiB,CAAA;AAC5C;AAOA,eAAsB,0BAA0B,GAAA,EAI7B;AACjB,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,MAAA,GAAS,IAAI,GAAA,CAAI,MAAA,CAAO,MAAM,CAAA,CAAA,GAAK,EAAA;AAC7D,EAAA,MAAM,KAAA,GAAQ,IAAI,eAAA,CAAgB,GAAA,CAAI,MAAM,CAAA;AAC5C,EAAA,KAAA,CAAM,GAAA,C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xC,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,cAAc,OAAA,CAAQ;AAAA,GACvB,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-6FAUK2WT.js","sourcesContent":["import { useEffect } from 'react';\nimport type { QueryClient } from '@tanstack/react-query';\nimport { isMissingResource, redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { productKeyOfId } from '../router/product-key-urls';\nimport { CATEGORY_SLUG_ROUTE_ID, PRODUCT_SLUG_ROUTE_ID } from '../router/slug-routes';\nimport { clearAuthTokenCookie } from '../utils/cookies';\nimport { parseShortLinkPath } from './short-link-path';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\n/**\n * Twig's brand address, `/{slug}/brand-{id}`, the one its pages link and search engines indexed,\n * moved for good to the engine's `/brands/{id}`: a 301, so the brand page keeps its ranking at the\n * new address (a 307 keeps the old one indexed). No locale in the URL stays without one: the\n * locale layout adds it only where the store has several, so a single-language store is one hop.\n */\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/brands/${ctx.params.id}`, { statusCode: 301 });\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/**\n * `/rating/{id}` and `/account/rating/{id}`: the rate-your-order link in the order email and SMS,\n * sent like Twig to the order with its rating popup. The id goes as it came: the orders API\n * decodes it the way Store's `rateOrder` does (optimus when numeric, else the hash).\n */\nexport async function orderRatingRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams & { id: string };\n /** The incoming query string, `token` included: the SDK signs the visitor in with it. */\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.set('show-rating-popup', 'true');\n throw redirect(`${prefix}/account/orders/${encodeURIComponent(ctx.params.id)}?${query}`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\nexport { resolveProductKeyPage } from './product/key';\nexport { publicProductKeyPath } from '../router/product-key-urls';\n\n/** Routes a Twig URL lands on by accident: a locale bound as `$slug`, or an id that is no number. */\nconst SLUG_ROUTES = new Set([PRODUCT_SLUG_ROUTE_ID, CATEGORY_SLUG_ROUTE_ID]);\n\n/** `/p{id}` or `/p{id}-{name}`, with or without a leading segment; the id capped as in `./product/id`. */\nconst TWIG_PRODUCT_URL = /^(?:\\/([^/]+))?\\/p(\\d{1,18})(?:-[^/]*)?\\/?$/;\n/** `/category/{hash}`, with or without a leading segment. */\nconst TWIG_CATEGORY_URL = /^(?:\\/([^/]+))?\\/category\\/([A-Za-z0-9]+)\\/?$/;\n/**\n * `/p/{slug}`, with or without a leading segment: Twig's page address (`PageController@show`), the\n * one a store without SEO URLs lists in its sitemap. Twig renders it there, or 301s it to the page's\n * `/{slug}/page-{id}` on a store with SEO URLs.\n */\nconst TWIG_PAGE_URL = /^(?:\\/([^/]+))?\\/p\\/([^/]+)\\/?$/;\n\n/** The page the router matched, as the locale layout's `beforeLoad` sees it. */\nexport interface MatchedPage {\n routeId: string;\n params: Record<string, string | undefined>;\n}\n\nfunction rendersNoPage({ routeId, params }: MatchedPage): boolean {\n // A first segment that is no language binds as the locale, of the layout or of the home page.\n if (routeId === '/{-$locale}' || (params.locale && !isLocale(params.locale))) return true;\n if (!SLUG_ROUTES.has(routeId)) return false;\n // A SKU-link address the router's rewrite gave the product route (`router/product-key-urls`).\n if (productKeyOfId(params.id)) return false;\n return (!params.locale && isLocale(params.slug)) || !/^\\d+$/.test(params.id ?? '');\n}\n\nexport interface TwigUrlRedirectOptions {\n /**\n * The language segment the target takes, given the one the address had. The locale layout\n * knows how the store addresses its pages, so the redirect lands there in one hop: `/-/p1`\n * on a store with several languages was sent on again to `/ar/-/p1`, and that second request\n * also fetched the product, because the server starts every loader at once. Without it the\n * address's own segment is kept.\n */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n /**\n * The request's query client. The category lookup is then shared between a hover preload and\n * the click.\n */\n queryClient?: QueryClient;\n}\n\n/** The category's numeric id for its Twig hash, or `undefined` when the API has no such category. */\nasync function categoryIdOf(hash: string, queryClient?: QueryClient): Promise<string | undefined> {\n const { category } = await import('../api/category');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(category.queries.detail(hash))\n : await category.find(hash);\n // Only the id is taken. The category is never filed under its id for the category page:\n // this lookup ran in the address's language (Arabic when it has none, the fallback), and\n // the page may be in another (`/en/-/c…` on an English-only store), while a category's\n // cache key carries no language.\n return String(found.id_ ?? found.id);\n } catch (error) {\n if (isMissingResource(error)) return undefined;\n throw error;\n }\n}\n\n/**\n * The product id behind a short link (`/KjQrpE`). A store without SEO URLs gives every product\n * that address, in its sitemap and in the API's `url`, and the API takes the code in place of\n * the id. Any failure counts as \"no such product\": a bare `/{code}` is also every scanner's\n * `/admin`, so an API error must not turn those into 500s. The not-found page's\n * `useProductShortLink` asks again from the browser, as it did before.\n */\nasync function shortLinkProductId(\n code: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { product } = await import('../api/product');\n try {\n const found = queryClient\n ? await queryClient.ensureQueryData(product.queries.detail(code))\n : await product.find(code);\n return found?.id ? String(found.id) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A slug as Twig compares it: decoded, trimmed, case aside. */\nfunction comparableSlug(slug: string): string {\n let decoded = slug;\n try {\n decoded = decodeURIComponent(slug);\n } catch {\n // Not percent-encoded as a whole: compared as it came.\n }\n return decoded.trim().toLowerCase();\n}\n\n/**\n * The address of the page Twig calls `/p/{slug}`, found in the store's page list by its slug (the\n * page API takes only an id). Any failure counts as \"no such page\", as for a short link: the\n * address then stays the not-found page, after the merchant's custom URLs are asked.\n */\nasync function legacyPagePath(\n slug: string,\n queryClient?: QueryClient\n): Promise<string | undefined> {\n const { page } = await import('../api/page');\n try {\n const pages = queryClient\n ? await queryClient.ensureQueryData(page.queries.list())\n : await page.list();\n const wanted = comparableSlug(slug);\n const found = pages.find((listed) => listed.slug && comparableSlug(listed.slug) === wanted);\n return found ? `/${encodeURIComponent(found.slug.trim())}/page-${found.id}` : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Where a Twig URL's page is now, and the language its address carried. */\n/**\n * A Twig product or category URL: `/p{id}…` or `/category/{hash}`, bare or under a language. Under\n * any other first segment it is no Twig route, so the Store's catch-all would have it.\n */\nfunction twigPageUrl(\n pathname: string\n): { kind: 'p' | 'c'; ref: string; locale?: string } | undefined {\n const productUrl = TWIG_PRODUCT_URL.exec(pathname);\n const match = productUrl ?? TWIG_CATEGORY_URL.exec(pathname);\n if (!match || (match[1] && !isLocale(match[1]))) return undefined;\n return { kind: productUrl ? 'p' : 'c', ref: match[2], locale: match[1] };\n}\n\nasync function twigTarget(\n pathname: string,\n queryClient?: QueryClient\n): Promise<{ path: string; locale?: string } | undefined> {\n const pageUrl = twigPageUrl(pathname);\n if (pageUrl) {\n if (pageUrl.kind === 'p') return { path: `/-/p${pageUrl.ref}`, locale: pageUrl.locale };\n const id = await categoryIdOf(pageUrl.ref, queryClient);\n return id ? { path: `/-/c${id}`, locale: pageUrl.locale } : undefined;\n }\n const legacyPage = TWIG_PAGE_URL.exec(pathname);\n if (legacyPage && (!legacyPage[1] || isLocale(legacyPage[1]))) {\n const path = await legacyPagePath(legacyPage[2], queryClient);\n return path ? { path, locale: legacyPage[1] } : undefined;\n }\n const shortLink = parseShortLinkPath(pathname);\n if (!shortLink) return undefined;\n const id = await shortLinkProductId(shortLink.code, queryClient);\n return id ? { path: `/-/p${id}`, locale: shortLink.locale } : undefined;\n}\n\n/**\n * Twig's product, category and page URLs, each with or without a locale, sent to the page that\n * has them now: `/p{id}`, `/p{id}-{name}`, `/category/{hash}`, the product short link `/{code}` and\n * a page's `/p/{slug}`.\n * Run by the locale layout's `beforeLoad`, only for an address no page answers: the router binds\n * `/ar/p1` to `$slug/p{$id}` (slug `ar`) and `/p1` to the locale.\n *\n * A product URL carries its id, so it is redirected without asking the API: a product that is\n * gone is the product page's not-found, one hop on. A category hash or a short code only the API\n * can turn into the id; one that is gone stays the not-found page at its address.\n *\n * Any other address no page answers, a short code that names no product included, may be one of\n * the merchant's custom URLs, which Twig's catch-all answers last (`./custom-urls`). A gone\n * category's Twig URL is not: Twig's category route answers it.\n */\nexport async function twigUrlRedirect(\n pathname: string,\n search: string,\n page: MatchedPage | undefined,\n options: TwigUrlRedirectOptions = {}\n): Promise<void> {\n if (!page || !rendersNoPage(page)) return;\n const target = await twigTarget(pathname, options.queryClient);\n if (target) {\n const locale = options.targetLocale ? await options.targetLocale(target.locale) : target.locale;\n throw redirect(`${locale ? `/${locale}` : ''}${target.path}${search}`, { statusCode: 301 });\n }\n if (!options.queryClient || twigPageUrl(pathname)) return;\n const { customUrlRedirect } = await import('./custom-urls');\n await customUrlRedirect(pathname, search, {\n queryClient: options.queryClient,\n targetLocale: options.targetLocale,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow, orUnauthorized } from './chunk-I6FORV4B.js';
2
- import { api } from './chunk-7IL5RSR5.js';
1
+ import { orThrow, orUnauthorized } from './chunk-KUROVEJP.js';
2
+ import { api } from './chunk-LC3M4HW7.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  async function twilightShape(path) {
@@ -89,5 +89,5 @@ var order = {
89
89
  };
90
90
 
91
91
  export { order };
92
- //# sourceMappingURL=chunk-H3PNVKBQ.js.map
93
- //# sourceMappingURL=chunk-H3PNVKBQ.js.map
92
+ //# sourceMappingURL=chunk-6KARAWOF.js.map
93
+ //# sourceMappingURL=chunk-6KARAWOF.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/order.ts"],"names":[],"mappings":";;;;AAqDA,eAAe,cAAc,IAAA,EAAsC;AACjE,EAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,IAAA,EAAM;AAAA,IACT,KAAA,EAAO;AAAA;AAAA,MAEL,aAAA,EAAe,CAAC,CAAC,EAAE,OAAA,OAAc,OAAA,CAAQ,OAAA,CAAQ,MAAA,CAAO,cAAc,CAAC;AAAA;AACzE,GACD,EACA,IAAA,EAA8B;AACjC,EAAA,OAAO,QAAA,CAAS,IAAA;AAClB;AAEO,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;AAAA,MACZ;AAAA,KACF,GAAI,UAAU,EAAC;AAEf,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,IAAI,SAAS,MAAA,EAAW,YAAA,CAAa,IAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AAC7D,IAAA,IAAI,MAAA,EAAQ,YAAA,CAAa,GAAA,CAAI,QAAA,EAAU,MAAM,CAAA;AAC7C,IAAA,IAAI,MAAA,EAAQ,YAAA,CAAa,GAAA,CAAI,QAAA,EAAU,MAAM,CAAA;AAC7C,IAAA,IAAI,cAAA,EA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AM,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-H3PNVKBQ.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\n/** Reads an order path without `s-theme-type`, so the API answers in the Twilight components' shape. */\nasync function twilightShape(path: string): Promise<TwilightOrder> {\n const response = await api\n .get(path, {\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\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> => twilightShape(`orders/${id}`),\n\n /**\n * The order the thank-you page renders, `orders/{id}/thank-you`: the same payload as `find`, but a guest\n * (no customer token) may read it for the short window after checkout the Twig thank-you page allows.\n */\n findForThankYou: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}/thank-you`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n /** `findForThankYou` in the Twilight components' shape, as `findForComponents` is to `find`. */\n findForThankYouComponents: async (id: string): Promise<TwilightOrder> =>\n twilightShape(`orders/${id}/thank-you`),\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":";;;;AAqDA,eAAe,cAAc,IAAA,EAAsC;AACjE,EAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,IAAA,EAAM;AAAA,IACT,KAAA,EAAO;AAAA;AAAA,MAEL,aAAA,EAAe,CAAC,CAAC,EAAE,OAAA,OAAc,OAAA,CAAQ,OAAA,CAAQ,MAAA,CAAO,cAAc,CAAC;AAAA;A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AM,QAAA,CAAS,OAAO;AAAA,KACtC;AAAA;AAEP","file":"chunk-6KARAWOF.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\n/** Reads an order path without `s-theme-type`, so the API answers in the Twilight components' shape. */\nasync function twilightShape(path: string): Promise<TwilightOrder> {\n const response = await api\n .get(path, {\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\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> => twilightShape(`orders/${id}`),\n\n /**\n * The order the thank-you page renders, `orders/{id}/thank-you`: the same payload as `find`, but a guest\n * (no customer token) may read it for the short window after checkout the Twig thank-you page allows.\n */\n findForThankYou: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}/thank-you`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n /** `findForThankYou` in the Twilight components' shape, as `findForComponents` is to `find`. */\n findForThankYouComponents: async (id: string): Promise<TwilightOrder> =>\n twilightShape(`orders/${id}/thank-you`),\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,8 +1,8 @@
1
1
  import { seoField } from './chunk-MHBWYHS5.js';
2
- import { HomeComponentRenderer, ReorderProducts } from './chunk-3FGCLNM6.js';
3
- import { home } from './chunk-5DRX6ZKG.js';
2
+ import { HomeComponentRenderer, ReorderProducts } from './chunk-PWUOIH5V.js';
3
+ import { home } from './chunk-JR5EDVZU.js';
4
4
  import { useLiveBlockList, reorder, useLiveBlockMoves } from './chunk-TJK4DVQM.js';
5
- import { useDevHomeBlocks } from './chunk-5ZARPSEZ.js';
5
+ import { useDevHomeBlocks } from './chunk-P5BIPOJ4.js';
6
6
  import { storePageUrl, buildHreflangAlternates } from './chunk-EUHIN5FN.js';
7
7
  import { RouteId } from './chunk-OUW6WESU.js';
8
8
  import { HookSlot } from './chunk-XZFWBF3P.js';
@@ -136,5 +136,5 @@ function head(ctx) {
136
136
  var Home = { id: RouteId.INDEX, loader, head, Component: HomePage };
137
137
 
138
138
  export { Home, HomeSkeleton, homeLoader };
139
- //# sourceMappingURL=chunk-YB6QLCDQ.js.map
140
- //# sourceMappingURL=chunk-YB6QLCDQ.js.map
139
+ //# sourceMappingURL=chunk-6RWMVAOC.js.map
140
+ //# sourceMappingURL=chunk-6RWMVAOC.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/home/blockList.ts","../src/routes/home/loader.ts","../src/routes/home/HomePage.tsx","../src/routes/home/index.tsx"],"names":["HomeSkeleton","HomePage"],"m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MAAM,KAAA,GAAQ,IAAI,QAAA,EAAU,KAAA;AAC5B,EAAA,IAAI,CAAC,KAAA,EAAO,OAAO,EAAC;AAGpB,EAAA,MAAM,QAAQ,QAAA,CAAS,KAAA,CAAM,IAAA,EAAM,KAAA,EAAO,MAAM,IAAI,CAAA;AACpD,EAAA,MAAM,cAAc,QAAA,CAAS,KAAA,CAAM,IAAA,EAAM,WAAA,EAAa,MAAM,WAAW,CAAA;AACvE,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,KAAA,CAAM,IAAA,EAAM,UAAU,MAAS,CAAA;AAEzD,EAAA,MAAM,GAAA,GAAM,aAAa,GAAA,CAAI,QAAA,EAAU,IAAI,QAAA,CAAS,QAAQ,KAAK,KAAA,CAAM,GAAA;AAEvE,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA,EAAW,GAAA;AAAA,IACX,SAAA,EAAW;AAAA,MACT,IAAA,EAAM,SAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAQ,KAAA,CAAM,IAAA;AAAA,MACd;AAAA,KACF;AAAA,IACA,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,qBAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAQ,KAAA,CAAM;AAAA,KAChB;AAAA,IACA,oBAAoB,uBAAA,CAAwB,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,SAAS,QAAQ;AAAA,GACjF;AACF;AAEO,IAAM,IAAA,GAAO,EAAE,EAAA,EAAI,OAAA,CAAQ,OAAO,MAAA,EAAQ,IAAA,EAAM,WAAW,QAAA","file":"chunk-YB6QLCDQ.js","sourcesContent":["import type { HomeComponentData } from '../../types';\n\n/** Paths and keys of `blocks` in order: enough to tell the store's list from one a theme built. */\nexport function blockList(blocks: readonly HomeComponentData[]): string {\n return JSON.stringify(blocks.map((block) => [block.path, block.key ?? null]));\n}\n","import { getTwilightContext } from '../../twilight/context';\nimport { home } from '../../api/home';\nimport type { HomeComponentData } from '../../types';\nimport { RouteId } from '../../router/route-ids';\nimport { blockList } from './blockList';\n\nexport interface HomeLoaderData {\n locale: string;\n components: HomeComponentData[];\n page: { slug: string };\n /**\n * The store's blocks as this loader lists them (`blockList`). A theme whose own loader\n * reshapes `components` keeps this, so the page can tell its list is no longer the store's.\n */\n storeBlocks?: string;\n}\n\nexport async function homeLoader(ctx?: { locale?: string }): Promise<HomeLoaderData> {\n const { queryClient } = getTwilightContext();\n const components = await queryClient.ensureQueryData(home.queries.components());\n const blocks = components.map((comp) => ({\n ...comp,\n path: comp.path?.replace('home.', '') || comp.path,\n }));\n return {\n locale: ctx?.locale || 'ar',\n components: blocks,\n page: { slug: RouteId.INDEX },\n storeBlocks: blockList(blocks),\n };\n}\n","import { memo, useCallback, useMemo, useState } from 'react';\nimport { useDevHomeBlocks, type DevHomeBlock } from '../../dev/dev-settings-store';\nimport { HookSlot } from '../../hooks';\nimport { HomeComponentRenderer, ReorderProducts } from '../../components/home';\nimport { reorder, useLiveBlockList, useLiveBlockMoves } from '../../components/live-editor/moves';\nimport type { HomePageProps } from './types';\nimport { blockList } from './blockList';\nimport type { HomeComponentData } from '../../types';\nimport { Pulse } from '@salla.sa/twilight-components-react';\n\nexport const HomeSkeleton = memo(function HomeSkeleton() {\n return (\n <>\n <div className=\"s-block container skeleton-block-hero\">\n <Pulse className=\"h-64 sm:h-80 rounded-md\" />\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n </>\n );\n});\n\n/** As on Twig, a home page with no blocks lists the store's latest products instead. */\nconst LATEST_PRODUCTS: HomeComponentData = { path: 'latest-products' };\n\n/** The blocks' places in the store's order: 0, 1, 2… */\nconst storeOrder = (blocks: readonly unknown[]) => Array.from(blocks, (_, at) => at);\n\n// Stable, so a redraw of a page loaded without blocks is kept.\nconst NO_BLOCKS: HomeComponentData[] = [];\n\n// Catalog id (or path) plus copy number: a block drawn in or out leaves the others' state alone.\nfunction blockKeys(blocks: ReadonlyArray<DevHomeBlock<HomeComponentData>>): string[] {\n const copies = new Map<string, number>();\n return blocks.map((block) => {\n if (block.__dev_id) return block.__dev_id;\n const name = String(block.key ?? block.path);\n const copy = copies.get(name) ?? 0;\n copies.set(name, copy + 1);\n return `${name}~${copy}`;\n });\n}\n\nexport const HomePage = memo(function HomePage({\n components = NO_BLOCKS,\n storeBlocks,\n}: HomePageProps) {\n // The design studio draws the blocks again after a save, in place of the loaded\n // ones, until the page loads its blocks anew.\n const [drawn, setDrawn] = useState<{\n source: HomeComponentData[];\n blocks: HomeComponentData[];\n } | null>(null);\n const onList = useCallback(\n (blocks: HomeComponentData[]) => setDrawn({ source: components, blocks }),\n [components]\n );\n // A list the theme's own loader built (Tania's home) is not the store's: the studio reloads it instead.\n const storeList = useMemo(\n () => storeBlocks === undefined || storeBlocks === blockList(components),\n [storeBlocks, components]\n );\n useLiveBlockList(storeList ? onList : null);\n const current = drawn?.source === components ? drawn.blocks : components;\n // Dev-mode only: the dev editor's layout replaces the store's blocks while it\n // is on. No-op passthrough in production builds.\n const renderedComponents = useDevHomeBlocks(current);\n // The theme editor's preview moves blocks in place while the editor saves the\n // order; blocks from the server (a new page, a reload) start over from theirs.\n const [moved, setMoved] = useState<{ source: HomeComponentData[]; order: number[] } | null>(null);\n const order = moved?.source === renderedComponents ? moved.order : null;\n const onMove = useCallback(\n (from: number, to: number) =>\n setMoved((prev) => ({\n source: renderedComponents,\n order: reorder(\n prev?.source === renderedComponents ? prev.order : storeOrder(renderedComponents),\n from,\n to\n ),\n })),\n [renderedComponents]\n );\n useLiveBlockMoves(onMove);\n const placed = order ?? storeOrder(renderedComponents);\n const keys = useMemo(() => blockKeys(renderedComponents), [renderedComponents]);\n\n return (\n <>\n <HookSlot name=\"home:start\" />\n <HookSlot name=\"home:content\" />\n {placed.map((at, index) => {\n // A block's key stays with it when the preview moves it, so a move keeps its state.\n return <HomeComponentRenderer key={keys[at]} data={renderedComponents[at]} index={index} />;\n })}\n {!renderedComponents.length && (\n <HomeComponentRenderer data={LATEST_PRODUCTS} index={0} editable={false} />\n )}\n <HookSlot name=\"home:end\" />\n <ReorderProducts />\n </>\n );\n});\n\nexport { HomePage as default };\n","import type { HeadDescriptor } from '../../utils/head';\nimport { buildHreflangAlternates, storePageUrl } from '../../utils/baseHead';\nimport { seoField } from '../../utils/seo-text';\nimport type { HomeLoaderData } from './loader';\nimport { homeLoader } from './loader';\nimport type { TwilightContext } from '../../twilight/context';\nimport { HomePage } from './HomePage';\nimport { RouteId } from '../../router/route-ids';\n\nexport { HomeSkeleton } from './HomePage';\nexport { registerHomeComponents, DefaultHomeComponents } from '../../components/home/register';\nexport { registerHomeComponentConfig } from '../../components/home';\nexport type { HomePageProps } from './types';\nexport type { HomeLoaderData } from './loader';\nexport type {\n HomeComponentsProps,\n AnyHomeComponent,\n HomeComponentConfig,\n} from '../../components/home';\n\nfunction loader(_ctx?: { locale?: string }): Promise<HomeLoaderData> {\n return homeLoader({ locale: _ctx?.locale });\n}\n\nfunction head(ctx: TwilightContext): HeadDescriptor {\n const store = ctx.settings?.store;\n if (!store) return {};\n\n // `seoField`, not `??`: the store's unset SEO fields arrive as \"\".\n const title = seoField(store.meta?.title, store.name);\n const description = seoField(store.meta?.description, store.description);\n const keywords = seoField(store.meta?.keywords, undefined);\n // `/ar`, like Twig, where store.url reads `/ar/`.\n const url = storePageUrl(ctx.settings, ctx.location.pathname) ?? store.url;\n\n return {\n title,\n description,\n keywords,\n canonical: url,\n openGraph: {\n type: 'website',\n title,\n description,\n images: store.logo,\n url,\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: store.logo,\n },\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n}\n\nexport const Home = { id: RouteId.INDEX, loader, head, Component: HomePage } as const;\n\nexport { homeLoader };\n"]}
1
+ {"version":3,"sources":["../src/routes/home/blockList.ts","../src/routes/home/loader.ts","../src/routes/home/HomePage.tsx","../src/routes/home/index.tsx"],"names":["HomeSkeleton","HomePage"],"mappings":";;;;;;;;;;;;;;AAGO,SAAS,UAAU,MAAA,EAA8C;AACtE,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAU,CAAC,KAAA,CAAM,IAAA,EAAM,KAAA,CAAM,GAAA,IAAO,IAAI,CAAC,CAAC,CAAA;AAC9E;;;ACYA,eAAsB,WAAW,GAAA,EAAoD;AACnF,EAAA,MAAM,EAAE,WAAA,EAAY,GAAI,kBAAA,EAAmB;AAC3C,EAAA,MAAM,aAAa,MAAM,WAAA,CAAY,gBAAgB,IAAA,CAAK,OAAA,CAAQ,YAAY,CAAA;AAC9E,EAAA,MAAM,MAAA,GAAS,UAAA,CAAW,GAAA,CAAI,CAAC,IAAA,MAAU;AAAA,IACvC,GAAG,IAAA;AAAA,IACH,MAAM,IAAA,CAAK,IAAA,EAAM,QAAQ,OAAA,EAAS,EAAE,KAAK,IAAA,CAAK;AAAA,GAChD,CAAE,CAAA;AACF,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,KAAK,MAAA,IAAU,IAAA;AAAA,IACvB,UAAA,EAAY,MAAA;AAAA,IACZ,IAAA,EAAM,EAAE,IAAA,EAAM,OAAA,CAAQ,KAAA,EAAM;AAAA,IAC5B,WAAA,EAAa,UAAU,MAAM;AAAA,GAC/B;AACF;ACpBO,IAAM,YAAA,GAAe,IAAA,CAAK,SAASA,aAAAA,GAAe;AACvD,EAAA,u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AU,GAAA,CAAI,SAAS,QAAQ;AAAA,GACjF;AACF;AAEO,IAAM,IAAA,GAAO,EAAE,EAAA,EAAI,OAAA,CAAQ,OAAO,MAAA,EAAQ,IAAA,EAAM,WAAW,QAAA","file":"chunk-6RWMVAOC.js","sourcesContent":["import type { HomeComponentData } from '../../types';\n\n/** Paths and keys of `blocks` in order: enough to tell the store's list from one a theme built. */\nexport function blockList(blocks: readonly HomeComponentData[]): string {\n return JSON.stringify(blocks.map((block) => [block.path, block.key ?? null]));\n}\n","import { getTwilightContext } from '../../twilight/context';\nimport { home } from '../../api/home';\nimport type { HomeComponentData } from '../../types';\nimport { RouteId } from '../../router/route-ids';\nimport { blockList } from './blockList';\n\nexport interface HomeLoaderData {\n locale: string;\n components: HomeComponentData[];\n page: { slug: string };\n /**\n * The store's blocks as this loader lists them (`blockList`). A theme whose own loader\n * reshapes `components` keeps this, so the page can tell its list is no longer the store's.\n */\n storeBlocks?: string;\n}\n\nexport async function homeLoader(ctx?: { locale?: string }): Promise<HomeLoaderData> {\n const { queryClient } = getTwilightContext();\n const components = await queryClient.ensureQueryData(home.queries.components());\n const blocks = components.map((comp) => ({\n ...comp,\n path: comp.path?.replace('home.', '') || comp.path,\n }));\n return {\n locale: ctx?.locale || 'ar',\n components: blocks,\n page: { slug: RouteId.INDEX },\n storeBlocks: blockList(blocks),\n };\n}\n","import { memo, useCallback, useMemo, useState } from 'react';\nimport { useDevHomeBlocks, type DevHomeBlock } from '../../dev/dev-settings-store';\nimport { HookSlot } from '../../hooks';\nimport { HomeComponentRenderer, ReorderProducts } from '../../components/home';\nimport { reorder, useLiveBlockList, useLiveBlockMoves } from '../../components/live-editor/moves';\nimport type { HomePageProps } from './types';\nimport { blockList } from './blockList';\nimport type { HomeComponentData } from '../../types';\nimport { Pulse } from '@salla.sa/twilight-components-react';\n\nexport const HomeSkeleton = memo(function HomeSkeleton() {\n return (\n <>\n <div className=\"s-block container skeleton-block-hero\">\n <Pulse className=\"h-64 sm:h-80 rounded-md\" />\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n <div className=\"s-block container skeleton-block-products\">\n <Pulse className=\"h-10 w-48 mb-4\" />\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <Pulse key={i} className=\"h-56\" />\n ))}\n </div>\n </div>\n </>\n );\n});\n\n/** As on Twig, a home page with no blocks lists the store's latest products instead. */\nconst LATEST_PRODUCTS: HomeComponentData = { path: 'latest-products' };\n\n/** The blocks' places in the store's order: 0, 1, 2… */\nconst storeOrder = (blocks: readonly unknown[]) => Array.from(blocks, (_, at) => at);\n\n// Stable, so a redraw of a page loaded without blocks is kept.\nconst NO_BLOCKS: HomeComponentData[] = [];\n\n// Catalog id (or path) plus copy number: a block drawn in or out leaves the others' state alone.\nfunction blockKeys(blocks: ReadonlyArray<DevHomeBlock<HomeComponentData>>): string[] {\n const copies = new Map<string, number>();\n return blocks.map((block) => {\n if (block.__dev_id) return block.__dev_id;\n const name = String(block.key ?? block.path);\n const copy = copies.get(name) ?? 0;\n copies.set(name, copy + 1);\n return `${name}~${copy}`;\n });\n}\n\nexport const HomePage = memo(function HomePage({\n components = NO_BLOCKS,\n storeBlocks,\n}: HomePageProps) {\n // The design studio draws the blocks again after a save, in place of the loaded\n // ones, until the page loads its blocks anew.\n const [drawn, setDrawn] = useState<{\n source: HomeComponentData[];\n blocks: HomeComponentData[];\n } | null>(null);\n const onList = useCallback(\n (blocks: HomeComponentData[]) => setDrawn({ source: components, blocks }),\n [components]\n );\n // A list the theme's own loader built (Tania's home) is not the store's: the studio reloads it instead.\n const storeList = useMemo(\n () => storeBlocks === undefined || storeBlocks === blockList(components),\n [storeBlocks, components]\n );\n useLiveBlockList(storeList ? onList : null);\n const current = drawn?.source === components ? drawn.blocks : components;\n // Dev-mode only: the dev editor's layout replaces the store's blocks while it\n // is on. No-op passthrough in production builds.\n const renderedComponents = useDevHomeBlocks(current);\n // The theme editor's preview moves blocks in place while the editor saves the\n // order; blocks from the server (a new page, a reload) start over from theirs.\n const [moved, setMoved] = useState<{ source: HomeComponentData[]; order: number[] } | null>(null);\n const order = moved?.source === renderedComponents ? moved.order : null;\n const onMove = useCallback(\n (from: number, to: number) =>\n setMoved((prev) => ({\n source: renderedComponents,\n order: reorder(\n prev?.source === renderedComponents ? prev.order : storeOrder(renderedComponents),\n from,\n to\n ),\n })),\n [renderedComponents]\n );\n useLiveBlockMoves(onMove);\n const placed = order ?? storeOrder(renderedComponents);\n const keys = useMemo(() => blockKeys(renderedComponents), [renderedComponents]);\n\n return (\n <>\n <HookSlot name=\"home:start\" />\n <HookSlot name=\"home:content\" />\n {placed.map((at, index) => {\n // A block's key stays with it when the preview moves it, so a move keeps its state.\n return <HomeComponentRenderer key={keys[at]} data={renderedComponents[at]} index={index} />;\n })}\n {!renderedComponents.length && (\n <HomeComponentRenderer data={LATEST_PRODUCTS} index={0} editable={false} />\n )}\n <HookSlot name=\"home:end\" />\n <ReorderProducts />\n </>\n );\n});\n\nexport { HomePage as default };\n","import type { HeadDescriptor } from '../../utils/head';\nimport { buildHreflangAlternates, storePageUrl } from '../../utils/baseHead';\nimport { seoField } from '../../utils/seo-text';\nimport type { HomeLoaderData } from './loader';\nimport { homeLoader } from './loader';\nimport type { TwilightContext } from '../../twilight/context';\nimport { HomePage } from './HomePage';\nimport { RouteId } from '../../router/route-ids';\n\nexport { HomeSkeleton } from './HomePage';\nexport { registerHomeComponents, DefaultHomeComponents } from '../../components/home/register';\nexport { registerHomeComponentConfig } from '../../components/home';\nexport type { HomePageProps } from './types';\nexport type { HomeLoaderData } from './loader';\nexport type {\n HomeComponentsProps,\n AnyHomeComponent,\n HomeComponentConfig,\n} from '../../components/home';\n\nfunction loader(_ctx?: { locale?: string }): Promise<HomeLoaderData> {\n return homeLoader({ locale: _ctx?.locale });\n}\n\nfunction head(ctx: TwilightContext): HeadDescriptor {\n const store = ctx.settings?.store;\n if (!store) return {};\n\n // `seoField`, not `??`: the store's unset SEO fields arrive as \"\".\n const title = seoField(store.meta?.title, store.name);\n const description = seoField(store.meta?.description, store.description);\n const keywords = seoField(store.meta?.keywords, undefined);\n // `/ar`, like Twig, where store.url reads `/ar/`.\n const url = storePageUrl(ctx.settings, ctx.location.pathname) ?? store.url;\n\n return {\n title,\n description,\n keywords,\n canonical: url,\n openGraph: {\n type: 'website',\n title,\n description,\n images: store.logo,\n url,\n },\n twitter: {\n card: 'summary_large_image',\n title,\n description,\n images: store.logo,\n },\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n}\n\nexport const Home = { id: RouteId.INDEX, loader, head, Component: HomePage } as const;\n\nexport { homeLoader };\n"]}
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-7IL5RSR5.js';
1
+ import { api } from './chunk-LC3M4HW7.js';
2
2
  import { queryOptions } from '@tanstack/react-query';
3
3
 
4
4
  var apps = {
@@ -40,5 +40,5 @@ var apps = {
40
40
  };
41
41
 
42
42
  export { apps };
43
- //# sourceMappingURL=chunk-GTNCHLXK.js.map
44
- //# sourceMappingURL=chunk-GTNCHLXK.js.map
43
+ //# sourceMappingURL=chunk-7326LK5W.js.map
44
+ //# sourceMappingURL=chunk-7326LK5W.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/apps.ts"],"names":[],"mappings":";;;AAmCO,IAAM,IAAA,GAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlB,UAAU,YAAmC;AAC3C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,eAAA,EAAiB,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CACtC,IAAA,EAA8B;AACjC,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAkC;AAC1C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,wBAAA,EAA0B,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CAC/C,IAAA,EAAsC;AACzC,IAAA,OAAO,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,IAAQ,EAAC,EAAE;AAAA,EAClC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA;AAAA;AAAA;AAAA,MAIX,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,IAEH,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA,MACX,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-GTNCHLXK.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\n\nexport interface AppSnippetRow {\n place: string;\n content: string;\n url?: string | null;\n /**\n * Raw snippet id, emitted as `data-snippet-id`. Present only on CDN rows — the\n * inline branch of the backend's snippet parser omits the key entirely.\n */\n id?: number;\n /** `{{customer.x}}` placeholders in `content` to substitute from SDK config `user.*` keys. */\n customer_parameters?: string[];\n}\n\nexport interface AppSnippet {\n service: string;\n app_id: string;\n /** Encoded app id (`getRouteKey()`): the scope id its snippets bind to via `data-scope-id`,\n * and its settings-bucket key. Absent on payloads predating the settings API. */\n id?: string;\n app_slug: string;\n status: string;\n snippets: AppSnippetRow[];\n}\n\n/**\n * Per-app public `app.*` buckets for CDN snippets, keyed by encoded app id (== `AppSnippet.id`,\n * the `Salla.appScope` scope id). One isolated bucket per app; reads within a scope are bare `app.*`.\n */\nexport interface AppSettings {\n apps: Record<string, Record<string, unknown>>;\n}\n\nexport const apps = {\n /**\n * Installed apps' snippets (scripts/HTML to inject). Timeout-bounded because it's awaited in\n * rootBeforeLoad (SSR/TTFB): a slow response degrades to no CDN tags, never stalls the page.\n */\n snippets: async (): Promise<AppSnippet[]> => {\n const { data } = await api\n .get('apps/snippets', { timeout: 2500 })\n .json<{ data?: AppSnippet[] }>();\n return data ?? [];\n },\n\n /**\n * Per-app public `app.*` buckets, keyed by encoded app id. Timeout-bounded (SSR-awaited):\n * a slow response degrades to empty buckets (fail-open), never strands injection.\n */\n settings: async (): Promise<AppSettings> => {\n const { data } = await api\n .get('apps/snippets/settings', { timeout: 2500 })\n .json<{ data?: Partial<AppSettings> }>();\n return { apps: data?.apps ?? {} };\n },\n\n queries: {\n snippets: () =>\n queryOptions({\n queryKey: ['apps', 'snippets'],\n queryFn: () => apps.snippets(),\n // Snippets are static per session; one fetch per page load is enough.\n staleTime: Infinity,\n // No retry: this is awaited in rootBeforeLoad, so the router's default `retry: 1` would\n // make the SSR wait 2 x the 2500ms timeout (plus backoff) before failing open. The\n // 2500ms timeout must be the whole budget; the client fallback query does the retrying.\n retry: 0,\n }),\n\n settings: () =>\n queryOptions({\n queryKey: ['apps', 'settings'],\n queryFn: () => apps.settings(),\n // Encoded app ids and their buckets are stable per page; one fetch is enough.\n staleTime: Infinity,\n retry: 0,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/apps.ts"],"names":[],"mappings":";;;AAmCO,IAAM,IAAA,GAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlB,UAAU,YAAmC;AAC3C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,eAAA,EAAiB,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CACtC,IAAA,EAA8B;AACjC,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAkC;AAC1C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,wBAAA,EAA0B,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CAC/C,IAAA,EAAsC;AACzC,IAAA,OAAO,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,IAAQ,EAAC,EAAE;AAAA,EAClC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA;AAAA;AAAA;AAAA,MAIX,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,IAEH,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA,MACX,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-7326LK5W.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\n\nexport interface AppSnippetRow {\n place: string;\n content: string;\n url?: string | null;\n /**\n * Raw snippet id, emitted as `data-snippet-id`. Present only on CDN rows — the\n * inline branch of the backend's snippet parser omits the key entirely.\n */\n id?: number;\n /** `{{customer.x}}` placeholders in `content` to substitute from SDK config `user.*` keys. */\n customer_parameters?: string[];\n}\n\nexport interface AppSnippet {\n service: string;\n app_id: string;\n /** Encoded app id (`getRouteKey()`): the scope id its snippets bind to via `data-scope-id`,\n * and its settings-bucket key. Absent on payloads predating the settings API. */\n id?: string;\n app_slug: string;\n status: string;\n snippets: AppSnippetRow[];\n}\n\n/**\n * Per-app public `app.*` buckets for CDN snippets, keyed by encoded app id (== `AppSnippet.id`,\n * the `Salla.appScope` scope id). One isolated bucket per app; reads within a scope are bare `app.*`.\n */\nexport interface AppSettings {\n apps: Record<string, Record<string, unknown>>;\n}\n\nexport const apps = {\n /**\n * Installed apps' snippets (scripts/HTML to inject). Timeout-bounded because it's awaited in\n * rootBeforeLoad (SSR/TTFB): a slow response degrades to no CDN tags, never stalls the page.\n */\n snippets: async (): Promise<AppSnippet[]> => {\n const { data } = await api\n .get('apps/snippets', { timeout: 2500 })\n .json<{ data?: AppSnippet[] }>();\n return data ?? [];\n },\n\n /**\n * Per-app public `app.*` buckets, keyed by encoded app id. Timeout-bounded (SSR-awaited):\n * a slow response degrades to empty buckets (fail-open), never strands injection.\n */\n settings: async (): Promise<AppSettings> => {\n const { data } = await api\n .get('apps/snippets/settings', { timeout: 2500 })\n .json<{ data?: Partial<AppSettings> }>();\n return { apps: data?.apps ?? {} };\n },\n\n queries: {\n snippets: () =>\n queryOptions({\n queryKey: ['apps', 'snippets'],\n queryFn: () => apps.snippets(),\n // Snippets are static per session; one fetch per page load is enough.\n staleTime: Infinity,\n // No retry: this is awaited in rootBeforeLoad, so the router's default `retry: 1` would\n // make the SSR wait 2 x the 2500ms timeout (plus backoff) before failing open. The\n // 2500ms timeout must be the whole budget; the client fallback query does the retrying.\n retry: 0,\n }),\n\n settings: () =>\n queryOptions({\n queryKey: ['apps', 'settings'],\n queryFn: () => apps.settings(),\n // Encoded app ids and their buckets are stable per page; one fetch is enough.\n staleTime: Infinity,\n retry: 0,\n }),\n },\n};\n"]}
@@ -1,6 +1,6 @@
1
- import { customUrl } from './chunk-DBFVTN4C.js';
2
- import { store } from './chunk-AVJSCOYE.js';
3
- import { redirect } from './chunk-I6FORV4B.js';
1
+ import { customUrl } from './chunk-VIUK32MB.js';
2
+ import { store } from './chunk-4IISS5KO.js';
3
+ import { redirect } from './chunk-KUROVEJP.js';
4
4
  import { isLocale } from './chunk-T72DAX7R.js';
5
5
 
6
6
  // src/routes/custom-urls.ts
@@ -87,5 +87,5 @@ async function customUrlRedirect(pathname, search, options) {
87
87
  }
88
88
 
89
89
  export { customUrlKey, customUrlPagePath, customUrlRedirect, storePathOf, withAddressQuery };
90
- //# sourceMappingURL=chunk-NAZ7AXD3.js.map
91
- //# sourceMappingURL=chunk-NAZ7AXD3.js.map
90
+ //# sourceMappingURL=chunk-7CZXUN6C.js.map
91
+ //# sourceMappingURL=chunk-7CZXUN6C.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/custom-urls.ts"],"names":[],"mappings":";;;;;;AAiCO,SAAS,aAAa,QAAA,EAA2D;AACtF,EAAA,MAAM,WAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AACnD,EAAA,MAAM,MAAA,GAAS,SAAS,QAAA,CAAS,CAAC,CAAC,CAAA,GAAI,QAAA,CAAS,OAAM,GAAI,MAAA;AAC1D,EAAA,IAAI,CAAC,QAAA,CAAS,MAAA,EAAQ,OAAO,IAAA;AAC7B,EAAA,OAAO,EAAE,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,GAAG,GAAG,MAAA,EAAO;AAC3C;AAOO,SAAS,WAAA,CAAY,KAAa,QAAA,EAA6C;AACpF,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI;AACF,IAAA,IAAA,GAAO,IAAI,IAAI,GAAG,CAAA;AAClB,IAAA,IAAA,GAAO,IAAI,GAAA,CAAI,QAAA,IAAY,EAAE,CAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACpC,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,CAA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AAa,QAAQ,CAAA;AACrC,EAAA,IAAI,CAAC,OAAA,EAAS;AACd,EAAA,MAAM,QAAA,GAAW,MAAM,sBAAA,CAAuB,OAAA,CAAQ,WAAW,CAAA;AACjE,EAAA,IAAI,CAAC,QAAA,EAAU;AACf,EAAA,MAAM,SAAS,MAAM,MAAA,CAAO,OAAA,CAAQ,GAAA,EAAK,QAAQ,WAAW,CAAA;AAC5D,EAAA,IAAI,CAAC,MAAA,EAAQ;AAEb,EAAA,MAAM,IAAA,GAAO,iBAAA,CAAkB,MAAA,EAAQ,QAAA,CAAS,OAAO,GAAG,CAAA;AAC1D,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,MAAA,GAAS,QAAQ,YAAA,GACnB,MAAM,QAAQ,YAAA,CAAa,OAAA,CAAQ,MAAM,CAAA,GACzC,OAAA,CAAQ,MAAA;AACZ,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,CAAA,EAAG,MAAA,GAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,GAAK,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,EAAG;AAAA,MAC/E,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AAC/B,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,IAAA,EAAM,MAAM,CAAA,EAAG,EAAE,UAAA,EAAY,GAAA,EAAK,cAAA,EAAgB,IAAA,EAAM,CAAA;AAAA,EAC1F;AACF","file":"chunk-NAZ7AXD3.js","sourcesContent":["/**\n * @fileoverview A merchant's custom URLs (Dashboard → SEO → custom links) on a React storefront.\n *\n * Twig answers them in the Store's catch-all, its last fallback: after every route, and after the\n * product lookups by short code (`/{code}`) and by SKU (`/{sku}-{name}`). A React theme has no\n * catch-all, so the locale layout's `beforeLoad` asks the API (Store-Module#1798, the catch-all's\n * own lookup) at the same two points:\n * - an address no page answers (`twigUrlRedirect`, after the short code);\n * - a SKU-link address whose SKU names no product (`resolveProductKeyPage`).\n *\n * It asks only on a store that lists `custom-urls` in `store.features` (the plan has it, and the\n * store has an active one), so an address no page answers costs a store without one nothing. The answer is a 302, as Twig's, because the\n * merchant can point the URL elsewhere at any time.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport { customUrl, type CustomUrlTarget } from '../api/custom-url';\nimport { store } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport { redirect } from '../providers/NavigationProvider';\nimport { isLocale } from '../providers/locale-constants';\n\nexport interface CustomUrlRedirectOptions {\n /** The request's query client: the settings are in it already, and a lookup is shared. */\n queryClient: QueryClient;\n /** The language segment an item's page takes, given the one the address had (the locale layout's rule). */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n}\n\n/**\n * The path a custom URL is saved under, for an address the router hands over (the store base\n * already off): without a language segment, which the Store strips before its catch-all, and\n * without the slashes around it. `null` for a home page.\n */\nexport function customUrlKey(pathname: string): { key: string; locale?: string } | null {\n const segments = pathname.split('/').filter(Boolean);\n const locale = isLocale(segments[0]) ? segments.shift() : undefined;\n if (!segments.length) return null;\n return { key: segments.join('/'), locale };\n}\n\n/**\n * The path an item's URL has under the store root, without its language segment:\n * `https://salla.sa/dev-x/en/shoes/p1` with store URL `https://salla.sa/dev-x/` is `/shoes/p1`.\n * `null` when the URL is not on the store (another host, or outside the store's segment).\n */\nexport function storePathOf(url: string, storeUrl: string | undefined): string | null {\n let item: URL;\n let root: URL;\n try {\n item = new URL(url);\n root = new URL(storeUrl ?? '');\n } catch {\n return null;\n }\n if (item.host !== root.host) return null;\n const rootPath = root.pathname.replace(/\\/+$/, '');\n if (rootPath && item.pathname !== rootPath && !item.pathname.startsWith(`${rootPath}/`)) {\n return null;\n }\n const segments = item.pathname.slice(rootPath.length).split('/').filter(Boolean);\n if (isLocale(segments[0])) segments.shift();\n return `/${segments.join('/')}`;\n}\n\n/** Twig's brand address, `/{slug}/brand-{id}`: the engine's brand page is `/brands/{id}`. */\nconst TWIG_BRAND_PATH = /^\\/[^/]+\\/brand-(\\d+)$/;\n\n/**\n * The engine's page for the item a custom URL names, under the store root and with no language,\n * or `null` for a `custom` row or an item URL that is not on the store. The item's own address\n * is used: the engine serves Twig's product, category, tag and page addresses (and redirects a\n * hash URL itself), and only a brand is sent straight to its page, a hop shorter.\n */\nexport function customUrlPagePath(\n target: CustomUrlTarget,\n storeUrl: string | undefined\n): string | null {\n if (target.type === 'custom') return null;\n const path = storePathOf(target.url, storeUrl);\n if (!path) return null;\n const brand = TWIG_BRAND_PATH.exec(path);\n return brand ? `/brands/${brand[1]}` : path;\n}\n\n/**\n * `target` with the address's query string on it, as the Store's catch-all keeps it (an ad's\n * `utm_*`): after the target's own query, and before its fragment.\n */\nexport function withAddressQuery(target: string, search: string): string {\n const query = search.replace(/^\\?/, '');\n if (!query) return target;\n const hashAt = target.indexOf('#');\n const [head, fragment] =\n hashAt < 0 ? [target, ''] : [target.slice(0, hashAt), target.slice(hashAt)];\n return `${head}${head.includes('?') ? '&' : '?'}${query}${fragment}`;\n}\n\n/** A URL when it is http(s): the Dashboard asks for a URL, and the router refuses any other scheme. */\nfunction httpUrl(url: string): string | null {\n try {\n const { protocol } = new URL(url);\n return protocol === 'http:' || protocol === 'https:' ? url : null;\n } catch {\n return null;\n }\n}\n\n/** The settings, when they list `custom-urls` in the store's features; else `null`. */\nasync function settingsWithCustomUrls(queryClient: QueryClient): Promise<StoreContext | null> {\n try {\n const settings = await queryClient.ensureQueryData(store.queries.settings());\n return settings?.store?.features?.includes('custom-urls') ? settings : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The custom URL saved for `key`, or `undefined`. Any failure counts as none: an address no page\n * answers is also every scanner's, and an API error must leave it the 404 it was, not a 500.\n */\nasync function lookup(key: string, queryClient: QueryClient): Promise<CustomUrlTarget | undefined> {\n try {\n return await queryClient.ensureQueryData(customUrl.queries.resolve(key));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sends the visitor where the custom URL saved for `pathname` leads, with the address's query, by\n * a 302; returns when there is none, and the caller answers as it would have. An item on the store\n * is reached in one hop, in the language the locale layout would give it. A `custom` row's URL,\n * or an item URL on another site, is a full page load.\n */\nexport async function customUrlRedirect(\n pathname: string,\n search: string,\n options: CustomUrlRedirectOptions\n): Promise<void> {\n const address = customUrlKey(pathname);\n if (!address) return;\n const settings = await settingsWithCustomUrls(options.queryClient);\n if (!settings) return;\n const target = await lookup(address.key, options.queryClient);\n if (!target) return;\n\n const path = customUrlPagePath(target, settings.store?.url);\n if (path) {\n const locale = options.targetLocale\n ? await options.targetLocale(address.locale)\n : address.locale;\n throw redirect(withAddressQuery(`${locale ? `/${locale}` : ''}${path}`, search), {\n statusCode: 302,\n });\n }\n const href = httpUrl(target.url);\n if (href) {\n throw redirect(withAddressQuery(href, search), { statusCode: 302, reloadDocument: true });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/routes/custom-urls.ts"],"names":[],"mappings":";;;;;;AAiCO,SAAS,aAAa,QAAA,EAA2D;AACtF,EAAA,MAAM,WAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AACnD,EAAA,MAAM,MAAA,GAAS,SAAS,QAAA,CAAS,CAAC,CAAC,CAAA,GAAI,QAAA,CAAS,OAAM,GAAI,MAAA;AAC1D,EAAA,IAAI,CAAC,QAAA,CAAS,MAAA,EAAQ,OAAO,IAAA;AAC7B,EAAA,OAAO,EAAE,GAAA,EAAK,QAAA,CAAS,IAAA,CAAK,GAAG,GAAG,MAAA,EAAO;AAC3C;AAOO,SAAS,WAAA,CAAY,KAAa,QAAA,EAA6C;AACpF,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI,IAAA;AACJ,EAAA,IAAI;AACF,IAAA,IAAA,GAAO,IAAI,IAAI,GAAG,CAAA;AAClB,IAAA,IAAA,GAAO,IAAI,GAAA,CAAI,QAAA,IAAY,EA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sourcesContent":["/**\n * @fileoverview A merchant's custom URLs (Dashboard → SEO → custom links) on a React storefront.\n *\n * Twig answers them in the Store's catch-all, its last fallback: after every route, and after the\n * product lookups by short code (`/{code}`) and by SKU (`/{sku}-{name}`). A React theme has no\n * catch-all, so the locale layout's `beforeLoad` asks the API (Store-Module#1798, the catch-all's\n * own lookup) at the same two points:\n * - an address no page answers (`twigUrlRedirect`, after the short code);\n * - a SKU-link address whose SKU names no product (`resolveProductKeyPage`).\n *\n * It asks only on a store that lists `custom-urls` in `store.features` (the plan has it, and the\n * store has an active one), so an address no page answers costs a store without one nothing. The answer is a 302, as Twig's, because the\n * merchant can point the URL elsewhere at any time.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport { customUrl, type CustomUrlTarget } from '../api/custom-url';\nimport { store } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport { redirect } from '../providers/NavigationProvider';\nimport { isLocale } from '../providers/locale-constants';\n\nexport interface CustomUrlRedirectOptions {\n /** The request's query client: the settings are in it already, and a lookup is shared. */\n queryClient: QueryClient;\n /** The language segment an item's page takes, given the one the address had (the locale layout's rule). */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n}\n\n/**\n * The path a custom URL is saved under, for an address the router hands over (the store base\n * already off): without a language segment, which the Store strips before its catch-all, and\n * without the slashes around it. `null` for a home page.\n */\nexport function customUrlKey(pathname: string): { key: string; locale?: string } | null {\n const segments = pathname.split('/').filter(Boolean);\n const locale = isLocale(segments[0]) ? segments.shift() : undefined;\n if (!segments.length) return null;\n return { key: segments.join('/'), locale };\n}\n\n/**\n * The path an item's URL has under the store root, without its language segment:\n * `https://salla.sa/dev-x/en/shoes/p1` with store URL `https://salla.sa/dev-x/` is `/shoes/p1`.\n * `null` when the URL is not on the store (another host, or outside the store's segment).\n */\nexport function storePathOf(url: string, storeUrl: string | undefined): string | null {\n let item: URL;\n let root: URL;\n try {\n item = new URL(url);\n root = new URL(storeUrl ?? '');\n } catch {\n return null;\n }\n if (item.host !== root.host) return null;\n const rootPath = root.pathname.replace(/\\/+$/, '');\n if (rootPath && item.pathname !== rootPath && !item.pathname.startsWith(`${rootPath}/`)) {\n return null;\n }\n const segments = item.pathname.slice(rootPath.length).split('/').filter(Boolean);\n if (isLocale(segments[0])) segments.shift();\n return `/${segments.join('/')}`;\n}\n\n/** Twig's brand address, `/{slug}/brand-{id}`: the engine's brand page is `/brands/{id}`. */\nconst TWIG_BRAND_PATH = /^\\/[^/]+\\/brand-(\\d+)$/;\n\n/**\n * The engine's page for the item a custom URL names, under the store root and with no language,\n * or `null` for a `custom` row or an item URL that is not on the store. The item's own address\n * is used: the engine serves Twig's product, category, tag and page addresses (and redirects a\n * hash URL itself), and only a brand is sent straight to its page, a hop shorter.\n */\nexport function customUrlPagePath(\n target: CustomUrlTarget,\n storeUrl: string | undefined\n): string | null {\n if (target.type === 'custom') return null;\n const path = storePathOf(target.url, storeUrl);\n if (!path) return null;\n const brand = TWIG_BRAND_PATH.exec(path);\n return brand ? `/brands/${brand[1]}` : path;\n}\n\n/**\n * `target` with the address's query string on it, as the Store's catch-all keeps it (an ad's\n * `utm_*`): after the target's own query, and before its fragment.\n */\nexport function withAddressQuery(target: string, search: string): string {\n const query = search.replace(/^\\?/, '');\n if (!query) return target;\n const hashAt = target.indexOf('#');\n const [head, fragment] =\n hashAt < 0 ? [target, ''] : [target.slice(0, hashAt), target.slice(hashAt)];\n return `${head}${head.includes('?') ? '&' : '?'}${query}${fragment}`;\n}\n\n/** A URL when it is http(s): the Dashboard asks for a URL, and the router refuses any other scheme. */\nfunction httpUrl(url: string): string | null {\n try {\n const { protocol } = new URL(url);\n return protocol === 'http:' || protocol === 'https:' ? url : null;\n } catch {\n return null;\n }\n}\n\n/** The settings, when they list `custom-urls` in the store's features; else `null`. */\nasync function settingsWithCustomUrls(queryClient: QueryClient): Promise<StoreContext | null> {\n try {\n const settings = await queryClient.ensureQueryData(store.queries.settings());\n return settings?.store?.features?.includes('custom-urls') ? settings : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The custom URL saved for `key`, or `undefined`. Any failure counts as none: an address no page\n * answers is also every scanner's, and an API error must leave it the 404 it was, not a 500.\n */\nasync function lookup(key: string, queryClient: QueryClient): Promise<CustomUrlTarget | undefined> {\n try {\n return await queryClient.ensureQueryData(customUrl.queries.resolve(key));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sends the visitor where the custom URL saved for `pathname` leads, with the address's query, by\n * a 302; returns when there is none, and the caller answers as it would have. An item on the store\n * is reached in one hop, in the language the locale layout would give it. A `custom` row's URL,\n * or an item URL on another site, is a full page load.\n */\nexport async function customUrlRedirect(\n pathname: string,\n search: string,\n options: CustomUrlRedirectOptions\n): Promise<void> {\n const address = customUrlKey(pathname);\n if (!address) return;\n const settings = await settingsWithCustomUrls(options.queryClient);\n if (!settings) return;\n const target = await lookup(address.key, options.queryClient);\n if (!target) return;\n\n const path = customUrlPagePath(target, settings.store?.url);\n if (path) {\n const locale = options.targetLocale\n ? await options.targetLocale(address.locale)\n : address.locale;\n throw redirect(withAddressQuery(`${locale ? `/${locale}` : ''}${path}`, search), {\n statusCode: 302,\n });\n }\n const href = httpUrl(target.url);\n if (href) {\n throw redirect(withAddressQuery(href, search), { statusCode: 302, reloadDocument: true });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-7IL5RSR5.js';
1
+ import { api } from './chunk-LC3M4HW7.js';
2
2
  import { getTwilightContext } from './chunk-MWUAHDQL.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-FD4QTGWX.js.map
27
- //# sourceMappingURL=chunk-FD4QTGWX.js.map
26
+ //# sourceMappingURL=chunk-7XEF3ITQ.js.map
27
+ //# sourceMappingURL=chunk-7XEF3ITQ.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-FD4QTGWX.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-7XEF3ITQ.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 { advertisement, advertisementsFor } from './chunk-6O2TYPUP.js';
1
+ import { advertisement, advertisementsFor } from './chunk-HYARGOSU.js';
2
2
  import { useTranslation } from './chunk-TYNZ5B2B.js';
3
3
  import { whenSallaReady } from './chunk-MZPX4EPS.js';
4
4
  import { subscribeTwilight, getTwilightContext } from './chunk-MWUAHDQL.js';
@@ -99,5 +99,5 @@ function PageAdvertisements() {
99
99
  }
100
100
 
101
101
  export { PageAdvertisements };
102
- //# sourceMappingURL=chunk-TZ3DCT3S.js.map
103
- //# sourceMappingURL=chunk-TZ3DCT3S.js.map
102
+ //# sourceMappingURL=chunk-BUXWWPX4.js.map
103
+ //# sourceMappingURL=chunk-BUXWWPX4.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/layout/PageAdvertisements.tsx"],"names":[],"mappings":";;;;;;;;AAOA,IAAM,eAAA,GAAkB,MAAM,kBAAA,EAAmB,CAAE,IAAA,EAAM,IAAA;AAGzD,IAAM,YAAA,GAAe,CAAC,EAAA,KAAe,CAAA,SAAA,EAAY,EAAE,CAAA,CAAA;AAGnD,IAAM,SAA0B,EAAC;AAGjC,IAAM,qBAAA,GACJ,uPAAA;AAEF,SAAS,YAAY,EAAA,EAAqB;AACxC,EAAA,IAAI;AACF,IAAA,OAAO,QAAQ,MAAA,CAAO,YAAA,CAAa,QAAQ,YAAA,CAAa,EAAE,CAAC,CAAC,CAAA;AAAA,EAC9D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,EAAA,EAAkB;AACjC,EAAA,MAAM,OAAA,GAAU,OAAO,KAAA,EAAO,OAAA;AAC9B,EAAA,IAAI,OAAO,SAAS,GAAA,KAAQ,UAAA,U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tanstack/react-query';\nimport { advertisement, advertisementsFor, type Advertisement } from '../../api/advertisement';\nimport { whenSallaReady } from '../../utils/sdk-helpers';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { getTwilightContext, subscribeTwilight } from '../../twilight/context';\n\nconst currentPageSlug = () => getTwilightContext().page?.slug;\n\n/** The key `<salla-advertisement>` marks a closed ad with, through `salla.storage` (store.js, JSON). */\nconst dismissedKey = (id: number) => `statusAd-${id}`;\n\n/** Stable while the query has no data, so the effect below doesn't rerun on every render. */\nconst NO_ADS: Advertisement[] = [];\n\n/** Hides the ads this visitor closed before the first paint; the effect then drops them. */\nconst HIDE_DISMISSED_SCRIPT =\n \"(function(){try{if(window.self!==window.top)return;document.currentScript.parentNode.querySelectorAll('.s-advertisement[data-id]').forEach(function(e){if(localStorage.getItem('statusAd-'+e.getAttribute('data-id')))e.hidden=true})}catch(e){}})();\";\n\nfunction isDismissed(id: number): boolean {\n try {\n return Boolean(window.localStorage.getItem(dismissedKey(id)));\n } catch {\n return false;\n }\n}\n\nfunction dismiss(id: number): void {\n const storage = window.salla?.storage;\n if (typeof storage?.set === 'function') storage.set(dismissedKey(id), 'dismissed');\n else {\n try {\n window.localStorage.setItem(dismissedKey(id), JSON.stringify('dismissed'));\n } catch {\n // Storage disabled: the ad hides for this page view only.\n }\n }\n}\n\ninterface ClientView {\n /** The theme editor's iframe, or the SDK's debug flag: every ad shows, closed or not. */\n preview: boolean;\n /** Inside the Salla mobile app, which shows no ads. */\n inApp: boolean;\n dismissed: Set<number>;\n}\n\n/**\n * The merchant's announcement bars, in place of `<salla-advertisement>`. Same data, rules and\n * markup, but rendered on the server (the ads are prefetched in the root `beforeLoad`), so the\n * bar is in the first paint instead of pushing the page down when the web component fetches it.\n */\nexport function PageAdvertisements() {\n const { t } = useTranslation();\n // The deepest route loader's `page`, the page `salla.config` reports.\n const pageSlug = useSyncExternalStore(subscribeTwilight, currentPageSlug, currentPageSlug);\n // The query's `retry: 0` only bounds the server wait; the browser may retry.\n const { data: ads = NO_ADS } = useQuery({ ...advertisement.queries.list(), retry: 2 });\n const [view, setView] = useState<ClientView | null>(null);\n\n useEffect(() => {\n const dismissed = new Set(ads.filter((ad) => isDismissed(ad.id)).map((ad) => ad.id));\n setView({ preview: window.self !== window.top, inApp: false, dismissed });\n return whenSallaReady((sdk) => {\n const config = sdk.config as { isMobileApp?: () => boolean; isDebug?: () => boolean };\n const inApp = Boolean(config?.isMobileApp?.());\n const debug = Boolean(config?.isDebug?.());\n if (inApp || debug) {\n setView((current) =>\n current ? { ...current, inApp, preview: current.preview || debug } : current\n );\n }\n });\n }, [ads]);\n\n if (view?.inApp) return null;\n const shown = view?.preview\n ? ads\n : advertisementsFor(ads, pageSlug).filter((ad) => !view?.dismissed.has(ad.id));\n if (!shown.length) return null;\n\n const close = (id: number) => {\n dismiss(id);\n setView((current) =>\n current ? { ...current, dismissed: new Set(current.dismissed).add(id) } : current\n );\n };\n\n return (\n <>\n {shown.map((ad) => (\n <div\n key={ad.id}\n className=\"s-advertisement\"\n data-id={ad.id}\n style={{ backgroundColor: ad.colors?.bg, color: ad.colors?.text }}\n >\n <div className=\"s-advertisement-content container flex justify-between items-center py-2.5\">\n <span className=\"s-advertisement-content-main flex-1 font-bold text-center text-sm\">\n {/* Rendered without an icon too, as the SDK does: its margin is part of the layout. */}\n <i\n className={`s-advertisement-content-icon inline-block align-middle me-2 text-base ${ad.icon ?? ''}`}\n />\n {ad.url ? (\n <a\n href={ad.url}\n target={ad.target ?? undefined}\n rel={ad.target === '_blank' ? 'noopener' : undefined}\n >\n {ad.description}\n </a>\n ) : (\n ad.description\n )}\n </span>\n <button\n type=\"button\"\n className=\"s-advertisement-action px-1\"\n aria-label={t('common.buttons.close', 'Close')}\n onClick={() => close(ad.id)}\n >\n {/* `inline-block`: before the icon CSS loads, an empty inline `<i>` leaves the button 0px tall. */}\n <i className=\"sicon-cancel inline-block\" />\n </button>\n </div>\n </div>\n ))}\n <script suppressHydrationWarning>{HIDE_DISMISS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AAA,gBAGN,EAAA,CAAG;AAAA,WAAA,EAEP,CAAA;AAAA,0BACA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAA,EAAK,QAAA;AAAA,cACL,SAAA,EAAU,6BAAA;AAAA,cACV,YAAA,EAAY,CAAA,CAAE,sBAAA,EAAwB,OAAO,CAAA;AAAA,cAC7C,OAAA,EAAS,MAAM,KAAA,CAAM,EAAA,CAAG,EAAE,CAAA;AAAA,cAG1B,QAAA,kBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,2BAAA,EAA4B;AAAA;AAAA;AAC3C,SAAA,EACF;AAAA,OAAA;AAAA,MAhCK,EAAA,CAAG;AAAA,KAkCX,CAAA;AAAA,oBACD,GAAA,CAAC,QAAA,EAAA,EAAO,wBAAA,EAAwB,IAAA,EAAE,QAAA,EAAA,qBAAA,EAAsB;AAAA,GAAA,EAC1D,CAAA;AAEJ","file":"chunk-BUXWWPX4.js","sourcesContent":["import { useEffect, useState, useSyncExternalStore } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { advertisement, advertisementsFor, type Advertisement } from '../../api/advertisement';\nimport { whenSallaReady } from '../../utils/sdk-helpers';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { getTwilightContext, subscribeTwilight } from '../../twilight/context';\n\nconst currentPageSlug = () => getTwilightContext().page?.slug;\n\n/** The key `<salla-advertisement>` marks a closed ad with, through `salla.storage` (store.js, JSON). */\nconst dismissedKey = (id: number) => `statusAd-${id}`;\n\n/** Stable while the query has no data, so the effect below doesn't rerun on every render. */\nconst NO_ADS: Advertisement[] = [];\n\n/** Hides the ads this visitor closed before the first paint; the effect then drops them. */\nconst HIDE_DISMISSED_SCRIPT =\n \"(function(){try{if(window.self!==window.top)return;document.currentScript.parentNode.querySelectorAll('.s-advertisement[data-id]').forEach(function(e){if(localStorage.getItem('statusAd-'+e.getAttribute('data-id')))e.hidden=true})}catch(e){}})();\";\n\nfunction isDismissed(id: number): boolean {\n try {\n return Boolean(window.localStorage.getItem(dismissedKey(id)));\n } catch {\n return false;\n }\n}\n\nfunction dismiss(id: number): void {\n const storage = window.salla?.storage;\n if (typeof storage?.set === 'function') storage.set(dismissedKey(id), 'dismissed');\n else {\n try {\n window.localStorage.setItem(dismissedKey(id), JSON.stringify('dismissed'));\n } catch {\n // Storage disabled: the ad hides for this page view only.\n }\n }\n}\n\ninterface ClientView {\n /** The theme editor's iframe, or the SDK's debug flag: every ad shows, closed or not. */\n preview: boolean;\n /** Inside the Salla mobile app, which shows no ads. */\n inApp: boolean;\n dismissed: Set<number>;\n}\n\n/**\n * The merchant's announcement bars, in place of `<salla-advertisement>`. Same data, rules and\n * markup, but rendered on the server (the ads are prefetched in the root `beforeLoad`), so the\n * bar is in the first paint instead of pushing the page down when the web component fetches it.\n */\nexport function PageAdvertisements() {\n const { t } = useTranslation();\n // The deepest route loader's `page`, the page `salla.config` reports.\n const pageSlug = useSyncExternalStore(subscribeTwilight, currentPageSlug, currentPageSlug);\n // The query's `retry: 0` only bounds the server wait; the browser may retry.\n const { data: ads = NO_ADS } = useQuery({ ...advertisement.queries.list(), retry: 2 });\n const [view, setView] = useState<ClientView | null>(null);\n\n useEffect(() => {\n const dismissed = new Set(ads.filter((ad) => isDismissed(ad.id)).map((ad) => ad.id));\n setView({ preview: window.self !== window.top, inApp: false, dismissed });\n return whenSallaReady((sdk) => {\n const config = sdk.config as { isMobileApp?: () => boolean; isDebug?: () => boolean };\n const inApp = Boolean(config?.isMobileApp?.());\n const debug = Boolean(config?.isDebug?.());\n if (inApp || debug) {\n setView((current) =>\n current ? { ...current, inApp, preview: current.preview || debug } : current\n );\n }\n });\n }, [ads]);\n\n if (view?.inApp) return null;\n const shown = view?.preview\n ? ads\n : advertisementsFor(ads, pageSlug).filter((ad) => !view?.dismissed.has(ad.id));\n if (!shown.length) return null;\n\n const close = (id: number) => {\n dismiss(id);\n setView((current) =>\n current ? { ...current, dismissed: new Set(current.dismissed).add(id) } : current\n );\n };\n\n return (\n <>\n {shown.map((ad) => (\n <div\n key={ad.id}\n className=\"s-advertisement\"\n data-id={ad.id}\n style={{ backgroundColor: ad.colors?.bg, color: ad.colors?.text }}\n >\n <div className=\"s-advertisement-content container flex justify-between items-center py-2.5\">\n <span className=\"s-advertisement-content-main flex-1 font-bold text-center text-sm\">\n {/* Rendered without an icon too, as the SDK does: its margin is part of the layout. */}\n <i\n className={`s-advertisement-content-icon inline-block align-middle me-2 text-base ${ad.icon ?? ''}`}\n />\n {ad.url ? (\n <a\n href={ad.url}\n target={ad.target ?? undefined}\n rel={ad.target === '_blank' ? 'noopener' : undefined}\n >\n {ad.description}\n </a>\n ) : (\n ad.description\n )}\n </span>\n <button\n type=\"button\"\n className=\"s-advertisement-action px-1\"\n aria-label={t('common.buttons.close', 'Close')}\n onClick={() => close(ad.id)}\n >\n {/* `inline-block`: before the icon CSS loads, an empty inline `<i>` leaves the button 0px tall. */}\n <i className=\"sicon-cancel inline-block\" />\n </button>\n </div>\n </div>\n ))}\n <script suppressHydrationWarning>{HIDE_DISMISSED_SCRIPT}</script>\n </>\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { registry } from './chunk-Y32RHCOH.js';
2
- import { useMoney, useNumber } from './chunk-6DTT6DFS.js';
2
+ import { useMoney, useNumber } from './chunk-V4ZRPTFE.js';
3
3
  import { useAsset } from './chunk-Z653O7MX.js';
4
4
  import { useWishlist } from './chunk-DVJGKIFQ.js';
5
5
  import { useTranslation } from './chunk-TYNZ5B2B.js';
@@ -230,5 +230,5 @@ var ProductCard = memo(function ProductCard2(props) {
230
230
  });
231
231
 
232
232
  export { ProductCard };
233
- //# sourceMappingURL=chunk-Z7SE66QV.js.map
234
- //# sourceMappingURL=chunk-Z7SE66QV.js.map
233
+ //# sourceMappingURL=chunk-C2MAZFIT.js.map
234
+ //# sourceMappingURL=chunk-C2MAZFIT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/product/ProductCard.tsx"],"names":["ProductCard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emo } from 'react';\nimport { SallaAddProductButton } from '@salla.sa/twilight-components-react/add-product-button';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\nimport { useHostAttributes } from '@salla.sa/twilight-theme-engine/hooks/useHostAttributes';\nimport { useMoney } from '../../hooks/useMoney';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useWishlist } from '../../hooks/useWishlist';\nimport { useAsset } from '../../hooks/useAsset';\nimport { useNumber } from '../../hooks/useNumber';\nimport { registry } from '../ComponentRegistry';\nimport { Image } from '../common';\nimport type { Product } from '../../types';\n\nconst PRODUCT_CARD_KEY = 'product:card';\n\nconst PRODUCT_IMAGE_SRCSET_WIDTHS = [150, 300, 450, 600] as const;\n/** Matches `.s-products-list-vertical-cards`: 2-col below 768px, 4-col above. */\nconst PRODUCT_IMAGE_SIZES = '(min-width: 768px) 25vw, 50vw';\n/** fullImage / minimal slots in FeaturedProductsStyle3 (`lg:grid-cols-2`). */\nconst PRODUCT_WIDE_IMAGE_SIZES = '(min-width: 1024px) 50vw, 100vw';\n\n/** Product card layout variants - mutually exclusive */\nexport type ProductCardLayout = 'vertical' | 'horizontal' | 'fullImage' | 'minimal' | 'special';\n\nexport interface ProductCardProps {\n product: Product;\n layout?: ProductCardLayout;\n className?: string;\n withShadow?: boolean;\n withQuantity?: boolean;\n withoutAddButton?: boolean;\n index?: number;\n imagePriority?: boolean;\n /** Overrides the layout-based image `sizes` hint. */\n sizes?: string;\n}\n\n/**\n * ProductCard - Displays a product in various layouts\n *\n * Layouts:\n * - vertical: Default card with image top, content bottom\n * - horizontal: Side-by-side image and content\n * - fullImage: Full bleed image with overlay content\n * - minimal: Compact version with reduced info\n * - special: Featured card with quantity pie chart\n *\n * Features:\n * - Native lazy loading for images\n * - Product badges (promotion, preorder, quantity, out of stock)\n * - Wishlist toggle button\n * - Price display (sale, starting, regular)\n * - Rating display\n * - Add to cart button via SallaAddProductButton (handles labels internally)\n */\nconst ProductCardContent = memo(function ProductCardContent({\n product,\n layout = 'vertical',\n className = '',\n withShadow = false,\n withQuantity = false,\n withoutAddButton = false,\n index = 0,\n imagePriority = false,\n sizes,\n}: ProductCardProps) {\n const { format } = useMoney();\n const { t } = useTranslation();\n const { store, theme, currency } = useTwilight();\n const wishlist = useWishlist();\n const { isPlaceholder } = useAsset();\n const { format: formatNumber } = useNumber();\n\n // Out-of-stock cards offer \"notify me when available\" instead of a dead button, unless\n // the merchant switched `notify_when_available_in_card` off (Twig theme-raed parity).\n const notifyInCard = theme?.settings?.notify_when_available_in_card !== false;\n const addButtonStatus =\n notifyInCard &&\n product.is_out_of_stock &&\n product.type !== 'donating' &&\n product.type !== 'financial_support'\n ? 'out-and-notify'\n : product.status;\n\n const addButtonRef = useHostAttributes({ fill: 'outline', width: 'wide' });\n\n // Layout flags\n const isVertical = layout === 'vertical';\n const isHorizontal = layout === 'horizontal';\n const isFullImage = layout === 'fullImage';\n const isMinimal = layout === 'minimal';\n const isSpecial = layout === 'special';\n\n // Wishlist status\n const productInWishlist = wishlist.has(Number(product.id));\n const handleWishlistToggle = useCallback(() => {\n wishlist.toggle(Number(product.id));\n }, [wishlist, product.id]);\n\n // Get image fit type from store settings\n const fitImageHeight = store?.settings?.product?.fit_type;\n\n // Product badge component\n const getProductBadge = () => {\n if (product?.preorder?.label && typeof product.preorder.label === 'string') {\n return <div className=\"s-product-card-promotion-title\">{product.preorder.label}</div>;\n }\n if (product.promotion_title) {\n return <div className=\"s-product-card-promotion-title\">{product.promotion_title}</div>;\n }\n if (withQuantity && product?.quantity) {\n const formattedQty = formatNumber(product.quantity);\n return (\n <div className=\"s-product-card-quantity\">\n {t('pages.products.remained', 'Remained')} {formattedQty}\n </div>\n );\n }\n if (withQuantity && product?.is_out_of_stock) {\n return (\n <div className=\"s-product-card-out-badge\">\n {t('pages.products.out_of_stock', 'Out of Stock')}\n </div>\n );\n }\n return null;\n };\n\n // List responses can convert prices to the visitor's currency while retaining the source currency.\n const priceOptions = { currency: currency?.code ?? product.currency };\n const getProductPrice = () => {\n if (product.is_on_sale && product.sale_price) {\n return (\n <div className=\"s-product-card-sale-price\">\n <h4>{format(product.sale_price, priceOptions)}</h4>\n {product.regular_price && <span>{format(product.regular_price, priceOptions)}</span>}\n </div>\n );\n }\n if (product.starting_price) {\n return (\n <div className=\"s-product-card-starting-price\">\n <p>{t('pages.products.starting_price', 'Starting from')}</p>\n <h4>{format(product.starting_price, priceOptions)}</h4>\n </div>\n );\n }\n return <h4 className=\"s-product-card-price\">{format(product.price, priceOptions)}</h4>;\n };\n\n // Build card class names\n const cardClassName = [\n 's-product-card',\n 's-product-card-entry',\n isVertical ? 's-product-card-vertical' : '',\n isHorizontal ? 's-product-card-horizontal' : '',\n // As Twig's card: the store's unified image height sizes horizontal cards too.\n fitImageHeight && (isVertical || isHorizontal) ? `s-product-card-fit-height` : '',\n isSpecial ? 's-product-card-special' : '',\n isFullImage ? 's-product-card-full-image' : '',\n isMinimal ? 's-product-card-minimal' : '',\n product?.donation ? 's-product-card-donation' : '',\n withShadow ? 's-product-card-shadow' : '',\n product?.is_out_of_stock ? 's-product-card-out-of-stock' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // Image fit class\n const isProductPlaceholder = isPlaceholder(product.image?.url);\n const imageFitClass = isProductPlaceholder ? 'contain' : fitImageHeight || 'cover';\n\n return (\n <div\n id={`product-card-${product.id}`}\n className={cardClassName}\n data-product-id={product.id}\n style={{\n animationDelay: `${index * 100}ms`,\n }}\n >\n <div className={isFullImage ? 's-product-card-image-full' : 's-product-card-image'}>\n <a href={product.url} aria-label={product.image?.alt || product.name}>\n <Image\n className={`s-product-card-image-${imageFitClass}`}\n src={product.image?.url}\n alt={product.image?.alt ?? product.name}\n width={300}\n height={300}\n sizes={\n sizes ?? (isFullImage || isMinimal ? PRODUCT_WIDE_IMAGE_SIZES : PRODUCT_IMAGE_SIZES)\n }\n srcSetWidths={PRODUCT_IMAGE_SRCSET_WIDTHS}\n aspectRatio=\"1/1\"\n priority={imagePriority}\n />\n {!isFullImage && !isMinimal && getProductBadge()}\n </a>\n {isFullImage && (\n <a href={product.url} aria-label={product.name} className=\"s-product-card-overlay\" />\n )}\n {!isHorizontal && !isFullImage && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n <div className=\"s-product-card-content\">\n {/* Special card: quantity pie */}\n {isSpecial && product?.quantity && (\n <div className=\"s-product-card-content-pie\">\n <span>\n <b>{formatNumber(product.quantity)}</b>\n {t('pages.products.remained', 'Remained')}\n </span>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"-2 -1 36 34\"\n className=\"s-product-card-content-pie-svg\"\n >\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n )}\n\n <div\n className={`s-product-card-content-main ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n <h3 className=\"s-product-card-content-title\">\n <a href={product.url}>{product.name}</a>\n </h3>\n {product.subtitle && !isMinimal && (\n <p className=\"s-product-card-content-subtitle opacity-80\">{product.subtitle}</p>\n )}\n </div>\n\n <div\n className={`s-product-card-content-sub ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n {!product?.donation?.can_donate && getProductPrice()}\n {product.rating?.stars && (\n <div className=\"s-product-card-rating\">\n <i className=\"sicon-star2 text-orange-300\" />\n <span>{product.rating.stars}</span>\n </div>\n )}\n </div>\n\n {!withoutAddButton && (\n <div className=\"s-product-card-content-footer gap-2\">\n <SallaAddProductButton\n ref={addButtonRef}\n fill=\"outline\"\n width=\"wide\"\n productId={product.id}\n productStatus={addButtonStatus}\n productType={product.type}\n hasPreOrder={product.has_preorder_campaign}\n />\n {(isHorizontal || isFullImage) && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n )}\n </div>\n </div>\n );\n});\n\nexport const ProductCard = memo(function ProductCard(props: ProductCardProps) {\n const Component = useMemo(() => {\n const hasOverride = registry.getOriginal<ProductCardProps>(PRODUCT_CARD_KEY) !== null;\n if (hasOverride) {\n return registry.resolve<ProductCardProps>(PRODUCT_CARD_KEY);\n }\n return null;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductCardContent {...props} />;\n});\n\nexport default ProductCard;\n"]}
1
+ {"version":3,"sources":["../src/components/product/ProductCard.tsx"],"names":["ProductCardContent","ProductCard"],"mappings":";;;;;;;;;;;;;AAcA,IAAM,gBAAA,GAAmB,cAAA;AAEzB,IAAM,2BAAA,GAA8B,CAAC,GAAA,EAAK,GAAA,EAAK,KAAK,GAAG,CAAA;AAEvD,IAAM,mBAAA,GAAsB,+BAAA;AAE5B,IAAM,wBAAA,GAA2B,iCAAA;AAoCjC,IAAM,kBAAA,GAAqB,IAAA,CAAK,SAASA,mBAAAA,CAAmB;AAAA,EAC1D,OAAA;AAAA,EACA,MAAA,GAAS,UAAA;AAAA,EACT,SAAA,GAAY,EAAA;AAAA,EACZ,UAAA,GAAa,KAAA;AAAA,EACb,YAAA,GAAe,KAAA;AAAA,EACf,gBAAA,GAAmB,KAAA;AAAA,EACnB,KAAA,GAAQ,CAAA;AAAA,EACR,aAAA,GAAgB,KAAA;AAAA,EAChB;AACF,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AA,EAAU,aAAA,EAAc;AAAA;AAAA;AAC7B,WAAA,EAEJ;AAAA,SAAA,EAEJ;AAAA;AAAA;AAAA,GACF;AAEJ,CAAC,CAAA;AAEM,IAAM,WAAA,GAAc,IAAA,CAAK,SAASC,YAAAA,CAAY,KAAA,EAAyB;AAC5E,EAAA,MAAM,SAAA,GAAY,QAAQ,MAAM;AAC9B,IAAA,MAAM,WAAA,GAAc,QAAA,CAAS,WAAA,CAA8B,gBAAgB,CAAA,KAAM,IAAA;AACjF,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,OAAO,QAAA,CAAS,QAA0B,gBAAgB,CAAA;AAAA,IAC5D;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,uBAAO,GAAA,CAAC,SAAA,EAAA,EAAW,GAAG,KAAA,EAAO,CAAA;AAAA,EAC/B;AAEA,EAAA,uBAAO,GAAA,CAAC,kBAAA,EAAA,EAAoB,GAAG,KAAA,EAAO,CAAA;AACxC,CAAC","file":"chunk-C2MAZFIT.js","sourcesContent":["import { memo, useCallback, useMemo } from 'react';\nimport { SallaAddProductButton } from '@salla.sa/twilight-components-react/add-product-button';\nimport { SallaButton } from '@salla.sa/twilight-components-react/button';\nimport { useHostAttributes } from '@salla.sa/twilight-theme-engine/hooks/useHostAttributes';\nimport { useMoney } from '../../hooks/useMoney';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useWishlist } from '../../hooks/useWishlist';\nimport { useAsset } from '../../hooks/useAsset';\nimport { useNumber } from '../../hooks/useNumber';\nimport { registry } from '../ComponentRegistry';\nimport { Image } from '../common';\nimport type { Product } from '../../types';\n\nconst PRODUCT_CARD_KEY = 'product:card';\n\nconst PRODUCT_IMAGE_SRCSET_WIDTHS = [150, 300, 450, 600] as const;\n/** Matches `.s-products-list-vertical-cards`: 2-col below 768px, 4-col above. */\nconst PRODUCT_IMAGE_SIZES = '(min-width: 768px) 25vw, 50vw';\n/** fullImage / minimal slots in FeaturedProductsStyle3 (`lg:grid-cols-2`). */\nconst PRODUCT_WIDE_IMAGE_SIZES = '(min-width: 1024px) 50vw, 100vw';\n\n/** Product card layout variants - mutually exclusive */\nexport type ProductCardLayout = 'vertical' | 'horizontal' | 'fullImage' | 'minimal' | 'special';\n\nexport interface ProductCardProps {\n product: Product;\n layout?: ProductCardLayout;\n className?: string;\n withShadow?: boolean;\n withQuantity?: boolean;\n withoutAddButton?: boolean;\n index?: number;\n imagePriority?: boolean;\n /** Overrides the layout-based image `sizes` hint. */\n sizes?: string;\n}\n\n/**\n * ProductCard - Displays a product in various layouts\n *\n * Layouts:\n * - vertical: Default card with image top, content bottom\n * - horizontal: Side-by-side image and content\n * - fullImage: Full bleed image with overlay content\n * - minimal: Compact version with reduced info\n * - special: Featured card with quantity pie chart\n *\n * Features:\n * - Native lazy loading for images\n * - Product badges (promotion, preorder, quantity, out of stock)\n * - Wishlist toggle button\n * - Price display (sale, starting, regular)\n * - Rating display\n * - Add to cart button via SallaAddProductButton (handles labels internally)\n */\nconst ProductCardContent = memo(function ProductCardContent({\n product,\n layout = 'vertical',\n className = '',\n withShadow = false,\n withQuantity = false,\n withoutAddButton = false,\n index = 0,\n imagePriority = false,\n sizes,\n}: ProductCardProps) {\n const { format } = useMoney();\n const { t } = useTranslation();\n const { store, theme, currency } = useTwilight();\n const wishlist = useWishlist();\n const { isPlaceholder } = useAsset();\n const { format: formatNumber } = useNumber();\n\n // Out-of-stock cards offer \"notify me when available\" instead of a dead button, unless\n // the merchant switched `notify_when_available_in_card` off (Twig theme-raed parity).\n const notifyInCard = theme?.settings?.notify_when_available_in_card !== false;\n const addButtonStatus =\n notifyInCard &&\n product.is_out_of_stock &&\n product.type !== 'donating' &&\n product.type !== 'financial_support'\n ? 'out-and-notify'\n : product.status;\n\n const addButtonRef = useHostAttributes({ fill: 'outline', width: 'wide' });\n\n // Layout flags\n const isVertical = layout === 'vertical';\n const isHorizontal = layout === 'horizontal';\n const isFullImage = layout === 'fullImage';\n const isMinimal = layout === 'minimal';\n const isSpecial = layout === 'special';\n\n // Wishlist status\n const productInWishlist = wishlist.has(Number(product.id));\n const handleWishlistToggle = useCallback(() => {\n wishlist.toggle(Number(product.id));\n }, [wishlist, product.id]);\n\n // Get image fit type from store settings\n const fitImageHeight = store?.settings?.product?.fit_type;\n\n // Product badge component\n const getProductBadge = () => {\n if (product?.preorder?.label && typeof product.preorder.label === 'string') {\n return <div className=\"s-product-card-promotion-title\">{product.preorder.label}</div>;\n }\n if (product.promotion_title) {\n return <div className=\"s-product-card-promotion-title\">{product.promotion_title}</div>;\n }\n if (withQuantity && product?.quantity) {\n const formattedQty = formatNumber(product.quantity);\n return (\n <div className=\"s-product-card-quantity\">\n {t('pages.products.remained', 'Remained')} {formattedQty}\n </div>\n );\n }\n if (withQuantity && product?.is_out_of_stock) {\n return (\n <div className=\"s-product-card-out-badge\">\n {t('pages.products.out_of_stock', 'Out of Stock')}\n </div>\n );\n }\n return null;\n };\n\n // List responses can convert prices to the visitor's currency while retaining the source currency.\n const priceOptions = { currency: currency?.code ?? product.currency };\n const getProductPrice = () => {\n if (product.is_on_sale && product.sale_price) {\n return (\n <div className=\"s-product-card-sale-price\">\n <h4>{format(product.sale_price, priceOptions)}</h4>\n {product.regular_price && <span>{format(product.regular_price, priceOptions)}</span>}\n </div>\n );\n }\n if (product.starting_price) {\n return (\n <div className=\"s-product-card-starting-price\">\n <p>{t('pages.products.starting_price', 'Starting from')}</p>\n <h4>{format(product.starting_price, priceOptions)}</h4>\n </div>\n );\n }\n return <h4 className=\"s-product-card-price\">{format(product.price, priceOptions)}</h4>;\n };\n\n // Build card class names\n const cardClassName = [\n 's-product-card',\n 's-product-card-entry',\n isVertical ? 's-product-card-vertical' : '',\n isHorizontal ? 's-product-card-horizontal' : '',\n // As Twig's card: the store's unified image height sizes horizontal cards too.\n fitImageHeight && (isVertical || isHorizontal) ? `s-product-card-fit-height` : '',\n isSpecial ? 's-product-card-special' : '',\n isFullImage ? 's-product-card-full-image' : '',\n isMinimal ? 's-product-card-minimal' : '',\n product?.donation ? 's-product-card-donation' : '',\n withShadow ? 's-product-card-shadow' : '',\n product?.is_out_of_stock ? 's-product-card-out-of-stock' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n // Image fit class\n const isProductPlaceholder = isPlaceholder(product.image?.url);\n const imageFitClass = isProductPlaceholder ? 'contain' : fitImageHeight || 'cover';\n\n return (\n <div\n id={`product-card-${product.id}`}\n className={cardClassName}\n data-product-id={product.id}\n style={{\n animationDelay: `${index * 100}ms`,\n }}\n >\n <div className={isFullImage ? 's-product-card-image-full' : 's-product-card-image'}>\n <a href={product.url} aria-label={product.image?.alt || product.name}>\n <Image\n className={`s-product-card-image-${imageFitClass}`}\n src={product.image?.url}\n alt={product.image?.alt ?? product.name}\n width={300}\n height={300}\n sizes={\n sizes ?? (isFullImage || isMinimal ? PRODUCT_WIDE_IMAGE_SIZES : PRODUCT_IMAGE_SIZES)\n }\n srcSetWidths={PRODUCT_IMAGE_SRCSET_WIDTHS}\n aspectRatio=\"1/1\"\n priority={imagePriority}\n />\n {!isFullImage && !isMinimal && getProductBadge()}\n </a>\n {isFullImage && (\n <a href={product.url} aria-label={product.name} className=\"s-product-card-overlay\" />\n )}\n {!isHorizontal && !isFullImage && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n <div className=\"s-product-card-content\">\n {/* Special card: quantity pie */}\n {isSpecial && product?.quantity && (\n <div className=\"s-product-card-content-pie\">\n <span>\n <b>{formatNumber(product.quantity)}</b>\n {t('pages.products.remained', 'Remained')}\n </span>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"-2 -1 36 34\"\n className=\"s-product-card-content-pie-svg\"\n >\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" className=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n )}\n\n <div\n className={`s-product-card-content-main ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n <h3 className=\"s-product-card-content-title\">\n <a href={product.url}>{product.name}</a>\n </h3>\n {product.subtitle && !isMinimal && (\n <p className=\"s-product-card-content-subtitle opacity-80\">{product.subtitle}</p>\n )}\n </div>\n\n <div\n className={`s-product-card-content-sub ${isSpecial ? 's-product-card-content-extra-padding' : ''}`}\n >\n {!product?.donation?.can_donate && getProductPrice()}\n {product.rating?.stars && (\n <div className=\"s-product-card-rating\">\n <i className=\"sicon-star2 text-orange-300\" />\n <span>{product.rating.stars}</span>\n </div>\n )}\n </div>\n\n {!withoutAddButton && (\n <div className=\"s-product-card-content-footer gap-2\">\n <SallaAddProductButton\n ref={addButtonRef}\n fill=\"outline\"\n width=\"wide\"\n productId={product.id}\n productStatus={addButtonStatus}\n productType={product.type}\n hasPreOrder={product.has_preorder_campaign}\n />\n {(isHorizontal || isFullImage) && (\n <SallaButton\n shape=\"icon\"\n fill=\"outline\"\n color=\"light\"\n ariaLabel={t('pages.wishlist.toggle', 'Add or remove to wishlist')}\n className={`s-product-card-wishlist-btn animated ${productInWishlist ? 's-product-card-wishlist-added pulse-anime' : 'not-added un-favorited'}`}\n onClick={handleWishlistToggle}\n data-id={product.id}\n >\n <i className=\"sicon-heart\" />\n </SallaButton>\n )}\n </div>\n )}\n </div>\n </div>\n );\n});\n\nexport const ProductCard = memo(function ProductCard(props: ProductCardProps) {\n const Component = useMemo(() => {\n const hasOverride = registry.getOriginal<ProductCardProps>(PRODUCT_CARD_KEY) !== null;\n if (hasOverride) {\n return registry.resolve<ProductCardProps>(PRODUCT_CARD_KEY);\n }\n return null;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductCardContent {...props} />;\n});\n\nexport default ProductCard;\n"]}