@salla.sa/twilight-theme-engine 1.0.116 → 1.0.118

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 (239) hide show
  1. package/dist/{AddToCartForm-6NCWP2NI.js → AddToCartForm-QYSEYGYJ.js} +3 -3
  2. package/dist/{AddToCartForm-6NCWP2NI.js.map → AddToCartForm-QYSEYGYJ.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-NLVQF5Q5.js → BlogAuthorPage-ZDQE2AZX.js} +22 -22
  4. package/dist/{BlogAuthorPage-NLVQF5Q5.js.map → BlogAuthorPage-ZDQE2AZX.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-4QUIKTSA.js → BlogCategoryPage-2F5MARO5.js} +22 -22
  6. package/dist/{BlogCategoryPage-4QUIKTSA.js.map → BlogCategoryPage-2F5MARO5.js.map} +1 -1
  7. package/dist/{BlogPage-XB2D5HHJ.js → BlogPage-CAVVNZ4W.js} +20 -20
  8. package/dist/{BlogPage-XB2D5HHJ.js.map → BlogPage-CAVVNZ4W.js.map} +1 -1
  9. package/dist/{BlogSinglePage-KA66R2CQ.js → BlogSinglePage-Z2HIKZNQ.js} +20 -20
  10. package/dist/{BlogSinglePage-KA66R2CQ.js.map → BlogSinglePage-Z2HIKZNQ.js.map} +1 -1
  11. package/dist/{BlogTagPage-MBRDNQVV.js → BlogTagPage-2ULPCKZI.js} +22 -22
  12. package/dist/{BlogTagPage-MBRDNQVV.js.map → BlogTagPage-2ULPCKZI.js.map} +1 -1
  13. package/dist/{BrandsPage-NFKQQEAI.js → BrandsPage-TWEXYBHF.js} +21 -21
  14. package/dist/{BrandsPage-NFKQQEAI.js.map → BrandsPage-TWEXYBHF.js.map} +1 -1
  15. package/dist/{Breadcrumb-VZTWGT26.js → Breadcrumb-EWUPYS3P.js} +20 -20
  16. package/dist/{Breadcrumb-VZTWGT26.js.map → Breadcrumb-EWUPYS3P.js.map} +1 -1
  17. package/dist/{CartItem-EFDQLYP7.js → CartItem-WREXJVPL.js} +20 -20
  18. package/dist/{CartItem-EFDQLYP7.js.map → CartItem-WREXJVPL.js.map} +1 -1
  19. package/dist/{CartSummary-PJDCLQTS.js → CartSummary-UOQRTFXF.js} +20 -20
  20. package/dist/{CartSummary-PJDCLQTS.js.map → CartSummary-UOQRTFXF.js.map} +1 -1
  21. package/dist/{Copyright-HAU4I2CU.js → Copyright-THOU54OW.js} +3 -3
  22. package/dist/{Copyright-HAU4I2CU.js.map → Copyright-THOU54OW.js.map} +1 -1
  23. package/dist/{CustomerLayout-IHB3VD3E.js → CustomerLayout-52HRHKMR.js} +20 -20
  24. package/dist/{CustomerLayout-IHB3VD3E.js.map → CustomerLayout-52HRHKMR.js.map} +1 -1
  25. package/dist/{Footer-GKYZN2IF.js → Footer-J22W5XIY.js} +4 -4
  26. package/dist/{Footer-GKYZN2IF.js.map → Footer-J22W5XIY.js.map} +1 -1
  27. package/dist/{Header-OUMPXV42.js → Header-YTBXJUWG.js} +10 -10
  28. package/dist/{Header-OUMPXV42.js.map → Header-YTBXJUWG.js.map} +1 -1
  29. package/dist/{LoyaltyPage-RLDDXCXX.js → LoyaltyPage-VYRO57M7.js} +20 -20
  30. package/dist/{LoyaltyPage-RLDDXCXX.js.map → LoyaltyPage-VYRO57M7.js.map} +1 -1
  31. package/dist/{LoyaltyPointsPage-O5KWIEY2.js → LoyaltyPointsPage-EBXM7KN3.js} +7 -7
  32. package/dist/{LoyaltyPointsPage-O5KWIEY2.js.map → LoyaltyPointsPage-EBXM7KN3.js.map} +1 -1
  33. package/dist/{MainMenu-LJIJY4AX.js → MainMenu-ESHMVSQT.js} +6 -6
  34. package/dist/{MainMenu-LJIJY4AX.js.map → MainMenu-ESHMVSQT.js.map} +1 -1
  35. package/dist/{MasterLayout-FNC6M7D7.js → MasterLayout-GPOW75JW.js} +20 -20
  36. package/dist/{MasterLayout-FNC6M7D7.js.map → MasterLayout-GPOW75JW.js.map} +1 -1
  37. package/dist/{MobileMenu-BRKNE7QW.js → MobileMenu-YRIGGD3A.js} +21 -21
  38. package/dist/{MobileMenu-BRKNE7QW.js.map → MobileMenu-YRIGGD3A.js.map} +1 -1
  39. package/dist/{NotificationsPage-PUFFEJJL.js → NotificationsPage-YWA3WHKP.js} +20 -20
  40. package/dist/{NotificationsPage-PUFFEJJL.js.map → NotificationsPage-YWA3WHKP.js.map} +1 -1
  41. package/dist/{OrderSinglePage-DPRCLI7U.js → OrderSinglePage-FIJTEFHJ.js} +21 -21
  42. package/dist/{OrderSinglePage-DPRCLI7U.js.map → OrderSinglePage-FIJTEFHJ.js.map} +1 -1
  43. package/dist/{OrdersPage-YCF2F4CC.js → OrdersPage-CSQPJ3A2.js} +20 -20
  44. package/dist/{OrdersPage-YCF2F4CC.js.map → OrdersPage-CSQPJ3A2.js.map} +1 -1
  45. package/dist/{PageSingle-UIFZXJIV.js → PageSingle-UIJ3USK4.js} +5 -5
  46. package/dist/{PageSingle-UIFZXJIV.js.map → PageSingle-UIJ3USK4.js.map} +1 -1
  47. package/dist/{ProductDetails-73Q6BYGA.js → ProductDetails-F5CTHGCT.js} +6 -6
  48. package/dist/{ProductDetails-73Q6BYGA.js.map → ProductDetails-F5CTHGCT.js.map} +1 -1
  49. package/dist/{ProfilePage-ZD5E4OGM.js → ProfilePage-P2FZ4KCI.js} +20 -20
  50. package/dist/{ProfilePage-ZD5E4OGM.js.map → ProfilePage-P2FZ4KCI.js.map} +1 -1
  51. package/dist/{ReviewsPage-5WOXAZDE.js → ReviewsPage-X37ZSSWG.js} +3 -3
  52. package/dist/{ReviewsPage-5WOXAZDE.js.map → ReviewsPage-X37ZSSWG.js.map} +1 -1
  53. package/dist/{SeoCartWidget-GYAGYAX2.js → SeoCartWidget-ZDYIBND6.js} +20 -20
  54. package/dist/{SeoCartWidget-GYAGYAX2.js.map → SeoCartWidget-ZDYIBND6.js.map} +1 -1
  55. package/dist/{SettingsPage-7CU5SRJO.js → SettingsPage-R6G63QP4.js} +20 -20
  56. package/dist/{SettingsPage-7CU5SRJO.js.map → SettingsPage-R6G63QP4.js.map} +1 -1
  57. package/dist/{StoreClosedNotification-O5YSPII4.js → StoreClosedNotification-Q7TMNZEX.js} +21 -21
  58. package/dist/{StoreClosedNotification-O5YSPII4.js.map → StoreClosedNotification-Q7TMNZEX.js.map} +1 -1
  59. package/dist/{TestimonialsPage-BFEG7S6W.js → TestimonialsPage-RZ77X7BG.js} +5 -5
  60. package/dist/{TestimonialsPage-BFEG7S6W.js.map → TestimonialsPage-RZ77X7BG.js.map} +1 -1
  61. package/dist/{ThankYouPage-5QENDZTM.js → ThankYouPage-WDABLHMH.js} +20 -20
  62. package/dist/{ThankYouPage-5QENDZTM.js.map → ThankYouPage-WDABLHMH.js.map} +1 -1
  63. package/dist/{WalletPage-EYTVKQMV.js → WalletPage-SGB23HK3.js} +21 -21
  64. package/dist/{WalletPage-EYTVKQMV.js.map → WalletPage-SGB23HK3.js.map} +1 -1
  65. package/dist/{WishlistPage-LT7TOAM3.js → WishlistPage-QZADACKT.js} +22 -22
  66. package/dist/{WishlistPage-LT7TOAM3.js.map → WishlistPage-QZADACKT.js.map} +1 -1
  67. package/dist/api/advertisement.js +3 -3
  68. package/dist/api/apps.js +3 -3
  69. package/dist/api/blog.js +5 -5
  70. package/dist/api/brands.js +5 -5
  71. package/dist/api/cart.js +5 -5
  72. package/dist/api/category.js +5 -5
  73. package/dist/api/client.js +2 -2
  74. package/dist/api/home.js +3 -3
  75. package/dist/api/loyalty.js +5 -5
  76. package/dist/api/menu.js +3 -3
  77. package/dist/api/notification.js +3 -3
  78. package/dist/api/order.js +5 -5
  79. package/dist/api/page.js +5 -5
  80. package/dist/api/product.js +5 -5
  81. package/dist/api/profile.js +2 -2
  82. package/dist/api/store.js +3 -3
  83. package/dist/api/translations.js +3 -3
  84. package/dist/api/user.js +3 -3
  85. package/dist/api/wallet.js +3 -3
  86. package/dist/api/wishlist.js +6 -6
  87. package/dist/{chunk-7AIDISU2.js → chunk-2TLIULJZ.js} +3 -3
  88. package/dist/{chunk-7AIDISU2.js.map → chunk-2TLIULJZ.js.map} +1 -1
  89. package/dist/{chunk-WBL7MSKQ.js → chunk-3WGZZD2Y.js} +4 -4
  90. package/dist/{chunk-WBL7MSKQ.js.map → chunk-3WGZZD2Y.js.map} +1 -1
  91. package/dist/{chunk-CGHCXWV2.js → chunk-4EATTQQA.js} +3 -3
  92. package/dist/{chunk-CGHCXWV2.js.map → chunk-4EATTQQA.js.map} +1 -1
  93. package/dist/{chunk-HFGOFYQX.js → chunk-4FUSNRFO.js} +3 -3
  94. package/dist/{chunk-HFGOFYQX.js.map → chunk-4FUSNRFO.js.map} +1 -1
  95. package/dist/{chunk-V3NOBNNU.js → chunk-5CKTQAFX.js} +3 -3
  96. package/dist/{chunk-V3NOBNNU.js.map → chunk-5CKTQAFX.js.map} +1 -1
  97. package/dist/{chunk-BLIH42Y6.js → chunk-6KCK7SG7.js} +7 -7
  98. package/dist/{chunk-BLIH42Y6.js.map → chunk-6KCK7SG7.js.map} +1 -1
  99. package/dist/{chunk-4ZTHNUB7.js → chunk-B3QDJK2B.js} +7 -7
  100. package/dist/{chunk-4ZTHNUB7.js.map → chunk-B3QDJK2B.js.map} +1 -1
  101. package/dist/{chunk-GFZEZQ45.js → chunk-B6JTC5R6.js} +4 -4
  102. package/dist/{chunk-GFZEZQ45.js.map → chunk-B6JTC5R6.js.map} +1 -1
  103. package/dist/{chunk-D3PO3ICA.js → chunk-BK5TBUGG.js} +3 -3
  104. package/dist/{chunk-D3PO3ICA.js.map → chunk-BK5TBUGG.js.map} +1 -1
  105. package/dist/{chunk-Z3EAHRXR.js → chunk-BSJPKSKE.js} +38 -13
  106. package/dist/chunk-BSJPKSKE.js.map +1 -0
  107. package/dist/{chunk-L34CKKVC.js → chunk-CVBRA2LE.js} +3 -3
  108. package/dist/{chunk-L34CKKVC.js.map → chunk-CVBRA2LE.js.map} +1 -1
  109. package/dist/{chunk-75TXHISE.js → chunk-D2RUSG36.js} +4 -4
  110. package/dist/{chunk-75TXHISE.js.map → chunk-D2RUSG36.js.map} +1 -1
  111. package/dist/{chunk-5G6PD6P2.js → chunk-E552K72T.js} +3 -3
  112. package/dist/{chunk-5G6PD6P2.js.map → chunk-E552K72T.js.map} +1 -1
  113. package/dist/{chunk-7EZZR4WA.js → chunk-EFCIK5NI.js} +4 -4
  114. package/dist/{chunk-7EZZR4WA.js.map → chunk-EFCIK5NI.js.map} +1 -1
  115. package/dist/{chunk-7QHK77KL.js → chunk-EFT442TN.js} +4 -4
  116. package/dist/{chunk-7QHK77KL.js.map → chunk-EFT442TN.js.map} +1 -1
  117. package/dist/{chunk-DGTFJWBV.js → chunk-GEGB34LB.js} +4 -4
  118. package/dist/{chunk-DGTFJWBV.js.map → chunk-GEGB34LB.js.map} +1 -1
  119. package/dist/{chunk-3GDJMMMS.js → chunk-GYXUYHKO.js} +41 -6
  120. package/dist/chunk-GYXUYHKO.js.map +1 -0
  121. package/dist/{chunk-LQ4X4YQM.js → chunk-HUQU5NB5.js} +23 -21
  122. package/dist/chunk-HUQU5NB5.js.map +1 -0
  123. package/dist/{chunk-BVMHRVCG.js → chunk-JGVEGQHJ.js} +3 -3
  124. package/dist/{chunk-BVMHRVCG.js.map → chunk-JGVEGQHJ.js.map} +1 -1
  125. package/dist/{chunk-UHXL4VZS.js → chunk-JHTTTXTI.js} +4 -4
  126. package/dist/{chunk-UHXL4VZS.js.map → chunk-JHTTTXTI.js.map} +1 -1
  127. package/dist/chunk-JJ7VOYWQ.js +14 -0
  128. package/dist/{chunk-GPWNE2C6.js.map → chunk-JJ7VOYWQ.js.map} +1 -1
  129. package/dist/{chunk-5CEVDCMY.js → chunk-L4TQBWR7.js} +3 -3
  130. package/dist/{chunk-5CEVDCMY.js.map → chunk-L4TQBWR7.js.map} +1 -1
  131. package/dist/{chunk-6D3OWIEC.js → chunk-LPCNDH4F.js} +4 -3
  132. package/dist/chunk-LPCNDH4F.js.map +1 -0
  133. package/dist/{chunk-ZGVBXJQO.js → chunk-ME4UKH7Y.js} +5 -5
  134. package/dist/{chunk-ZGVBXJQO.js.map → chunk-ME4UKH7Y.js.map} +1 -1
  135. package/dist/{chunk-DGCHTKPZ.js → chunk-MKDS22Q3.js} +8 -8
  136. package/dist/{chunk-DGCHTKPZ.js.map → chunk-MKDS22Q3.js.map} +1 -1
  137. package/dist/{chunk-YWDMDW2K.js → chunk-MQALPNFL.js} +4 -4
  138. package/dist/{chunk-YWDMDW2K.js.map → chunk-MQALPNFL.js.map} +1 -1
  139. package/dist/{chunk-4ODMWV34.js → chunk-MQTO6I7W.js} +4 -4
  140. package/dist/{chunk-4ODMWV34.js.map → chunk-MQTO6I7W.js.map} +1 -1
  141. package/dist/{chunk-JVAFKLXJ.js → chunk-NEHOBD4K.js} +3 -3
  142. package/dist/{chunk-JVAFKLXJ.js.map → chunk-NEHOBD4K.js.map} +1 -1
  143. package/dist/{chunk-CDOGKC7B.js → chunk-NU2LPGNB.js} +5 -5
  144. package/dist/{chunk-CDOGKC7B.js.map → chunk-NU2LPGNB.js.map} +1 -1
  145. package/dist/{chunk-M46EKE7R.js → chunk-PFAPRJVF.js} +5 -31
  146. package/dist/chunk-PFAPRJVF.js.map +1 -0
  147. package/dist/{chunk-ZMXHQKZS.js → chunk-PRA6E6SQ.js} +4 -4
  148. package/dist/{chunk-ZMXHQKZS.js.map → chunk-PRA6E6SQ.js.map} +1 -1
  149. package/dist/{chunk-7ANH3RD5.js → chunk-QXYSINUS.js} +4 -4
  150. package/dist/{chunk-7ANH3RD5.js.map → chunk-QXYSINUS.js.map} +1 -1
  151. package/dist/{chunk-OU2KIHZI.js → chunk-RVPC4AYT.js} +3 -3
  152. package/dist/{chunk-OU2KIHZI.js.map → chunk-RVPC4AYT.js.map} +1 -1
  153. package/dist/{chunk-KXD4WUYA.js → chunk-T23HXVW5.js} +14 -7
  154. package/dist/chunk-T23HXVW5.js.map +1 -0
  155. package/dist/{chunk-X7A6BCYN.js → chunk-TYYXLAOZ.js} +7 -7
  156. package/dist/{chunk-X7A6BCYN.js.map → chunk-TYYXLAOZ.js.map} +1 -1
  157. package/dist/{chunk-SW4WGOLU.js → chunk-UMTMIMH7.js} +3 -3
  158. package/dist/{chunk-SW4WGOLU.js.map → chunk-UMTMIMH7.js.map} +1 -1
  159. package/dist/{chunk-P7A24TSM.js → chunk-V2M5YNZQ.js} +3 -3
  160. package/dist/{chunk-P7A24TSM.js.map → chunk-V2M5YNZQ.js.map} +1 -1
  161. package/dist/{chunk-WBXIDILF.js → chunk-VI2WHQDR.js} +3 -3
  162. package/dist/{chunk-WBXIDILF.js.map → chunk-VI2WHQDR.js.map} +1 -1
  163. package/dist/{chunk-W6LB5TRO.js → chunk-VSK2WS4G.js} +3 -3
  164. package/dist/{chunk-W6LB5TRO.js.map → chunk-VSK2WS4G.js.map} +1 -1
  165. package/dist/{chunk-OKCNKVB5.js → chunk-VT6FE3CB.js} +3 -3
  166. package/dist/{chunk-OKCNKVB5.js.map → chunk-VT6FE3CB.js.map} +1 -1
  167. package/dist/{chunk-4TM54PZO.js → chunk-VXSBJZ3E.js} +4 -4
  168. package/dist/{chunk-4TM54PZO.js.map → chunk-VXSBJZ3E.js.map} +1 -1
  169. package/dist/{chunk-QQTY4PDC.js → chunk-W6NQM4FQ.js} +3 -3
  170. package/dist/{chunk-QQTY4PDC.js.map → chunk-W6NQM4FQ.js.map} +1 -1
  171. package/dist/{chunk-74W2O47D.js → chunk-XMFVSBEO.js} +3 -3
  172. package/dist/{chunk-74W2O47D.js.map → chunk-XMFVSBEO.js.map} +1 -1
  173. package/dist/{chunk-RR2RWSCF.js → chunk-XSJ3YUSS.js} +7 -7
  174. package/dist/{chunk-RR2RWSCF.js.map → chunk-XSJ3YUSS.js.map} +1 -1
  175. package/dist/{chunk-JZ2SYFVR.js → chunk-YAVIABRR.js} +5 -5
  176. package/dist/{chunk-JZ2SYFVR.js.map → chunk-YAVIABRR.js.map} +1 -1
  177. package/dist/components/cart/index.js +1 -1
  178. package/dist/components/common/index.js +1 -1
  179. package/dist/components/drawer/index.js +18 -18
  180. package/dist/components/home/index.js +22 -22
  181. package/dist/components/layout/index.js +5 -5
  182. package/dist/components/product/index.js +19 -19
  183. package/dist/components/store/index.js +19 -19
  184. package/dist/components/toast/index.js +3 -3
  185. package/dist/dev/editor/index.js +1 -1
  186. package/dist/dev/index.js +1 -1
  187. package/dist/{document-class-YRZ37ED3.js → document-class-HCJFZSJ2.js} +13 -13
  188. package/dist/{document-class-YRZ37ED3.js.map → document-class-HCJFZSJ2.js.map} +1 -1
  189. package/dist/hooks/index.js +18 -18
  190. package/dist/hooks/useComments.js +2 -2
  191. package/dist/hooks/useGtm.js +18 -18
  192. package/dist/hooks/useMoney.js +18 -18
  193. package/dist/hooks/useProduct.js +2 -2
  194. package/dist/hooks/useStore.js +18 -18
  195. package/dist/hooks/useUser.js +4 -4
  196. package/dist/hooks/useWishlist.js +2 -2
  197. package/dist/index.js +18 -18
  198. package/dist/native-app/index.js +2 -2
  199. package/dist/{navigation-ZTRVRY6C.js → navigation-2V7R2ANX.js} +7 -7
  200. package/dist/{navigation-ZTRVRY6C.js.map → navigation-2V7R2ANX.js.map} +1 -1
  201. package/dist/{navigation-PALPE7RN.js → navigation-LRBZCNKS.js} +6 -6
  202. package/dist/{navigation-PALPE7RN.js.map → navigation-LRBZCNKS.js.map} +1 -1
  203. package/dist/{not-found-UD7MDFAE.js → not-found-ZJ64R3RS.js} +21 -21
  204. package/dist/{not-found-UD7MDFAE.js.map → not-found-ZJ64R3RS.js.map} +1 -1
  205. package/dist/providers/NavigationProvider.d.ts +4 -0
  206. package/dist/providers/NavigationProvider.d.ts.map +1 -1
  207. package/dist/providers/index.js +18 -18
  208. package/dist/providers/twilight-init.d.ts.map +1 -1
  209. package/dist/routes/account/orders.js +6 -6
  210. package/dist/routes/account.js +15 -15
  211. package/dist/routes/blog.js +10 -10
  212. package/dist/routes/brands.js +6 -6
  213. package/dist/routes/cart.js +26 -26
  214. package/dist/routes/home.js +23 -23
  215. package/dist/routes/index.js +5 -5
  216. package/dist/routes/loyalty.js +7 -7
  217. package/dist/routes/page.js +6 -6
  218. package/dist/routes/product-listing.js +24 -24
  219. package/dist/routes/product.js +22 -22
  220. package/dist/routes/seo-redirects.js +5 -5
  221. package/dist/routes/testimonials.js +2 -2
  222. package/dist/routes/thank-you.js +6 -6
  223. package/dist/skeleton.js +23 -23
  224. package/dist/{store-lookup-6QB4WMID.js → store-lookup-YUA66JS6.js} +10 -10
  225. package/dist/{store-lookup-6QB4WMID.js.map → store-lookup-YUA66JS6.js.map} +1 -1
  226. package/dist/tanstack/router.d.ts +17 -0
  227. package/dist/tanstack/router.d.ts.map +1 -1
  228. package/dist/tanstack.js +13 -13
  229. package/dist/utils/index.js +3 -3
  230. package/dist/utils/sdk-helpers.d.ts +12 -1
  231. package/dist/utils/sdk-helpers.d.ts.map +1 -1
  232. package/package.json +1 -1
  233. package/dist/chunk-3GDJMMMS.js.map +0 -1
  234. package/dist/chunk-6D3OWIEC.js.map +0 -1
  235. package/dist/chunk-GPWNE2C6.js +0 -14
  236. package/dist/chunk-KXD4WUYA.js.map +0 -1
  237. package/dist/chunk-LQ4X4YQM.js.map +0 -1
  238. package/dist/chunk-M46EKE7R.js.map +0 -1
  239. package/dist/chunk-Z3EAHRXR.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useWishlist.ts"],"names":[],"mappings":";;;;;AAuCA,IAAM,oBAAA,GAAuB,iBAAA;AAE7B,IAAI,MAAgB,EAAC;AACrB,IAAM,SAAA,uBAAgB,GAAA,EAAgB;AACtC,IAAI,UAAA,GAAa,KAAA;AAEjB,SAAS,UAAA,GAAa;AACpB,EAAA,KAAA,MAAW,QAAA,IAAY,WAAW,QAAA,EAAS;AAC7C;AAEA,SAAS,UAAU,QAAA,EAAsB;AACvC,EAAA,SAAA,CAAU,IAAI,QAAQ,CAAA;AACtB,EAAA,OAAO,MAAM;AACX,IAAA,SAAA,CAAU,OAAO,QAAQ,CAAA;AAAA,EAC3B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AAA,CAAO,SAAS,CAAA,GAAI,GAAA,CAAI,SAAS,CAAA;AAAA,IAC1E,CAAC,GAAA,EAAK,KAAA,EAAO,QAAQ;AAAA,GACvB;AAEA,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,SAAA;AAAA,IACL,OAAO,SAAA,CAAU,MAAA;AAAA,IACjB,GAAA;AAAA,IACA,GAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA,EAAS,QAAA,CAAS,OAAA,IAAW,WAAA,CAAY,OAAA;AAAA,IACzC,KAAA,EAAA,CAAQ,QAAA,CAAS,KAAA,IAAS,WAAA,CAAY,QAAQ,OAAA,IAAW;AAAA,GAC3D;AACF;AAEO,SAAS,kBAAA,GAAqB;AACnC,EAAA,GAAA,GAAM,EAAC;AACP,EAAA,SAAA,CAAU,KAAA,EAAM;AAChB,EAAA,UAAA,GAAa,KAAA;AACf","file":"chunk-BVMHRVCG.js","sourcesContent":["import { useCallback, useSyncExternalStore } from 'react';\nimport { useAsyncFn } from './useAsyncFn';\nimport { useTranslation } from '../providers/I18nProvider';\nimport { onSallaEvent, whenSallaLoaded } from '../utils/sdk-helpers';\nimport type { UseToggleWithItems } from './types';\n\nexport type UseWishlistResult = UseToggleWithItems<number>;\n\n/**\n * useWishlist - Hook for managing wishlist functionality\n *\n * Provides wishlist product management with local storage persistence\n * and Salla SDK integration. Syncs with the SDK's wishlist state and\n * listens for events to maintain real-time consistency.\n *\n * Uses a module-level singleton store so SDK event listeners are\n * registered ONCE globally — not per-component. All hook instances\n * share the same state via `useSyncExternalStore`.\n *\n * @returns Wishlist state and management functions\n *\n * @example\n * ```tsx\n * function WishlistButton({ productId }) {\n * const { has, toggle, loading } = useWishlist();\n *\n * return (\n * <button\n * onClick={() => toggle(productId)}\n * disabled={loading}\n * className={has(productId) ? 'liked' : ''}\n * >\n * ❤️\n * </button>\n * );\n * }\n * ```\n */\n\nconst WISHLIST_STORAGE_KEY = 'salla::wishlist';\n\nlet ids: number[] = [];\nconst listeners = new Set<() => void>();\nlet subscribed = false;\n\nfunction emitChange() {\n for (const listener of listeners) listener();\n}\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nfunction getSnapshot(): number[] {\n return ids;\n}\n\nconst getServerSnapshot = (): number[] => [];\n\nfunction persistIds() {\n try {\n localStorage.setItem(WISHLIST_STORAGE_KEY, JSON.stringify(ids));\n } catch {\n /* ignore storage errors */\n }\n}\n\nfunction initFromStorage() {\n try {\n // `storage` is missing while `window.salla` is still the head script's stub.\n const sdkWishlist = window.salla?.storage?.get(WISHLIST_STORAGE_KEY, []);\n const stored = localStorage.getItem(WISHLIST_STORAGE_KEY);\n const parsed = stored ? JSON.parse(stored) : [];\n ids = Array.isArray(sdkWishlist) && sdkWishlist.length > 0 ? sdkWishlist : parsed;\n } catch {\n /* ignore storage errors */\n }\n}\n\nfunction reloadFromStorage() {\n initFromStorage();\n emitChange();\n}\n\nfunction ensureSubscribed() {\n if (subscribed || typeof window === 'undefined') return;\n subscribed = true;\n initFromStorage();\n\n // On a cold load hydration runs before the SDK has loaded.\n whenSallaLoaded((salla) => {\n reloadFromStorage();\n if (!salla.wishlist?.event) return;\n\n salla.wishlist.event.onAdded((_event: unknown, id: number) => {\n if (ids.includes(id)) return;\n ids = [...ids, id];\n persistIds();\n emitChange();\n });\n\n salla.wishlist.event.onRemoved((_response: unknown, id: number) => {\n ids = ids.filter((itemId) => itemId !== id);\n persistIds();\n emitChange();\n });\n });\n\n // The SDK fills its storage with the customer's saved wishlist after init.\n onSallaEvent('wishlist::storage.synced', reloadFromStorage);\n}\n\n/**\n * useAsyncFn resolves with whatever the SDK rejected with, and callers detect\n * failure via `instanceof Error`. Normalize non-Error rejections so they are\n * never mistaken for success.\n */\nfunction toError(reason: unknown, fallback: string): Error {\n if (reason instanceof Error) return reason;\n if (typeof reason === 'string') return new Error(reason);\n const message = (reason as { message?: unknown } | null)?.message;\n return new Error(typeof message === 'string' ? message : fallback);\n}\n\nexport function useWishlist(): UseWishlistResult {\n ensureSubscribed();\n const storedIds = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n const { t } = useTranslation();\n const failed = t('common.errors.error_occurred', 'Something went wrong');\n\n const [addState, addFn] = useAsyncFn(\n async (productId: number) => {\n const salla = window.salla;\n try {\n await salla?.wishlist.add(productId);\n } catch (reason) {\n throw toError(reason, failed);\n }\n if (!ids.includes(productId)) {\n ids = [...ids, productId];\n persistIds();\n emitChange();\n }\n },\n [failed]\n );\n\n const [removeState, removeFn] = useAsyncFn(\n async (productId: number) => {\n const salla = window.salla;\n try {\n await salla?.wishlist.remove(productId);\n } catch (reason) {\n throw toError(reason, failed);\n }\n ids = ids.filter((id) => id !== productId);\n persistIds();\n emitChange();\n },\n [failed]\n );\n\n const has = useCallback((productId: number) => storedIds.includes(productId), [storedIds]);\n\n const add = async (productId: number): Promise<boolean> =>\n !(((await addFn(productId)) as unknown) instanceof Error);\n\n const remove = async (productId: number): Promise<boolean> =>\n !(((await removeFn(productId)) as unknown) instanceof Error);\n\n const toggle = useCallback(\n (productId: number) => (has(productId) ? remove(productId) : add(productId)),\n [has, addFn, removeFn]\n );\n\n return {\n ids: storedIds,\n count: storedIds.length,\n has,\n add,\n remove,\n toggle,\n loading: addState.loading || removeState.loading,\n error: (addState.error ?? removeState.error)?.message ?? null,\n };\n}\n\nexport function resetWishlistStore() {\n ids = [];\n listeners.clear();\n subscribed = false;\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/useWishlist.ts"],"names":[],"mappings":";;;;;AAuCA,IAAM,oBAAA,GAAuB,iBAAA;AAE7B,IAAI,MAAgB,EAAC;AACrB,IAAM,SAAA,uBAAgB,GAAA,EAAgB;AACtC,IAAI,UAAA,GAAa,KAAA;AAEjB,SAAS,UAAA,GAAa;AACpB,EAAA,KAAA,MAAW,QAAA,IAAY,WAAW,QAAA,EAAS;AAC7C;AAEA,SAAS,UAAU,QAAA,EAAsB;AACvC,EAAA,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AAA,YAA0B,KAAA,CAAA;AAExD,EAAA,MAAM,MAAA,GAAS,WAAA;AAAA,IACb,CAAC,cAAuB,GAAA,CAAI,SAAS,IAAI,MAAA,CAAO,SAAS,CAAA,GAAI,GAAA,CAAI,SAAS,CAAA;AAAA,IAC1E,CAAC,GAAA,EAAK,KAAA,EAAO,QAAQ;AAAA,GACvB;AAEA,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,SAAA;AAAA,IACL,OAAO,SAAA,CAAU,MAAA;AAAA,IACjB,GAAA;AAAA,IACA,GAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA,EAAS,QAAA,CAAS,OAAA,IAAW,WAAA,CAAY,OAAA;AAAA,IACzC,KAAA,EAAA,CAAQ,QAAA,CAAS,KAAA,IAAS,WAAA,CAAY,QAAQ,OAAA,IAAW;AAAA,GAC3D;AACF;AAEO,SAAS,kBAAA,GAAqB;AACnC,EAAA,GAAA,GAAM,EAAC;AACP,EAAA,SAAA,CAAU,KAAA,EAAM;AAChB,EAAA,UAAA,GAAa,KAAA;AACf","file":"chunk-JGVEGQHJ.js","sourcesContent":["import { useCallback, useSyncExternalStore } from 'react';\nimport { useAsyncFn } from './useAsyncFn';\nimport { useTranslation } from '../providers/I18nProvider';\nimport { onSallaEvent, whenSallaLoaded } from '../utils/sdk-helpers';\nimport type { UseToggleWithItems } from './types';\n\nexport type UseWishlistResult = UseToggleWithItems<number>;\n\n/**\n * useWishlist - Hook for managing wishlist functionality\n *\n * Provides wishlist product management with local storage persistence\n * and Salla SDK integration. Syncs with the SDK's wishlist state and\n * listens for events to maintain real-time consistency.\n *\n * Uses a module-level singleton store so SDK event listeners are\n * registered ONCE globally — not per-component. All hook instances\n * share the same state via `useSyncExternalStore`.\n *\n * @returns Wishlist state and management functions\n *\n * @example\n * ```tsx\n * function WishlistButton({ productId }) {\n * const { has, toggle, loading } = useWishlist();\n *\n * return (\n * <button\n * onClick={() => toggle(productId)}\n * disabled={loading}\n * className={has(productId) ? 'liked' : ''}\n * >\n * ❤️\n * </button>\n * );\n * }\n * ```\n */\n\nconst WISHLIST_STORAGE_KEY = 'salla::wishlist';\n\nlet ids: number[] = [];\nconst listeners = new Set<() => void>();\nlet subscribed = false;\n\nfunction emitChange() {\n for (const listener of listeners) listener();\n}\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nfunction getSnapshot(): number[] {\n return ids;\n}\n\nconst getServerSnapshot = (): number[] => [];\n\nfunction persistIds() {\n try {\n localStorage.setItem(WISHLIST_STORAGE_KEY, JSON.stringify(ids));\n } catch {\n /* ignore storage errors */\n }\n}\n\nfunction initFromStorage() {\n try {\n // `storage` is missing while `window.salla` is still the head script's stub.\n const sdkWishlist = window.salla?.storage?.get(WISHLIST_STORAGE_KEY, []);\n const stored = localStorage.getItem(WISHLIST_STORAGE_KEY);\n const parsed = stored ? JSON.parse(stored) : [];\n ids = Array.isArray(sdkWishlist) && sdkWishlist.length > 0 ? sdkWishlist : parsed;\n } catch {\n /* ignore storage errors */\n }\n}\n\nfunction reloadFromStorage() {\n initFromStorage();\n emitChange();\n}\n\nfunction ensureSubscribed() {\n if (subscribed || typeof window === 'undefined') return;\n subscribed = true;\n initFromStorage();\n\n // On a cold load hydration runs before the SDK has loaded.\n whenSallaLoaded((salla) => {\n reloadFromStorage();\n if (!salla.wishlist?.event) return;\n\n salla.wishlist.event.onAdded((_event: unknown, id: number) => {\n if (ids.includes(id)) return;\n ids = [...ids, id];\n persistIds();\n emitChange();\n });\n\n salla.wishlist.event.onRemoved((_response: unknown, id: number) => {\n ids = ids.filter((itemId) => itemId !== id);\n persistIds();\n emitChange();\n });\n });\n\n // The SDK fills its storage with the customer's saved wishlist after init.\n onSallaEvent('wishlist::storage.synced', reloadFromStorage);\n}\n\n/**\n * useAsyncFn resolves with whatever the SDK rejected with, and callers detect\n * failure via `instanceof Error`. Normalize non-Error rejections so they are\n * never mistaken for success.\n */\nfunction toError(reason: unknown, fallback: string): Error {\n if (reason instanceof Error) return reason;\n if (typeof reason === 'string') return new Error(reason);\n const message = (reason as { message?: unknown } | null)?.message;\n return new Error(typeof message === 'string' ? message : fallback);\n}\n\nexport function useWishlist(): UseWishlistResult {\n ensureSubscribed();\n const storedIds = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n const { t } = useTranslation();\n const failed = t('common.errors.error_occurred', 'Something went wrong');\n\n const [addState, addFn] = useAsyncFn(\n async (productId: number) => {\n const salla = window.salla;\n try {\n await salla?.wishlist.add(productId);\n } catch (reason) {\n throw toError(reason, failed);\n }\n if (!ids.includes(productId)) {\n ids = [...ids, productId];\n persistIds();\n emitChange();\n }\n },\n [failed]\n );\n\n const [removeState, removeFn] = useAsyncFn(\n async (productId: number) => {\n const salla = window.salla;\n try {\n await salla?.wishlist.remove(productId);\n } catch (reason) {\n throw toError(reason, failed);\n }\n ids = ids.filter((id) => id !== productId);\n persistIds();\n emitChange();\n },\n [failed]\n );\n\n const has = useCallback((productId: number) => storedIds.includes(productId), [storedIds]);\n\n const add = async (productId: number): Promise<boolean> =>\n !(((await addFn(productId)) as unknown) instanceof Error);\n\n const remove = async (productId: number): Promise<boolean> =>\n !(((await removeFn(productId)) as unknown) instanceof Error);\n\n const toggle = useCallback(\n (productId: number) => (has(productId) ? remove(productId) : add(productId)),\n [has, addFn, removeFn]\n );\n\n return {\n ids: storedIds,\n count: storedIds.length,\n has,\n add,\n remove,\n toggle,\n loading: addState.loading || removeState.loading,\n error: (addState.error ?? removeState.error)?.message ?? null,\n };\n}\n\nexport function resetWishlistStore() {\n ids = [];\n listeners.clear();\n subscribed = false;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { rememberProductPreview } from './chunk-YWDMDW2K.js';
2
- import { getActiveScope, api } from './chunk-M46EKE7R.js';
1
+ import { rememberProductPreview } from './chunk-MQALPNFL.js';
2
+ import { getActiveScope, api } from './chunk-PFAPRJVF.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var wishlist = {
@@ -31,5 +31,5 @@ var wishlist = {
31
31
  };
32
32
 
33
33
  export { wishlist };
34
- //# sourceMappingURL=chunk-UHXL4VZS.js.map
35
- //# sourceMappingURL=chunk-UHXL4VZS.js.map
34
+ //# sourceMappingURL=chunk-JHTTTXTI.js.map
35
+ //# sourceMappingURL=chunk-JHTTTXTI.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/wishlist.ts"],"names":[],"mappings":";;;;AAmBO,IAAM,QAAA,GAAW;AAAA,EACtB,IAAA,EAAM,OAAO,MAAA,GAA6B,EAAC,KAAmC;AAC5E,IAAA,MAAM,EAAE,IAAA,GAAO,CAAA,EAAG,UAAU,EAAA,EAAI,UAAA,EAAY,QAAO,GAAI,MAAA;AAEvD,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AACzC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAU,UAAU,CAAA;AACrC,IAAA,YAAA,CAAa,GAAA,CAAI,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA;AACrC,IAAA,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAA,CAAO,OAAO,CAAC,CAAA;AAE5C,IAAA,IAAI,eAAe,MAAA,EAAW;AAC5B,MAAA,YAAA,CAAa,GAAA,CAAI,YAAA,EAAc,UAAA,GAAa,GAAA,GAAM,GAAG,CAAA;AAAA,IACvD;AAEA,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,IAAI,MAAA,UAAgB,MAAA,GAAS,MAAA;AAE7B,IAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,CAAA,SAAA,EAAY,YAAA,CAAa,QAAA,EAAU,CAAA,CAAA,EAAI,OAAc,CAAA,CACzD,IAAA,EAA2B;AAE9B,IAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,IAAA,IAAQ,EAAC;AAChC,IAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,EAAO,sBAAA,CAAuB,IAAI,CAAA;AAErD,IAAA,OAAO;AAAA,MACL,KAAA;AAAA,MACA,IAAA,EAAM,QAAA,CAAS,MAAA,EAAQ,IAAA,IAAQ;AAAA,KACjC;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,CAAC,MAAA,KACL,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,UAAA,EAAY,MAAA,EAAQ,QAAQ,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AAAA,MAClE,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,QAAA,CAAS,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC7D;AAAA;AAEP","file":"chunk-UHXL4VZS.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport {\n rememberProductPreview,\n type ProductsListResult,\n type ProductsListResponse,\n} from './product';\n\nexport interface WishlistListParams {\n page?: number;\n perPage?: number;\n filterable?: boolean;\n signal?: AbortSignal;\n}\n\n/**\n * Wishlist API — page-based pagination only.\n * Kept separate from product.list to avoid mixing cursor and page pagination strategies.\n */\nexport const wishlist = {\n list: async (params: WishlistListParams = {}): Promise<ProductsListResult> => {\n const { page = 1, perPage = 15, filterable, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('source', 'wishlist');\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n const items = response.data ?? [];\n for (const item of items) rememberProductPreview(item);\n\n return {\n items,\n next: response.cursor?.next ?? null,\n };\n },\n\n queries: {\n list: (params: Omit<WishlistListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['wishlist', 'list', params, { scope: getActiveScope() }],\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AC,MAAA,KACL,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,UAAA,EAAY,MAAA,EAAQ,QAAQ,EAAE,KAAA,EAAO,cAAA,EAAe,EAAG,CAAA;AAAA,MAClE,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,QAAA,CAAS,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC7D;AAAA;AAEP","file":"chunk-JHTTTXTI.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport {\n rememberProductPreview,\n type ProductsListResult,\n type ProductsListResponse,\n} from './product';\n\nexport interface WishlistListParams {\n page?: number;\n perPage?: number;\n filterable?: boolean;\n signal?: AbortSignal;\n}\n\n/**\n * Wishlist API — page-based pagination only.\n * Kept separate from product.list to avoid mixing cursor and page pagination strategies.\n */\nexport const wishlist = {\n list: async (params: WishlistListParams = {}): Promise<ProductsListResult> => {\n const { page = 1, perPage = 15, filterable, signal } = params;\n\n const searchParams = new URLSearchParams();\n searchParams.set('source', 'wishlist');\n searchParams.set('page', String(page));\n searchParams.set('per_page', String(perPage));\n\n if (filterable !== undefined) {\n searchParams.set('filterable', filterable ? '1' : '0');\n }\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`products?${searchParams.toString()}`, options as any)\n .json<ProductsListResponse>();\n\n const items = response.data ?? [];\n for (const item of items) rememberProductPreview(item);\n\n return {\n items,\n next: response.cursor?.next ?? null,\n };\n },\n\n queries: {\n list: (params: Omit<WishlistListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['wishlist', 'list', params, { scope: getActiveScope() }],\n queryFn: ({ signal }) => wishlist.list({ ...params, signal }),\n }),\n },\n};\n"]}
@@ -0,0 +1,14 @@
1
+ import { lazy } from 'react';
2
+
3
+ // src/components/cart/lazy.ts
4
+ var LazyCartItem = lazy(() => import('./CartItem-WREXJVPL.js').then((m) => ({ default: m.CartItem })));
5
+ var LazyCartSummary = lazy(
6
+ () => import('./CartSummary-UOQRTFXF.js').then((m) => ({ default: m.CartSummary }))
7
+ );
8
+ var LazySeoCartWidget = lazy(
9
+ () => import('./SeoCartWidget-ZDYIBND6.js').then((m) => ({ default: m.SeoCartWidget }))
10
+ );
11
+
12
+ export { LazyCartItem, LazyCartSummary, LazySeoCartWidget };
13
+ //# sourceMappingURL=chunk-JJ7VOYWQ.js.map
14
+ //# sourceMappingURL=chunk-JJ7VOYWQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/cart/lazy.ts"],"names":[],"mappings":";;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC;AAE3F,IAAM,eAAA,GAAkB,IAAA;AAAA,EAAK,MAClC,OAAO,2BAAe,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,WAAA,EAAY,CAAE;AAClE;AAEO,IAAM,iBAAA,GAAoB,IAAA;AAAA,EAAK,MACpC,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE","file":"chunk-GPWNE2C6.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded cart components\n * Use these for code-splitting cart sections\n */\nexport const LazyCartItem = lazy(() => import('./CartItem').then((m) => ({ default: m.CartItem })));\n\nexport const LazyCartSummary = lazy(() =>\n import('./CartSummary').then((m) => ({ default: m.CartSummary }))\n);\n\nexport const LazySeoCartWidget = lazy(() =>\n import('./SeoCartWidget').then((m) => ({ default: m.SeoCartWidget }))\n);\n"]}
1
+ {"version":3,"sources":["../src/components/cart/lazy.ts"],"names":[],"mappings":";;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC;AAE3F,IAAM,eAAA,GAAkB,IAAA;AAAA,EAAK,MAClC,OAAO,2BAAe,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,WAAA,EAAY,CAAE;AAClE;AAEO,IAAM,iBAAA,GAAoB,IAAA;AAAA,EAAK,MACpC,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE","file":"chunk-JJ7VOYWQ.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded cart components\n * Use these for code-splitting cart sections\n */\nexport const LazyCartItem = lazy(() => import('./CartItem').then((m) => ({ default: m.CartItem })));\n\nexport const LazyCartSummary = lazy(() =>\n import('./CartSummary').then((m) => ({ default: m.CartSummary }))\n);\n\nexport const LazySeoCartWidget = lazy(() =>\n import('./SeoCartWidget').then((m) => ({ default: m.SeoCartWidget }))\n);\n"]}
@@ -1,4 +1,4 @@
1
- import { onSallaEvent } from './chunk-3GDJMMMS.js';
1
+ import { onSallaEvent } from './chunk-GYXUYHKO.js';
2
2
  import { useState, useRef, useEffect, useCallback } from 'react';
3
3
 
4
4
  function useProduct(initialProduct, options) {
@@ -61,5 +61,5 @@ function useProduct(initialProduct, options) {
61
61
  }
62
62
 
63
63
  export { useProduct };
64
- //# sourceMappingURL=chunk-5CEVDCMY.js.map
65
- //# sourceMappingURL=chunk-5CEVDCMY.js.map
64
+ //# sourceMappingURL=chunk-L4TQBWR7.js.map
65
+ //# sourceMappingURL=chunk-L4TQBWR7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useProduct.ts"],"names":[],"mappings":";;;AA4DO,SAAS,UAAA,CAAW,gBAAyB,OAAA,EAA+C;AACjG,EA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5CEVDCMY.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Product } from '../types';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseProductResult - Return type for useProduct hook\n */\nexport interface UseProductResult {\n /** Current product state (updates on option changes) */\n product: Product;\n /** Reload product data from API */\n reload: () => Promise<void>;\n}\n\nexport interface UseProductOptions {\n /**\n * True while `initialProduct` is a list-card stand-in. When it flips to false\n * (details arrived), state re-seeds. Do not infer this from `options`/`images`\n * — list payloads may include those fields.\n */\n isPreview?: boolean;\n}\n\n/**\n * useProduct - Hook for managing product state with live updates\n *\n * Provides reactive product data with automatic updates for price, stock,\n * and variant changes. Handles manual reloads (e.g., after add-to-cart)\n * and subscribes to Salla SDK events for real-time price updates.\n *\n * Stock status is reflected in `product.is_out_of_stock` which updates\n * when price calculations succeed or fail (e.g., unavailable option combinations).\n *\n * @param initialProduct - The initial product object (typically from loader/SSR).\n * @param options.isPreview - Pass true for a list-card placeholder so the hook\n * re-seeds when details for the same id arrive (`isPreview` goes false).\n *\n * @returns Object with product and reload function\n *\n * @example\n * ```tsx\n * function ProductDetails({ product }) {\n * const { product: updatedProduct, reload } = useProduct(product);\n *\n * const handleAddToCart = async () => {\n * await addToCart(updatedProduct.id);\n * await reload(); // Refresh product state after cart update\n * };\n *\n * return (\n * <div>\n * <h1>{updatedProduct.name}</h1>\n * <p>Price: {formatMoney(updatedProduct.price)}</p>\n * {updatedProduct.is_out_of_stock && <p>Currently out of stock</p>}\n * <button onClick={handleAddToCart}>Add to Cart</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProduct(initialProduct: Product, options?: UseProductOptions): UseProductResult {\n const [product, setProduct] = useState<Product>(initialProduct);\n\n // Always keep a ref to the latest initialProduct so the re-seed effect below\n // can read it without adding the full object to the dependency array.\n const initialProductRef = useRef<Product>(initialProduct);\n useEffect(() => {\n initialProductRef.current = initialProduct;\n });\n\n const reload = useCallback(async () => {\n const salla = window.salla;\n if (!salla?.api?.product?.getDetails) return;\n try {\n const response = await salla.api.product.getDetails(String(product.id), [\n 'images',\n 'category',\n ]);\n if (response?.success && response.data) {\n setProduct(response.data as Product);\n }\n } catch {\n // silently ignore network errors during reload\n }\n }, [product.id]);\n\n // Re-seed when the loader navigates to a different product, or when a\n // list-card placeholder (`isPreview`) is replaced by details for the same id.\n // Object identity is not a dependency — that would reset live option/price state.\n useEffect(() => {\n setProduct(initialProductRef.current);\n }, [initialProduct.id, options?.isPreview]);\n\n // Subscribe to Salla option-change events so price/stock stays in sync\n useEffect(() => onSallaEvent('product:options.updated', reload), [reload]);\n\n // Subscribe to price update events (matches product.js registerEvents)\n useEffect(() => {\n const handlePriceUpdated = (res: { data?: Record<string, unknown> }) => {\n const data = res.data;\n if (!data) return;\n\n setProduct((prev) => {\n const price = (data.price as number) ?? prev.price;\n const regularPrice = (data.regular_price as number) ?? prev.regular_price;\n // The payload has no sale_price: like product.js, `price` is the payable (sale) figure.\n const isOnSale = Boolean(data.has_sale_price) && regularPrice > price;\n return {\n ...prev,\n price,\n sale_price: isOnSale ? price : prev.sale_price,\n regular_price: regularPrice,\n is_on_sale: isOnSale,\n starting_price: null,\n weight: (data.weight as string) || '',\n // An empty variant SKU/barcode blanks it; a payload without the field keeps it (product.js).\n sku: data.sku === undefined ? prev.sku : (data.sku as string) || '',\n barcode: data.barcode === undefined ? prev.barcode : (data.barcode as string) || '',\n is_out_of_stock: false,\n };\n });\n };\n\n const listener = handlePriceUpdated as (...args: unknown[]) => void;\n\n // Root on/off: onPriceUpdated registers a wrapper that salla.event.off can't match.\n return onSallaEvent('product::price.updated', listener);\n }, []);\n\n // Subscribe to price update failed events (matches product.js)\n useEffect(() => {\n const handlePriceFailed = () => {\n setProduct((prev) => ({ ...prev, is_out_of_stock: true }));\n };\n\n return onSallaEvent('product::price.updated.failed', handlePriceFailed);\n }, []);\n\n return { product, reload };\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/useProduct.ts"],"names":[],"mappings":";;;AA4DO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AA,OAAO,EAAE,SAAS,MAAA,EAAO;AAC3B","file":"chunk-L4TQBWR7.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Product } from '../types';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseProductResult - Return type for useProduct hook\n */\nexport interface UseProductResult {\n /** Current product state (updates on option changes) */\n product: Product;\n /** Reload product data from API */\n reload: () => Promise<void>;\n}\n\nexport interface UseProductOptions {\n /**\n * True while `initialProduct` is a list-card stand-in. When it flips to false\n * (details arrived), state re-seeds. Do not infer this from `options`/`images`\n * — list payloads may include those fields.\n */\n isPreview?: boolean;\n}\n\n/**\n * useProduct - Hook for managing product state with live updates\n *\n * Provides reactive product data with automatic updates for price, stock,\n * and variant changes. Handles manual reloads (e.g., after add-to-cart)\n * and subscribes to Salla SDK events for real-time price updates.\n *\n * Stock status is reflected in `product.is_out_of_stock` which updates\n * when price calculations succeed or fail (e.g., unavailable option combinations).\n *\n * @param initialProduct - The initial product object (typically from loader/SSR).\n * @param options.isPreview - Pass true for a list-card placeholder so the hook\n * re-seeds when details for the same id arrive (`isPreview` goes false).\n *\n * @returns Object with product and reload function\n *\n * @example\n * ```tsx\n * function ProductDetails({ product }) {\n * const { product: updatedProduct, reload } = useProduct(product);\n *\n * const handleAddToCart = async () => {\n * await addToCart(updatedProduct.id);\n * await reload(); // Refresh product state after cart update\n * };\n *\n * return (\n * <div>\n * <h1>{updatedProduct.name}</h1>\n * <p>Price: {formatMoney(updatedProduct.price)}</p>\n * {updatedProduct.is_out_of_stock && <p>Currently out of stock</p>}\n * <button onClick={handleAddToCart}>Add to Cart</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProduct(initialProduct: Product, options?: UseProductOptions): UseProductResult {\n const [product, setProduct] = useState<Product>(initialProduct);\n\n // Always keep a ref to the latest initialProduct so the re-seed effect below\n // can read it without adding the full object to the dependency array.\n const initialProductRef = useRef<Product>(initialProduct);\n useEffect(() => {\n initialProductRef.current = initialProduct;\n });\n\n const reload = useCallback(async () => {\n const salla = window.salla;\n if (!salla?.api?.product?.getDetails) return;\n try {\n const response = await salla.api.product.getDetails(String(product.id), [\n 'images',\n 'category',\n ]);\n if (response?.success && response.data) {\n setProduct(response.data as Product);\n }\n } catch {\n // silently ignore network errors during reload\n }\n }, [product.id]);\n\n // Re-seed when the loader navigates to a different product, or when a\n // list-card placeholder (`isPreview`) is replaced by details for the same id.\n // Object identity is not a dependency — that would reset live option/price state.\n useEffect(() => {\n setProduct(initialProductRef.current);\n }, [initialProduct.id, options?.isPreview]);\n\n // Subscribe to Salla option-change events so price/stock stays in sync\n useEffect(() => onSallaEvent('product:options.updated', reload), [reload]);\n\n // Subscribe to price update events (matches product.js registerEvents)\n useEffect(() => {\n const handlePriceUpdated = (res: { data?: Record<string, unknown> }) => {\n const data = res.data;\n if (!data) return;\n\n setProduct((prev) => {\n const price = (data.price as number) ?? prev.price;\n const regularPrice = (data.regular_price as number) ?? prev.regular_price;\n // The payload has no sale_price: like product.js, `price` is the payable (sale) figure.\n const isOnSale = Boolean(data.has_sale_price) && regularPrice > price;\n return {\n ...prev,\n price,\n sale_price: isOnSale ? price : prev.sale_price,\n regular_price: regularPrice,\n is_on_sale: isOnSale,\n starting_price: null,\n weight: (data.weight as string) || '',\n // An empty variant SKU/barcode blanks it; a payload without the field keeps it (product.js).\n sku: data.sku === undefined ? prev.sku : (data.sku as string) || '',\n barcode: data.barcode === undefined ? prev.barcode : (data.barcode as string) || '',\n is_out_of_stock: false,\n };\n });\n };\n\n const listener = handlePriceUpdated as (...args: unknown[]) => void;\n\n // Root on/off: onPriceUpdated registers a wrapper that salla.event.off can't match.\n return onSallaEvent('product::price.updated', listener);\n }, []);\n\n // Subscribe to price update failed events (matches product.js)\n useEffect(() => {\n const handlePriceFailed = () => {\n setProduct((prev) => ({ ...prev, is_out_of_stock: true }));\n };\n\n return onSallaEvent('product::price.updated.failed', handlePriceFailed);\n }, []);\n\n return { product, reload };\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { getActiveScope, requestedThemeVersionId, api, STORE_IDENTIFIER_HEADER } from './chunk-M46EKE7R.js';
1
+ import { getActiveScope, api, STORE_IDENTIFIER_HEADER } from './chunk-PFAPRJVF.js';
2
+ import { requestedThemeVersionId } from './chunk-GYXUYHKO.js';
2
3
  import { resolveStoreIdentifier, parseStoreId } from './chunk-FHU2MXZA.js';
3
4
  import { getTwilightContext, SettingsError } from './chunk-7VNVCHID.js';
4
5
  import { queryOptions } from '@tanstack/react-query';
@@ -183,5 +184,5 @@ var store = {
183
184
  };
184
185
 
185
186
  export { readNativeAppHeaders, store };
186
- //# sourceMappingURL=chunk-6D3OWIEC.js.map
187
- //# sourceMappingURL=chunk-6D3OWIEC.js.map
187
+ //# sourceMappingURL=chunk-LPCNDH4F.js.map
188
+ //# sourceMappingURL=chunk-LPCNDH4F.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/native-app-headers.ts","../src/api/store.ts"],"names":[],"mappings":";;;;;;;;AACO,IAAM,kBAAA,GAAqB;AAAA,EAChC,UAAA;AAAA,EACA,eAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF,CAAA;AAUO,SAAS,qBAAqB,OAAA,EAAiD;AACpF,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,GAAA,CAAI,UAAU,GAAG,WAAA,EAAY;AAChD,EAAA,IAAI,EAAA,KAAO,KAAA,IAAS,EAAA,KAAO,SAAA,EAAW,OAAO,IAAA;AAC7C,EAAA,MAAM,QAAgC,EAAC;AACvC,EAAA,KAAA,MAAW,QAAQ,kBAAA,EAAoB;AACrC,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,IAAI,CAAA;AAC9B,IAAA,IAAI,KAAA,EAAO,KAAA,CAAM,IAAI,CAAA,GAAI,KAAA;AAAA,EAC3B;AACA,EAAA,OAAO,KAAA;AACT;;;ACZA,IAAM,qBAAA,GAAwB;AAAA,EAC5B,OAAA;AAAA,EACA,UAAA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AA,CAAM,OAAA,EAAS,GAAI,KAAA,KAAU,KAAA,GAAQ,EAAC,GAAI,CAAC,KAAK,CAAE,CAAA;AACpF,IAAA,MAAM,KAAA;AAAA,EACR;AACF;AAEO,IAAM,KAAA,GAAQ;AAAA,EACnB,QAAA,EAAU,OAAO,eAAA,KAA2D;AAC1E,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,cAAc,eAAe,CAAA;AAAA,IAC5C,CAAA,CAAA,MAAQ;AAEN,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,CAAC,eAAA,KACT,YAAA,CAAkC;AAAA,MAChC,QAAA,EAAU;AAAA,QACR,OAAA;AAAA,QACA,UAAA;AAAA,QACA,eAAA;AAAA,QACA,oBAAmB,CAAE,MAAA;AAAA,QACrB,cAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQf,uBAAA;AAAwB,OAC1B;AAAA;AAAA,MAEA,OAAA,EAAS,MAAM,aAAA,CAAc,eAAe,CAAA;AAAA;AAAA;AAAA,MAG5C,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-LPCNDH4F.js","sourcesContent":["/** The headers the Salla native app sends with every page it loads in its webview. */\nexport const NATIVE_APP_HEADERS = [\n 's-app-os',\n 's-app-version',\n 's-app-full-version',\n 's-app-os-version',\n];\n\n/**\n * The native app's own headers on this request, or null when it is not the app.\n *\n * On a Twig theme Laravel copies them into the settings' `jitsu.context.extra.headers`,\n * where the SDK reads the app's platform and version from (`salla.config.isMobileApp()`).\n * A React theme asks for its settings from the server, through the API, so the app's\n * headers never reach that call: the request is the only place they are.\n */\nexport function readNativeAppHeaders(headers: Headers): Record<string, string> | null {\n const os = headers.get('s-app-os')?.toLowerCase();\n if (os !== 'ios' && os !== 'android') return null;\n const found: Record<string, string> = {};\n for (const name of NATIVE_APP_HEADERS) {\n const value = headers.get(name);\n if (value) found[name] = value;\n }\n return found;\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport { api, getActiveScope, STORE_IDENTIFIER_HEADER } from './client';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { parseStoreId } from '../utils/cookies';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\n\nexport { resolveStoreIdentifier };\n\nconst DEFAULT_INCLUDE_ITEMS = [\n 'store',\n 'settings',\n 'theme',\n 'theme_settings',\n 'external_services',\n 'currencies',\n 'languages',\n 'payments',\n 'product_widgets',\n 'rating',\n 'ratings',\n 'user',\n];\n\n/** Twig's `salla.init({ user })` object; the endpoint ignores the token, so always the guest. */\nexport interface SettingsUser {\n type: 'guest' | 'user';\n id?: number | string | null;\n language_code?: string;\n currency_code?: string;\n country_code?: string;\n [key: string]: unknown;\n}\n\n/**\n * Raw API response for settings endpoint.\n * Languages come as object: { \"AR\": { code, name, ... }, \"EN\": {...} }\n */\ninterface SettingsApiResponse {\n store?: Store;\n theme?: Theme;\n languages?: Record<string, Language>;\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean;\n policy_url?: string;\n user?: SettingsUser;\n swoole?: string[];\n jitsu?: JitsuConfig;\n maintenance?: boolean;\n maintenance_details?: MaintenanceDetails;\n}\n\n/**\n * Central settings context - single source of truth for all API data.\n * Contains everything from the settings endpoint response after processing.\n */\nexport interface StoreContext {\n store?: Store;\n theme?: Theme;\n /** Languages as array after conversion from API object format */\n languages?: Language[];\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean; // todo:: remove it\n policy_url?: string;\n user?: SettingsUser;\n /** API paths the SDK sends with `s-store-api-version: swoole` */\n swoole?: string[];\n /** Where the SDK's analytics send events, and which ones; without it the SDK tracks nothing. */\n jitsu?: JitsuConfig;\n /**\n * The store is closed: by the merchant from the dashboard, by the platform, or\n * for the selected market only. The engine then renders the maintenance page\n * to everyone but the merchant; see `rootBeforeLoad`.\n */\n maintenance?: boolean;\n /** What the maintenance page says; sent beside `maintenance`. */\n maintenance_details?: MaintenanceDetails;\n /**\n * The scope these settings were requested with; absent when none was. Not from\n * the API: stamped by `store.settings`, so `resolveThemeVersionId` can tell\n * whether the version they name still answers the scope that is active now.\n */\n requestedScopeId?: string;\n}\n\n/**\n * Converts languages object from API to array format.\n * API returns: { \"AR\": { code, name, ... }, \"EN\": { ... } }\n * We need: [{ code, name, ... }, { code, name, ... }]\n * todo:: return the languages as object from the APIs to avoid this\n */\nfunction languagesToArray(languages?: Record<string, Language>): Language[] | undefined {\n if (!languages) return undefined;\n // The SDK's localization modal reads `lang.iso_code` (not `code`) when a language is\n // selected — without it the switch navigates to `/undefined/...`.\n return Object.values(languages).map((lang) => ({ iso_code: lang.code, ...lang }));\n}\n\n/**\n * The settings' analytics context with the native app's headers in it, as Laravel\n * writes it for a Twig theme: the SDK reads the app's platform and version from there.\n * The API answers a server-side call with the engine's own headers, never the app's.\n */\nfunction withNativeAppHeaders(jitsu?: JitsuConfig): JitsuConfig | undefined {\n if (!jitsu || typeof window !== 'undefined') return jitsu;\n let appHeaders: Record<string, string> | null = null;\n try {\n appHeaders = getTwilightContext().nativeAppHeaders;\n } catch {\n return jitsu;\n }\n if (!appHeaders) return jitsu;\n const extra = jitsu.context?.extra;\n // The engine's own app headers go, so an app that sends no version doesn't get the engine's.\n const headers = { ...extra?.headers };\n for (const name of NATIVE_APP_HEADERS) delete headers[name];\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers: { ...headers, ...appHeaders } },\n },\n };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\nasync function requestSettings(identifier: string): Promise<StoreContext> {\n const includeParams = DEFAULT_INCLUDE_ITEMS.map((i) => `include[]=${i}`).join('&');\n const scope = getActiveScope();\n const params = scope != null ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const json = await api\n // Sent explicitly rather than left to the client's own resolution, so\n // the identifier this function checked is the identifier that travels.\n // They agree today; a caller passing one and being answered about\n // another is the failure this makes impossible rather than unlikely.\n .get(`store/settings?${params}`, {\n timeout: SETTINGS_TIMEOUT_MS,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n })\n .json<{ data?: SettingsApiResponse }>();\n\n const data = json?.data;\n if (!data) {\n throw new SettingsError(\n `The Salla API answered the settings request for store \"${identifier}\" without settings.`,\n { reason: 'empty' }\n );\n }\n\n // Convert languages from object to array\n const languages = languagesToArray(data.languages);\n\n return {\n store: data.store,\n theme: data.theme,\n languages,\n currencies: data.currencies,\n external_services: data.external_services,\n headers: data.headers,\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n swoole: data.swoole,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(scope && { requestedScopeId: scope.id }),\n };\n}\n\n/** The message the API put in an error body, `{ error: { message } }`, when it sent one. */\nfunction apiErrorMessage(data: unknown): string | undefined {\n const message = (data as { error?: { message?: unknown } } | undefined)?.error?.message;\n return typeof message === 'string' && message.length > 0 && message.length <= 200\n ? message\n : undefined;\n}\n\n/**\n * What core's `CurrentStoreMiddleware` answers, with a 422, when no store has the\n * username or domain it was given (or the store's status is `deleted`). The lookup is\n * `loadUseUsernameOrDomain`, the same one Twig's `checkUsername` turns into its 410.\n * The literal is not translated: it reads the same whatever language was asked for.\n */\nconst STORE_NOT_FOUND_MESSAGE = 'المتجر غير موجود';\n\n/**\n * Whether the API answered that no store has this identifier. A numeric identifier\n * is looked up with `findOrFail`, which Store's exception handler answers with a 410;\n * a username or domain gets {@link STORE_NOT_FOUND_MESSAGE}. A 410 for a username is\n * not read as one: nothing on that path answers it, and a store that does exist must\n * never be told it does not.\n */\nfunction isStoreNotFound(identifier: string, status: number, said: string | undefined): boolean {\n if (status === 410) return parseStoreId(identifier) !== null;\n return status === 422 && said === STORE_NOT_FOUND_MESSAGE;\n}\n\n/**\n * Names what went wrong, because the page, the server log and Sentry all carry\n * this message. Every failure used to read \"Make sure VITE_STORE_DOMAIN is set\",\n * a local-development variable no deployed theme has, so a slow API looked like\n * a misconfigured theme.\n */\nfunction describeSettingsFailure(identifier: string, error: unknown): SettingsError {\n if (error instanceof SettingsError) return error;\n const request = `the settings request for store \"${identifier}\"`;\n if (isTimeoutError(error)) {\n return new SettingsError(\n `The Salla API did not answer ${request} within ${SETTINGS_TIMEOUT_MS} ms.`,\n { reason: 'timeout' }\n );\n }\n if (isHTTPError(error)) {\n const { status } = error.response;\n const said = apiErrorMessage(error.data);\n return new SettingsError(\n `The Salla API answered ${request} with HTTP ${status}${said ? `: ${said}` : ''}.`,\n { reason: isStoreNotFound(identifier, status, said) ? 'not-found' : 'http', status }\n );\n }\n if (isNetworkError(error)) {\n return new SettingsError(`The Salla API could not be reached for ${request}.`, {\n reason: 'network',\n });\n }\n const detail = error instanceof Error ? `: ${error.message}` : '';\n return new SettingsError(`The settings request for store \"${identifier}\" failed${detail}.`);\n}\n\n/**\n * The settings, or a {@link SettingsError} that says why there are none. The\n * query throws it so the root route can say why the store did not load;\n * `store.settings` keeps answering `null` for its own callers.\n */\nasync function fetchSettings(storeIdentifier?: string): Promise<StoreContext> {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n const error = new SettingsError(\n 'No store is named for this request: add `?storeId=` on the preview host, or set VITE_STORE_DOMAIN in local development.',\n { reason: 'no-store' }\n );\n console.warn('[store.settings]', error.message);\n throw error;\n }\n\n try {\n return await requestSettings(identifier);\n } catch (cause) {\n const error = describeSettingsFailure(identifier, cause);\n console.error('[store.settings]', error.message, ...(cause === error ? [] : [cause]));\n throw error;\n }\n}\n\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n try {\n return await fetchSettings(storeIdentifier);\n } catch {\n // Already logged, with the reason.\n return null;\n }\n },\n\n queries: {\n settings: (storeIdentifier?: string) =>\n queryOptions<StoreContext | null>({\n queryKey: [\n 'store',\n 'settings',\n storeIdentifier,\n getTwilightContext().locale,\n getActiveScope(),\n // Two versions of one store's settings are two different answers, and\n // this is the query whose answer decides what every other call is\n // pinned to. `requestedThemeVersionId` rather than the resolved one:\n // the resolved value falls back to what these settings report, so it\n // is not knowable until after this query has run — the key would be\n // one thing on the server and another on the client, and the hydrated\n // page would refetch the settings it was just handed.\n requestedThemeVersionId(),\n ],\n // Throws rather than resolving `null`, so the failure keeps its reason.\n queryFn: () => fetchSettings(storeIdentifier),\n // A null never retried, and the root route waits on this: the router's\n // default `retry: 1` would sit through the timeout twice.\n retry: 0,\n }),\n },\n};\n"]}
@@ -1,6 +1,6 @@
1
- import { orThrow } from './chunk-KXD4WUYA.js';
2
- import { api } from './chunk-M46EKE7R.js';
3
- import { getSallaSDK } from './chunk-3GDJMMMS.js';
1
+ import { orThrow } from './chunk-T23HXVW5.js';
2
+ import { api } from './chunk-PFAPRJVF.js';
3
+ import { getSallaSDK } from './chunk-GYXUYHKO.js';
4
4
  import { queryOptions } from '@tanstack/react-query';
5
5
 
6
6
  function normalizeCartResponse(data) {
@@ -44,5 +44,5 @@ var cart = {
44
44
  };
45
45
 
46
46
  export { cart };
47
- //# sourceMappingURL=chunk-ZGVBXJQO.js.map
48
- //# sourceMappingURL=chunk-ZGVBXJQO.js.map
47
+ //# sourceMappingURL=chunk-ME4UKH7Y.js.map
48
+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9B,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,IACH,SAAA,EAAW,MACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,YAAA,EAAa;AAAA;AAAA,MAEjC,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT;AAAA;AAEP","file":"chunk-ZGVBXJQO.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Cart } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getSallaSDK } from '../utils/sdk-helpers';\n\nexport interface CartApiResponse {\n /** Absent once the cart was turned into an order (the body then carries a top-level `redirect`). */\n cart?: Omit<Cart, 'loyalty'>;\n loyalty?: Cart['loyalty'];\n gift?: Cart['gift'];\n}\n\nfunction normalizeCartResponse(data: CartApiResponse): Cart | null {\n if (!data.cart) return null;\n return {\n ...data.cart,\n loyalty: data.loyalty ?? null,\n // The API sends `gift` inside `cart`.\n gift: data.gift ?? data.cart.gift ?? null,\n } as Cart;\n}\n\nexport const cart = {\n get: async (cartId: number): Promise<Cart | null> => {\n const { data } = await api.get(`cart/${cartId}`).json<{ data: CartApiResponse }>();\n return normalizeCartResponse(data);\n },\n\n getOrThrow: (cartId: number): Promise<Cart | null> => orThrow(cart.get(cartId)),\n\n /** The visitor's cart id, which only the Salla SDK knows; `null` outside the browser. */\n getCurrentId: async (): Promise<number | null> => {\n const salla = getSallaSDK();\n if (!salla) return null;\n // The app bundle can run before the SDK module, when `salla` is still the head stub.\n await salla.onReady().catch(() => undefined);\n return salla.cart.api.getCurrentCartId();\n },\n\n queries: {\n detail: (cartId: number) =>\n queryOptions({\n queryKey: ['cart', cartId],\n queryFn: () => cart.get(cartId),\n // The SDK changes the cart from any page, so a cached copy is never safe to show.\n staleTime: 0,\n gcTime: 0,\n }),\n currentId: () =>\n queryOptions({\n queryKey: ['cart', 'current-id'],\n queryFn: () => cart.getCurrentId(),\n // Completing an order starts a new cart, so an earlier id is never reused.\n staleTime: 0,\n gcTime: 0,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/cart.ts"],"names":[],"mappings":";;;;;AAaA,SAAS,sBAAsB,IAAA,EAAoC;AACjE,EAAA,IAAI,CAAC,IAAA,CAAK,IAAA,EAAM,OAAO,IAAA;AACvB,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CAAK,IAAA;AAAA,IACR,OAAA,EAAS,KAAK,OAAA,IAAW,IAAA;AAAA;AAAA,IAEzB,IAAA,EAAM,IAAA,CAAK,IAAA,IAAQ,IAAA,CAAK,KAAK,IAAA,IAAQ;AAAA,GACvC;AACF;AAEO,IAAM,IAAA,GAAO;AAAA,EAClB,GAAA,EAAK,OAAO,MAAA,KAAyC;AACnD,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAAgC;AACjF,IAAA,OAAO,sBAAsB,IAAI,CAAA;AAAA,EACnC,CAAA;AAAA,EAEA,YAAY,CAAC,MAAA,KAAyC,QAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAC,CAAA;AAAA;AAAA,EAG9E,cAAc,YAAoC;AAChD,IAAA,MAAM,QAAQ,WAAA,EAAY;AAC1B,IAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AAEnB,IAAA,MAAM,KAAA,CAAM,OAAA,EAAQ,CAAE,KAAA,CAAM,MAAM,MAAS,CAAA;AAC3C,IAAA,OAAO,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,gBAAA,EAAiB;AAAA,EACzC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,MAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,MACzB,OAAA,EAAS,MAAM,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA;AAAA;AAAA,MAE9B,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,IACH,SAAA,EAAW,MACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,YAAA,EAAa;AAAA;AAAA,MAEjC,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT;AAAA;AAEP","file":"chunk-ME4UKH7Y.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Cart } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getSallaSDK } from '../utils/sdk-helpers';\n\nexport interface CartApiResponse {\n /** Absent once the cart was turned into an order (the body then carries a top-level `redirect`). */\n cart?: Omit<Cart, 'loyalty'>;\n loyalty?: Cart['loyalty'];\n gift?: Cart['gift'];\n}\n\nfunction normalizeCartResponse(data: CartApiResponse): Cart | null {\n if (!data.cart) return null;\n return {\n ...data.cart,\n loyalty: data.loyalty ?? null,\n // The API sends `gift` inside `cart`.\n gift: data.gift ?? data.cart.gift ?? null,\n } as Cart;\n}\n\nexport const cart = {\n get: async (cartId: number): Promise<Cart | null> => {\n const { data } = await api.get(`cart/${cartId}`).json<{ data: CartApiResponse }>();\n return normalizeCartResponse(data);\n },\n\n getOrThrow: (cartId: number): Promise<Cart | null> => orThrow(cart.get(cartId)),\n\n /** The visitor's cart id, which only the Salla SDK knows; `null` outside the browser. */\n getCurrentId: async (): Promise<number | null> => {\n const salla = getSallaSDK();\n if (!salla) return null;\n // The app bundle can run before the SDK module, when `salla` is still the head stub.\n await salla.onReady().catch(() => undefined);\n return salla.cart.api.getCurrentCartId();\n },\n\n queries: {\n detail: (cartId: number) =>\n queryOptions({\n queryKey: ['cart', cartId],\n queryFn: () => cart.get(cartId),\n // The SDK changes the cart from any page, so a cached copy is never safe to show.\n staleTime: 0,\n gcTime: 0,\n }),\n currentId: () =>\n queryOptions({\n queryKey: ['cart', 'current-id'],\n queryFn: () => cart.getCurrentId(),\n // Completing an order starts a new cart, so an earlier id is never reused.\n staleTime: 0,\n gcTime: 0,\n }),\n },\n};\n"]}
@@ -1,11 +1,11 @@
1
1
  import { registry } from './chunk-Y32RHCOH.js';
2
- import { useMoney, useNumber } from './chunk-LQ4X4YQM.js';
2
+ import { useMoney, useNumber } from './chunk-HUQU5NB5.js';
3
3
  import { useAsset } from './chunk-Z653O7MX.js';
4
- import { useWishlist } from './chunk-BVMHRVCG.js';
4
+ import { useWishlist } from './chunk-JGVEGQHJ.js';
5
5
  import { useTranslation } from './chunk-TYNZ5B2B.js';
6
- import { Image } from './chunk-L34CKKVC.js';
6
+ import { Image } from './chunk-CVBRA2LE.js';
7
7
  import { LazyImageModal } from './chunk-7V5HOZW4.js';
8
- import { isNativeApp } from './chunk-7AIDISU2.js';
8
+ import { isNativeApp } from './chunk-2TLIULJZ.js';
9
9
  import { useTwilight } from './chunk-DF6FBKDN.js';
10
10
  import { lazy, memo, useCallback, useMemo, useState, useEffect, Suspense } from 'react';
11
11
  import { SallaAddProductButton } from '@salla.sa/twilight-components-react/add-product-button';
@@ -15,10 +15,10 @@ import { jsxs, jsx } from 'react/jsx-runtime';
15
15
  import { SallaSlider } from '@salla.sa/twilight-components-react/slider';
16
16
 
17
17
  var LazyProductDetails = lazy(
18
- () => import('./ProductDetails-73Q6BYGA.js').then((m) => ({ default: m.ProductDetails }))
18
+ () => import('./ProductDetails-F5CTHGCT.js').then((m) => ({ default: m.ProductDetails }))
19
19
  );
20
20
  var LazyAddToCartForm = lazy(
21
- () => import('./AddToCartForm-6NCWP2NI.js').then((m) => ({ default: m.AddToCartForm }))
21
+ () => import('./AddToCartForm-QYSEYGYJ.js').then((m) => ({ default: m.AddToCartForm }))
22
22
  );
23
23
  var PRODUCT_CARD_KEY = "product:card";
24
24
  var PRODUCT_IMAGE_SRCSET_WIDTHS = [150, 300, 450, 600];
@@ -421,5 +421,5 @@ function ThumbSlide({ image, index }) {
421
421
  }
422
422
 
423
423
  export { LazyAddToCartForm, LazyProductDetails, ProductCard, ProductGallery };
424
- //# sourceMappingURL=chunk-DGCHTKPZ.js.map
425
- //# sourceMappingURL=chunk-DGCHTKPZ.js.map
424
+ //# sourceMappingURL=chunk-MKDS22Q3.js.map
425
+ //# sourceMappingURL=chunk-MKDS22Q3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/product/lazy.ts","../src/components/product/ProductCard.tsx","../src/components/product/ProductGallery.tsx"],"names":["ProductCardContent","ProductCard","jsxs","jsx","useMemo"],"mappings":";;;;;;;;;;;;;;;;AAEO,IAAM,kBAAA,GAAqB,IAAA;AAAA,EAAK,MACrC,OAAO,8BAAkB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,cAAA,EAAe,CAAE;AACxE;AAEO,IAAM,iBAAA,GAAoB,IAAA;AAAA,EAAK,MACpC,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE;ACMA,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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AS,IAAA;AAAA,UACT,MAAA,EAAQ,MAAM,SAAA,CAAU,IAAI;AAAA;AAAA,OAC9B,EACF;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAM,EAA2C;AAC5E,EAAA,uBACEA,GAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,CAAA,kBAAA,EAAqB,KAAA,CAAM,SAAA,GAAY,aAAA,GAAgB,EAAE,CAAA,CAAA,EAAI,KAAA,CAAM,iBAAA,GAAoB,aAAA,GAAgB,EAAE,CAAA,CAAA;AAAA,MACpH,gBAAc,KAAA,CAAM,GAAA;AAAA,MAEpB,QAAA,kBAAAA,GAAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAK,KAAA,CAAM,GAAA;AAAA,UACX,GAAA,EAAK,MAAM,GAAA,IAAO,EAAA;AAAA,UAClB,SAAA,EAAU,mEAAA;AAAA,UACV,OAAO,KAAA,CAAM,GAAA;AAAA,UACb,UAAU,KAAA,GAAQ,CAAA;AAAA,UAClB,SAAA,EAAS;AAAA;AAAA;AACX;AAAA,GACF;AAEJ","file":"chunk-DGCHTKPZ.js","sourcesContent":["import { lazy } from 'react';\n\nexport const LazyProductDetails = lazy(() =>\n import('./ProductDetails').then((m) => ({ default: m.ProductDetails }))\n);\n\nexport const LazyAddToCartForm = lazy(() =>\n import('./AddToCartForm').then((m) => ({ default: m.AddToCartForm }))\n);\n","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 } = 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 // Price display component\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)}</h4>\n {product.regular_price && <span>{format(product.regular_price)}</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)}</h4>\n </div>\n );\n }\n return <h4 className=\"s-product-card-price\">{format(product.price)}</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 fitImageHeight && isVertical ? `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","import { SallaSlider } from '@salla.sa/twilight-components-react/slider';\nimport { Suspense, useEffect, useMemo, useState } from 'react';\nimport { registry } from '../ComponentRegistry';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Product, ProductImage } from '../../types';\nimport { Image } from '../common/Image';\nimport { ImageModal } from '../modal';\nimport { isNativeApp } from '../../native-app';\n\nconst PRODUCT_GALLERY_KEY = 'product:gallery';\n\nexport interface ProductGalleryProps {\n product: Product;\n}\n\ntype ImagePreview = { src: string; alt: string };\ntype GalleryMedia = { url: string; type: 'image' | 'video' | '3d-image' };\n\n/**\n * The engine's own `mobile::gallery.open` payload from before `salla.mobile.openGallery`: a video's\n * link and a 3D model's file go in `url`, with no ids. Sent when the SDK has no `openGallery`\n * (Twilight before 2.14.569) or declines inside the app, so those stores keep the gallery they had.\n */\nfunction legacyGalleryMedia(images: ProductImage[]): GalleryMedia[] {\n return images.flatMap<GalleryMedia>((image) => {\n if (image.three_d_image_url) return [{ url: image.three_d_image_url, type: '3d-image' }];\n if (image.video_url) return [{ url: image.video_url, type: 'video' }];\n return image.url ? [{ url: image.url, type: 'image' }] : [];\n });\n}\n\nfunction ProductGalleryContent({ product }: ProductGalleryProps) {\n const { t } = useTranslation();\n const { theme } = useTwilight();\n const sliderId = `details-slider-${product.id}`;\n const objectFit = theme.settings.slider_background_size ?? 'cover';\n\n // Clicking an image opens an in-app lightbox instead of navigating to the CDN URL.\n const [preview, setPreview] = useState<ImagePreview | null>(null);\n\n useEffect(() => {\n const raf = requestAnimationFrame(() => {\n const el = document.getElementById(sliderId);\n if (!el?.parentElement) return;\n const { parentElement, nextSibling } = el;\n parentElement.removeChild(el);\n parentElement.insertBefore(el, nextSibling);\n });\n return () => cancelAnimationFrame(raf);\n }, [sliderId]);\n\n // The product-details API only returns `image` (singular).\n // Fall back so the main image always renders even without the full gallery array.\n const images: ProductImage[] =\n product.images && product.images.length > 0\n ? product.images\n : product.image?.url\n ? [product.image]\n : [];\n\n const hasManyImages = images.length > 1;\n const openNativeGallery = (selected: ProductImage) => {\n if (!isNativeApp()) return false;\n if (window.salla?.mobile?.openGallery?.(images, selected)) return true;\n window.salla?.event.dispatch('mobile::gallery.open', { images: legacyGalleryMedia(images) });\n return true;\n };\n\n return (\n <div className=\"sidebar md:sticky top-24 w-full md:!w-2/4 rtl:ml-8 ltr:mr-8 pb-8 md:pb-16 overflow-hidden shrink-0\">\n <SallaSlider\n id={sliderId}\n className=\"details-slider rounded-md image-slider\"\n type=\"thumbs\"\n loop={false}\n autoHeight\n listenToThumbnailsOption\n showThumbsControls={false}\n sliderConfig={{ watchOverflow: true, autoHeight: true }}\n >\n {product.promotion_title && (\n <div className=\"promotion-title\">{product.promotion_title}</div>\n )}\n\n {product.calories && (\n <div className=\"absolute z-[2] top-4 rtl:left-4 ltr:right-4 bg-white shadow-sm flex flex-col justify-center items-center rounded-full w-20 h-20 md:w-24 md:h-24\">\n <span className=\"text-red-500 text-xl leading-none font-bold\">{product.calories}</span>\n <span className=\"text-xs text-gray-500\">\n {t('pages.products.calories', 'Calories')}\n </span>\n </div>\n )}\n\n <div slot=\"items\">\n {images.map((image, index) => (\n <ImageSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n product={product}\n index={index}\n objectFit={objectFit}\n onPreview={setPreview}\n onNativeOpen={openNativeGallery}\n />\n ))}\n </div>\n\n {hasManyImages && (\n <div slot=\"thumbs\">\n {images.map((image, index) => (\n <ThumbSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n index={index}\n />\n ))}\n </div>\n )}\n </SallaSlider>\n\n <Suspense fallback={null}>\n <ImageModal\n isOpen={!!preview}\n onClose={() => setPreview(null)}\n src={preview?.src ?? ''}\n alt={preview?.alt}\n />\n </Suspense>\n </div>\n );\n}\n\nexport function ProductGallery(props: ProductGalleryProps) {\n const Component = useMemo(() => {\n const resolved = registry.resolve<ProductGalleryProps>(PRODUCT_GALLERY_KEY);\n // A theme that seeds the key with this component (register + override) would\n // otherwise recurse into itself when it has not actually overridden anything.\n return resolved === ProductGallery ? null : resolved;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductGalleryContent {...props} />;\n}\n\nfunction ImageSlide({\n image,\n product,\n index,\n objectFit,\n onPreview,\n onNativeOpen,\n}: {\n image: ProductImage;\n product: Product;\n index: number;\n objectFit: 'cover' | 'contain';\n onPreview: (preview: ImagePreview) => void;\n onNativeOpen: (image: ProductImage) => boolean;\n}) {\n const [loaded, setLoaded] = useState(false);\n const isVideo = Boolean(image.video_url);\n\n if (image.three_d_image_url) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: model-viewer is an interactive web component.\n <model-viewer\n style={{ minHeight: '500px' }}\n className=\"swiper-slide model-entry w-full h-full\"\n loading=\"lazy\"\n camera-controls\n touch-action=\"pan-y\"\n auto-rotate\n poster={image.url || undefined}\n src={image.three_d_image_url}\n shadow-intensity=\"1\"\n alt={image.alt}\n onClick={() => onNativeOpen(image)}\n ></model-viewer>\n );\n }\n\n return (\n <a\n data-fslightbox={`product_${product.id}`}\n data-img-id={image.id}\n data-slid-index={index}\n {...(image.video_url ? { 'data-video-src': image.video_url } : {})}\n data-caption={image.alt}\n data-infinite=\"false\"\n data-type={image.video_url ? 'youtube' : 'image'}\n href={image.video_url || image.url}\n // FsLightbox isn't loaded in this React theme, so the bare href would leave the SPA.\n // Open images in an in-app lightbox; let videos open in a new tab.\n {...(isVideo ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n onClick={(event) => {\n if (onNativeOpen(image)) {\n event.preventDefault();\n return;\n }\n if (isVideo || !image.url) return;\n event.preventDefault();\n onPreview({ src: image.url, alt: image.alt || product.name });\n }}\n aria-label={product.name}\n className={`swiper-slide magnify-wrapper homeslider__slide ${image.video_url ? 'video-entry' : ''}`}\n >\n <div className={`w-full ${loaded ? '' : 'aspect-square bg-gray-100 animate-pulse'}`}>\n <Image\n id={String(image.id)}\n src={image.url}\n alt={image.alt || product.name}\n className={`h-full w-full object-${objectFit}`}\n aspectRatio=\"1/1\"\n priority={index === 0}\n noWrapper\n onLoad={() => setLoaded(true)}\n />\n </div>\n </a>\n );\n}\n\nfunction ThumbSlide({ image, index }: { image: ProductImage; index: number }) {\n return (\n <div\n className={`slide--one-fourth ${image.video_url ? 'video-entry' : ''} ${image.three_d_image_url ? 'model-entry' : ''}`}\n data-caption={image.alt}\n >\n <Image\n src={image.url}\n alt={image.alt || ''}\n className=\"object-cover w-full h-full bg-gray-100 rounded-md overflow-hidden\"\n title={image.alt}\n priority={index < 5}\n noWrapper\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/components/product/lazy.ts","../src/components/product/ProductCard.tsx","../src/components/product/ProductGallery.tsx"],"names":["ProductCardContent","ProductCard","jsxs","jsx","useMemo"],"mappings":";;;;;;;;;;;;;;;;AAEO,IAAM,kBAAA,GAAqB,IAAA;AAAA,EAAK,MACrC,OAAO,8BAAkB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,cAAA,EAAe,CAAE;AACxE;AAEO,IAAM,iBAAA,GAAoB,IAAA;AAAA,EAAK,MACpC,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE;ACMA,IAAM,gBAAA,GAAmB,cAAA;AAEzB,IAAM,2BAAA,GAA8B,CAAC,GAAA,EAAK,GAAA,EAAK,KAAK,GAAG,CAAA;AAEvD,IAAM,mBAA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AA;AAAA,UACC,EAAA,EAAI,MAAA,CAAO,KAAA,CAAM,EAAE,CAAA;AAAA,UACnB,KAAK,KAAA,CAAM,GAAA;AAAA,UACX,GAAA,EAAK,KAAA,CAAM,GAAA,IAAO,OAAA,CAAQ,IAAA;AAAA,UAC1B,SAAA,EAAW,wBAAwB,SAAS,CAAA,CAAA;AAAA,UAC5C,WAAA,EAAY,KAAA;AAAA,UACZ,UAAU,KAAA,KAAU,CAAA;AAAA,UACpB,SAAA,EAAS,IAAA;AAAA,UACT,MAAA,EAAQ,MAAM,SAAA,CAAU,IAAI;AAAA;AAAA,OAC9B,EACF;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAM,EAA2C;AAC5E,EAAA,uBACEA,GAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,CAAA,kBAAA,EAAqB,KAAA,CAAM,SAAA,GAAY,aAAA,GAAgB,EAAE,CAAA,CAAA,EAAI,KAAA,CAAM,iBAAA,GAAoB,aAAA,GAAgB,EAAE,CAAA,CAAA;AAAA,MACpH,gBAAc,KAAA,CAAM,GAAA;AAAA,MAEpB,QAAA,kBAAAA,GAAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAK,KAAA,CAAM,GAAA;AAAA,UACX,GAAA,EAAK,MAAM,GAAA,IAAO,EAAA;AAAA,UAClB,SAAA,EAAU,mEAAA;AAAA,UACV,OAAO,KAAA,CAAM,GAAA;AAAA,UACb,UAAU,KAAA,GAAQ,CAAA;AAAA,UAClB,SAAA,EAAS;AAAA;AAAA;AACX;AAAA,GACF;AAEJ","file":"chunk-MKDS22Q3.js","sourcesContent":["import { lazy } from 'react';\n\nexport const LazyProductDetails = lazy(() =>\n import('./ProductDetails').then((m) => ({ default: m.ProductDetails }))\n);\n\nexport const LazyAddToCartForm = lazy(() =>\n import('./AddToCartForm').then((m) => ({ default: m.AddToCartForm }))\n);\n","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 } = 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 // Price display component\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)}</h4>\n {product.regular_price && <span>{format(product.regular_price)}</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)}</h4>\n </div>\n );\n }\n return <h4 className=\"s-product-card-price\">{format(product.price)}</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 fitImageHeight && isVertical ? `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","import { SallaSlider } from '@salla.sa/twilight-components-react/slider';\nimport { Suspense, useEffect, useMemo, useState } from 'react';\nimport { registry } from '../ComponentRegistry';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Product, ProductImage } from '../../types';\nimport { Image } from '../common/Image';\nimport { ImageModal } from '../modal';\nimport { isNativeApp } from '../../native-app';\n\nconst PRODUCT_GALLERY_KEY = 'product:gallery';\n\nexport interface ProductGalleryProps {\n product: Product;\n}\n\ntype ImagePreview = { src: string; alt: string };\ntype GalleryMedia = { url: string; type: 'image' | 'video' | '3d-image' };\n\n/**\n * The engine's own `mobile::gallery.open` payload from before `salla.mobile.openGallery`: a video's\n * link and a 3D model's file go in `url`, with no ids. Sent when the SDK has no `openGallery`\n * (Twilight before 2.14.569) or declines inside the app, so those stores keep the gallery they had.\n */\nfunction legacyGalleryMedia(images: ProductImage[]): GalleryMedia[] {\n return images.flatMap<GalleryMedia>((image) => {\n if (image.three_d_image_url) return [{ url: image.three_d_image_url, type: '3d-image' }];\n if (image.video_url) return [{ url: image.video_url, type: 'video' }];\n return image.url ? [{ url: image.url, type: 'image' }] : [];\n });\n}\n\nfunction ProductGalleryContent({ product }: ProductGalleryProps) {\n const { t } = useTranslation();\n const { theme } = useTwilight();\n const sliderId = `details-slider-${product.id}`;\n const objectFit = theme.settings.slider_background_size ?? 'cover';\n\n // Clicking an image opens an in-app lightbox instead of navigating to the CDN URL.\n const [preview, setPreview] = useState<ImagePreview | null>(null);\n\n useEffect(() => {\n const raf = requestAnimationFrame(() => {\n const el = document.getElementById(sliderId);\n if (!el?.parentElement) return;\n const { parentElement, nextSibling } = el;\n parentElement.removeChild(el);\n parentElement.insertBefore(el, nextSibling);\n });\n return () => cancelAnimationFrame(raf);\n }, [sliderId]);\n\n // The product-details API only returns `image` (singular).\n // Fall back so the main image always renders even without the full gallery array.\n const images: ProductImage[] =\n product.images && product.images.length > 0\n ? product.images\n : product.image?.url\n ? [product.image]\n : [];\n\n const hasManyImages = images.length > 1;\n const openNativeGallery = (selected: ProductImage) => {\n if (!isNativeApp()) return false;\n if (window.salla?.mobile?.openGallery?.(images, selected)) return true;\n window.salla?.event.dispatch('mobile::gallery.open', { images: legacyGalleryMedia(images) });\n return true;\n };\n\n return (\n <div className=\"sidebar md:sticky top-24 w-full md:!w-2/4 rtl:ml-8 ltr:mr-8 pb-8 md:pb-16 overflow-hidden shrink-0\">\n <SallaSlider\n id={sliderId}\n className=\"details-slider rounded-md image-slider\"\n type=\"thumbs\"\n loop={false}\n autoHeight\n listenToThumbnailsOption\n showThumbsControls={false}\n sliderConfig={{ watchOverflow: true, autoHeight: true }}\n >\n {product.promotion_title && (\n <div className=\"promotion-title\">{product.promotion_title}</div>\n )}\n\n {product.calories && (\n <div className=\"absolute z-[2] top-4 rtl:left-4 ltr:right-4 bg-white shadow-sm flex flex-col justify-center items-center rounded-full w-20 h-20 md:w-24 md:h-24\">\n <span className=\"text-red-500 text-xl leading-none font-bold\">{product.calories}</span>\n <span className=\"text-xs text-gray-500\">\n {t('pages.products.calories', 'Calories')}\n </span>\n </div>\n )}\n\n <div slot=\"items\">\n {images.map((image, index) => (\n <ImageSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n product={product}\n index={index}\n objectFit={objectFit}\n onPreview={setPreview}\n onNativeOpen={openNativeGallery}\n />\n ))}\n </div>\n\n {hasManyImages && (\n <div slot=\"thumbs\">\n {images.map((image, index) => (\n <ThumbSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n index={index}\n />\n ))}\n </div>\n )}\n </SallaSlider>\n\n <Suspense fallback={null}>\n <ImageModal\n isOpen={!!preview}\n onClose={() => setPreview(null)}\n src={preview?.src ?? ''}\n alt={preview?.alt}\n />\n </Suspense>\n </div>\n );\n}\n\nexport function ProductGallery(props: ProductGalleryProps) {\n const Component = useMemo(() => {\n const resolved = registry.resolve<ProductGalleryProps>(PRODUCT_GALLERY_KEY);\n // A theme that seeds the key with this component (register + override) would\n // otherwise recurse into itself when it has not actually overridden anything.\n return resolved === ProductGallery ? null : resolved;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductGalleryContent {...props} />;\n}\n\nfunction ImageSlide({\n image,\n product,\n index,\n objectFit,\n onPreview,\n onNativeOpen,\n}: {\n image: ProductImage;\n product: Product;\n index: number;\n objectFit: 'cover' | 'contain';\n onPreview: (preview: ImagePreview) => void;\n onNativeOpen: (image: ProductImage) => boolean;\n}) {\n const [loaded, setLoaded] = useState(false);\n const isVideo = Boolean(image.video_url);\n\n if (image.three_d_image_url) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: model-viewer is an interactive web component.\n <model-viewer\n style={{ minHeight: '500px' }}\n className=\"swiper-slide model-entry w-full h-full\"\n loading=\"lazy\"\n camera-controls\n touch-action=\"pan-y\"\n auto-rotate\n poster={image.url || undefined}\n src={image.three_d_image_url}\n shadow-intensity=\"1\"\n alt={image.alt}\n onClick={() => onNativeOpen(image)}\n ></model-viewer>\n );\n }\n\n return (\n <a\n data-fslightbox={`product_${product.id}`}\n data-img-id={image.id}\n data-slid-index={index}\n {...(image.video_url ? { 'data-video-src': image.video_url } : {})}\n data-caption={image.alt}\n data-infinite=\"false\"\n data-type={image.video_url ? 'youtube' : 'image'}\n href={image.video_url || image.url}\n // FsLightbox isn't loaded in this React theme, so the bare href would leave the SPA.\n // Open images in an in-app lightbox; let videos open in a new tab.\n {...(isVideo ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n onClick={(event) => {\n if (onNativeOpen(image)) {\n event.preventDefault();\n return;\n }\n if (isVideo || !image.url) return;\n event.preventDefault();\n onPreview({ src: image.url, alt: image.alt || product.name });\n }}\n aria-label={product.name}\n className={`swiper-slide magnify-wrapper homeslider__slide ${image.video_url ? 'video-entry' : ''}`}\n >\n <div className={`w-full ${loaded ? '' : 'aspect-square bg-gray-100 animate-pulse'}`}>\n <Image\n id={String(image.id)}\n src={image.url}\n alt={image.alt || product.name}\n className={`h-full w-full object-${objectFit}`}\n aspectRatio=\"1/1\"\n priority={index === 0}\n noWrapper\n onLoad={() => setLoaded(true)}\n />\n </div>\n </a>\n );\n}\n\nfunction ThumbSlide({ image, index }: { image: ProductImage; index: number }) {\n return (\n <div\n className={`slide--one-fourth ${image.video_url ? 'video-entry' : ''} ${image.three_d_image_url ? 'model-entry' : ''}`}\n data-caption={image.alt}\n >\n <Image\n src={image.url}\n alt={image.alt || ''}\n className=\"object-cover w-full h-full bg-gray-100 rounded-md overflow-hidden\"\n title={image.alt}\n priority={index < 5}\n noWrapper\n />\n </div>\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow } from './chunk-KXD4WUYA.js';
2
- import { getActiveScope, api } from './chunk-M46EKE7R.js';
1
+ import { orThrow } from './chunk-T23HXVW5.js';
2
+ import { getActiveScope, api } from './chunk-PFAPRJVF.js';
3
3
  import { getTwilightContext } from './chunk-7VNVCHID.js';
4
4
  import { defaultShouldDehydrateQuery, queryOptions } from '@tanstack/react-query';
5
5
 
@@ -194,5 +194,5 @@ var product = {
194
194
  };
195
195
 
196
196
  export { getProductPreview, isProductPreviewQuery, parseNextPageToken, product, productDetailQueryKey, productPreviewQueryKey, rememberProductPreview, shouldDehydrateQuery };
197
- //# sourceMappingURL=chunk-YWDMDW2K.js.map
198
- //# sourceMappingURL=chunk-YWDMDW2K.js.map
197
+ //# sourceMappingURL=chunk-MQALPNFL.js.map
198
+ //# sourceMappingURL=chunk-MQALPNFL.js.map