@salla.sa/twilight-theme-engine 1.0.132 → 1.0.134

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 (272) hide show
  1. package/dist/{AddToCartForm-LUVIZGH5.js → AddToCartForm-D7AQIX7K.js} +3 -3
  2. package/dist/{AddToCartForm-LUVIZGH5.js.map → AddToCartForm-D7AQIX7K.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-UC5JFBRH.js → BlogAuthorPage-P2TVMO5O.js} +29 -29
  4. package/dist/{BlogAuthorPage-UC5JFBRH.js.map → BlogAuthorPage-P2TVMO5O.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-YZ6BN4QV.js → BlogCategoryPage-A2BS6T3I.js} +29 -29
  6. package/dist/{BlogCategoryPage-YZ6BN4QV.js.map → BlogCategoryPage-A2BS6T3I.js.map} +1 -1
  7. package/dist/{BlogPage-ERPCNHQV.js → BlogPage-ZOIVZQ5W.js} +27 -27
  8. package/dist/{BlogPage-ERPCNHQV.js.map → BlogPage-ZOIVZQ5W.js.map} +1 -1
  9. package/dist/{BlogSinglePage-TNVS5VCF.js → BlogSinglePage-X57JXKQ6.js} +27 -27
  10. package/dist/{BlogSinglePage-TNVS5VCF.js.map → BlogSinglePage-X57JXKQ6.js.map} +1 -1
  11. package/dist/{BlogTagPage-DKWJM6GQ.js → BlogTagPage-WXLEEA63.js} +29 -29
  12. package/dist/{BlogTagPage-DKWJM6GQ.js.map → BlogTagPage-WXLEEA63.js.map} +1 -1
  13. package/dist/{BrandsPage-ALLXOEZ7.js → BrandsPage-6ZMEF4EQ.js} +28 -28
  14. package/dist/{BrandsPage-ALLXOEZ7.js.map → BrandsPage-6ZMEF4EQ.js.map} +1 -1
  15. package/dist/{Breadcrumb-2TWWY76F.js → Breadcrumb-FYA3KNAY.js} +27 -27
  16. package/dist/{Breadcrumb-2TWWY76F.js.map → Breadcrumb-FYA3KNAY.js.map} +1 -1
  17. package/dist/{CartItem-XNCZZQ4X.js → CartItem-XGDV4EZ4.js} +27 -27
  18. package/dist/{CartItem-XNCZZQ4X.js.map → CartItem-XGDV4EZ4.js.map} +1 -1
  19. package/dist/{CartSummary-ROELC4AF.js → CartSummary-BP6BJ7BB.js} +27 -27
  20. package/dist/{CartSummary-ROELC4AF.js.map → CartSummary-BP6BJ7BB.js.map} +1 -1
  21. package/dist/{Copyright-UPGI2I5D.js → Copyright-H4CYJQR3.js} +3 -3
  22. package/dist/{Copyright-UPGI2I5D.js.map → Copyright-H4CYJQR3.js.map} +1 -1
  23. package/dist/{CustomerLayout-YXTOHATN.js → CustomerLayout-YLMMDLXA.js} +27 -27
  24. package/dist/{CustomerLayout-YXTOHATN.js.map → CustomerLayout-YLMMDLXA.js.map} +1 -1
  25. package/dist/{Footer-J4V5UUCF.js → Footer-ADZZF3NE.js} +4 -4
  26. package/dist/{Footer-J4V5UUCF.js.map → Footer-ADZZF3NE.js.map} +1 -1
  27. package/dist/Header-OMEW5PF4.js +23 -0
  28. package/dist/{Header-5ENK5VKP.js.map → Header-OMEW5PF4.js.map} +1 -1
  29. package/dist/{LoyaltyPage-J6GSLDVZ.js → LoyaltyPage-EGTJAFY3.js} +27 -27
  30. package/dist/{LoyaltyPage-J6GSLDVZ.js.map → LoyaltyPage-EGTJAFY3.js.map} +1 -1
  31. package/dist/{LoyaltyPointsPage-XP2RCLZA.js → LoyaltyPointsPage-RSPBAI73.js} +9 -9
  32. package/dist/{LoyaltyPointsPage-XP2RCLZA.js.map → LoyaltyPointsPage-RSPBAI73.js.map} +1 -1
  33. package/dist/{MainMenu-RMM6ZJWZ.js → MainMenu-R7RNOTPO.js} +8 -8
  34. package/dist/{MainMenu-RMM6ZJWZ.js.map → MainMenu-R7RNOTPO.js.map} +1 -1
  35. package/dist/MaintenancePage-U5P43D52.js +7 -0
  36. package/dist/{MaintenancePage-A7CNHM7B.js.map → MaintenancePage-U5P43D52.js.map} +1 -1
  37. package/dist/{MasterLayout-BIAXVZNR.js → MasterLayout-LLKACZ7T.js} +27 -27
  38. package/dist/{MasterLayout-BIAXVZNR.js.map → MasterLayout-LLKACZ7T.js.map} +1 -1
  39. package/dist/{MobileMenu-HYKQCDTC.js → MobileMenu-4F4DBTWU.js} +28 -28
  40. package/dist/{MobileMenu-HYKQCDTC.js.map → MobileMenu-4F4DBTWU.js.map} +1 -1
  41. package/dist/{NotificationsPage-Q6EDPEQX.js → NotificationsPage-AWKZRH7H.js} +27 -27
  42. package/dist/{NotificationsPage-Q6EDPEQX.js.map → NotificationsPage-AWKZRH7H.js.map} +1 -1
  43. package/dist/{OrderSinglePage-HGEECI7Q.js → OrderSinglePage-2RTLHMMO.js} +28 -28
  44. package/dist/{OrderSinglePage-HGEECI7Q.js.map → OrderSinglePage-2RTLHMMO.js.map} +1 -1
  45. package/dist/{OrdersPage-CBHLD5XG.js → OrdersPage-57MRSJTB.js} +27 -27
  46. package/dist/{OrdersPage-CBHLD5XG.js.map → OrdersPage-57MRSJTB.js.map} +1 -1
  47. package/dist/{PageSingle-S6IRM4Q5.js → PageSingle-YTXFQHHC.js} +7 -7
  48. package/dist/{PageSingle-S6IRM4Q5.js.map → PageSingle-YTXFQHHC.js.map} +1 -1
  49. package/dist/{ProductDetails-DHY35UDT.js → ProductDetails-6LWZSW7R.js} +8 -8
  50. package/dist/{ProductDetails-DHY35UDT.js.map → ProductDetails-6LWZSW7R.js.map} +1 -1
  51. package/dist/{ProfilePage-3ES62QH7.js → ProfilePage-JKDLNAKB.js} +27 -27
  52. package/dist/{ProfilePage-3ES62QH7.js.map → ProfilePage-JKDLNAKB.js.map} +1 -1
  53. package/dist/{ReviewsPage-RFEOWEVU.js → ReviewsPage-OST5SGH5.js} +3 -3
  54. package/dist/{ReviewsPage-RFEOWEVU.js.map → ReviewsPage-OST5SGH5.js.map} +1 -1
  55. package/dist/{SeoCartWidget-WJCQ76TI.js → SeoCartWidget-7L2B25DP.js} +27 -27
  56. package/dist/{SeoCartWidget-WJCQ76TI.js.map → SeoCartWidget-7L2B25DP.js.map} +1 -1
  57. package/dist/{SettingsPage-BHIVN22T.js → SettingsPage-IFYFZ2SP.js} +27 -27
  58. package/dist/{SettingsPage-BHIVN22T.js.map → SettingsPage-IFYFZ2SP.js.map} +1 -1
  59. package/dist/StoreClosedNotification-COURDUGE.js +58 -0
  60. package/dist/{StoreClosedNotification-IYVXVJJO.js.map → StoreClosedNotification-COURDUGE.js.map} +1 -1
  61. package/dist/{TestimonialsPage-E7IKEHCT.js → TestimonialsPage-2RWGM5OP.js} +7 -7
  62. package/dist/{TestimonialsPage-E7IKEHCT.js.map → TestimonialsPage-2RWGM5OP.js.map} +1 -1
  63. package/dist/{ThankYouPage-DAZOZH6Y.js → ThankYouPage-OJLIJPLR.js} +27 -27
  64. package/dist/{ThankYouPage-DAZOZH6Y.js.map → ThankYouPage-OJLIJPLR.js.map} +1 -1
  65. package/dist/{WalletPage-ZBCGMDSP.js → WalletPage-FBOYCP2F.js} +28 -28
  66. package/dist/{WalletPage-ZBCGMDSP.js.map → WalletPage-FBOYCP2F.js.map} +1 -1
  67. package/dist/{WishlistPage-HAUJQL2G.js → WishlistPage-YWTH5YAO.js} +29 -29
  68. package/dist/{WishlistPage-HAUJQL2G.js.map → WishlistPage-YWTH5YAO.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.d.ts +3 -0
  83. package/dist/api/product.d.ts.map +1 -1
  84. package/dist/api/product.js +7 -7
  85. package/dist/api/profile.js +4 -4
  86. package/dist/api/store.js +6 -6
  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-5NN4OICC.js → chunk-2EF2HHHL.js} +3 -3
  92. package/dist/{chunk-5NN4OICC.js.map → chunk-2EF2HHHL.js.map} +1 -1
  93. package/dist/{chunk-Z4N3WJ6R.js → chunk-2ZJAQBFV.js} +3 -3
  94. package/dist/{chunk-Z4N3WJ6R.js.map → chunk-2ZJAQBFV.js.map} +1 -1
  95. package/dist/{chunk-CGAKEPEC.js → chunk-352YYRKV.js} +3 -3
  96. package/dist/{chunk-CGAKEPEC.js.map → chunk-352YYRKV.js.map} +1 -1
  97. package/dist/{chunk-2TLIULJZ.js → chunk-3E3ABCPC.js} +3 -3
  98. package/dist/{chunk-2TLIULJZ.js.map → chunk-3E3ABCPC.js.map} +1 -1
  99. package/dist/{chunk-7E7CA72E.js → chunk-3OWCF54L.js} +4 -4
  100. package/dist/{chunk-7E7CA72E.js.map → chunk-3OWCF54L.js.map} +1 -1
  101. package/dist/{chunk-D5SYOOE2.js → chunk-4EAYVEJO.js} +4 -4
  102. package/dist/{chunk-D5SYOOE2.js.map → chunk-4EAYVEJO.js.map} +1 -1
  103. package/dist/{chunk-KLSRARPU.js → chunk-5EDFGGY4.js} +4 -4
  104. package/dist/{chunk-KLSRARPU.js.map → chunk-5EDFGGY4.js.map} +1 -1
  105. package/dist/{chunk-F5NB3H5P.js → chunk-5RWIVHYS.js} +6 -6
  106. package/dist/{chunk-F5NB3H5P.js.map → chunk-5RWIVHYS.js.map} +1 -1
  107. package/dist/{chunk-EHTLXK5F.js → chunk-5UWRPWK2.js} +5 -5
  108. package/dist/{chunk-EHTLXK5F.js.map → chunk-5UWRPWK2.js.map} +1 -1
  109. package/dist/{chunk-7VNVCHID.js → chunk-6K34BCUP.js} +2 -2
  110. package/dist/{chunk-7VNVCHID.js.map → chunk-6K34BCUP.js.map} +1 -1
  111. package/dist/{chunk-MPQ5NACW.js → chunk-6PMG5J4Z.js} +4 -4
  112. package/dist/{chunk-MPQ5NACW.js.map → chunk-6PMG5J4Z.js.map} +1 -1
  113. package/dist/{chunk-TTZKDTD5.js → chunk-6S43HHJM.js} +3 -3
  114. package/dist/{chunk-TTZKDTD5.js.map → chunk-6S43HHJM.js.map} +1 -1
  115. package/dist/{chunk-JB5XMO4D.js → chunk-BQ5SELOL.js} +4 -4
  116. package/dist/{chunk-JB5XMO4D.js.map → chunk-BQ5SELOL.js.map} +1 -1
  117. package/dist/{chunk-CKH6WBMA.js → chunk-CZ6VJPCG.js} +3 -3
  118. package/dist/{chunk-CKH6WBMA.js.map → chunk-CZ6VJPCG.js.map} +1 -1
  119. package/dist/{chunk-GLDGDTVU.js → chunk-DGK2HVSR.js} +6 -6
  120. package/dist/{chunk-GLDGDTVU.js.map → chunk-DGK2HVSR.js.map} +1 -1
  121. package/dist/{chunk-GY6G7S3N.js → chunk-DRDQQNIW.js} +29 -8
  122. package/dist/chunk-DRDQQNIW.js.map +1 -0
  123. package/dist/{chunk-PGXRNW3Y.js → chunk-DRX6L472.js} +3 -3
  124. package/dist/{chunk-PGXRNW3Y.js.map → chunk-DRX6L472.js.map} +1 -1
  125. package/dist/{chunk-YZDL2P6T.js → chunk-EISZVMJY.js} +4 -4
  126. package/dist/{chunk-YZDL2P6T.js.map → chunk-EISZVMJY.js.map} +1 -1
  127. package/dist/{chunk-BAS4BPSB.js → chunk-FOBC4W73.js} +3 -3
  128. package/dist/{chunk-BAS4BPSB.js.map → chunk-FOBC4W73.js.map} +1 -1
  129. package/dist/{chunk-FHU2MXZA.js → chunk-FXVII733.js} +18 -8
  130. package/dist/chunk-FXVII733.js.map +1 -0
  131. package/dist/{chunk-HHHDPYMO.js → chunk-HIF6PP7C.js} +4 -4
  132. package/dist/{chunk-HHHDPYMO.js.map → chunk-HIF6PP7C.js.map} +1 -1
  133. package/dist/{chunk-BK5TBUGG.js → chunk-HOJ5E2PG.js} +3 -3
  134. package/dist/{chunk-BK5TBUGG.js.map → chunk-HOJ5E2PG.js.map} +1 -1
  135. package/dist/{chunk-DCPQ4Z7N.js → chunk-IJX2MCPN.js} +4 -4
  136. package/dist/{chunk-DCPQ4Z7N.js.map → chunk-IJX2MCPN.js.map} +1 -1
  137. package/dist/{chunk-5RUFKW7T.js → chunk-IYAXNDJI.js} +4 -4
  138. package/dist/{chunk-5RUFKW7T.js.map → chunk-IYAXNDJI.js.map} +1 -1
  139. package/dist/{chunk-EANN5L2E.js → chunk-JPG5XSTP.js} +8 -8
  140. package/dist/{chunk-EANN5L2E.js.map → chunk-JPG5XSTP.js.map} +1 -1
  141. package/dist/{chunk-YMXOKWNO.js → chunk-KJG4BPY2.js} +4 -4
  142. package/dist/{chunk-YMXOKWNO.js.map → chunk-KJG4BPY2.js.map} +1 -1
  143. package/dist/{chunk-TI3Q2B3H.js → chunk-LA7B3TTK.js} +9 -9
  144. package/dist/{chunk-TI3Q2B3H.js.map → chunk-LA7B3TTK.js.map} +1 -1
  145. package/dist/{chunk-JGVEGQHJ.js → chunk-LFHYQ6AN.js} +3 -3
  146. package/dist/{chunk-JGVEGQHJ.js.map → chunk-LFHYQ6AN.js.map} +1 -1
  147. package/dist/{chunk-BL6DCALA.js → chunk-LVEIDCW2.js} +7 -7
  148. package/dist/{chunk-BL6DCALA.js.map → chunk-LVEIDCW2.js.map} +1 -1
  149. package/dist/{chunk-DROQER6S.js → chunk-M75BIUMZ.js} +3 -3
  150. package/dist/{chunk-DROQER6S.js.map → chunk-M75BIUMZ.js.map} +1 -1
  151. package/dist/{chunk-V2M5YNZQ.js → chunk-MWYKP7CI.js} +3 -3
  152. package/dist/{chunk-V2M5YNZQ.js.map → chunk-MWYKP7CI.js.map} +1 -1
  153. package/dist/{chunk-GYXUYHKO.js → chunk-NHA4SBKG.js} +4 -4
  154. package/dist/{chunk-GYXUYHKO.js.map → chunk-NHA4SBKG.js.map} +1 -1
  155. package/dist/{chunk-CQY64PLJ.js → chunk-NVPG5X2H.js} +4 -4
  156. package/dist/{chunk-CQY64PLJ.js.map → chunk-NVPG5X2H.js.map} +1 -1
  157. package/dist/{chunk-ZVZPCDEU.js → chunk-OO2JMMCL.js} +4 -4
  158. package/dist/{chunk-ZVZPCDEU.js.map → chunk-OO2JMMCL.js.map} +1 -1
  159. package/dist/{chunk-YQELP5ND.js → chunk-PXH5TZGZ.js} +5 -5
  160. package/dist/{chunk-YQELP5ND.js.map → chunk-PXH5TZGZ.js.map} +1 -1
  161. package/dist/{chunk-FID76MUV.js → chunk-Q7E4TNN7.js} +10 -6
  162. package/dist/chunk-Q7E4TNN7.js.map +1 -0
  163. package/dist/{chunk-CHMWAYVU.js → chunk-QC4XQO6D.js} +4 -4
  164. package/dist/{chunk-CHMWAYVU.js.map → chunk-QC4XQO6D.js.map} +1 -1
  165. package/dist/{chunk-TBTQQM45.js → chunk-R7DPH75N.js} +5 -5
  166. package/dist/{chunk-TBTQQM45.js.map → chunk-R7DPH75N.js.map} +1 -1
  167. package/dist/{chunk-EJIMEI36.js → chunk-RFDP66ID.js} +7 -7
  168. package/dist/{chunk-EJIMEI36.js.map → chunk-RFDP66ID.js.map} +1 -1
  169. package/dist/{chunk-OM2GRPDH.js → chunk-RYGEIQWO.js} +3 -3
  170. package/dist/{chunk-OM2GRPDH.js.map → chunk-RYGEIQWO.js.map} +1 -1
  171. package/dist/{chunk-PCEKL6S3.js → chunk-SXI2XBCC.js} +7 -7
  172. package/dist/{chunk-PCEKL6S3.js.map → chunk-SXI2XBCC.js.map} +1 -1
  173. package/dist/{chunk-L4TQBWR7.js → chunk-TF6HFXTW.js} +3 -3
  174. package/dist/{chunk-L4TQBWR7.js.map → chunk-TF6HFXTW.js.map} +1 -1
  175. package/dist/{chunk-E7YBFA3H.js → chunk-TL2RV5KC.js} +5 -5
  176. package/dist/{chunk-E7YBFA3H.js.map → chunk-TL2RV5KC.js.map} +1 -1
  177. package/dist/{chunk-6LMS7IYL.js → chunk-UII3OBWQ.js} +7 -7
  178. package/dist/{chunk-6LMS7IYL.js.map → chunk-UII3OBWQ.js.map} +1 -1
  179. package/dist/{chunk-THQDHZ4K.js → chunk-UJIE7IEJ.js} +4 -4
  180. package/dist/{chunk-THQDHZ4K.js.map → chunk-UJIE7IEJ.js.map} +1 -1
  181. package/dist/{chunk-5FJFN3IW.js → chunk-WQPG22DY.js} +3 -3
  182. package/dist/{chunk-5FJFN3IW.js.map → chunk-WQPG22DY.js.map} +1 -1
  183. package/dist/{chunk-2MUBQOS5.js → chunk-WSPMY4BC.js} +8 -8
  184. package/dist/{chunk-2MUBQOS5.js.map → chunk-WSPMY4BC.js.map} +1 -1
  185. package/dist/{chunk-NXJ4KAJQ.js → chunk-WUDGMLUX.js} +4 -4
  186. package/dist/{chunk-NXJ4KAJQ.js.map → chunk-WUDGMLUX.js.map} +1 -1
  187. package/dist/{chunk-EJV3NYBP.js → chunk-WVQBEAYO.js} +24 -24
  188. package/dist/chunk-WVQBEAYO.js.map +1 -0
  189. package/dist/{chunk-JYV25VNZ.js → chunk-X55R4VVK.js} +3 -3
  190. package/dist/{chunk-JYV25VNZ.js.map → chunk-X55R4VVK.js.map} +1 -1
  191. package/dist/chunk-XRULXQBR.js +14 -0
  192. package/dist/{chunk-DOTKJOVG.js.map → chunk-XRULXQBR.js.map} +1 -1
  193. package/dist/{chunk-RSKVPOMJ.js → chunk-XUJJIH5C.js} +17 -17
  194. package/dist/chunk-XUJJIH5C.js.map +1 -0
  195. package/dist/{chunk-5DOMRYLF.js → chunk-YDXBRST4.js} +7 -7
  196. package/dist/{chunk-5DOMRYLF.js.map → chunk-YDXBRST4.js.map} +1 -1
  197. package/dist/{chunk-TOJM4ZIF.js → chunk-ZKHMZF36.js} +7 -7
  198. package/dist/{chunk-TOJM4ZIF.js.map → chunk-ZKHMZF36.js.map} +1 -1
  199. package/dist/components/cart/index.js +1 -1
  200. package/dist/components/common/index.js +1 -1
  201. package/dist/components/drawer/index.js +25 -25
  202. package/dist/components/home/index.js +29 -29
  203. package/dist/components/layout/index.js +7 -7
  204. package/dist/components/product/index.js +26 -26
  205. package/dist/components/store/index.js +27 -27
  206. package/dist/components/toast/index.js +5 -5
  207. package/dist/dev/editor/index.js +3 -3
  208. package/dist/dev/index.js +3 -3
  209. package/dist/document-class-R26LC5C2.js +31 -0
  210. package/dist/{document-class-G5XELNQN.js.map → document-class-R26LC5C2.js.map} +1 -1
  211. package/dist/hooks/index.js +25 -25
  212. package/dist/hooks/useComments.js +4 -4
  213. package/dist/hooks/useGtm.js +25 -25
  214. package/dist/hooks/useMoney.js +25 -25
  215. package/dist/hooks/useProduct.js +4 -4
  216. package/dist/hooks/useStore.js +25 -25
  217. package/dist/hooks/useUser.js +6 -6
  218. package/dist/hooks/useWishlist.js +4 -4
  219. package/dist/index.js +25 -25
  220. package/dist/native-app/index.js +4 -4
  221. package/dist/{navigation-ZPJHUO4Z.js → navigation-2UNFQOOQ.js} +8 -8
  222. package/dist/{navigation-ZPJHUO4Z.js.map → navigation-2UNFQOOQ.js.map} +1 -1
  223. package/dist/navigation-5ZAI4SPZ.js +15 -0
  224. package/dist/{navigation-S6ZL2WSI.js.map → navigation-5ZAI4SPZ.js.map} +1 -1
  225. package/dist/{not-found-KME662CU.js → not-found-LGTTNZ4Y.js} +28 -28
  226. package/dist/{not-found-KME662CU.js.map → not-found-LGTTNZ4Y.js.map} +1 -1
  227. package/dist/providers/index.js +25 -25
  228. package/dist/providers/twilight-init.d.ts.map +1 -1
  229. package/dist/routes/account/orders.js +9 -9
  230. package/dist/routes/account.js +18 -18
  231. package/dist/routes/blog.js +13 -13
  232. package/dist/routes/brands.js +9 -9
  233. package/dist/routes/cart.js +33 -33
  234. package/dist/routes/home.js +30 -30
  235. package/dist/routes/index.js +7 -7
  236. package/dist/routes/loyalty.js +10 -10
  237. package/dist/routes/page.js +9 -9
  238. package/dist/routes/product-listing.js +31 -31
  239. package/dist/routes/product.js +29 -29
  240. package/dist/routes/root/beforeLoad.d.ts +6 -0
  241. package/dist/routes/root/beforeLoad.d.ts.map +1 -1
  242. package/dist/routes/seo-redirects.js +7 -7
  243. package/dist/routes/testimonials.js +5 -5
  244. package/dist/routes/thank-you.js +9 -9
  245. package/dist/skeleton.js +30 -30
  246. package/dist/{store-lookup-R5KJS7Z3.js → store-lookup-DQECZUBL.js} +12 -12
  247. package/dist/{store-lookup-R5KJS7Z3.js.map → store-lookup-DQECZUBL.js.map} +1 -1
  248. package/dist/tanstack.js +22 -22
  249. package/dist/twilight/context.d.ts +3 -2
  250. package/dist/twilight/context.d.ts.map +1 -1
  251. package/dist/utils/baseHead.js +3 -3
  252. package/dist/utils/cookies.d.ts +15 -1
  253. package/dist/utils/cookies.d.ts.map +1 -1
  254. package/dist/utils/index.js +7 -7
  255. package/dist/utils/maintenance.d.ts +37 -5
  256. package/dist/utils/maintenance.d.ts.map +1 -1
  257. package/dist/utils/store-identity.d.ts +10 -0
  258. package/dist/utils/store-identity.d.ts.map +1 -1
  259. package/dist/vite/index.js +5 -5
  260. package/package.json +1 -1
  261. package/tailwind/routes/root/beforeLoad.ts.txt +8 -1
  262. package/dist/Header-5ENK5VKP.js +0 -23
  263. package/dist/MaintenancePage-A7CNHM7B.js +0 -7
  264. package/dist/StoreClosedNotification-IYVXVJJO.js +0 -58
  265. package/dist/chunk-DOTKJOVG.js +0 -14
  266. package/dist/chunk-EJV3NYBP.js.map +0 -1
  267. package/dist/chunk-FHU2MXZA.js.map +0 -1
  268. package/dist/chunk-FID76MUV.js.map +0 -1
  269. package/dist/chunk-GY6G7S3N.js.map +0 -1
  270. package/dist/chunk-RSKVPOMJ.js.map +0 -1
  271. package/dist/document-class-G5XELNQN.js +0 -31
  272. package/dist/navigation-S6ZL2WSI.js +0 -15
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/apply-theme.ts","../src/providers/twilight-theme.ts","../src/providers/twilight-init.ts","../src/providers/native-safe-area.ts","../src/providers/native-spa-webview.ts","../src/providers/navigation-setups.ts","../src/providers/DocumentSyncRegistry.ts","../src/hooks/useDate.ts","../src/hooks/useNumber.ts","../src/utils/number.ts","../src/hooks/useMoney.tsx","../src/hooks/useGtm.ts","../src/hooks/useOpeningHours.ts","../src/hooks/usePageConfig.ts","../src/utils/breadcrumb.ts","../src/hooks/useBreadcrumbs.ts","../src/utils/fast-checkout.ts","../src/hooks/registerDefaultHooks.tsx","../src/components/layout/MasterLayout.tsx","../src/components/snippets/AppsSnippets.tsx","../src/components/snippets/SallaSdkScripts.tsx","../src/components/store/lazy.ts","../src/components/store/MaintenanceDevBar.tsx","../src/components/live-editor/index.tsx","../src/providers/TwilightProvider.tsx","../src/hooks/useStore.ts"],"names":["color","useEffect","lazy","ARABIC_NUMERALS","useCallback","useMemo","useState","jsx","id","jsxs","Fragment","Suspense","LazyStoreClosedNotification","getSalla","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,aAAa,KAAA,EAAkC;AAC7D,EAAA,MAAM,OAA2B,EAAC;AAElC,EAAA,MAAM,QAAA,GAAW,MAAM,IAAA,EAAM,IAAA;AAC7B,EAAA,IAAI,QAAA,EAAU;AAGZ,IAAA,MAAM,MAAA,GAAS,CAAC,MAAA,GAAS,EAAA,KAAO,IAAA,CAAK,UAAU,CAAA,EAAG,QAAQ,CAAA,EAAG,MAAM,CAAA,CAAE,CAAA;AACrE,IAAA,IAAA,CAAK,IAAA;AAAA,MACH,CAAC,aAAA,EAAe,MAAA,EAAQ,CAAA;AAAA,MACxB,CAAC,cAAA,EAAgB,MAAA,EAAQ,CAAA;AAAA,MACzB,CAAC,gBAAA,EAAkB,MAAA,EAAQ,CAAA;AAAA,MAC3B,CAAC,eAAA,EAAiB,MAAA,CAAO,SAAS,CAAC,CAAA;AAAA,MACnC,CAAC,aAAA,EAAe,MAAA,CAAO,OAAO,CAAC;AAAA,KACjC;AAAA,EACF;AAEA,EAAA,MAAM,EAAE,KAAA,EAAAA,MAAAA,EAAM,GAAI,KAAA;AAClB,EAAA,IAAIA,MAAAA,EAAO;AACT,IAAA,IAAA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AC,UAAU,EAAE,GAAG,MAAM,GAAI,IAAA,CAAK,OAAyB,CAAE,CAAA;AAAA,MACtE;AAAA,IACF,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,SAAS,CAAC,CAAA;AAErB,EAAA,OAAO,EAAE,GAAG,KAAA,EAAO,OAAA,EAAQ;AAC7B","file":"chunk-EJV3NYBP.js","sourcesContent":["import type { Theme } from '../types';\nimport { color as makeColor } from './color';\n\nexport function themeCssVars(theme: Theme): [string, string][] {\n const vars: [string, string][] = [];\n\n const fontName = theme.font?.name;\n if (fontName) {\n // Quoted: an unquoted name such as `Baloo Bhaijaan 2` is not a valid family,\n // which drops the whole `font-family` declaration back to the browser default.\n const family = (suffix = '') => JSON.stringify(`${fontName}${suffix}`);\n vars.push(\n ['--font-main', family()],\n ['--font-light', family()],\n ['--font-regular', family()],\n ['--font-medium', family('-Medium')],\n ['--font-bold', family('-Bold')]\n );\n }\n\n const { color } = theme;\n if (color) {\n vars.push(['--color-text', '#222222']);\n\n if (color.primary) {\n const c = makeColor(color.primary);\n vars.push(\n ['--color-primary', color.primary],\n ['--color-primary-dark', c.darken(0.15)],\n ['--color-primary-light', c.lighten(0.15)],\n ['--color-title', color.primary],\n ['--color-secondary', color.primary]\n );\n }\n\n if (color.reverse_text) {\n vars.push(\n ['--color-primary-reverse', color.reverse_text],\n ['--color-text-reverse', color.reverse_text],\n ['--color-reverse-text', color.reverse_text]\n );\n }\n\n if (color.reverse_primary) {\n vars.push(['--color-reverse-primary', color.reverse_primary]);\n }\n }\n\n vars.push(['--page-height', '100%']);\n return vars;\n}\n\n// What the previous applyTheme set, so a theme without a font or colour (another\n// market's, after a scope change) does not keep the previous one's values.\nlet applied = new Set<string>();\n\nexport function applyTheme(theme: Theme): void {\n if (typeof document === 'undefined') return;\n\n const root = document.documentElement;\n const vars = themeCssVars(theme);\n const next = new Set(vars.map(([prop]) => prop));\n for (const prop of applied) {\n if (!next.has(prop)) root.style.removeProperty(prop);\n }\n for (const [prop, val] of vars) {\n root.style.setProperty(prop, val);\n }\n applied = next;\n}\n","import { createElement, useEffect, type ReactElement } from 'react';\nimport { applyTheme, themeCssVars } from '../utils/apply-theme';\nimport { escapeForInlineScript } from '../utils/inline-script';\nimport { useDocumentClass } from '../hooks/useDocumentClass';\nimport type { Theme } from '../types';\n\nexport function fontToClass(name: string | undefined): string | null {\n if (!name) return null;\n const slug = name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n return slug ? `font-${slug}` : null;\n}\n\nexport function themeBodyClasses(\n theme: Theme,\n direction: 'rtl' | 'ltr',\n isMobileWebview: boolean\n): string[] {\n return [\n theme.name ? `salla-${theme.name}` : null,\n `color-mode-${theme.color?.is_dark ? 'dark' : 'light'}`,\n direction,\n theme.mode === 'preview' ? 'preview-mode' : null,\n fontToClass(theme.font?.name),\n isMobileWebview ? 'mobile-webview' : null,\n theme.settings?.footer_is_dark ? 'footer-is-dark' : 'footer-is-light',\n theme.settings?.topnav_is_dark ? 'topnav-is-dark' : null,\n theme.settings?.sticky_add_to_cart ? 'is-sticky-product-bar' : null,\n ].filter(Boolean) as string[];\n}\n\n/** Applies the theme's variables and body classes as the body starts parsing, ahead of hydration. */\nexport function themeSyncScript(vars: [string, string][], bodyClasses: string[]): string {\n const json = (value: unknown) => escapeForInlineScript(JSON.stringify(value));\n return (\n `(function(d){var s=d.documentElement.style;${json(vars)}.forEach(function(v){s.setProperty(v[0],v[1])});` +\n `d.body.classList.add.apply(d.body.classList,${json(bodyClasses)})})(document);`\n );\n}\n\nexport function ThemeDocumentSync({\n theme,\n locale,\n direction,\n isMobileWebview,\n}: {\n theme: Theme;\n locale: string;\n direction: 'rtl' | 'ltr';\n isMobileWebview: boolean;\n}): ReactElement {\n const bodyClasses = themeBodyClasses(theme, direction, isMobileWebview);\n\n useDocumentClass({\n html: { lang: locale, dir: direction },\n body: { class: bodyClasses },\n });\n\n useEffect(() => {\n applyTheme(theme);\n }, [theme]);\n\n // React 19 renders script children verbatim; themeSyncScript escapes `<`, so the tag can't close early.\n return createElement(\n 'script',\n { id: 'salla-theme-sync', suppressHydrationWarning: true },\n themeSyncScript(themeCssVars(theme), bodyClasses)\n );\n}\n","import {\n type Dispatch,\n type SetStateAction,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport type { SallaCurrency, SallaSDK } from '../types/salla-sdk';\nimport { getActiveCurrency } from '../api/client';\nimport { useDevReportSettingsFetchedAt, useDevSettingsOverrides } from '../dev/dev-settings-store';\nimport { getTwilightContext } from '../twilight/context';\nimport type { Store, Theme } from '../types';\nimport { syncScopeCookie } from '../utils/cookies';\nimport { withOwnerMaintenanceButton } from '../utils/maintenance';\nimport { ENGINE_VERSION } from '../utils/engine-version';\nimport {\n type StoreContext,\n syncSdkLocale,\n whenSallaLoaded,\n withSdkThemeVersion,\n} from '../utils/sdk-helpers';\nimport { getLanguageInfo } from './locale-constants';\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\nfunction getSalla(): SallaSDK | undefined {\n if (typeof window === 'undefined') return undefined;\n return window.salla;\n}\n\n// The SDK's own guest currency default (init-user.js); its cookie.get drops that default.\nconst SDK_GUEST_CURRENCY = 'SAR';\n\n// The SDK starts in `user.language_code` and loads only that language's messages, so it is the\n// page's: `s-lang` and the stored user can name another, and an `/en` page then drew its salla-*\n// components in Arabic, or as raw keys. They answer only when the page names no language.\nfunction userLanguage(sdk: SallaSDK, locale: string, stored?: unknown) {\n return locale || (sdk.cookie?.get?.('s-lang') ?? stored);\n}\n\n// The SDK resolves these itself (init-user.js), but its cookie.get drops the stored fallback.\nfunction withCookieLocale(sdk: SallaSDK, stored: Record<string, unknown>, locale: string) {\n return {\n ...stored,\n language_code: userLanguage(sdk, locale, stored.language_code),\n currency_code: sdk.cookie?.get?.('s-curr') ?? stored.currency_code ?? SDK_GUEST_CURRENCY,\n };\n}\n\n// The API derives currency/country/geo from the SSR worker's IP, so only IP-free guest fields are seeded.\nfunction withSettingsUser(sdk: SallaSDK, settings: StoreContext | undefined, locale: string) {\n if (!settings) return settings;\n const { user: guest, ...rest } = settings;\n const stored = sdk.storage?.get?.('user') as Record<string, unknown> | null | undefined;\n if (stored) return { ...rest, user: withCookieLocale(sdk, stored, locale) };\n const {\n currency_code: _currency,\n country_code: _country,\n default_geo_location: _geo,\n ...visitor\n } = guest ?? { type: 'guest' };\n return {\n ...rest,\n user: {\n ...visitor,\n language_code: userLanguage(sdk, locale, visitor.language_code),\n currency_code: sdk.cookie?.get?.('s-curr') ?? SDK_GUEST_CURRENCY,\n },\n };\n}\n\n// Twig layouts set it; without it the SDK's product cards request `<theme assets>/undefined`.\nconst PLACEHOLDER_IMAGE = 'https://cdn.salla.network/images/placeholder.png';\n\nfunction withPlaceholder<T extends Pick<StoreContext, 'theme'>>(settings: T): T {\n const theme = settings.theme;\n if (!theme || theme.settings?.placeholder) return settings;\n return {\n ...settings,\n theme: { ...theme, settings: { ...theme.settings, placeholder: PLACEHOLDER_IMAGE } },\n };\n}\n\n// Twig's `store_status_alert_widget.maintenance.button_title`, through the theme's translations.\nfunction disableMaintenanceLabel(ctx: ReturnType<typeof getTwilightContext>, locale: string) {\n const defaultValue = locale.startsWith('ar') ? 'تنشيط المتجر' : 'Disable Maintenance';\n return ctx.i18n?.t?.('pages.maintenance.disable_button', { defaultValue }) ?? defaultValue;\n}\n\n// The SDK ignores `window.translations` and reuses only its own cache, else it downloads every locale.\nfunction seedSdkTranslations(sdk: SallaSDK, settings: StoreContext | undefined, locale: string) {\n const localeKey = `${locale}.trans`;\n const messages = window.translations?.[localeKey];\n const hash = settings?.theme?.translations_hash ?? settings?.store?.id;\n if (!messages || !Object.keys(messages).length || !hash) return;\n try {\n const cached = sdk.storage.get(`s_translations.${hash}`) as Record<string, unknown> | null;\n if (cached?.[localeKey]) return;\n sdk.storage.set('s_translations', { [hash]: { [localeKey]: messages } });\n } catch {\n // Storage full, disabled or missing: the SDK downloads its own copy, as before.\n }\n}\n\n// ─── Hook ─────────────────────────────────────────────────────────────────────\n\nexport interface UseTwilightInitOptions {\n debug: boolean;\n initialData?: StoreContext | Record<string, unknown>;\n onReady?: (data: { store: Store; theme: Theme }) => void;\n onError?: (error: Error) => void;\n initialLocale: string;\n}\n\nexport interface UseTwilightInitReturn {\n isReady: boolean;\n storeData: Store;\n setStoreData: Dispatch<SetStateAction<Store>>;\n themeData: Theme;\n currency: SallaCurrency | null;\n isMobileWebview: boolean;\n}\n\n// Each SDK init() mounts another copy of its auto widgets (loyalty banners...), so run it once.\nconst initializedSdks = new WeakSet<object>();\nconst EMPTY_STORE = {} as Store;\n\nexport function useTwilightInit({\n debug: _debug,\n initialData,\n onReady,\n onError: _onError,\n initialLocale,\n}: UseTwilightInitOptions): UseTwilightInitReturn {\n const isBrowser = typeof window !== 'undefined';\n const initialLanguage = getLanguageInfo(initialLocale);\n const settingsData = initialData as StoreContext | undefined;\n\n const [isReady, setReady] = useState<boolean>(() => !!settingsData);\n // Settings answered for another market (a scope switch) carry another store scope\n // and theme version; follow them instead of the first page load's. A theme's\n // `_setStore` patch applies on top of the settings it was written against only.\n const settingsStore = (settingsData?.store as Store | undefined) ?? EMPTY_STORE;\n const [storePatch, setStorePatch] = useState<{ base: Store; patch: Partial<Store> } | null>(null);\n const patch = storePatch?.base === settingsStore ? storePatch.patch : null;\n const storeData = useMemo<Store>(\n () => (patch ? { ...settingsStore, ...patch } : settingsStore),\n [settingsStore, patch]\n );\n const setStoreData = useCallback<Dispatch<SetStateAction<Store>>>(\n (action) =>\n setStorePatch((prev) => {\n const prevPatch = prev?.base === settingsStore ? prev.patch : null;\n return {\n base: settingsStore,\n patch: typeof action === 'function' ? action({ ...settingsStore, ...prevPatch }) : action,\n };\n }),\n [settingsStore]\n );\n const settingsTheme = settingsData?.theme as Partial<Theme> | undefined;\n const baseTheme = useMemo<Theme>(() => {\n if (settingsTheme) {\n return {\n ...settingsTheme,\n is_rtl: settingsTheme.is_rtl ?? initialLanguage.dir === 'rtl',\n } as Theme;\n }\n return { is_rtl: initialLanguage.dir === 'rtl' } as Theme;\n }, [settingsTheme, initialLanguage.dir]);\n\n // Dev-mode only: overlay the settings the DevSettingsWidget has enabled onto\n // the real theme so the storefront renders with them live. `import.meta.env.DEV`\n // is statically false in production builds, so this whole branch (and the\n // overrides hook's effect) is dead-code-eliminated from the shipped bundle.\n const devOverrides = useDevSettingsOverrides();\n // Dev-mode only, like the overrides: tells the theme editor how old the settings are.\n useDevReportSettingsFetchedAt(settingsData?.devFetchedAt);\n const themeData = useMemo<Theme>(() => {\n if (import.meta.env.DEV && devOverrides.enabled) {\n const overrides = devOverrides.settings;\n if (overrides && Object.keys(overrides).length > 0) {\n return {\n ...baseTheme,\n settings: { ...(baseTheme.settings ?? {}), ...overrides } as Theme['settings'],\n };\n }\n }\n return baseTheme;\n }, [baseTheme, devOverrides]);\n const [currency] = useState<SallaCurrency | null>(() => {\n const code = getActiveCurrency();\n const active = code ? settingsData?.currencies?.[code] : undefined;\n return active ? { code: active.code, name: active.name, symbol: active.symbol } : null;\n });\n const [isMobileWebview] = useState<boolean>(false); // todo :: add a flage in the store data for mobile\n\n useEffect(() => {\n if (!isBrowser || !themeData) return;\n const sdk = getSalla();\n sdk?.config?.set?.('theme.is_rtl', themeData.is_rtl ?? false);\n window.enable_more_menu = String(themeData.settings?.enable_more_menu ?? true);\n }, [themeData, isBrowser]);\n\n useEffect(() => {\n // Not `if (!sdk) return`: `window.salla` is the head script's stub until the SDK\n // has loaded, and on a cold load hydration runs this first. Returning then left\n // the storefront with an SDK nobody ever initialised — `salla.status` stuck on\n // 'loading', no store config, no cart. Wait for it instead.\n return whenSallaLoaded((sdk) => {\n // Expose which engine build rendered this storefront (salla.versions.engine)\n // for debugging and support tooling. Merged, not assigned, so other Salla\n // packages can register their own versions on the same object.\n const sdkWithVersions = sdk as SallaSDK & { versions?: Record<string, string> };\n sdkWithVersions.versions = { ...sdkWithVersions.versions, engine: ENGINE_VERSION };\n\n if (initialLocale) {\n // Sync UI translations + the SDK's axios accept-language header to the route locale.\n // The header set may be a no-op now if the SDK isn't fully ready; it's re-asserted\n // after onReady below, and on every navigation in rootBeforeLoad.\n syncSdkLocale(initialLocale);\n }\n\n if (typeof sdk.init !== 'function') return;\n\n const ctx = getTwilightContext();\n const pageCtx = ctx.page;\n const userData = withSettingsUser(sdk, settingsData, initialLocale);\n const baseData =\n userData &&\n withSdkThemeVersion(\n withOwnerMaintenanceButton(\n withPlaceholder(userData),\n disableMaintenanceLabel(ctx, initialLocale)\n )\n );\n const initData = pageCtx\n ? {\n ...baseData,\n page: {\n ...pageCtx,\n url: pageCtx.url ?? ctx.location.pathname + ctx.location.searchStr,\n },\n }\n : baseData;\n\n if (!initializedSdks.has(sdk)) {\n initializedSdks.add(sdk);\n seedSdkTranslations(sdk, settingsData, initialLocale);\n sdk.init(initData);\n }\n\n const initSdk = async () => {\n try {\n await sdk.onReady();\n } catch {\n // sdk.onReady() may fail during partial initialization\n }\n\n // The SDK loads async; the sync above may have run against a not-yet-ready SDK.\n // Now that it's ready, re-assert so the very first SDK API calls use the route locale.\n syncSdkLocale(initialLocale);\n\n // Mirror the selected branch into the `scope` cookie so the NEXT SSR request keys\n // its settings query on the same scope the client does. rootBeforeLoad also calls\n // this, but only from a client-side navigation: on the initial load TanStack\n // restores the root match's __beforeLoadContext instead of re-running beforeLoad,\n // so a visitor who never navigates would otherwise never write the cookie. Here is\n // the earliest point salla.storage is guaranteed populated.\n syncScopeCookie();\n\n setReady(true);\n document.dispatchEvent(new CustomEvent('theme::ready'));\n\n onReady?.({\n store: storeData,\n theme: themeData,\n });\n };\n\n initSdk();\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- Intentional: SDK init runs once per locale change only\n }, [initialLocale]);\n\n return {\n isReady,\n storeData,\n setStoreData,\n themeData,\n currency,\n isMobileWebview,\n };\n}\n","import { useEffect } from 'react';\nimport { isNativeApp } from '../native-app';\nimport { onSallaEvent, whenSallaReady } from '../utils/sdk-helpers';\n\nconst SAFE_AREA_EVENT = 'mobile::ui.safearea';\nconst CSS_VARS = { top: '--app-safe-area-top', bottom: '--app-safe-area-bottom' } as const;\n\n/**\n * Writes the native app's insets (status bar, home indicator) to `--app-safe-area-top` and\n * `--app-safe-area-bottom` on `<html>`, for a theme's CSS to read. The values come from the\n * `mobile::ui.safearea` payload, so a re-emit updates them live. Nothing is registered\n * outside the app (`isNativeApp()`): there the variables stay unset and a\n * consumer falls back to `0px`. The app is recognised once the SDK is ready, not just\n * loaded: one that identifies itself through its config has not said so before `init`.\n *\n * `TwilightProvider` calls this rather than the navigation setup, which loads lazily and\n * would attach later than a theme's own root-level listener did.\n */\nexport function useNativeSafeArea(): void {\n useEffect(() => {\n let off: (() => void) | undefined;\n const cancel = whenSallaReady(() => {\n if (isNativeApp()) off = onSallaEvent(SAFE_AREA_EVENT, applySafeArea);\n });\n return () => {\n cancel();\n off?.();\n };\n }, []);\n}\n\ntype SafeAreaPayload = { value?: unknown; top?: unknown; bottom?: unknown };\n\n/**\n * `{ top, bottom }` in pixels, as numbers or numeric strings (`{\"top\":\"62\",\"bottom\":\"8\"}`);\n * the legacy payload is the top inset alone, as `{ value }`. Also read when the app sends\n * the whole bridge envelope, `{ event, details: { top, bottom } }`.\n */\nfunction applySafeArea(data?: unknown): void {\n const raw = data as (SafeAreaPayload & { details?: SafeAreaPayload }) | undefined;\n const payload = raw?.details && typeof raw.details === 'object' ? raw.details : raw;\n for (const side of ['top', 'bottom'] as const) {\n const px = Number(side === 'top' ? (payload?.top ?? payload?.value) : payload?.bottom);\n if (Number.isFinite(px)) {\n document.documentElement.style.setProperty(CSS_VARS[side], `${px}px`);\n }\n }\n}\n","import { useEffect } from 'react';\nimport { isNativeApp } from '../native-app';\nimport { getSallaSDK, whenSallaReady } from '../utils/sdk-helpers';\n\n/** The SDK's opt-in for an SPA storefront inside the Salla app (`salla.mobile.isSpaWebview()`). */\nconst SPA_WEBVIEW_FLAG = 'theme.is_spa_webview';\n\n/**\n * Inside the Salla app, tells the SDK this storefront is the app's SPA shell\n * (`theme.is_spa_webview`). The SDK and Salla's components keep their native\n * hand-offs behind that flag, so with it set:\n * - `salla.cart.submit()` (every checkout button) opens the app's checkout\n * (`mobile::checkout.open`) instead of loading the checkout page in the webview;\n * - `<salla-scopes>` opens the app's branch sheet (`mobile::scope.open`).\n *\n * A value the app or the store config already gives (even `false`) is kept.\n * Nothing happens outside the app.\n */\nexport function useNativeSpaWebview(): void {\n useEffect(\n () =>\n whenSallaReady(() => {\n if (!isNativeApp()) return;\n const config = getSallaSDK()?.config;\n if (config && config.get(SPA_WEBVIEW_FLAG) == null) config.set(SPA_WEBVIEW_FLAG, true);\n }),\n []\n );\n}\n","import { lazy, type LazyExoticComponent, type FC, type ReactNode } from 'react';\n\nexport const navigationSetups: Record<string, LazyExoticComponent<FC<{ children: ReactNode }>>> = {\n tanstack: lazy(() =>\n import('../tanstack/navigation').then((m) => ({ default: m.NavigationSetup }))\n ),\n nextjs: lazy(() => import('../nextjs/navigation').then((m) => ({ default: m.NavigationSetup }))),\n};\n","import { lazy, type FC, type LazyExoticComponent } from 'react';\n\n/**\n * Registry for framework-specific document sync components.\n * Each framework (tanstack, nextjs, etc.) can register its own sync component.\n * Used by TwilightProvider to automatically apply route-based body classes.\n *\n * @example Adding a new framework\n * ```ts\n * import { registerDocumentSync } from '@salla.sa/twilight-theme-engine';\n *\n * registerDocumentSync('my-framework', lazy(() => import('./my-document-sync')));\n * ```\n */\nexport const routeDocumentSyncs: Record<string, LazyExoticComponent<FC>> = {\n tanstack: lazy(() =>\n import('../tanstack/document-class').then((m) => ({\n default: m.TanStackDocumentSync,\n }))\n ),\n // Add other frameworks here:\n // nextjs: lazy(() => import('../nextjs/document-sync').then(m => ({ default: m.NextjsDocumentSync }))),\n};\n\n/**\n * Register a framework-specific document sync component.\n * Convenience function for adding new frameworks to the registry.\n */\nexport function registerDocumentSync(framework: string, component: LazyExoticComponent<FC>): void {\n routeDocumentSyncs[framework] = component;\n}\n","import { useTranslation } from '../providers/I18nProvider';\n\ntype DateFormat = 'full' | 'long' | 'medium' | 'short' | 'time';\n\nexport type DateInput =\n | string\n | number\n | Date\n | { date: string; timezone_type: number; timezone: string }\n | undefined;\n\nfunction normalizeDate(input: DateInput): Date {\n if (!input) return new Date();\n if (input instanceof Date) return input;\n if (typeof input === 'number') return new Date(input);\n if (typeof input === 'object' && 'date' in input) return new Date(input.date);\n return new Date(input);\n}\n\nexport interface UseDateResult {\n format: (date: DateInput, formatType?: DateFormat) => string;\n ago: (date: DateInput) => string;\n now: Date;\n}\n\n/**\n * useDate - Hook for formatting dates\n *\n * @example\n * const { format, ago, now } = useDate();\n * format('2024-03-15') // 'March 15, 2024'\n * format('2024-03-15', 'full') // 'Friday, March 15, 2024'\n * ago(Date.now() - 3600000) // '1 hour ago'\n * now // current Date object\n */\nexport function useDate(): UseDateResult {\n const { locale } = useTranslation();\n\n const format = (date: DateInput, formatType: DateFormat = 'medium'): string => {\n const dateObj = normalizeDate(date);\n\n const formatOptionsMap: Record<DateFormat, Intl.DateTimeFormatOptions> = {\n full: { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' },\n long: { year: 'numeric', month: 'long', day: 'numeric' },\n medium: { year: 'numeric', month: 'long', day: 'numeric' },\n short: { year: 'numeric', month: 'short', day: 'numeric' },\n time: { hour: '2-digit', minute: '2-digit' },\n };\n\n try {\n return new Intl.DateTimeFormat(locale, formatOptionsMap[formatType]).format(dateObj);\n } catch {\n return dateObj.toLocaleDateString(locale);\n }\n };\n\n const ago = (date: DateInput): string => {\n const dateObj = normalizeDate(date);\n const diffInSeconds = Math.floor((Date.now() - dateObj.getTime()) / 1000);\n\n const units: Array<{ unit: Intl.RelativeTimeFormatUnit; threshold: number; divisor: number }> =\n [\n { unit: 'year', threshold: 31536000, divisor: 31536000 },\n { unit: 'month', threshold: 2592000, divisor: 2592000 },\n { unit: 'week', threshold: 604800, divisor: 604800 },\n { unit: 'day', threshold: 86400, divisor: 86400 },\n { unit: 'hour', threshold: 3600, divisor: 3600 },\n { unit: 'minute', threshold: 60, divisor: 60 },\n { unit: 'second', threshold: 1, divisor: 1 },\n ];\n\n for (const { unit, threshold, divisor } of units) {\n if (diffInSeconds >= threshold) {\n const value = Math.floor(diffInSeconds / divisor);\n try {\n return new Intl.RelativeTimeFormat(locale, { numeric: 'auto', style: 'long' }).format(\n -value,\n unit\n );\n } catch {\n return new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(-value, unit);\n }\n }\n }\n\n return locale.startsWith('ar') ? 'الآن' : 'just now';\n };\n\n return { format, ago, now: new Date() };\n}\n","import { useTwilight } from '../providers/TwilightProvider';\n\nconst ARABIC_NUMERALS = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];\n\nconst toArabic = (input: number | string): string => {\n const str = String(input);\n return str.replace(/[0-9]/g, (d) => ARABIC_NUMERALS[parseInt(d)]);\n};\n\n/**\n * UseNumberResult - Return type for useNumber hook\n */\nexport interface UseNumberResult {\n /** Format number with store settings */\n format: (number: number | string) => string;\n /** Convert to Arabic numerals */\n toArabic: (input: number | string) => string;\n /** Whether Arabic numerals are enabled */\n useArabicNumerals: boolean;\n}\n\n/**\n * useNumber - Hook for number formatting\n *\n * @returns Object with number formatting utilities\n *\n * @example\n * const { format, toArabic, useArabicNumerals } = useNumber();\n * format(1234) // '١٢٣٤' if arabic numbers enabled, else '1234'\n * toArabic(1234) // '١٢٣٤'\n * useArabicNumerals // boolean from store settings\n */\nexport function useNumber(): UseNumberResult {\n const { store } = useTwilight();\n const useArabicNumerals = store?.settings?.arabic_numbers_enabled ?? false;\n\n const format = (number: number | string): string => {\n return useArabicNumerals ? toArabic(number) : String(number);\n };\n\n return {\n /** Format number with store settings */\n format,\n /** Convert to Arabic numerals */\n toArabic,\n /** Whether Arabic numerals are enabled */\n useArabicNumerals,\n };\n}\n","/**\n * Number formatting utilities\n *\n * For React components, use useNumber hook instead.\n */\n\nconst ARABIC_NUMERALS = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];\n\n/**\n * Convert Western Arabic numerals (0-9) to Arabic-Indic numerals (٠-٩)\n *\n * @example\n * toArabicNumerals('123') // '١٢٣'\n */\nexport function toArabicNumerals(input: number | string): string {\n const str = String(input);\n return str.replace(/[0-9]/g, (d) => ARABIC_NUMERALS[parseInt(d)]);\n}\n\n/**\n * Format number with optional Arabic numerals\n *\n * @example\n * formatNumber(1234, true) // '١٢٣٤'\n * formatNumber(1234, false) // '1234'\n */\nexport function formatNumber(number: number | string, useArabic: boolean): string {\n return useArabic ? toArabicNumerals(number) : String(number);\n}\n","import { useTwilight } from '../providers/TwilightProvider';\nimport { toArabicNumerals } from '../utils/number';\nimport React from 'react';\n\nconst SAR_SYMBOLS = ['SAR', 'ر.س'];\n\n/**\n * Parse a money string to a number.\n *\n * Locale-agnostic by design: normalises both Western (`,.`) and\n * Arabic-Indic (`٬`, `٫`) separators using fixed rules. Do NOT add\n * locale-dependent separator logic here — if per-locale rules are\n * ever needed, refactor back into the hook body where `locale`\n * is available.\n */\nconst parse = (moneyString: string): number => {\n const cleaned = moneyString.replace(/[^\\d.,٬٫]/g, '');\n const normalized = cleaned.replace(/٬/g, '').replace(/٫/g, '.');\n const parts = normalized.split(/[.,]/);\n if (parts.length > 2) {\n return parseFloat(`${parts.slice(0, -1).join('')}.${parts[parts.length - 1]}`);\n }\n return parseFloat(normalized.replace(/,/g, ''));\n};\n\n/**\n * Check if a value is a valid monetary amount.\n *\n * Locale-agnostic: accepts numbers and numeric strings only.\n */\nconst isValid = (value: unknown): boolean => {\n if (typeof value === 'number' && !isNaN(value) && isFinite(value)) return true;\n if (typeof value === 'string') {\n const parsed = parseFloat(value);\n return !isNaN(parsed) && isFinite(parsed);\n }\n return false;\n};\n\n/**\n * UseMoneyResult - Return type for useMoney hook\n */\nexport interface UseMoneyResult {\n /** Format amount with currency */\n format: (\n amount: number | string | undefined,\n options?: { currency?: string; locale?: string; type?: 'product' | 'general' }\n ) => React.ReactNode;\n /** Parse money string to number */\n parse: (moneyString: string) => number;\n /** Check if value is valid monetary amount */\n isValid: (value: unknown) => boolean;\n}\n\n/**\n * useMoney - Hook for formatting monetary values, matching Twilight's `salla.money`\n *\n * @example\n * const { format, parse, isValid } = useMoney();\n * // Render price (SAR shows the icon when the store enables it):\n * <span>{format(100)}</span> // '100' with <i className=\"sicon-sar\" />\n */\nexport function useMoney(): UseMoneyResult {\n const { store, settings, currency: active } = useTwilight();\n const useArabicNumerals = store?.settings?.arabic_numbers_enabled ?? false;\n const useSarSymbol = store?.settings?.use_sar_symbol ?? false;\n\n const format = (\n amount: number | string | undefined,\n options?: { currency?: string; locale?: string; type?: 'product' | 'general' }\n ): React.ReactNode => {\n const currency = options?.currency ?? active?.code ?? 'SAR';\n const type = options?.type ?? 'product';\n\n if (amount == null || amount === '') {\n const showDash = type === 'product' ? store?.settings?.product?.show_price_as_dash : false;\n return showDash ? '-' : '';\n }\n\n if (typeof amount === 'string' && amount === '-') return amount;\n if (isNaN(typeof amount === 'string' ? parseFloat(amount) : amount)) return String(amount);\n\n // Printed as given, like salla.money: \"10.50\" keeps its zero.\n const number = useArabicNumerals ? toArabicNumerals(amount).replace('.', '٫') : String(amount);\n const symbol = settings?.currencies?.[currency]?.symbol ?? currency;\n\n if (useSarSymbol && SAR_SYMBOLS.includes(symbol)) {\n return (\n <>\n {number} <i className=\"sicon-sar\" />\n </>\n );\n }\n return `${number} ${symbol}`;\n };\n\n return { format, parse, isValid };\n}\n","import { useCallback } from 'react';\nimport type { Product, Cart, CartItem } from '../types';\nimport { useTwilight } from '../providers/TwilightProvider';\nimport { useUser } from './useUser';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface UseGtmResult {\n /** Check if GTM is enabled */\n enabled: boolean;\n /** Raw push to dataLayer */\n push: (data: Record<string, unknown>) => void;\n /** Track page view */\n viewPage: (pageType: string) => void;\n /** Track product detail view */\n detail: (product: Product) => void;\n /** Track product impressions (listing) */\n impressions: (products: Product[], list?: string) => void;\n /** Track product click */\n click: (product: Product, list?: string, position?: number) => void;\n /** Track add to cart */\n add: (product: Product, quantity?: number) => void;\n /** Track remove from cart */\n remove: (item: CartItem) => void;\n /** Track checkout */\n checkout: (cart: Cart, step?: number) => void;\n /** Track purchase */\n purchase: (orderId: string | number, cart: Cart) => void;\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/** Generate unique event ID */\nfunction eventId(prefix: string): string {\n return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;\n}\n\n/** Convert Product to GTM format */\nfunction toProduct(product: Product, overrides?: Record<string, unknown>): Record<string, unknown> {\n return {\n id: product.id,\n name: product.name,\n price: product.sale_price,\n brand: product.brand?.name,\n category: product.category?.name,\n quantity: 1,\n ...overrides,\n };\n}\n\n/** Get currency from product or fallback */\nfunction getCurrency(product?: Product, fallback = 'SAR'): string {\n return product?.currency ?? fallback;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * useGtm - Google Tag Manager hook for tracking events\n *\n * @example\n * ```tsx\n * function ProductPage({ product }) {\n * const gtm = useGtm();\n *\n * useEffect(() => { gtm.detail(product); }, [product.id]);\n * return <button onClick={() => gtm.add(product)}>Add to Cart</button>;\n * }\n * ```\n */\nexport function useGtm(): UseGtmResult {\n const { store } = useTwilight();\n const { data: user } = useUser();\n\n const gtmIds = store.settings?.keys?.gtm;\n const enabled = !!(gtmIds && gtmIds.length > 0);\n const currency = user?.preferences?.currency_code ?? 'SAR';\n\n const push = useCallback(\n (data: Record<string, unknown>) => {\n if (!enabled) return;\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push(data);\n },\n [enabled]\n );\n\n const viewPage = useCallback((pageType: string) => push({ event: 'viewPage', pageType }), [push]);\n\n const detail = useCallback(\n (product: Product) =>\n push({\n event: 'detail',\n ecommerce: {\n currencyCode: getCurrency(product, currency),\n event_id: eventId('detail'),\n detail: { products: [toProduct(product)] },\n },\n }),\n [push, currency]\n );\n\n const impressions = useCallback(\n (products: Product[], list?: string) => {\n if (products.length === 0) return;\n push({\n event: 'impressions',\n ecommerce: {\n currencyCode: getCurrency(products[0], currency),\n event_id: eventId('impressions'),\n impressions: {\n products: products.map((p, i) => toProduct(p, { position: i + 1, list })),\n },\n },\n });\n },\n [push, currency]\n );\n\n const click = useCallback(\n (product: Product, list?: string, position?: number) =>\n push({\n event: 'click',\n ecommerce: {\n currencyCode: getCurrency(product, currency),\n event_id: eventId('click'),\n click: {\n actionField: { list },\n products: [toProduct(product, { position, list })],\n },\n },\n }),\n [push, currency]\n );\n\n const add = useCallback(\n (product: Product, quantity = 1) =>\n push({\n event: 'addToCart',\n ecommerce: {\n currencyCode: getCurrency(product, currency),\n event_id: eventId('addToCart'),\n add: { products: [toProduct(product, { quantity })] },\n },\n }),\n [push, currency]\n );\n\n const remove = useCallback(\n (item: CartItem) =>\n push({\n event: 'removeFromCart',\n ecommerce: {\n currencyCode: currency,\n event_id: eventId('removeFromCart'),\n remove: {\n products: [\n {\n id: item.product_id,\n name: item.product_name,\n price: typeof item.price === 'number' ? item.price : item.price.amount,\n quantity: item.quantity,\n },\n ],\n },\n },\n }),\n [push, currency]\n );\n\n const checkout = useCallback(\n (cart: Cart, step = 1) =>\n push({\n event: 'checkout',\n ecommerce: {\n currencyCode: currency,\n event_id: eventId('checkout'),\n checkout: {\n actionField: { step, id: cart.id },\n products: cart.items.map((item) => ({\n id: item.product_id,\n name: item.product_name,\n price: typeof item.price === 'number' ? item.price : item.price.amount,\n quantity: item.quantity,\n })),\n },\n },\n }),\n [push, currency]\n );\n\n const purchase = useCallback(\n (orderId: string | number, cart: Cart) =>\n push({\n event: 'purchase',\n ecommerce: {\n currencyCode: currency,\n event_id: eventId('purchase'),\n purchase: {\n actionField: {\n id: orderId,\n revenue: cart.total,\n tax: cart.tax_amount,\n coupon: cart.coupon,\n },\n products: cart.items.map((item) => ({\n id: item.product_id,\n name: item.product_name,\n price: typeof item.price === 'number' ? item.price : item.price.amount,\n quantity: item.quantity,\n })),\n },\n },\n }),\n [push, currency]\n );\n\n return { enabled, push, viewPage, detail, impressions, click, add, remove, checkout, purchase };\n}\n","import { useMemo } from 'react';\nimport { useTranslation } from '../providers/I18nProvider';\nimport type { OpeningHoursSettings } from '../types';\n\ntype DayOfWeek = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';\n\nconst DAYS: DayOfWeek[] = [\n 'monday',\n 'tuesday',\n 'wednesday',\n 'thursday',\n 'friday',\n 'saturday',\n 'sunday',\n];\n\nconst DAY_NAMES: Record<string, string> = {\n monday: 'common.days.monday',\n tuesday: 'common.days.tuesday',\n wednesday: 'common.days.wednesday',\n thursday: 'common.days.thursday',\n friday: 'common.days.friday',\n saturday: 'common.days.saturday',\n sunday: 'common.days.sunday',\n};\n\nconst TIME_NAMES: Record<string, string> = {\n AM: 'common.time.am',\n PM: 'common.time.pm',\n};\n\ninterface ParsedTimeRange {\n start: number; // minutes from midnight\n end: number; // minutes from midnight\n}\n\ninterface DaySchedule {\n ranges: ParsedTimeRange[];\n}\n\nexport interface UseOpeningHoursResult {\n /** Whether the store is currently open */\n isOpen: boolean;\n /** Whether opening hours feature is enabled and configured */\n isEnabled: boolean;\n /** Next opening time as Date object, null if currently open or not configured */\n nextOpen: Date | null;\n /** Formatted next opening time string, empty if currently open or not configured */\n nextOpenFormatted: string;\n}\n\n/**\n * Parse a time string like \"09:00\" or \"9:00 AM\" to minutes from midnight.\n */\nfunction parseTime(timeStr: string): number {\n const cleaned = timeStr.trim().toLowerCase();\n const match = cleaned.match(/^(\\d{1,2}):(\\d{2})(?:\\s*(am|pm))?$/);\n\n if (!match) {\n return 0;\n }\n\n let hours = parseInt(match[1], 10);\n const minutes = parseInt(match[2], 10);\n const meridiem = match[3];\n\n if (meridiem === 'pm' && hours < 12) {\n hours += 12;\n } else if (meridiem === 'am' && hours === 12) {\n hours = 0;\n }\n\n return hours * 60 + minutes;\n}\n\n/**\n * Parse opening hours ranges for a day.\n * Input format: [\"09:00-12:00\", \"13:00-18:00\"] or [\"09:00 AM - 12:00 PM\"]\n */\nfunction parseRanges(ranges: string[]): ParsedTimeRange[] {\n return ranges\n .map((range) => {\n const parts = range.split('-').map((s) => s.trim());\n if (parts.length !== 2) return null;\n\n const start = parseTime(parts[0]);\n const end = parseTime(parts[1]);\n\n return { start, end };\n })\n .filter((r): r is ParsedTimeRange => r !== null && r.start < r.end);\n}\n\n/**\n * Convert day index (0 = Monday) to day name.\n */\nfunction indexToDay(index: number): DayOfWeek {\n return DAYS[index % 7];\n}\n\n/**\n * Get the day index for a date (0 = Monday, 6 = Sunday).\n */\nfunction getDayIndex(date: Date): number {\n const jsDay = date.getDay(); // 0 = Sunday, 1 = Monday, etc.\n return jsDay === 0 ? 6 : jsDay - 1; // Convert to 0 = Monday\n}\n\n/**\n * Get current time in minutes from midnight.\n */\nfunction getTimeInMinutes(date: Date): number {\n return date.getHours() * 60 + date.getMinutes();\n}\n\n/**\n * Check if the given time falls within any of the ranges.\n */\nfunction isInRanges(time: number, ranges: ParsedTimeRange[]): boolean {\n return ranges.some((range) => time >= range.start && time < range.end);\n}\n\n/**\n * Find the next time range that starts after the given time.\n */\nfunction findNextRange(time: number, ranges: ParsedTimeRange[]): ParsedTimeRange | null {\n const sorted = [...ranges].sort((a, b) => a.start - b.start);\n return sorted.find((range) => range.start > time) ?? null;\n}\n\n/**\n * useOpeningHours - Hook for checking store opening status and next open time.\n *\n * @param settings - Opening hours settings from the store\n * @returns Opening status information\n *\n * @example\n * ```tsx\n * const { isOpen, nextOpenFormatted } = useOpeningHours(store.settings.opening_hours);\n *\n * if (!isOpen) {\n * return <div>Store closed. Opens at {nextOpenFormatted}</div>;\n * }\n * ```\n */\nexport function useOpeningHours(settings?: OpeningHoursSettings): UseOpeningHoursResult {\n const { t } = useTranslation();\n\n return useMemo(() => {\n if (!settings?.enabled || !settings?.hours) {\n return {\n isOpen: true, // Assume open if not configured\n isEnabled: false,\n nextOpen: null,\n nextOpenFormatted: '',\n };\n }\n\n const hours = settings.hours;\n const now = new Date();\n const currentDayIndex = getDayIndex(now);\n const currentTime = getTimeInMinutes(now);\n\n // Build schedule for all days\n const schedule: Record<DayOfWeek, DaySchedule> = {} as Record<DayOfWeek, DaySchedule>;\n for (const day of DAYS) {\n const dayRanges = hours[day];\n schedule[day] = {\n ranges: dayRanges ? parseRanges(dayRanges) : [],\n };\n }\n\n // Check if currently open\n const todaySchedule = schedule[indexToDay(currentDayIndex)];\n if (isInRanges(currentTime, todaySchedule.ranges)) {\n return {\n isOpen: true,\n isEnabled: true,\n nextOpen: null,\n nextOpenFormatted: '',\n };\n }\n\n // Find next open time\n // Check remaining ranges today\n const nextRangeToday = findNextRange(currentTime, todaySchedule.ranges);\n if (nextRangeToday) {\n const nextOpen = new Date(now);\n nextOpen.setHours(Math.floor(nextRangeToday.start / 60), nextRangeToday.start % 60, 0, 0);\n\n return {\n isOpen: false,\n isEnabled: true,\n nextOpen,\n nextOpenFormatted: formatNextOpen(nextOpen, t),\n };\n }\n\n // Check subsequent days (up to 7 days ahead)\n for (let i = 1; i <= 7; i++) {\n const nextDayIndex = (currentDayIndex + i) % 7;\n const nextDayName = indexToDay(nextDayIndex);\n const nextDaySchedule = schedule[nextDayName];\n\n if (nextDaySchedule.ranges.length > 0) {\n // Get the first range of that day\n const firstRange = [...nextDaySchedule.ranges].sort((a, b) => a.start - b.start)[0];\n\n const nextOpen = new Date(now);\n nextOpen.setDate(nextOpen.getDate() + i);\n nextOpen.setHours(Math.floor(firstRange.start / 60), firstRange.start % 60, 0, 0);\n\n return {\n isOpen: false,\n isEnabled: true,\n nextOpen,\n nextOpenFormatted: formatNextOpen(nextOpen, t),\n };\n }\n }\n\n // No opening hours found in the next week - assume open\n return {\n isOpen: true,\n isEnabled: true,\n nextOpen: null,\n nextOpenFormatted: '',\n };\n }, [settings, t]);\n}\n\n/**\n * Format the next open time similar to the PHP widget.\n * Output: \"Sunday 09:00 AM\" (translated)\n */\nfunction formatNextOpen(date: Date, t: (key: string) => string): string {\n const dayName = t(DAY_NAMES[indexToDay(getDayIndex(date))]);\n const hours = date.getHours();\n const minutes = date.getMinutes().toString().padStart(2, '0');\n const isPM = hours >= 12;\n const displayHours = hours > 12 ? hours - 12 : hours === 0 ? 12 : hours;\n const meridiem = t(TIME_NAMES[isPM ? 'PM' : 'AM']);\n\n return `${dayName} ${displayHours}:${minutes} ${meridiem}`;\n}\n","import { useEffect, useRef } from 'react';\nimport { whenSallaLoaded } from '../utils/sdk-helpers';\n\n/**\n * Page config data structure for salla.config.set('page', ...)\n */\nexport interface PageConfigData {\n slug: string;\n id?: string | number;\n title: string;\n /** Optional - defaults to current location pathname + search */\n url?: string;\n parent?: { id: string | number; name: string; url: string } | null;\n}\n\n/**\n * usePageConfig - Centralized hook for setting salla.config.page\n *\n * Replaces scattered salla?.config?.set('page', ...) calls across multiple pages.\n * Handles optional salla object safely.\n * Automatically uses current URL from router context if url not provided.\n *\n * @param pageData - Page configuration data to set\n *\n * @example\n * ```tsx\n * // URL is auto-detected from router context\n * usePageConfig({\n * slug: 'product.index',\n * id: categoryId,\n * title: category.name,\n * });\n *\n * // With explicit URL override\n * usePageConfig({\n * slug: 'product.index',\n * id: categoryId,\n * title: category.name,\n * url: '/custom-url',\n * });\n * ```\n */\nexport function usePageConfig(pageData: PageConfigData): void {\n const pageDataRef = useRef(pageData);\n pageDataRef.current = pageData;\n\n useEffect(\n () =>\n whenSallaLoaded((salla) => {\n if (!salla.config?.set) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('[usePageConfig] salla.config.set not available. Page config not set.');\n }\n return;\n }\n\n const current = pageDataRef.current;\n // A page can render without loader page data (tests, custom mounts) — nothing to seed.\n if (!current) return;\n const url = current.url ?? window.location.pathname + window.location.search;\n\n salla.config.set('page', {\n ...current,\n url,\n });\n }),\n []\n );\n}\n","import type { Breadcrumb } from '../types';\n\nconst BREADCRUMB_REFERRER_KEY = 'breadcrumb-referrer';\n\nexport function getBreadcrumbReferrer(): Breadcrumb | null {\n try {\n const raw = sessionStorage.getItem(BREADCRUMB_REFERRER_KEY);\n if (!raw) return null;\n const { name, url } = JSON.parse(raw);\n return typeof name === 'string' && typeof url === 'string' ? { name, url } : null;\n } catch {\n return null;\n }\n}\n\nexport function setBreadcrumbReferrer(breadcrumb: Breadcrumb): void {\n try {\n sessionStorage.setItem(BREADCRUMB_REFERRER_KEY, JSON.stringify(breadcrumb));\n } catch {\n // sessionStorage unavailable (private browsing quota, etc.)\n }\n}\n","import { useMemo, useEffect, useState } from 'react';\nimport { useLocation, useIsHome } from '../providers/NavigationProvider';\nimport { useTranslation } from '../providers/I18nProvider';\nimport { getBreadcrumbReferrer, setBreadcrumbReferrer } from '../utils/breadcrumb';\nimport type { Breadcrumb, Page } from '../types';\n\nexport function useBreadcrumbs(page?: Page | null): Breadcrumb[] {\n const location = useLocation();\n const isHome = useIsHome();\n const { t } = useTranslation();\n\n const [referrerCrumb, setReferrerCrumb] = useState<Breadcrumb | null>(null);\n\n useEffect(() => {\n if (page?.slug === 'product.single') {\n const ref = getBreadcrumbReferrer();\n if (ref) setReferrerCrumb(ref);\n return;\n }\n\n setReferrerCrumb(null);\n\n if (!isHome && page) {\n setBreadcrumbReferrer({ name: page.title, url: location.pathname + location.searchStr });\n }\n }, [page, isHome, location.pathname, location.searchStr]);\n\n return useMemo(() => {\n if (!page) return [];\n\n if (page.breadcrumbs?.length) {\n if (page.slug === 'product.single' && referrerCrumb) {\n const last = page.breadcrumbs.at(-1);\n return last ? [page.breadcrumbs[0], referrerCrumb, last] : page.breadcrumbs;\n }\n return page.breadcrumbs;\n }\n\n if (isHome) return [];\n\n const home: Breadcrumb = { name: t('common.titles.home'), url: '/' };\n return [home, { name: page.title, url: location.pathname }];\n }, [isHome, location.pathname, page, t, referrerCrumb]);\n}\n","/**\n * `salla-add-product-button` renders its quick-buy widget only when an element with this id exists\n * at render time. The body:end default hook keeps a src-less marker with this id in the DOM on every\n * page; the widget code itself is loaded by `fastCheckoutScript()` (eager from the product route\n * head, on idle elsewhere) and deduped by src, not by id.\n */\nexport const FAST_CHECKOUT_SCRIPT_ID = 'fast-checkout-js';\n// The old `mini-checkout/widget` opens `/_app/mini-checkout`, whose app appends paths after the\n// checkout URL's `?lang=` query and breaks the address step; this one opens `/_app/fast-checkout`.\n// Same version the Store's FAST_CHECKOUT_WIDGET_ASSETS_URL gives Twig themes.\nexport const FAST_CHECKOUT_SCRIPT_URL =\n 'https://cdn.assets.salla.network/prod/@salla.sa/fast-checkout-widget/v0.0.47/widget.esm.js';\n\nexport const fastCheckoutScript = () => ({ type: 'module', src: FAST_CHECKOUT_SCRIPT_URL });\n\n/**\n * Appends the widget script unless one with the same src is already in the document. On a product\n * page's first load TanStack has removed its own head tag by the time this runs, so a second tag can\n * land; that is harmless, the module map serves the same URL without refetching or re-evaluating.\n */\nexport function injectFastCheckoutScript(): void {\n if (document.querySelector(`script[src=\"${FAST_CHECKOUT_SCRIPT_URL}\"]`)) return;\n const s = document.createElement('script');\n Object.assign(s, fastCheckoutScript());\n document.head.appendChild(s);\n}\n","/**\n * Auto-registered default hooks for tracking/notification components.\n *\n * This module is imported automatically by hooks/index.ts to register\n * default handlers for body:start and body:end hooks.\n *\n * All handlers check conditions at render time via twilight context,\n * so they work without any setup from theme-custom.\n */\n\nimport React, { lazy, Suspense, useEffect } from 'react';\nimport { hookRegistry } from './HookRegistry';\nimport { HookName } from '../types/hooks';\nimport type { HookContext } from './HookSlot';\nimport { useUser } from './useUser';\nimport { FAST_CHECKOUT_SCRIPT_ID, injectFastCheckoutScript } from '../utils/fast-checkout';\n\n// Lazy load tracking/notification components from theme-engine\nconst GoogleTagBody = lazy(() =>\n import('../components/tracking/GoogleTag').then((m) => ({ default: m.GoogleTagBody }))\n);\n\nconst TwilightBundles = lazy(() =>\n import('../components/tracking/TwilightBundles').then((m) => ({ default: m.TwilightBundles }))\n);\n\nconst LazySiftSnippet = lazy(() =>\n import('../components/tracking/SiftSnippet').then((m) => ({ default: m.SiftSnippet }))\n);\n\nconst LazyStoreClosedNotification = lazy(() =>\n import('../components/store/StoreClosedNotification').then((m) => ({\n default: m.StoreClosedNotification,\n }))\n);\n\n// Lazy load cart widget components\nconst LazyPriceQuoteButton = lazy(() =>\n import('../components/cart/PriceQuoteButton').then((m) => ({ default: m.PriceQuoteButton }))\n);\n\nconst LazyPreOrderNotification = lazy(() =>\n import('../components/cart/PreOrderNotification').then((m) => ({\n default: m.PreOrderNotification,\n }))\n);\n\n/**\n * GTM handler - renders GoogleTagBody if store has GTM keys configured.\n */\nfunction gtmHandler({ twilight }: HookContext): React.ReactNode {\n if (!twilight?.store?.settings?.keys?.gtm?.length) {\n return null;\n }\n\n return (\n <Suspense fallback={null}>\n <GoogleTagBody gtmIds={twilight.store.settings.keys.gtm} />\n </Suspense>\n );\n}\n\n/**\n * Sift handler - renders SiftSnippet if store has sift key configured.\n */\nfunction useSiftHandler({ twilight }: HookContext): React.ReactNode {\n const { data: user } = useUser();\n\n if (!twilight?.store?.settings?.keys?.sift) {\n return null;\n }\n\n const customerId = user?.type === 'user' && user.id ? String(user.id) : '';\n\n return (\n <Suspense fallback={null}>\n <LazySiftSnippet beaconKey={twilight.store.settings.keys.sift} customerId={customerId} />\n </Suspense>\n );\n}\n\n/**\n * Store closed notification handler - renders if opening hours feature is enabled.\n */\nfunction storeClosedHandler({ twilight }: HookContext): React.ReactNode {\n if (!twilight?.store?.settings?.opening_hours?.enabled) {\n return null;\n }\n\n return (\n <Suspense fallback={null}>\n <LazyStoreClosedNotification />\n </Suspense>\n );\n}\n\n/**\n * Quick-buy widget presence + lazy loader. `salla-add-product-button` only checks that\n * `#fast-checkout-js` exists when it renders, so a src-less marker with that id is kept in the\n * body on every page: it survives hydration (TanStack drops head scripts after hydrating) and is\n * there before any app or custom JS renders a quick-buy button. An early `<salla-mini-checkout-widget>`\n * simply upgrades once the code lands. The code is loaded eagerly by the product route head and,\n * elsewhere, appended once the page is idle so it stays off the critical chain.\n */\nfunction FastCheckoutTag(): React.JSX.Element {\n useEffect(() => {\n if (typeof window.requestIdleCallback === 'function') {\n const id = window.requestIdleCallback(injectFastCheckoutScript);\n return () => window.cancelIdleCallback(id);\n }\n const id = window.setTimeout(injectFastCheckoutScript, 2000);\n return () => window.clearTimeout(id);\n }, []);\n return <script id={FAST_CHECKOUT_SCRIPT_ID} type=\"module\" />;\n}\n\n/**\n * Fast checkout handler - keeps the quick-buy marker in the DOM and lazily loads the widget when\n * quick purchase (`store.settings.buy_now`) is on.\n */\nfunction fastCheckoutHandler({ twilight }: HookContext): React.ReactNode {\n if (!twilight?.store?.settings?.buy_now) {\n return null;\n }\n\n return <FastCheckoutTag />;\n}\n\n/**\n * Twilight bundles handler - always renders (core tracking).\n */\nfunction bundlesHandler(): React.ReactNode {\n return (\n <Suspense fallback={null}>\n <TwilightBundles />\n </Suspense>\n );\n}\n\n/**\n * Price quote handler - renders if price-quote feature is enabled.\n * Twig: PriceQuoteWidget - checks feature('price-quote')->isAccessibleForCustomers()\n */\nfunction priceQuoteHandler({ twilight }: HookContext): React.ReactNode {\n // TODO: support price_quote in store settings API response\n if (!twilight?.store?.settings?.features?.price_quote) {\n return null;\n }\n\n return (\n <Suspense fallback={null}>\n <LazyPriceQuoteButton />\n </Suspense>\n );\n}\n\n/**\n * Pre-order notification handler - renders if cart has items with active pre-order campaigns.\n * Twig: PreOrderNotificationWidget - checks cart items for getHasActivePreorderCampaign()\n */\nfunction preOrderNotificationHandler({ twilight, cartItems }: HookContext): React.ReactNode {\n if (!twilight?.store?.settings?.features?.['pre-order-campaigns']) {\n return null;\n }\n\n const items = cartItems as\n Array<{ has_pre_order_campaign?: boolean; parent_id?: unknown }> | undefined;\n const hasPreOrder = items?.some((item) => !item.parent_id && item.has_pre_order_campaign);\n\n if (!hasPreOrder) {\n return null;\n }\n\n return (\n <Suspense fallback={null}>\n <LazyPreOrderNotification />\n </Suspense>\n );\n}\n\n/**\n * Register all default hooks from theme-engine.\n * Called automatically on module import.\n *\n * Note: theme-custom can register additional handlers like AddProductToast.\n */\nfunction registerDefaultHooks(): void {\n // Body start hooks (tracking, notifications)\n hookRegistry.register(HookName.BODY_START, gtmHandler, 100);\n hookRegistry.register(HookName.BODY_START, useSiftHandler, 90);\n hookRegistry.register(HookName.BODY_START, storeClosedHandler, 80);\n\n // Body end hooks (bundles)\n hookRegistry.register(HookName.BODY_END, bundlesHandler, 100);\n hookRegistry.register(HookName.BODY_END, fastCheckoutHandler, 90);\n\n // Cart hooks\n hookRegistry.register('cart:submit.start', priceQuoteHandler, 100);\n hookRegistry.register('cart:items.start', preOrderNotificationHandler, 100);\n}\n\n// Auto-register on module load\nregisterDefaultHooks();\n\nexport { registerDefaultHooks };\n","import { lazy, Suspense } from 'react';\nimport { Header } from './Header';\nimport { Footer } from './Footer';\nimport type { LayoutProps } from '../../types';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useUser } from '../../hooks';\n\nconst SallaLoginModal = lazy(() =>\n import('@salla.sa/twilight-components-react/login-modal').then((m) => ({\n default: m.SallaLoginModal,\n }))\n);\nconst SallaScopes = lazy(() =>\n import('@salla.sa/twilight-components-react/scopes').then((m) => ({\n default: m.SallaScopes,\n }))\n);\nconst SallaOfferModal = lazy(() =>\n import('@salla.sa/twilight-components-react/offer-modal').then((m) => ({\n default: m.SallaOfferModal,\n }))\n);\n\nexport function MasterLayout({ children }: LayoutProps) {\n const { store } = useTwilight();\n const { isLoggedIn } = useUser();\n\n return (\n <>\n <div className=\"app-inner flex flex-col min-h-full\">\n <Header />\n <main id=\"main-content\" role=\"main\" className=\"flex-1\">\n {children}\n </main>\n <Footer />\n </div>\n\n <Suspense>\n <SallaOfferModal />\n </Suspense>\n\n {!isLoggedIn && (\n <Suspense>\n <SallaLoginModal\n isEmailAllowed={store?.settings?.auth?.email_allowed}\n isMobileAllowed={store?.settings?.auth?.mobile_allowed}\n suppressHydrationWarning\n />\n </Suspense>\n )}\n\n {store?.scope && (\n <Suspense>\n <SallaScopes\n selection={store?.scope?.display_as === 'popup' ? 'mandatory' : 'optional'}\n suppressHydrationWarning\n />\n </Suspense>\n )}\n </>\n );\n}\n","import { useEffect, useMemo } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { apps, type AppSnippetRow } from '../../api/apps';\nimport { installAppScope } from '../../utils/app-scope';\nimport { applyThemeHookSlots } from '../../utils/theme-hook-slots';\nimport { getTwilightContext } from '../../twilight/context';\n\n/** How long to wait on the SDK / settings before injecting anyway. */\nconst READY_TIMEOUT_MS = 2500;\n\n// Module-level so StrictMode double-effects and remounts can't inject twice per page load.\nlet injected = false;\n\n/** A snippet plus its app's scope id — the key that resolves its config bucket. */\ntype OwnedSnippet = AppSnippetRow & { appScopeId: string };\n\n/**\n * Appends raw snippet HTML to `target`, recreating each `<script>` — innerHTML-parsed\n * scripts are flagged \"already started\" and never run.\n */\nexport function injectHtml(html: string, target: HTMLElement) {\n const tpl = document.createElement('template');\n tpl.innerHTML = html;\n tpl.content.querySelectorAll('script').forEach((inert) => {\n // importmap scripts can't be added post-init; the engine already injects its own.\n if (inert.type === 'importmap') {\n inert.remove();\n return;\n }\n const script = document.createElement('script');\n for (const attr of Array.from(inert.attributes)) {\n script.setAttribute(attr.name, attr.value);\n }\n script.text = inert.text;\n inert.replaceWith(script);\n });\n target.appendChild(tpl.content);\n}\n\n/**\n * Replaces `{{customer.x}}` placeholders with SDK config `user.*` values. Non-`customer.`\n * params are left untouched, matching the classic themes.\n */\nexport function resolveCustomerParams(content: string, params?: string[]): string {\n if (!params?.length) return content;\n for (const param of params) {\n if (!param.startsWith('customer.')) continue;\n const value = String(window.salla?.config?.get(param.replace(/^customer\\./, 'user.')) ?? '');\n // Tolerate inner whitespace (`{{ customer.email }}`); function replacement keeps `value`\n // literal so a `$&` in customer data isn't expanded.\n const escaped = param.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const placeholder = new RegExp(`\\\\{\\\\{\\\\s*${escaped}\\\\s*\\\\}\\\\}`, 'g');\n content = content.replace(placeholder, () => value);\n }\n return content;\n}\n\n/** Resolves after `ms`, so a promise that may never settle can't block injection. */\nconst timeout = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * `onReady` hangs forever if the SDK never initializes; race a timeout so a broken SDK\n * degrades to unsubstituted placeholders instead of dropping every snippet.\n */\nconst waitForSdk = (): Promise<unknown> => {\n const ready = window.salla?.onReady();\n return ready ? Promise.race([ready, timeout(READY_TIMEOUT_MS)]) : Promise.resolve();\n};\n\n/** Holds the snippets' onReady callbacks until all are injected, as on Twig, where they parse before ready. */\nexport function withDeferredOnReady(inject: () => void): void {\n const sdk = window.salla;\n const onReady = sdk?.onReady;\n if (!sdk || typeof onReady !== 'function') return inject();\n\n const queued: Array<() => void> = [];\n sdk.onReady = (callback) =>\n new Promise<void>((resolve, reject) => {\n queued.push(() => onReady.call(sdk, callback).then(resolve, reject));\n });\n try {\n inject();\n } finally {\n sdk.onReady = onReady;\n }\n queued.forEach((run) => run());\n}\n\n/**\n * Whitelists hook slots, installs the config sandbox, then injects the inline snippets.\n * Runs once per page load, after the SDK is ready.\n */\nfunction mountSnippets(\n owned: OwnedSnippet[],\n clientSnippets: OwnedSnippet[],\n buckets: Record<string, Record<string, unknown>>\n): void {\n // Backstop for the inline head copy (see renderThemeHookSlotsScript) — that one runs at\n // parse time, ahead of the snippet scripts; this only covers a head that didn't render.\n applyThemeHookSlots();\n\n // Install before any snippet resolves config. The inline SSR-head install normally got there\n // first (with these buckets, or with none when its prefetch failed), so this either installs\n // the factory or seeds the buckets into it. Pass the complete map once.\n installAppScope({ apps: buckets });\n\n // Flag every CDN scope with a missing bucket (SSR-rendered ones included).\n const unresolved = new Set<string>();\n for (const s of owned) {\n if (s.url && !(s.appScopeId in buckets)) unresolved.add(s.appScopeId);\n }\n\n withDeferredOnReady(() => {\n for (const snippet of clientSnippets) {\n // Honour `place`: a head-placed snippet is often a <meta>/<link>/<style> (site\n // verification, canonical, preload) that crawlers only read inside <head>.\n const target = snippet.place?.includes('head') ? document.head : document.body;\n try {\n injectHtml(resolveCustomerParams(snippet.content, snippet.customer_parameters), target);\n } catch (error) {\n console.error(`[salla] failed to inject snippet for app ${snippet.appScopeId}`, error);\n }\n }\n });\n\n if (unresolved.size) {\n // One line per page, not per snippet; expected during settings-endpoint rollout.\n console.warn(\n `[salla] app settings missing for ${unresolved.size} app(s); their snippets ran without app.* config`,\n [...unresolved]\n );\n }\n}\n\n/** A CDN snippet reduced to what its SSR `<script>` tag needs. */\ninterface SsrCdnScript {\n key: string;\n url: string;\n snippetId?: number;\n appScopeId: string;\n}\n\n/**\n * Mounts installed apps' snippets once per page load:\n * - **CDN** — rendered as SSR `<script>` tags in <body> (see return), so they exist on first\n * paint. `place` doesn't apply: they're deferred scripts, which run in order either way.\n * - **inline** — injected client-side in the effect, into `place`'s target (head or body).\n */\nexport function AppsSnippets() {\n // From twilight context, not useQuery: React Query isn't dehydrated here, so useQuery has no\n // SSR data — but the CDN <script> tags must render server-side.\n const ssrSnippets = getTwilightContext().appsSnippets;\n\n // Client fallback for when the SSR prefetch failed or timed out (it fails open, non-fatal).\n // Without it a single blip on `apps/snippets` would drop every installed app's snippets for\n // the whole page load — no CDN tags, no inline scripts, no hook slots. Retries here because\n // the query's own `retry: 0` exists only to bound the SSR wait.\n const { data: fallbackSnippets } = useQuery({\n ...apps.queries.snippets(),\n enabled: !ssrSnippets,\n retry: 2,\n });\n const data = ssrSnippets ?? fallbackSnippets;\n\n const { data: settings, isSuccess, isError } = useQuery({ ...apps.queries.settings(), retry: 2 });\n\n // Fail open: inject once settings settle either way, so snippets that never read `app.*`\n // aren't dropped when the bucket is empty.\n const settingsSettled = isSuccess || isError;\n\n // Each enabled app's snippets, tagged with its scope id (the encoded `id`). Older payloads\n // lacking `id` get a deterministic per-app fallback sharing one empty bucket.\n const owned = useMemo<OwnedSnippet[]>(\n () =>\n (data ?? [])\n .filter((app) => app.status === 'enabled')\n .flatMap((app) =>\n app.snippets.map((s) => ({ ...s, appScopeId: app.id ?? `unresolved-${app.app_id}` }))\n ),\n [data]\n );\n\n // Every CDN snippet → a real `<script>` tag in the SSR body (rendered below).\n const ssrCdnScripts = useMemo<SsrCdnScript[]>(\n () =>\n owned\n .filter((s) => s.url)\n .map((s, i) => ({\n key: `${s.appScopeId}:${s.id ?? i}`,\n url: s.url as string,\n snippetId: s.id,\n appScopeId: s.appScopeId,\n })),\n [owned]\n );\n\n useEffect(() => {\n if (injected || !data || !settingsSettled) return;\n injected = true;\n\n // Client-injected: inline snippets only. Every CDN snippet is SSR-rendered (below).\n const clientSnippets = owned.filter((s) => !s.url);\n\n // Always wait for the SDK: a snippet body calls the global `salla`/`Salla` (config, hooks,\n // event bus) whether or not it declares customer parameters, and those are only populated\n // after init. The wait is timeout-raced, so a broken SDK still can't strand injection.\n void waitForSdk().then(() => mountSnippets(owned, clientSnippets, settings?.apps ?? {}));\n }, [data, owned, settings, settingsSettled]);\n\n // CDN snippets as classic `defer` scripts: non-blocking, in-order, kept in <body> (React hoists\n // only `async` to <head>), and still exposing `document.currentScript` for the wrapper.\n return (\n <>\n {ssrCdnScripts.map((s) => (\n <script\n key={s.key}\n src={s.url}\n defer\n data-scope-id={s.appScopeId}\n data-snippet-id={s.snippetId != null ? String(s.snippetId) : ''}\n />\n ))}\n </>\n );\n}\n","import type { StoreContext } from '../../api/store';\nimport { resolveTwilightSdkUrl, TICKETING_SCRIPT_URL } from '../../routes/root/head';\n\n/** SDK modules at the end of <body>, ahead of the snippets: same run order as from <head>, later download. */\nexport function SallaSdkScripts({ settings }: { settings?: StoreContext }) {\n return (\n <>\n <script id=\"salla-sdk\" type=\"module\" src={resolveTwilightSdkUrl(settings)} />\n {settings?.store?.settings?.ticketing_system_enabled && (\n <script id=\"salla-ticketing-script\" type=\"module\" src={TICKETING_SCRIPT_URL} />\n )}\n </>\n );\n}\n","import { lazy } from 'react';\n\n/** Lazy-loaded StoreClosedNotification component. */\nexport const LazyStoreClosedNotification = lazy(() =>\n import('./StoreClosedNotification').then((m) => ({\n default: m.StoreClosedNotification,\n }))\n);\n\n/** Lazy-loaded MaintenancePage: off the shell chunk, since almost no visit renders it. */\nexport const LazyMaintenancePage = lazy(() =>\n import('./MaintenancePage').then((m) => ({ default: m.MaintenancePage }))\n);\n","import type { CSSProperties } from 'react';\nimport { getTwilightContext, hasTwilightSettings } from '../../twilight/context';\nimport { useTranslation } from '../../providers/I18nProvider';\n\nconst BAR: CSSProperties = {\n position: 'fixed',\n insetInline: 0,\n top: 0,\n zIndex: 2147483647,\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'center',\n justifyContent: 'center',\n gap: '8px 16px',\n padding: '10px 16px',\n font: '14px/1.4 system-ui, sans-serif',\n color: '#fff',\n background: '#1f2937',\n boxShadow: '0 2px 8px rgb(0 0 0 / 20%)',\n};\n\nconst LINK: CSSProperties = {\n color: '#fff',\n fontWeight: 600,\n textDecoration: 'underline',\n};\n\n/**\n * Dev-server only, pinned over the top of the maintenance page: says why the store did not render\n * and links to the dashboard's own entry (`?utm_source=dashboard&identifier=<store id>`),\n * which `rootBeforeLoad` answers with the owner cookie and the store. The provider\n * mounts it behind `import.meta.env.DEV`, so production builds drop it; the theme's\n * own `maintenancePage` gets it too.\n */\nexport function MaintenanceDevBar() {\n const { t } = useTranslation();\n const storeId = hasTwilightSettings() ? getTwilightContext().settings?.store?.id : undefined;\n if (storeId == null) return null;\n return (\n <aside data-testid=\"store-maintenance-dev-bar\" style={BAR}>\n <span>\n {t('pages.maintenance.dev_hint', {\n defaultValue: 'Twilight dev: this store is in maintenance, so customers get this page.',\n })}\n </span>\n <a\n data-testid=\"store-maintenance-view-as-merchant\"\n href={`?utm_source=dashboard&identifier=${storeId}`}\n style={LINK}\n >\n {t('pages.maintenance.view_as_merchant', {\n defaultValue: 'View the store as the merchant',\n })}\n </a>\n </aside>\n );\n}\n","import { lazy, Suspense, useEffect, useState, type ReactElement } from 'react';\nimport { editorFrame, FRAME_LOADED_ACTION, postToEditor, type EditorFrame } from './frame';\n\n/** Off the shell chunk: only a store framed by the theme editor ever loads it. */\nconst LazyLiveEditorBar = lazy(() =>\n import('./LiveEditorBar').then((m) => ({ default: m.LiveEditorBar }))\n);\n\n/**\n * Turns the storefront into the theme editor's live preview when the editor\n * frames it: tells the editor the page has loaded, and shows the action bar on\n * home blocks, the header and the footer. Renders nothing for shoppers, and\n * nothing on the server, so it changes no markup.\n */\nexport function LiveEditor(): ReactElement | null {\n const [frame, setFrame] = useState<EditorFrame | null>(null);\n\n useEffect(() => {\n const found = editorFrame();\n if (!found) return;\n setFrame(found);\n // The merchant's editor checks the preview's health with it; the dev editor doesn't.\n if (found.dev) return;\n const announce = () => postToEditor(found.origin, FRAME_LOADED_ACTION);\n if (document.readyState === 'complete') {\n announce();\n return;\n }\n window.addEventListener('load', announce, { once: true });\n return () => window.removeEventListener('load', announce);\n }, []);\n\n if (!frame) return null;\n return (\n <Suspense fallback={null}>\n <LazyLiveEditorBar origin={frame.origin} dev={frame.dev} />\n </Suspense>\n );\n}\n","import React, { useMemo, Suspense, useState, useEffect, useSyncExternalStore } from 'react';\nimport { WidgetHead } from '../components/layout/WidgetHead';\nimport { HookSlot } from '../hooks/HookSlot';\nimport { HookName } from '../types/hooks';\nimport { DocumentClassProvider } from './DocumentClassProvider';\nimport { TwilightContext } from './twilight-context';\nimport { ThemeDocumentSync } from './twilight-theme';\nimport { useTwilightInit } from './twilight-init';\nimport { useNativeSafeArea } from './native-safe-area';\nimport { useNativeSpaWebview } from './native-spa-webview';\nimport { I18nProvider, FALLBACK_LOCALE } from './I18nProvider';\nimport { NavigationInterceptor } from './NavigationProvider';\nimport { navigationSetups } from './navigation-setups';\nimport { routeDocumentSyncs } from './DocumentSyncRegistry';\nimport { MasterLayout } from '../components/layout/MasterLayout';\nimport { Toaster } from '../components/toast/Toaster';\nimport { AppsSnippets } from '../components/snippets/AppsSnippets';\nimport { SallaSdkScripts } from '../components/snippets/SallaSdkScripts';\nimport { LazyMaintenancePage } from '../components/store/lazy';\nimport { MaintenanceDevBar } from '../components/store/MaintenanceDevBar';\nimport { LiveEditor } from '../components/live-editor';\nimport { editorFrame, previewTheme } from '../components/live-editor/frame';\nimport {\n getTwilightContext,\n hasTwilightSettings,\n subscribeTwilight,\n updateTwilightContext,\n} from '../twilight/context';\nimport { AUTH_TOKEN_COOKIE_NAME, clearAuthTokenCookie, rememberDevStoreId } from '../utils/cookies';\nimport { whenSallaLoaded } from '../utils/sdk-helpers';\nimport type {\n TwilightContextValue,\n TwilightConfig,\n TwilightProviderProps,\n TwilightLog,\n} from '../types/twilight';\nimport type { StoreContext } from '../api/store';\n\nconst getSalla = () => (typeof window !== 'undefined' ? window.salla : undefined);\n\nconst TWILIGHT_LOG_STYLES = {\n header:\n 'background: linear-gradient(90deg, #7c3aed, #6366f1); color: white; padding: 4px 8px; border-radius: 4px; font-weight: bold;',\n error:\n 'background: #dc2626; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold;',\n warn: 'background: #f59e0b; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold;',\n info: 'background: #3b82f6; color: white; padding: 2px 6px; border-radius: 3px; font-weight: bold;',\n label: 'color: #7c3aed; font-weight: bold;',\n value: 'color: inherit;',\n};\n\nexport { useTwilight } from './twilight-context';\nexport type { TwilightProviderProps };\n\nfunction currentSettings(): StoreContext | undefined {\n return hasTwilightSettings() ? getTwilightContext().settings : undefined;\n}\n\nfunction currentMaintenance(): boolean {\n return hasTwilightSettings() && getTwilightContext().maintenance;\n}\n\nexport function TwilightProvider({\n children,\n debug = false,\n skeleton,\n translations: themeTranslations,\n onReady,\n onError,\n client = { framework: 'tanstack', interceptLinks: true },\n toast = true,\n toastMobilePosition = 'bottom-center',\n addToCartToast = true,\n routeClass = true,\n layout: LayoutComponent = MasterLayout,\n maintenancePage: MaintenancePageComponent = LazyMaintenancePage,\n}: TwilightProviderProps): React.ReactElement {\n const ctx = getTwilightContext();\n const initialLocale = ctx.locale || FALLBACK_LOCALE;\n // Subscribed, not read once: a market switch re-runs the root loader with another\n // scope and the router publishes the new settings here, and the theme version they\n // name has its own colours and settings.\n const initialData = useSyncExternalStore(subscribeTwilight, currentSettings, currentSettings);\n // Decided per request in rootBeforeLoad: the store is closed and this visitor is not the merchant.\n const maintenance = useSyncExternalStore(\n subscribeTwilight,\n currentMaintenance,\n currentMaintenance\n );\n\n // Auth token state for React re-renders on login/logout\n const [authToken, setAuthToken] = useState<string | null>(() => {\n if (typeof window !== 'undefined') {\n return ctx.authToken ?? window.localStorage.getItem(AUTH_TOKEN_COOKIE_NAME);\n }\n return null;\n });\n\n useNativeSafeArea();\n useNativeSpaWebview();\n\n // SDK auth event listeners, bound when the SDK arrives — on a cold load, after this runs.\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n let unbind: (() => void) | undefined;\n const cancel = whenSallaLoaded((sdk) => {\n // Symmetric counterpart to handleTokenInvalid's clear below. path=/ + Lax so the\n // cookie is sent on the native webview's top-level navigation to /account/orders,\n // letting twilightMiddleware authenticate the SSR render — the SDK only stores the\n // token in localStorage, which the server can't read.\n const writeAuthCookie = (token: string) => {\n document.cookie = `${AUTH_TOKEN_COOKIE_NAME}=${token}; path=/; max-age=${60 * 60 * 24 * 30}; SameSite=Lax; Secure`;\n };\n\n const clearAuthCookie = clearAuthTokenCookie;\n\n // The SDK only refreshes `user.type` on a full page load, but our auth flows update\n // the UI without one — SDK components read it directly (e.g. salla-login-modal's\n // render bails for 'user' and never creates its inner modal), so keep it in sync.\n const setSdkUserType = (type: 'user' | 'guest') => {\n sdk.config?.set?.('user.type', type);\n };\n\n const handleLogin = () => {\n const newToken = sdk.storage.get(AUTH_TOKEN_COOKIE_NAME) as string | null;\n // logged.in can fire before the token is stored (iframe mirror) — don't clobber\n if (!newToken) return;\n setAuthToken(newToken);\n updateTwilightContext({ authToken: newToken });\n setSdkUserType('user');\n };\n\n // Fires on a fresh token fetch (login / web-session refresh — the native app flow).\n // Mirror the token into a cookie so SSR loads of authenticated pages are authenticated.\n const handleTokenFetched = (token: unknown) => {\n if (typeof token !== 'string' || !token) return;\n setAuthToken(token);\n updateTwilightContext({ authToken: token });\n writeAuthCookie(token);\n setSdkUserType('user');\n };\n\n const handleLogout = () => {\n const wasLoggedIn = Boolean(getTwilightContext().authToken);\n setAuthToken(null);\n updateTwilightContext({ authToken: null });\n setSdkUserType('guest');\n // Clear the SSR cookie too, otherwise a logged-out user's next full-page load\n // would still send a stale token to the server.\n try {\n clearAuthCookie();\n } catch {\n // Cookie removal may fail in restricted environments\n }\n // SDK logout redirects via location.href only after an accounts-iframe roundtrip\n // that can hang forever (iOS webview). If its redirect hasn't unloaded the page\n // by then, reload so SSR re-renders as guest. Guarded to logged-in users so the\n // SDK's force_logout guest flow can't reload-loop.\n if (wasLoggedIn) {\n window.setTimeout(() => window.location.reload(), 3500);\n }\n };\n\n const handleTokenInvalid = () => {\n setAuthToken(null);\n updateTwilightContext({ authToken: null });\n setSdkUserType('guest');\n try {\n window.localStorage.removeItem(AUTH_TOKEN_COOKIE_NAME);\n sdk.storage.remove?.(AUTH_TOKEN_COOKIE_NAME);\n clearAuthCookie();\n } catch {\n // Storage/cookie removal may fail in restricted environments\n }\n };\n\n const listeners: Array<[string, (...args: unknown[]) => void]> = [\n ['auth::logged.in', handleLogin],\n ['auth::logged.out', handleLogout],\n ['auth::token.invalid', handleTokenInvalid],\n ['auth::token.fetched', handleTokenFetched],\n // fires on every token path, and BEFORE logged.in in the login-iframe flow\n ['api::token.injected', handleTokenFetched],\n ];\n listeners.forEach(([name, listener]) => sdk.event.on(name, listener));\n unbind = () => listeners.forEach(([name, listener]) => sdk.event.off(name, listener));\n });\n\n return () => {\n cancel();\n unbind?.();\n };\n }, []);\n\n const { isReady, storeData, setStoreData, themeData, currency, isMobileWebview } =\n useTwilightInit({\n debug,\n initialData,\n onReady,\n onError,\n initialLocale,\n });\n\n // Known only in the browser, so the first render matches the server's.\n const [inEditor, setInEditor] = useState(false);\n useEffect(() => setInEditor(editorFrame() !== null), []);\n const theme = useMemo(\n () => (inEditor ? previewTheme(themeData) : themeData),\n [inEditor, themeData]\n );\n\n const storeId = storeData?.id;\n useEffect(() => rememberDevStoreId(storeId), [storeId]);\n\n const config = useMemo<TwilightConfig>(() => ({ debug }), [debug]);\n\n const log = useMemo<TwilightLog>(\n () => ({\n groupCollapsed: (title) =>\n console.groupCollapsed(`%c ⚡ Twilight: ${title} `, TWILIGHT_LOG_STYLES.header),\n group: (title) => console.group(`%c${title}`, TWILIGHT_LOG_STYLES.label),\n groupEnd: () => console.groupEnd(),\n error: (label, value) =>\n console.log(`%c[${label}]%c`, TWILIGHT_LOG_STYLES.error, TWILIGHT_LOG_STYLES.value, value),\n warn: (label, value) =>\n console.log(`%c[${label}]%c`, TWILIGHT_LOG_STYLES.warn, TWILIGHT_LOG_STYLES.value, value),\n info: (label, value) =>\n console.log(`%c[${label}]%c`, TWILIGHT_LOG_STYLES.info, TWILIGHT_LOG_STYLES.value, value),\n label: (label, value) =>\n console.log(`%c[${label}]%c`, TWILIGHT_LOG_STYLES.label, TWILIGHT_LOG_STYLES.value, value),\n dir: (label, value) => {\n console.log(`%c${label}`, TWILIGHT_LOG_STYLES.label);\n console.dir(value);\n },\n trace: (label, trace) => {\n console.log(`%c${label}`, TWILIGHT_LOG_STYLES.label);\n console.error(trace);\n },\n }),\n []\n );\n\n const contextValue = useMemo<TwilightContextValue>(\n () => ({\n isReady,\n store: storeData,\n _setStore: setStoreData,\n theme,\n currency,\n config,\n log,\n get salla() {\n return getSalla();\n },\n get settings() {\n return getTwilightContext().settings;\n },\n get locale() {\n return getTwilightContext().locale;\n },\n get routeId() {\n return getTwilightContext().routeId;\n },\n get location() {\n return getTwilightContext().location;\n },\n get authToken() {\n return authToken;\n },\n get i18n() {\n return getTwilightContext().i18n;\n },\n get dir() {\n return getTwilightContext().dir;\n },\n get extras() {\n return getTwilightContext().extras;\n },\n }),\n [isReady, storeData, setStoreData, theme, currency, config, log, authToken]\n );\n\n const framework = client !== false ? (client?.framework ?? 'tanstack') : null;\n const LazyNavSetup = framework ? navigationSetups[framework] : null;\n const LazyDocumentSync = routeClass && framework ? routeDocumentSyncs[framework] : null;\n const interceptLinks = client !== false && (client?.interceptLinks ?? true);\n\n const documentSyncElement = useMemo(\n () => (LazyDocumentSync ? React.createElement(LazyDocumentSync) : null),\n [LazyDocumentSync]\n );\n\n const readyShell = useMemo(() => {\n if (!isReady) return null;\n return {\n LayoutComponent,\n MaintenancePageComponent,\n LazyNavSetup,\n toast,\n toastMobilePosition,\n addToCartToast,\n interceptLinks,\n };\n }, [\n isReady,\n LazyNavSetup,\n LayoutComponent,\n MaintenancePageComponent,\n toast,\n toastMobilePosition,\n addToCartToast,\n interceptLinks,\n ]);\n\n const readyContent = useMemo(() => {\n if (!readyShell) return null;\n\n // The maintenance page stands alone: no layout, no SDK (which would add its own\n // merchant-only maintenance bar), no app snippets. On a dev server a bar over it\n // links to the owner view, so nobody has to type the dashboard's URL by hand.\n if (maintenance) {\n return (\n <>\n <Suspense fallback={null}>\n <readyShell.MaintenancePageComponent />\n </Suspense>\n {import.meta.env.DEV && <MaintenanceDevBar />}\n </>\n );\n }\n\n const inner = readyShell.LayoutComponent ? (\n <readyShell.LayoutComponent>{children}</readyShell.LayoutComponent>\n ) : (\n children\n );\n\n const wrapped = (\n <>\n <WidgetHead />\n <HookSlot name={HookName.BODY_START} />\n <Suspense fallback={null}>\n {readyShell.toast && (\n <Toaster\n mobilePosition={readyShell.toastMobilePosition}\n addToCartToast={readyShell.addToCartToast}\n />\n )}\n {readyShell.interceptLinks && <NavigationInterceptor />}\n </Suspense>\n {inner}\n {/* The SDK, then installed apps' snippets (which need it), last so neither downloads ahead of the page. */}\n <SallaSdkScripts settings={initialData} />\n <AppsSnippets />\n <HookSlot name={HookName.BODY_END} />\n <LiveEditor />\n </>\n );\n\n if (readyShell.LazyNavSetup) {\n return React.createElement(readyShell.LazyNavSetup, null, wrapped);\n }\n return wrapped;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [readyShell, maintenance]);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const i18nInstance = useMemo(() => getTwilightContext().i18n, [initialLocale]);\n\n return (\n <DocumentClassProvider>\n <TwilightContext.Provider value={contextValue}>\n <I18nProvider i18nInstance={i18nInstance} themeTranslations={themeTranslations}>\n <ThemeDocumentSync\n theme={theme}\n locale={initialLocale}\n direction={getTwilightContext().dir}\n isMobileWebview={isMobileWebview}\n />\n {documentSyncElement}\n {!isReady && (\n <div className=\"loading-overlay\">{skeleton || <div className=\"loading-spinner\" />}</div>\n )}\n {readyContent}\n </I18nProvider>\n </TwilightContext.Provider>\n </DocumentClassProvider>\n );\n}\n\nexport default TwilightProvider;\n","import { useCallback } from 'react';\nimport { useTwilight } from '../providers/TwilightProvider';\nimport type { Store } from '../types';\n\n/**\n * UseStoreResult - Return type for useStore hook\n *\n * Extends the Store interface with a refresh method to re-fetch\n * the latest store configuration from the Salla SDK.\n */\nexport interface UseStoreResult extends Store {\n refresh: () => Promise<void>;\n}\n\n/**\n * useStore - Hook for accessing and managing store state\n *\n * Provides access to the store configuration and metadata from the\n * Twilight provider. Includes a refresh method to update the store\n * state with the latest data from the Salla SDK.\n *\n * @returns Store object with refresh() method to reload store data\n *\n * @example\n * ```tsx\n * function StoreInfo() {\n * const { name, currency, refresh } = useStore();\n *\n * return (\n * <div>\n * <h1>{name}</h1>\n * <button onClick={refresh}>Refresh store data</button>\n * <p>Current currency: {currency}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useStore(): UseStoreResult {\n const { store, _setStore, salla } = useTwilight();\n\n const refresh = useCallback(async () => {\n if (!salla) return;\n try {\n const data = salla.config.all();\n if (data?.store && typeof data.store === 'object') {\n _setStore((prev) => ({ ...prev, ...(data.store as Partial<Store>) }));\n }\n } catch {\n // Silently ignore errors - store remains unchanged\n }\n }, [salla, _setStore]);\n\n return { ...store, refresh };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/cookies.ts","../src/utils/inline-script.ts","../src/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CACd,UACA,IAAA,EACe;AACf,EAAA,MAAM,IAAA,GACJ,iBAAgB,CAAE,WAAA,KAAgB,OAAO,MAAA,KAAW,WAAA,GAAc,MAAA,CAAO,QAAA,CAAS,IAAA,GAAO,IAAA,CAAA;AAC3F,EAAA,OAAO,qBAAA,CAAsB,EAAE,IAAA,EAAM,IAAA,EAAM,kBAAiB,EAAG,QAAA,EAAU,MAAM,CAAA;AACjF","file":"chunk-FHU2MXZA.js","sourcesContent":["import { isLocale } from '../providers/locale-constants';\n\nexport const AUTH_TOKEN_COOKIE_NAME = 'token';\nexport const SCOPE_COOKIE_NAME = 'scope';\nexport const CURRENCY_COOKIE_NAME = 's-curr';\n/** The language the SDK's localization modal remembers; host-wide, so shared by every store on a shared host. */\nexport const LANGUAGE_COOKIE_NAME = 's-lang';\n/** Query parameter the localization modal navigates with to ask for a language. */\nexport const LANGUAGE_PARAM = 'lang';\n/** How long a language choice is remembered: one year, like the `scope` cookie. */\nexport const LANGUAGE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;\n\n/**\n * Which store this request is for, when the hostname does not say.\n *\n * A live storefront is reached at its own domain, so the hostname identifies it\n * and nothing else is needed. A preview is not: every theme under review is\n * served from the one preview hostname, so the store has to be named some other\n * way — the dispatcher takes it from `?storeId=` and puts it here, the same way\n * it remembers which theme to serve.\n *\n * Written by the dispatcher rather than the theme, and set on the *forwarded\n * request* as well as the response, because the response cookie only arrives in\n * time for the second page load and the first one has to render too.\n *\n * The literal is a contract with `STORE_COOKIE` in store-front-dispacher\n * (`src/dispatch/preview.ts`), and **nothing checks the two agree**. Drift does\n * not fail loudly — it renders somebody else's shop. Grep both repos before\n * changing it.\n */\nexport const STORE_ID_COOKIE_NAME = 'salla_sid';\n\n/** Query parameter naming the store, on a host that serves more than one. */\nexport const STORE_ID_PARAM = 'storeId';\n\n/**\n * Which version of the theme's settings to render.\n *\n * A merchant's theme settings are versioned, and the storefront normally shows\n * whichever version is live — the API answers with it, and names it back as\n * `theme.profile.id`. Two places need a different one: the merchant's own theme\n * editor, which previews a draft version before it is published, and a partner\n * running a theme locally against a store whose settings they are editing. Both\n * open the theme inside an iframe, and the version travels in that URL.\n *\n * Named `versionId` rather than the `version_id` the Dashboard uses internally,\n * because it sits beside `?storeId=` and one URL should not spell two ids two\n * ways. The value is the same one either way: the Optimus-encoded version id,\n * which is exactly what `s-version-id` has always carried.\n *\n * The literal is a contract with `VERSION_COOKIE` in store-front-dispacher\n * (`src/dispatch/preview.ts`), on the same terms as {@link STORE_ID_COOKIE_NAME}:\n * nothing checks the two agree, and drift shows a merchant the wrong version of\n * their own settings rather than failing.\n */\nexport const VERSION_ID_COOKIE_NAME = 'salla_vid';\n\n/** Query parameter naming the theme-settings version, where one may be named. */\nexport const VERSION_ID_PARAM = 'versionId';\n\n/**\n * An id named by a request is an integer, and anything else is not one.\n *\n * Validated rather than passed through because these values end up in an upstream\n * API path and header. Leading zeroes, signs, decimals and whitespace are all\n * rejected: the point is a single canonical form, not the widest set of things\n * that could be coerced into a number.\n *\n * One function for both ids on purpose. They arrive the same way, from the same\n * untrusted place, and are spent the same way; two copies of this rule would be\n * two chances for one of them to be relaxed on its own.\n */\nfunction parseRequestId(raw: string | null | undefined): string | null {\n if (!raw) return null;\n return /^[1-9][0-9]{0,18}$/.test(raw) ? raw : null;\n}\n\n/** A store id in its canonical form, or null when it is not one. */\nexport function parseStoreId(raw: string | null | undefined): string | null {\n return parseRequestId(raw);\n}\n\n/** A theme-settings version id in its canonical form, or null when it is not one. */\nexport function parseVersionId(raw: string | null | undefined): string | null {\n return parseRequestId(raw);\n}\n\n/** The store id the dispatcher left in the cookie, or null when absent or malformed. */\nexport function extractStoreIdFromCookies(cookieHeader: string | null): string | null {\n return parseStoreId(extractTokenFromCookies(cookieHeader, STORE_ID_COOKIE_NAME));\n}\n\n/** The version id the dispatcher left in the cookie, or null when absent or malformed. */\nexport function extractVersionIdFromCookies(cookieHeader: string | null): string | null {\n return parseVersionId(extractTokenFromCookies(cookieHeader, VERSION_ID_COOKIE_NAME));\n}\n\n/**\n * The only hosts on which a request may name its own store.\n *\n * **This is a security boundary, not a convenience.** On a merchant's own domain\n * the hostname *is* the store, and it is the only thing that may decide. A theme\n * that also honoured `?storeId=` there would let anyone open\n * `https://reefperfumes.com/?storeId=<someone else>` and be served a different\n * merchant's shop from the domain its owner controls — their branding, their\n * customers' address bar, somebody else's catalogue — and the cookie would keep\n * serving it for the rest of that browser's session. Salla points SaaS domains\n * at this dispatcher, so those hostnames are real and reachable.\n *\n * The override exists for one situation: a host that serves many stores and so\n * cannot identify one from its name. That is the preview host, where every theme\n * under review answers on the same address, and local development.\n *\n * Adding an entry grants that host the ability to render any store on request.\n * Add nothing that a merchant's traffic reaches.\n */\nexport const STORE_ID_HOSTS: readonly string[] = ['preview.salla.design'];\n\n/** The hostname alone — a port never distinguishes one host's authority from another's. */\nfunction hostnameOf(host: string): string {\n const trimmed = host.trim().toLowerCase();\n // IPv6 literals are bracketed, and the colons inside them are not a port.\n if (trimmed.startsWith('[')) return trimmed.slice(0, trimmed.indexOf(']') + 1) || trimmed;\n const colon = trimmed.indexOf(':');\n return colon === -1 ? trimmed : trimmed.slice(0, colon);\n}\n\nexport function isLoopback(hostname: string): boolean {\n return (\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname === '[::1]' ||\n hostname.endsWith('.localhost')\n );\n}\n\n/**\n * Whether this host is allowed to let the request choose a store.\n *\n * Deliberately an allowlist of exact hostnames plus loopback. No suffix matching:\n * a rule like \"anything ending in salla.design\" is one wildcard DNS record away\n * from admitting a host nobody meant to admit, and the list of hosts that serve\n * more than one store is short and known.\n *\n * It gates {@link resolveRequestVersionId} as well, and the name has been left\n * alone rather than generalised because one predicate that both call is the\n * property worth keeping — a second, subtly different list is how a host ends up\n * permitted to name one thing and not the other. A version is worth gating for\n * the same reason a store is: on a merchant's own domain, honouring\n * `?versionId=` would publish whatever draft settings they are still working on\n * to anyone who guessed the URL.\n */\nexport function allowsRequestStoreId(host: string | null | undefined): boolean {\n if (!host) return false;\n const hostname = hostnameOf(host);\n return STORE_ID_HOSTS.includes(hostname) || isLoopback(hostname);\n}\n\n/**\n * Whether this host *is* a store, so its name can be used as the identifier.\n *\n * The exact inverse of {@link allowsRequestStoreId}, and deliberately written as\n * one so the two can never disagree: a host that may name its store is a host\n * that serves more than one, and a host that serves more than one cannot be the\n * answer to \"which store is this?\". `preview.salla.design` and `localhost:5188`\n * are not shops; asking the API about them earns a 422 and a page that reads as\n * a broken theme.\n */\nexport function hostIdentifiesStore(host: string | null | undefined): boolean {\n return Boolean(host) && !allowsRequestStoreId(host);\n}\n\n/**\n * The store this request names, on a host permitted to name one.\n *\n * The host check is inside the resolution rather than at a call site, because a\n * call site is a thing someone can add without reading this comment. There is no\n * way to ask \"what store did the request name?\" without also asking \"is this a\n * host that may say?\" — get it wrong and the answer is a security bug that looks\n * like a feature.\n *\n * Between the two permitted sources the URL wins, the same precedence the\n * dispatcher uses for the theme and for the same reason: a link is how someone\n * switches, and a cookie they cannot see should never beat the address they\n * just typed.\n */\nexport function resolveRequestStoreId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): string | null {\n return resolveRequestId(url, cookieHeader, host, STORE_ID_PARAM, STORE_ID_COOKIE_NAME);\n}\n\n/**\n * A store username as it can appear as the first segment of a path.\n *\n * Starts with a letter or digit, so nothing the platform mounts at the root of a\n * host — `/_serverFn/`, `/.well-known/` — is ever read as a store. Dots are allowed\n * (`zyros.sa`), but a root file (`/favicon.ico`, `/robots.txt`) is not a store.\n * The value is sent upstream as the `store-identifier` header, so the set is kept\n * narrow on purpose: a username outside it cannot be addressed by path, and\n * `?storeId=` still can.\n */\nconst STORE_BASE_SEGMENT = /^[a-z0-9][a-z0-9._-]{0,62}$/i;\nconst ROOT_FILE =\n /\\.(ico|txt|xml|json|webmanifest|html?|js|mjs|css|map|png|jpe?g|gif|svg|webp|avif|woff2?|ttf|otf|eot|pdf|mp4|webm|wasm)$/i;\n\n/**\n * Whether this could be a store's username in the first segment of a path.\n *\n * A supported locale code never is, in any case: `/ar` and `/EN` are languages,\n * so `preview.salla.design/en/cart` is the English cart of the store the cookie\n * names. That makes a store whose username is a locale code (`ar` is one)\n * unreachable by path; `?storeId=` still reaches it.\n *\n * The same predicate decides whether a username may become a path's root\n * (`storeBaseRedirectHref`). That is what stops the redirect from looping: a\n * store called `ar`, sent to `/ar/…`, would find no store there and be sent again.\n */\nexport function isStoreBaseSegment(value: string | null | undefined): value is string {\n return (\n typeof value === 'string' &&\n STORE_BASE_SEGMENT.test(value) &&\n !ROOT_FILE.test(value) &&\n !isLocale(value.toLowerCase())\n );\n}\n\n/**\n * The store the first segment of this request's path names, on a host permitted\n * to name one.\n *\n * On such a host the first segment **is** the store. It is the root of the\n * application there, so `https://preview.salla.design/mtgr-alaatr-2/cart` is the\n * cart of the store whose username is `mtgr-alaatr-2`. This is a rule rather than\n * a guess, and it has to be: `cart`, `offers` and `search` are all real store\n * usernames, so a store cannot be told from a page by looking at the segment.\n * `/cart` on these hosts is the store called `cart`.\n *\n * The one segment that is not a store is a supported locale code (see\n * {@link isStoreBaseSegment}). `/ar/cart` names a language, and the store comes\n * from the cookie or `VITE_STORE_DOMAIN`, as it would at `/`.\n *\n * A URL that carries `storeId` is not read this way at all, whatever its value.\n * That is how `salla theme dev` names a store (`/ar?storeId=…`), on a path that\n * begins with a page; the root loader then redirects to the store's own address.\n * Checking for a *valid* id instead would let a malformed one hand the page's\n * first segment the store's job. (On the preview host the dispatcher removes the\n * parameter and sends a cookie; the editor opens that host at `/`, where there is\n * no segment to read.)\n *\n * Same gate as {@link resolveRequestStoreId}, for the same reason: on a merchant's\n * own domain the hostname is the store and the path is only ever a page.\n */\nexport function resolveRequestStoreBase(\n url: string,\n host: string | null | undefined\n): string | null {\n if (!allowsRequestStoreId(host)) return null;\n\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.searchParams.has(STORE_ID_PARAM)) return null;\n\n const first = parsed.pathname.split('/')[1];\n return isStoreBaseSegment(first) ? first : null;\n}\n\n/** Which store a request addressed, and how. At most one of the two is set. */\nexport interface RequestStore {\n /** Named by `?storeId=`, or by the cookie remembering it. */\n storeId: string | null;\n /** Named by the first segment of the path. */\n storeBase: string | null;\n}\n\n/**\n * The store this request addressed: the query, then the path, then the cookie.\n *\n * The path outranks the cookie because it is the address the visitor can see.\n * The cookie is one value for the whole preview host, so with two stores open in\n * two tabs it names whichever was opened last; the path names the one in front\n * of them.\n */\nexport function resolveRequestStore(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): RequestStore {\n const storeBase = resolveRequestStoreBase(url, host);\n return {\n storeBase,\n storeId: storeBase ? null : resolveRequestStoreId(url, cookieHeader, host),\n };\n}\n\n/**\n * The header the storefront dispatcher names the store in, on a Salla shared host\n * that routes by username: `demostore.salla.sa/ar/dev-x/cart` is store `dev-x`.\n *\n * There the hostname belongs to every store, so the API cannot be asked about it\n * (it answers 422 and the page reads \"Store Unavailable\"), and only the dispatcher\n * has already read the username out of the path to choose this theme.\n *\n * Trusted because nothing else can set it. A theme worker is reached only through\n * the dispatcher, which hands it the headers on its own allowlist and then this one;\n * a visitor's copy never arrives. On a merchant's own domain the dispatcher does\n * not send it, so the hostname stays the store there.\n */\nexport const STORE_BASE_HEADER = 'x-salla-store-base';\n\n/** {@link RequestStore}, plus where the store segment sits in the path. */\nexport interface AddressedStore extends RequestStore {\n /**\n * True when the store segment follows the locale (`/ar/dev-x/cart`), as on a\n * Salla shared host; false when it is the root (`/mtgr-alaatr-2/ar/cart`), as on\n * the preview host and a dev server.\n */\n storeBaseFollowsLocale: boolean;\n}\n\n/**\n * The store this request addressed, counting the one the dispatcher named.\n *\n * The dispatcher's answer comes first and replaces the others: on a shared host it\n * is the address the visitor typed, read by the service that routed it here. Any\n * other request is resolved as {@link resolveRequestStore} always has, with the\n * segment at the root.\n */\nexport function resolveAddressedStore(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined,\n dispatchedStoreBase: string | null | undefined\n): AddressedStore {\n if (isStoreBaseSegment(dispatchedStoreBase)) {\n return { storeBase: dispatchedStoreBase, storeId: null, storeBaseFollowsLocale: true };\n }\n return { ...resolveRequestStore(url, cookieHeader, host), storeBaseFollowsLocale: false };\n}\n\n/**\n * The theme-settings version this request names, on a host permitted to name one.\n *\n * Same shape and the same host gate as {@link resolveRequestStoreId}, deliberately:\n * both answer \"what did this request ask to be shown?\", both are reached only on\n * a host that serves more than one thing, and a version that could be named where\n * a store could not would be a second rule to keep in step with the first.\n *\n * Null is the ordinary answer, and it is not a failure — it means nothing\n * addressed a version, so the store's own live one is what gets rendered.\n */\nexport function resolveRequestVersionId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined\n): string | null {\n return resolveRequestId(url, cookieHeader, host, VERSION_ID_PARAM, VERSION_ID_COOKIE_NAME);\n}\n\n/**\n * The id this request names, from the query first and the cookie after.\n *\n * The host check lives here rather than at either call site, for the reason the\n * two wrappers above are wrappers at all: there must be no way to ask what a\n * request named without also asking whether this host may say.\n */\nfunction resolveRequestId(\n url: string,\n cookieHeader: string | null,\n host: string | null | undefined,\n param: string,\n cookieName: string\n): string | null {\n if (!allowsRequestStoreId(host)) return null;\n\n let fromQuery: string | null = null;\n try {\n fromQuery = parseRequestId(new URL(url).searchParams.get(param));\n } catch {\n /* a relative or malformed URL simply names nothing */\n }\n return fromQuery ?? parseRequestId(extractTokenFromCookies(cookieHeader, cookieName));\n}\n\n/**\n * Deletes the auth `token` cookie. This cookie is written client-side by the theme\n * (TwilightProvider), not by the SDK — `salla.cookie.clearAll()` only clears its own\n * allowlist and leaves `token` behind — so logout must clear it here. Client-only.\n */\n/**\n * On a dev server, remembers the store the page is showing, so a later URL that\n * names no store keeps it instead of falling back to `VITE_STORE_DOMAIN`.\n * Loopback only: on the preview host this cookie belongs to the dispatcher. Client-only.\n */\nexport function rememberDevStoreId(id: string | number | null | undefined): void {\n if (typeof document === 'undefined' || !isLoopback(window.location.hostname)) return;\n const storeId = parseStoreId(id == null ? null : String(id));\n if (storeId) document.cookie = `${STORE_ID_COOKIE_NAME}=${storeId}; path=/; SameSite=Lax`;\n}\n\nexport function clearAuthTokenCookie(): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${AUTH_TOKEN_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n}\n\nexport function extractTokenFromCookies(\n cookieHeader: string | null,\n cookieName: string\n): string | null {\n if (!cookieHeader) return null;\n\n const prefix = `${cookieName}=`;\n let start = 0;\n\n while (start < cookieHeader.length) {\n const idx = cookieHeader.indexOf(prefix, start);\n if (idx === -1) return null;\n\n const prevChar = idx > 0 ? cookieHeader[idx - 1] : '';\n if (prevChar === '' || prevChar === ';' || prevChar === ' ') {\n let end = cookieHeader.indexOf(';', idx);\n if (end === -1) end = cookieHeader.length;\n\n const value = cookieHeader.slice(idx + prefix.length, end).trim();\n try {\n return decodeURIComponent(value) || null;\n } catch {\n return value || null;\n }\n }\n\n start = idx + prefix.length;\n }\n\n return null;\n}\n\n/**\n * The scope the Salla SDK persists as `scope`: the market (`id`/`type`) plus, once\n * bullet delivery confirms an address or branch, the allocation. The SDK sends all\n * four as request headers (`s-scope-id`, `s-scope-type`, `s-scope-allocation-type`,\n * `s-scope-allocation-id`) and the API resolves stock per allocation — a scope sent\n * without its allocation is a different question, answered from a different branch.\n */\nexport interface ActiveScope {\n id: string;\n type?: string;\n allocation_type?: string;\n allocation_id?: string;\n}\n\n/** The SDK stores the scope either as its full object or as a bare id. */\nfunction normalizeScope(raw: unknown): ActiveScope | null {\n if (raw == null) return null;\n if (typeof raw !== 'object') return { id: String(raw) };\n const s = raw as Record<string, unknown>;\n if (s.id == null) return null;\n const scope: ActiveScope = { id: String(s.id) };\n if (s.type != null) scope.type = String(s.type);\n if (s.allocation_type != null) scope.allocation_type = String(s.allocation_type);\n if (s.allocation_id != null) scope.allocation_id = String(s.allocation_id);\n return scope;\n}\n\n/**\n * Reads the active scope from the `scope` cookie, which Salla persists as a JSON\n * object (e.g. `{\"id\":123,\"type\":\"scope\",\"allocation_type\":\"branch\",\"allocation_id\":\"9\"}`).\n * Returns null when the cookie is missing or unparseable. Used server-side, where\n * `salla.storage` is absent.\n */\nexport function extractScopeFromCookies(cookieHeader: string | null): ActiveScope | null {\n const raw = extractTokenFromCookies(cookieHeader, SCOPE_COOKIE_NAME);\n if (!raw) return null;\n try {\n return normalizeScope(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\n/** `value` when it is a currency code, else null: the cookie's value goes into a request header. */\nexport function toCurrencyCode(value: string | null | undefined): string | null {\n return value && /^[A-Z]{3}$/.test(value) ? value : null;\n}\n\n/** The currency the visitor chose (`s-curr`, written by the SDK), or null for the store's own. */\nexport function extractCurrencyFromCookies(cookieHeader: string | null): string | null {\n return toCurrencyCode(extractTokenFromCookies(cookieHeader, CURRENCY_COOKIE_NAME));\n}\n\n/** {@link extractScopeFromCookies} reduced to the id. */\nexport function extractScopeIdFromCookies(cookieHeader: string | null): string | null {\n return extractScopeFromCookies(cookieHeader)?.id ?? null;\n}\n\n/**\n * The scope the Salla SDK persisted in its storage (`salla.storage.get('scope')`).\n *\n * Returns `undefined` when the SDK storage API isn't ready yet — deliberately\n * distinct from `null` (\"no branch selected\"), so callers can't mistake a\n * not-yet-hydrated SDK for a cleared selection. Client-only.\n *\n * Storage the SDK has loaded but not yet initialised counts as not ready: it is\n * what the previous visit left, and `init` replaces it with the scope the page\n * was rendered for and the one `?scope=` names. Read before that, it would\n * outvote the `scope` cookie the server wrote for this page.\n */\nexport function readSdkScope(): ActiveScope | null | undefined {\n const sdk = typeof window !== 'undefined' ? window.salla : undefined;\n const storage = sdk?.storage;\n if (typeof storage?.get !== 'function') return undefined;\n const status = (sdk as { status?: unknown } | undefined)?.status;\n if (status !== undefined && status !== 'ready') return undefined;\n return normalizeScope(storage.get(SCOPE_COOKIE_NAME));\n}\n\n/** The type of a multi-market (Country Scopes) store's scopes, which `s-scope-type` must name. */\nconst MARKET_SCOPE_TYPE = 'scope';\n\nconst ALLOCATION_TYPES = ['address', 'branch'];\n\n/** An encoded branch id, or the `msa_` token several branches are packed into. */\nconst ALLOCATION_ID = /^(?:[1-9][0-9]{0,18}|msa_[A-Za-z0-9+/=_-]{1,2048})$/;\n\n/**\n * The scope a page URL names, the way Twig storefronts switch market: the SDK's\n * scopes modal reloads the page with `?scope=<id>`, and a branch picked for it\n * travels as `allocation_type` / `allocation_id`. Null when the URL names none\n * or names it malformed; an allocation is kept only when both halves are valid.\n */\nexport function extractScopeFromUrl(url: string): ActiveScope | null {\n let params: URLSearchParams;\n try {\n params = new URL(url).searchParams;\n } catch {\n return null;\n }\n const id = parseRequestId(params.get('scope'));\n if (!id) return null;\n\n const scope: ActiveScope = { id };\n const allocationType = params.get('allocation_type');\n const allocationId = params.get('allocation_id');\n if (\n allocationType &&\n ALLOCATION_TYPES.includes(allocationType) &&\n allocationId &&\n ALLOCATION_ID.test(allocationId)\n ) {\n scope.allocation_type = allocationType;\n scope.allocation_id = allocationId;\n }\n return scope;\n}\n\n/**\n * The scope a request is for: the one its URL names, else the `scope` cookie.\n *\n * The URL wins because it is the newer choice: it is how a market is switched,\n * and the cookie still holds the one switched from. Merged with that cookie only\n * when both name the same scope; a different scope does not inherit the previous\n * one's branch. The type is store-wide, so it comes from the cookie, or is the\n * multi-market one when there is no cookie yet — the settings answer corrects it\n * for a store that browses by branch or city (see `rootBeforeLoad`).\n */\nexport function resolveRequestScope(url: string, cookieHeader: string | null): ActiveScope | null {\n const fromCookie = extractScopeFromCookies(cookieHeader);\n const fromUrl = extractScopeFromUrl(url);\n if (!fromUrl) return fromCookie;\n if (fromCookie?.id === fromUrl.id) return { ...fromCookie, ...fromUrl };\n return { ...fromUrl, type: fromCookie?.type ?? MARKET_SCOPE_TYPE };\n}\n\n/** {@link readSdkScope} reduced to the id; keeps the not-ready/none distinction. */\nexport function readSdkScopeId(): string | null | undefined {\n const scope = readSdkScope();\n return scope === undefined ? undefined : (scope?.id ?? null);\n}\n\n/** One year — the SDK keeps the selected branch in localStorage indefinitely. */\nexport const SCOPE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;\n\nexport const sameScope = (a: ActiveScope | null, b: ActiveScope | null): boolean =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Mirrors the scope the Salla SDK selected into the `scope` cookie so the SERVER\n * can see it. The SDK persists the selection in localStorage ONLY and writes no\n * cookie, so without this the server computes scope=null for every visitor who\n * picked a branch while the client computes the branch id — the dehydrated settings\n * query key never matches and the client refetches store settings on every page\n * load (SAL-122).\n *\n * Written in the SDK's own JSON shape so {@link extractScopeFromCookies} parses it,\n * allocation included: the bullet-delivery component writes the same cookie with the\n * full object, and rewriting it with the id alone would drop the branch the server\n * needs. Returns true when the cookie was (re)written. Client-only; no-op on the server.\n */\nexport function writeScopeCookie(scope: ActiveScope | null): boolean {\n if (typeof document === 'undefined') return false;\n if (sameScope(extractScopeFromCookies(document.cookie), scope)) return false;\n\n if (scope == null) {\n document.cookie = `${SCOPE_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n return true;\n }\n\n const value = encodeURIComponent(JSON.stringify(scope));\n document.cookie = `${SCOPE_COOKIE_NAME}=${value}; path=/; max-age=${SCOPE_COOKIE_MAX_AGE}; samesite=lax`;\n return true;\n}\n\n/**\n * Keeps the `scope` cookie in step with the SDK's selected branch. Call on every\n * client navigation; it no-ops while the SDK storage API is still hydrating so a\n * late-loading SDK can't wipe a valid cookie.\n */\nexport function syncScopeCookie(): boolean {\n const scope = readSdkScope();\n return scope === undefined ? false : writeScopeCookie(scope);\n}\n","/**\n * Escape a JSON-stringified value for safe embedding inside an inline `<script>` body.\n *\n * The head injects script bodies raw, so a `</script>` inside partner-set data would break out\n * of the tag; U+2028/U+2029 are line terminators in JS but not in JSON, so they must go too.\n */\nexport function escapeForInlineScript(value: string): string {\n return value\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n","import { escapeForInlineScript } from './inline-script';\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore } from './cookies';\n\n/** Where `rootHead` publishes the SSR-resolved env for the browser bundle to read. */\nconst RUNTIME_ENV_KEY = '__SALLA_RUNTIME_ENV__';\n\n/** The env values that must agree between the SSR render and the hydrated client. */\nexport interface RuntimeEnv {\n /** Store API base — `VITE_API_URL`. */\n apiBase?: string;\n /** Store identifier — `VITE_STORE_DOMAIN`. */\n storeIdentifier?: string;\n /**\n * The theme-settings version the request named, if any.\n *\n * Published for the same reason `storeIdentifier` is: the dispatcher strips\n * `?versionId=` on the way in, so by the time the browser has the page its own\n * URL no longer says which version it is showing. Without this the hydrated\n * client would ask the API about the store's live version and quietly replace\n * the draft it was handed.\n *\n * Absent — not empty — when nothing named one, so it drops out of the inline\n * script entirely rather than publishing a value that means \"live\".\n */\n versionId?: string;\n /**\n * The store segment at the root of this page's paths, when the store is\n * addressed that way — see `resolveStoreBase`.\n *\n * Published because the browser's address is not always the URL the server\n * read: the dispatcher removes `?storeId=` from the request it forwards but not\n * from the address bar, and a URL carrying it is never read for a segment. The\n * client builds its router from this, and a router that disagreed with the\n * server about the root would hydrate a different page.\n */\n storeBase?: string;\n /**\n * True when {@link storeBase} sits behind the locale (`/ar/dev-x/cart`), as on a\n * Salla shared host. Published with it: a client router that put the segment in\n * the other place would build every link to a page the dispatcher cannot route.\n * Absent when false, like the other flags here.\n */\n storeBaseFollowsLocale?: boolean;\n}\n\n/**\n * A build-time `import.meta.env` var, falling back to the worker's runtime `process.env`\n * (wrangler `vars`, exposed via the `nodejs_compat_populate_process_env` flag).\n */\nexport function readEnv(key: string): string | undefined {\n try {\n const vite = (import.meta as unknown as { env?: Record<string, string | undefined> }).env?.[\n key\n ];\n if (vite) return vite;\n } catch {\n /* import.meta.env not available in all environments */\n }\n return typeof process !== 'undefined' ? process.env?.[key] : undefined;\n}\n\n/**\n * What this runtime resolves from its own env — server-side that includes the worker vars.\n * Prefers what the server already published, so re-rendering the head during hydration yields\n * the same script instead of dropping it.\n */\nexport function resolveRuntimeEnv(): RuntimeEnv {\n const injected = getInjectedRuntimeEnv();\n const { storeId, storeBase, storeBaseFollowsLocale, versionId, requestHost } = getRequestStore();\n return {\n apiBase: injected.apiBase || readEnv('VITE_API_URL'),\n // The request outranks the build-time var here for the same reason it does\n // in `resolveStoreIdentifier`, and this is the copy that reaches the\n // browser: publish the store SSR actually rendered, or hydration resolves\n // again from a URL whose `?storeId=` the dispatcher has already stripped and\n // queries a different store than the markup it is hydrating.\n storeIdentifier:\n injected.storeIdentifier ||\n storeId ||\n storeBase ||\n (hostIdentifiesStore(requestHost) ? requestHost : null) ||\n readEnv('VITE_STORE_DOMAIN'),\n // Absent rather than empty when the path named no store, so it drops out of\n // the inline script, like `versionId`.\n storeBase: injected.storeBase || storeBase || undefined,\n storeBaseFollowsLocale:\n injected.storeBaseFollowsLocale || (storeBase ? storeBaseFollowsLocale : false) || undefined,\n // No env fallback on purpose. A store identifier has one because a build can\n // legitimately be pinned to a store; a version is something a request asks\n // for, and a build-time default would make every visitor of every store see\n // whichever draft was current when the theme was compiled.\n versionId: injected.versionId || versionId || undefined,\n };\n}\n\n/**\n * The env the SSR worker resolved, as handed to the browser by `rootHead`. Empty on the server\n * and on a client whose head carried nothing.\n *\n * Worker `vars` are *runtime* env: they live in `process.env` on the server only, while\n * `import.meta.env` is substituted at build time. A bundle built without those vars therefore\n * sees `undefined` in the browser and silently falls back to the production defaults — SSR\n * would render off the configured backend while every post-hydration fetch hits another one.\n */\nexport function getInjectedRuntimeEnv(): RuntimeEnv {\n const holder = globalThis as typeof globalThis & { [RUNTIME_ENV_KEY]?: RuntimeEnv };\n return holder[RUNTIME_ENV_KEY] ?? {};\n}\n\n/**\n * Inline head `<script>` body publishing the server-resolved env, or null when there is nothing\n * to publish (no overrides configured — the defaults already agree on both sides).\n */\nexport function renderRuntimeEnvScript(env: RuntimeEnv = resolveRuntimeEnv()): string | null {\n const set = Object.entries(env).filter(([, value]) => Boolean(value));\n if (!set.length) return null;\n const json = escapeForInlineScript(JSON.stringify(Object.fromEntries(set)));\n return `window.${RUNTIME_ENV_KEY}=${json};`;\n}\n","/**\n * @fileoverview The language of a page on a Salla shared host, where the URL does not carry it.\n *\n * On `demostore.salla.sa` and `salla.sa` a store is addressed `/dev-x/cart`. The route tree\n * still has a `/{-$locale}` segment, so the router puts a *virtual* locale in front of the\n * path on the way in and takes it off on the way out (`tanstack/store-base.ts`). This file\n * decides which one, and what to do when the choice is not one the store offers. See\n * `docs/store-base-path.md`.\n *\n * Pure: no request, no cookies written. The callers read and write those.\n */\nimport type { StoreContext } from '../api/store';\nimport { FALLBACK_LOCALE, isLocale } from '../providers/locale-constants';\nimport { extractTokenFromCookies, LANGUAGE_COOKIE_NAME, LANGUAGE_PARAM } from './cookies';\n\n/** A language code from a request, if it is one the engine knows. Case is not significant. */\nfunction knownLocale(value: string | null | undefined): string | null {\n const code = value?.toLowerCase();\n return isLocale(code) ? code : null;\n}\n\nfunction safeDecode(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** The value of `?lang=` in a query string (with or without the `?`), or null when absent. */\nfunction langParam(search: string): string | null {\n for (const part of search.replace(/^\\?/, '').split('&')) {\n const [key, value = ''] = part.split('=');\n if (safeDecode(key) === LANGUAGE_PARAM) return safeDecode(value);\n }\n return null;\n}\n\n/** Whether a query string (with or without the `?`) carries `lang`, whatever its value. */\nexport function hasLanguageParam(search: string): boolean {\n return langParam(search) !== null;\n}\n\n/** The language the `s-lang` cookie remembers, if it is a known one. */\nexport function languageFromCookies(cookieHeader: string | null): string | null {\n return knownLocale(extractTokenFromCookies(cookieHeader, LANGUAGE_COOKIE_NAME));\n}\n\n/**\n * The language a request on a shared host is for, before the store's settings are known:\n * `?lang=`, then the `s-lang` cookie, then {@link FALLBACK_LOCALE}. Each must be a language\n * the engine knows; whether the store offers it is {@link decideSharedHostLanguage}'s\n * question.\n */\nexport function virtualLocale(search: string, cookieHeader: string | null): string {\n return knownLocale(langParam(search)) ?? languageFromCookies(cookieHeader) ?? FALLBACK_LOCALE;\n}\n\n/** The ISO codes (lower case) a store lists, or null when its settings did not say. */\nfunction listedLocales(settings: StoreContext): string[] | null {\n const codes = (settings.languages ?? [])\n .map((language) => (language.iso_code ?? language.code)?.toLowerCase())\n .filter((code): code is string => Boolean(code));\n return codes.length ? codes : null;\n}\n\n/**\n * Whether the store has more than one language to choose between.\n *\n * Both signals count: the merchant's `is_multilingual` switch, and the number of languages\n * the settings list. Either one saying \"single\" makes the store single-language. The count\n * is only used when the settings carry the list at all.\n */\nexport function isMultilingualStore(settings: StoreContext | null | undefined): boolean {\n if (settings?.store?.settings?.is_multilingual === false) return false;\n return settings?.languages == null || settings.languages.length >= 2;\n}\n\n/** The store's default language: the one marked, else the engine's fallback, else the first listed. */\nexport function defaultLanguage(settings: StoreContext): string | null {\n const listed = listedLocales(settings);\n if (!listed) return null;\n const marked = settings.languages?.find((language) => Boolean(language.is_default));\n const markedCode = (marked?.iso_code ?? marked?.code)?.toLowerCase();\n if (markedCode) return markedCode;\n return listed.includes(FALLBACK_LOCALE) ? FALLBACK_LOCALE : listed[0];\n}\n\n/**\n * The languages this store can be shown in, or null when its settings did not list any\n * (nothing to check against). A store that is not multilingual shows its default only.\n */\nexport function offeredLanguages(settings: StoreContext): string[] | null {\n const listed = listedLocales(settings);\n if (!listed) return null;\n if (isMultilingualStore(settings)) return listed;\n const only = defaultLanguage(settings);\n return only ? [only] : listed;\n}\n\n/** `search` (a query string, with or without `?`) without `lang`, and then `lang=<code>` if given. */\nexport function withLanguageParam(search: string, code?: string): string {\n const kept = search\n .replace(/^\\?/, '')\n .split('&')\n .filter((part) => part && safeDecode(part.split('=')[0]) !== LANGUAGE_PARAM);\n if (code) kept.push(`${LANGUAGE_PARAM}=${encodeURIComponent(code)}`);\n return kept.length ? `?${kept.join('&')}` : '';\n}\n\nexport interface SharedHostLanguage {\n /** A language to remember in the `s-lang` cookie, or null to leave the cookie alone. */\n cookie: string | null;\n /** Where to send the visitor (path, query and hash, in the address the browser uses), or null to render. */\n redirectTo: string | null;\n}\n\n/**\n * What to do with the language of a page on a shared host, once the store's settings are in.\n *\n * - `?lang=` asking for a language the store offers is remembered in the cookie. It is taken\n * off the URL with a redirect when that cannot change what the next request renders: the\n * cookie already says it, or it is the fallback a cookieless request gets anyway. Otherwise\n * it stays, so a visitor whose browser drops the cookie is not sent round in circles.\n * - `?lang=` asking for one the store does not offer is dropped, and nothing is remembered.\n * - No `?lang=`, and the language the request resolved to is not offered (a stale cookie\n * from another store on this host, or the fallback of a store that does not offer it):\n * sent to `?lang=<the store's default>`.\n *\n * Every redirect either removes `?lang=` or adds one for an offered language, so none\n * returns the request to itself.\n *\n * @param href - the browser's address for this page: path (with the store segment, without\n * a language), query and hash.\n * @param locale - the language the request resolved to ({@link virtualLocale}).\n */\nexport function decideSharedHostLanguage(args: {\n settings: StoreContext;\n locale: string;\n href: string;\n cookieHeader: string | null;\n}): SharedHostLanguage {\n const { settings, locale, href, cookieHeader } = args;\n const offered = offeredLanguages(settings);\n const url = new URL(href, 'http://shared-host.invalid');\n const withSearch = (search: string) => `${url.pathname}${search}${url.hash}`;\n\n const asked = langParam(url.search);\n if (asked !== null) {\n const wanted = knownLocale(asked);\n if (!wanted || (offered && !offered.includes(wanted))) {\n return { cookie: null, redirectTo: withSearch(withLanguageParam(url.search)) };\n }\n const remembered = languageFromCookies(cookieHeader);\n const clean = remembered === wanted || wanted === FALLBACK_LOCALE;\n return {\n cookie: remembered === wanted ? null : wanted,\n redirectTo: clean ? withSearch(withLanguageParam(url.search)) : null,\n };\n }\n\n if (offered && !offered.includes(locale)) {\n const fallback = defaultLanguage(settings) as string;\n return { cookie: null, redirectTo: withSearch(withLanguageParam(url.search, fallback)) };\n }\n return { cookie: null, redirectTo: null };\n}\n","/**\n * @fileoverview Paths on a host where the store is part of every address.\n *\n * On `preview.salla.design` and a dev server a store is addressed by the first\n * segment of the path — `/mtgr-alaatr-2/cart` — and that segment is the root of\n * the application. No route knows about it: the router takes it off every URL on\n * the way in and puts it back on every URL on the way out\n * (`tanstack/store-base.ts`), so pages, links and loaders all see `/cart`.\n *\n * On a Salla shared host (`demostore.salla.sa`, `salla.sa`) the store is the\n * root too — `/dev-x/cart`, with no language in the address — and the storefront\n * dispatcher names it (`resolveAddressedStore`). The old shape, `/ar/dev-x/cart`,\n * is still read, and redirected once by `twilightMiddleware`. The same two\n * functions move the segment, told which host it is.\n *\n * Which segment it is, and on which hosts, is decided once, in `utils/cookies.ts`.\n * This file only moves it on and off a path. See `docs/store-base-path.md`.\n */\nimport { allowsRequestStoreId, isStoreBaseSegment, STORE_ID_PARAM } from './cookies';\nimport { isLocale } from '../providers/locale-constants';\nimport { withLanguageParam } from './shared-host-language';\n\n/**\n * An application pathname, without the store segment in front.\n *\n * Only a whole segment is removed, so `/mtgr-alaatr-2x/cart` is left alone, and a\n * pathname that does not start with the segment comes back unchanged.\n *\n * With `followsLocale` the segment is also taken from behind a leading locale,\n * where Salla's shared hosts used to put it (`/ar/dev-x/cart` → `/ar/cart`). It is\n * looked for there first, then at the root, which is where it is now\n * (`/dev-x/cart`).\n */\nexport function stripStoreBase(pathname: string, base: string, followsLocale = false): string {\n if (followsLocale) {\n const segments = pathname.split('/');\n if (isLocale(segments[1]) && segments[2] === base) {\n segments.splice(2, 1);\n return segments.join('/');\n }\n }\n\n const prefix = `/${base}`;\n if (pathname === prefix) return '/';\n return pathname.startsWith(`${prefix}/`) ? pathname.slice(prefix.length) : pathname;\n}\n\n/**\n * A rooted path split into its first segment and what follows it (a path, a query, a hash, or\n * nothing). The segment ends at the first `/`, `?` or `#`. Plain string work, no pattern.\n */\nexport function splitLeadingSegment(rooted: string): { first: string; rest: string } {\n if (!rooted.startsWith('/')) return { first: '', rest: '' };\n let end = 1;\n while (end < rooted.length && rooted[end] !== '/' && rooted[end] !== '?' && rooted[end] !== '#') {\n end += 1;\n }\n return { first: rooted.slice(1, end), rest: rooted.slice(end) };\n}\n\n/**\n * An application path as the browser addresses it, with the store segment in front.\n *\n * It never checks whether the segment is already there, because that cannot be\n * told apart from a page of the same name: a store called `cart` keeps its cart at\n * `/cart/cart`. Callers pass application paths only.\n *\n * With `followsLocale` (a Salla shared host) the address has no language in it at\n * all: a leading locale is dropped (`/ar/cart` → `/dev-x/cart`). The language comes\n * back from `?lang=` or the `s-lang` cookie on the way in (`tanstack/store-base.ts`).\n */\nexport function prefixStoreBase(path: string, base: string, followsLocale = false): string {\n let rooted = path.startsWith('/') ? path : `/${path}`;\n\n if (followsLocale) {\n const { first, rest } = splitLeadingSegment(rooted);\n // What follows the locale is a path (`/cart`), a query or a hash, or nothing: the root.\n if (isLocale(first)) rooted = rest.startsWith('/') ? rest : `/${rest}`;\n }\n\n // The store's root is `/<base>`, not `/<base>/`, with or without a query or hash.\n const atRoot = rooted === '/' || rooted[1] === '?' || rooted[1] === '#';\n return `/${base}${atRoot ? rooted.slice(1) : rooted}`;\n}\n\n/**\n * Where to send a request that still uses the old shared-host address, or null when it\n * does not.\n *\n * Shared hosts used to put the language in front of the store (`/ar/dev-x/cart`) and now\n * leave it out (`/dev-x/cart`). A link in the old shape is sent once to the new one,\n * carrying its language as `?lang=` so the visitor keeps it; the page then remembers it\n * and the language stays out of the address (`rootBeforeLoad`).\n *\n * Only a path that *starts* with a locale and then names this store as a whole segment\n * matches, so a page whose slug is a locale code, or that is spelled like the store, is\n * never redirected. The result is a relative path: it cannot leave the host.\n */\nexport function legacyLocaleRedirectHref(url: string, base: string): string | null {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n\n const segments = parsed.pathname.split('/');\n if (!isLocale(segments[1]) || segments[2] !== base) return null;\n\n const pathname = ['', base, ...segments.slice(3)].join('/');\n // An explicit `?lang=` outranks the old path's language, as it did when it was rewritten\n // into the path.\n const search = parsed.searchParams.has('lang')\n ? parsed.search\n : withLanguageParam(parsed.search, segments[1]);\n return `${pathname}${search}`;\n}\n\n/**\n * A pathname from a link the Salla API handed out, without the store's username in it.\n *\n * A store with no domain of its own is served under its username on a shared host,\n * and every URL the API returns for it carries that segment. Its `store.url` is\n * `/{lang}/{username}/` when the store is multilingual and `/{username}/` when it is\n * not: `https://demostore.salla.sa/ar/dev-vgckq3fssfhjewwi/`, `https://salla.sa/cart/`.\n * The segment there belongs to Salla's host, not to the application. Left in, it\n * lands where a page slug is expected and matches no route.\n *\n * The username is the last segment of `store.url`, but only when it equals the\n * store's username. Neither its position nor its spelling says so on its own: `/ar/`\n * is the locale of `https://3tir.com/ar/`, a store on its own domain whose links carry\n * no username, and it is also the whole address of the store called `ar`,\n * `https://salla.sa/ar/`. Without a username to compare against, a last segment\n * spelled like a locale is taken to be one, which is wrong only for a store whose\n * username is a locale code.\n *\n * The locale stays wherever the link put it.\n */\nexport function withoutStoreUrlBase(\n pathname: string,\n storeUrlPathname: string,\n username?: string | null\n): string {\n const own = storeUrlSegment(storeUrlPathname, username);\n if (!own) return pathname;\n\n const segments = pathname.split('/');\n // Salla puts the locale first (`/ar/dev-x/…`); a store that is not multilingual has\n // none (`/dev-x/…`). Checked in that order, `/ar/ar/…` for a store called `ar` keeps\n // its locale.\n let at = -1;\n if (isLocale(segments[1]) && segments[2] === own) at = 2;\n else if (segments[1] === own) at = 1;\n if (at === -1) return pathname;\n\n segments.splice(at, 1);\n return segments.join('/') || '/';\n}\n\n/**\n * Whether a pathname on the store's host is this store's.\n *\n * On a shared host the origin belongs to every store there, and a link names its store\n * by the username in its path, where {@link withoutStoreUrlBase} looks for it. One\n * without it is another store's page, or the host's own. A store on its own domain has\n * no such segment, and every path on its host is its own.\n */\nexport function hasStoreUrlBase(\n pathname: string,\n storeUrlPathname: string,\n username?: string | null\n): boolean {\n const own = storeUrlSegment(storeUrlPathname, username);\n if (!own) return true;\n\n const segments = pathname.split('/');\n return segments[1] === own || (isLocale(segments[1]) && segments[2] === own);\n}\n\n/** The segment `store.url` serves the store under, or null when it has none. */\nfunction storeUrlSegment(storeUrlPathname: string, username?: string | null): string | null {\n const last = storeUrlPathname.split('/').filter(Boolean).pop();\n if (!last) return null;\n if (username) return last === username ? last : null;\n return isLocale(last) ? null : last;\n}\n\n/**\n * Where to send a page whose store was not named by its own first segment, or null\n * when it already was.\n *\n * On a host where the store is the root, every page has one address,\n * `/<username>/…`. A request that found its store some other way (`?storeId=`, the\n * preview cookie, `VITE_STORE_DOMAIN`, or a first segment that named the store by\n * another spelling, such as its numeric id) is sent there once the store's settings\n * say what its username is.\n *\n * `storeId` is dropped from the query on the way. It has to be: a URL carrying it\n * is never read for a store segment, so keeping it would redirect to an address\n * that redirects again, forever. For the same reason a username that could not be\n * read back out of a path produces no redirect at all.\n *\n * `href` is the application's own href (path, query and hash, already without any\n * store segment), which the router keeps percent-encoded, so the result is safe to\n * put in a `Location` header.\n */\nexport function storeBaseRedirectHref(args: {\n host: string | null | undefined;\n base: string | null;\n username: string | null | undefined;\n href: string;\n}): string | null {\n const { host, base, username, href } = args;\n if (!allowsRequestStoreId(host) || !isStoreBaseSegment(username) || username === base) {\n return null;\n }\n\n const url = new URL(href, 'http://store-base.invalid');\n url.searchParams.delete(STORE_ID_PARAM);\n return `${prefixStoreBase(url.pathname, username)}${url.search}${url.hash}`;\n}\n\n/**\n * Where to send a guest who opened a customer-only page: the locale's home with\n * `intended_to`, which the SDK reads to open the login modal and come back after.\n * Null when already there, so the redirect cannot loop.\n */\nexport function loginRedirectHref(args: {\n pathname: string;\n searchStr: string;\n origin: string;\n base: string | null;\n baseFollowsLocale?: boolean;\n}): string | null {\n const { pathname, searchStr, origin, base, baseFollowsLocale = false } = args;\n const first = pathname.split('/')[1];\n const home = isLocale(first) ? `/${first}` : '/';\n if ((pathname.replace(/\\/$/, '') || '/') === home) return null;\n\n const browserPath = (path: string) =>\n base ? prefixStoreBase(path, base, baseFollowsLocale) : path;\n const intended = `${origin}${browserPath(pathname)}${searchStr}`;\n return `${browserPath(home)}?intended_to=${encodeURIComponent(intended)}`;\n}\n","/**\n * @fileoverview Which store to ask about — the one answer, in one place.\n *\n * This lived in two places once. `api/store.ts` learned to read the store a\n * request names, and `utils/sdk-helpers.ts` — the copy `api/client.ts` actually\n * sets the `store-identifier` header from — did not. So the resolver that had\n * been taught the answer was consulted for a null check and thrown away, every\n * outgoing request carried an empty identifier, the API answered\n * `422 Store Identifier not found`, and every published theme rendered\n * \"Store Unavailable\" while its tests passed: the client's suite mocked the\n * resolver, and the resolver's suite never went near a request.\n *\n * Hence one module, imported by both. If a third place ever needs a store\n * identifier, it imports this — a second implementation is the bug, not a\n * refactor away from it.\n *\n * See `docs/store-identity.md` for the full picture, including the security\n * boundary on who may name a store.\n */\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore, resolveRequestStoreBase } from './cookies';\nimport { getInjectedRuntimeEnv, readEnv } from './runtime-env';\nimport { storeBaseRedirectHref } from './store-base';\n\n/**\n * Which store to ask about, in the order the answers can be trusted.\n *\n * A deployed theme worker is published with **no vars and no bindings** — the\n * script metadata carries `main_module`, compatibility settings, assets and tags\n * and nothing else — so `VITE_STORE_DOMAIN` exists only where a build baked it\n * in, which is local development. In production this function used to reach the\n * end of that chain and return the empty string, `store.settings` refused to\n * call with no identifier, and the root loader threw \"Store Unavailable\" — a\n * theme that renders its own failure page for every visitor of every store.\n *\n * The order:\n *\n * 1. what the caller passed, which is always deliberate;\n * 2. the store this request names — the `?storeId=` a preview was opened with,\n * then the cookie remembering it — seeded by `twilightMiddleware`, and only\n * on a host permitted to name one;\n * 3. the store the first segment of the path names, on those same hosts — its\n * username, which the API accepts as an identifier as readily as an id (see\n * {@link resolveStoreBase});\n * 4. what SSR already resolved and published, so the hydrated client asks about\n * the same store the server rendered instead of resolving again from a URL\n * that no longer names it;\n * 5. the request's own host, which *is* the identity of a live storefront —\n * but only when that host is a storefront. `preview.salla.design` and\n * `localhost` serve many stores, so their names identify none;\n * 6. `VITE_STORE_DOMAIN`, last, because a build-time constant is a development\n * convenience and must never outrank what the request actually said.\n *\n * Steps 2 and 3 never both answer: a path that names a store takes the place of\n * the cookie, and a URL carrying `?storeId=` is not read for a path segment.\n */\nexport function resolveStoreIdentifier(explicit?: string): string {\n if (explicit) return explicit;\n\n const { storeId, requestHost } = getRequestStore();\n if (storeId) return storeId;\n\n const storeBase = resolveStoreBase();\n if (storeBase) return storeBase;\n\n const injected = getInjectedRuntimeEnv().storeIdentifier;\n if (injected) return injected;\n\n if (hostIdentifiesStore(requestHost)) return requestHost as string;\n\n // The browser's own address, for a client render that reached neither of the\n // above — a live storefront, where the host is the store.\n const browserHost = typeof window !== 'undefined' ? window.location.host : null;\n if (hostIdentifiesStore(browserHost)) return browserHost as string;\n\n return readEnv('VITE_STORE_DOMAIN') || readEnv('STORE_DOMAIN') || '';\n}\n\n/**\n * The store segment at the root of this page's paths, or null when the store is\n * not addressed that way.\n *\n * On the server it is what `twilightMiddleware` read off the request. In the\n * browser it is what SSR published, because the address bar is not always the\n * URL the server rendered: on the preview host the dispatcher removes\n * `?storeId=` from the request it forwards and leaves it in the browser's, and a\n * URL carrying `storeId` is never read for a segment. Re-reading\n * `window.location` would, for `/ar?storeId=…`, route the page under a different\n * store than the one it was rendered for.\n *\n * The address bar is read only when SSR published nothing at all: a page the dev\n * server answered with its client shell instead of a render, where there is no\n * server decision to agree with.\n */\nexport function resolveStoreBase(): string | null {\n const { storeBase } = getRequestStore();\n if (storeBase) return storeBase;\n if (typeof window === 'undefined') return null;\n\n const published = getInjectedRuntimeEnv();\n if (published.storeBase) return published.storeBase;\n if (Object.keys(published).length > 0) return null;\n\n return resolveRequestStoreBase(window.location.href, window.location.host);\n}\n\n/**\n * Whether {@link resolveStoreBase}'s segment sits behind the locale\n * (`/ar/dev-x/cart`) rather than at the root of the path.\n *\n * True only on a Salla shared host, where the dispatcher named the store. Read\n * from the same place as the segment, so the two always describe one address: the\n * request on the server, what SSR published in the browser.\n */\nexport function resolveStoreBaseFollowsLocale(): boolean {\n const { storeBase, storeBaseFollowsLocale } = getRequestStore();\n if (storeBase) return storeBaseFollowsLocale;\n if (typeof window === 'undefined') return false;\n\n const published = getInjectedRuntimeEnv();\n return Boolean(published.storeBase && published.storeBaseFollowsLocale);\n}\n\n/**\n * The address this page should be loaded from instead, when the store is the root\n * of every URL on this host and this request did not use it; null otherwise.\n *\n * @param username - the store's username, from the settings the request loaded\n * @param href - the router's own href for the page, without any store segment\n *\n * See `storeBaseRedirectHref` for the rules. The host is the request's on the\n * server and the browser's own in the browser, so the decision is gated the same\n * way on both sides.\n */\nexport function resolveStoreBaseRedirect(\n username: string | null | undefined,\n href: string\n): string | null {\n const host =\n getRequestStore().requestHost ?? (typeof window !== 'undefined' ? window.location.host : null);\n return storeBaseRedirectHref({ host, base: resolveStoreBase(), username, href });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/maintenance.ts"],"names":[],"mappings":";;;AAgBO,IAAM,yBAAA,GAA4B;AAEzC,IAAM,aAAA,GAAgB,CAAC,WAAA,EAAa,QAAQ,CAAA;AAG5C,SAAS,UAAU,QAAA,EAA0D;AAC3E,EAAA,MAAM,EAAA,GAAK,UAAU,KAAA,EAAO,EAAA;AAC5B,EAAA,OAAO,EAAA,IAAM,IAAA,GAAO,IAAA,GAAO,MAAA,CAAO,EAAE,CAAA;AACtC;AAOO,SAAS,gBAAA,CAAiB,MAAc,QAAA,EAAoD;AACjG,EAAA,MAAM,OAAA,GAAU,UAAU,QAAQ,CAAA;AAClC,EAAA,IAAI,CAAC,SAAS,OAAO,KAAA;AACrB,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,IAAA,EAAM,kBAAkB,CAAA,CAAE,YAAA;AAAA,EAC7C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,GAAA,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intenanceDetails } from '../types';\nimport { extractTokenFromCookies } from './cookies';\n\n/**\n * Remembers that this browser is the merchant looking at their own closed store.\n *\n * The dashboard's \"view store\" link carries `?utm_source=dashboard&identifier=<store id>`\n * (`portal` for the partners portal). Twig's backend checks that once, keeps\n * `view-as: owner` in the PHP session and lets every later request through; this\n * cookie is that session entry. No `max-age`: a session cookie, as the PHP session\n * was, so closing the browser ends the owner view.\n *\n * The value is the store id the bypass was granted for, checked against the store\n * the settings answer about, so one store's cookie opens no other store.\n */\nexport const VIEW_AS_OWNER_COOKIE_NAME = 'salla_view_as';\n\nconst OWNER_SOURCES = ['dashboard', 'portal'];\n\n/** The id as the URL and the cookie spell it, or null when the settings name none. */\nfunction storeIdOf(settings: StoreContext | null | undefined): string | null {\n const id = settings?.store?.id;\n return id == null ? null : String(id);\n}\n\n/**\n * Whether `href` is the dashboard's link into the merchant's own store:\n * `utm_source` is `dashboard` or `portal`, and `identifier` is this store's id.\n * The backend's own rule, translated.\n */\nexport function ownerLinkMatches(href: string, settings: StoreContext | null | undefined): boolean {\n const storeId = storeIdOf(settings);\n if (!storeId) return false;\n let params: URLSearchParams;\n try {\n params = new URL(href, 'http://localhost').searchParams;\n } catch {\n return false;\n }\n const source = params.get('utm_source');\n return source != null && OWNER_SOURCES.includes(source) && params.get('identifier') === storeId;\n}\n\n/** Whether the cookie remembers an owner view of this store. */\nexport function ownerCookieMatches(\n cookieHeader: string | null,\n settings: StoreContext | null | undefined\n): boolean {\n const storeId = storeIdOf(settings);\n return !!storeId && extractTokenFromCookies(cookieHeader, VIEW_AS_OWNER_COOKIE_NAME) === storeId;\n}\n\n/**\n * Whether this visitor gets the maintenance page instead of the store.\n *\n * True only when the settings say the store is closed and nothing lets the visitor\n * through: neither an owner view (the link or the cookie) nor the theme editor's\n * preview, which the backend also always lets in.\n */\nexport function showsMaintenancePage(\n settings: StoreContext | null | undefined,\n viewAsOwner: boolean\n): boolean {\n return settings?.maintenance === true && !viewAsOwner && settings.theme?.mode !== 'preview';\n}\n\n/**\n * The response header a maintenance 503 carries saying which settings decided it.\n *\n * Theme workers write no logs, and the dispatcher's line for a 5xx records the\n * answer's own `x-trace-id` and this header, so the evidence travels on the answer.\n * The backend sets `maintenance` from store-wide state alone (closed, not launched,\n * or the market in maintenance), so `request-id` and `trace` find the settings\n * request it logged, and `cache`/`age` say whether this was a cached copy of one.\n */\nexport const MAINTENANCE_EVIDENCE_HEADER = 'x-twilight-maintenance';\n\n/**\n * What the maintenance decision rested on, as `key=value` pairs. Ids and the API's\n * own header values only: nothing a visitor typed, nothing that identifies them.\n */\nexport function maintenanceEvidence(\n settings: StoreContext | null | undefined\n): Record<string, string> {\n const evidence: Record<string, string> = {};\n if (!settings) return evidence;\n for (const [key, read] of EVIDENCE) {\n const value = read(settings);\n if (value != null && value !== '') evidence[key] = String(value);\n }\n return evidence;\n}\n\nconst EVIDENCE: [string, (settings: StoreContext) => unknown][] = [\n ['store', (s) => s.store?.id],\n ['scope', (s) => s.store?.scope?.id],\n ['requested-scope', (s) => s.requestedScopeId],\n ['mode', (s) => s.theme?.mode],\n ['request-id', (s) => s.answer?.requestId],\n ['trace', (s) => s.answer?.traceId],\n ['cache', (s) => s.answer?.cacheStatus],\n ['age', (s) => s.answer?.age],\n];\n\n/** {@link maintenanceEvidence} as one header value: `store=1; scope=2; cache=HIT`. */\nexport function maintenanceEvidenceHeader(evidence: Record<string, string>): string {\n return Object.entries(evidence)\n .map(([key, value]) => `${key}=${value.replace(/[^\\x21-\\x7e]/g, '')}`)\n .join('; ');\n}\n\n// todo:: drop both once the backend sends `dashboard_url` (or the filled `button_*`) in the\n// settings; until then this mirrors `config('salla.app.dashboard_url')` and the path Twig's\n// `StoreStatusAlertWidget` appends for the owner.\nconst DASHBOARD_URL = 'https://s.salla.sa';\n\n/** The dashboard page where the merchant turns maintenance mode off, as the backend links it. */\nexport const MAINTENANCE_SETTINGS_URL = `${DASHBOARD_URL}/channel/settings?legacy=0#maintenance-mode`;\n\n/**\n * Whether the notice is the one the backend sends for a store that has not launched yet.\n *\n * The settings carry no `launched` flag: a store whose `store::launched` setting is `0`\n * gets `maintenance: true` and `StoreStatusAlertWidget::getData(true)`, the merchant's\n * \"finish launching\" notice, whose button goes to the dashboard's root, and it goes\n * there for every visitor. A closed store's notice links nowhere for a customer and to\n * {@link MAINTENANCE_SETTINGS_URL} for the owner, so the bare dashboard URL tells them\n * apart, as Twig's `CheckStoreStatus` does by rendering `construction` instead of\n * `maintenance`.\n */\n// todo:: read the backend's own flag once the settings send one.\nexport function isNotLaunchedNotice(details: MaintenanceDetails | null | undefined): boolean {\n return details?.button_url?.replace(/\\/+$/, '') === DASHBOARD_URL;\n}\n\n/**\n * The button on the SDK's merchant maintenance bar. The API fills the `button_*`\n * fields only inside Twig's owner session, which the engine's settings request has\n * none of, so the SDK, handed the settings as they are, draws an empty button. The\n * SDK renders only in the store view, so `maintenance: true` there means the owner\n * (or the preview, where the SDK mounts no bar): the three fields get what Twig's\n * owner branch gives them. The merchant's own title and message stay as they are.\n */\nexport function withOwnerMaintenanceButton<\n T extends Pick<StoreContext, 'maintenance' | 'maintenance_details'>,\n>(settings: T, buttonTitle: string): T {\n const details = settings.maintenance_details;\n if (settings.maintenance !== true || details?.button_title) return settings;\n return {\n ...settings,\n maintenance_details: {\n ...details,\n button_title: buttonTitle,\n button_full_title: buttonTitle,\n button_url: MAINTENANCE_SETTINGS_URL,\n },\n };\n}\n"]}