@salla.sa/twilight-theme-engine 1.0.150 → 1.0.152

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 (260) hide show
  1. package/dist/{AddToCartForm-P5Q4P763.js → AddToCartForm-HOBSTMWX.js} +3 -3
  2. package/dist/{AddToCartForm-P5Q4P763.js.map → AddToCartForm-HOBSTMWX.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-Z3R6AETN.js → BlogAuthorPage-56OY5GCN.js} +27 -27
  4. package/dist/{BlogAuthorPage-Z3R6AETN.js.map → BlogAuthorPage-56OY5GCN.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-7VROFBGI.js → BlogCategoryPage-HW7A6RNL.js} +27 -27
  6. package/dist/{BlogCategoryPage-7VROFBGI.js.map → BlogCategoryPage-HW7A6RNL.js.map} +1 -1
  7. package/dist/{BlogPage-Q2NN4WTB.js → BlogPage-RRHKP3GP.js} +25 -25
  8. package/dist/{BlogPage-Q2NN4WTB.js.map → BlogPage-RRHKP3GP.js.map} +1 -1
  9. package/dist/{BlogSinglePage-ZPCSNBIX.js → BlogSinglePage-STNMFQHX.js} +25 -25
  10. package/dist/{BlogSinglePage-ZPCSNBIX.js.map → BlogSinglePage-STNMFQHX.js.map} +1 -1
  11. package/dist/{BlogTagPage-IGG2VEMR.js → BlogTagPage-YD3EPTQY.js} +27 -27
  12. package/dist/{BlogTagPage-IGG2VEMR.js.map → BlogTagPage-YD3EPTQY.js.map} +1 -1
  13. package/dist/{BrandsPage-ZAJT6RGM.js → BrandsPage-KJFB4QBN.js} +26 -26
  14. package/dist/{BrandsPage-ZAJT6RGM.js.map → BrandsPage-KJFB4QBN.js.map} +1 -1
  15. package/dist/{Breadcrumb-KE4EWH7L.js → Breadcrumb-QKHYTTFB.js} +25 -25
  16. package/dist/{Breadcrumb-KE4EWH7L.js.map → Breadcrumb-QKHYTTFB.js.map} +1 -1
  17. package/dist/{CartItem-RMCXCGHT.js → CartItem-DCCYGMRI.js} +25 -25
  18. package/dist/{CartItem-RMCXCGHT.js.map → CartItem-DCCYGMRI.js.map} +1 -1
  19. package/dist/{CartSummary-NLEAHKWF.js → CartSummary-DAAYDRFS.js} +25 -25
  20. package/dist/{CartSummary-NLEAHKWF.js.map → CartSummary-DAAYDRFS.js.map} +1 -1
  21. package/dist/{Copyright-EIBPTE3B.js → Copyright-GL5Q4FTN.js} +3 -3
  22. package/dist/{Copyright-EIBPTE3B.js.map → Copyright-GL5Q4FTN.js.map} +1 -1
  23. package/dist/{CustomerLayout-POGWFN6R.js → CustomerLayout-D7HC4G7V.js} +25 -25
  24. package/dist/{CustomerLayout-POGWFN6R.js.map → CustomerLayout-D7HC4G7V.js.map} +1 -1
  25. package/dist/{Footer-LGIUINGS.js → Footer-3NQWLPAA.js} +4 -4
  26. package/dist/{Footer-LGIUINGS.js.map → Footer-3NQWLPAA.js.map} +1 -1
  27. package/dist/{Header-4TGYO6E4.js → Header-SCR46P4B.js} +11 -11
  28. package/dist/{Header-4TGYO6E4.js.map → Header-SCR46P4B.js.map} +1 -1
  29. package/dist/{LatestProducts-YYKQNL5N.js → LatestProducts-4UML6BNG.js} +27 -27
  30. package/dist/{LatestProducts-YYKQNL5N.js.map → LatestProducts-4UML6BNG.js.map} +1 -1
  31. package/dist/{LoyaltyPage-MROFMZXV.js → LoyaltyPage-CQIUT7MD.js} +25 -25
  32. package/dist/{LoyaltyPage-MROFMZXV.js.map → LoyaltyPage-CQIUT7MD.js.map} +1 -1
  33. package/dist/{LoyaltyPointsPage-DVHJOAKP.js → LoyaltyPointsPage-ZOZFDRZT.js} +8 -8
  34. package/dist/{LoyaltyPointsPage-DVHJOAKP.js.map → LoyaltyPointsPage-ZOZFDRZT.js.map} +1 -1
  35. package/dist/{MainMenu-GQO5KOTU.js → MainMenu-YLCB4MT7.js} +7 -7
  36. package/dist/{MainMenu-GQO5KOTU.js.map → MainMenu-YLCB4MT7.js.map} +1 -1
  37. package/dist/{MasterLayout-ZJBJ7EHM.js → MasterLayout-BDDKPLS6.js} +25 -25
  38. package/dist/{MasterLayout-ZJBJ7EHM.js.map → MasterLayout-BDDKPLS6.js.map} +1 -1
  39. package/dist/{MobileMenu-TZSFYHPW.js → MobileMenu-S5LB622I.js} +26 -26
  40. package/dist/{MobileMenu-TZSFYHPW.js.map → MobileMenu-S5LB622I.js.map} +1 -1
  41. package/dist/{NotificationsPage-BX6OSIDY.js → NotificationsPage-FPF7UU3Q.js} +25 -25
  42. package/dist/{NotificationsPage-BX6OSIDY.js.map → NotificationsPage-FPF7UU3Q.js.map} +1 -1
  43. package/dist/{OrderSinglePage-3RQ5TJDB.js → OrderSinglePage-M37ROUBX.js} +26 -26
  44. package/dist/{OrderSinglePage-3RQ5TJDB.js.map → OrderSinglePage-M37ROUBX.js.map} +1 -1
  45. package/dist/{OrdersPage-S4ECYNGI.js → OrdersPage-GIZFTPQ7.js} +25 -25
  46. package/dist/{OrdersPage-S4ECYNGI.js.map → OrdersPage-GIZFTPQ7.js.map} +1 -1
  47. package/dist/{PageSingle-BZGDC4VE.js → PageSingle-EQD5Y3L5.js} +6 -6
  48. package/dist/{PageSingle-BZGDC4VE.js.map → PageSingle-EQD5Y3L5.js.map} +1 -1
  49. package/dist/{ProductDetails-ZPRWPSVK.js → ProductDetails-53BXVF37.js} +7 -7
  50. package/dist/{ProductDetails-ZPRWPSVK.js.map → ProductDetails-53BXVF37.js.map} +1 -1
  51. package/dist/{ProfilePage-SKAS6LFQ.js → ProfilePage-6GJXTBFN.js} +25 -25
  52. package/dist/{ProfilePage-SKAS6LFQ.js.map → ProfilePage-6GJXTBFN.js.map} +1 -1
  53. package/dist/{ReviewsPage-NAZWXVXT.js → ReviewsPage-SCHVMKXV.js} +3 -3
  54. package/dist/{ReviewsPage-NAZWXVXT.js.map → ReviewsPage-SCHVMKXV.js.map} +1 -1
  55. package/dist/{SeoCartWidget-6NB6LT2Z.js → SeoCartWidget-IUXLYOTC.js} +25 -25
  56. package/dist/{SeoCartWidget-6NB6LT2Z.js.map → SeoCartWidget-IUXLYOTC.js.map} +1 -1
  57. package/dist/{SettingsPage-GZ2NJIUR.js → SettingsPage-2TKL2COF.js} +25 -25
  58. package/dist/{SettingsPage-GZ2NJIUR.js.map → SettingsPage-2TKL2COF.js.map} +1 -1
  59. package/dist/{StoreClosedNotification-V72F7HE5.js → StoreClosedNotification-HHOQXT6N.js} +26 -26
  60. package/dist/{StoreClosedNotification-V72F7HE5.js.map → StoreClosedNotification-HHOQXT6N.js.map} +1 -1
  61. package/dist/{TestimonialsPage-L6VBZFLT.js → TestimonialsPage-GJJT7F5G.js} +6 -6
  62. package/dist/{TestimonialsPage-L6VBZFLT.js.map → TestimonialsPage-GJJT7F5G.js.map} +1 -1
  63. package/dist/{ThankYouPage-O5U3V6J4.js → ThankYouPage-ZAEZWSUK.js} +25 -25
  64. package/dist/{ThankYouPage-O5U3V6J4.js.map → ThankYouPage-ZAEZWSUK.js.map} +1 -1
  65. package/dist/{WalletPage-NJBBZIMM.js → WalletPage-74LAUONG.js} +26 -26
  66. package/dist/{WalletPage-NJBBZIMM.js.map → WalletPage-74LAUONG.js.map} +1 -1
  67. package/dist/{WebMcpTools-VAZH3S5G.js → WebMcpTools-J6HCO5B6.js} +9 -9
  68. package/dist/{WebMcpTools-VAZH3S5G.js.map → WebMcpTools-J6HCO5B6.js.map} +1 -1
  69. package/dist/{WishlistPage-UKOGNFKB.js → WishlistPage-SV55V5CP.js} +27 -27
  70. package/dist/{WishlistPage-UKOGNFKB.js.map → WishlistPage-SV55V5CP.js.map} +1 -1
  71. package/dist/api/advertisement.js +4 -4
  72. package/dist/api/apps.js +4 -4
  73. package/dist/api/blog.js +6 -6
  74. package/dist/api/brands.js +6 -6
  75. package/dist/api/cart.js +6 -6
  76. package/dist/api/category.js +6 -6
  77. package/dist/api/client.js +3 -3
  78. package/dist/api/home.js +4 -4
  79. package/dist/api/loyalty.js +6 -6
  80. package/dist/api/menu.js +4 -4
  81. package/dist/api/notification.js +4 -4
  82. package/dist/api/order.js +6 -6
  83. package/dist/api/page.js +6 -6
  84. package/dist/api/product.js +6 -6
  85. package/dist/api/profile.js +3 -3
  86. package/dist/api/store.js +5 -5
  87. package/dist/api/translations.js +4 -4
  88. package/dist/api/user.js +4 -4
  89. package/dist/api/wallet.js +4 -4
  90. package/dist/api/wishlist.js +7 -7
  91. package/dist/{chunk-FL3OK7AQ.js → chunk-4SZNUX4K.js} +16 -16
  92. package/dist/{chunk-FL3OK7AQ.js.map → chunk-4SZNUX4K.js.map} +1 -1
  93. package/dist/{chunk-JSAWLWUN.js → chunk-5VTVPQQB.js} +4 -4
  94. package/dist/{chunk-JSAWLWUN.js.map → chunk-5VTVPQQB.js.map} +1 -1
  95. package/dist/{chunk-PVOJJ2BV.js → chunk-64RDACOS.js} +5 -5
  96. package/dist/{chunk-PVOJJ2BV.js.map → chunk-64RDACOS.js.map} +1 -1
  97. package/dist/{chunk-PYXAPLNB.js → chunk-677OXNGV.js} +3 -3
  98. package/dist/{chunk-PYXAPLNB.js.map → chunk-677OXNGV.js.map} +1 -1
  99. package/dist/{chunk-7XAGU6CT.js → chunk-7IVHY4OR.js} +3 -3
  100. package/dist/{chunk-7XAGU6CT.js.map → chunk-7IVHY4OR.js.map} +1 -1
  101. package/dist/{chunk-6H6BVZBV.js → chunk-A2SS3TNE.js} +3 -3
  102. package/dist/{chunk-6H6BVZBV.js.map → chunk-A2SS3TNE.js.map} +1 -1
  103. package/dist/{chunk-TXYLHBUH.js → chunk-AFFBCOH6.js} +3 -3
  104. package/dist/{chunk-TXYLHBUH.js.map → chunk-AFFBCOH6.js.map} +1 -1
  105. package/dist/{chunk-LBZNLTBM.js → chunk-AU2XMLTH.js} +3 -3
  106. package/dist/{chunk-LBZNLTBM.js.map → chunk-AU2XMLTH.js.map} +1 -1
  107. package/dist/{chunk-5NUCGUTE.js → chunk-BIVBSVWR.js} +4 -4
  108. package/dist/{chunk-5NUCGUTE.js.map → chunk-BIVBSVWR.js.map} +1 -1
  109. package/dist/{chunk-6YEE3VHL.js → chunk-BRIRWS2Q.js} +3 -3
  110. package/dist/{chunk-6YEE3VHL.js.map → chunk-BRIRWS2Q.js.map} +1 -1
  111. package/dist/{chunk-ZUVBDALM.js → chunk-BWKHA4ZD.js} +4 -4
  112. package/dist/{chunk-ZUVBDALM.js.map → chunk-BWKHA4ZD.js.map} +1 -1
  113. package/dist/{chunk-EMAAVDEK.js → chunk-BY4DQTOG.js} +7 -7
  114. package/dist/{chunk-EMAAVDEK.js.map → chunk-BY4DQTOG.js.map} +1 -1
  115. package/dist/{chunk-TEAYGNHT.js → chunk-CIJVNUNZ.js} +3 -3
  116. package/dist/{chunk-TEAYGNHT.js.map → chunk-CIJVNUNZ.js.map} +1 -1
  117. package/dist/{chunk-5RBXCPG6.js → chunk-CV32FSEL.js} +3 -3
  118. package/dist/{chunk-5RBXCPG6.js.map → chunk-CV32FSEL.js.map} +1 -1
  119. package/dist/{chunk-FCCGJ4DI.js → chunk-EAQAPYYU.js} +7 -7
  120. package/dist/{chunk-FCCGJ4DI.js.map → chunk-EAQAPYYU.js.map} +1 -1
  121. package/dist/{chunk-4E6FD5W7.js → chunk-EEL6OYAQ.js} +7 -3
  122. package/dist/chunk-EEL6OYAQ.js.map +1 -0
  123. package/dist/{chunk-W7CYFPGY.js → chunk-EFKVEYML.js} +6 -6
  124. package/dist/{chunk-W7CYFPGY.js.map → chunk-EFKVEYML.js.map} +1 -1
  125. package/dist/{chunk-O63WBEAC.js → chunk-F5RU2UCE.js} +22 -22
  126. package/dist/{chunk-O63WBEAC.js.map → chunk-F5RU2UCE.js.map} +1 -1
  127. package/dist/{chunk-RB7RHMKJ.js → chunk-FCFIG4M3.js} +5 -5
  128. package/dist/{chunk-RB7RHMKJ.js.map → chunk-FCFIG4M3.js.map} +1 -1
  129. package/dist/{chunk-B57KIBQL.js → chunk-GGQA6QBB.js} +3 -3
  130. package/dist/{chunk-B57KIBQL.js.map → chunk-GGQA6QBB.js.map} +1 -1
  131. package/dist/{chunk-WAKCWE6P.js → chunk-GMXNVBCD.js} +5 -5
  132. package/dist/{chunk-WAKCWE6P.js.map → chunk-GMXNVBCD.js.map} +1 -1
  133. package/dist/{chunk-PHPOMWQ4.js → chunk-HSJCVD3P.js} +4 -4
  134. package/dist/{chunk-PHPOMWQ4.js.map → chunk-HSJCVD3P.js.map} +1 -1
  135. package/dist/{chunk-5LI536P6.js → chunk-I3KAWUPG.js} +5 -5
  136. package/dist/{chunk-5LI536P6.js.map → chunk-I3KAWUPG.js.map} +1 -1
  137. package/dist/{chunk-34L65JGK.js → chunk-I5GFTVR2.js} +4 -4
  138. package/dist/{chunk-34L65JGK.js.map → chunk-I5GFTVR2.js.map} +1 -1
  139. package/dist/{chunk-QKKEBQ57.js → chunk-IO4CVUL5.js} +6 -6
  140. package/dist/{chunk-QKKEBQ57.js.map → chunk-IO4CVUL5.js.map} +1 -1
  141. package/dist/{chunk-ULF4LPVA.js → chunk-IURXJAIK.js} +3 -3
  142. package/dist/{chunk-ULF4LPVA.js.map → chunk-IURXJAIK.js.map} +1 -1
  143. package/dist/{chunk-2CILV5ME.js → chunk-JWYZLXJZ.js} +5 -5
  144. package/dist/{chunk-2CILV5ME.js.map → chunk-JWYZLXJZ.js.map} +1 -1
  145. package/dist/{chunk-PZP3372I.js → chunk-KNY2ZZ5M.js} +4 -4
  146. package/dist/{chunk-PZP3372I.js.map → chunk-KNY2ZZ5M.js.map} +1 -1
  147. package/dist/{chunk-UUHLRFXB.js → chunk-LAO3MSKN.js} +8 -8
  148. package/dist/{chunk-UUHLRFXB.js.map → chunk-LAO3MSKN.js.map} +1 -1
  149. package/dist/{chunk-5EAISVPV.js → chunk-LFMCUQQ3.js} +3 -3
  150. package/dist/{chunk-5EAISVPV.js.map → chunk-LFMCUQQ3.js.map} +1 -1
  151. package/dist/{chunk-Q7Z76F7N.js → chunk-LJXWCGBH.js} +8 -8
  152. package/dist/{chunk-Q7Z76F7N.js.map → chunk-LJXWCGBH.js.map} +1 -1
  153. package/dist/{chunk-6QIF6WJH.js → chunk-LPF6YURL.js} +3 -3
  154. package/dist/{chunk-6QIF6WJH.js.map → chunk-LPF6YURL.js.map} +1 -1
  155. package/dist/{chunk-P2PPBXHD.js → chunk-M2MJKUQF.js} +3 -3
  156. package/dist/{chunk-P2PPBXHD.js.map → chunk-M2MJKUQF.js.map} +1 -1
  157. package/dist/{chunk-IEKP3HYS.js → chunk-MJQ3HFLJ.js} +4 -4
  158. package/dist/{chunk-IEKP3HYS.js.map → chunk-MJQ3HFLJ.js.map} +1 -1
  159. package/dist/{chunk-VJA4DVVT.js → chunk-N2RAPPQ3.js} +4 -4
  160. package/dist/{chunk-VJA4DVVT.js.map → chunk-N2RAPPQ3.js.map} +1 -1
  161. package/dist/{chunk-OOZQVX7C.js → chunk-O76H6TDP.js} +6 -6
  162. package/dist/{chunk-OOZQVX7C.js.map → chunk-O76H6TDP.js.map} +1 -1
  163. package/dist/{chunk-GLSRVHYJ.js → chunk-OZRGUVHQ.js} +4 -4
  164. package/dist/{chunk-GLSRVHYJ.js.map → chunk-OZRGUVHQ.js.map} +1 -1
  165. package/dist/{chunk-JK45RUVV.js → chunk-PPUV27YN.js} +3 -3
  166. package/dist/{chunk-JK45RUVV.js.map → chunk-PPUV27YN.js.map} +1 -1
  167. package/dist/{chunk-RY6VPXG6.js → chunk-R4LA6IMS.js} +3 -3
  168. package/dist/{chunk-RY6VPXG6.js.map → chunk-R4LA6IMS.js.map} +1 -1
  169. package/dist/{chunk-R7QCNL62.js → chunk-REBJQRQF.js} +3 -3
  170. package/dist/{chunk-R7QCNL62.js.map → chunk-REBJQRQF.js.map} +1 -1
  171. package/dist/{chunk-5M2AK5KE.js → chunk-S5KE6KPV.js} +4 -4
  172. package/dist/{chunk-5M2AK5KE.js.map → chunk-S5KE6KPV.js.map} +1 -1
  173. package/dist/{chunk-LWAJNEIM.js → chunk-SIYINCXL.js} +4 -4
  174. package/dist/{chunk-LWAJNEIM.js.map → chunk-SIYINCXL.js.map} +1 -1
  175. package/dist/{chunk-KJ7NG3ZH.js → chunk-SXJEZEGN.js} +3 -3
  176. package/dist/{chunk-KJ7NG3ZH.js.map → chunk-SXJEZEGN.js.map} +1 -1
  177. package/dist/{chunk-I2LK4IC2.js → chunk-UBRG55VM.js} +4 -4
  178. package/dist/{chunk-I2LK4IC2.js.map → chunk-UBRG55VM.js.map} +1 -1
  179. package/dist/{chunk-2HCODIC6.js → chunk-UG44HSCN.js} +4 -4
  180. package/dist/{chunk-2HCODIC6.js.map → chunk-UG44HSCN.js.map} +1 -1
  181. package/dist/{chunk-BYGVKW3M.js → chunk-UL2DRYH3.js} +4 -4
  182. package/dist/{chunk-BYGVKW3M.js.map → chunk-UL2DRYH3.js.map} +1 -1
  183. package/dist/{chunk-PPFD456V.js → chunk-URBOD4MX.js} +3 -3
  184. package/dist/{chunk-PPFD456V.js.map → chunk-URBOD4MX.js.map} +1 -1
  185. package/dist/{chunk-5T4MJAUN.js → chunk-VBAFSMNX.js} +3 -3
  186. package/dist/{chunk-5T4MJAUN.js.map → chunk-VBAFSMNX.js.map} +1 -1
  187. package/dist/{chunk-DPQIVZ4T.js → chunk-VDPMCOHX.js} +3 -3
  188. package/dist/{chunk-DPQIVZ4T.js.map → chunk-VDPMCOHX.js.map} +1 -1
  189. package/dist/{chunk-2ZC5YGMI.js → chunk-XEHOZTER.js} +3 -3
  190. package/dist/{chunk-2ZC5YGMI.js.map → chunk-XEHOZTER.js.map} +1 -1
  191. package/dist/{chunk-AOQZHLZZ.js → chunk-XTBFIIAR.js} +5 -5
  192. package/dist/{chunk-AOQZHLZZ.js.map → chunk-XTBFIIAR.js.map} +1 -1
  193. package/dist/{chunk-O3XMYDNC.js → chunk-ZBGMIDDO.js} +5 -5
  194. package/dist/{chunk-O3XMYDNC.js.map → chunk-ZBGMIDDO.js.map} +1 -1
  195. package/dist/{chunk-CAULDK3N.js → chunk-ZC4O472R.js} +6 -6
  196. package/dist/{chunk-CAULDK3N.js.map → chunk-ZC4O472R.js.map} +1 -1
  197. package/dist/components/cart/index.js +1 -1
  198. package/dist/components/common/index.js +1 -1
  199. package/dist/components/drawer/index.js +23 -23
  200. package/dist/components/home/index.js +28 -28
  201. package/dist/components/layout/index.js +6 -6
  202. package/dist/components/product/index.js +25 -25
  203. package/dist/components/store/index.js +24 -24
  204. package/dist/components/toast/index.js +4 -4
  205. package/dist/dev/editor/index.js +2 -2
  206. package/dist/dev/index.js +2 -2
  207. package/dist/document-class-XYBFXCE7.js +33 -0
  208. package/dist/{document-class-N7WF3WXG.js.map → document-class-XYBFXCE7.js.map} +1 -1
  209. package/dist/hooks/index.js +23 -23
  210. package/dist/hooks/useComments.js +3 -3
  211. package/dist/hooks/useGtm.js +23 -23
  212. package/dist/hooks/useMoney.js +23 -23
  213. package/dist/hooks/useProduct.js +3 -3
  214. package/dist/hooks/useStore.js +23 -23
  215. package/dist/hooks/useUser.js +5 -5
  216. package/dist/hooks/useWishlist.js +3 -3
  217. package/dist/index.js +23 -23
  218. package/dist/native-app/index.js +3 -3
  219. package/dist/{navigation-FRKMKNLK.js → navigation-QDTYXINL.js} +7 -7
  220. package/dist/{navigation-FRKMKNLK.js.map → navigation-QDTYXINL.js.map} +1 -1
  221. package/dist/{navigation-5DPDZQUU.js → navigation-SHFUWYCA.js} +8 -8
  222. package/dist/{navigation-5DPDZQUU.js.map → navigation-SHFUWYCA.js.map} +1 -1
  223. package/dist/{not-found-4U2TRCLF.js → not-found-IFD562WC.js} +26 -26
  224. package/dist/{not-found-4U2TRCLF.js.map → not-found-IFD562WC.js.map} +1 -1
  225. package/dist/providers/index.js +23 -23
  226. package/dist/routes/account/orders.js +8 -8
  227. package/dist/routes/account.js +17 -17
  228. package/dist/routes/blog.js +12 -12
  229. package/dist/routes/brands.js +8 -8
  230. package/dist/routes/cart.js +32 -32
  231. package/dist/routes/home.js +29 -29
  232. package/dist/routes/index.js +6 -6
  233. package/dist/routes/loyalty.js +9 -9
  234. package/dist/routes/page/loader.d.ts.map +1 -1
  235. package/dist/routes/page.js +9 -8
  236. package/dist/routes/page.js.map +1 -1
  237. package/dist/routes/product/loader.d.ts.map +1 -1
  238. package/dist/routes/product-listing.js +33 -33
  239. package/dist/routes/product.js +29 -28
  240. package/dist/routes/product.js.map +1 -1
  241. package/dist/routes/seo-redirects.js +6 -6
  242. package/dist/routes/testimonials.js +4 -4
  243. package/dist/routes/thank-you.js +8 -8
  244. package/dist/skeleton.js +29 -29
  245. package/dist/{store-lookup-S6JUSKNH.js → store-lookup-AJT3ZHTS.js} +11 -11
  246. package/dist/{store-lookup-S6JUSKNH.js.map → store-lookup-AJT3ZHTS.js.map} +1 -1
  247. package/dist/tanstack/templates/locale-wrapper.d.ts +3 -1
  248. package/dist/tanstack/templates/locale-wrapper.d.ts.map +1 -1
  249. package/dist/tanstack.js +20 -20
  250. package/dist/utils/baseHead.js +2 -2
  251. package/dist/utils/cookies.d.ts +6 -0
  252. package/dist/utils/cookies.d.ts.map +1 -1
  253. package/dist/utils/index.js +6 -6
  254. package/dist/vite/index.js +32 -14
  255. package/dist/vite/index.js.map +1 -1
  256. package/package.json +1 -1
  257. package/tailwind/routes/page/loader.ts.txt +4 -0
  258. package/tailwind/routes/product/loader.ts.txt +5 -0
  259. package/dist/chunk-4E6FD5W7.js.map +0 -1
  260. package/dist/document-class-N7WF3WXG.js +0 -33
@@ -1,13 +1,13 @@
1
1
  import { DEV_SETTINGS_REFRESH_COOKIE } from './chunk-Z5M4YYWT.js';
2
- import { getStoreIdentifier, resolveThemeVersionId } from './chunk-7XAGU6CT.js';
3
- import { AUTH_TOKEN_COOKIE_NAME, extractTokenFromCookies, toCurrencyCode, CURRENCY_COOKIE_NAME, getInjectedRuntimeEnv, readEnv, readSdkScope, extractScopeFromCookies, extractCurrencyFromCookies } from './chunk-4E6FD5W7.js';
2
+ import { getStoreIdentifier, resolveThemeVersionId } from './chunk-7IVHY4OR.js';
3
+ import { AUTH_TOKEN_COOKIE_NAME, extractTokenFromCookies, toCurrencyCode, CURRENCY_COOKIE_NAME, getInjectedRuntimeEnv, readEnv, readSdkScope, extractScopeFromCookies, extractCurrencyFromCookies } from './chunk-EEL6OYAQ.js';
4
4
  import { getTwilightContext } from './chunk-6K34BCUP.js';
5
5
  import ky from 'ky';
6
6
  import { createIsomorphicFn } from '@tanstack/react-start';
7
7
  import { getCookie } from '@tanstack/react-start/server';
8
8
 
9
9
  // src/utils/engine-version.ts
10
- var ENGINE_VERSION = "1.0.150" ;
10
+ var ENGINE_VERSION = "1.0.152" ;
11
11
  var DEV_SETTINGS_TTL_MS = 60 * 6e4;
12
12
  var HIT_HEADER = "x-twilight-dev-cache";
13
13
  var FETCHED_AT_HEADER = "x-twilight-dev-fetched-at";
@@ -242,5 +242,5 @@ var filesCdn = ky.extend({
242
242
  });
243
243
 
244
244
  export { ENGINE_VERSION, STORE_IDENTIFIER_HEADER, api, cdn, devSettingsFetchedAt, filesCdn, getActiveCurrency, getActiveScope, getActiveScopeId, getAuthToken };
245
- //# sourceMappingURL=chunk-RB7RHMKJ.js.map
246
- //# sourceMappingURL=chunk-RB7RHMKJ.js.map
245
+ //# sourceMappingURL=chunk-FCFIG4M3.js.map
246
+ //# sourceMappingURL=chunk-FCFIG4M3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/engine-version.ts","../src/api/dev-settings-cache.ts","../src/api/client.ts"],"names":["entry","createIsomorphicFn","getCookie"],"mappings":";;;;;;;;;AAQO,IAAM,cAAA,GAC0C,SAAA;ACWhD,IAAM,sBAAsB,EAAA,GAAK,GAAA;AAGxC,IAAM,UAAA,GAAa,sBAAA;AAGnB,IAAM,iBAAA,GAAoB,2BAAA;AAOnB,SAAS,qBAAqB,OAAA,EAAkD;AACrF,EAAA,MAAM,EAAA,GAAK,MAAA,CAAO,OAAA,EAAS,GAAA,CAAI,iBAAiB,CAAC,CAAA;AACjD,EAAA,OAAO,OAAO,QAAA,CAAS,EAAE,CAAA,IAAK,EAAA,GAAK,IAAI,EAAA,GAAK,MAAA;AAC9C;A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dist is\n * built. Falls back to 'dev' when the source runs unbundled (vitest, direct\n * src imports in the monorepo).\n *\n * Exposed at runtime as `salla.versions.engine` by `useTwilightInit` so a\n * storefront can always be asked which engine build rendered it.\n */\nexport const ENGINE_VERSION: string =\n typeof __TWILIGHT_ENGINE_VERSION__ !== 'undefined' ? __TWILIGHT_ENGINE_VERSION__ : 'dev';\n","import type { AfterResponseHook, BeforeRequestHook } from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { DEV_SETTINGS_REFRESH_COOKIE } from '../utils/dev-settings-refresh';\n\n/**\n * A dev server reuses a store's settings for up to an hour.\n *\n * Every server render asks the API for `store/settings`, and a developer clicking\n * around a theme renders dozens of pages a minute. The API answers a burst of\n * settings requests for one store from one address with a challenge, which a\n * server-side fetch cannot pass, so the dev server rendered \"Store Unavailable\"\n * (6.05k challenged `(development; ssr)` calls in the 7 days to 2026-10-25). In\n * development, on the server, the same request within {@link DEV_SETTINGS_TTL_MS}\n * is answered from memory instead. An hour because the API counts settings\n * requests per hour, so one fetch an hour can never reach its limit; the theme\n * editor's \"Fetch fresh store data\" fetches sooner, and says how old the settings\n * are. A production build never runs it: `import.meta.env.DEV` is statically\n * false there.\n */\nexport const DEV_SETTINGS_TTL_MS = 60 * 60_000;\n\n/** Marks an answer from memory, so the store step does not file it again. */\nconst HIT_HEADER = 'x-twilight-dev-cache';\n\n/** When the answer was really fetched from the API (epoch ms), on fresh answers and reused ones alike. */\nconst FETCHED_AT_HEADER = 'x-twilight-dev-fetched-at';\n\n/**\n * When the dev server fetched these settings from the API, read off the answer the\n * cache handed back; `undefined` when the cache did not handle the call (a\n * production build, the browser, a test), so nothing new reaches the settings there.\n */\nexport function devSettingsFetchedAt(headers: Headers | undefined): number | undefined {\n const at = Number(headers?.get(FETCHED_AT_HEADER));\n return Number.isFinite(at) && at > 0 ? at : undefined;\n}\n\n/**\n * Not carried over to an answer from memory: the body is stored decoded, so its\n * original encoding and length no longer describe it.\n */\nconst DROPPED_HEADERS = new Set(['content-encoding', 'content-length']);\n\ninterface Entry {\n body: string;\n status: number;\n statusText: string;\n headers: [string, string][];\n fetchedAt: number;\n /** The refresh cookie's value when this answer was fetched. */\n refresh: string | null;\n}\n\nexport interface DevSettingsCacheOptions {\n /** Whether this call may use the cache at all. */\n enabled: () => boolean;\n /** The current value of {@link DEV_SETTINGS_REFRESH_COOKIE}, or null. */\n refreshToken: () => string | null;\n now?: () => number;\n ttlMs?: number;\n /** Called the first time an answer comes from memory. */\n onFirstHit?: () => void;\n}\n\nfunction isSettingsRequest(request: Request): boolean {\n if (request.method !== 'GET') return false;\n try {\n return new URL(request.url).pathname.endsWith('/store/settings');\n } catch {\n return false;\n }\n}\n\n/**\n * An answer `requestSettings` accepts: JSON carrying `data`. A 200 without it is\n * refused there as \"Store Unavailable\"; kept here, it would be refused for the next\n * hour too, after the API had recovered.\n */\nfunction hasSettings(body: string): boolean {\n try {\n return Boolean((JSON.parse(body) as { data?: unknown } | null)?.data);\n } catch {\n return false;\n }\n}\n\n/**\n * The request as the API receives it: method, URL and every header the client's\n * hooks set. Keyed on the request itself rather than on the inputs that build it,\n * so a header added to the client later cannot be missing from the key.\n */\nfunction keyOf(request: Request): string {\n const headers = [...request.headers].map(([name, value]) => `${name}: ${value}`).join('\\n');\n return `${request.method} ${request.url}\\n${headers}`;\n}\n\n/**\n * The two ky hooks behind the cache: `lookup` runs last among `beforeRequest`, once\n * every header is set, and `store` among `afterResponse`. Only an answer with\n * settings in it is kept, so a timeout, a 429, a challenge or an empty 200 is asked\n * again on the next render.\n */\nexport function createDevSettingsCache(options: DevSettingsCacheOptions) {\n const {\n enabled,\n refreshToken,\n now = Date.now,\n ttlMs = DEV_SETTINGS_TTL_MS,\n onFirstHit,\n } = options;\n const entries = new Map<string, Entry>();\n let announced = false;\n\n const isFresh = (entry: Entry): boolean =>\n now() - entry.fetchedAt < ttlMs && entry.refresh === refreshToken();\n\n const answerOf = (entry: Entry, hit: boolean): Response => {\n const headers = new Headers(entry.headers);\n headers.set(FETCHED_AT_HEADER, String(entry.fetchedAt));\n if (hit) headers.set(HIT_HEADER, 'hit');\n return new Response(entry.body, {\n status: entry.status,\n statusText: entry.statusText,\n headers,\n });\n };\n\n const lookup: BeforeRequestHook = ({ request }) => {\n if (!enabled() || !isSettingsRequest(request)) return;\n const key = keyOf(request);\n const entry = entries.get(key);\n if (!entry) return;\n if (!isFresh(entry)) {\n entries.delete(key);\n return;\n }\n if (!announced) {\n announced = true;\n onFirstHit?.();\n }\n return answerOf(entry, true);\n };\n\n const store: AfterResponseHook = async ({ request, response }) => {\n if (!enabled() || !isSettingsRequest(request) || !response.ok) return;\n if (response.headers.has(HIT_HEADER)) return;\n // ky hands each hook a clone, so reading it leaves the answer it returns intact.\n const body = await response.text();\n if (!hasSettings(body)) return;\n for (const [key, entry] of entries) {\n if (now() - entry.fetchedAt >= ttlMs) entries.delete(key);\n }\n const entry: Entry = {\n body,\n status: response.status,\n statusText: response.statusText,\n headers: [...response.headers].filter(([name]) => !DROPPED_HEADERS.has(name)),\n fetchedAt: now(),\n refresh: refreshToken(),\n };\n entries.set(keyOf(request), entry);\n // Handed on in place of the API's own answer, so it carries its fetch time too.\n return answerOf(entry, false);\n };\n\n return { lookup, store, clear: () => entries.clear() };\n}\n\nconst readRefreshCookie = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getCookie(DEV_SETTINGS_REFRESH_COOKIE) ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nexport const devSettingsCache = createDevSettingsCache({\n // A dev server's render only. A production build has `DEV` statically false,\n // the browser keeps the settings it was handed in its query cache, and vitest\n // runs in `test` mode, where every test wants the request it mocked.\n enabled: () =>\n import.meta.env.DEV && import.meta.env.MODE !== 'test' && typeof document === 'undefined',\n refreshToken: readRefreshCookie,\n onFirstHit: () =>\n console.warn(\n `[twilight] Store settings are reused for up to ${DEV_SETTINGS_TTL_MS / 60_000} minutes while you develop, to stay under the Salla API's rate limit. To see a change you made in the dashboard, press \"Fetch fresh store data\" in the theme editor's side panel: it also says when they were last fetched.`\n ),\n});\n","import ky from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { getStoreIdentifier } from '../utils/sdk-helpers';\nimport { resolveThemeVersionId } from '../utils/theme-version';\nimport { getInjectedRuntimeEnv, readEnv } from '../utils/runtime-env';\nimport { getTwilightContext } from '../twilight/context';\nimport { ENGINE_VERSION } from '../utils/engine-version';\nimport { devSettingsCache } from './dev-settings-cache';\nimport {\n AUTH_TOKEN_COOKIE_NAME,\n CURRENCY_COOKIE_NAME,\n extractCurrencyFromCookies,\n extractScopeFromCookies,\n toCurrencyCode,\n extractTokenFromCookies,\n readSdkScope,\n type ActiveScope,\n} from '../utils/cookies';\n\n// The twilight module store doesn't reliably carry authToken into every scope: on the\n// SERVER workerd has no AsyncLocalStorage, and on BOTH sides this api client can live in a\n// different module instance than the one rootBeforeLoad populates (engine subpath import vs\n// engine-internal relative import). So `getTwilightContext().authToken` is often null even\n// for logged-in users → API calls (orders/customer/…) return `token_not_provided` (400).\n// Read the token directly from the request cookie (server) or document.cookie / salla.storage\n// (client) as a fallback. The server-only import is stripped from the client bundle by\n// createIsomorphicFn.\nconst readFallbackToken = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getCookie(AUTH_TOKEN_COOKIE_NAME) ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => {\n const fromCookie =\n typeof document !== 'undefined'\n ? extractTokenFromCookies(document.cookie, AUTH_TOKEN_COOKIE_NAME)\n : null;\n if (fromCookie) return fromCookie;\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n const fromStorage =\n typeof storage?.get === 'function' ? storage.get(AUTH_TOKEN_COOKIE_NAME) : null;\n if (typeof fromStorage === 'string' && fromStorage) return fromStorage;\n // `?token=` webview injection lands only on the SDK's axios instance\n const fromSdkApi = typeof window !== 'undefined' ? window.salla?.api?.token : undefined;\n return typeof fromSdkApi === 'string' && fromSdkApi ? fromSdkApi : null;\n });\n\n/**\n * The auth token as the api client sees it: twilight context first, cookie/storage fallback.\n * Use this (not `getTwilightContext().authToken`, which is often null for logged-in users —\n * see the note above) to decide whether an authenticated-only query should run.\n */\nexport const getAuthToken = (): string | null =>\n getTwilightContext().authToken ?? readFallbackToken();\n\nconst readRequestCurrency = createIsomorphicFn()\n .server((): string | null => {\n try {\n return toCurrencyCode(getCookie(CURRENCY_COOKIE_NAME));\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\n/**\n * The currency the visitor chose, from the `s-curr` cookie the SDK writes: the API\n * answers in the store's own currency unless the request names one.\n */\nexport function getActiveCurrency(): string | null;\nexport function getActiveCurrency(fallback: string): string;\nexport function getActiveCurrency(fallback: string | null = null): string | null {\n const chosen =\n typeof document !== 'undefined'\n ? extractCurrencyFromCookies(document.cookie)\n : readRequestCurrency();\n return chosen ?? fallback;\n}\n\nconst API_HEADERS = {\n ACCEPT: 'accept',\n ACCEPT_LANGUAGE: 'accept-language',\n APP_OS: 's-app-os',\n APP_VERSION: 's-app-version',\n RAY: 's-ray',\n SOURCE: 's-source',\n THEME_TYPE: 's-theme-type',\n STORE_API_VERSION: 's-store-api-version',\n REQUESTED_WITH: 'x-requested-with',\n CF_PROXY_WHITELIST: 's-cf-proxy-whitelist-id',\n STORE_IDENTIFIER: 'store-identifier',\n CURRENCY: 'currency',\n AUTHORIZATION: 'Authorization',\n VERSION_ID: 's-version-id',\n SCOPE_ID: 's-scope-id',\n SCOPE_TYPE: 's-scope-type',\n SCOPE_ALLOCATION_TYPE: 's-scope-allocation-type',\n SCOPE_ALLOCATION_ID: 's-scope-allocation-id',\n USER_AGENT: 'user-agent',\n} as const;\n\n/**\n * The header every Salla API call is answered by store.\n *\n * Exported because a caller that already knows which store it is asking about\n * must be able to say so on the request itself — see `store.settings`. Without\n * it the only way to name a store is the ambient resolver, and \"the identifier\n * I checked\" and \"the identifier that was sent\" become two different things.\n */\nexport const STORE_IDENTIFIER_HEADER = API_HEADERS.STORE_IDENTIFIER;\n\n/**\n * Active scope: the market plus its branch allocation, as the SDK stores it. On the\n * client it comes from `salla.storage.get('scope')`; before the SDK hydrates storage\n * it falls back to the `scope` cookie the theme mirrors that selection into (see\n * writeScopeCookie), then to the scope twilightMiddleware seeded from the same\n * cookie on the server. Requests vary by the `s-scope-*` headers, so React Query\n * keys must include this to avoid serving another branch's cached categories/products.\n *\n * The cookie step matters for hydration: the SDK is not guaranteed to have\n * populated `salla.storage` by the time the client rebuilds a dehydrated query\n * key, and without it the client would compute null against a scoped SSR key.\n */\nexport const getActiveScope = (): ActiveScope | null => {\n // `!== undefined`, not `!= null`: a null here is the SDK authoritatively saying \"no branch\n // selected\", which must beat a cookie left over from the previous selection. Only a\n // not-yet-ready storage API (undefined) falls through to the cookie.\n const fromStorage = readSdkScope();\n if (fromStorage !== undefined) return fromStorage;\n\n if (typeof document !== 'undefined') {\n const fromCookie = extractScopeFromCookies(document.cookie);\n if (fromCookie != null) return fromCookie;\n }\n\n try {\n return getTwilightContext().scope;\n } catch {\n return null;\n }\n};\n\n/** {@link getActiveScope} reduced to the market id. */\nexport const getActiveScopeId = (): string | null => getActiveScope()?.id ?? null;\n\nconst sharedHeaders = (locale: string) => ({\n [API_HEADERS.ACCEPT]: 'application/json' as const,\n [API_HEADERS.ACCEPT_LANGUAGE]: locale,\n [API_HEADERS.APP_OS]: 'browser',\n [API_HEADERS.APP_VERSION]: '2.14.363',\n [API_HEADERS.RAY]: '50',\n [API_HEADERS.SOURCE]: 'twilight',\n [API_HEADERS.THEME_TYPE]: 'react',\n [API_HEADERS.STORE_API_VERSION]: 'swoole',\n [API_HEADERS.REQUESTED_WITH]: 'XMLHttpRequest',\n [API_HEADERS.CF_PROXY_WHITELIST]: '019a2f78-a64c-7edb-proxy-whitelist-id-9a3a-17afda90f03a',\n});\n\n/**\n * Who a server-rendered call says it is.\n *\n * Every theme worker reaches api.salla.dev from Cloudflare's one Workers address, so\n * salla.dev's per-IP rate limits counted every React store as a single client and\n * refused the calls each page makes (`store/settings` among them: \"Store Unavailable\").\n * The zone skips rate limiting for a User-Agent shaped `Salla-<Name>/<N.N.N> (<env>; <meta>)`\n * from Cloudflare's or AWS's networks, the convention Salla's other services already send.\n *\n * Built from fixed parts: the zone's pattern takes only digits and dots for the version,\n * so a prerelease suffix is dropped, and an unbundled engine (`dev`) reads as `0.0.0`.\n */\nconst SERVER_USER_AGENT = `Salla-TwilightReact/${\n /^\\d+(?:\\.\\d+)*/.exec(ENGINE_VERSION)?.[0] ?? '0.0.0'\n} (${import.meta.env.DEV ? 'development' : 'production'}; ssr)`;\n\n/**\n * Store API base. `VITE_API_URL` override points a preview at a branch backend; unset → prod\n * `api.salla.dev`. Resolution order matters: the value the SSR worker resolved (published into\n * the head, since worker `vars` are server-only `process.env` and never reach the browser\n * bundle) wins, so the hydrated client keeps talking to the backend that rendered the page.\n */\n\nconst STORE_API_BASE =\n getInjectedRuntimeEnv().apiBase || readEnv('VITE_API_URL') || 'https://api.salla.dev/store/v1';\n\nexport const api = ky.extend({\n prefix: STORE_API_BASE,\n timeout: 8000,\n hooks: {\n beforeRequest: [\n ({ request }) => {\n const { locale, authToken } = getTwilightContext();\n const headers = sharedHeaders(locale);\n for (const [key, value] of Object.entries(headers)) {\n request.headers.set(key, value);\n }\n // Only when the caller did not say. `headers.set` here would otherwise\n // overwrite a per-request identifier with the ambient one, which is a\n // silent way to answer a question about one store with another's data.\n if (!request.headers.get(API_HEADERS.STORE_IDENTIFIER)) {\n request.headers.set(API_HEADERS.STORE_IDENTIFIER, getStoreIdentifier());\n }\n\n // Server only. A browser call comes from the shopper's own address and is\n // counted against it, which is what the zone's limits are for.\n if (typeof document === 'undefined') {\n request.headers.set(API_HEADERS.USER_AGENT, SERVER_USER_AGENT);\n }\n\n const scope = getActiveScope();\n\n // The version the request asked for, else the one the settings named for\n // this scope. Absent means \"whatever is live\", which is what an ordinary\n // storefront visit wants — so a null is left off rather than sent empty.\n const versionId = resolveThemeVersionId(scope?.id ?? null);\n if (versionId) {\n request.headers.set(API_HEADERS.VERSION_ID, versionId);\n }\n\n const currency = getActiveCurrency();\n if (currency) request.headers.set(API_HEADERS.CURRENCY, currency);\n\n const token = authToken ?? readFallbackToken();\n if (token) {\n request.headers.set(API_HEADERS.AUTHORIZATION, `Bearer ${token}`);\n }\n\n // The same four the SDK's own client sends. The API resolves stock per\n // allocation: id alone asks about the market, not the branch the shopper chose.\n if (scope) {\n request.headers.set(API_HEADERS.SCOPE_ID, scope.id);\n if (scope.type) request.headers.set(API_HEADERS.SCOPE_TYPE, scope.type);\n if (scope.allocation_type)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_TYPE, scope.allocation_type);\n if (scope.allocation_id)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_ID, scope.allocation_id);\n }\n },\n // Last, so it keys on the request with every header above set.\n devSettingsCache.lookup,\n ],\n afterResponse: [devSettingsCache.store],\n },\n});\n\nexport const cdn = ky.extend({\n prefix: 'https://cdn.salla.network',\n timeout: 5000,\n});\n\n/**\n * The merchant uploader's public bucket, `admin-uploader-prod`.\n *\n * A different host from {@link cdn} and a different thing behind it: this one\n * is an R2 custom domain, so a read never passes through a worker. Storefront\n * translations live here, per language, under `translations/` — see\n * `api/translations.ts`.\n */\nexport const filesCdn = ky.extend({\n prefix: 'https://cdn.files.salla.network',\n timeout: 5000,\n});\n"]}
1
+ {"version":3,"sources":["../src/utils/engine-version.ts","../src/api/dev-settings-cache.ts","../src/api/client.ts"],"names":["entry","createIsomorphicFn","getCookie"],"mappings":";;;;;;;;;AAQO,IAAM,cAAA,GAC0C,SAAA;ACWhD,IAAM,sBAAsB,EAAA,GAAK,GAAA;AAGxC,IAAM,UAAA,GAAa,sBAAA;AAGnB,IAAM,iBAAA,GAAoB,2BAAA;AAOnB,SAAS,qBAAqB,OAAA,EAAkD;AACrF,EAAA,MAAM,EAAA,GAAK,MAAA,CAAO,OAAA,EAAS,GAAA,CA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A,EAChC,MAAA,EAAQ,iCAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"chunk-FCFIG4M3.js","sourcesContent":["/**\n * The engine's own build version, injected by tsup `define` when dist is\n * built. Falls back to 'dev' when the source runs unbundled (vitest, direct\n * src imports in the monorepo).\n *\n * Exposed at runtime as `salla.versions.engine` by `useTwilightInit` so a\n * storefront can always be asked which engine build rendered it.\n */\nexport const ENGINE_VERSION: string =\n typeof __TWILIGHT_ENGINE_VERSION__ !== 'undefined' ? __TWILIGHT_ENGINE_VERSION__ : 'dev';\n","import type { AfterResponseHook, BeforeRequestHook } from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { DEV_SETTINGS_REFRESH_COOKIE } from '../utils/dev-settings-refresh';\n\n/**\n * A dev server reuses a store's settings for up to an hour.\n *\n * Every server render asks the API for `store/settings`, and a developer clicking\n * around a theme renders dozens of pages a minute. The API answers a burst of\n * settings requests for one store from one address with a challenge, which a\n * server-side fetch cannot pass, so the dev server rendered \"Store Unavailable\"\n * (6.05k challenged `(development; ssr)` calls in the 7 days to 2026-10-25). In\n * development, on the server, the same request within {@link DEV_SETTINGS_TTL_MS}\n * is answered from memory instead. An hour because the API counts settings\n * requests per hour, so one fetch an hour can never reach its limit; the theme\n * editor's \"Fetch fresh store data\" fetches sooner, and says how old the settings\n * are. A production build never runs it: `import.meta.env.DEV` is statically\n * false there.\n */\nexport const DEV_SETTINGS_TTL_MS = 60 * 60_000;\n\n/** Marks an answer from memory, so the store step does not file it again. */\nconst HIT_HEADER = 'x-twilight-dev-cache';\n\n/** When the answer was really fetched from the API (epoch ms), on fresh answers and reused ones alike. */\nconst FETCHED_AT_HEADER = 'x-twilight-dev-fetched-at';\n\n/**\n * When the dev server fetched these settings from the API, read off the answer the\n * cache handed back; `undefined` when the cache did not handle the call (a\n * production build, the browser, a test), so nothing new reaches the settings there.\n */\nexport function devSettingsFetchedAt(headers: Headers | undefined): number | undefined {\n const at = Number(headers?.get(FETCHED_AT_HEADER));\n return Number.isFinite(at) && at > 0 ? at : undefined;\n}\n\n/**\n * Not carried over to an answer from memory: the body is stored decoded, so its\n * original encoding and length no longer describe it.\n */\nconst DROPPED_HEADERS = new Set(['content-encoding', 'content-length']);\n\ninterface Entry {\n body: string;\n status: number;\n statusText: string;\n headers: [string, string][];\n fetchedAt: number;\n /** The refresh cookie's value when this answer was fetched. */\n refresh: string | null;\n}\n\nexport interface DevSettingsCacheOptions {\n /** Whether this call may use the cache at all. */\n enabled: () => boolean;\n /** The current value of {@link DEV_SETTINGS_REFRESH_COOKIE}, or null. */\n refreshToken: () => string | null;\n now?: () => number;\n ttlMs?: number;\n /** Called the first time an answer comes from memory. */\n onFirstHit?: () => void;\n}\n\nfunction isSettingsRequest(request: Request): boolean {\n if (request.method !== 'GET') return false;\n try {\n return new URL(request.url).pathname.endsWith('/store/settings');\n } catch {\n return false;\n }\n}\n\n/**\n * An answer `requestSettings` accepts: JSON carrying `data`. A 200 without it is\n * refused there as \"Store Unavailable\"; kept here, it would be refused for the next\n * hour too, after the API had recovered.\n */\nfunction hasSettings(body: string): boolean {\n try {\n return Boolean((JSON.parse(body) as { data?: unknown } | null)?.data);\n } catch {\n return false;\n }\n}\n\n/**\n * The request as the API receives it: method, URL and every header the client's\n * hooks set. Keyed on the request itself rather than on the inputs that build it,\n * so a header added to the client later cannot be missing from the key.\n */\nfunction keyOf(request: Request): string {\n const headers = [...request.headers].map(([name, value]) => `${name}: ${value}`).join('\\n');\n return `${request.method} ${request.url}\\n${headers}`;\n}\n\n/**\n * The two ky hooks behind the cache: `lookup` runs last among `beforeRequest`, once\n * every header is set, and `store` among `afterResponse`. Only an answer with\n * settings in it is kept, so a timeout, a 429, a challenge or an empty 200 is asked\n * again on the next render.\n */\nexport function createDevSettingsCache(options: DevSettingsCacheOptions) {\n const {\n enabled,\n refreshToken,\n now = Date.now,\n ttlMs = DEV_SETTINGS_TTL_MS,\n onFirstHit,\n } = options;\n const entries = new Map<string, Entry>();\n let announced = false;\n\n const isFresh = (entry: Entry): boolean =>\n now() - entry.fetchedAt < ttlMs && entry.refresh === refreshToken();\n\n const answerOf = (entry: Entry, hit: boolean): Response => {\n const headers = new Headers(entry.headers);\n headers.set(FETCHED_AT_HEADER, String(entry.fetchedAt));\n if (hit) headers.set(HIT_HEADER, 'hit');\n return new Response(entry.body, {\n status: entry.status,\n statusText: entry.statusText,\n headers,\n });\n };\n\n const lookup: BeforeRequestHook = ({ request }) => {\n if (!enabled() || !isSettingsRequest(request)) return;\n const key = keyOf(request);\n const entry = entries.get(key);\n if (!entry) return;\n if (!isFresh(entry)) {\n entries.delete(key);\n return;\n }\n if (!announced) {\n announced = true;\n onFirstHit?.();\n }\n return answerOf(entry, true);\n };\n\n const store: AfterResponseHook = async ({ request, response }) => {\n if (!enabled() || !isSettingsRequest(request) || !response.ok) return;\n if (response.headers.has(HIT_HEADER)) return;\n // ky hands each hook a clone, so reading it leaves the answer it returns intact.\n const body = await response.text();\n if (!hasSettings(body)) return;\n for (const [key, entry] of entries) {\n if (now() - entry.fetchedAt >= ttlMs) entries.delete(key);\n }\n const entry: Entry = {\n body,\n status: response.status,\n statusText: response.statusText,\n headers: [...response.headers].filter(([name]) => !DROPPED_HEADERS.has(name)),\n fetchedAt: now(),\n refresh: refreshToken(),\n };\n entries.set(keyOf(request), entry);\n // Handed on in place of the API's own answer, so it carries its fetch time too.\n return answerOf(entry, false);\n };\n\n return { lookup, store, clear: () => entries.clear() };\n}\n\nconst readRefreshCookie = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getCookie(DEV_SETTINGS_REFRESH_COOKIE) ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nexport const devSettingsCache = createDevSettingsCache({\n // A dev server's render only. A production build has `DEV` statically false,\n // the browser keeps the settings it was handed in its query cache, and vitest\n // runs in `test` mode, where every test wants the request it mocked.\n enabled: () =>\n import.meta.env.DEV && import.meta.env.MODE !== 'test' && typeof document === 'undefined',\n refreshToken: readRefreshCookie,\n onFirstHit: () =>\n console.warn(\n `[twilight] Store settings are reused for up to ${DEV_SETTINGS_TTL_MS / 60_000} minutes while you develop, to stay under the Salla API's rate limit. To see a change you made in the dashboard, press \"Fetch fresh store data\" in the theme editor's side panel: it also says when they were last fetched.`\n ),\n});\n","import ky from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { getStoreIdentifier } from '../utils/sdk-helpers';\nimport { resolveThemeVersionId } from '../utils/theme-version';\nimport { getInjectedRuntimeEnv, readEnv } from '../utils/runtime-env';\nimport { getTwilightContext } from '../twilight/context';\nimport { ENGINE_VERSION } from '../utils/engine-version';\nimport { devSettingsCache } from './dev-settings-cache';\nimport {\n AUTH_TOKEN_COOKIE_NAME,\n CURRENCY_COOKIE_NAME,\n extractCurrencyFromCookies,\n extractScopeFromCookies,\n toCurrencyCode,\n extractTokenFromCookies,\n readSdkScope,\n type ActiveScope,\n} from '../utils/cookies';\n\n// The twilight module store doesn't reliably carry authToken into every scope: on the\n// SERVER workerd has no AsyncLocalStorage, and on BOTH sides this api client can live in a\n// different module instance than the one rootBeforeLoad populates (engine subpath import vs\n// engine-internal relative import). So `getTwilightContext().authToken` is often null even\n// for logged-in users → API calls (orders/customer/…) return `token_not_provided` (400).\n// Read the token directly from the request cookie (server) or document.cookie / salla.storage\n// (client) as a fallback. The server-only import is stripped from the client bundle by\n// createIsomorphicFn.\nconst readFallbackToken = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getCookie(AUTH_TOKEN_COOKIE_NAME) ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => {\n const fromCookie =\n typeof document !== 'undefined'\n ? extractTokenFromCookies(document.cookie, AUTH_TOKEN_COOKIE_NAME)\n : null;\n if (fromCookie) return fromCookie;\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n const fromStorage =\n typeof storage?.get === 'function' ? storage.get(AUTH_TOKEN_COOKIE_NAME) : null;\n if (typeof fromStorage === 'string' && fromStorage) return fromStorage;\n // `?token=` webview injection lands only on the SDK's axios instance\n const fromSdkApi = typeof window !== 'undefined' ? window.salla?.api?.token : undefined;\n return typeof fromSdkApi === 'string' && fromSdkApi ? fromSdkApi : null;\n });\n\n/**\n * The auth token as the api client sees it: twilight context first, cookie/storage fallback.\n * Use this (not `getTwilightContext().authToken`, which is often null for logged-in users —\n * see the note above) to decide whether an authenticated-only query should run.\n */\nexport const getAuthToken = (): string | null =>\n getTwilightContext().authToken ?? readFallbackToken();\n\nconst readRequestCurrency = createIsomorphicFn()\n .server((): string | null => {\n try {\n return toCurrencyCode(getCookie(CURRENCY_COOKIE_NAME));\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\n/**\n * The currency the visitor chose, from the `s-curr` cookie the SDK writes: the API\n * answers in the store's own currency unless the request names one.\n */\nexport function getActiveCurrency(): string | null;\nexport function getActiveCurrency(fallback: string): string;\nexport function getActiveCurrency(fallback: string | null = null): string | null {\n const chosen =\n typeof document !== 'undefined'\n ? extractCurrencyFromCookies(document.cookie)\n : readRequestCurrency();\n return chosen ?? fallback;\n}\n\nconst API_HEADERS = {\n ACCEPT: 'accept',\n ACCEPT_LANGUAGE: 'accept-language',\n APP_OS: 's-app-os',\n APP_VERSION: 's-app-version',\n RAY: 's-ray',\n SOURCE: 's-source',\n THEME_TYPE: 's-theme-type',\n STORE_API_VERSION: 's-store-api-version',\n REQUESTED_WITH: 'x-requested-with',\n CF_PROXY_WHITELIST: 's-cf-proxy-whitelist-id',\n STORE_IDENTIFIER: 'store-identifier',\n CURRENCY: 'currency',\n AUTHORIZATION: 'Authorization',\n VERSION_ID: 's-version-id',\n SCOPE_ID: 's-scope-id',\n SCOPE_TYPE: 's-scope-type',\n SCOPE_ALLOCATION_TYPE: 's-scope-allocation-type',\n SCOPE_ALLOCATION_ID: 's-scope-allocation-id',\n USER_AGENT: 'user-agent',\n} as const;\n\n/**\n * The header every Salla API call is answered by store.\n *\n * Exported because a caller that already knows which store it is asking about\n * must be able to say so on the request itself — see `store.settings`. Without\n * it the only way to name a store is the ambient resolver, and \"the identifier\n * I checked\" and \"the identifier that was sent\" become two different things.\n */\nexport const STORE_IDENTIFIER_HEADER = API_HEADERS.STORE_IDENTIFIER;\n\n/**\n * Active scope: the market plus its branch allocation, as the SDK stores it. On the\n * client it comes from `salla.storage.get('scope')`; before the SDK hydrates storage\n * it falls back to the `scope` cookie the theme mirrors that selection into (see\n * writeScopeCookie), then to the scope twilightMiddleware seeded from the same\n * cookie on the server. Requests vary by the `s-scope-*` headers, so React Query\n * keys must include this to avoid serving another branch's cached categories/products.\n *\n * The cookie step matters for hydration: the SDK is not guaranteed to have\n * populated `salla.storage` by the time the client rebuilds a dehydrated query\n * key, and without it the client would compute null against a scoped SSR key.\n */\nexport const getActiveScope = (): ActiveScope | null => {\n // `!== undefined`, not `!= null`: a null here is the SDK authoritatively saying \"no branch\n // selected\", which must beat a cookie left over from the previous selection. Only a\n // not-yet-ready storage API (undefined) falls through to the cookie.\n const fromStorage = readSdkScope();\n if (fromStorage !== undefined) return fromStorage;\n\n if (typeof document !== 'undefined') {\n const fromCookie = extractScopeFromCookies(document.cookie);\n if (fromCookie != null) return fromCookie;\n }\n\n try {\n return getTwilightContext().scope;\n } catch {\n return null;\n }\n};\n\n/** {@link getActiveScope} reduced to the market id. */\nexport const getActiveScopeId = (): string | null => getActiveScope()?.id ?? null;\n\nconst sharedHeaders = (locale: string) => ({\n [API_HEADERS.ACCEPT]: 'application/json' as const,\n [API_HEADERS.ACCEPT_LANGUAGE]: locale,\n [API_HEADERS.APP_OS]: 'browser',\n [API_HEADERS.APP_VERSION]: '2.14.363',\n [API_HEADERS.RAY]: '50',\n [API_HEADERS.SOURCE]: 'twilight',\n [API_HEADERS.THEME_TYPE]: 'react',\n [API_HEADERS.STORE_API_VERSION]: 'swoole',\n [API_HEADERS.REQUESTED_WITH]: 'XMLHttpRequest',\n [API_HEADERS.CF_PROXY_WHITELIST]: '019a2f78-a64c-7edb-proxy-whitelist-id-9a3a-17afda90f03a',\n});\n\n/**\n * Who a server-rendered call says it is.\n *\n * Every theme worker reaches api.salla.dev from Cloudflare's one Workers address, so\n * salla.dev's per-IP rate limits counted every React store as a single client and\n * refused the calls each page makes (`store/settings` among them: \"Store Unavailable\").\n * The zone skips rate limiting for a User-Agent shaped `Salla-<Name>/<N.N.N> (<env>; <meta>)`\n * from Cloudflare's or AWS's networks, the convention Salla's other services already send.\n *\n * Built from fixed parts: the zone's pattern takes only digits and dots for the version,\n * so a prerelease suffix is dropped, and an unbundled engine (`dev`) reads as `0.0.0`.\n */\nconst SERVER_USER_AGENT = `Salla-TwilightReact/${\n /^\\d+(?:\\.\\d+)*/.exec(ENGINE_VERSION)?.[0] ?? '0.0.0'\n} (${import.meta.env.DEV ? 'development' : 'production'}; ssr)`;\n\n/**\n * Store API base. `VITE_API_URL` override points a preview at a branch backend; unset → prod\n * `api.salla.dev`. Resolution order matters: the value the SSR worker resolved (published into\n * the head, since worker `vars` are server-only `process.env` and never reach the browser\n * bundle) wins, so the hydrated client keeps talking to the backend that rendered the page.\n */\n\nconst STORE_API_BASE =\n getInjectedRuntimeEnv().apiBase || readEnv('VITE_API_URL') || 'https://api.salla.dev/store/v1';\n\nexport const api = ky.extend({\n prefix: STORE_API_BASE,\n timeout: 8000,\n hooks: {\n beforeRequest: [\n ({ request }) => {\n const { locale, authToken } = getTwilightContext();\n const headers = sharedHeaders(locale);\n for (const [key, value] of Object.entries(headers)) {\n request.headers.set(key, value);\n }\n // Only when the caller did not say. `headers.set` here would otherwise\n // overwrite a per-request identifier with the ambient one, which is a\n // silent way to answer a question about one store with another's data.\n if (!request.headers.get(API_HEADERS.STORE_IDENTIFIER)) {\n request.headers.set(API_HEADERS.STORE_IDENTIFIER, getStoreIdentifier());\n }\n\n // Server only. A browser call comes from the shopper's own address and is\n // counted against it, which is what the zone's limits are for.\n if (typeof document === 'undefined') {\n request.headers.set(API_HEADERS.USER_AGENT, SERVER_USER_AGENT);\n }\n\n const scope = getActiveScope();\n\n // The version the request asked for, else the one the settings named for\n // this scope. Absent means \"whatever is live\", which is what an ordinary\n // storefront visit wants — so a null is left off rather than sent empty.\n const versionId = resolveThemeVersionId(scope?.id ?? null);\n if (versionId) {\n request.headers.set(API_HEADERS.VERSION_ID, versionId);\n }\n\n const currency = getActiveCurrency();\n if (currency) request.headers.set(API_HEADERS.CURRENCY, currency);\n\n const token = authToken ?? readFallbackToken();\n if (token) {\n request.headers.set(API_HEADERS.AUTHORIZATION, `Bearer ${token}`);\n }\n\n // The same four the SDK's own client sends. The API resolves stock per\n // allocation: id alone asks about the market, not the branch the shopper chose.\n if (scope) {\n request.headers.set(API_HEADERS.SCOPE_ID, scope.id);\n if (scope.type) request.headers.set(API_HEADERS.SCOPE_TYPE, scope.type);\n if (scope.allocation_type)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_TYPE, scope.allocation_type);\n if (scope.allocation_id)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_ID, scope.allocation_id);\n }\n },\n // Last, so it keys on the request with every header above set.\n devSettingsCache.lookup,\n ],\n afterResponse: [devSettingsCache.store],\n },\n});\n\nexport const cdn = ky.extend({\n prefix: 'https://cdn.salla.network',\n timeout: 5000,\n});\n\n/**\n * The merchant uploader's public bucket, `admin-uploader-prod`.\n *\n * A different host from {@link cdn} and a different thing behind it: this one\n * is an R2 custom domain, so a read never passes through a worker. Storefront\n * translations live here, per language, under `translations/` — see\n * `api/translations.ts`.\n */\nexport const filesCdn = ky.extend({\n prefix: 'https://cdn.files.salla.network',\n timeout: 5000,\n});\n"]}
@@ -1,4 +1,4 @@
1
- import { onSallaEvent } from './chunk-7XAGU6CT.js';
1
+ import { onSallaEvent } from './chunk-7IVHY4OR.js';
2
2
  import { useState, useRef, useEffect, useCallback } from 'react';
3
3
 
4
4
  function useProduct(initialProduct, options) {
@@ -61,5 +61,5 @@ function useProduct(initialProduct, options) {
61
61
  }
62
62
 
63
63
  export { useProduct };
64
- //# sourceMappingURL=chunk-B57KIBQL.js.map
65
- //# sourceMappingURL=chunk-B57KIBQL.js.map
64
+ //# sourceMappingURL=chunk-GGQA6QBB.js.map
65
+ //# sourceMappingURL=chunk-GGQA6QBB.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useProduct.ts"],"names":[],"mappings":";;;AA4DO,SAAS,UAAA,CAAW,gBAAyB,OAAA,EAA+C;AACjG,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAkB,cAAc,CAAA;AAI9D,EAAA,MAAM,iBAAA,GAAoB,OAAgB,cAAc,CAAA;AACxD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,iBAAA,CAAkB,OAAA,GAAU,cAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,MAAM,MAAA,GAAS,YAAY,YAAY;AACrC,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,IAAI,CAAC,KAAA,EAAO,GAAA,EAAK,OAAA,EAAS,UAAA,EAAY;AACtC,IAAA,IAAI;AACF,MAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,GAAA,CAAI,QAAQ,UAAA,CAAW,MAAA,CAAO,OAAA,CAAQ,EAAE,CAAA,EAAG;AAAA,QACtE,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAA,IAAI,QAAA,EAAU,OAAA,IAAW,QAAA,CAAS,IAAA,EAAM;AACtC,QAAA,UAAA,CAAW,SAAS,IAAe,CAAA;AAAA,MACrC;AAAA,IACF,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF,CAAA,EAAG,CAAC,OAAA,CAAQ,EAAE,CAAC,CAAA;AAKf,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,UAAA,CAAW,kBAAkB,OAAO,CAAA;AAAA,EACtC,GAAG,CAAC,cAAA,CAAe,EAAA,EAAI,OAAA,EAAS,SAAS,CAAC,CAAA;AAG1C,EAAA,SAAA,CAAU,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AAoB,MAAM;AAC9B,MAAA,UAAA,CAAW,CAAC,IAAA,MAAU,EAAE,GAAG,IAAA,EAAM,eAAA,EAAiB,MAAK,CAAE,CAAA;AAAA,IAC3D,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,iCAAiC,iBAAiB,CAAA;AAAA,EACxE,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,SAAS,MAAA,EAAO;AAC3B","file":"chunk-B57KIBQL.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Product } from '../types';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseProductResult - Return type for useProduct hook\n */\nexport interface UseProductResult {\n /** Current product state (updates on option changes) */\n product: Product;\n /** Reload product data from API */\n reload: () => Promise<void>;\n}\n\nexport interface UseProductOptions {\n /**\n * True while `initialProduct` is a list-card stand-in. When it flips to false\n * (details arrived), state re-seeds. Do not infer this from `options`/`images`\n * — list payloads may include those fields.\n */\n isPreview?: boolean;\n}\n\n/**\n * useProduct - Hook for managing product state with live updates\n *\n * Provides reactive product data with automatic updates for price, stock,\n * and variant changes. Handles manual reloads (e.g., after add-to-cart)\n * and subscribes to Salla SDK events for real-time price updates.\n *\n * Stock status is reflected in `product.is_out_of_stock` which updates\n * when price calculations succeed or fail (e.g., unavailable option combinations).\n *\n * @param initialProduct - The initial product object (typically from loader/SSR).\n * @param options.isPreview - Pass true for a list-card placeholder so the hook\n * re-seeds when details for the same id arrive (`isPreview` goes false).\n *\n * @returns Object with product and reload function\n *\n * @example\n * ```tsx\n * function ProductDetails({ product }) {\n * const { product: updatedProduct, reload } = useProduct(product);\n *\n * const handleAddToCart = async () => {\n * await addToCart(updatedProduct.id);\n * await reload(); // Refresh product state after cart update\n * };\n *\n * return (\n * <div>\n * <h1>{updatedProduct.name}</h1>\n * <p>Price: {formatMoney(updatedProduct.price)}</p>\n * {updatedProduct.is_out_of_stock && <p>Currently out of stock</p>}\n * <button onClick={handleAddToCart}>Add to Cart</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProduct(initialProduct: Product, options?: UseProductOptions): UseProductResult {\n const [product, setProduct] = useState<Product>(initialProduct);\n\n // Always keep a ref to the latest initialProduct so the re-seed effect below\n // can read it without adding the full object to the dependency array.\n const initialProductRef = useRef<Product>(initialProduct);\n useEffect(() => {\n initialProductRef.current = initialProduct;\n });\n\n const reload = useCallback(async () => {\n const salla = window.salla;\n if (!salla?.api?.product?.getDetails) return;\n try {\n const response = await salla.api.product.getDetails(String(product.id), [\n 'images',\n 'category',\n ]);\n if (response?.success && response.data) {\n setProduct(response.data as Product);\n }\n } catch {\n // silently ignore network errors during reload\n }\n }, [product.id]);\n\n // Re-seed when the loader navigates to a different product, or when a\n // list-card placeholder (`isPreview`) is replaced by details for the same id.\n // Object identity is not a dependency — that would reset live option/price state.\n useEffect(() => {\n setProduct(initialProductRef.current);\n }, [initialProduct.id, options?.isPreview]);\n\n // Subscribe to Salla option-change events so price/stock stays in sync\n useEffect(() => onSallaEvent('product:options.updated', reload), [reload]);\n\n // Subscribe to price update events (matches product.js registerEvents)\n useEffect(() => {\n const handlePriceUpdated = (res: { data?: Record<string, unknown> }) => {\n const data = res.data;\n if (!data) return;\n\n setProduct((prev) => {\n const price = (data.price as number) ?? prev.price;\n const regularPrice = (data.regular_price as number) ?? prev.regular_price;\n // The payload has no sale_price: like product.js, `price` is the payable (sale) figure.\n const isOnSale = Boolean(data.has_sale_price) && regularPrice > price;\n return {\n ...prev,\n price,\n sale_price: isOnSale ? price : prev.sale_price,\n regular_price: regularPrice,\n is_on_sale: isOnSale,\n starting_price: null,\n weight: (data.weight as string) || '',\n // An empty variant SKU/barcode blanks it; a payload without the field keeps it (product.js).\n sku: data.sku === undefined ? prev.sku : (data.sku as string) || '',\n barcode: data.barcode === undefined ? prev.barcode : (data.barcode as string) || '',\n is_out_of_stock: false,\n };\n });\n };\n\n const listener = handlePriceUpdated as (...args: unknown[]) => void;\n\n // Root on/off: onPriceUpdated registers a wrapper that salla.event.off can't match.\n return onSallaEvent('product::price.updated', listener);\n }, []);\n\n // Subscribe to price update failed events (matches product.js)\n useEffect(() => {\n const handlePriceFailed = () => {\n setProduct((prev) => ({ ...prev, is_out_of_stock: true }));\n };\n\n return onSallaEvent('product::price.updated.failed', handlePriceFailed);\n }, []);\n\n return { product, reload };\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/useProduct.ts"],"names":[],"mappings":";;;AA4DO,SAAS,UAAA,CAAW,gBAAyB,OAAA,EAA+C;AACjG,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAkB,cAAc,CAAA;AAI9D,EAAA,MAAM,iBAAA,GAAoB,OAAgB,cAAc,CAAA;AACxD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,iBAAA,CAAkB,OAAA,GAAU,cAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,MAAM,MAAA,GAAS,YAAY,YAAY;AACrC,IAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,IAAA,IAAI,CAAC,KAAA,EAAO,GAAA,EAAK,OAAA,EAAS,UAAA,EAAY;AACtC,IAAA,IAAI;AACF,MAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,GAAA,CAAI,QAAQ,UAAA,CAAW,MAAA,CAAO,OAAA,CAAQ,EAAE,CAAA,EAAG;AAAA,QACtE,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAA,IAAI,QAAA,EAAU,OAAA,IAAW,QAAA,CAAS,IAAA,EAAM;AACtC,QAAA,UAAA,CAAW,SAAS,IAAe,CAAA;AAAA,MACrC;AAAA,IACF,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF,CAAA,EAAG,CAAC,OAAA,CAAQ,EAAE,CAAC,CAAA;AAKf,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,UAAA,CAAW,kBAAkB,OAAO,CAAA;AAAA,EACtC,GAAG,CAAC,cAAA,CAAe,EAAA,EAAI,OAAA,E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AGL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,oBAAoB,MAAM;AAC9B,MAAA,UAAA,CAAW,CAAC,IAAA,MAAU,EAAE,GAAG,IAAA,EAAM,eAAA,EAAiB,MAAK,CAAE,CAAA;AAAA,IAC3D,CAAA;AAEA,IAAA,OAAO,YAAA,CAAa,iCAAiC,iBAAiB,CAAA;AAAA,EACxE,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,SAAS,MAAA,EAAO;AAC3B","file":"chunk-GGQA6QBB.js","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Product } from '../types';\nimport { onSallaEvent } from '../utils/sdk-helpers';\n\n/**\n * UseProductResult - Return type for useProduct hook\n */\nexport interface UseProductResult {\n /** Current product state (updates on option changes) */\n product: Product;\n /** Reload product data from API */\n reload: () => Promise<void>;\n}\n\nexport interface UseProductOptions {\n /**\n * True while `initialProduct` is a list-card stand-in. When it flips to false\n * (details arrived), state re-seeds. Do not infer this from `options`/`images`\n * — list payloads may include those fields.\n */\n isPreview?: boolean;\n}\n\n/**\n * useProduct - Hook for managing product state with live updates\n *\n * Provides reactive product data with automatic updates for price, stock,\n * and variant changes. Handles manual reloads (e.g., after add-to-cart)\n * and subscribes to Salla SDK events for real-time price updates.\n *\n * Stock status is reflected in `product.is_out_of_stock` which updates\n * when price calculations succeed or fail (e.g., unavailable option combinations).\n *\n * @param initialProduct - The initial product object (typically from loader/SSR).\n * @param options.isPreview - Pass true for a list-card placeholder so the hook\n * re-seeds when details for the same id arrive (`isPreview` goes false).\n *\n * @returns Object with product and reload function\n *\n * @example\n * ```tsx\n * function ProductDetails({ product }) {\n * const { product: updatedProduct, reload } = useProduct(product);\n *\n * const handleAddToCart = async () => {\n * await addToCart(updatedProduct.id);\n * await reload(); // Refresh product state after cart update\n * };\n *\n * return (\n * <div>\n * <h1>{updatedProduct.name}</h1>\n * <p>Price: {formatMoney(updatedProduct.price)}</p>\n * {updatedProduct.is_out_of_stock && <p>Currently out of stock</p>}\n * <button onClick={handleAddToCart}>Add to Cart</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProduct(initialProduct: Product, options?: UseProductOptions): UseProductResult {\n const [product, setProduct] = useState<Product>(initialProduct);\n\n // Always keep a ref to the latest initialProduct so the re-seed effect below\n // can read it without adding the full object to the dependency array.\n const initialProductRef = useRef<Product>(initialProduct);\n useEffect(() => {\n initialProductRef.current = initialProduct;\n });\n\n const reload = useCallback(async () => {\n const salla = window.salla;\n if (!salla?.api?.product?.getDetails) return;\n try {\n const response = await salla.api.product.getDetails(String(product.id), [\n 'images',\n 'category',\n ]);\n if (response?.success && response.data) {\n setProduct(response.data as Product);\n }\n } catch {\n // silently ignore network errors during reload\n }\n }, [product.id]);\n\n // Re-seed when the loader navigates to a different product, or when a\n // list-card placeholder (`isPreview`) is replaced by details for the same id.\n // Object identity is not a dependency — that would reset live option/price state.\n useEffect(() => {\n setProduct(initialProductRef.current);\n }, [initialProduct.id, options?.isPreview]);\n\n // Subscribe to Salla option-change events so price/stock stays in sync\n useEffect(() => onSallaEvent('product:options.updated', reload), [reload]);\n\n // Subscribe to price update events (matches product.js registerEvents)\n useEffect(() => {\n const handlePriceUpdated = (res: { data?: Record<string, unknown> }) => {\n const data = res.data;\n if (!data) return;\n\n setProduct((prev) => {\n const price = (data.price as number) ?? prev.price;\n const regularPrice = (data.regular_price as number) ?? prev.regular_price;\n // The payload has no sale_price: like product.js, `price` is the payable (sale) figure.\n const isOnSale = Boolean(data.has_sale_price) && regularPrice > price;\n return {\n ...prev,\n price,\n sale_price: isOnSale ? price : prev.sale_price,\n regular_price: regularPrice,\n is_on_sale: isOnSale,\n starting_price: null,\n weight: (data.weight as string) || '',\n // An empty variant SKU/barcode blanks it; a payload without the field keeps it (product.js).\n sku: data.sku === undefined ? prev.sku : (data.sku as string) || '',\n barcode: data.barcode === undefined ? prev.barcode : (data.barcode as string) || '',\n is_out_of_stock: false,\n };\n });\n };\n\n const listener = handlePriceUpdated as (...args: unknown[]) => void;\n\n // Root on/off: onPriceUpdated registers a wrapper that salla.event.off can't match.\n return onSallaEvent('product::price.updated', listener);\n }, []);\n\n // Subscribe to price update failed events (matches product.js)\n useEffect(() => {\n const handlePriceFailed = () => {\n setProduct((prev) => ({ ...prev, is_out_of_stock: true }));\n };\n\n return onSallaEvent('product::price.updated.failed', handlePriceFailed);\n }, []);\n\n return { product, reload };\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { ensureTwilightContextFromMatches } from './chunk-X55R4VVK.js';
2
- import { renderThemeHookSlotsScript, renderAppScopeInstallScript } from './chunk-DPQIVZ4T.js';
2
+ import { renderThemeHookSlotsScript, renderAppScopeInstallScript } from './chunk-VDPMCOHX.js';
3
3
  import { resolveHead, mergeHead } from './chunk-GD26FI4J.js';
4
- import { buildBaseHead } from './chunk-P2PPBXHD.js';
5
- import { readEnv, renderRuntimeEnvScript, escapeForInlineScript } from './chunk-4E6FD5W7.js';
4
+ import { buildBaseHead } from './chunk-M2MJKUQF.js';
5
+ import { readEnv, renderRuntimeEnvScript, escapeForInlineScript } from './chunk-EEL6OYAQ.js';
6
6
  import { getTwilightContext, SettingsError } from './chunk-6K34BCUP.js';
7
7
  import { FALLBACK_LOCALE } from './chunk-T72DAX7R.js';
8
8
 
@@ -492,5 +492,5 @@ function buildCustomJsScript(customJs, isUrl) {
492
492
  }
493
493
 
494
494
  export { TICKETING_SCRIPT_URL, needsDocumentLoad, resolveTwilightSdkUrl, rootHead, setSnippetPageTargets, subscribeSnippetPageTargets };
495
- //# sourceMappingURL=chunk-WAKCWE6P.js.map
496
- //# sourceMappingURL=chunk-WAKCWE6P.js.map
495
+ //# sourceMappingURL=chunk-GMXNVBCD.js.map
496
+ //# sourceMappingURL=chunk-GMXNVBCD.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/snippet-page-compat.ts","../src/routes/root/head.ts"],"names":[],"mappings":";;;;;;;;;AAeA,IAAM,YAAA,GAAe,oDAAA;AAGr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IAAI;AAAC,GACvF;AACF;AAEA,SAAS,iBAAiB,CAAA,EAA0D;AAClF,EAAA,OAAO;AAAA;AAAA;AAAA,IAGL,GAAI,CAAA,CAAE,gBAAA,GAAmB,CAAC,EAAE,EAAA,EAAI,mBAAA,EAAqB,QAAA,EAAU,CAAA,CAAE,gBAAA,EAAkB,CAAA,GAAI,EAAC;AAAA,IACxF,EAAE,EAAA,EAAI,eAAA,EAAiB,QAAA,EAAU,iBAAA,EAAkB;AAAA;AAAA;AAAA,IAGnD,EAAE,EAAA,EAAI,iBAAA,EAAmB,QAAA,EAAU,EAAE,qBAAA,EAAsB;AAAA;AAAA;AAAA,IAG3D,GAAI,CAAA,CAAE,oBAAA,GACF,CAAC,EAAE,EAAA,EAAI,wBAAA,EAA0B,QAAA,EAAU,CAAA,CAAE,oBAAA,EAAsB,CAAA,GACnE,EAAC;AAAA,IACL,EAAE,EAAA,EAAI,iBAAA,EAAmB,QAAA,EAAU,iBAAA,EAAkB;AAAA;AAAA,IAErD,GAAI,CAAA,CAAE,QAAA,GAAW,CAAC,mBAAA,CAAoB,CAAA,CAAE,QAAA,EAAU,OAAA,CAAQ,CAAA,CAAE,aAAa,CAAC,CAAC,IAAI;AAAC,GAClF;AACF;AAIA,SAAS,mBAAA,CAAoB,UAAkB,KAAA,EAAgB;AAC7D,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,iBAAA;AAAA,IACJ,QAAA,EAAU,KAAA,GACN,CAAA,sGAAA,EAAyG,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAC,CAAC,CAAA,yDAAA,CAAA,GACxJ,CAAA,MAAA,EAAS,QAAQ,CAAA,yEAAA;AAAA,GACvB;AACF","file":"chunk-WAKCWE6P.js","sourcesContent":["/**\n * Compatibility mode for app snippets written for Twig, where every page is a full load.\n *\n * Such a snippet checks the page once, when it runs (`if (salla.url.is_page('product.single'))`),\n * and edits the DOM it finds. In the SPA it runs once per visit, on whatever page the shopper\n * landed on, so it never mounts on a later product page, and React replaces what it added when\n * the page changes. Until those apps move to the SDK's `page::view`, the engine loads the document fully\n * when a navigation enters or leaves a page one of them names, which is what Twig did. Only pages a\n * snippet names count: every other navigation stays in the browser.\n */\n\n/**\n * The start of a listener for SPA navigation, `on('page::view'` or `on('route::changed'`. The\n * page checks inside its arguments run on every navigation, so they need no full loads.\n */\nconst SPA_LISTENER = /\\bon\\s*\\(\\s*['\"](?:page::view|route::changed)['\"]/g;\n\n/** A `/` after one of these starts a regex literal, not a division. */\nconst BEFORE_REGEX = /[(,=:[!&|?{};+\\-*%<>~^]/;\n\n/** Index of the quote that ends the string opened at `start`, or -1. */\nfunction stringEnd(src: string, start: number): number {\n for (let i = start + 1; i < src.length; i++) {\n if (src[i] === '\\\\') i++;\n else if (src[i] === src[start]) return i;\n else if (src[i] === '\\n') return -1;\n }\n return -1;\n}\n\n/** Index of the `/` that ends the regex literal opened at `start`, or -1. */\nfunction regexEnd(src: string, start: number): number {\n let inClass = false;\n for (let i = start + 1; i < src.length; i++) {\n if (src[i] === '\\\\') i++;\n else if (src[i] === '[') inClass = true;\n else if (src[i] === ']') inClass = false;\n else if (src[i] === '/' && !inClass) return i;\n else if (src[i] === '\\n') return -1;\n }\n return -1;\n}\n\n/** From inside a template literal: the index of its closing backtick, or of the `{` of a `${`; -1 if neither. */\nfunction templatePartEnd(src: string, from: number): number {\n for (let i = from; i < src.length; i++) {\n if (src[i] === '\\\\') i++;\n else if (src[i] === '`') return i;\n else if (src[i] === '$' && src[i + 1] === '{') return i + 1;\n }\n return -1;\n}\n\n/**\n * The index just past the `)` that closes the `(` at `open`, or -1 when it never closes. Parens\n * in strings, template literals, comments and regex literals don't count: the snippet's own\n * `track('(')` must not end the call early and hide the code after it.\n */\nfunction closingParen(src: string, open: number): number {\n let depth = 0;\n let braces = 0;\n // Brace depth around each `${` the scan is inside, innermost last.\n const templates: number[] = [];\n let prev = '(';\n for (let i = open; i < src.length; i++) {\n const c = src[i];\n if (/\\s/.test(c)) continue;\n if (c === '/' && src[i + 1] === '/') {\n i = src.indexOf('\\n', i);\n if (i < 0) return -1;\n continue;\n }\n if (c === '/' && src[i + 1] === '*') {\n i = src.indexOf('*/', i + 2) + 1;\n if (i < 1) return -1;\n continue;\n }\n if (c === '\"' || c === \"'\") i = stringEnd(src, i);\n else if (c === '/' && BEFORE_REGEX.test(prev)) i = regexEnd(src, i);\n else if (c === '`' || (c === '}' && braces === 0 && templates.length)) {\n if (c === '}') braces = templates.pop() as number;\n i = templatePartEnd(src, i + 1);\n if (i >= 0 && src[i] === '{') {\n templates.push(braces);\n braces = 0;\n }\n } else if (c === '{') braces++;\n else if (c === '}') braces--;\n else if (c === '(') depth++;\n else if (c === ')' && --depth === 0) return i + 1;\n if (i < 0) return -1;\n prev = src[i];\n }\n return -1;\n}\n\n/**\n * `content` with each navigation listener's arguments cut out, up to the paren that closes the\n * call. What's left runs once, at load. A handler defined elsewhere and passed by name stays in,\n * and its checks still count: the scan can't tell where it runs, so it keeps the full load.\n */\nfunction stripNavigationListeners(content: string): string {\n let out = '';\n let from = 0;\n for (const match of content.matchAll(SPA_LISTENER)) {\n if (match.index < from) continue;\n const end = closingParen(content, content.indexOf('(', match.index));\n // Never closes, or the scan lost its place: keep the rest, so its checks still count.\n if (end < 0) break;\n out += content.slice(from, match.index);\n from = end;\n }\n return out + content.slice(from);\n}\n\n/** Index of the newline at or after `from`, or the end. */\nfunction lineEnd(src: string, from: number): number {\n const at = src.indexOf('\\n', from);\n return at < 0 ? src.length : at;\n}\n\n/** Whether `src` opens a comment at `i`. */\nconst isComment = (src: string, i: number) =>\n src[i] === '/' && (src[i + 1] === '/' || src[i + 1] === '*');\n\n/**\n * Index just past the comment, string or regex literal that opens at `i`, or -1 when code (or a\n * template literal, which holds code) starts there. `prev` is the last code character before it.\n */\nfunction literalEnd(src: string, i: number, prev: string): number {\n const c = src[i];\n if (isComment(src, i)) {\n if (src[i + 1] === '/') return lineEnd(src, i);\n const close = src.indexOf('*/', i + 2);\n return close < 0 ? src.length : close + 2;\n }\n if (c === '\"' || c === \"'\") {\n const close = stringEnd(src, i);\n return close < 0 ? lineEnd(src, i) : close + 1;\n }\n if (c === '/' && BEFORE_REGEX.test(prev)) {\n const close = regexEnd(src, i);\n return close < 0 ? -1 : close + 1;\n }\n return -1;\n}\n\n/**\n * Clears `code` over the template literal opened at `start`, all but the code inside its\n * `${…}`, which runs like any other. Returns the index of its closing backtick.\n */\nfunction maskTemplate(src: string, code: Uint8Array, start: number): number {\n code[start] = 0;\n for (let i = start + 1; i < src.length; i++) {\n code[i] = 0;\n if (src[i] === '\\\\') code[++i] = 0;\n else if (src[i] === '`') return i;\n else if (src[i] === '$' && src[i + 1] === '{') {\n code[i + 1] = 0;\n i = maskCode(src, code, i + 2, true);\n code[i] = 0;\n }\n }\n return src.length;\n}\n\n/**\n * Clears `code` over the comments and literals of the script from `from`. Inside a template's\n * `${…}` (`inExpression`), it stops at the `}` that closes it and returns that index.\n */\nfunction maskCode(src: string, code: Uint8Array, from: number, inExpression = false): number {\n let prev = '(';\n let braces = 0;\n for (let i = from; i < src.length; i++) {\n const c = src[i];\n if (/\\s/.test(c)) continue;\n const end = literalEnd(src, i, prev);\n if (end >= 0) {\n code.fill(0, i, end);\n // A literal is a value, so a `/` after it divides; a comment changes nothing.\n if (!isComment(src, i)) prev = 'a';\n i = end - 1;\n continue;\n }\n if (c === '`') {\n i = maskTemplate(src, code, i);\n prev = 'a';\n continue;\n }\n if (inExpression && c === '}' && braces-- === 0) return i;\n if (c === '{') braces++;\n prev = c;\n }\n return src.length;\n}\n\n/** Which characters of a script are code: not in a comment, string or template text. */\nfunction scriptMask(src: string): Uint8Array {\n const code = new Uint8Array(src.length).fill(1);\n maskCode(src, code, 0);\n return code;\n}\n\n/** A `type` the browser runs as JavaScript: none, `module`, or a JavaScript MIME type. */\nconst JS_TYPE = /^(?:|module|(?:text|application)\\/(?:x-)?(?:java|ecma)script)$/i;\n\n/**\n * The JavaScript an inline snippet runs: the text of its `<script>` elements, parsed by the\n * browser as `injectHtml` parses it, so attributes, quotes and the HTML around a script read as\n * they will on the page. A snippet with no `<script>` tag, or a scan with no DOM, reads whole.\n */\nfunction snippetScripts(snippet: string): string[] {\n if (!/<script\\b/i.test(snippet) || typeof document === 'undefined') return [snippet];\n const tpl = document.createElement('template');\n tpl.innerHTML = snippet;\n return Array.from(tpl.content.querySelectorAll('script'))\n .filter((script) => JS_TYPE.test(script.type.trim()))\n .map((script) => script.text);\n}\n\n/** `is_page('product.single')` with a literal slug. */\nconst IS_PAGE_LITERAL = /\\bis_page\\s*\\(\\s*['\"]([\\w.-]+)['\"]\\s*\\)/g;\n\n/**\n * A negated check, `!salla.url.is_page('cart')`, `!(is_page('cart'))` or\n * `is_page('cart') === false`: it acts on every page but the one it names, so that slug says\n * nothing about where it acts.\n */\n// Character classes for the `(` and `salla.url.` prefixes, not repeated groups: no nested\n// quantifier to backtrack on, as the snippet text is the app's.\nconst IS_PAGE_NEGATED =\n /![\\s(]*[\\w$.]*is_page\\s*\\(\\s*['\"][\\w.-]+['\"]\\s*\\)|\\bis_page\\s*\\(\\s*['\"][\\w.-]+['\"]\\s*\\)\\s*={2,3}\\s*false\\b/g;\n\n/**\n * The pages an inline snippet's code depends on: the slugs it passes to `is_page` as a literal,\n * or nothing when it doesn't care or reads the page only inside a `page::view` listener.\n *\n * Only a literal, positive check counts. A negated one, `page.slug`, `config.get('page')` or a\n * slug held in a variable would point at every page, and a full load on every navigation costs\n * the whole store its in-browser navigation (#513), so those snippets keep running once.\n */\nexport function snippetPageTargets(snippet: string): string[] {\n const slugs = new Set<string>();\n for (const script of snippetScripts(snippet)) {\n for (const slug of scriptPageTargets(script)) slugs.add(slug);\n }\n return [...slugs];\n}\n\n/** The slugs one script checks with a literal, positive `is_page`, in code that runs at load. */\nfunction scriptPageTargets(script: string): string[] {\n const content = stripNavigationListeners(script);\n const code = scriptMask(content);\n const negated = [...content.matchAll(IS_PAGE_NEGATED)].map(\n (m) => [m.index, m.index + m[0].length] as const\n );\n return [...content.matchAll(IS_PAGE_LITERAL)]\n .filter(\n ({ index }) => code[index] && !negated.some(([from, to]) => index >= from && index < to)\n )\n .map((m) => m[1]);\n}\n\n/** Pages that need a full load, across every installed app's inline snippets. */\nlet targets = new Set<string>();\n\n/** Told whether any page needs a full load, each time the snippets are recorded. */\ntype TargetsListener = (active: boolean) => void;\nconst listeners = new Set<TargetsListener>();\n\n/**\n * Calls `listener` now and whenever the snippets are recorded, with whether any page needs a full\n * load. The router installs its navigation blocker only while one does: a blocker makes every\n * history push wait a tick, which stores without such snippets shouldn't pay for.\n */\nexport function subscribeSnippetPageTargets(listener: TargetsListener): () => void {\n listeners.add(listener);\n listener(targets.size > 0);\n return () => listeners.delete(listener);\n}\n\n/**\n * Records the installed apps' inline snippets. CDN snippets are not scanned: their code is on\n * another origin. `AppsSnippets` calls this once the snippets are known.\n */\nexport function setSnippetPageTargets(\n snippets: ReadonlyArray<{ content: string; url?: string | null }>\n): void {\n const next = new Set<string>();\n for (const s of snippets) {\n if (s.url) continue;\n for (const slug of snippetPageTargets(s.content)) next.add(slug);\n }\n targets = next;\n listeners.forEach((listener) => listener(next.size > 0));\n if (next.size && typeof console !== 'undefined') {\n console.warn(\n '[salla] app snippets depend on the page; navigating to or from these pages reloads the document:',\n [...next]\n );\n }\n}\n\n/**\n * Whether going from the page `from` to the page `to` must load the document fully: when either\n * is a page some app snippet targets. Leaving one matters as much as entering: a widget an app\n * added to <body> for the product page would otherwise stay on the cart.\n */\nexport function needsDocumentLoad(from: string | undefined, to: string | undefined): boolean {\n if (!targets.size) return false;\n return (!!from && targets.has(from)) || (!!to && targets.has(to));\n}\n\n/** @internal Test-only. */\nexport function resetSnippetPageTargets(): void {\n targets = new Set();\n listeners.forEach((listener) => listener(false));\n}\n","import type { HeadDescriptor, HeadResult } from '../../utils/head';\nimport { mergeHead, resolveHead } from '../../utils/head';\nimport { buildBaseHead } from '../../utils/baseHead';\nimport { FALLBACK_LOCALE } from '../../providers/locale-constants';\nimport { getTwilightContext } from '../../twilight/context';\nimport type { TwilightContextMatch } from '../../twilight/ensure-context';\nimport { ensureTwilightContextFromMatches } from '../../twilight/ensure-context';\nimport type { StoreContext } from '../../api/store';\nimport type { AppSnippet } from '../../api/apps';\nimport { SettingsError } from '../../utils/errors';\nimport { renderAppScopeInstallScript } from '../../utils/app-scope';\nimport { renderThemeHookSlotsScript } from '../../utils/theme-hook-slots';\nimport { escapeForInlineScript } from '../../utils/inline-script';\nimport { readEnv, renderRuntimeEnvScript } from '../../utils/runtime-env';\n\nconst SALLA_ICONS_CSS_URL = 'https://cdn.assets.salla.network/static/fonts/sallaicons.css?v=2.0.5';\nconst LIT_VERSION = '3.3.3';\nconst LIT_CDN_BASE = `https://cdn.assets.salla.network/static/lit/${LIT_VERSION}`;\n\n/** Bare-specifier map for the lit build the engine's `<salla-*>` web components resolve against. */\nconst LIT_IMPORTS: Record<string, string> = {\n lit: `${LIT_CDN_BASE}/lit.js`,\n 'lit/': `${LIT_CDN_BASE}/`,\n 'lit-html': `${LIT_CDN_BASE}/lit-html/lit-html.js`,\n 'lit-html/': `${LIT_CDN_BASE}/lit-html/`,\n 'lit-element': `${LIT_CDN_BASE}/lit-element/lit-element.js`,\n 'lit-element/': `${LIT_CDN_BASE}/lit-element/`,\n '@lit/reactive-element': `${LIT_CDN_BASE}/reactive-element/reactive-element.js`,\n '@lit/reactive-element/': `${LIT_CDN_BASE}/reactive-element/`,\n};\n\nexport const TICKETING_SCRIPT_URL =\n 'https://cdn.assets.salla.network/latest/@salla.sa/ui-store-ticketing-system/ticketing-system.es.js';\n\nconst TWILIGHT_RELEASE_CDN = 'https://cdn.salla.network/js/twilight';\nconst TWILIGHT_DEV_CDN = 'https://cdn.assets.salla.network/dev/@salla.sa/twilight';\n// The oldest Twilight release this engine works with. Raise it whenever the engine\n// starts relying on something newer; the reason lives in that commit. Today's floor:\n// components ship their own CSS, which themes no longer compile (SallaApp/twilight#2107).\nconst MIN_TWILIGHT_VERSION = '2.14.538';\n// Last resort when no override and no platform pin, and the substitute for a pin below the floor.\nconst DEFAULT_TWILIGHT_VERSION = '2.14.584';\nconst releaseUrl = (version: string): string =>\n `${TWILIGHT_RELEASE_CDN}/${version}/twilight.esm.js`;\n// The head is built more than once per request (early hints, then the page); say it once.\nconst warnedPins = new Set<string>();\n\n/** `x.y.z` release pins only; dev shas and other strings are loaded as given. */\nfunction belowMinimum(version: string): boolean {\n return (\n /^\\d+\\.\\d+\\.\\d+$/.test(version) &&\n version.localeCompare(MIN_TWILIGHT_VERSION, undefined, { numeric: true }) < 0\n );\n}\n\n/** The `x.y.z` release segment of a release-CDN `.../twilight.esm.js` URL, if present. */\nfunction releaseVersionInUrl(url: string): string | null {\n const match = url.match(/\\/(\\d+\\.\\d+\\.\\d+)\\/twilight\\.esm\\.js(?:[?#]|$)/);\n return match ? match[1] : null;\n}\n\n/**\n * `VITE_TWILIGHT_URL`/`VITE_TWILIGHT_VERSION` outrank everything below, including\n * `theme.twilight.version`'s own `belowMinimum` guard — a stale override wins\n * silently otherwise (TD-16375: a scaffold-time pin outlived the engine raising\n * MIN_TWILIGHT_VERSION, so every new theme rendered without component CSS and\n * nothing said why). Only a dev-mode nudge, not a swap: an env override is a\n * deliberate choice, so unlike the settings-pin path below this never substitutes\n * the engine default underneath the developer.\n */\nfunction warnIfOverrideBelowMinimum(source: string, version: string): void {\n // Worker logs in production should stay quiet -- this is a developer-directed nudge,\n // not a user-facing or production-monitored signal. import.meta.env.DEV is a static\n // false in production builds, so this branch (and the console.warn below) is\n // tree-shaken out entirely, same as DevSettingsWidget / dev-settings-store.ts.\n if (!import.meta.env.DEV) return;\n if (!belowMinimum(version)) return;\n const key = `${source}:${version}`;\n if (warnedPins.has(key)) return;\n warnedPins.add(key);\n console.warn(\n `[twilight] ${source}=${version} is below the engine minimum ${MIN_TWILIGHT_VERSION} — components may load without their CSS (SallaApp/twilight#2107). Unset it or bump it to ${MIN_TWILIGHT_VERSION}+.`\n );\n}\n\n/**\n * Which twilight.esm.js the storefront loads, in priority order:\n * 1. `VITE_TWILIGHT_URL` — full local/deployment override.\n * 2. `VITE_TWILIGHT_VERSION` — dev-CDN build override.\n * 3. `theme.twilight.version` from the settings endpoint — the platform-pinned\n * release used when no environment override is configured.\n * 4. The engine's default release, also used when the pin is below the engine minimum.\n */\nexport function resolveTwilightSdkUrl(settings?: StoreContext): string {\n const urlOverride = readEnv('VITE_TWILIGHT_URL');\n if (urlOverride) {\n const version = releaseVersionInUrl(urlOverride);\n if (version) warnIfOverrideBelowMinimum('VITE_TWILIGHT_URL', version);\n return urlOverride;\n }\n\n const versionOverride = readEnv('VITE_TWILIGHT_VERSION');\n if (versionOverride) {\n warnIfOverrideBelowMinimum('VITE_TWILIGHT_VERSION', versionOverride);\n return `${TWILIGHT_DEV_CDN}/${versionOverride}/twilight.esm.js`;\n }\n\n const pinnedVersion = settings?.theme?.twilight?.version;\n if (pinnedVersion && belowMinimum(pinnedVersion)) {\n if (!warnedPins.has(pinnedVersion)) {\n warnedPins.add(pinnedVersion);\n console.warn(\n `[twilight] theme.twilight.version ${pinnedVersion} is below the engine minimum ${MIN_TWILIGHT_VERSION}; loading ${DEFAULT_TWILIGHT_VERSION} instead`\n );\n }\n return releaseUrl(DEFAULT_TWILIGHT_VERSION);\n }\n if (pinnedVersion) return releaseUrl(pinnedVersion);\n\n return releaseUrl(DEFAULT_TWILIGHT_VERSION);\n}\n\n// On a page that preloads its LCP image, the icon font (~270 KB) applies once the first screen's\n// priority images have painted, so it doesn't compete with them; other pages swap on load.\nconst MEDIA_SWAP_SCRIPT = `\n(function(){var d=document,s=function(l){if(l.sheet||\"all\"===l.media)l.media=\"all\";else l.onload=function(){this.media=\"all\"}},f=d.getElementById(\"salla-theme-font\"),i=d.getElementById(\"salla-icons-css\");f&&s(f);if(!i)return;if(!d.querySelector('link[rel=\"preload\"][as=\"image\"]'))return s(i);var g=function(){g=function(){};s(i)},p=function(){requestAnimationFrame(function(){setTimeout(function(){g()})});setTimeout(function(){g()},100)};d.addEventListener(\"DOMContentLoaded\",function(){var m=[].filter.call(d.querySelectorAll('img[fetchpriority=\"high\"]'),function(x){return!x.complete}),n=m.length;if(!n)return p();m.forEach(function(x){var o=function(){--n||p()};x.addEventListener(\"load\",o,{once:!0});x.addEventListener(\"error\",o,{once:!0})});setTimeout(function(){g()},2500)})})();\n`.trim();\n\nconst LOADING_CSS = `\n.loading-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#fff;z-index:9999}\n.loading-spinner{animation:spin 1s linear infinite;border-radius:9999px;height:3rem;width:3rem;border-bottom:2px solid var(--color-primary,#000)}\n@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}\nhtml,body{margin:0;padding:0;height:100%}\n`.trim();\n\nconst SALLA_INIT_SCRIPT = `\nwindow.salla = window.Salla = window.Salla || window.salla || {};\nwindow.Salla.onReady = window.Salla.onReady || function(callback) {\n return new Promise(function(resolve) {\n if (window.Salla.status === 'ready') {\n var config = window.salla && window.salla.config && window.salla.config.all();\n resolve(callback ? callback(config) : config);\n } else {\n window.addEventListener('twilight::initiated', function(event) {\n resolve(callback ? callback(event.detail) : event.detail);\n }, { once: true });\n }\n });\n};\n`.trim();\n\n/**\n * Distinct snippet-host origins to `preconnect` (warm DNS/TCP/TLS during parse). From the real\n * URLs (dev/prod-correct), deduped and capped at 4. No `crossOrigin`: snippets are no-cors fetches.\n */\nexport function snippetPreconnectOrigins(snippets: readonly AppSnippet[] | undefined): string[] {\n if (!snippets?.length) return [];\n const origins = new Set<string>();\n for (const app of snippets) {\n if (app.status !== 'enabled') continue;\n for (const s of app.snippets) {\n if (!s.url) continue;\n try {\n origins.add(new URL(s.url).origin);\n } catch {\n /* skip a malformed snippet url rather than breaking the head */\n }\n if (origins.size >= 4) return [...origins];\n }\n }\n return [...origins];\n}\n\nexport function rootHead(ctx: {\n params: Record<string, string>;\n matches?: readonly TwilightContextMatch[];\n}): HeadResult {\n // Re-run on the client during hydration, where the twilight module store may\n // still be empty. Recover it from the resolved match context so the head is\n // built from real settings instead of falling through to 'Store Unavailable'.\n ensureTwilightContextFromMatches(ctx.matches);\n\n let settings: StoreContext | undefined;\n try {\n settings = getTwilightContext().settings;\n } catch (e) {\n if (e instanceof SettingsError) {\n return resolveHead({\n title: 'Store Unavailable',\n });\n }\n throw e;\n }\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n const parts = deriveHeadParts(settings);\n\n return resolveHead(\n mergeHead(buildBaseHead(settings, locale), {\n meta: buildRootMeta(parts),\n links: buildRootLinks(parts),\n styles: buildRootStyles(parts),\n importMap: [{ imports: LIT_IMPORTS }],\n scripts: buildRootScripts(parts),\n })\n );\n}\n\n/** Everything the root head's tag builders read, derived once from the store settings. */\ninterface RootHeadParts {\n store: StoreContext['store'] | undefined;\n favicon?: string;\n primaryColor?: string;\n fontUrl?: string;\n fontUrlWithDisplay?: string;\n isGoogleFont?: boolean;\n fontFamilyName?: string;\n customJs?: string;\n customCss?: string;\n isCustomCssUrl?: boolean;\n isCustomJsUrl?: boolean;\n twilightSdkUrl: string;\n /** The visitor gets the maintenance page, which loads no SDK and no app snippets. */\n maintenance: boolean;\n snippetPreconnects: Array<{ rel: 'preconnect'; href: string }>;\n appScopeInstallScript: string;\n themeHookSlotsScript: string | null;\n runtimeEnvScript: string | null;\n}\n\n/** Google Fonts only honours `display=swap` as a query param; other hosts get the @font-face\n * override instead (see buildRootStyles). */\nfunction deriveFontParts(theme?: StoreContext['theme']) {\n const font = theme?.font;\n const fontUrl = font?.url || font?.path;\n const isGoogleFont = fontUrl?.includes('fonts.googleapis.com');\n const needsDisplay = Boolean(isGoogleFont && fontUrl && !fontUrl.includes('display='));\n const separator = fontUrl?.includes('?') ? '&' : '?';\n\n return {\n fontUrl,\n isGoogleFont,\n fontFamilyName: font?.family_name,\n fontUrlWithDisplay: needsDisplay ? `${fontUrl}${separator}display=swap` : fontUrl,\n };\n}\n\n/** Theme customization JS/CSS, each either a URL to load or an inline blob to embed. */\nfunction deriveCustomizationParts(theme?: StoreContext['theme']) {\n const customization = theme?.customization;\n const customJs = customization?.js?.trim();\n const customCss = customization?.css?.trim();\n const isUrl = (value?: string): boolean =>\n Boolean(value?.startsWith('http') || value?.startsWith('//'));\n\n return {\n customJs,\n customCss,\n isCustomCssUrl: isUrl(customCss),\n isCustomJsUrl: isUrl(customJs),\n };\n}\n\nfunction deriveHeadParts(settings?: StoreContext): RootHeadParts {\n const store = settings?.store;\n\n return {\n store,\n favicon: store?.icon,\n primaryColor: settings?.theme?.color?.primary,\n ...deriveFontParts(settings?.theme),\n ...deriveCustomizationParts(settings?.theme),\n twilightSdkUrl: resolveTwilightSdkUrl(settings),\n maintenance: getTwilightContext().maintenance,\n // Warm the connection to the snippet host(s) during head parse, so the body's deferred\n // `<script src>` snippet tags fetch off an already-open socket instead of DNS+TCP+TLS.\n snippetPreconnects: snippetPreconnectOrigins(getTwilightContext().appsSnippets).map((href) => ({\n rel: 'preconnect' as const,\n href,\n })),\n // Install `Salla.appScope` inline at parse time, before the SDK is ready — else a snippet's\n // onReady callback calls it too early and throws. Always emitted, even when the settings\n // prefetch failed: the CDN snippet tags ship regardless (they come from the *snippets*\n // endpoint), so the factory has to exist for them. `installAppScope` then seeds the real\n // buckets into this install once the client query resolves.\n appScopeInstallScript: renderAppScopeInstallScript(\n getTwilightContext().appsSettings ?? { apps: {} }\n ),\n // Whitelist the theme's own hook slots at parse time too, for the same reason: apps register\n // their `onReady` callbacks from parser-inserted snippet tags, long before React hydrates.\n themeHookSlotsScript: renderThemeHookSlotsScript(),\n // Env this render resolved (worker `vars` live in server-only `process.env`), handed to the\n // client so it doesn't silently fall back to the production defaults. Re-rendered on the\n // client during hydration, where it resolves to the same values or to nothing.\n runtimeEnvScript: renderRuntimeEnvScript(),\n };\n}\n\nfunction buildRootMeta(p: RootHeadParts): NonNullable<HeadDescriptor['meta']> {\n return [\n { name: 'robots', content: 'index, follow' },\n { name: 'msapplication-TileColor', content: '#ffffff' },\n ...(p.favicon ? [{ name: 'msapplication-TileImage', content: p.favicon }] : []),\n ...(p.primaryColor\n ? [\n { name: 'theme-color', content: p.primaryColor },\n { name: 'msapplication-navbutton-color', content: p.primaryColor },\n { name: 'apple-mobile-web-app-status-bar-style', content: p.primaryColor },\n ]\n : []),\n ];\n}\n\nfunction buildRootLinks(p: RootHeadParts): NonNullable<HeadDescriptor['links']> {\n return [\n { rel: 'preconnect', href: 'https://api.salla.dev' },\n { rel: 'preconnect', href: 'https://cdn.salla.sa' },\n { rel: 'preconnect', href: 'https://cdn.assets.salla.network', crossOrigin: 'anonymous' },\n // Warm the installed apps' CDN snippet host(s) — see snippetPreconnectOrigins.\n // Not on the maintenance page: it renders neither the snippets nor the SDK.\n ...(p.maintenance ? [] : p.snippetPreconnects),\n ...(p.isGoogleFont\n ? [\n {\n rel: 'preconnect' as const,\n href: 'https://fonts.gstatic.com',\n crossOrigin: 'anonymous' as const,\n },\n ]\n : []),\n ...(p.maintenance ? [] : [{ rel: 'modulepreload' as const, href: p.twilightSdkUrl }]),\n ...(p.fontUrlWithDisplay\n ? [\n {\n id: 'salla-theme-font',\n rel: 'stylesheet',\n href: p.fontUrlWithDisplay,\n media: 'print',\n },\n ]\n : []),\n ...(p.fontUrlWithDisplay && !p.isGoogleFont && p.fontFamilyName\n ? [\n {\n id: 'salla-font-display-override',\n rel: 'preload',\n as: 'style',\n href: p.fontUrlWithDisplay,\n },\n ]\n : []),\n ...(p.favicon ? [{ rel: 'icon', href: p.favicon }] : []),\n ...(p.favicon\n ? [{ id: 'salla-apple-icon', rel: 'apple-touch-icon-precomposed', href: p.favicon }]\n : []),\n ...(p.isCustomCssUrl && p.customCss\n ? [{ id: 'salla-custom-css', rel: 'stylesheet', href: p.customCss }]\n : []),\n {\n id: 'salla-icons-css',\n rel: 'stylesheet',\n href: SALLA_ICONS_CSS_URL,\n media: 'print',\n },\n // {\n // id: 'intl-tel-input-css',\n // rel: 'stylesheet',\n // href: 'https://cdn.jsdelivr.net/npm/intl-tel-input@26.8.0/build/css/intlTelInput.css',\n // },\n ...(p.isCustomJsUrl && p.customJs\n ? [{ id: 'salla-custom-js-preload', rel: 'preload', as: 'script', href: p.customJs }]\n : []),\n ];\n}\n\n// Hoistable (href + precedence): the web components insert their own <style> near the top of\n// <head> before hydration, which a positionally hydrated <style> would be matched against.\nconst hoisted = (id: string, children: string) => ({\n id,\n href: id,\n precedence: 'default',\n children,\n});\n\nfunction buildRootStyles(p: RootHeadParts): NonNullable<HeadDescriptor['styles']> {\n return [\n hoisted('twilight-loading', LOADING_CSS),\n ...(!p.isGoogleFont && p.fontFamilyName\n ? [\n hoisted(\n 'salla-font-display-swap',\n `@font-face{font-family:\"${p.fontFamilyName}\";font-display:swap;src:local(\"${p.fontFamilyName}\")}`\n ),\n ]\n : []),\n ...(!p.isCustomCssUrl && p.customCss ? [hoisted('salla-custom-css', p.customCss)] : []),\n ];\n}\n\nfunction buildRootScripts(p: RootHeadParts): NonNullable<HeadDescriptor['scripts']> {\n return [\n // First: the API base / store identifier this render used, so the hydrated client\n // resolves the same ones (worker `vars` never reach the browser bundle on their own).\n ...(p.runtimeEnvScript ? [{ id: 'salla-runtime-env', children: p.runtimeEnvScript }] : []),\n { id: 'twilight-init', children: SALLA_INIT_SCRIPT },\n // After twilight-init (which defines window.Salla) and before the SDK module, so the\n // appScope factory exists ahead of any snippet's onReady callback firing.\n { id: 'salla-app-scope', children: p.appScopeInstallScript },\n // Arms the hook-slot whitelist push here, so its `twilight::initiated` listener is\n // registered before any app snippet's — listeners fire in registration order.\n ...(p.themeHookSlotsScript\n ? [{ id: 'salla-theme-hook-slots', children: p.themeHookSlotsScript }]\n : []),\n { id: 'salla-async-css', children: MEDIA_SWAP_SCRIPT },\n // The SDK and ticketing modules are rendered at the end of <body> (SallaSdkScripts).\n ...(p.customJs ? [buildCustomJsScript(p.customJs, Boolean(p.isCustomJsUrl))] : []),\n ];\n}\n\n/** A URL customization is loaded after SDK init; an inline one is wrapped so a syntax/runtime\n * error in partner JS warns instead of taking the page down. */\nfunction buildCustomJsScript(customJs: string, isUrl: boolean) {\n return {\n id: 'salla-custom-js',\n children: isUrl\n ? `window.addEventListener('twilight::initiated',function(){var s=document.createElement('script');s.src=${escapeForInlineScript(JSON.stringify(customJs))};s.async=true;document.head.appendChild(s)},{once:true});`\n : `try { ${customJs} } catch(e) { console.warn(\"[ThemeCustomization] Custom JS error:\", e); }`,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/snippet-page-compat.ts","../src/routes/root/head.ts"],"names":[],"mappings":";;;;;;;;;AAeA,IAAM,YAAA,GAAe,oDAAA;AAGrB,IAAM,YAAA,GAAe,yBAAA;AAGrB,SAAS,SAAA,CAAU,KAAa,KAAA,EAAuB;AACrD,EAAA,KAAA,IAAS,IAAI,KAAA,GAAQ,CAAA,EAAG,CAAA,GAAI,GAAA,CAAI,QAAQ,CAAA,EAAA,EAAK;AAC3C,IAAA,IAAI,GAAA,CAAI,CAAC,CAAA,KAAM,IAAA,EAAM,CAAA,EAAA;AAAA,SAAA,IACZ,IAAI,CAAC,CAAA,KAAM,GAAA,CAAI,KAAK,GAAG,OAAO,CAAA;AAAA,SAAA,IAC9B,GAAA,CAAI,CAAC,CAAA,KAAM,IAAA,EAAM,OAAO,EAAA;AAAA,EACnC;AACA,EAAA,OAAO,EAAA;AACT;AAGA,SAAS,QAAA,CAAS,KAAa,KAAA,EAAuB;AACpD,EAAA,IAAI,OAAA,GAAU,KAAA;AACd,EAAA,KAAA,IAAS,IAAI,KAAA,GAAQ,CAAA,EAAG,CAAA,GAAI,GAAA,CAAI,QAAQ,CAAA,EAAA,EAAK;AAC3C,IAAA,IAAI,GAAA,CAAI,CAAC,CAAA,KAAM,IAAA,EAAM,CAAA,EAAA;AAAA,SAAA,IACZ,GAAA,CAAI,CAAC,CAAA,KAAM,GAAA,EAAK,OAAA,GAAU,IAAA;AAAA,SAAA,IAC1B,GAAA,CAAI,CAAC,CAAA,KAAM,GAAA,EAAK,OAAA,GAAU,KAAA;AAAA,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AAAA,IACJ,QAAA,EAAU,KAAA,GACN,CAAA,sGAAA,EAAyG,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAC,CAAC,CAAA,yDAAA,CAAA,GACxJ,CAAA,MAAA,EAAS,QAAQ,CAAA,yEAAA;AAAA,GACvB;AACF","file":"chunk-GMXNVBCD.js","sourcesContent":["/**\n * Compatibility mode for app snippets written for Twig, where every page is a full load.\n *\n * Such a snippet checks the page once, when it runs (`if (salla.url.is_page('product.single'))`),\n * and edits the DOM it finds. In the SPA it runs once per visit, on whatever page the shopper\n * landed on, so it never mounts on a later product page, and React replaces what it added when\n * the page changes. Until those apps move to the SDK's `page::view`, the engine loads the document fully\n * when a navigation enters or leaves a page one of them names, which is what Twig did. Only pages a\n * snippet names count: every other navigation stays in the browser.\n */\n\n/**\n * The start of a listener for SPA navigation, `on('page::view'` or `on('route::changed'`. The\n * page checks inside its arguments run on every navigation, so they need no full loads.\n */\nconst SPA_LISTENER = /\\bon\\s*\\(\\s*['\"](?:page::view|route::changed)['\"]/g;\n\n/** A `/` after one of these starts a regex literal, not a division. */\nconst BEFORE_REGEX = /[(,=:[!&|?{};+\\-*%<>~^]/;\n\n/** Index of the quote that ends the string opened at `start`, or -1. */\nfunction stringEnd(src: string, start: number): number {\n for (let i = start + 1; i < src.length; i++) {\n if (src[i] === '\\\\') i++;\n else if (src[i] === src[start]) return i;\n else if (src[i] === '\\n') return -1;\n }\n return -1;\n}\n\n/** Index of the `/` that ends the regex literal opened at `start`, or -1. */\nfunction regexEnd(src: string, start: number): number {\n let inClass = false;\n for (let i = start + 1; i < src.length; i++) {\n if (src[i] === '\\\\') i++;\n else if (src[i] === '[') inClass = true;\n else if (src[i] === ']') inClass = false;\n else if (src[i] === '/' && !inClass) return i;\n else if (src[i] === '\\n') return -1;\n }\n return -1;\n}\n\n/** From inside a template literal: the index of its closing backtick, or of the `{` of a `${`; -1 if neither. */\nfunction templatePartEnd(src: string, from: number): number {\n for (let i = from; i < src.length; i++) {\n if (src[i] === '\\\\') i++;\n else if (src[i] === '`') return i;\n else if (src[i] === '$' && src[i + 1] === '{') return i + 1;\n }\n return -1;\n}\n\n/**\n * The index just past the `)` that closes the `(` at `open`, or -1 when it never closes. Parens\n * in strings, template literals, comments and regex literals don't count: the snippet's own\n * `track('(')` must not end the call early and hide the code after it.\n */\nfunction closingParen(src: string, open: number): number {\n let depth = 0;\n let braces = 0;\n // Brace depth around each `${` the scan is inside, innermost last.\n const templates: number[] = [];\n let prev = '(';\n for (let i = open; i < src.length; i++) {\n const c = src[i];\n if (/\\s/.test(c)) continue;\n if (c === '/' && src[i + 1] === '/') {\n i = src.indexOf('\\n', i);\n if (i < 0) return -1;\n continue;\n }\n if (c === '/' && src[i + 1] === '*') {\n i = src.indexOf('*/', i + 2) + 1;\n if (i < 1) return -1;\n continue;\n }\n if (c === '\"' || c === \"'\") i = stringEnd(src, i);\n else if (c === '/' && BEFORE_REGEX.test(prev)) i = regexEnd(src, i);\n else if (c === '`' || (c === '}' && braces === 0 && templates.length)) {\n if (c === '}') braces = templates.pop() as number;\n i = templatePartEnd(src, i + 1);\n if (i >= 0 && src[i] === '{') {\n templates.push(braces);\n braces = 0;\n }\n } else if (c === '{') braces++;\n else if (c === '}') braces--;\n else if (c === '(') depth++;\n else if (c === ')' && --depth === 0) return i + 1;\n if (i < 0) return -1;\n prev = src[i];\n }\n return -1;\n}\n\n/**\n * `content` with each navigation listener's arguments cut out, up to the paren that closes the\n * call. What's left runs once, at load. A handler defined elsewhere and passed by name stays in,\n * and its checks still count: the scan can't tell where it runs, so it keeps the full load.\n */\nfunction stripNavigationListeners(content: string): string {\n let out = '';\n let from = 0;\n for (const match of content.matchAll(SPA_LISTENER)) {\n if (match.index < from) continue;\n const end = closingParen(content, content.indexOf('(', match.index));\n // Never closes, or the scan lost its place: keep the rest, so its checks still count.\n if (end < 0) break;\n out += content.slice(from, match.index);\n from = end;\n }\n return out + content.slice(from);\n}\n\n/** Index of the newline at or after `from`, or the end. */\nfunction lineEnd(src: string, from: number): number {\n const at = src.indexOf('\\n', from);\n return at < 0 ? src.length : at;\n}\n\n/** Whether `src` opens a comment at `i`. */\nconst isComment = (src: string, i: number) =>\n src[i] === '/' && (src[i + 1] === '/' || src[i + 1] === '*');\n\n/**\n * Index just past the comment, string or regex literal that opens at `i`, or -1 when code (or a\n * template literal, which holds code) starts there. `prev` is the last code character before it.\n */\nfunction literalEnd(src: string, i: number, prev: string): number {\n const c = src[i];\n if (isComment(src, i)) {\n if (src[i + 1] === '/') return lineEnd(src, i);\n const close = src.indexOf('*/', i + 2);\n return close < 0 ? src.length : close + 2;\n }\n if (c === '\"' || c === \"'\") {\n const close = stringEnd(src, i);\n return close < 0 ? lineEnd(src, i) : close + 1;\n }\n if (c === '/' && BEFORE_REGEX.test(prev)) {\n const close = regexEnd(src, i);\n return close < 0 ? -1 : close + 1;\n }\n return -1;\n}\n\n/**\n * Clears `code` over the template literal opened at `start`, all but the code inside its\n * `${…}`, which runs like any other. Returns the index of its closing backtick.\n */\nfunction maskTemplate(src: string, code: Uint8Array, start: number): number {\n code[start] = 0;\n for (let i = start + 1; i < src.length; i++) {\n code[i] = 0;\n if (src[i] === '\\\\') code[++i] = 0;\n else if (src[i] === '`') return i;\n else if (src[i] === '$' && src[i + 1] === '{') {\n code[i + 1] = 0;\n i = maskCode(src, code, i + 2, true);\n code[i] = 0;\n }\n }\n return src.length;\n}\n\n/**\n * Clears `code` over the comments and literals of the script from `from`. Inside a template's\n * `${…}` (`inExpression`), it stops at the `}` that closes it and returns that index.\n */\nfunction maskCode(src: string, code: Uint8Array, from: number, inExpression = false): number {\n let prev = '(';\n let braces = 0;\n for (let i = from; i < src.length; i++) {\n const c = src[i];\n if (/\\s/.test(c)) continue;\n const end = literalEnd(src, i, prev);\n if (end >= 0) {\n code.fill(0, i, end);\n // A literal is a value, so a `/` after it divides; a comment changes nothing.\n if (!isComment(src, i)) prev = 'a';\n i = end - 1;\n continue;\n }\n if (c === '`') {\n i = maskTemplate(src, code, i);\n prev = 'a';\n continue;\n }\n if (inExpression && c === '}' && braces-- === 0) return i;\n if (c === '{') braces++;\n prev = c;\n }\n return src.length;\n}\n\n/** Which characters of a script are code: not in a comment, string or template text. */\nfunction scriptMask(src: string): Uint8Array {\n const code = new Uint8Array(src.length).fill(1);\n maskCode(src, code, 0);\n return code;\n}\n\n/** A `type` the browser runs as JavaScript: none, `module`, or a JavaScript MIME type. */\nconst JS_TYPE = /^(?:|module|(?:text|application)\\/(?:x-)?(?:java|ecma)script)$/i;\n\n/**\n * The JavaScript an inline snippet runs: the text of its `<script>` elements, parsed by the\n * browser as `injectHtml` parses it, so attributes, quotes and the HTML around a script read as\n * they will on the page. A snippet with no `<script>` tag, or a scan with no DOM, reads whole.\n */\nfunction snippetScripts(snippet: string): string[] {\n if (!/<script\\b/i.test(snippet) || typeof document === 'undefined') return [snippet];\n const tpl = document.createElement('template');\n tpl.innerHTML = snippet;\n return Array.from(tpl.content.querySelectorAll('script'))\n .filter((script) => JS_TYPE.test(script.type.trim()))\n .map((script) => script.text);\n}\n\n/** `is_page('product.single')` with a literal slug. */\nconst IS_PAGE_LITERAL = /\\bis_page\\s*\\(\\s*['\"]([\\w.-]+)['\"]\\s*\\)/g;\n\n/**\n * A negated check, `!salla.url.is_page('cart')`, `!(is_page('cart'))` or\n * `is_page('cart') === false`: it acts on every page but the one it names, so that slug says\n * nothing about where it acts.\n */\n// Character classes for the `(` and `salla.url.` prefixes, not repeated groups: no nested\n// quantifier to backtrack on, as the snippet text is the app's.\nconst IS_PAGE_NEGATED =\n /![\\s(]*[\\w$.]*is_page\\s*\\(\\s*['\"][\\w.-]+['\"]\\s*\\)|\\bis_page\\s*\\(\\s*['\"][\\w.-]+['\"]\\s*\\)\\s*={2,3}\\s*false\\b/g;\n\n/**\n * The pages an inline snippet's code depends on: the slugs it passes to `is_page` as a literal,\n * or nothing when it doesn't care or reads the page only inside a `page::view` listener.\n *\n * Only a literal, positive check counts. A negated one, `page.slug`, `config.get('page')` or a\n * slug held in a variable would point at every page, and a full load on every navigation costs\n * the whole store its in-browser navigation (#513), so those snippets keep running once.\n */\nexport function snippetPageTargets(snippet: string): string[] {\n const slugs = new Set<string>();\n for (const script of snippetScripts(snippet)) {\n for (const slug of scriptPageTargets(script)) slugs.add(slug);\n }\n return [...slugs];\n}\n\n/** The slugs one script checks with a literal, positive `is_page`, in code that runs at load. */\nfunction scriptPageTargets(script: string): string[] {\n const content = stripNavigationListeners(script);\n const code = scriptMask(content);\n const negated = [...content.matchAll(IS_PAGE_NEGATED)].map(\n (m) => [m.index, m.index + m[0].length] as const\n );\n return [...content.matchAll(IS_PAGE_LITERAL)]\n .filter(\n ({ index }) => code[index] && !negated.some(([from, to]) => index >= from && index < to)\n )\n .map((m) => m[1]);\n}\n\n/** Pages that need a full load, across every installed app's inline snippets. */\nlet targets = new Set<string>();\n\n/** Told whether any page needs a full load, each time the snippets are recorded. */\ntype TargetsListener = (active: boolean) => void;\nconst listeners = new Set<TargetsListener>();\n\n/**\n * Calls `listener` now and whenever the snippets are recorded, with whether any page needs a full\n * load. The router installs its navigation blocker only while one does: a blocker makes every\n * history push wait a tick, which stores without such snippets shouldn't pay for.\n */\nexport function subscribeSnippetPageTargets(listener: TargetsListener): () => void {\n listeners.add(listener);\n listener(targets.size > 0);\n return () => listeners.delete(listener);\n}\n\n/**\n * Records the installed apps' inline snippets. CDN snippets are not scanned: their code is on\n * another origin. `AppsSnippets` calls this once the snippets are known.\n */\nexport function setSnippetPageTargets(\n snippets: ReadonlyArray<{ content: string; url?: string | null }>\n): void {\n const next = new Set<string>();\n for (const s of snippets) {\n if (s.url) continue;\n for (const slug of snippetPageTargets(s.content)) next.add(slug);\n }\n targets = next;\n listeners.forEach((listener) => listener(next.size > 0));\n if (next.size && typeof console !== 'undefined') {\n console.warn(\n '[salla] app snippets depend on the page; navigating to or from these pages reloads the document:',\n [...next]\n );\n }\n}\n\n/**\n * Whether going from the page `from` to the page `to` must load the document fully: when either\n * is a page some app snippet targets. Leaving one matters as much as entering: a widget an app\n * added to <body> for the product page would otherwise stay on the cart.\n */\nexport function needsDocumentLoad(from: string | undefined, to: string | undefined): boolean {\n if (!targets.size) return false;\n return (!!from && targets.has(from)) || (!!to && targets.has(to));\n}\n\n/** @internal Test-only. */\nexport function resetSnippetPageTargets(): void {\n targets = new Set();\n listeners.forEach((listener) => listener(false));\n}\n","import type { HeadDescriptor, HeadResult } from '../../utils/head';\nimport { mergeHead, resolveHead } from '../../utils/head';\nimport { buildBaseHead } from '../../utils/baseHead';\nimport { FALLBACK_LOCALE } from '../../providers/locale-constants';\nimport { getTwilightContext } from '../../twilight/context';\nimport type { TwilightContextMatch } from '../../twilight/ensure-context';\nimport { ensureTwilightContextFromMatches } from '../../twilight/ensure-context';\nimport type { StoreContext } from '../../api/store';\nimport type { AppSnippet } from '../../api/apps';\nimport { SettingsError } from '../../utils/errors';\nimport { renderAppScopeInstallScript } from '../../utils/app-scope';\nimport { renderThemeHookSlotsScript } from '../../utils/theme-hook-slots';\nimport { escapeForInlineScript } from '../../utils/inline-script';\nimport { readEnv, renderRuntimeEnvScript } from '../../utils/runtime-env';\n\nconst SALLA_ICONS_CSS_URL = 'https://cdn.assets.salla.network/static/fonts/sallaicons.css?v=2.0.5';\nconst LIT_VERSION = '3.3.3';\nconst LIT_CDN_BASE = `https://cdn.assets.salla.network/static/lit/${LIT_VERSION}`;\n\n/** Bare-specifier map for the lit build the engine's `<salla-*>` web components resolve against. */\nconst LIT_IMPORTS: Record<string, string> = {\n lit: `${LIT_CDN_BASE}/lit.js`,\n 'lit/': `${LIT_CDN_BASE}/`,\n 'lit-html': `${LIT_CDN_BASE}/lit-html/lit-html.js`,\n 'lit-html/': `${LIT_CDN_BASE}/lit-html/`,\n 'lit-element': `${LIT_CDN_BASE}/lit-element/lit-element.js`,\n 'lit-element/': `${LIT_CDN_BASE}/lit-element/`,\n '@lit/reactive-element': `${LIT_CDN_BASE}/reactive-element/reactive-element.js`,\n '@lit/reactive-element/': `${LIT_CDN_BASE}/reactive-element/`,\n};\n\nexport const TICKETING_SCRIPT_URL =\n 'https://cdn.assets.salla.network/latest/@salla.sa/ui-store-ticketing-system/ticketing-system.es.js';\n\nconst TWILIGHT_RELEASE_CDN = 'https://cdn.salla.network/js/twilight';\nconst TWILIGHT_DEV_CDN = 'https://cdn.assets.salla.network/dev/@salla.sa/twilight';\n// The oldest Twilight release this engine works with. Raise it whenever the engine\n// starts relying on something newer; the reason lives in that commit. Today's floor:\n// components ship their own CSS, which themes no longer compile (SallaApp/twilight#2107).\nconst MIN_TWILIGHT_VERSION = '2.14.538';\n// Last resort when no override and no platform pin, and the substitute for a pin below the floor.\nconst DEFAULT_TWILIGHT_VERSION = '2.14.584';\nconst releaseUrl = (version: string): string =>\n `${TWILIGHT_RELEASE_CDN}/${version}/twilight.esm.js`;\n// The head is built more than once per request (early hints, then the page); say it once.\nconst warnedPins = new Set<string>();\n\n/** `x.y.z` release pins only; dev shas and other strings are loaded as given. */\nfunction belowMinimum(version: string): boolean {\n return (\n /^\\d+\\.\\d+\\.\\d+$/.test(version) &&\n version.localeCompare(MIN_TWILIGHT_VERSION, undefined, { numeric: true }) < 0\n );\n}\n\n/** The `x.y.z` release segment of a release-CDN `.../twilight.esm.js` URL, if present. */\nfunction releaseVersionInUrl(url: string): string | null {\n const match = url.match(/\\/(\\d+\\.\\d+\\.\\d+)\\/twilight\\.esm\\.js(?:[?#]|$)/);\n return match ? match[1] : null;\n}\n\n/**\n * `VITE_TWILIGHT_URL`/`VITE_TWILIGHT_VERSION` outrank everything below, including\n * `theme.twilight.version`'s own `belowMinimum` guard — a stale override wins\n * silently otherwise (TD-16375: a scaffold-time pin outlived the engine raising\n * MIN_TWILIGHT_VERSION, so every new theme rendered without component CSS and\n * nothing said why). Only a dev-mode nudge, not a swap: an env override is a\n * deliberate choice, so unlike the settings-pin path below this never substitutes\n * the engine default underneath the developer.\n */\nfunction warnIfOverrideBelowMinimum(source: string, version: string): void {\n // Worker logs in production should stay quiet -- this is a developer-directed nudge,\n // not a user-facing or production-monitored signal. import.meta.env.DEV is a static\n // false in production builds, so this branch (and the console.warn below) is\n // tree-shaken out entirely, same as DevSettingsWidget / dev-settings-store.ts.\n if (!import.meta.env.DEV) return;\n if (!belowMinimum(version)) return;\n const key = `${source}:${version}`;\n if (warnedPins.has(key)) return;\n warnedPins.add(key);\n console.warn(\n `[twilight] ${source}=${version} is below the engine minimum ${MIN_TWILIGHT_VERSION} — components may load without their CSS (SallaApp/twilight#2107). Unset it or bump it to ${MIN_TWILIGHT_VERSION}+.`\n );\n}\n\n/**\n * Which twilight.esm.js the storefront loads, in priority order:\n * 1. `VITE_TWILIGHT_URL` — full local/deployment override.\n * 2. `VITE_TWILIGHT_VERSION` — dev-CDN build override.\n * 3. `theme.twilight.version` from the settings endpoint — the platform-pinned\n * release used when no environment override is configured.\n * 4. The engine's default release, also used when the pin is below the engine minimum.\n */\nexport function resolveTwilightSdkUrl(settings?: StoreContext): string {\n const urlOverride = readEnv('VITE_TWILIGHT_URL');\n if (urlOverride) {\n const version = releaseVersionInUrl(urlOverride);\n if (version) warnIfOverrideBelowMinimum('VITE_TWILIGHT_URL', version);\n return urlOverride;\n }\n\n const versionOverride = readEnv('VITE_TWILIGHT_VERSION');\n if (versionOverride) {\n warnIfOverrideBelowMinimum('VITE_TWILIGHT_VERSION', versionOverride);\n return `${TWILIGHT_DEV_CDN}/${versionOverride}/twilight.esm.js`;\n }\n\n const pinnedVersion = settings?.theme?.twilight?.version;\n if (pinnedVersion && belowMinimum(pinnedVersion)) {\n if (!warnedPins.has(pinnedVersion)) {\n warnedPins.add(pinnedVersion);\n console.warn(\n `[twilight] theme.twilight.version ${pinnedVersion} is below the engine minimum ${MIN_TWILIGHT_VERSION}; loading ${DEFAULT_TWILIGHT_VERSION} instead`\n );\n }\n return releaseUrl(DEFAULT_TWILIGHT_VERSION);\n }\n if (pinnedVersion) return releaseUrl(pinnedVersion);\n\n return releaseUrl(DEFAULT_TWILIGHT_VERSION);\n}\n\n// On a page that preloads its LCP image, the icon font (~270 KB) applies once the first screen's\n// priority images have painted, so it doesn't compete with them; other pages swap on load.\nconst MEDIA_SWAP_SCRIPT = `\n(function(){var d=document,s=function(l){if(l.sheet||\"all\"===l.media)l.media=\"all\";else l.onload=function(){this.media=\"all\"}},f=d.getElementById(\"salla-theme-font\"),i=d.getElementById(\"salla-icons-css\");f&&s(f);if(!i)return;if(!d.querySelector('link[rel=\"preload\"][as=\"image\"]'))return s(i);var g=function(){g=function(){};s(i)},p=function(){requestAnimationFrame(function(){setTimeout(function(){g()})});setTimeout(function(){g()},100)};d.addEventListener(\"DOMContentLoaded\",function(){var m=[].filter.call(d.querySelectorAll('img[fetchpriority=\"high\"]'),function(x){return!x.complete}),n=m.length;if(!n)return p();m.forEach(function(x){var o=function(){--n||p()};x.addEventListener(\"load\",o,{once:!0});x.addEventListener(\"error\",o,{once:!0})});setTimeout(function(){g()},2500)})})();\n`.trim();\n\nconst LOADING_CSS = `\n.loading-overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#fff;z-index:9999}\n.loading-spinner{animation:spin 1s linear infinite;border-radius:9999px;height:3rem;width:3rem;border-bottom:2px solid var(--color-primary,#000)}\n@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}\nhtml,body{margin:0;padding:0;height:100%}\n`.trim();\n\nconst SALLA_INIT_SCRIPT = `\nwindow.salla = window.Salla = window.Salla || window.salla || {};\nwindow.Salla.onReady = window.Salla.onReady || function(callback) {\n return new Promise(function(resolve) {\n if (window.Salla.status === 'ready') {\n var config = window.salla && window.salla.config && window.salla.config.all();\n resolve(callback ? callback(config) : config);\n } else {\n window.addEventListener('twilight::initiated', function(event) {\n resolve(callback ? callback(event.detail) : event.detail);\n }, { once: true });\n }\n });\n};\n`.trim();\n\n/**\n * Distinct snippet-host origins to `preconnect` (warm DNS/TCP/TLS during parse). From the real\n * URLs (dev/prod-correct), deduped and capped at 4. No `crossOrigin`: snippets are no-cors fetches.\n */\nexport function snippetPreconnectOrigins(snippets: readonly AppSnippet[] | undefined): string[] {\n if (!snippets?.length) return [];\n const origins = new Set<string>();\n for (const app of snippets) {\n if (app.status !== 'enabled') continue;\n for (const s of app.snippets) {\n if (!s.url) continue;\n try {\n origins.add(new URL(s.url).origin);\n } catch {\n /* skip a malformed snippet url rather than breaking the head */\n }\n if (origins.size >= 4) return [...origins];\n }\n }\n return [...origins];\n}\n\nexport function rootHead(ctx: {\n params: Record<string, string>;\n matches?: readonly TwilightContextMatch[];\n}): HeadResult {\n // Re-run on the client during hydration, where the twilight module store may\n // still be empty. Recover it from the resolved match context so the head is\n // built from real settings instead of falling through to 'Store Unavailable'.\n ensureTwilightContextFromMatches(ctx.matches);\n\n let settings: StoreContext | undefined;\n try {\n settings = getTwilightContext().settings;\n } catch (e) {\n if (e instanceof SettingsError) {\n return resolveHead({\n title: 'Store Unavailable',\n });\n }\n throw e;\n }\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n const parts = deriveHeadParts(settings);\n\n return resolveHead(\n mergeHead(buildBaseHead(settings, locale), {\n meta: buildRootMeta(parts),\n links: buildRootLinks(parts),\n styles: buildRootStyles(parts),\n importMap: [{ imports: LIT_IMPORTS }],\n scripts: buildRootScripts(parts),\n })\n );\n}\n\n/** Everything the root head's tag builders read, derived once from the store settings. */\ninterface RootHeadParts {\n store: StoreContext['store'] | undefined;\n favicon?: string;\n primaryColor?: string;\n fontUrl?: string;\n fontUrlWithDisplay?: string;\n isGoogleFont?: boolean;\n fontFamilyName?: string;\n customJs?: string;\n customCss?: string;\n isCustomCssUrl?: boolean;\n isCustomJsUrl?: boolean;\n twilightSdkUrl: string;\n /** The visitor gets the maintenance page, which loads no SDK and no app snippets. */\n maintenance: boolean;\n snippetPreconnects: Array<{ rel: 'preconnect'; href: string }>;\n appScopeInstallScript: string;\n themeHookSlotsScript: string | null;\n runtimeEnvScript: string | null;\n}\n\n/** Google Fonts only honours `display=swap` as a query param; other hosts get the @font-face\n * override instead (see buildRootStyles). */\nfunction deriveFontParts(theme?: StoreContext['theme']) {\n const font = theme?.font;\n const fontUrl = font?.url || font?.path;\n const isGoogleFont = fontUrl?.includes('fonts.googleapis.com');\n const needsDisplay = Boolean(isGoogleFont && fontUrl && !fontUrl.includes('display='));\n const separator = fontUrl?.includes('?') ? '&' : '?';\n\n return {\n fontUrl,\n isGoogleFont,\n fontFamilyName: font?.family_name,\n fontUrlWithDisplay: needsDisplay ? `${fontUrl}${separator}display=swap` : fontUrl,\n };\n}\n\n/** Theme customization JS/CSS, each either a URL to load or an inline blob to embed. */\nfunction deriveCustomizationParts(theme?: StoreContext['theme']) {\n const customization = theme?.customization;\n const customJs = customization?.js?.trim();\n const customCss = customization?.css?.trim();\n const isUrl = (value?: string): boolean =>\n Boolean(value?.startsWith('http') || value?.startsWith('//'));\n\n return {\n customJs,\n customCss,\n isCustomCssUrl: isUrl(customCss),\n isCustomJsUrl: isUrl(customJs),\n };\n}\n\nfunction deriveHeadParts(settings?: StoreContext): RootHeadParts {\n const store = settings?.store;\n\n return {\n store,\n favicon: store?.icon,\n primaryColor: settings?.theme?.color?.primary,\n ...deriveFontParts(settings?.theme),\n ...deriveCustomizationParts(settings?.theme),\n twilightSdkUrl: resolveTwilightSdkUrl(settings),\n maintenance: getTwilightContext().maintenance,\n // Warm the connection to the snippet host(s) during head parse, so the body's deferred\n // `<script src>` snippet tags fetch off an already-open socket instead of DNS+TCP+TLS.\n snippetPreconnects: snippetPreconnectOrigins(getTwilightContext().appsSnippets).map((href) => ({\n rel: 'preconnect' as const,\n href,\n })),\n // Install `Salla.appScope` inline at parse time, before the SDK is ready — else a snippet's\n // onReady callback calls it too early and throws. Always emitted, even when the settings\n // prefetch failed: the CDN snippet tags ship regardless (they come from the *snippets*\n // endpoint), so the factory has to exist for them. `installAppScope` then seeds the real\n // buckets into this install once the client query resolves.\n appScopeInstallScript: renderAppScopeInstallScript(\n getTwilightContext().appsSettings ?? { apps: {} }\n ),\n // Whitelist the theme's own hook slots at parse time too, for the same reason: apps register\n // their `onReady` callbacks from parser-inserted snippet tags, long before React hydrates.\n themeHookSlotsScript: renderThemeHookSlotsScript(),\n // Env this render resolved (worker `vars` live in server-only `process.env`), handed to the\n // client so it doesn't silently fall back to the production defaults. Re-rendered on the\n // client during hydration, where it resolves to the same values or to nothing.\n runtimeEnvScript: renderRuntimeEnvScript(),\n };\n}\n\nfunction buildRootMeta(p: RootHeadParts): NonNullable<HeadDescriptor['meta']> {\n return [\n { name: 'robots', content: 'index, follow' },\n { name: 'msapplication-TileColor', content: '#ffffff' },\n ...(p.favicon ? [{ name: 'msapplication-TileImage', content: p.favicon }] : []),\n ...(p.primaryColor\n ? [\n { name: 'theme-color', content: p.primaryColor },\n { name: 'msapplication-navbutton-color', content: p.primaryColor },\n { name: 'apple-mobile-web-app-status-bar-style', content: p.primaryColor },\n ]\n : []),\n ];\n}\n\nfunction buildRootLinks(p: RootHeadParts): NonNullable<HeadDescriptor['links']> {\n return [\n { rel: 'preconnect', href: 'https://api.salla.dev' },\n { rel: 'preconnect', href: 'https://cdn.salla.sa' },\n { rel: 'preconnect', href: 'https://cdn.assets.salla.network', crossOrigin: 'anonymous' },\n // Warm the installed apps' CDN snippet host(s) — see snippetPreconnectOrigins.\n // Not on the maintenance page: it renders neither the snippets nor the SDK.\n ...(p.maintenance ? [] : p.snippetPreconnects),\n ...(p.isGoogleFont\n ? [\n {\n rel: 'preconnect' as const,\n href: 'https://fonts.gstatic.com',\n crossOrigin: 'anonymous' as const,\n },\n ]\n : []),\n ...(p.maintenance ? [] : [{ rel: 'modulepreload' as const, href: p.twilightSdkUrl }]),\n ...(p.fontUrlWithDisplay\n ? [\n {\n id: 'salla-theme-font',\n rel: 'stylesheet',\n href: p.fontUrlWithDisplay,\n media: 'print',\n },\n ]\n : []),\n ...(p.fontUrlWithDisplay && !p.isGoogleFont && p.fontFamilyName\n ? [\n {\n id: 'salla-font-display-override',\n rel: 'preload',\n as: 'style',\n href: p.fontUrlWithDisplay,\n },\n ]\n : []),\n ...(p.favicon ? [{ rel: 'icon', href: p.favicon }] : []),\n ...(p.favicon\n ? [{ id: 'salla-apple-icon', rel: 'apple-touch-icon-precomposed', href: p.favicon }]\n : []),\n ...(p.isCustomCssUrl && p.customCss\n ? [{ id: 'salla-custom-css', rel: 'stylesheet', href: p.customCss }]\n : []),\n {\n id: 'salla-icons-css',\n rel: 'stylesheet',\n href: SALLA_ICONS_CSS_URL,\n media: 'print',\n },\n // {\n // id: 'intl-tel-input-css',\n // rel: 'stylesheet',\n // href: 'https://cdn.jsdelivr.net/npm/intl-tel-input@26.8.0/build/css/intlTelInput.css',\n // },\n ...(p.isCustomJsUrl && p.customJs\n ? [{ id: 'salla-custom-js-preload', rel: 'preload', as: 'script', href: p.customJs }]\n : []),\n ];\n}\n\n// Hoistable (href + precedence): the web components insert their own <style> near the top of\n// <head> before hydration, which a positionally hydrated <style> would be matched against.\nconst hoisted = (id: string, children: string) => ({\n id,\n href: id,\n precedence: 'default',\n children,\n});\n\nfunction buildRootStyles(p: RootHeadParts): NonNullable<HeadDescriptor['styles']> {\n return [\n hoisted('twilight-loading', LOADING_CSS),\n ...(!p.isGoogleFont && p.fontFamilyName\n ? [\n hoisted(\n 'salla-font-display-swap',\n `@font-face{font-family:\"${p.fontFamilyName}\";font-display:swap;src:local(\"${p.fontFamilyName}\")}`\n ),\n ]\n : []),\n ...(!p.isCustomCssUrl && p.customCss ? [hoisted('salla-custom-css', p.customCss)] : []),\n ];\n}\n\nfunction buildRootScripts(p: RootHeadParts): NonNullable<HeadDescriptor['scripts']> {\n return [\n // First: the API base / store identifier this render used, so the hydrated client\n // resolves the same ones (worker `vars` never reach the browser bundle on their own).\n ...(p.runtimeEnvScript ? [{ id: 'salla-runtime-env', children: p.runtimeEnvScript }] : []),\n { id: 'twilight-init', children: SALLA_INIT_SCRIPT },\n // After twilight-init (which defines window.Salla) and before the SDK module, so the\n // appScope factory exists ahead of any snippet's onReady callback firing.\n { id: 'salla-app-scope', children: p.appScopeInstallScript },\n // Arms the hook-slot whitelist push here, so its `twilight::initiated` listener is\n // registered before any app snippet's — listeners fire in registration order.\n ...(p.themeHookSlotsScript\n ? [{ id: 'salla-theme-hook-slots', children: p.themeHookSlotsScript }]\n : []),\n { id: 'salla-async-css', children: MEDIA_SWAP_SCRIPT },\n // The SDK and ticketing modules are rendered at the end of <body> (SallaSdkScripts).\n ...(p.customJs ? [buildCustomJsScript(p.customJs, Boolean(p.isCustomJsUrl))] : []),\n ];\n}\n\n/** A URL customization is loaded after SDK init; an inline one is wrapped so a syntax/runtime\n * error in partner JS warns instead of taking the page down. */\nfunction buildCustomJsScript(customJs: string, isUrl: boolean) {\n return {\n id: 'salla-custom-js',\n children: isUrl\n ? `window.addEventListener('twilight::initiated',function(){var s=document.createElement('script');s.src=${escapeForInlineScript(JSON.stringify(customJs))};s.async=true;document.head.appendChild(s)},{once:true});`\n : `try { ${customJs} } catch(e) { console.warn(\"[ThemeCustomization] Custom JS error:\", e); }`,\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { useOpeningHours } from './chunk-O63WBEAC.js';
2
- import { useIsProduct } from './chunk-O3XMYDNC.js';
1
+ import { useOpeningHours } from './chunk-F5RU2UCE.js';
2
+ import { useIsProduct } from './chunk-ZBGMIDDO.js';
3
3
  import { useTranslation } from './chunk-TYNZ5B2B.js';
4
4
  import { useTwilight } from './chunk-DF6FBKDN.js';
5
5
  import { useState } from 'react';
@@ -54,5 +54,5 @@ function StoreClosedNotification(_props) {
54
54
  }
55
55
 
56
56
  export { StoreClosedNotification };
57
- //# sourceMappingURL=chunk-PHPOMWQ4.js.map
58
- //# sourceMappingURL=chunk-PHPOMWQ4.js.map
57
+ //# sourceMappingURL=chunk-HSJCVD3P.js.map
58
+ //# sourceMappingURL=chunk-HSJCVD3P.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/store/StoreClosedNotification.tsx"],"names":[],"mappings":";;;;;;;AAsBO,SAAS,wBAAwB,MAAA,EAAsC;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Q,cAAA,EAAgB,MAAA,EAAO;AAAA,YAE/E,QAAA,kBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,cAAA,EAAe;AAAA;AAAA,SAC9B;AAAA,wBACA,GAAA,CAAC,GAAA,EAAA,EAAE,KAAA,EAAO,EAAE,MAAA,EAAQ,CAAA,EAAG,SAAA,EAAW,QAAA,EAAU,IAAA,EAAM,CAAA,EAAE,EACjD,QAAA,EAAA,CAAA,CAAE,2BAAA,EAA6B;AAAA,UAC9B,YAAA,EAAc,qPAAkD,iBAAiB,CAAA,CAAA,CAAA;AAAA,UACjF,QAAA,EAAU;AAAA,SACX,CAAA,EACH;AAAA;AAAA;AAAA,GACF;AAEJ","file":"chunk-PHPOMWQ4.js","sourcesContent":["import { useState } from 'react';\nimport { useIsProduct } from '../../providers/NavigationProvider';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useOpeningHours } from '../../hooks/useOpeningHours';\nimport { useTranslation } from '../../providers/I18nProvider';\n\nexport interface StoreClosedNotificationProps {\n /** Whether to show the notification (defaults to true when store is closed on product page) */\n show?: boolean;\n}\n\n/**\n * StoreClosedNotification - Shows a notification bar when the store is closed.\n *\n * Mirrors PHP ReceivingOrdersTimesWidget:\n * - Only shows on product pages\n * - Only shows when store is closed for receiving orders\n * - Displays when the store will open next\n * - Has a close button to dismiss\n *\n * Injected via hook registry at body:start.\n */\nexport function StoreClosedNotification(_props: StoreClosedNotificationProps) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n const { isOpen, isEnabled, nextOpenFormatted } = useOpeningHours(store.settings?.opening_hours);\n const [dismissed, setDismissed] = useState(false);\n\n // Check if we're on a product page\n const isProductPage = useIsProduct();\n\n // Conditions: product page, opening hours enabled, store closed, not dismissed\n if (!isProductPage || !isEnabled || isOpen || dismissed || !nextOpenFormatted) {\n return null;\n }\n\n const handleClose = (e: React.MouseEvent) => {\n e.preventDefault();\n setDismissed(true);\n };\n\n return (\n <div\n className=\"store-notify\"\n id=\"store-closed-notification\"\n data-testid=\"store-closed-notification\"\n style={{\n backgroundColor: '#d63031',\n color: '#fff',\n padding: '10px 15px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n position: 'relative',\n }}\n >\n <a\n href=\"#\"\n id=\"notify-close\"\n onClick={handleClose}\n style={{ position: 'absolute', left: 15, color: '#fff', textDecoration: 'none' }}\n >\n <i className=\"sicon-cancel\" />\n </a>\n <p style={{ margin: 0, textAlign: 'center', flex: 1 }}>\n {t('store.closed_notification', {\n defaultValue: `المتجر حاليا مغلق لاستقبال الطلبات وسيتم فتحه (${nextOpenFormatted})`,\n nextOpen: nextOpenFormatted,\n })}\n </p>\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/components/store/StoreClosedNotification.tsx"],"names":[],"mappings":";;;;;;;AAsBO,SAAS,wBAAwB,MAAA,EAAsC;AAC5E,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAC7B,EAAA,MAAM,EAAE,QAAQ,SAAA,EAAW,iBAAA,KAAsB,eAAA,CAAgB,KAAA,CAAM,UAAU,aAAa,CAAA;AAC9F,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAGhD,EAAA,MAAM,gBAAgB,YAAA,EAAa;AAGnC,EAAA,IAAI,CAAC,aAAA,IAAiB,CAAC,aAAa,MAAA,IAAU,SAAA,IAAa,CAAC,iBAAA,EAAmB;AAC7E,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,CAAC,CAAA,KAAwB;AAC3C,IAAA,CAAA,CAAE,cAAA,EAAe;AACjB,IAAA,YAAA,CAAa,IAAI,CAAA;AAAA,EACnB,CAAA;AAEA,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAU,cAAA;AAAA,MACV,EAAA,EAAG,2BAAA;AAAA,MACH,aAAA,EAAY,2BAAA;AAAA,MACZ,KAAA,EAAO;AAAA,QACL,eAAA,EAAiB,SAAA;AAAA,QACjB,KAAA,EAAO,MAAA;AAAA,QACP,OAAA,EAAS,WAAA;AAAA,QACT,OAAA,EAAS,MAAA;AAAA,QACT,UAAA,EAAY,QAAA;AAAA,QACZ,cAAA,EAAgB,QAAA;AAAA,QAChB,QAAA,EAAU;AAAA,OACZ;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,GAAA;AAAA,YACL,EAAA,EAAG,cAAA;AAAA,YACH,OAAA,EAAS,WAAA;AAAA,YACT,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,MAAM,EAAA,EAAI,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,MAAA,EAAO;AAAA,YAE/E,QAAA,kBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,cAAA,EAAe;AAAA;AAAA,SAC9B;AAAA,wBACA,GAAA,CAAC,GAAA,EAAA,EAAE,KAAA,EAAO,EAAE,MAAA,EAAQ,CAAA,EAAG,SAAA,EAAW,QAAA,EAAU,IAAA,EAAM,CAAA,EAAE,EACjD,QAAA,EAAA,CAAA,CAAE,2BAAA,EAA6B;AAAA,UAC9B,YAAA,EAAc,qPAAkD,iBAAiB,CAAA,CAAA,CAAA;AAAA,UACjF,QAAA,EAAU;AAAA,SACX,CAAA,EACH;AAAA;AAAA;AAAA,GACF;AAEJ","file":"chunk-HSJCVD3P.js","sourcesContent":["import { useState } from 'react';\nimport { useIsProduct } from '../../providers/NavigationProvider';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useOpeningHours } from '../../hooks/useOpeningHours';\nimport { useTranslation } from '../../providers/I18nProvider';\n\nexport interface StoreClosedNotificationProps {\n /** Whether to show the notification (defaults to true when store is closed on product page) */\n show?: boolean;\n}\n\n/**\n * StoreClosedNotification - Shows a notification bar when the store is closed.\n *\n * Mirrors PHP ReceivingOrdersTimesWidget:\n * - Only shows on product pages\n * - Only shows when store is closed for receiving orders\n * - Displays when the store will open next\n * - Has a close button to dismiss\n *\n * Injected via hook registry at body:start.\n */\nexport function StoreClosedNotification(_props: StoreClosedNotificationProps) {\n const { store } = useTwilight();\n const { t } = useTranslation();\n const { isOpen, isEnabled, nextOpenFormatted } = useOpeningHours(store.settings?.opening_hours);\n const [dismissed, setDismissed] = useState(false);\n\n // Check if we're on a product page\n const isProductPage = useIsProduct();\n\n // Conditions: product page, opening hours enabled, store closed, not dismissed\n if (!isProductPage || !isEnabled || isOpen || dismissed || !nextOpenFormatted) {\n return null;\n }\n\n const handleClose = (e: React.MouseEvent) => {\n e.preventDefault();\n setDismissed(true);\n };\n\n return (\n <div\n className=\"store-notify\"\n id=\"store-closed-notification\"\n data-testid=\"store-closed-notification\"\n style={{\n backgroundColor: '#d63031',\n color: '#fff',\n padding: '10px 15px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n position: 'relative',\n }}\n >\n <a\n href=\"#\"\n id=\"notify-close\"\n onClick={handleClose}\n style={{ position: 'absolute', left: 15, color: '#fff', textDecoration: 'none' }}\n >\n <i className=\"sicon-cancel\" />\n </a>\n <p style={{ margin: 0, textAlign: 'center', flex: 1 }}>\n {t('store.closed_notification', {\n defaultValue: `المتجر حاليا مغلق لاستقبال الطلبات وسيتم فتحه (${nextOpenFormatted})`,\n nextOpen: nextOpenFormatted,\n })}\n </p>\n </div>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { dispatchProductsFetched } from './chunk-PZP3372I.js';
2
- import { product } from './chunk-ZUVBDALM.js';
3
- import { onSallaEvent } from './chunk-7XAGU6CT.js';
1
+ import { dispatchProductsFetched } from './chunk-KNY2ZZ5M.js';
2
+ import { product } from './chunk-BWKHA4ZD.js';
3
+ import { onSallaEvent } from './chunk-7IVHY4OR.js';
4
4
  import { useState, useEffect, useCallback } from 'react';
5
5
 
6
6
  var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
@@ -71,5 +71,5 @@ function useAppliedFilters(source, sort, enabled) {
71
71
  }
72
72
 
73
73
  export { parseFiltersFromSearch, useAppliedFilters };
74
- //# sourceMappingURL=chunk-5LI536P6.js.map
75
- //# sourceMappingURL=chunk-5LI536P6.js.map
74
+ //# sourceMappingURL=chunk-I3KAWUPG.js.map
75
+ //# sourceMappingURL=chunk-I3KAWUPG.js.map