@salla.sa/twilight-theme-engine 1.0.103 → 1.0.105

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 (287) hide show
  1. package/dist/{AddToCartForm-O7UZDX6G.js → AddToCartForm-LWSRJJSF.js} +3 -3
  2. package/dist/{AddToCartForm-O7UZDX6G.js.map → AddToCartForm-LWSRJJSF.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-JLU2JWPT.js → BlogAuthorPage-E2BONAKB.js} +27 -27
  4. package/dist/{BlogAuthorPage-JLU2JWPT.js.map → BlogAuthorPage-E2BONAKB.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-FTZPLNTL.js → BlogCategoryPage-F5G35XQE.js} +27 -27
  6. package/dist/{BlogCategoryPage-FTZPLNTL.js.map → BlogCategoryPage-F5G35XQE.js.map} +1 -1
  7. package/dist/{BlogPage-JBVPGHR5.js → BlogPage-W4NDWE5Q.js} +25 -25
  8. package/dist/{BlogPage-JBVPGHR5.js.map → BlogPage-W4NDWE5Q.js.map} +1 -1
  9. package/dist/{BlogSinglePage-V3KQ5HIW.js → BlogSinglePage-543VMKSI.js} +25 -25
  10. package/dist/{BlogSinglePage-V3KQ5HIW.js.map → BlogSinglePage-543VMKSI.js.map} +1 -1
  11. package/dist/{BlogTagPage-NTYO6TB4.js → BlogTagPage-KDQVHQ65.js} +27 -27
  12. package/dist/{BlogTagPage-NTYO6TB4.js.map → BlogTagPage-KDQVHQ65.js.map} +1 -1
  13. package/dist/{BrandsPage-5OSSOWDP.js → BrandsPage-ABKUKE5J.js} +26 -26
  14. package/dist/{BrandsPage-5OSSOWDP.js.map → BrandsPage-ABKUKE5J.js.map} +1 -1
  15. package/dist/{Breadcrumb-GJI3N76F.js → Breadcrumb-WBTLVXYF.js} +25 -25
  16. package/dist/{Breadcrumb-GJI3N76F.js.map → Breadcrumb-WBTLVXYF.js.map} +1 -1
  17. package/dist/{CartItem-KO34MYXT.js → CartItem-KNFR7K7Z.js} +25 -25
  18. package/dist/{CartItem-KO34MYXT.js.map → CartItem-KNFR7K7Z.js.map} +1 -1
  19. package/dist/{CartSummary-NPFAJI7C.js → CartSummary-EQ4GTR4Y.js} +25 -25
  20. package/dist/{CartSummary-NPFAJI7C.js.map → CartSummary-EQ4GTR4Y.js.map} +1 -1
  21. package/dist/{Copyright-VEJV2YTR.js → Copyright-NYKF6LY5.js} +3 -3
  22. package/dist/{Copyright-VEJV2YTR.js.map → Copyright-NYKF6LY5.js.map} +1 -1
  23. package/dist/{CustomerLayout-L374ZRWY.js → CustomerLayout-NY4LOV3Y.js} +25 -25
  24. package/dist/{CustomerLayout-L374ZRWY.js.map → CustomerLayout-NY4LOV3Y.js.map} +1 -1
  25. package/dist/{Footer-D4YSIM25.js → Footer-DRKA2MI6.js} +4 -4
  26. package/dist/{Footer-D4YSIM25.js.map → Footer-DRKA2MI6.js.map} +1 -1
  27. package/dist/Header-JBZRD2WU.js +22 -0
  28. package/dist/{Header-CXJ3TFHO.js.map → Header-JBZRD2WU.js.map} +1 -1
  29. package/dist/{LoyaltyPage-BTKKAZYT.js → LoyaltyPage-VOAUC2CY.js} +25 -25
  30. package/dist/{LoyaltyPage-BTKKAZYT.js.map → LoyaltyPage-VOAUC2CY.js.map} +1 -1
  31. package/dist/{LoyaltyPointsPage-CBVSWLR6.js → LoyaltyPointsPage-I5U5NFK3.js} +9 -9
  32. package/dist/{LoyaltyPointsPage-CBVSWLR6.js.map → LoyaltyPointsPage-I5U5NFK3.js.map} +1 -1
  33. package/dist/{MainMenu-KCVTEZRG.js → MainMenu-SWP46RPJ.js} +8 -8
  34. package/dist/{MainMenu-KCVTEZRG.js.map → MainMenu-SWP46RPJ.js.map} +1 -1
  35. package/dist/MaintenancePage-MGWJYB2O.js +7 -0
  36. package/dist/MaintenancePage-MGWJYB2O.js.map +1 -0
  37. package/dist/{MasterLayout-K6IGPKCD.js → MasterLayout-BF2E47SE.js} +25 -25
  38. package/dist/{MasterLayout-K6IGPKCD.js.map → MasterLayout-BF2E47SE.js.map} +1 -1
  39. package/dist/{MobileMenu-KDKARTM5.js → MobileMenu-LBOVOA6D.js} +26 -26
  40. package/dist/{MobileMenu-KDKARTM5.js.map → MobileMenu-LBOVOA6D.js.map} +1 -1
  41. package/dist/{NotificationsPage-A3NZEO52.js → NotificationsPage-FNFKEOX3.js} +25 -25
  42. package/dist/{NotificationsPage-A3NZEO52.js.map → NotificationsPage-FNFKEOX3.js.map} +1 -1
  43. package/dist/{OrderSinglePage-APA3LCWT.js → OrderSinglePage-EGCPZ25S.js} +26 -26
  44. package/dist/{OrderSinglePage-APA3LCWT.js.map → OrderSinglePage-EGCPZ25S.js.map} +1 -1
  45. package/dist/{OrdersPage-N4S2SKXD.js → OrdersPage-DOK3AE37.js} +25 -25
  46. package/dist/{OrdersPage-N4S2SKXD.js.map → OrdersPage-DOK3AE37.js.map} +1 -1
  47. package/dist/{PageSingle-ED3IQQLS.js → PageSingle-4NYB7VCI.js} +7 -7
  48. package/dist/{PageSingle-ED3IQQLS.js.map → PageSingle-4NYB7VCI.js.map} +1 -1
  49. package/dist/{ProductDetails-MN3GXUXK.js → ProductDetails-EJ6WKSLO.js} +8 -8
  50. package/dist/{ProductDetails-MN3GXUXK.js.map → ProductDetails-EJ6WKSLO.js.map} +1 -1
  51. package/dist/{ProfilePage-QQ2GN7RO.js → ProfilePage-RQJNJFAV.js} +25 -25
  52. package/dist/{ProfilePage-QQ2GN7RO.js.map → ProfilePage-RQJNJFAV.js.map} +1 -1
  53. package/dist/{ReviewsPage-YHO2CNZP.js → ReviewsPage-SSVTW76R.js} +3 -3
  54. package/dist/{ReviewsPage-YHO2CNZP.js.map → ReviewsPage-SSVTW76R.js.map} +1 -1
  55. package/dist/{SeoCartWidget-DWJT2WXI.js → SeoCartWidget-I3T6MEYN.js} +25 -25
  56. package/dist/{SeoCartWidget-DWJT2WXI.js.map → SeoCartWidget-I3T6MEYN.js.map} +1 -1
  57. package/dist/{SettingsPage-BRCNPSRN.js → SettingsPage-F2PHWF6M.js} +25 -25
  58. package/dist/{SettingsPage-BRCNPSRN.js.map → SettingsPage-F2PHWF6M.js.map} +1 -1
  59. package/dist/StoreClosedNotification-A55JL5ZF.js +54 -0
  60. package/dist/{StoreClosedNotification-2CIG5LX6.js.map → StoreClosedNotification-A55JL5ZF.js.map} +1 -1
  61. package/dist/{TestimonialsPage-DDLTHBMM.js → TestimonialsPage-P3NQ4MD6.js} +7 -7
  62. package/dist/{TestimonialsPage-DDLTHBMM.js.map → TestimonialsPage-P3NQ4MD6.js.map} +1 -1
  63. package/dist/{ThankYouPage-YN6PC4GT.js → ThankYouPage-NGQHYJV5.js} +25 -25
  64. package/dist/{ThankYouPage-YN6PC4GT.js.map → ThankYouPage-NGQHYJV5.js.map} +1 -1
  65. package/dist/{WalletPage-YVJYIL52.js → WalletPage-QKMWV2NA.js} +26 -26
  66. package/dist/{WalletPage-YVJYIL52.js.map → WalletPage-QKMWV2NA.js.map} +1 -1
  67. package/dist/{WishlistPage-PD3SHN27.js → WishlistPage-HOR22EBU.js} +27 -27
  68. package/dist/{WishlistPage-PD3SHN27.js.map → WishlistPage-HOR22EBU.js.map} +1 -1
  69. package/dist/api/advertisement.js +5 -5
  70. package/dist/api/apps.js +5 -5
  71. package/dist/api/blog.js +7 -7
  72. package/dist/api/brands.js +7 -7
  73. package/dist/api/cart.js +7 -7
  74. package/dist/api/category.js +7 -7
  75. package/dist/api/client.js +4 -4
  76. package/dist/api/home.js +5 -5
  77. package/dist/api/loyalty.js +7 -7
  78. package/dist/api/menu.js +5 -5
  79. package/dist/api/notification.js +5 -5
  80. package/dist/api/order.js +7 -7
  81. package/dist/api/page.js +7 -7
  82. package/dist/api/product.js +7 -7
  83. package/dist/api/profile.js +4 -4
  84. package/dist/api/store.d.ts +9 -1
  85. package/dist/api/store.d.ts.map +1 -1
  86. package/dist/api/store.js +5 -5
  87. package/dist/api/translations.js +5 -5
  88. package/dist/api/user.js +5 -5
  89. package/dist/api/wallet.js +5 -5
  90. package/dist/api/wishlist.js +8 -8
  91. package/dist/{chunk-PXHFHHTW.js → chunk-25SLMOCZ.js} +4 -4
  92. package/dist/{chunk-PXHFHHTW.js.map → chunk-25SLMOCZ.js.map} +1 -1
  93. package/dist/{chunk-IOUOF5KK.js → chunk-2IS4QU3P.js} +4 -4
  94. package/dist/{chunk-IOUOF5KK.js.map → chunk-2IS4QU3P.js.map} +1 -1
  95. package/dist/{chunk-OOCN4RFV.js → chunk-3EBV4X6W.js} +3 -3
  96. package/dist/{chunk-OOCN4RFV.js.map → chunk-3EBV4X6W.js.map} +1 -1
  97. package/dist/chunk-3PSJH6Q4.js +108 -0
  98. package/dist/chunk-3PSJH6Q4.js.map +1 -0
  99. package/dist/{chunk-V7EPED4G.js → chunk-42RKFHJG.js} +74 -18
  100. package/dist/chunk-42RKFHJG.js.map +1 -0
  101. package/dist/{chunk-HKSDEFQV.js → chunk-42YMCOK4.js} +3 -3
  102. package/dist/{chunk-HKSDEFQV.js.map → chunk-42YMCOK4.js.map} +1 -1
  103. package/dist/{chunk-JUUKZRE5.js → chunk-4O52OV5N.js} +3 -3
  104. package/dist/{chunk-JUUKZRE5.js.map → chunk-4O52OV5N.js.map} +1 -1
  105. package/dist/{chunk-JDLXT6VI.js → chunk-5DWTU5KS.js} +7 -5
  106. package/dist/chunk-5DWTU5KS.js.map +1 -0
  107. package/dist/{chunk-IGD4G3SP.js → chunk-5L6IBYWZ.js} +4 -4
  108. package/dist/{chunk-IGD4G3SP.js.map → chunk-5L6IBYWZ.js.map} +1 -1
  109. package/dist/{chunk-TMN53ONR.js → chunk-6SXIAFXW.js} +7 -7
  110. package/dist/{chunk-TMN53ONR.js.map → chunk-6SXIAFXW.js.map} +1 -1
  111. package/dist/{chunk-46JZXQRS.js → chunk-76GCBYJX.js} +3 -3
  112. package/dist/{chunk-46JZXQRS.js.map → chunk-76GCBYJX.js.map} +1 -1
  113. package/dist/{chunk-L4AWMQPQ.js → chunk-BHNY4T4O.js} +8 -8
  114. package/dist/{chunk-L4AWMQPQ.js.map → chunk-BHNY4T4O.js.map} +1 -1
  115. package/dist/{chunk-XMO7HDZZ.js → chunk-C5MQ6VWX.js} +3 -3
  116. package/dist/{chunk-XMO7HDZZ.js.map → chunk-C5MQ6VWX.js.map} +1 -1
  117. package/dist/{chunk-Y6J6NYNK.js → chunk-CTV5GA2U.js} +4 -4
  118. package/dist/{chunk-Y6J6NYNK.js.map → chunk-CTV5GA2U.js.map} +1 -1
  119. package/dist/{chunk-JZDJO2CK.js → chunk-D2VMJV3L.js} +10 -8
  120. package/dist/chunk-D2VMJV3L.js.map +1 -0
  121. package/dist/{chunk-IYD3EN22.js → chunk-D6IJYZ7U.js} +7 -7
  122. package/dist/{chunk-IYD3EN22.js.map → chunk-D6IJYZ7U.js.map} +1 -1
  123. package/dist/{chunk-7YH3A5BT.js → chunk-DMMGD4GW.js} +5 -5
  124. package/dist/{chunk-7YH3A5BT.js.map → chunk-DMMGD4GW.js.map} +1 -1
  125. package/dist/{chunk-HIAHDZI5.js → chunk-FQHNVD3H.js} +3 -3
  126. package/dist/{chunk-HIAHDZI5.js.map → chunk-FQHNVD3H.js.map} +1 -1
  127. package/dist/{chunk-H3PJJKAQ.js → chunk-HG4B4F4N.js} +8 -3
  128. package/dist/chunk-HG4B4F4N.js.map +1 -0
  129. package/dist/{chunk-6EBVVCNI.js → chunk-HGKAIIAJ.js} +4 -4
  130. package/dist/{chunk-6EBVVCNI.js.map → chunk-HGKAIIAJ.js.map} +1 -1
  131. package/dist/{chunk-FV6PNN6N.js → chunk-HGY7P2Y3.js} +5 -5
  132. package/dist/{chunk-FV6PNN6N.js.map → chunk-HGY7P2Y3.js.map} +1 -1
  133. package/dist/{chunk-RPVHCIR4.js → chunk-JP5XQJKO.js} +4 -4
  134. package/dist/{chunk-RPVHCIR4.js.map → chunk-JP5XQJKO.js.map} +1 -1
  135. package/dist/{chunk-ZPX4LBQZ.js → chunk-KTLQV4Q4.js} +5 -5
  136. package/dist/{chunk-ZPX4LBQZ.js.map → chunk-KTLQV4Q4.js.map} +1 -1
  137. package/dist/{chunk-3W746XYR.js → chunk-LBBPJM4K.js} +5 -5
  138. package/dist/{chunk-3W746XYR.js.map → chunk-LBBPJM4K.js.map} +1 -1
  139. package/dist/{chunk-GLWSJZJZ.js → chunk-LPAWMUJR.js} +4 -4
  140. package/dist/{chunk-GLWSJZJZ.js.map → chunk-LPAWMUJR.js.map} +1 -1
  141. package/dist/{chunk-AVPU5C5V.js → chunk-MHDOK7GH.js} +4 -4
  142. package/dist/{chunk-AVPU5C5V.js.map → chunk-MHDOK7GH.js.map} +1 -1
  143. package/dist/{chunk-UY57T42N.js → chunk-MSNU4NYS.js} +3 -3
  144. package/dist/{chunk-UY57T42N.js.map → chunk-MSNU4NYS.js.map} +1 -1
  145. package/dist/{chunk-VEWF3NFM.js → chunk-OWJMPD7X.js} +3 -3
  146. package/dist/{chunk-VEWF3NFM.js.map → chunk-OWJMPD7X.js.map} +1 -1
  147. package/dist/{chunk-UIXEKYTM.js → chunk-P7N3TZFE.js} +46 -24
  148. package/dist/chunk-P7N3TZFE.js.map +1 -0
  149. package/dist/{chunk-U73QOIGZ.js → chunk-PLW6MTSL.js} +8 -8
  150. package/dist/{chunk-U73QOIGZ.js.map → chunk-PLW6MTSL.js.map} +1 -1
  151. package/dist/{chunk-6LRTCW27.js → chunk-PSBXF3O5.js} +4 -4
  152. package/dist/{chunk-6LRTCW27.js.map → chunk-PSBXF3O5.js.map} +1 -1
  153. package/dist/{chunk-7RL4DG54.js → chunk-PXM3FBPO.js} +3 -3
  154. package/dist/{chunk-7RL4DG54.js.map → chunk-PXM3FBPO.js.map} +1 -1
  155. package/dist/{chunk-VPGOT3JO.js → chunk-QUBQPGT7.js} +3 -3
  156. package/dist/{chunk-VPGOT3JO.js.map → chunk-QUBQPGT7.js.map} +1 -1
  157. package/dist/{chunk-6TWQZEPF.js → chunk-QXX54X55.js} +4 -4
  158. package/dist/{chunk-6TWQZEPF.js.map → chunk-QXX54X55.js.map} +1 -1
  159. package/dist/{chunk-TSAIM4XM.js → chunk-RSWRKU4X.js} +4 -4
  160. package/dist/{chunk-TSAIM4XM.js.map → chunk-RSWRKU4X.js.map} +1 -1
  161. package/dist/{chunk-P4XV656A.js → chunk-S6SP272Z.js} +5 -4
  162. package/dist/chunk-S6SP272Z.js.map +1 -0
  163. package/dist/{chunk-7OB2DG2K.js → chunk-SDEBSX6Z.js} +4 -4
  164. package/dist/{chunk-7OB2DG2K.js.map → chunk-SDEBSX6Z.js.map} +1 -1
  165. package/dist/{chunk-C7RM335V.js → chunk-STKR2KHL.js} +3 -3
  166. package/dist/{chunk-C7RM335V.js.map → chunk-STKR2KHL.js.map} +1 -1
  167. package/dist/{chunk-GNLCPK6N.js → chunk-SU7NHAYA.js} +3 -3
  168. package/dist/{chunk-GNLCPK6N.js.map → chunk-SU7NHAYA.js.map} +1 -1
  169. package/dist/chunk-TCTKM34I.js +14 -0
  170. package/dist/{chunk-CXONF653.js.map → chunk-TCTKM34I.js.map} +1 -1
  171. package/dist/{chunk-PENQTLAN.js → chunk-TWD4ECS3.js} +3 -3
  172. package/dist/{chunk-PENQTLAN.js.map → chunk-TWD4ECS3.js.map} +1 -1
  173. package/dist/{chunk-44FMRCHW.js → chunk-TYTYD6AK.js} +3 -3
  174. package/dist/{chunk-44FMRCHW.js.map → chunk-TYTYD6AK.js.map} +1 -1
  175. package/dist/{chunk-YXI2ZCXD.js → chunk-U3UY2BDN.js} +4 -4
  176. package/dist/{chunk-YXI2ZCXD.js.map → chunk-U3UY2BDN.js.map} +1 -1
  177. package/dist/{chunk-224CL4SD.js → chunk-UWDS42UX.js} +4 -4
  178. package/dist/{chunk-224CL4SD.js.map → chunk-UWDS42UX.js.map} +1 -1
  179. package/dist/{chunk-GT2L5IJ4.js → chunk-V7QFIGQ4.js} +7 -6
  180. package/dist/chunk-V7QFIGQ4.js.map +1 -0
  181. package/dist/{chunk-6YWW5Y22.js → chunk-VEA7QDNY.js} +3 -3
  182. package/dist/{chunk-6YWW5Y22.js.map → chunk-VEA7QDNY.js.map} +1 -1
  183. package/dist/{chunk-RI5PSI34.js → chunk-VJQ7SM4O.js} +5 -5
  184. package/dist/{chunk-RI5PSI34.js.map → chunk-VJQ7SM4O.js.map} +1 -1
  185. package/dist/{chunk-QTH6GGUH.js → chunk-XD33WKKI.js} +7 -7
  186. package/dist/{chunk-QTH6GGUH.js.map → chunk-XD33WKKI.js.map} +1 -1
  187. package/dist/{chunk-BXOQ663B.js → chunk-YMHL73TL.js} +6 -6
  188. package/dist/{chunk-BXOQ663B.js.map → chunk-YMHL73TL.js.map} +1 -1
  189. package/dist/{chunk-ZMCFSOYF.js → chunk-YSRKR5DE.js} +4 -4
  190. package/dist/{chunk-ZMCFSOYF.js.map → chunk-YSRKR5DE.js.map} +1 -1
  191. package/dist/{chunk-46EXP3AL.js → chunk-YXCJBX6X.js} +8 -8
  192. package/dist/{chunk-46EXP3AL.js.map → chunk-YXCJBX6X.js.map} +1 -1
  193. package/dist/{chunk-RJTIP2L3.js → chunk-ZE262XHY.js} +4 -4
  194. package/dist/{chunk-RJTIP2L3.js.map → chunk-ZE262XHY.js.map} +1 -1
  195. package/dist/components/cart/index.js +1 -1
  196. package/dist/components/common/index.js +1 -1
  197. package/dist/components/drawer/index.js +23 -23
  198. package/dist/components/home/index.js +27 -27
  199. package/dist/components/layout/index.js +7 -7
  200. package/dist/components/product/index.js +24 -24
  201. package/dist/components/store/MaintenancePage.d.ts +8 -0
  202. package/dist/components/store/MaintenancePage.d.ts.map +1 -0
  203. package/dist/components/store/index.d.ts +2 -1
  204. package/dist/components/store/index.d.ts.map +1 -1
  205. package/dist/components/store/index.js +25 -33
  206. package/dist/components/store/index.js.map +1 -1
  207. package/dist/components/store/lazy.d.ts +2 -0
  208. package/dist/components/store/lazy.d.ts.map +1 -1
  209. package/dist/components/toast/index.js +5 -5
  210. package/dist/dev/editor/index.js +3 -3
  211. package/dist/dev/index.js +3 -3
  212. package/dist/document-class-AQ7FGLPE.js +29 -0
  213. package/dist/{document-class-JQ7ZZJAT.js.map → document-class-AQ7FGLPE.js.map} +1 -1
  214. package/dist/hooks/index.js +23 -23
  215. package/dist/hooks/useComments.js +4 -4
  216. package/dist/hooks/useGtm.js +23 -23
  217. package/dist/hooks/useMoney.js +23 -23
  218. package/dist/hooks/useProduct.js +4 -4
  219. package/dist/hooks/useStore.js +23 -23
  220. package/dist/hooks/useUser.js +6 -6
  221. package/dist/hooks/useWishlist.js +4 -4
  222. package/dist/index.js +23 -23
  223. package/dist/native-app/index.js +4 -4
  224. package/dist/{navigation-GQA6OA42.js → navigation-6MDIVFMB.js} +8 -8
  225. package/dist/{navigation-GQA6OA42.js.map → navigation-6MDIVFMB.js.map} +1 -1
  226. package/dist/navigation-P3RDLBP7.js +14 -0
  227. package/dist/{navigation-RO3T4FDQ.js.map → navigation-P3RDLBP7.js.map} +1 -1
  228. package/dist/{not-found-MTU2BM73.js → not-found-RBWKACRW.js} +26 -26
  229. package/dist/{not-found-MTU2BM73.js.map → not-found-RBWKACRW.js.map} +1 -1
  230. package/dist/providers/NavigationProvider.d.ts +4 -1
  231. package/dist/providers/NavigationProvider.d.ts.map +1 -1
  232. package/dist/providers/TwilightProvider.d.ts +1 -1
  233. package/dist/providers/TwilightProvider.d.ts.map +1 -1
  234. package/dist/providers/index.js +23 -23
  235. package/dist/routes/account/orders.js +8 -8
  236. package/dist/routes/account.js +17 -17
  237. package/dist/routes/blog.js +12 -12
  238. package/dist/routes/brands.js +8 -8
  239. package/dist/routes/cart.js +31 -31
  240. package/dist/routes/home.js +28 -28
  241. package/dist/routes/index.js +7 -7
  242. package/dist/routes/loyalty.js +9 -9
  243. package/dist/routes/page.js +8 -8
  244. package/dist/routes/product-listing.js +29 -29
  245. package/dist/routes/product.js +27 -27
  246. package/dist/routes/root/beforeLoad.d.ts +13 -0
  247. package/dist/routes/root/beforeLoad.d.ts.map +1 -1
  248. package/dist/routes/seo-redirects.js +7 -7
  249. package/dist/routes/testimonials.js +3 -3
  250. package/dist/routes/thank-you.js +8 -8
  251. package/dist/skeleton.js +28 -28
  252. package/dist/{store-lookup-C4DMFSBT.js → store-lookup-7SAEE4L3.js} +12 -12
  253. package/dist/{store-lookup-C4DMFSBT.js.map → store-lookup-7SAEE4L3.js.map} +1 -1
  254. package/dist/tanstack/middleware/twilight.d.ts +12 -0
  255. package/dist/tanstack/middleware/twilight.d.ts.map +1 -1
  256. package/dist/tanstack/router.d.ts.map +1 -1
  257. package/dist/tanstack.js +34 -21
  258. package/dist/tanstack.js.map +1 -1
  259. package/dist/twilight/context.d.ts +5 -0
  260. package/dist/twilight/context.d.ts.map +1 -1
  261. package/dist/twilight/ensure-context.d.ts.map +1 -1
  262. package/dist/types/index.d.ts +19 -0
  263. package/dist/types/index.d.ts.map +1 -1
  264. package/dist/types/twilight.d.ts +8 -0
  265. package/dist/types/twilight.d.ts.map +1 -1
  266. package/dist/utils/index.js +6 -6
  267. package/dist/utils/maintenance.d.ts +31 -0
  268. package/dist/utils/maintenance.d.ts.map +1 -0
  269. package/dist/vite/index.js +3 -3
  270. package/package.json +1 -1
  271. package/tailwind/components/store/MaintenancePage.tsx.txt +156 -0
  272. package/tailwind/components/store/index.ts.txt +4 -1
  273. package/tailwind/components/store/lazy.ts.txt +5 -0
  274. package/tailwind/routes/root/beforeLoad.ts.txt +54 -0
  275. package/tailwind/routes/root/head.ts.txt +6 -2
  276. package/dist/Header-CXJ3TFHO.js +0 -22
  277. package/dist/StoreClosedNotification-2CIG5LX6.js +0 -54
  278. package/dist/chunk-CXONF653.js +0 -14
  279. package/dist/chunk-GT2L5IJ4.js.map +0 -1
  280. package/dist/chunk-H3PJJKAQ.js.map +0 -1
  281. package/dist/chunk-JDLXT6VI.js.map +0 -1
  282. package/dist/chunk-JZDJO2CK.js.map +0 -1
  283. package/dist/chunk-P4XV656A.js.map +0 -1
  284. package/dist/chunk-UIXEKYTM.js.map +0 -1
  285. package/dist/chunk-V7EPED4G.js.map +0 -1
  286. package/dist/document-class-JQ7ZZJAT.js +0 -29
  287. package/dist/navigation-RO3T4FDQ.js +0 -14
@@ -0,0 +1,156 @@
1
+ import { getTwilightContext } from '../../twilight/context';
2
+ import { useTranslation } from '../../providers/I18nProvider';
3
+ import type { Store, StoreSocial } from '../../types';
4
+
5
+ const THUMB_URL = 'https://cdn.assets.salla.network/prod/stores/images/construction-01.png';
6
+
7
+ /** Social networks the page links to, in the old page's order, with their Salla icon class. */
8
+ const SOCIAL_ICONS: [keyof StoreSocial, string][] = [
9
+ ['twitter', 'sicon-x'],
10
+ ['snapchat', 'sicon-snapchat'],
11
+ ['youtube', 'sicon-youtube'],
12
+ ['tiktok', 'sicon-tiktok'],
13
+ ['facebook', 'sicon-facebook'],
14
+ ['instagram', 'sicon-instagram'],
15
+ ];
16
+
17
+ // The platform's maintenance page (Store `pages/maintenance.blade.php` + `_maintenance.scss`),
18
+ // trimmed to what it renders: greyscale, logo + title beside the message, contacts under a
19
+ // rule, the illustration alongside; stacked and centred under 1024px.
20
+ const STYLE = `
21
+ .s-maintenance{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;min-height:100vh;color:#a3a3a3;background:#fff;filter:grayscale(100%);box-sizing:border-box}
22
+ .s-maintenance *{box-sizing:border-box}
23
+ .s-maintenance .mt-container{width:100%;max-width:1200px;padding:0 15px}
24
+ .s-maintenance .mt-panel{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%}
25
+ .s-maintenance .mt-message{width:100%;padding-inline-start:80px;animation:revealMtBlock 1.5s forwards}
26
+ .s-maintenance .mt-title{display:flex;align-items:center;margin:0 0 20px}
27
+ .s-maintenance .mt-logo{display:block;flex-shrink:0;width:80px;height:80px;margin-inline-end:20px;border-radius:50%;overflow:hidden;box-shadow:0 0 5px rgb(0 0 0 / 10%)}
28
+ .s-maintenance .mt-logo img{display:block;width:100%;height:100%;object-fit:cover}
29
+ .s-maintenance .mt-title h1{font-size:2.25rem;line-height:1;margin:0;color:#666}
30
+ .s-maintenance .mt-content p{margin:0;white-space:pre-line}
31
+ .s-maintenance .mt-contact-list{display:inline-block;list-style:none;width:100%;max-width:500px;margin:20px 0 0;padding:20px 0 0;border-top:1px solid #eee}
32
+ .s-maintenance .mt-contact-list li{display:inline-block;margin-inline-end:10px}
33
+ .s-maintenance .mt-contact-list a{display:inline-flex;align-items:center;padding:5px;color:rgb(102 102 102 / 80%);text-decoration:none;font-size:1.25rem}
34
+ .s-maintenance .mt-contact-list a:hover{color:#666}
35
+ .s-maintenance .mt-contact--btn{padding:3px 20px 5px;border-radius:20px;color:#fff!important;background:rgb(102 102 102 / 80%);font-size:1rem!important}
36
+ .s-maintenance .mt-contact--btn:hover{background:#666}
37
+ .s-maintenance .mt-contact--btn i{margin-inline-end:10px}
38
+ .s-maintenance .thumb{width:100%;animation:revealMtBlock 1.5s .1s forwards;opacity:0}
39
+ .s-maintenance .thumb img{display:block;width:100%;max-width:450px;margin:0 auto}
40
+ @media (max-width:1024px){
41
+ .s-maintenance{padding:40px 0 10px}
42
+ .s-maintenance .mt-panel{flex-direction:column}
43
+ .s-maintenance .mt-message{order:2;text-align:center;padding:0;margin:50px 0 0}
44
+ .s-maintenance .mt-title{flex-direction:column;margin-bottom:30px}
45
+ .s-maintenance .mt-logo{margin:0 0 10px}
46
+ .s-maintenance .mt-title h1{font-size:1.5rem}
47
+ }
48
+ @media (max-width:640px){.s-maintenance .thumb img{width:80%}}
49
+ @keyframes revealMtBlock{from{opacity:0;transform:translateY(50%)}to{opacity:1;transform:translateY(0)}}
50
+ `;
51
+
52
+ /** The phone button and social links under the message; nothing when the store lists none. */
53
+ function Contacts({ store, arabic }: { store: Store | undefined; arabic: boolean }) {
54
+ const { t } = useTranslation();
55
+ const mobile = store?.contacts?.mobile;
56
+ const socials = SOCIAL_ICONS.flatMap(([key, icon]) => {
57
+ const href = store?.social?.[key];
58
+ return href ? [{ key, icon, href }] : [];
59
+ });
60
+ if (!mobile && socials.length === 0) return null;
61
+
62
+ return (
63
+ <ul className="mt-contact-list">
64
+ {mobile && (
65
+ <li>
66
+ <a href={`tel:${mobile}`} className="mt-contact--btn">
67
+ <i className="sicon-phone" aria-hidden="true" />
68
+ {t('common.elements.contact_us', {
69
+ defaultValue: arabic ? 'تواصل معنا' : 'Contact us',
70
+ })}
71
+ </a>
72
+ </li>
73
+ )}
74
+ {socials.map(({ key, icon, href }) => (
75
+ <li key={key}>
76
+ <a href={href} target="_blank" rel="noreferrer" aria-label={key}>
77
+ <i className={icon} aria-hidden="true" />
78
+ </a>
79
+ </li>
80
+ ))}
81
+ </ul>
82
+ );
83
+ }
84
+
85
+ /**
86
+ * The page a customer sees while the store is closed: the platform's maintenance page,
87
+ * fed by the settings' `maintenance_details` (the merchant's title and message) and the
88
+ * store's contacts. Rendered by `TwilightProvider` in place of the layout; see
89
+ * `rootBeforeLoad` for who sees it.
90
+ */
91
+ export function MaintenancePage() {
92
+ const { settings, locale } = getTwilightContext();
93
+ const { t } = useTranslation();
94
+ const store = settings.store;
95
+ const details = settings.maintenance_details;
96
+ const arabic = locale.startsWith('ar');
97
+
98
+ const title =
99
+ details?.title ||
100
+ t('pages.maintenance.title', {
101
+ defaultValue: arabic ? 'المتجر قيد الصيانة' : 'Store under maintenance',
102
+ });
103
+
104
+ return (
105
+ <div className="s-maintenance" data-testid="store-maintenance-page">
106
+ <style>{STYLE}</style>
107
+ <div className="mt-container">
108
+ <section className="mt-panel">
109
+ <div className="mt-message">
110
+ <div className="mt-title">
111
+ {store?.logo && (
112
+ <span className="mt-logo">
113
+ <img
114
+ src={store.logo}
115
+ alt={
116
+ store.name ||
117
+ t('common.elements.store_logo', {
118
+ defaultValue: arabic ? 'شعار المتجر' : 'Store logo',
119
+ })
120
+ }
121
+ />
122
+ </span>
123
+ )}
124
+ <h1>{title}</h1>
125
+ </div>
126
+ <div className="mt-content">
127
+ {details?.message ? (
128
+ // The merchant's own wording: a plain string the dashboard caps at 200 characters.
129
+ <p>{details.message}</p>
130
+ ) : (
131
+ <>
132
+ <p>
133
+ {t('pages.maintenance.message', {
134
+ defaultValue: arabic
135
+ ? 'عذرا عزيزي العميل، المتجر حاليا قيد الصيانة و سنعاود العمل خلال فترة وجيزة'
136
+ : 'Sorry, the store is under maintenance and will be back shortly.',
137
+ })}
138
+ </p>
139
+ <p>
140
+ {t('pages.maintenance.thanks', {
141
+ defaultValue: arabic ? 'شكرا لتفهمكم' : 'Thank you for your understanding.',
142
+ })}
143
+ </p>
144
+ </>
145
+ )}
146
+ </div>
147
+ <Contacts store={store} arabic={arabic} />
148
+ </div>
149
+ <div className="thumb">
150
+ <img src={THUMB_URL} alt="" />
151
+ </div>
152
+ </section>
153
+ </div>
154
+ </div>
155
+ );
156
+ }
@@ -4,5 +4,8 @@ export {
4
4
  type StoreClosedNotificationProps,
5
5
  } from './StoreClosedNotification';
6
6
 
7
+ // The page customers see while the store is in maintenance (TwilightProvider renders it).
8
+ export { MaintenancePage } from './MaintenancePage';
9
+
7
10
  // Lazy component
8
- export { LazyStoreClosedNotification } from './lazy';
11
+ export { LazyStoreClosedNotification, LazyMaintenancePage } from './lazy';
@@ -6,3 +6,8 @@ export const LazyStoreClosedNotification = lazy(() =>
6
6
  default: m.StoreClosedNotification,
7
7
  }))
8
8
  );
9
+
10
+ /** Lazy-loaded MaintenancePage: off the shell chunk, since almost no visit renders it. */
11
+ export const LazyMaintenancePage = lazy(() =>
12
+ import('./MaintenancePage').then((m) => ({ default: m.MaintenancePage }))
13
+ );
@@ -31,6 +31,12 @@ import {
31
31
  import { syncSdkLocale, syncSdkThemeVersion } from '../../utils/sdk-helpers';
32
32
  import { SettingsError } from '../../utils/errors';
33
33
  import { resolveStoreBaseRedirect } from '../../utils/store-identity';
34
+ import {
35
+ ownerCookieMatches,
36
+ ownerLinkMatches,
37
+ showsMaintenancePage,
38
+ VIEW_AS_OWNER_COOKIE_NAME,
39
+ } from '../../utils/maintenance';
34
40
 
35
41
  // Reads the `token` cookie from the incoming request on the SERVER. twilightMiddleware
36
42
  // extracts the same cookie into a custom ALS, but that ALS does NOT propagate to the
@@ -128,6 +134,48 @@ export const persistRequestScope = createIsomorphicFn()
128
134
  })
129
135
  .client((): void => {});
130
136
 
137
+ /** The request's cookie header: the framework's on the server, the document's in the browser. */
138
+ const requestCookies = createIsomorphicFn()
139
+ .server((): string | null => {
140
+ try {
141
+ return getRequestHeader('cookie') ?? null;
142
+ } catch {
143
+ return null;
144
+ }
145
+ })
146
+ .client((): string | null => (typeof document !== 'undefined' ? document.cookie : null));
147
+
148
+ /** Remembers the owner view for the rest of this browser session; see {@link VIEW_AS_OWNER_COOKIE_NAME}. */
149
+ const rememberOwnerView = createIsomorphicFn()
150
+ .server((storeId: string): void => {
151
+ try {
152
+ setCookie(VIEW_AS_OWNER_COOKIE_NAME, storeId, { path: '/', sameSite: 'lax' });
153
+ } catch {
154
+ // Outside a request (prerender): there is no response to write to.
155
+ }
156
+ })
157
+ .client((storeId: string): void => {
158
+ document.cookie = `${VIEW_AS_OWNER_COOKIE_NAME}=${storeId}; path=/; SameSite=Lax`;
159
+ });
160
+
161
+ /**
162
+ * Whether this visitor sees the maintenance page instead of the store, deciding and
163
+ * remembering the merchant's owner view on the way.
164
+ *
165
+ * Twig's backend lets the merchant into their closed store when the dashboard's link
166
+ * brings them (`?utm_source=dashboard&identifier=<store id>`), and keeps that in the
167
+ * session. Here the link grants a session cookie, and the cookie or the link is the
168
+ * owner view. A customer gets the maintenance page, and `twilightMiddleware` turns the
169
+ * render into a 503 (see `withMaintenanceStatus`).
170
+ */
171
+ export function resolveMaintenance(href: string, settings: StoreContext): boolean {
172
+ const fromLink = ownerLinkMatches(href, settings);
173
+ const storeId = settings.store?.id;
174
+ if (fromLink && storeId != null) rememberOwnerView(String(storeId));
175
+ const viewAsOwner = fromLink || ownerCookieMatches(requestCookies(), settings);
176
+ return showsMaintenancePage(settings, viewAsOwner);
177
+ }
178
+
131
179
  /** On the server, once the settings are in: {@link alignRequestScopeType}, then {@link persistRequestScope}. */
132
180
  function settleRequestScope(queryClient: QueryClient, settings: StoreContext): void {
133
181
  if (typeof window !== 'undefined') return;
@@ -146,6 +194,8 @@ export interface BeforeLoadResult {
146
194
  /** Per-app public `app.*` buckets, threaded the same way so rootHead can install the
147
195
  * `Salla.appScope` factory inline in the SSR head. */
148
196
  appsSettings?: AppSettings;
197
+ /** This visitor sees the maintenance page, not the store; see {@link resolveMaintenance}. */
198
+ maintenance: boolean;
149
199
  }
150
200
 
151
201
  /**
@@ -279,6 +329,8 @@ export async function rootBeforeLoad(ctx: {
279
329
  throw redirect({ href: storeBaseHref, reloadDocument: true, replace: true });
280
330
  }
281
331
 
332
+ const maintenance = resolveMaintenance(ctx.location.href, settingsResult);
333
+
282
334
  // The merchant's own wording, laid over the platform's — but only when the
283
335
  // settings say this language has any.
284
336
  //
@@ -341,6 +393,7 @@ export async function rootBeforeLoad(ctx: {
341
393
  authToken,
342
394
  appsSnippets: snippetsResult,
343
395
  appsSettings: appSettingsResult,
396
+ maintenance,
344
397
  });
345
398
 
346
399
  return {
@@ -350,5 +403,6 @@ export async function rootBeforeLoad(ctx: {
350
403
  authToken,
351
404
  appsSnippets: snippetsResult,
352
405
  appsSettings: appSettingsResult,
406
+ maintenance,
353
407
  };
354
408
  }
@@ -219,6 +219,8 @@ interface RootHeadParts {
219
219
  isCustomCssUrl?: boolean;
220
220
  isCustomJsUrl?: boolean;
221
221
  twilightSdkUrl: string;
222
+ /** The visitor gets the maintenance page, which loads no SDK and no app snippets. */
223
+ maintenance: boolean;
222
224
  snippetPreconnects: Array<{ rel: 'preconnect'; href: string }>;
223
225
  appScopeInstallScript: string;
224
226
  themeHookSlotsScript: string | null;
@@ -268,6 +270,7 @@ function deriveHeadParts(settings?: StoreContext): RootHeadParts {
268
270
  ...deriveFontParts(settings?.theme),
269
271
  ...deriveCustomizationParts(settings?.theme),
270
272
  twilightSdkUrl: resolveTwilightSdkUrl(settings),
273
+ maintenance: getTwilightContext().maintenance,
271
274
  // Warm the connection to the snippet host(s) during head parse, so the body's deferred
272
275
  // `<script src>` snippet tags fetch off an already-open socket instead of DNS+TCP+TLS.
273
276
  snippetPreconnects: snippetPreconnectOrigins(getTwilightContext().appsSnippets).map((href) => ({
@@ -313,7 +316,8 @@ function buildRootLinks(p: RootHeadParts): NonNullable<HeadDescriptor['links']>
313
316
  { rel: 'preconnect', href: 'https://cdn.salla.sa' },
314
317
  { rel: 'preconnect', href: 'https://cdn.assets.salla.network', crossOrigin: 'anonymous' },
315
318
  // Warm the installed apps' CDN snippet host(s) — see snippetPreconnectOrigins.
316
- ...p.snippetPreconnects,
319
+ // Not on the maintenance page: it renders neither the snippets nor the SDK.
320
+ ...(p.maintenance ? [] : p.snippetPreconnects),
317
321
  ...(p.isGoogleFont
318
322
  ? [
319
323
  {
@@ -323,7 +327,7 @@ function buildRootLinks(p: RootHeadParts): NonNullable<HeadDescriptor['links']>
323
327
  },
324
328
  ]
325
329
  : []),
326
- { rel: 'modulepreload', href: p.twilightSdkUrl },
330
+ ...(p.maintenance ? [] : [{ rel: 'modulepreload' as const, href: p.twilightSdkUrl }]),
327
331
  ...(p.fontUrlWithDisplay
328
332
  ? [
329
333
  {
@@ -1,22 +0,0 @@
1
- export { Header } from './chunk-IYD3EN22.js';
2
- import './chunk-GT2L5IJ4.js';
3
- import './chunk-OUW6WESU.js';
4
- import './chunk-7YH3A5BT.js';
5
- import './chunk-ZMCFSOYF.js';
6
- import './chunk-5XDPAKF5.js';
7
- import './chunk-GCPEMNSU.js';
8
- import './chunk-ZPX4LBQZ.js';
9
- import './chunk-TYNZ5B2B.js';
10
- import './chunk-44FMRCHW.js';
11
- import './chunk-AXW67SY7.js';
12
- import './chunk-BYMOPN2S.js';
13
- import './chunk-SKLEJJ6M.js';
14
- import './chunk-VPGOT3JO.js';
15
- import './chunk-VEWF3NFM.js';
16
- import './chunk-GNLCPK6N.js';
17
- import './chunk-H3PJJKAQ.js';
18
- import './chunk-T72DAX7R.js';
19
- import './chunk-DF6FBKDN.js';
20
- import './chunk-DGUM43GV.js';
21
- //# sourceMappingURL=Header-CXJ3TFHO.js.map
22
- //# sourceMappingURL=Header-CXJ3TFHO.js.map
@@ -1,54 +0,0 @@
1
- export { StoreClosedNotification } from './chunk-RPVHCIR4.js';
2
- import './chunk-UIXEKYTM.js';
3
- import './chunk-IYD3EN22.js';
4
- import './chunk-7RL4DG54.js';
5
- import './chunk-JZDJO2CK.js';
6
- import './chunk-P4XV656A.js';
7
- import './chunk-GLWSJZJZ.js';
8
- import './chunk-OXMUPNMH.js';
9
- import './chunk-PENQTLAN.js';
10
- import './chunk-VVZNW5CB.js';
11
- import './chunk-HIAHDZI5.js';
12
- import './chunk-GD26FI4J.js';
13
- import './chunk-4SZZPXM2.js';
14
- import './chunk-GT2L5IJ4.js';
15
- import './chunk-OUW6WESU.js';
16
- import './chunk-6YWW5Y22.js';
17
- import './chunk-HI5V5X3S.js';
18
- import './chunk-PXHFHHTW.js';
19
- import './chunk-XMO7HDZZ.js';
20
- import './chunk-MVT5AF2A.js';
21
- import './chunk-Z653O7MX.js';
22
- import './chunk-ZCH7W7DZ.js';
23
- import './chunk-JUUKZRE5.js';
24
- import './chunk-JWXJPJBO.js';
25
- import './chunk-CW625T2E.js';
26
- import './chunk-7V36I5GT.js';
27
- import './chunk-6WI7R2BD.js';
28
- import './chunk-OOCN4RFV.js';
29
- import './chunk-OAMIDZKW.js';
30
- import './chunk-7YH3A5BT.js';
31
- import './chunk-V2ZDTY6H.js';
32
- import './chunk-ZMCFSOYF.js';
33
- import './chunk-5XDPAKF5.js';
34
- import './chunk-GCPEMNSU.js';
35
- import './chunk-ZPX4LBQZ.js';
36
- import './chunk-TYNZ5B2B.js';
37
- import './chunk-44FMRCHW.js';
38
- import './chunk-AXW67SY7.js';
39
- import './chunk-BYMOPN2S.js';
40
- import './chunk-SKLEJJ6M.js';
41
- import './chunk-6BZ5TKEV.js';
42
- import './chunk-FZKRSGLP.js';
43
- import './chunk-7V5HOZW4.js';
44
- import './chunk-YA6ABQB7.js';
45
- import './chunk-46JZXQRS.js';
46
- import './chunk-VPGOT3JO.js';
47
- import './chunk-VEWF3NFM.js';
48
- import './chunk-GNLCPK6N.js';
49
- import './chunk-H3PJJKAQ.js';
50
- import './chunk-T72DAX7R.js';
51
- import './chunk-DF6FBKDN.js';
52
- import './chunk-DGUM43GV.js';
53
- //# sourceMappingURL=StoreClosedNotification-2CIG5LX6.js.map
54
- //# sourceMappingURL=StoreClosedNotification-2CIG5LX6.js.map
@@ -1,14 +0,0 @@
1
- import { lazy } from 'react';
2
-
3
- // src/components/cart/lazy.ts
4
- var LazyCartItem = lazy(() => import('./CartItem-KO34MYXT.js').then((m) => ({ default: m.CartItem })));
5
- var LazyCartSummary = lazy(
6
- () => import('./CartSummary-NPFAJI7C.js').then((m) => ({ default: m.CartSummary }))
7
- );
8
- var LazySeoCartWidget = lazy(
9
- () => import('./SeoCartWidget-DWJT2WXI.js').then((m) => ({ default: m.SeoCartWidget }))
10
- );
11
-
12
- export { LazyCartItem, LazyCartSummary, LazySeoCartWidget };
13
- //# sourceMappingURL=chunk-CXONF653.js.map
14
- //# sourceMappingURL=chunk-CXONF653.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/providers/NavigationProvider.ts"],"names":[],"mappings":";;;;;;;;AA6BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,WAAA,CACS,IAAA,EACA,OAAA,GAAU,KAAA,EACjB;AACA,IAAA,KAAA,CAAM,CAAA,YAAA,EAAe,IAAI,CAAA,CAAE,CAAA;AAHpB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EACd;AACF;AAGO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,YAAY,OAAA,EAAkB;AAC5B,IAAA,KAAA,CAAM,WAAW,WAAW,CAAA;AAC5B,IAAA,IAAA,CAAK,IAAA,GAAO,eAA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AAAA,QAC3B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AACA,MAAA,IAAI,cAAA,EAAgB;AAClB,QAAA,IAAI;AACF,UAAA,MAAA,CAAO,SAAS,OAAA,GAAU,WAAA;AAAA,QAC5B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AAClB","file":"chunk-GT2L5IJ4.js","sourcesContent":["import {\n createElement,\n createContext,\n useContext,\n useCallback,\n useRef,\n useEffect,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { useTwilight } from './twilight-context';\nimport { getTwilightContext, subscribeTwilight, type TwilightLocation } from '../twilight/context';\nimport { RouteId } from '../router/route-ids';\nimport { withoutStoreUrlBase } from '../utils/store-base';\nimport { extractScopeFromUrl } from '../utils/cookies';\nimport { getActiveScope } from '../api/client';\nimport { openNativeBrowser } from '../native-app';\n\n// Re-export RouteId from centralized location\nexport { RouteId } from '../router/route-ids';\nexport type { RouteIdType } from '../router/route-ids';\n\n// Re-export TwilightLocation as Location for convenience\nexport type { TwilightLocation as Location } from '../twilight/context';\n\nexport type NavigateOptions = { replace?: boolean };\nexport type NavigateFn = (to: string, opts?: NavigateOptions) => void;\n\n/** Redirect error - thrown to trigger a redirect */\nexport class RedirectError extends Error {\n constructor(\n public path: string,\n public replace = false\n ) {\n super(`Redirect to ${path}`);\n this.name = 'RedirectError';\n }\n}\n\n/** NotFound error - thrown to trigger 404 */\nexport class NotFoundError extends Error {\n constructor(message?: string) {\n super(message ?? 'Not Found');\n this.name = 'NotFoundError';\n }\n}\n\n/** Unauthorized error - thrown to trigger 401 */\nexport class UnauthorizedError extends Error {\n constructor(message?: string) {\n super(message ?? 'Unauthorized');\n this.name = 'UnauthorizedError';\n }\n}\n\nexport { SettingsError } from '../utils/errors';\n\nexport const defaultNavigate: NavigateFn = (to, opts) => {\n if (opts?.replace) window.location.replace(to);\n else window.location.href = to;\n};\n\nexport interface RedirectOptions {\n replace?: boolean;\n /** HTTP status of a server redirect, e.g. 301 for a URL that moved for good. Defaults to 307. */\n statusCode?: number;\n}\n\n/** Default redirect - throws RedirectError with browser navigation as fallback */\nexport const defaultRedirect = (path: string, opts?: RedirectOptions): never => {\n const replace = opts?.replace ?? false;\n\n // In browser, perform actual navigation before throwing\n if (typeof window !== 'undefined') {\n if (replace) window.location.replace(path);\n else window.location.href = path;\n }\n\n throw new RedirectError(path, replace);\n};\n\n/** Default notFound - throws generic error */\nexport const defaultNotFound = (message?: string): never => {\n throw new NotFoundError(message);\n};\n\n/** Default unauthorized - throws generic error */\nexport const defaultUnauthorized = (message?: string): never => {\n throw new UnauthorizedError(message);\n};\n\n// ─── Framework-agnostic functions for loaders (outside React context) ──────\n\ninterface NavigationHandlers {\n notFound: (message?: string) => never;\n redirect: (path: string, opts?: RedirectOptions) => never;\n unauthorized: (message?: string) => never;\n}\n\n// One set per isolate, so a loader in another copy of this module (a separate\n// package entry, a dev reload) still throws what the framework adapter configured.\nconst HANDLERS_KEY = Symbol.for('salla.twilight.navigation.handlers');\nconst registry = globalThis as { [HANDLERS_KEY]?: NavigationHandlers };\nconst handlers: NavigationHandlers = (registry[HANDLERS_KEY] ??= {\n notFound: defaultNotFound,\n redirect: defaultRedirect,\n unauthorized: defaultUnauthorized,\n});\n\n/**\n * Throw a notFound error. Use in route loaders.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * // In loader\n * import { notFound } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!data) throw notFound();\n * ```\n */\nexport function notFound(message?: string): never {\n return handlers.notFound(message);\n}\n\n/**\n * Throw an unauthorized error. Use in route loaders to protect authenticated routes.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * import { unauthorized } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!user) throw unauthorized();\n * ```\n */\nexport function unauthorized(message?: string): never {\n return handlers.unauthorized(message);\n}\n\n/**\n * Throw a redirect. Use in route loaders.\n * Framework adapters will override this to throw framework-specific redirects.\n *\n * @param path - Path to redirect to\n * @param opts - Redirect options\n *\n * @example\n * ```ts\n * // In loader\n * import { redirect } from '@salla.sa/twilight-theme-engine/providers';\n *\n * throw redirect('/ar/cart');\n * ```\n */\nexport function redirect(path: string, opts?: RedirectOptions): never {\n return handlers.redirect(path, opts);\n}\n\n/**\n * Configure navigation functions for a specific framework.\n * Called by framework adapters during setup.\n */\nexport function configureNavigation(config: {\n notFound?: (message?: string) => never;\n redirect?: (path: string, opts?: RedirectOptions) => never;\n unauthorized?: (_message?: string) => never;\n}): void {\n if (config.notFound) handlers.notFound = config.notFound;\n if (config.redirect) handlers.redirect = config.redirect;\n if (config.unauthorized) handlers.unauthorized = config.unauthorized;\n}\n\n// ─── Loader Error Handling Helpers ─────────────────────────────────────────────\n\n/**\n * Wraps an API promise with error handling for route loaders.\n * On a 404/410 response throws notFound(); other errors propagate.\n *\n * @example\n * ```ts\n * findOrThrow: (id, locale) => orThrow(product.find(id, locale)),\n * const data = await product.findOrThrow(id, locale);\n * ```\n */\nexport async function orThrow<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n console.debug('[loader error]', error);\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n // The API answers a missing resource with 410, sometimes 404.\n if (status === 404 || status === 410) return notFound();\n throw error;\n }\n}\n\n/**\n * Wraps an API promise with error handling for authenticated route loaders.\n * On a 401/403 response throws unauthorized(); other errors propagate.\n *\n * @example\n * ```ts\n * const data = await orUnauthorized(order.find(id, locale));\n * ```\n */\nexport async function orUnauthorized<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n if (status === 401 || status === 403) {\n throw unauthorized();\n }\n throw error;\n }\n}\n\n// ─── Navigation Context ──────────────────────────────────────────────────────\n\ninterface NavigationContextValue {\n navigate: NavigateFn;\n}\n\nconst NavigationContext = createContext<NavigationContextValue>({\n navigate: defaultNavigate,\n});\n\nexport function NavigationProvider({\n navigate,\n children,\n}: {\n navigate: NavigateFn;\n children: ReactNode;\n}) {\n return createElement(NavigationContext.Provider, { value: { navigate } }, children);\n}\n\n// ─── Primary Hooks (High Compatibility) ───────────────────────────────────────\n\n/**\n * Get the navigate function.\n * Matches React Router, TanStack Router, and Remix naming convention.\n *\n * @returns Navigate function\n *\n * @example\n * ```tsx\n * const navigate = useNavigate();\n * navigate('/cart');\n * navigate('/cart', { replace: true });\n * ```\n */\nexport function useNavigate(): NavigateFn {\n return useContext(NavigationContext).navigate;\n}\n\n/**\n * Get the current route ID.\n * Used for route detection (isHome, isProduct, etc.)\n *\n * @returns Current route ID string\n *\n * @example\n * ```tsx\n * const routeId = useRouteId();\n * if (routeId === RouteId.INDEX) { ... }\n * ```\n */\nexport function useRouteId(): string {\n return useSyncExternalStore(\n subscribeTwilight,\n () => getTwilightContext().routeId,\n () => getTwilightContext().routeId\n );\n}\n\n/**\n * Get the current location (TanStack Router compatible).\n * Reads from the router context for SSR compatibility.\n *\n * @returns Location object matching TanStack's ParsedLocation\n *\n * @example\n * ```tsx\n * const location = useLocation();\n * console.log(location.pathname); // '/ar/products'\n * console.log(location.searchStr); // '?q=shoes&page=2'\n * console.log(location.search); // { q: 'shoes', page: '2' }\n * console.log(location.href); // 'https://store.com/ar/products?q=shoes'\n * console.log(location.hash); // '#section-1'\n * console.log(location.state); // { scrollY: 100 }\n * ```\n */\nexport function useLocation<TSearch = Record<string, unknown>>(): TwilightLocation<TSearch> {\n useTwilight();\n return getTwilightContext().location as TwilightLocation<TSearch>;\n}\n\n// ─── Selector Hooks ───────────────────────────────────────────────────────────\n\n/**\n * Check if current page is homepage */\nexport function useIsHome(): boolean {\n return useRouteId() === RouteId.INDEX;\n}\n\n/** Check if current page is product detail */\nexport function useIsProduct(): boolean {\n return useRouteId() === RouteId.PRODUCT_SINGLE;\n}\n\n/** Check if current page is cart */\nexport function useIsCart(): boolean {\n return useRouteId() === RouteId.CART;\n}\n\n/** Check if current page is in customer area */\nexport function useIsCustomer(): boolean {\n return useRouteId().startsWith('customer');\n}\n\n/** Check if current page is blog related */\nexport function useIsBlog(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BLOG_INDEX || routeId === RouteId.BLOG_SINGLE;\n}\n\n/** Check if current page is brands related */\nexport function useIsBrands(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BRANDS_INDEX || routeId === RouteId.BRANDS_SINGLE;\n}\n\n/** Check if current page is search */\nexport function useIsSearch(): boolean {\n return useRouteId() === RouteId.SEARCH;\n}\n\n// ─── Navigation Interceptor ──────────────────────────────────────────────────\n\n/**\n * NavigationInterceptor - Framework-agnostic SPA navigation interceptor.\n *\n * Uses navigate function from NavigationProvider context and store URL\n * from TwilightProvider to intercept same-origin navigations.\n */\nexport function NavigationInterceptor(): null {\n const navigate = useNavigate();\n const { store } = useTwilight();\n useNavigationInterceptor(navigate, store?.url, store?.username);\n return null;\n}\n\n/**\n * resolveRelativePath - Resolve href to store-relative path\n *\n * Returns `null` when the URL is not on the same origin as the store,\n * keeping this helper safe against open-redirect misuse.\n *\n * The path is the application's, not the address on Salla's host: a store served\n * under its username there (`https://demostore.salla.sa/ar/dev-…/`) hands out links\n * carrying that segment, and it is removed. On a host where the store is the root\n * of every URL, the router adds its own segment back when it navigates.\n *\n * @param href - The URL to resolve\n * @param storeUrl - The store's base URL\n * @param username - The store's username, which tells that segment apart from a\n * locale spelled the same way (see `withoutStoreUrlBase`)\n * @returns The relative path string, or null if the URL is external\n */\nexport function resolveRelativePath(\n href: string,\n storeUrl: string,\n username?: string | null\n): string | null {\n try {\n const target = new URL(href, window.location.href);\n const base = new URL(storeUrl);\n\n if (target.origin !== base.origin) return null;\n\n const pathname = withoutStoreUrlBase(target.pathname, base.pathname, username);\n const path = pathname + target.search + target.hash;\n return path || '/';\n } catch {\n return null;\n }\n}\n\n/**\n * EXTERNAL_TARGETS - Target attribute values that indicate external navigation\n */\nconst EXTERNAL_TARGETS = new Set(['_blank', '_parent', '_top']);\n\n/**\n * shouldIntercept - Determine if an anchor click should be intercepted by SPA router\n *\n * Follows browser conventions: modifier keys, external targets, downloads,\n * and non-HTTP(S) protocols are left to the browser's default behavior.\n *\n * @param anchor - The anchor element that was clicked\n * @param event - The click event\n * @returns true if the click should be intercepted by the router\n */\nexport function shouldIntercept(anchor: HTMLAnchorElement, event: MouseEvent): boolean {\n if (event.defaultPrevented) return false;\n\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return false;\n\n const targetAttr = anchor.getAttribute('target');\n if (targetAttr && EXTERNAL_TARGETS.has(targetAttr)) return false;\n\n if (anchor.hasAttribute('download')) return false;\n\n const rel = (anchor.getAttribute('rel') ?? '').split(/\\s+/);\n if (rel.includes('external')) return false;\n\n const href = anchor.getAttribute('href') ?? '';\n if (!href) return false;\n\n try {\n const url = new URL(href, window.location.href);\n if (url.protocol.startsWith('javascript:')) return false;\n } catch {\n return false;\n }\n\n return true;\n}\n\n/**\n * Whether `href` switches market: its `?scope=` names another scope than the active one,\n * or the same scope with another branch (`allocation_type` / `allocation_id`).\n *\n * Twig switches market with a full load (the SDK's scopes modal calls\n * `location.replace('?scope=<id>')`), and only a document request lets the server render\n * the new market and record it in the `scope` cookie. Left to the browser, not the router.\n */\nexport function switchesScope(href: string): boolean {\n let url: URL;\n try {\n url = new URL(href, window.location.href);\n } catch {\n return false;\n }\n const requested = extractScopeFromUrl(url.href);\n if (!requested) return false;\n const active = getActiveScope();\n if (requested.id !== active?.id) return true;\n return (\n requested.allocation_id != null &&\n (requested.allocation_id !== active.allocation_id ||\n requested.allocation_type !== active.allocation_type)\n );\n}\n\n/**\n * Whether an untouched tap on `anchor` would load a page off the store: an\n * http(s) link to neither this page's origin nor the store's. `mailto:`, `tel:`\n * and the like are the device's to handle, and are left alone.\n */\nexport function leavesStore(\n anchor: HTMLAnchorElement,\n event: MouseEvent,\n storeUrl: string | undefined\n): boolean {\n if (event.defaultPrevented || anchor.hasAttribute('download')) return false;\n let url: URL;\n try {\n url = new URL(anchor.getAttribute('href') ?? '', window.location.href);\n } catch {\n return false;\n }\n if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;\n if (url.origin === window.location.origin) return false;\n try {\n return !storeUrl || url.origin !== new URL(storeUrl).origin;\n } catch {\n return true;\n }\n}\n\nfunction isSamePage(href: string): boolean {\n const url = new URL(href, window.location.href);\n return url.pathname === window.location.pathname && url.search === window.location.search;\n}\n\nfunction closeEnclosingModal(path: EventTarget[]): void {\n const modal = path.find(\n (el): el is HTMLElement & { close?: () => unknown } =>\n el instanceof HTMLElement && el.localName === 'salla-modal'\n );\n void modal?.close?.();\n}\n\n// ─── Navigation Interceptor Hook (framework-agnostic) ─────────────────────────\n\n/**\n * Hook for navigation interception using framework-agnostic navigate function.\n * Framework adapters call this with their navigate implementation.\n */\nexport function useNavigationInterceptor(\n navigate: NavigateFn,\n storeUrl: string | undefined,\n username?: string\n): void {\n const storeUrlRef = useRef<string | undefined>(storeUrl);\n const usernameRef = useRef<string | undefined>(username);\n\n useEffect(() => {\n storeUrlRef.current = storeUrl;\n usernameRef.current = username;\n }, [storeUrl, username]);\n\n const tryNavigate = useCallback(\n (href: string, replace = false): boolean => {\n const currentStoreUrl = storeUrlRef.current;\n if (!currentStoreUrl || switchesScope(href)) return false;\n\n const relativePath = resolveRelativePath(href, currentStoreUrl, usernameRef.current);\n if (!relativePath) return false;\n\n navigate(relativePath, { replace });\n return true;\n },\n [navigate]\n );\n\n useEffect(() => {\n // ── Pointer movement tracking ────────────────────────────────────────────\n // Detect drag/scroll gestures to avoid intercepting clicks from swipes.\n let pointerStartX = 0;\n let pointerStartY = 0;\n let pointerSwiped = false;\n const MOVE_THRESHOLD = 10;\n\n function handlePointerDown(event: PointerEvent): void {\n pointerStartX = event.clientX;\n pointerStartY = event.clientY;\n pointerSwiped = false;\n }\n\n function handlePointerUp(event: PointerEvent): void {\n const dx = Math.abs(event.clientX - pointerStartX);\n const dy = Math.abs(event.clientY - pointerStartY);\n pointerSwiped = dx > MOVE_THRESHOLD || dy > MOVE_THRESHOLD;\n }\n\n // ── Anchor click interception ────────────────────────────────────────────\n function handleClick(event: MouseEvent): void {\n // Ignore clicks that resulted from swipe/drag gestures.\n if (pointerSwiped) {\n pointerSwiped = false;\n return;\n }\n\n const path = event.composedPath();\n const anchor = path.find((el): el is HTMLAnchorElement => el instanceof HTMLAnchorElement);\n\n // Inside the Salla app, a link that leaves the store opens in the device's\n // browser; loaded in the app's webview it would strand the shopper there.\n if (\n anchor &&\n leavesStore(anchor, event, storeUrlRef.current) &&\n openNativeBrowser(anchor.href)\n ) {\n event.preventDefault();\n return;\n }\n\n if (!anchor || !shouldIntercept(anchor, event)) return;\n\n const samePage = isSamePage(anchor.href);\n if (tryNavigate(anchor.href, false)) {\n event.preventDefault();\n // A page load would close a web component's modal; an in-app navigation leaves it open.\n if (!samePage) closeEnclosingModal(path);\n }\n }\n\n // ── window.location.assign patch ─────────────────────────────────────────\n const origAssign = window.location.assign;\n function patchedAssign(url: string): void {\n if (!tryNavigate(url, false)) origAssign.call(window.location, url);\n }\n\n // ── window.location.replace patch ────────────────────────────────────────\n const origReplace = window.location.replace;\n function patchedReplace(url: string): void {\n if (!tryNavigate(url, true)) origReplace.call(window.location, url);\n }\n\n let assignPatched = false;\n let replacePatched = false;\n try {\n window.location.assign = patchedAssign;\n assignPatched = true;\n } catch {\n /* non-writable in this environment */\n }\n try {\n window.location.replace = patchedReplace;\n replacePatched = true;\n } catch {\n /* non-writable in this environment */\n }\n\n document.addEventListener('click', handleClick, { capture: true });\n document.addEventListener('pointerdown', handlePointerDown, { passive: true });\n document.addEventListener('pointerup', handlePointerUp, { passive: true });\n\n return () => {\n document.removeEventListener('click', handleClick, { capture: true });\n document.removeEventListener('pointerdown', handlePointerDown);\n document.removeEventListener('pointerup', handlePointerUp);\n if (assignPatched) {\n try {\n window.location.assign = origAssign;\n } catch {\n /* ignore */\n }\n }\n if (replacePatched) {\n try {\n window.location.replace = origReplace;\n } catch {\n /* ignore */\n }\n }\n };\n }, [tryNavigate]);\n}\n\n// ─── Client navigation config ─────────────────────────────────────────────────\n\nexport interface ClientNav {\n /** Framework adapter to use for client-side navigation. @default 'tanstack' */\n framework?: 'tanstack' | 'nextjs';\n /**\n * Intercept same-origin `<a>` clicks and `window.location` calls from web\n * components and route them through the framework router.\n * @default true\n */\n interceptLinks?: boolean;\n}\n\n// Framework adapter setups are registered in navigation-setups.ts to avoid circular imports.\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api/translations-key.ts","../src/api/messages.ts","../src/utils/errors.ts","../src/providers/i18n-factory.ts","../src/twilight/context.ts"],"names":[],"mappings":";;;;;;AAwBO,SAAS,qBAAqB,MAAA,EAAkC;AACrE,EAAA,OAAO,CAAC,gBAAgB,MAAM,CAAA;AAChC;AAkBO,SAAS,yBAAA,CACd,SACA,MAAA,EAC0B;AAC1B,EAAA,OAAO,CAAC,cAAA,EAAgB,MAAA,CAAO,OAAO,GAAG,MAAM,CAAA;AACjD;;;ACrBO,SAAS,cAAc,KAAA,EAAmC;AAC/D,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAgBO,SAAS,aAAA,CAAc,MAAgB,SAAA,EAA+B;AAC3E,EAAA,MAAM,MAAA,GAAmB,EAAE,GAAG,IAAA,EAAK;AAEnC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACpD,IAAA,MAAM,QAAA,GAAW,OAAO,GAAG,CAAA;AAC3B,IAAA,MAAA,CAAO,GAAG,CAAA,GACR,aAAA,CAAc,QAAQ,CAAA,IAAK,aAAA,CAAc,KAAK,CAAA,GAAI,aAAA,CAAc,QAAA,EAAU,KAAK,CAAA,GAAI,KAAA;AAAA,EACvF;AAEA,EAAA,OAA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AAK,MAAA;AAAA,IACd;AAAA,GACF;AACF","file":"chunk-H3PJJKAQ.js","sourcesContent":["/**\n * @fileoverview The translations query key, on its own, importing nothing.\n *\n * Three places read the cached translations — `rootBeforeLoad`, the hydration\n * path in `tanstack/router.tsx`, and the lazy `i18n` accessor in\n * `twilight/context.ts` — and all three have to agree on the key or the\n * hydrated page misses the entry it was just handed and refetches. One\n * definition is the only way to keep that true.\n *\n * It lives here rather than in `api/translations.ts`, where it would naturally\n * sit, because **`twilight/context.ts` cannot afford that module's imports**.\n * `api/translations` pulls in `api/client`, which pulls in `ky`; `context.ts`\n * is imported directly by tests that mock `ky`, and adding that edge made six\n * of them stop being mocked and start issuing real requests to `api.salla.dev`\n * (`tests/routes/rootBeforeLoad.test.ts`, bisected to exactly this import). A\n * leaf module with no imports of its own cannot do that to anyone.\n */\n\n/**\n * @param locale is part of the key because each file on the CDN holds one\n * language. The global file this replaced carried every language and was\n * sliced after the cache, so a key without the locale was correct then and is\n * a wrong-language bug now: `/ar` → `/en` would reuse the Arabic entry.\n */\nexport function translationsQueryKey(locale: string): [string, string] {\n return ['translations', locale];\n}\n\n/**\n * The merchant's own wording for one store and one language.\n *\n * Separate from {@link translationsQueryKey} rather than folded into it,\n * because the two files have different lifetimes and different audiences: the\n * platform's copy is the same object for every store on the CDN, and this one\n * is a single merchant's overrides. Keeping them apart means a store with no\n * overrides never invalidates, refetches or dehydrates anything on its account.\n *\n * @param storeId is `settings.store.id` — the Optimus-encoded numeric id, which\n * is what names the object. It is safe in a key even though the locale-only key\n * deliberately avoids naming a store: that warning is about a store *resolved\n * from the request*, which differs between server and client. This one is read\n * out of the settings payload, so both sides compute it from the same\n * dehydrated data and agree.\n */\nexport function storeTranslationsQueryKey(\n storeId: string | number,\n locale: string\n): [string, string, string] {\n return ['translations', String(storeId), locale];\n}\n","/**\n * @fileoverview Composing one language's messages out of the query cache.\n *\n * **There are three places that build an i18n instance**, and they have to\n * agree on more than the key: `rootBeforeLoad`, the hydration path in\n * `tanstack/router.tsx`, and the lazy `i18n` accessor in `twilight/context.ts`.\n * When the platform's copy was the only source, agreeing on\n * `translationsQueryKey` was enough. It is not any more — a merchant's own\n * wording is a second cache entry, and a reader that knows about one and not\n * the other renders different text from the page beside it.\n *\n * That is exactly what shipped in #366: the server rendered the merchant's\n * words and hydration replaced them with the platform's, because only\n * `rootBeforeLoad` had been taught to merge. Greptile caught it. This module is\n * the single answer to \"what are the messages for this locale\", so the next\n * source cannot be added to one reader and forgotten in two.\n *\n * It lives beside `translations-key.ts` and imports nothing at runtime for the\n * same reason that file does: `twilight/context.ts` cannot afford\n * `api/translations`, which pulls in `api/client` and therefore `ky`, and tests\n * that mock `ky` stop being mocked the moment that edge exists.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport { translationsQueryKey } from './translations-key';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\nexport type Messages = Record<string, unknown>;\n\nexport function isPlainObject(value: unknown): value is Messages {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * `overrides` laid over `base`, one leaf at a time.\n *\n * Recursive rather than a spread, because both files are nested by group\n * (`common.errors.500`) and a top-level spread would make a merchant who\n * overrode one string inside `common` lose every other string in it. The\n * merchant's value wins at the leaf, and a group they never touched is left\n * exactly as the platform sent it.\n *\n * A type conflict — one side an object where the other is a string — resolves\n * to the merchant's value. It is the more specific of the two and there is no\n * sensible way to merge a string into a group; the alternative, keeping the\n * platform's, would mean a merchant's edit silently doing nothing.\n */\nexport function mergeMessages(base: Messages, overrides: Messages): Messages {\n const merged: Messages = { ...base };\n\n for (const [key, value] of Object.entries(overrides)) {\n const existing = merged[key];\n merged[key] =\n isPlainObject(existing) && isPlainObject(value) ? mergeMessages(existing, value) : value;\n }\n\n return merged;\n}\n\n/**\n * This store's overrides for `locale`, if any were fetched into the cache.\n *\n * Found by **shape** rather than by asking the settings for a store id, and\n * that is deliberate: the two readers that were missing the merge have a\n * `queryClient` and a locale between them and nothing else, and reaching for\n * `api/store` from `twilight/context.ts` would drag `ky` in through the back\n * door. One document serves one store — a request naming a different one is\n * redirected with `reloadDocument` — so at most one such entry per locale\n * exists, and matching `['translations', <anything>, <locale>]` cannot pick up\n * somebody else's.\n */\nfunction cachedOverrides(queryClient: QueryClient, locale: string): Messages | undefined {\n const entries = queryClient.getQueriesData<Messages>({ queryKey: ['translations'] });\n\n for (const [key, data] of entries) {\n if (key.length === 3 && key[2] === locale && isPlainObject(data)) {\n return data;\n }\n }\n\n return undefined;\n}\n\n/**\n * The messages for `locale`: the platform's copy with this merchant's over it.\n *\n * Reads only — whoever wants the merchant's file in the cache has to have put\n * it there, which `rootBeforeLoad` does and only when the settings say there is\n * one. A reader that runs without it simply gets the platform's copy, which is\n * the same thing it got before any of this existed.\n */\nexport function messagesForLocale(\n queryClient: QueryClient | undefined,\n locale: string\n): TranslationMessages | undefined {\n const common = queryClient?.getQueryData<TranslationMessages>(translationsQueryKey(locale));\n const overrides = queryClient ? cachedOverrides(queryClient, locale) : undefined;\n\n return composeMessages(common, overrides, locale);\n}\n\n/**\n * The same composition from values rather than from the cache.\n *\n * `rootBeforeLoad` has both in hand already — it just awaited them — so it\n * composes directly instead of reading back what it put in.\n */\nexport function composeMessages(\n common: TranslationMessages | null | undefined,\n overrides: Messages | null | undefined,\n locale: string\n): TranslationMessages | undefined {\n if (!overrides || Object.keys(overrides).length === 0) return common ?? undefined;\n\n const base = common?.[`${locale}.trans`];\n\n return {\n [`${locale}.trans`]: mergeMessages(isPlainObject(base) ? base : {}, overrides) as Record<\n string,\n string\n >,\n };\n}\n","export class SettingsError extends Error {\n constructor(message?: string) {\n super(message ?? 'Store settings could not be loaded.');\n this.name = 'SettingsError';\n }\n}\n","import { createInstance, type i18n as I18nInstance } from 'i18next';\nimport { initReactI18next } from 'react-i18next';\n\nexport type TranslationMessages = Record<string, Record<string, string>>;\n\n/**\n * Creates a new i18next instance for the given locale.\n *\n * @param locale - Active locale code, e.g. `'ar'`\n * @param translations - App translations from the Salla API (store-specific)\n * @param themeTranslations - Bundled theme translations (static defaults)\n */\nexport function createI18nInstance(\n locale: string,\n translations?: TranslationMessages,\n themeTranslations?: TranslationMessages\n): I18nInstance {\n const instance = createInstance();\n const transKey = `${locale}.trans`;\n\n instance.use(initReactI18next).init({\n lng: locale,\n fallbackLng: locale,\n ns: ['app', 'theme'],\n defaultNS: 'app',\n fallbackNS: 'theme',\n resources: {\n [locale]: {\n app: translations?.[transKey] ?? {},\n theme: themeTranslations?.[transKey] ?? {},\n },\n },\n interpolation: { escapeValue: false },\n react: { useSuspense: false },\n keySeparator: '.',\n nsSeparator: false,\n });\n\n return instance;\n}\n\n/**\n * Creates i18n instance for testing\n * @param locale - Locale code (default: 'ar')\n * @param translations - Optional translations\n */\nexport function createTestI18n(locale = 'ar', translations?: TranslationMessages): I18nInstance {\n return createI18nInstance(locale, translations);\n}\n","import type { QueryClient } from '@tanstack/react-query';\nimport type { i18n } from 'i18next';\nimport type { StoreContext } from '../api/store';\nimport type { AppSnippet, AppSettings } from '../api/apps';\nimport { FALLBACK_LOCALE, getLanguageInfo } from '../providers/locale-constants';\nimport { createI18nInstance } from '../providers/i18n-factory';\nimport { messagesForLocale } from '../api/messages';\nimport { SettingsError } from '../utils/errors';\nimport type { ActiveScope } from '../utils/cookies';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface TwilightLocation<TSearch = Record<string, unknown>> {\n href: string;\n pathname: string;\n search: TSearch;\n searchStr: string;\n state: Record<string, unknown>;\n hash: string;\n}\n\nexport interface PageContext {\n slug: string;\n id?: string | number;\n title: string;\n url?: string;\n parent?: { id: string | number; name: string; url: string } | null;\n breadcrumbs?: { name: string; url: string }[];\n}\n\nexport interface TwilightContext {\n queryClient: QueryClient;\n settings: StoreContext;\n locale: string;\n routeId: string;\n location: TwilightLocation;\n authToken: string | null;\n /**\n * The selected market and, once bullet delivery confirmed one, its branch\n * allocation — the full object the SDK sends as `s-scope-*` headers. Seeded from\n * the `scope` cookie on the server; see {@link ActiveScope}.\n */\n scope: ActiveScope | null;\n /** `scope.id`, kept for callers that only need the market. */\n scopeId: string | null;\n /**\n * Which store this request is for, when something other than the hostname says\n * so — the `?storeId=` a preview was opened with, or the cookie remembering it.\n *\n * Null on a live storefront, where the hostname is the answer and there is\n * nothing to carry. See {@link resolveRequestStoreId}.\n */\n storeId: string | null;\n /**\n * Which store the first segment of this request's path named, on a host where\n * the store is the root of every URL: `mtgr-alaatr-2` for\n * `https://preview.salla.design/mtgr-alaatr-2/cart`.\n *\n * Null whenever something else named the store, and on every merchant domain.\n * See {@link resolveRequestStoreBase}.\n */\n storeBase: string | null;\n /**\n * Where {@link storeBase} sits in this request's paths: behind the locale on a\n * Salla shared host (`/ar/dev-x/cart`, named by the dispatcher), in front of it\n * everywhere else. See {@link resolveAddressedStore}.\n */\n storeBaseFollowsLocale: boolean;\n /**\n * Which version of the theme's settings this request asked for — the\n * `?versionId=` an editor preview or a local dev session was opened with, or\n * the cookie remembering it.\n *\n * Null on an ordinary storefront visit, which is the common case: nothing\n * named a version, so the store's live one is what the API answers with. See\n * {@link resolveRequestVersionId}.\n */\n versionId: string | null;\n /**\n * The host this request arrived on, captured server-side.\n *\n * A theme worker is deployed with no vars and no bindings, so the request is\n * the only thing that knows which storefront it is serving. On the client this\n * is `window.location.host`; on the server nothing else has it.\n */\n requestHost: string | null;\n i18n: i18n;\n dir: 'ltr' | 'rtl';\n page?: PageContext;\n /** Installed apps' snippets, fetched in rootBeforeLoad so AppsSnippets can render CDN\n * <script> tags during SSR (React Query isn't dehydrated here, so useQuery has no SSR data). */\n appsSnippets?: AppSnippet[];\n /** Per-app public `app.*` buckets, fetched in rootBeforeLoad so rootHead can install the\n * `Salla.appScope` factory inline at parse time — ahead of the snippets' onReady callbacks. */\n appsSettings?: AppSettings;\n extras?: Record<string, unknown>;\n}\n\n// ============================================================================\n// Internal Store\n// ============================================================================\n\nconst DEFAULT_LOCATION: TwilightLocation = {\n href: '',\n pathname: '',\n search: {},\n searchStr: '',\n state: {},\n hash: '',\n};\n\ninterface ContextData {\n queryClient: QueryClient;\n settings: StoreContext | null;\n locale: string;\n routeId: string;\n location: TwilightLocation;\n authToken: string | null;\n scope: ActiveScope | null;\n storeId: string | null;\n storeBase: string | null;\n storeBaseFollowsLocale: boolean;\n versionId: string | null;\n requestHost: string | null;\n i18n?: i18n;\n page?: PageContext;\n appsSnippets?: AppSnippet[];\n appsSettings?: AppSettings;\n extras?: Record<string, unknown>;\n}\n\nconst DEFAULT_DATA: ContextData = {\n queryClient: null as unknown as QueryClient,\n settings: null,\n locale: FALLBACK_LOCALE,\n routeId: '',\n location: { ...DEFAULT_LOCATION },\n authToken: null,\n scope: null,\n storeId: null,\n storeBase: null,\n storeBaseFollowsLocale: false,\n versionId: null,\n requestHost: null,\n i18n: undefined,\n page: undefined,\n};\n\n// ============================================================================\n// Storage: AsyncLocalStorage (server) or module-level store (client)\n// ============================================================================\n\ntype AsyncLocalStore<T> = { getStore(): T | undefined; run(val: T, fn: () => unknown): unknown };\n\n// Initialize ALS at module load time for SSR — no race condition\ntype AsyncHooks = { AsyncLocalStorage: new <T>() => AsyncLocalStore<T> };\n\n// workerd has no global `require`, so a bundled `require()` throws there; it does have\n// `process.getBuiltinModule` (so does Node >= 20.16), which keeps this out of the browser bundle.\nfunction loadAsyncHooks(): AsyncHooks | null {\n const proc = (globalThis as { process?: { getBuiltinModule?: (id: string) => unknown } }).process;\n try {\n const builtin = proc?.getBuiltinModule?.('node:async_hooks') as AsyncHooks | undefined;\n if (builtin?.AsyncLocalStorage) return builtin;\n } catch {\n /* fall through to require */\n }\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require('node:async_hooks') as AsyncHooks;\n } catch {\n return null;\n }\n}\n\nconst isServer = typeof window === 'undefined';\n// One instance per isolate, so a re-evaluated or duplicated copy of this module (dev\n// reloads, src next to dist) reads the scope the request middleware opened.\nconst ALS_KEY = Symbol.for('salla.twilight.context.als');\nlet _als: AsyncLocalStore<ContextData> | null = null;\nif (isServer) {\n const registry = globalThis as { [ALS_KEY]?: AsyncLocalStore<ContextData> };\n const hooks = registry[ALS_KEY] ? null : loadAsyncHooks();\n if (hooks) registry[ALS_KEY] = new hooks.AsyncLocalStorage<ContextData>();\n _als = registry[ALS_KEY] ?? null;\n}\n\n// Without request isolation every request would share `clientStore`: one visitor's\n// auth token and store settings rendered into another's page.\nfunction assertRequestIsolation(): void {\n if (isServer && !_als) {\n throw new Error(\n '[Twilight] AsyncLocalStorage is unavailable; refusing to share request state.'\n );\n }\n}\n\n// The browser's store, shared by every copy of this module on the page like the ALS above,\n// so a loader in one copy reads the location and token the router wrote through another.\nconst CLIENT_KEY = Symbol.for('salla.twilight.context.client');\nconst clientRegistry = globalThis as {\n [CLIENT_KEY]?: { store: ContextData; listeners: Set<() => void> };\n};\nconst clientShared = (clientRegistry[CLIENT_KEY] ??= {\n store: { ...DEFAULT_DATA },\n listeners: new Set<() => void>(),\n});\nconst clientStore: ContextData = clientShared.store;\n\nfunction getTwilightStore(): ContextData {\n assertRequestIsolation();\n if (_als) {\n const store = _als.getStore();\n if (!store)\n throw new Error('[Twilight] No request context. Wrap with runWithTwilightContext().');\n return store;\n }\n return clientStore;\n}\n\nfunction writableStore(): ContextData {\n if (_als) {\n const store = _als.getStore();\n if (store) return store;\n }\n return clientStore;\n}\n\nfunction mergeIntoStore(store: ContextData, partial: Partial<TwilightContext>): void {\n if ('queryClient' in partial && partial.queryClient) store.queryClient = partial.queryClient;\n if ('settings' in partial && partial.settings != null) store.settings = partial.settings;\n if ('locale' in partial && partial.locale != null) store.locale = partial.locale;\n if ('routeId' in partial && partial.routeId != null) store.routeId = partial.routeId;\n if ('location' in partial && partial.location != null)\n store.location = { ...store.location, ...partial.location };\n if ('authToken' in partial && partial.authToken !== undefined)\n store.authToken = partial.authToken ?? null;\n if ('scope' in partial && partial.scope !== undefined) store.scope = partial.scope ?? null;\n else if ('scopeId' in partial && partial.scopeId !== undefined)\n store.scope = partial.scopeId == null ? null : { id: partial.scopeId };\n if ('storeId' in partial && partial.storeId !== undefined)\n store.storeId = partial.storeId ?? null;\n if ('storeBase' in partial && partial.storeBase !== undefined)\n store.storeBase = partial.storeBase ?? null;\n if ('storeBaseFollowsLocale' in partial && partial.storeBaseFollowsLocale !== undefined)\n store.storeBaseFollowsLocale = partial.storeBaseFollowsLocale === true;\n if ('versionId' in partial && partial.versionId !== undefined)\n store.versionId = partial.versionId ?? null;\n if ('requestHost' in partial && partial.requestHost !== undefined)\n store.requestHost = partial.requestHost ?? null;\n if ('i18n' in partial && partial.i18n != null) store.i18n = partial.i18n;\n if ('page' in partial) store.page = partial.page;\n if ('appsSnippets' in partial) store.appsSnippets = partial.appsSnippets;\n if ('appsSettings' in partial) store.appsSettings = partial.appsSettings;\n if ('extras' in partial) store.extras = partial.extras;\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport function runWithTwilightContext<T>(partial: Partial<TwilightContext>, fn: () => T): T {\n assertRequestIsolation();\n if (_als) {\n const data: ContextData = { ...DEFAULT_DATA };\n mergeIntoStore(data, partial);\n return _als.run(data, fn) as T;\n }\n mergeIntoStore(clientStore, partial);\n return fn();\n}\n\n// Client-only subscription so React consumers (useRouteId/useIsHome/…) re-render\n// when navigation mutates the module store. Mirrors hooks/useWishlist.ts.\nconst listeners = clientShared.listeners;\n\nexport function subscribeTwilight(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function updateTwilightContext(partial: Partial<TwilightContext>): void {\n mergeIntoStore(getTwilightStore(), partial);\n // Server uses AsyncLocalStorage and has no React subscribers; notify on client only.\n if (typeof window !== 'undefined') {\n for (const listener of listeners) listener();\n }\n}\n\n/**\n * Whether store settings are available, without throwing.\n *\n * `getTwilightContext().settings` throws a `SettingsError` when the store is\n * empty, which is fatal inside a head function during hydration. Callers that\n * need to *test* availability must use this instead of a try/catch around the\n * getter. Returns false when there is no request context at all (server-side\n * calls outside `runWithTwilightContext`).\n */\nexport function hasTwilightSettings(): boolean {\n try {\n return getTwilightStore().settings != null;\n } catch {\n return false;\n }\n}\n\n/** What a request addressed, as opposed to what it is. */\nexport interface RequestAddressing {\n storeId: string | null;\n storeBase: string | null;\n storeBaseFollowsLocale: boolean;\n versionId: string | null;\n requestHost: string | null;\n}\n\n/**\n * What this request named and the host it arrived on, without throwing.\n *\n * Separate from {@link getTwilightContext} because store identity is read while\n * deciding *what to fetch* — before there is a context worth having — and on the\n * server outside a request the getter throws. A caller asking \"which store?\" has\n * a sane answer for \"none named\"; it has none for an exception.\n *\n * The version rides along rather than getting an accessor of its own: it is read\n * at the same moment, for the same reason, and by the same callers, and a second\n * copy of this try/catch would be a second thing to remember to widen.\n */\nexport function getRequestStore(): RequestAddressing {\n try {\n const data = getTwilightStore();\n return {\n storeId: data.storeId,\n storeBase: data.storeBase,\n storeBaseFollowsLocale: data.storeBaseFollowsLocale,\n versionId: data.versionId,\n requestHost: data.requestHost,\n };\n } catch {\n return {\n storeId: null,\n storeBase: null,\n storeBaseFollowsLocale: false,\n versionId: null,\n requestHost: null,\n };\n }\n}\n\nexport function getTwilightContext(): TwilightContext {\n const data = getTwilightStore();\n return {\n get queryClient() {\n return data.queryClient;\n },\n get settings() {\n if (!data.settings) throw new SettingsError();\n return data.settings;\n },\n get locale() {\n return data.locale;\n },\n get routeId() {\n return data.routeId;\n },\n get location() {\n return data.location;\n },\n get authToken() {\n return data.authToken;\n },\n get scope() {\n return data.scope;\n },\n get scopeId() {\n return data.scope?.id ?? null;\n },\n get storeId() {\n return data.storeId;\n },\n get storeBase() {\n return data.storeBase;\n },\n get storeBaseFollowsLocale() {\n return data.storeBaseFollowsLocale;\n },\n get versionId() {\n return data.versionId;\n },\n get requestHost() {\n return data.requestHost;\n },\n get i18n() {\n if (!data.i18n) {\n // Composed the same way as `rootBeforeLoad` and the hydration path —\n // the platform's copy with this merchant's over it. See\n // `api/messages.ts`: this accessor reading one entry while the others\n // read two is precisely the drift that module exists to stop.\n data.i18n = createI18nInstance(\n data.locale,\n messagesForLocale(data.queryClient, data.locale)\n );\n }\n return data.i18n;\n },\n get dir() {\n return getLanguageInfo(data.locale).dir;\n },\n get page() {\n return data.page;\n },\n get appsSnippets() {\n return data.appsSnippets;\n },\n get appsSettings() {\n return data.appsSettings;\n },\n get extras() {\n return data.extras;\n },\n };\n}\n\n/** @internal Reset store for testing */\nexport function resetForTesting(): void {\n Object.assign(writableStore(), { ...DEFAULT_DATA });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/api/store.ts"],"names":[],"mappings":";;;;;AASA,IAAM,qBAAA,GAAwB;AAAA,EAC5B,OAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA;AA2EA,SAAS,iBAAiB,SAAA,EAA8D;AACtF,EAAA,IAAI,CAAC,WAAW,OAAO,MAAA;AAGvB,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA,CAAE,GAAA,CAAI,CAAC,IAAA,MAAU,EAAE,QAAA,EAAU,IAAA,CAAK,IAAA,EAAM,GAAG,MAAK,CAAE,CAAA;AAClF;AAEO,IAAM,KAAA,GAAQ;AAAA,EACnB,QAAA,EAAU,OAAO,eAAA,KAA2D;AAC1E,IAAA,MAAM,UAAA,GAAa,mBAAmB,sBAAA,EAAuB;AAE7D,IAAA,IAAI,CAAC,UAAA,EAAY;AACf,MAAA,OAAA,CAAQ,KAAK,gDAAgD,CAAA;AAC7D,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,MAAM,aAAA,GAAgB,qBAAA,CAAsB,GAAA,CAAI,CAAC,CAAA,KAAM,aAAa,CAAC,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACjF,IAAA,MAAM,QAAQ,cAAA,EAAe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,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,MACA,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,eAAe;AAAA,KAC9C;AAAA;AAEP","file":"chunk-JDLXT6VI.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope, STORE_IDENTIFIER_HEADER } from './client';\nimport type { Store, Theme, Language, JitsuConfig } from '../types';\nimport { getTwilightContext } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { requestedThemeVersionId } from '../utils/theme-version';\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}\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 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\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n console.warn('[store.settings] No store identifier available');\n return null;\n }\n\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 try {\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: 5000,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n })\n .json<{ data?: SettingsApiResponse }>();\n\n const data = json?.data;\n if (!data) return null;\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: data.jitsu,\n ...(scope && { requestedScopeId: scope.id }),\n };\n } catch (error) {\n console.error('[store.settings] Failed:', error);\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 queryFn: () => store.settings(storeIdentifier),\n }),\n },\n};\n"]}