@salla.sa/twilight-theme-engine 1.0.128 → 1.0.130

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 (271) hide show
  1. package/dist/{AddToCartForm-NBU3MIEW.js → AddToCartForm-ZJIIU4I4.js} +3 -3
  2. package/dist/{AddToCartForm-NBU3MIEW.js.map → AddToCartForm-ZJIIU4I4.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-4HGFVIG2.js → BlogAuthorPage-DNZSR42D.js} +19 -18
  4. package/dist/BlogAuthorPage-DNZSR42D.js.map +1 -0
  5. package/dist/{BlogCategoryPage-67TZRH3C.js → BlogCategoryPage-AC4DDQ7N.js} +19 -18
  6. package/dist/BlogCategoryPage-AC4DDQ7N.js.map +1 -0
  7. package/dist/{BlogPage-HINCPIQO.js → BlogPage-F5OY24RP.js} +17 -16
  8. package/dist/BlogPage-F5OY24RP.js.map +1 -0
  9. package/dist/{BlogSinglePage-4BWHLJU6.js → BlogSinglePage-YXC5WU3N.js} +17 -16
  10. package/dist/BlogSinglePage-YXC5WU3N.js.map +1 -0
  11. package/dist/{BlogTagPage-BGPLVWGM.js → BlogTagPage-6QQ2CF2B.js} +19 -18
  12. package/dist/BlogTagPage-6QQ2CF2B.js.map +1 -0
  13. package/dist/{BrandsPage-2NC3RCZK.js → BrandsPage-UXWNTTT3.js} +18 -17
  14. package/dist/BrandsPage-UXWNTTT3.js.map +1 -0
  15. package/dist/{Breadcrumb-CCYDVGCS.js → Breadcrumb-TUXEVRZZ.js} +17 -16
  16. package/dist/Breadcrumb-TUXEVRZZ.js.map +1 -0
  17. package/dist/{CartItem-M5PC54CM.js → CartItem-B7AYUFGZ.js} +17 -16
  18. package/dist/CartItem-B7AYUFGZ.js.map +1 -0
  19. package/dist/{CartSummary-YQI7XI4D.js → CartSummary-LSFD7QUY.js} +17 -16
  20. package/dist/CartSummary-LSFD7QUY.js.map +1 -0
  21. package/dist/{Copyright-67E3ANPE.js → Copyright-HH2S2KDM.js} +3 -3
  22. package/dist/{Copyright-67E3ANPE.js.map → Copyright-HH2S2KDM.js.map} +1 -1
  23. package/dist/{CustomerLayout-HPLKOG7R.js → CustomerLayout-2NVQ6G72.js} +17 -16
  24. package/dist/CustomerLayout-2NVQ6G72.js.map +1 -0
  25. package/dist/{Footer-56IXUTHF.js → Footer-4LQIBAHJ.js} +4 -4
  26. package/dist/{Footer-56IXUTHF.js.map → Footer-4LQIBAHJ.js.map} +1 -1
  27. package/dist/{Header-67Q5OA63.js → Header-VQTPIQPS.js} +8 -8
  28. package/dist/{Header-67Q5OA63.js.map → Header-VQTPIQPS.js.map} +1 -1
  29. package/dist/{LiveEditorBar-IQLFFBHE.js → LiveEditorBar-DOSRO35J.js} +3 -3
  30. package/dist/{LiveEditorBar-IQLFFBHE.js.map → LiveEditorBar-DOSRO35J.js.map} +1 -1
  31. package/dist/{LoyaltyPage-GC7B5FXF.js → LoyaltyPage-NSHSLS4O.js} +17 -16
  32. package/dist/LoyaltyPage-NSHSLS4O.js.map +1 -0
  33. package/dist/{LoyaltyPointsPage-UAZQ2GZT.js → LoyaltyPointsPage-7CUUKDLR.js} +6 -6
  34. package/dist/{LoyaltyPointsPage-UAZQ2GZT.js.map → LoyaltyPointsPage-7CUUKDLR.js.map} +1 -1
  35. package/dist/{MainMenu-7SXJ2DU4.js → MainMenu-NTSSUK6R.js} +5 -5
  36. package/dist/{MainMenu-7SXJ2DU4.js.map → MainMenu-NTSSUK6R.js.map} +1 -1
  37. package/dist/MaintenancePage-A7CNHM7B.js +7 -0
  38. package/dist/{MaintenancePage-7Y4QA5LD.js.map → MaintenancePage-A7CNHM7B.js.map} +1 -1
  39. package/dist/{MasterLayout-53MYQBTT.js → MasterLayout-ZOT7XICQ.js} +17 -16
  40. package/dist/{MasterLayout-53MYQBTT.js.map → MasterLayout-ZOT7XICQ.js.map} +1 -1
  41. package/dist/{MobileMenu-U6W2XQYI.js → MobileMenu-RBTT3KLS.js} +18 -17
  42. package/dist/MobileMenu-RBTT3KLS.js.map +1 -0
  43. package/dist/{NotificationsPage-2WFW7GCV.js → NotificationsPage-T775PMFX.js} +17 -16
  44. package/dist/NotificationsPage-T775PMFX.js.map +1 -0
  45. package/dist/{OrderSinglePage-VN3IBWOO.js → OrderSinglePage-T5SKWUNW.js} +18 -17
  46. package/dist/OrderSinglePage-T5SKWUNW.js.map +1 -0
  47. package/dist/{OrdersPage-NOUGRTHI.js → OrdersPage-PGAD6DDY.js} +17 -16
  48. package/dist/OrdersPage-PGAD6DDY.js.map +1 -0
  49. package/dist/{PageSingle-MP5THOR4.js → PageSingle-6W7U5YLG.js} +3 -3
  50. package/dist/{PageSingle-MP5THOR4.js.map → PageSingle-6W7U5YLG.js.map} +1 -1
  51. package/dist/{ProductDetails-GONQFVV2.js → ProductDetails-JFOFLMLV.js} +4 -4
  52. package/dist/{ProductDetails-GONQFVV2.js.map → ProductDetails-JFOFLMLV.js.map} +1 -1
  53. package/dist/{ProfilePage-RHK3OHFF.js → ProfilePage-2HZYDJBM.js} +17 -16
  54. package/dist/ProfilePage-2HZYDJBM.js.map +1 -0
  55. package/dist/{ReviewsPage-3PODTNEP.js → ReviewsPage-FYAZU7FT.js} +3 -3
  56. package/dist/{ReviewsPage-3PODTNEP.js.map → ReviewsPage-FYAZU7FT.js.map} +1 -1
  57. package/dist/{SeoCartWidget-MHOPTGWV.js → SeoCartWidget-7SUVC6MT.js} +17 -16
  58. package/dist/SeoCartWidget-7SUVC6MT.js.map +1 -0
  59. package/dist/{SettingsPage-RLNSTOCG.js → SettingsPage-IBWVB4ZJ.js} +17 -16
  60. package/dist/SettingsPage-IBWVB4ZJ.js.map +1 -0
  61. package/dist/{StoreClosedNotification-AUQCK2MP.js → StoreClosedNotification-CMOHA4LU.js} +18 -17
  62. package/dist/{StoreClosedNotification-AUQCK2MP.js.map → StoreClosedNotification-CMOHA4LU.js.map} +1 -1
  63. package/dist/{TestimonialsPage-GXKXWGDA.js → TestimonialsPage-WJMIDBRM.js} +3 -3
  64. package/dist/{TestimonialsPage-GXKXWGDA.js.map → TestimonialsPage-WJMIDBRM.js.map} +1 -1
  65. package/dist/{ThankYouPage-GILEXBPL.js → ThankYouPage-NILOPG4H.js} +17 -16
  66. package/dist/ThankYouPage-NILOPG4H.js.map +1 -0
  67. package/dist/{WalletPage-4OOHX65H.js → WalletPage-5O553SIT.js} +18 -17
  68. package/dist/WalletPage-5O553SIT.js.map +1 -0
  69. package/dist/{WishlistPage-Z2TPPFFM.js → WishlistPage-JPLKEMDX.js} +19 -18
  70. package/dist/WishlistPage-JPLKEMDX.js.map +1 -0
  71. package/dist/api/advertisement.js +2 -2
  72. package/dist/api/apps.js +2 -2
  73. package/dist/api/blog.js +3 -3
  74. package/dist/api/brands.js +3 -3
  75. package/dist/api/cart.js +3 -3
  76. package/dist/api/category.js +3 -3
  77. package/dist/api/client.js +1 -1
  78. package/dist/api/home.js +2 -2
  79. package/dist/api/loyalty.js +3 -3
  80. package/dist/api/menu.js +2 -2
  81. package/dist/api/notification.js +2 -2
  82. package/dist/api/order.js +3 -3
  83. package/dist/api/page.js +3 -3
  84. package/dist/api/product.js +3 -3
  85. package/dist/api/profile.js +1 -1
  86. package/dist/api/store.d.ts +8 -0
  87. package/dist/api/store.d.ts.map +1 -1
  88. package/dist/api/store.js +3 -2
  89. package/dist/api/translations.js +2 -2
  90. package/dist/api/user.js +2 -2
  91. package/dist/api/wallet.js +2 -2
  92. package/dist/api/wishlist.js +4 -4
  93. package/dist/chunk-2A2NODLC.js +14 -0
  94. package/dist/{chunk-L4FKJ3ZN.js.map → chunk-2A2NODLC.js.map} +1 -1
  95. package/dist/{chunk-L36ZEKBI.js → chunk-2UQKQTPB.js} +4 -4
  96. package/dist/{chunk-L36ZEKBI.js.map → chunk-2UQKQTPB.js.map} +1 -1
  97. package/dist/{chunk-KQEBYXYB.js → chunk-3CNXPHJE.js} +4 -69
  98. package/dist/chunk-3CNXPHJE.js.map +1 -0
  99. package/dist/{chunk-M6Z7KIDX.js → chunk-4FYLW5WS.js} +3 -3
  100. package/dist/{chunk-M6Z7KIDX.js.map → chunk-4FYLW5WS.js.map} +1 -1
  101. package/dist/{chunk-DI463VGL.js → chunk-4SMWY54W.js} +3 -3
  102. package/dist/{chunk-DI463VGL.js.map → chunk-4SMWY54W.js.map} +1 -1
  103. package/dist/{chunk-3FMJHVRY.js → chunk-52MZ4V5T.js} +4 -4
  104. package/dist/{chunk-3FMJHVRY.js.map → chunk-52MZ4V5T.js.map} +1 -1
  105. package/dist/{chunk-5GCOUJ7T.js → chunk-54FS47CL.js} +3 -3
  106. package/dist/{chunk-5GCOUJ7T.js.map → chunk-54FS47CL.js.map} +1 -1
  107. package/dist/{chunk-RA5O7L7Q.js → chunk-5DVSAKNY.js} +4 -4
  108. package/dist/{chunk-RA5O7L7Q.js.map → chunk-5DVSAKNY.js.map} +1 -1
  109. package/dist/{chunk-HRDCUTC6.js → chunk-5JN6P5L5.js} +6 -6
  110. package/dist/{chunk-HRDCUTC6.js.map → chunk-5JN6P5L5.js.map} +1 -1
  111. package/dist/{chunk-XCS62X6X.js → chunk-672DTSG4.js} +7 -7
  112. package/dist/{chunk-XCS62X6X.js.map → chunk-672DTSG4.js.map} +1 -1
  113. package/dist/{chunk-6GDNC6DS.js → chunk-AIPIJWOC.js} +3 -3
  114. package/dist/{chunk-6GDNC6DS.js.map → chunk-AIPIJWOC.js.map} +1 -1
  115. package/dist/{chunk-KNTHVSUL.js → chunk-AN2PETFM.js} +6 -6
  116. package/dist/{chunk-KNTHVSUL.js.map → chunk-AN2PETFM.js.map} +1 -1
  117. package/dist/{chunk-GFOAMXSO.js → chunk-AXPZEXJN.js} +3 -3
  118. package/dist/{chunk-GFOAMXSO.js.map → chunk-AXPZEXJN.js.map} +1 -1
  119. package/dist/{chunk-S7QZUBXM.js → chunk-BSGHOYMT.js} +3 -3
  120. package/dist/{chunk-S7QZUBXM.js.map → chunk-BSGHOYMT.js.map} +1 -1
  121. package/dist/{chunk-QLFRNPPF.js → chunk-CGDUSBLK.js} +28 -21
  122. package/dist/chunk-CGDUSBLK.js.map +1 -0
  123. package/dist/{chunk-J5DGBS7Q.js → chunk-CKH6WBMA.js} +71 -7
  124. package/dist/chunk-CKH6WBMA.js.map +1 -0
  125. package/dist/{chunk-2VRMQZXF.js → chunk-D423MW2M.js} +3 -3
  126. package/dist/{chunk-2VRMQZXF.js.map → chunk-D423MW2M.js.map} +1 -1
  127. package/dist/{chunk-OOQTZ7N7.js → chunk-EDCRELH3.js} +3 -3
  128. package/dist/{chunk-OOQTZ7N7.js.map → chunk-EDCRELH3.js.map} +1 -1
  129. package/dist/{chunk-6NT6RC2H.js → chunk-ELARAFMR.js} +3 -3
  130. package/dist/{chunk-6NT6RC2H.js.map → chunk-ELARAFMR.js.map} +1 -1
  131. package/dist/{chunk-CN4U4EWY.js → chunk-EZP2KOEL.js} +4 -4
  132. package/dist/{chunk-CN4U4EWY.js.map → chunk-EZP2KOEL.js.map} +1 -1
  133. package/dist/{chunk-MVNWWZWQ.js → chunk-FHAHE46U.js} +7 -3
  134. package/dist/chunk-FHAHE46U.js.map +1 -0
  135. package/dist/chunk-FID76MUV.js +73 -0
  136. package/dist/chunk-FID76MUV.js.map +1 -0
  137. package/dist/{chunk-U2UDXLAE.js → chunk-GSI42HHP.js} +3 -3
  138. package/dist/{chunk-U2UDXLAE.js.map → chunk-GSI42HHP.js.map} +1 -1
  139. package/dist/{chunk-5U7LPEFE.js → chunk-HH7WFQLN.js} +3 -3
  140. package/dist/{chunk-5U7LPEFE.js.map → chunk-HH7WFQLN.js.map} +1 -1
  141. package/dist/{chunk-O3BZBI27.js → chunk-I5XU5BQH.js} +3 -3
  142. package/dist/{chunk-O3BZBI27.js.map → chunk-I5XU5BQH.js.map} +1 -1
  143. package/dist/{chunk-LIQHWHYV.js → chunk-ITMXD75H.js} +12 -11
  144. package/dist/chunk-ITMXD75H.js.map +1 -0
  145. package/dist/{chunk-JUKKXGHR.js → chunk-IUEYRDEI.js} +3 -3
  146. package/dist/{chunk-JUKKXGHR.js.map → chunk-IUEYRDEI.js.map} +1 -1
  147. package/dist/{chunk-3OGFV27B.js → chunk-JLBDDH4N.js} +3 -3
  148. package/dist/{chunk-3OGFV27B.js.map → chunk-JLBDDH4N.js.map} +1 -1
  149. package/dist/{chunk-CGABIBZZ.js → chunk-K3PQSDGA.js} +4 -4
  150. package/dist/{chunk-CGABIBZZ.js.map → chunk-K3PQSDGA.js.map} +1 -1
  151. package/dist/{chunk-3U6BZUQL.js → chunk-KME6DTES.js} +7 -7
  152. package/dist/{chunk-3U6BZUQL.js.map → chunk-KME6DTES.js.map} +1 -1
  153. package/dist/{chunk-EXK6VVXU.js → chunk-NITRRCQV.js} +4 -4
  154. package/dist/{chunk-EXK6VVXU.js.map → chunk-NITRRCQV.js.map} +1 -1
  155. package/dist/{chunk-UGJ24VNF.js → chunk-NLT6YWUD.js} +4 -4
  156. package/dist/{chunk-UGJ24VNF.js.map → chunk-NLT6YWUD.js.map} +1 -1
  157. package/dist/{chunk-EZK2WD75.js → chunk-OR6HPFZT.js} +4 -4
  158. package/dist/{chunk-EZK2WD75.js.map → chunk-OR6HPFZT.js.map} +1 -1
  159. package/dist/{chunk-GN5V4IQI.js → chunk-ORBMN52O.js} +4 -4
  160. package/dist/{chunk-GN5V4IQI.js.map → chunk-ORBMN52O.js.map} +1 -1
  161. package/dist/{chunk-ZWV6YNIB.js → chunk-QYHNS2KS.js} +4 -4
  162. package/dist/{chunk-ZWV6YNIB.js.map → chunk-QYHNS2KS.js.map} +1 -1
  163. package/dist/{chunk-FWGHTOGZ.js → chunk-RQ72QOIC.js} +7 -7
  164. package/dist/{chunk-FWGHTOGZ.js.map → chunk-RQ72QOIC.js.map} +1 -1
  165. package/dist/{chunk-DJN6JAF7.js → chunk-RXWWNPCR.js} +5 -5
  166. package/dist/{chunk-DJN6JAF7.js.map → chunk-RXWWNPCR.js.map} +1 -1
  167. package/dist/{chunk-4LR7N76Q.js → chunk-SCM4P6QG.js} +3 -3
  168. package/dist/{chunk-4LR7N76Q.js.map → chunk-SCM4P6QG.js.map} +1 -1
  169. package/dist/{chunk-UWE2QL3O.js → chunk-T55LMU5R.js} +3 -3
  170. package/dist/{chunk-UWE2QL3O.js.map → chunk-T55LMU5R.js.map} +1 -1
  171. package/dist/{chunk-HZIQK63A.js → chunk-WYWI77EA.js} +23 -4
  172. package/dist/chunk-WYWI77EA.js.map +1 -0
  173. package/dist/{chunk-7SBSV5DD.js → chunk-X4A3D5O4.js} +3 -3
  174. package/dist/{chunk-7SBSV5DD.js.map → chunk-X4A3D5O4.js.map} +1 -1
  175. package/dist/{chunk-HAS46CRI.js → chunk-YGCPRUT6.js} +5 -3
  176. package/dist/chunk-YGCPRUT6.js.map +1 -0
  177. package/dist/{chunk-JAP5KTIG.js → chunk-YSSJ2CQC.js} +4 -4
  178. package/dist/{chunk-JAP5KTIG.js.map → chunk-YSSJ2CQC.js.map} +1 -1
  179. package/dist/components/cart/index.js +1 -1
  180. package/dist/components/common/index.js +1 -1
  181. package/dist/components/drawer/index.js +15 -14
  182. package/dist/components/home/index.js +19 -18
  183. package/dist/components/layout/index.js +4 -4
  184. package/dist/components/live-editor/frame.d.ts +6 -0
  185. package/dist/components/live-editor/frame.d.ts.map +1 -1
  186. package/dist/components/product/index.js +16 -15
  187. package/dist/components/store/MaintenancePage.d.ts +3 -2
  188. package/dist/components/store/MaintenancePage.d.ts.map +1 -1
  189. package/dist/components/store/index.js +17 -16
  190. package/dist/dev/editor/index.js +1 -1
  191. package/dist/dev/index.js +1 -1
  192. package/dist/{document-class-DSRV5LZK.js → document-class-2SKG4YZE.js} +13 -12
  193. package/dist/{document-class-DSRV5LZK.js.map → document-class-2SKG4YZE.js.map} +1 -1
  194. package/dist/hooks/index.js +15 -14
  195. package/dist/hooks/useGtm.js +15 -14
  196. package/dist/hooks/useMoney.js +15 -14
  197. package/dist/hooks/useStore.js +15 -14
  198. package/dist/hooks/useUser.js +3 -3
  199. package/dist/index.js +15 -14
  200. package/dist/index.js.map +1 -1
  201. package/dist/{navigation-ATD4DRST.js → navigation-7HBHI524.js} +4 -4
  202. package/dist/{navigation-ATD4DRST.js.map → navigation-7HBHI524.js.map} +1 -1
  203. package/dist/{navigation-XCZMJSNS.js → navigation-WVVYQOOZ.js} +5 -5
  204. package/dist/{navigation-XCZMJSNS.js.map → navigation-WVVYQOOZ.js.map} +1 -1
  205. package/dist/{not-found-ZE4Y7RLW.js → not-found-ZN7HOUO4.js} +18 -17
  206. package/dist/not-found-ZN7HOUO4.js.map +1 -0
  207. package/dist/providers/NavigationProvider.d.ts +2 -0
  208. package/dist/providers/NavigationProvider.d.ts.map +1 -1
  209. package/dist/providers/TwilightProvider.d.ts.map +1 -1
  210. package/dist/providers/index.js +15 -14
  211. package/dist/routes/account/orders.js +4 -4
  212. package/dist/routes/account.js +13 -13
  213. package/dist/routes/blog.js +8 -8
  214. package/dist/routes/brands.js +4 -4
  215. package/dist/routes/cart.js +23 -22
  216. package/dist/routes/cart.js.map +1 -1
  217. package/dist/routes/home.js +20 -19
  218. package/dist/routes/index.js +3 -3
  219. package/dist/routes/loyalty.js +5 -5
  220. package/dist/routes/page.js +4 -4
  221. package/dist/routes/product-listing.js +21 -20
  222. package/dist/routes/product-listing.js.map +1 -1
  223. package/dist/routes/product.js +19 -18
  224. package/dist/routes/product.js.map +1 -1
  225. package/dist/routes/seo-redirects.js +3 -3
  226. package/dist/routes/testimonials.js +2 -2
  227. package/dist/routes/thank-you.js +4 -4
  228. package/dist/skeleton.js +20 -19
  229. package/dist/{store-lookup-TG6RV6NV.js → store-lookup-KSHMPOFT.js} +8 -8
  230. package/dist/{store-lookup-TG6RV6NV.js.map → store-lookup-KSHMPOFT.js.map} +1 -1
  231. package/dist/tanstack.js +13 -12
  232. package/dist/tanstack.js.map +1 -1
  233. package/dist/types/twilight.d.ts +4 -2
  234. package/dist/types/twilight.d.ts.map +1 -1
  235. package/dist/utils/index.js +2 -2
  236. package/dist/utils/maintenance.d.ts +13 -0
  237. package/dist/utils/maintenance.d.ts.map +1 -1
  238. package/package.json +1 -1
  239. package/tailwind/components/live-editor/frame.ts.txt +10 -0
  240. package/tailwind/components/store/MaintenancePage.tsx.txt +116 -6
  241. package/dist/BlogAuthorPage-4HGFVIG2.js.map +0 -1
  242. package/dist/BlogCategoryPage-67TZRH3C.js.map +0 -1
  243. package/dist/BlogPage-HINCPIQO.js.map +0 -1
  244. package/dist/BlogSinglePage-4BWHLJU6.js.map +0 -1
  245. package/dist/BlogTagPage-BGPLVWGM.js.map +0 -1
  246. package/dist/BrandsPage-2NC3RCZK.js.map +0 -1
  247. package/dist/Breadcrumb-CCYDVGCS.js.map +0 -1
  248. package/dist/CartItem-M5PC54CM.js.map +0 -1
  249. package/dist/CartSummary-YQI7XI4D.js.map +0 -1
  250. package/dist/CustomerLayout-HPLKOG7R.js.map +0 -1
  251. package/dist/LoyaltyPage-GC7B5FXF.js.map +0 -1
  252. package/dist/MaintenancePage-7Y4QA5LD.js +0 -7
  253. package/dist/MobileMenu-U6W2XQYI.js.map +0 -1
  254. package/dist/NotificationsPage-2WFW7GCV.js.map +0 -1
  255. package/dist/OrderSinglePage-VN3IBWOO.js.map +0 -1
  256. package/dist/OrdersPage-NOUGRTHI.js.map +0 -1
  257. package/dist/ProfilePage-RHK3OHFF.js.map +0 -1
  258. package/dist/SeoCartWidget-MHOPTGWV.js.map +0 -1
  259. package/dist/SettingsPage-RLNSTOCG.js.map +0 -1
  260. package/dist/ThankYouPage-GILEXBPL.js.map +0 -1
  261. package/dist/WalletPage-4OOHX65H.js.map +0 -1
  262. package/dist/WishlistPage-Z2TPPFFM.js.map +0 -1
  263. package/dist/chunk-HAS46CRI.js.map +0 -1
  264. package/dist/chunk-HZIQK63A.js.map +0 -1
  265. package/dist/chunk-J5DGBS7Q.js.map +0 -1
  266. package/dist/chunk-KQEBYXYB.js.map +0 -1
  267. package/dist/chunk-L4FKJ3ZN.js +0 -14
  268. package/dist/chunk-LIQHWHYV.js.map +0 -1
  269. package/dist/chunk-MVNWWZWQ.js.map +0 -1
  270. package/dist/chunk-QLFRNPPF.js.map +0 -1
  271. package/dist/not-found-ZE4Y7RLW.js.map +0 -1
@@ -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;AAMA,IAAM,kCAAkB,IAAI,GAAA,CAAI,CAAC,kBAAA,EAAoB,gBAAgB,CAAC,CAAA;AAuBtE,SAAS,kBAAkB,OAAA,EAA2B;AACpD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,KAAA,EAAO,OAAO,KAAA;AACrC,EAAA,IAAI;AACF,IAAA,OAAO,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA,CAAE,QAAA,CAAS,SAAS,iBAAiB,CAAA;AAAA,EACjE,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAOA,SAAS,YAAY,IAAA,EAAuB;AAC1C,EAAA,IAAI;AACF,IAAA,OAAO,OAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAI,GAAiC,IAAI,CAAA;AAAA,EACtE,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAOA,SAAS,MAAM,OAAA,EAA0B;AACvC,EAAA,MAAM,UAAU,CAAC,GAAG,QAAQ,O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AAY,qBAAA,EAAuB,MAAM,eAAe,CAAA;AAC9E,UAAA,IAAI,KAAA,CAAM,aAAA;AACR,YAAA,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,WAAA,CAAY,mBAAA,EAAqB,MAAM,aAAa,CAAA;AAAA,QAC5E;AAAA,MACF,CAAA;AAAA;AAAA,MAEA,gBAAA,CAAiB;AAAA,KACnB;AAAA,IACA,aAAA,EAAe,CAAC,gBAAA,CAAiB,KAAK;AAAA;AAE1C,CAAC;AAEM,IAAM,GAAA,GAAM,GAAG,MAAA,CAAO;AAAA,EAC3B,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC;AAUM,IAAM,QAAA,GAAW,GAAG,MAAA,CAAO;AAAA,EAChC,MAAA,EAAQ,iCAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"chunk-S7QZUBXM.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
+ {"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;AAMA,IAAM,kCAAkB,IAAI,GAAA,CAAI,CAAC,kBAAA,EAAoB,gBAAgB,CAAC,CAAA;AAuBtE,SAAS,kBAAkB,OAAA,EAA2B;AACpD,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,KAAA,EAAO,OAAO,KAAA;AACrC,EAAA,IAAI;AACF,IAAA,OAAO,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA,CAAE,QAAA,CAAS,SAAS,iBAAiB,CAAA;AAAA,EACjE,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAOA,SAAS,YAAY,IAAA,EAAuB;AAC1C,EAAA,IAAI;AACF,IAAA,OAAO,OAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAI,GAAiC,IAAI,CAAA;AAAA,EACtE,CAAA,CAAA,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AAA,EAAY,MAAM,IAAI,CAAA;AACtE,UAAA,IAAI,KAAA,CAAM,eAAA;AACR,YAAA,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,WAAA,CAAY,qBAAA,EAAuB,MAAM,eAAe,CAAA;AAC9E,UAAA,IAAI,KAAA,CAAM,aAAA;AACR,YAAA,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,WAAA,CAAY,mBAAA,EAAqB,MAAM,aAAa,CAAA;AAAA,QAC5E;AAAA,MACF,CAAA;AAAA;AAAA,MAEA,gBAAA,CAAiB;AAAA,KACnB;AAAA,IACA,aAAA,EAAe,CAAC,gBAAA,CAAiB,KAAK;AAAA;AAE1C,CAAC;AAEM,IAAM,GAAA,GAAM,GAAG,MAAA,CAAO;AAAA,EAC3B,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC;AAUM,IAAM,QAAA,GAAW,GAAG,MAAA,CAAO;AAAA,EAChC,MAAA,EAAQ,iCAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"chunk-BSGHOYMT.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,18 +1,19 @@
1
- import { editorFrame, postToEditor, FRAME_LOADED_ACTION } from './chunk-MVNWWZWQ.js';
2
- import { Header } from './chunk-XCS62X6X.js';
3
- import { Footer } from './chunk-5U7LPEFE.js';
4
- import { withOwnerMaintenanceButton, resolveTwilightSdkUrl, TICKETING_SCRIPT_URL, setSnippetPageTargets } from './chunk-KQEBYXYB.js';
5
- import { useDevSettingsOverrides, useDevReportSettingsFetchedAt } from './chunk-4LR7N76Q.js';
6
- import { apps } from './chunk-GFOAMXSO.js';
1
+ import { editorFrame, previewTheme, postToEditor, FRAME_LOADED_ACTION } from './chunk-FHAHE46U.js';
2
+ import { Header } from './chunk-672DTSG4.js';
3
+ import { Footer } from './chunk-HH7WFQLN.js';
4
+ import { resolveTwilightSdkUrl, TICKETING_SCRIPT_URL, setSnippetPageTargets } from './chunk-3CNXPHJE.js';
5
+ import { useDevSettingsOverrides, useDevReportSettingsFetchedAt } from './chunk-SCM4P6QG.js';
6
+ import { apps } from './chunk-AXPZEXJN.js';
7
7
  import { color } from './chunk-VVZNW5CB.js';
8
8
  import { applyThemeHookSlots, installAppScope } from './chunk-5FJFN3IW.js';
9
- import { useLocation, useIsHome, NavigationInterceptor } from './chunk-HZIQK63A.js';
10
- import { useUser } from './chunk-U2UDXLAE.js';
9
+ import { withOwnerMaintenanceButton } from './chunk-FID76MUV.js';
10
+ import { useLocation, useIsHome, NavigationInterceptor } from './chunk-WYWI77EA.js';
11
+ import { useUser } from './chunk-GSI42HHP.js';
11
12
  import { DocumentClassProvider, useDocumentClass } from './chunk-JWXJPJBO.js';
12
13
  import { WidgetHead } from './chunk-V2ZDTY6H.js';
13
14
  import { HookSlot } from './chunk-5XDPAKF5.js';
14
15
  import { hookRegistry } from './chunk-GCPEMNSU.js';
15
- import { getActiveCurrency, ENGINE_VERSION } from './chunk-S7QZUBXM.js';
16
+ import { getActiveCurrency, ENGINE_VERSION } from './chunk-BSGHOYMT.js';
16
17
  import { useTranslation, I18nProvider } from './chunk-TYNZ5B2B.js';
17
18
  import { Toaster } from './chunk-V2M5YNZQ.js';
18
19
  import { isNativeApp } from './chunk-2TLIULJZ.js';
@@ -342,13 +343,13 @@ function useNativeSpaWebview() {
342
343
  }
343
344
  var navigationSetups = {
344
345
  tanstack: lazy(
345
- () => import('./navigation-XCZMJSNS.js').then((m) => ({ default: m.NavigationSetup }))
346
+ () => import('./navigation-WVVYQOOZ.js').then((m) => ({ default: m.NavigationSetup }))
346
347
  ),
347
- nextjs: lazy(() => import('./navigation-ATD4DRST.js').then((m) => ({ default: m.NavigationSetup })))
348
+ nextjs: lazy(() => import('./navigation-7HBHI524.js').then((m) => ({ default: m.NavigationSetup })))
348
349
  };
349
350
  var routeDocumentSyncs = {
350
351
  tanstack: lazy(
351
- () => import('./document-class-DSRV5LZK.js').then((m) => ({
352
+ () => import('./document-class-2SKG4YZE.js').then((m) => ({
352
353
  default: m.TanStackDocumentSync
353
354
  }))
354
355
  )
@@ -870,7 +871,7 @@ var LazySiftSnippet = lazy(
870
871
  () => import('./SiftSnippet-5FCU6TR6.js').then((m) => ({ default: m.SiftSnippet }))
871
872
  );
872
873
  var LazyStoreClosedNotification = lazy(
873
- () => import('./StoreClosedNotification-AUQCK2MP.js').then((m) => ({
874
+ () => import('./StoreClosedNotification-CMOHA4LU.js').then((m) => ({
874
875
  default: m.StoreClosedNotification
875
876
  }))
876
877
  );
@@ -1115,12 +1116,12 @@ function SallaSdkScripts({ settings }) {
1115
1116
  ] });
1116
1117
  }
1117
1118
  var LazyStoreClosedNotification2 = lazy(
1118
- () => import('./StoreClosedNotification-AUQCK2MP.js').then((m) => ({
1119
+ () => import('./StoreClosedNotification-CMOHA4LU.js').then((m) => ({
1119
1120
  default: m.StoreClosedNotification
1120
1121
  }))
1121
1122
  );
1122
1123
  var LazyMaintenancePage = lazy(
1123
- () => import('./MaintenancePage-7Y4QA5LD.js').then((m) => ({ default: m.MaintenancePage }))
1124
+ () => import('./MaintenancePage-A7CNHM7B.js').then((m) => ({ default: m.MaintenancePage }))
1124
1125
  );
1125
1126
  var BAR = {
1126
1127
  position: "fixed",
@@ -1165,7 +1166,7 @@ function MaintenanceDevBar() {
1165
1166
  ] });
1166
1167
  }
1167
1168
  var LazyLiveEditorBar = lazy(
1168
- () => import('./LiveEditorBar-IQLFFBHE.js').then((m) => ({ default: m.LiveEditorBar }))
1169
+ () => import('./LiveEditorBar-DOSRO35J.js').then((m) => ({ default: m.LiveEditorBar }))
1169
1170
  );
1170
1171
  function LiveEditor() {
1171
1172
  const [frame, setFrame] = useState(null);
@@ -1303,6 +1304,12 @@ function TwilightProvider({
1303
1304
  onError,
1304
1305
  initialLocale
1305
1306
  });
1307
+ const [inEditor, setInEditor] = useState(false);
1308
+ useEffect(() => setInEditor(editorFrame() !== null), []);
1309
+ const theme = useMemo(
1310
+ () => inEditor ? previewTheme(themeData) : themeData,
1311
+ [inEditor, themeData]
1312
+ );
1306
1313
  const storeId = storeData?.id;
1307
1314
  useEffect(() => rememberDevStoreId(storeId), [storeId]);
1308
1315
  const config = useMemo(() => ({ debug }), [debug]);
@@ -1331,7 +1338,7 @@ function TwilightProvider({
1331
1338
  isReady,
1332
1339
  store: storeData,
1333
1340
  _setStore: setStoreData,
1334
- theme: themeData,
1341
+ theme,
1335
1342
  currency,
1336
1343
  config,
1337
1344
  log,
@@ -1363,7 +1370,7 @@ function TwilightProvider({
1363
1370
  return getTwilightContext().extras;
1364
1371
  }
1365
1372
  }),
1366
- [isReady, storeData, setStoreData, themeData, currency, config, log, authToken]
1373
+ [isReady, storeData, setStoreData, theme, currency, config, log, authToken]
1367
1374
  );
1368
1375
  const framework = client !== false ? client?.framework ?? "tanstack" : null;
1369
1376
  const LazyNavSetup = framework ? navigationSetups[framework] : null;
@@ -1432,7 +1439,7 @@ function TwilightProvider({
1432
1439
  /* @__PURE__ */ jsx(
1433
1440
  ThemeDocumentSync,
1434
1441
  {
1435
- theme: themeData,
1442
+ theme,
1436
1443
  locale: initialLocale,
1437
1444
  direction: getTwilightContext().dir,
1438
1445
  isMobileWebview
@@ -1461,5 +1468,5 @@ function useStore() {
1461
1468
  }
1462
1469
 
1463
1470
  export { LazyMaintenancePage, LazyStoreClosedNotification2 as LazyStoreClosedNotification, MasterLayout, TwilightProvider, fastCheckoutScript, registerDefaultHooks, registerDocumentSync, routeDocumentSyncs, useBreadcrumbs, useDate, useGtm, useMoney, useNumber, useOpeningHours, usePageConfig, useStore };
1464
- //# sourceMappingURL=chunk-QLFRNPPF.js.map
1465
- //# sourceMappingURL=chunk-QLFRNPPF.js.map
1471
+ //# sourceMappingURL=chunk-CGDUSBLK.js.map
1472
+ //# sourceMappingURL=chunk-CGDUSBLK.js.map