@salla.sa/twilight-theme-engine 1.0.122 → 1.0.123

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 (219) hide show
  1. package/dist/{AddToCartForm-4Z6BBSU4.js → AddToCartForm-VFCTMUDL.js} +3 -3
  2. package/dist/{AddToCartForm-4Z6BBSU4.js.map → AddToCartForm-VFCTMUDL.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-GIQL4YX6.js → BlogAuthorPage-QVHRFMBQ.js} +17 -17
  4. package/dist/{BlogAuthorPage-GIQL4YX6.js.map → BlogAuthorPage-QVHRFMBQ.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-UELJFSB2.js → BlogCategoryPage-BP5WIW7X.js} +17 -17
  6. package/dist/{BlogCategoryPage-UELJFSB2.js.map → BlogCategoryPage-BP5WIW7X.js.map} +1 -1
  7. package/dist/{BlogPage-G6LPLQRM.js → BlogPage-YUZCR2YV.js} +15 -15
  8. package/dist/{BlogPage-G6LPLQRM.js.map → BlogPage-YUZCR2YV.js.map} +1 -1
  9. package/dist/{BlogSinglePage-SVTO3C5D.js → BlogSinglePage-BJHC7DVC.js} +15 -15
  10. package/dist/{BlogSinglePage-SVTO3C5D.js.map → BlogSinglePage-BJHC7DVC.js.map} +1 -1
  11. package/dist/{BlogTagPage-CFXXPULN.js → BlogTagPage-ND5KMCZZ.js} +17 -17
  12. package/dist/{BlogTagPage-CFXXPULN.js.map → BlogTagPage-ND5KMCZZ.js.map} +1 -1
  13. package/dist/{BrandsPage-IC26RKIG.js → BrandsPage-FGJBQBFL.js} +16 -16
  14. package/dist/{BrandsPage-IC26RKIG.js.map → BrandsPage-FGJBQBFL.js.map} +1 -1
  15. package/dist/{Breadcrumb-OI2H6GVZ.js → Breadcrumb-2LPY6KHS.js} +15 -15
  16. package/dist/{Breadcrumb-OI2H6GVZ.js.map → Breadcrumb-2LPY6KHS.js.map} +1 -1
  17. package/dist/{CartItem-HTEPMUDS.js → CartItem-UQF332H4.js} +15 -15
  18. package/dist/{CartItem-HTEPMUDS.js.map → CartItem-UQF332H4.js.map} +1 -1
  19. package/dist/{CartSummary-OKLYOGJ3.js → CartSummary-FV3I7CJV.js} +15 -15
  20. package/dist/{CartSummary-OKLYOGJ3.js.map → CartSummary-FV3I7CJV.js.map} +1 -1
  21. package/dist/{Copyright-EJW3DGP7.js → Copyright-AZHDEIJX.js} +3 -3
  22. package/dist/{Copyright-EJW3DGP7.js.map → Copyright-AZHDEIJX.js.map} +1 -1
  23. package/dist/{CustomerLayout-YADC5GF7.js → CustomerLayout-DYA77OLE.js} +15 -15
  24. package/dist/{CustomerLayout-YADC5GF7.js.map → CustomerLayout-DYA77OLE.js.map} +1 -1
  25. package/dist/{Footer-XJJIN5T3.js → Footer-BCFWCWWI.js} +4 -4
  26. package/dist/{Footer-XJJIN5T3.js.map → Footer-BCFWCWWI.js.map} +1 -1
  27. package/dist/{Header-WCRFWQIF.js → Header-HALNPMED.js} +8 -8
  28. package/dist/{Header-WCRFWQIF.js.map → Header-HALNPMED.js.map} +1 -1
  29. package/dist/{LoyaltyPage-CVNIZVMT.js → LoyaltyPage-LUQLKTDF.js} +15 -15
  30. package/dist/{LoyaltyPage-CVNIZVMT.js.map → LoyaltyPage-LUQLKTDF.js.map} +1 -1
  31. package/dist/{LoyaltyPointsPage-UZT7LR5E.js → LoyaltyPointsPage-LJLCJBLR.js} +6 -6
  32. package/dist/{LoyaltyPointsPage-UZT7LR5E.js.map → LoyaltyPointsPage-LJLCJBLR.js.map} +1 -1
  33. package/dist/{MainMenu-T2OXHLEM.js → MainMenu-WPVP2XF6.js} +5 -5
  34. package/dist/{MainMenu-T2OXHLEM.js.map → MainMenu-WPVP2XF6.js.map} +1 -1
  35. package/dist/{MasterLayout-MLEDURJK.js → MasterLayout-UPFHTRV6.js} +15 -15
  36. package/dist/{MasterLayout-MLEDURJK.js.map → MasterLayout-UPFHTRV6.js.map} +1 -1
  37. package/dist/{MobileMenu-RYICFJPO.js → MobileMenu-KMTRWYHV.js} +16 -16
  38. package/dist/{MobileMenu-RYICFJPO.js.map → MobileMenu-KMTRWYHV.js.map} +1 -1
  39. package/dist/{NotificationsPage-J2YNZPAN.js → NotificationsPage-5GDS22E6.js} +15 -15
  40. package/dist/{NotificationsPage-J2YNZPAN.js.map → NotificationsPage-5GDS22E6.js.map} +1 -1
  41. package/dist/{OrderSinglePage-IIC6JKFX.js → OrderSinglePage-EXVTMRJI.js} +16 -16
  42. package/dist/{OrderSinglePage-IIC6JKFX.js.map → OrderSinglePage-EXVTMRJI.js.map} +1 -1
  43. package/dist/{OrdersPage-FPUE5T6O.js → OrdersPage-JNIDVHV3.js} +15 -15
  44. package/dist/{OrdersPage-FPUE5T6O.js.map → OrdersPage-JNIDVHV3.js.map} +1 -1
  45. package/dist/{PageSingle-BOZFETZ5.js → PageSingle-KX5XSBWJ.js} +3 -3
  46. package/dist/{PageSingle-BOZFETZ5.js.map → PageSingle-KX5XSBWJ.js.map} +1 -1
  47. package/dist/{ProductDetails-ERSDEM5Z.js → ProductDetails-7EI5PTFY.js} +4 -4
  48. package/dist/{ProductDetails-ERSDEM5Z.js.map → ProductDetails-7EI5PTFY.js.map} +1 -1
  49. package/dist/{ProfilePage-MP4PE2LF.js → ProfilePage-6FSWT3RC.js} +15 -15
  50. package/dist/{ProfilePage-MP4PE2LF.js.map → ProfilePage-6FSWT3RC.js.map} +1 -1
  51. package/dist/{ReviewsPage-5L6DLPN2.js → ReviewsPage-2JSZHLPR.js} +3 -3
  52. package/dist/{ReviewsPage-5L6DLPN2.js.map → ReviewsPage-2JSZHLPR.js.map} +1 -1
  53. package/dist/{SeoCartWidget-XU5LKBMF.js → SeoCartWidget-2MI5P2RT.js} +15 -15
  54. package/dist/{SeoCartWidget-XU5LKBMF.js.map → SeoCartWidget-2MI5P2RT.js.map} +1 -1
  55. package/dist/{SettingsPage-A2AI5CWI.js → SettingsPage-BX3SZNO5.js} +15 -15
  56. package/dist/{SettingsPage-A2AI5CWI.js.map → SettingsPage-BX3SZNO5.js.map} +1 -1
  57. package/dist/{StoreClosedNotification-C6EZSOQF.js → StoreClosedNotification-E7WEFZGO.js} +16 -16
  58. package/dist/{StoreClosedNotification-C6EZSOQF.js.map → StoreClosedNotification-E7WEFZGO.js.map} +1 -1
  59. package/dist/{TestimonialsPage-ZO6OIZMX.js → TestimonialsPage-5OEZMBRF.js} +3 -3
  60. package/dist/{TestimonialsPage-ZO6OIZMX.js.map → TestimonialsPage-5OEZMBRF.js.map} +1 -1
  61. package/dist/{ThankYouPage-RZFWZZXI.js → ThankYouPage-3XJUFGSE.js} +15 -15
  62. package/dist/{ThankYouPage-RZFWZZXI.js.map → ThankYouPage-3XJUFGSE.js.map} +1 -1
  63. package/dist/{WalletPage-BDMVFQ4G.js → WalletPage-LUSSC5TL.js} +16 -16
  64. package/dist/{WalletPage-BDMVFQ4G.js.map → WalletPage-LUSSC5TL.js.map} +1 -1
  65. package/dist/{WishlistPage-3OFBHANB.js → WishlistPage-JK2JLLMR.js} +17 -17
  66. package/dist/{WishlistPage-3OFBHANB.js.map → WishlistPage-JK2JLLMR.js.map} +1 -1
  67. package/dist/api/advertisement.js +2 -2
  68. package/dist/api/apps.js +2 -2
  69. package/dist/api/blog.js +3 -3
  70. package/dist/api/brands.js +3 -3
  71. package/dist/api/cart.js +3 -3
  72. package/dist/api/category.js +3 -3
  73. package/dist/api/client.js +1 -1
  74. package/dist/api/home.js +2 -2
  75. package/dist/api/loyalty.js +3 -3
  76. package/dist/api/menu.js +2 -2
  77. package/dist/api/notification.js +2 -2
  78. package/dist/api/order.js +3 -3
  79. package/dist/api/page.js +3 -3
  80. package/dist/api/product.js +3 -3
  81. package/dist/api/profile.js +1 -1
  82. package/dist/api/store.js +2 -2
  83. package/dist/api/translations.js +2 -2
  84. package/dist/api/user.js +2 -2
  85. package/dist/api/wallet.js +2 -2
  86. package/dist/api/wishlist.js +4 -4
  87. package/dist/{chunk-V23ILNAK.js → chunk-2CORNDFS.js} +3 -3
  88. package/dist/{chunk-V23ILNAK.js.map → chunk-2CORNDFS.js.map} +1 -1
  89. package/dist/{chunk-LCBETTJI.js → chunk-2Q6M3CE5.js} +3 -3
  90. package/dist/{chunk-LCBETTJI.js.map → chunk-2Q6M3CE5.js.map} +1 -1
  91. package/dist/{chunk-6F6VACX5.js → chunk-36FXIFZ6.js} +4 -4
  92. package/dist/{chunk-6F6VACX5.js.map → chunk-36FXIFZ6.js.map} +1 -1
  93. package/dist/{chunk-EA334DDV.js → chunk-3BCIBYJC.js} +3 -3
  94. package/dist/{chunk-EA334DDV.js.map → chunk-3BCIBYJC.js.map} +1 -1
  95. package/dist/{chunk-LG5355UU.js → chunk-3BIT754E.js} +4 -4
  96. package/dist/{chunk-LG5355UU.js.map → chunk-3BIT754E.js.map} +1 -1
  97. package/dist/{chunk-XK6TXHVO.js → chunk-3L4TXBS7.js} +3 -3
  98. package/dist/{chunk-XK6TXHVO.js.map → chunk-3L4TXBS7.js.map} +1 -1
  99. package/dist/{chunk-6JS7UZ3S.js → chunk-4JNLIYCE.js} +3 -3
  100. package/dist/{chunk-6JS7UZ3S.js.map → chunk-4JNLIYCE.js.map} +1 -1
  101. package/dist/{chunk-JOY7HCIH.js → chunk-4KRALUHW.js} +3 -3
  102. package/dist/{chunk-JOY7HCIH.js.map → chunk-4KRALUHW.js.map} +1 -1
  103. package/dist/{chunk-PO6PTKMN.js → chunk-4X4FBQMO.js} +3 -3
  104. package/dist/{chunk-PO6PTKMN.js.map → chunk-4X4FBQMO.js.map} +1 -1
  105. package/dist/{chunk-QTRV6N64.js → chunk-74PTCV46.js} +16 -15
  106. package/dist/chunk-74PTCV46.js.map +1 -0
  107. package/dist/{chunk-HAH22L6T.js → chunk-AFERG34I.js} +7 -7
  108. package/dist/{chunk-HAH22L6T.js.map → chunk-AFERG34I.js.map} +1 -1
  109. package/dist/{chunk-3PS2WFNQ.js → chunk-C4GXSAYT.js} +4 -4
  110. package/dist/{chunk-3PS2WFNQ.js.map → chunk-C4GXSAYT.js.map} +1 -1
  111. package/dist/chunk-DEY7MDGF.js +14 -0
  112. package/dist/{chunk-3IBJ5QUW.js.map → chunk-DEY7MDGF.js.map} +1 -1
  113. package/dist/{chunk-ALHMPT6S.js → chunk-DPLMZQ2Q.js} +3 -3
  114. package/dist/{chunk-ALHMPT6S.js.map → chunk-DPLMZQ2Q.js.map} +1 -1
  115. package/dist/{chunk-BHCKUER2.js → chunk-EEZNB6HS.js} +4 -4
  116. package/dist/{chunk-BHCKUER2.js.map → chunk-EEZNB6HS.js.map} +1 -1
  117. package/dist/{chunk-EL6IDB5U.js → chunk-EPPCSJGJ.js} +3 -3
  118. package/dist/{chunk-EL6IDB5U.js.map → chunk-EPPCSJGJ.js.map} +1 -1
  119. package/dist/{chunk-QMKC7PA2.js → chunk-ESZBWB7X.js} +3 -3
  120. package/dist/{chunk-QMKC7PA2.js.map → chunk-ESZBWB7X.js.map} +1 -1
  121. package/dist/{chunk-N6EWTAE4.js → chunk-FLTPDDL3.js} +7 -7
  122. package/dist/{chunk-N6EWTAE4.js.map → chunk-FLTPDDL3.js.map} +1 -1
  123. package/dist/{chunk-DEIABJV4.js → chunk-FXYR563Z.js} +3 -3
  124. package/dist/{chunk-DEIABJV4.js.map → chunk-FXYR563Z.js.map} +1 -1
  125. package/dist/{chunk-WZOWGICV.js → chunk-G2BBB5AI.js} +3 -3
  126. package/dist/{chunk-WZOWGICV.js.map → chunk-G2BBB5AI.js.map} +1 -1
  127. package/dist/{chunk-4IBG3GR6.js → chunk-HGEKTJVV.js} +4 -4
  128. package/dist/{chunk-4IBG3GR6.js.map → chunk-HGEKTJVV.js.map} +1 -1
  129. package/dist/{chunk-6BQN4JKH.js → chunk-IMCS5L4A.js} +3 -3
  130. package/dist/{chunk-6BQN4JKH.js.map → chunk-IMCS5L4A.js.map} +1 -1
  131. package/dist/{chunk-7IQCF6GU.js → chunk-ISTESEV6.js} +7 -7
  132. package/dist/{chunk-7IQCF6GU.js.map → chunk-ISTESEV6.js.map} +1 -1
  133. package/dist/{chunk-LNSMPXGR.js → chunk-ITXVKNO7.js} +4 -4
  134. package/dist/{chunk-LNSMPXGR.js.map → chunk-ITXVKNO7.js.map} +1 -1
  135. package/dist/{chunk-NEPBUZ5S.js → chunk-IXZPQR4M.js} +5 -5
  136. package/dist/{chunk-NEPBUZ5S.js.map → chunk-IXZPQR4M.js.map} +1 -1
  137. package/dist/{chunk-D6XHL6VQ.js → chunk-KQEBYXYB.js} +121 -3
  138. package/dist/chunk-KQEBYXYB.js.map +1 -0
  139. package/dist/{chunk-PQNLRRWJ.js → chunk-MDJK7WHN.js} +4 -4
  140. package/dist/{chunk-PQNLRRWJ.js.map → chunk-MDJK7WHN.js.map} +1 -1
  141. package/dist/{chunk-UQ7NS6BZ.js → chunk-MQLMYMEQ.js} +3 -3
  142. package/dist/{chunk-UQ7NS6BZ.js.map → chunk-MQLMYMEQ.js.map} +1 -1
  143. package/dist/{chunk-E5OVMQIA.js → chunk-N67C5QRH.js} +3 -3
  144. package/dist/{chunk-E5OVMQIA.js.map → chunk-N67C5QRH.js.map} +1 -1
  145. package/dist/{chunk-MWOP57ZR.js → chunk-PGXS2QT5.js} +3 -3
  146. package/dist/{chunk-MWOP57ZR.js.map → chunk-PGXS2QT5.js.map} +1 -1
  147. package/dist/{chunk-3VOJOKQI.js → chunk-S5FRM4TG.js} +6 -6
  148. package/dist/{chunk-3VOJOKQI.js.map → chunk-S5FRM4TG.js.map} +1 -1
  149. package/dist/{chunk-ESYRKX7T.js → chunk-SLXTJLF2.js} +4 -4
  150. package/dist/{chunk-ESYRKX7T.js.map → chunk-SLXTJLF2.js.map} +1 -1
  151. package/dist/{chunk-Y57KRLGY.js → chunk-UBNOFV7C.js} +3 -3
  152. package/dist/{chunk-Y57KRLGY.js.map → chunk-UBNOFV7C.js.map} +1 -1
  153. package/dist/{chunk-F2MDQCTH.js → chunk-WAZYTMTB.js} +3 -3
  154. package/dist/{chunk-F2MDQCTH.js.map → chunk-WAZYTMTB.js.map} +1 -1
  155. package/dist/{chunk-KNUANWCR.js → chunk-XJJMGLHB.js} +6 -6
  156. package/dist/{chunk-KNUANWCR.js.map → chunk-XJJMGLHB.js.map} +1 -1
  157. package/dist/{chunk-YC4CEVQO.js → chunk-XK5CEGKA.js} +4 -4
  158. package/dist/{chunk-YC4CEVQO.js.map → chunk-XK5CEGKA.js.map} +1 -1
  159. package/dist/{chunk-UNDCL5EE.js → chunk-Y2OC2467.js} +44 -11
  160. package/dist/chunk-Y2OC2467.js.map +1 -0
  161. package/dist/{chunk-5K53BZIN.js → chunk-YPEWTS4L.js} +4 -4
  162. package/dist/{chunk-5K53BZIN.js.map → chunk-YPEWTS4L.js.map} +1 -1
  163. package/dist/{chunk-P6X2QUYL.js → chunk-Z43BQ7ZH.js} +4 -4
  164. package/dist/{chunk-P6X2QUYL.js.map → chunk-Z43BQ7ZH.js.map} +1 -1
  165. package/dist/{chunk-ABDYSBBY.js → chunk-ZTY326ZR.js} +3 -3
  166. package/dist/{chunk-ABDYSBBY.js.map → chunk-ZTY326ZR.js.map} +1 -1
  167. package/dist/components/cart/index.js +1 -1
  168. package/dist/components/common/index.js +1 -1
  169. package/dist/components/drawer/index.js +13 -13
  170. package/dist/components/home/index.js +17 -17
  171. package/dist/components/layout/index.js +4 -4
  172. package/dist/components/product/index.js +14 -14
  173. package/dist/components/snippets/AppsSnippets.d.ts.map +1 -1
  174. package/dist/components/store/index.js +14 -14
  175. package/dist/dev/editor/index.js +1 -1
  176. package/dist/dev/index.js +1 -1
  177. package/dist/{document-class-WRE36CKT.js → document-class-LQ6CAJYV.js} +12 -12
  178. package/dist/{document-class-WRE36CKT.js.map → document-class-LQ6CAJYV.js.map} +1 -1
  179. package/dist/hooks/index.js +13 -13
  180. package/dist/hooks/useGtm.js +13 -13
  181. package/dist/hooks/useMoney.js +13 -13
  182. package/dist/hooks/useStore.js +13 -13
  183. package/dist/hooks/useUser.js +3 -3
  184. package/dist/index.js +13 -13
  185. package/dist/{navigation-KPN6OPJN.js → navigation-MEQGPFG2.js} +4 -4
  186. package/dist/{navigation-KPN6OPJN.js.map → navigation-MEQGPFG2.js.map} +1 -1
  187. package/dist/{navigation-F5YC4AN5.js → navigation-YFRK3OW2.js} +5 -5
  188. package/dist/{navigation-F5YC4AN5.js.map → navigation-YFRK3OW2.js.map} +1 -1
  189. package/dist/{not-found-YZOISV3W.js → not-found-62H3K6KC.js} +16 -16
  190. package/dist/{not-found-YZOISV3W.js.map → not-found-62H3K6KC.js.map} +1 -1
  191. package/dist/providers/index.js +13 -13
  192. package/dist/routes/account/orders.js +4 -4
  193. package/dist/routes/account.js +13 -13
  194. package/dist/routes/blog.js +8 -8
  195. package/dist/routes/brands.js +4 -4
  196. package/dist/routes/cart.js +21 -21
  197. package/dist/routes/home.js +18 -18
  198. package/dist/routes/index.js +3 -3
  199. package/dist/routes/loyalty.js +5 -5
  200. package/dist/routes/page.js +4 -4
  201. package/dist/routes/product-listing.js +19 -19
  202. package/dist/routes/product.js +17 -17
  203. package/dist/routes/seo-redirects.js +3 -3
  204. package/dist/routes/testimonials.js +2 -2
  205. package/dist/routes/thank-you.js +4 -4
  206. package/dist/skeleton.js +18 -18
  207. package/dist/{store-lookup-GXBNYGCM.js → store-lookup-HQYYF3ZS.js} +8 -8
  208. package/dist/{store-lookup-GXBNYGCM.js.map → store-lookup-HQYYF3ZS.js.map} +1 -1
  209. package/dist/tanstack/router.d.ts.map +1 -1
  210. package/dist/tanstack.js +12 -12
  211. package/dist/utils/index.js +2 -2
  212. package/dist/utils/snippet-page-compat.d.ts +43 -0
  213. package/dist/utils/snippet-page-compat.d.ts.map +1 -0
  214. package/package.json +1 -1
  215. package/tailwind/components/snippets/AppsSnippets.tsx.txt +4 -0
  216. package/dist/chunk-3IBJ5QUW.js +0 -14
  217. package/dist/chunk-D6XHL6VQ.js.map +0 -1
  218. package/dist/chunk-QTRV6N64.js.map +0 -1
  219. package/dist/chunk-UNDCL5EE.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { useOpeningHours } from './chunk-QTRV6N64.js';
2
- import { useIsProduct } from './chunk-Y57KRLGY.js';
1
+ import { useOpeningHours } from './chunk-74PTCV46.js';
2
+ import { useIsProduct } from './chunk-UBNOFV7C.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-BHCKUER2.js.map
58
- //# sourceMappingURL=chunk-BHCKUER2.js.map
57
+ //# sourceMappingURL=chunk-EEZNB6HS.js.map
58
+ //# sourceMappingURL=chunk-EEZNB6HS.js.map
@@ -1 +1 @@
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-BHCKUER2.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,EA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,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-EEZNB6HS.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"]}
@@ -137,7 +137,7 @@ function listenForFrameMessages(s, signal) {
137
137
  async function answerLookup(message) {
138
138
  const { requestId, source, query } = message;
139
139
  try {
140
- const { lookupInStore } = await import('./store-lookup-GXBNYGCM.js');
140
+ const { lookupInStore } = await import('./store-lookup-HQYYF3ZS.js');
141
141
  sendToEditor({ kind: "lookup-result", requestId, items: await lookupInStore(source, query) });
142
142
  } catch (error) {
143
143
  sendToEditor({
@@ -457,5 +457,5 @@ function useDevLayoutBlocks(components) {
457
457
  var useDevHomeBlocks = import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;
458
458
 
459
459
  export { blockPath, devSettingsStore, useDevEditorMeta, useDevHomeBlocks, useDevSettingsOverrides, useDevSettingsState };
460
- //# sourceMappingURL=chunk-EL6IDB5U.js.map
461
- //# sourceMappingURL=chunk-EL6IDB5U.js.map
460
+ //# sourceMappingURL=chunk-EPPCSJGJ.js.map
461
+ //# sourceMappingURL=chunk-EPPCSJGJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev/dev-settings-store.ts"],"names":["block"],"mappings":";;;;AA4CA,IAAM,kBAAA,GAAqB,uBAAA;AAE3B,IAAM,aAAA,GAAgB,GAAA;AAEtB,IAAM,YAAA,GAAe,kBAAA;AAErB,IAAM,aAAA,GAAgB,iBAAA;AAEtB,IAAM,aAAA,GAAgB,GAAA;AACtB,IAAM,cAAA,GAAiB,IAAA;AAgBvB,IAAM,cAAA,uBAAqB,GAAA,EAA2B;AAetD,SAA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I,MAAM,EAAE,CAAA;AACtC,MAAA,MAAM,MAAA,GAAA,CACH,IAAA,EAAM,MAAA,IAAU,CAAA,KAAM,IAAA,IAAQ,aAAA,CAAc,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,MAAM,CAAA,GAAI,CAAA,GAAI,CAAA,CAAA;AAChF,MAAA,IAAA,CAAK,OAAA,CAAQ,IAAI,KAAA,CAAM,EAAA,EAAI,EAAE,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAE3D,MAAA,MAAM,KAAA,GAAQ,SAAS,CAAA,EAAG,KAAA,CAAM,EAAE,CAAA,CAAA,EAAI,MAAM,KAAK,KAAA,CAAM,EAAA;AACvD,MAAA,OAAO,EAAE,GAAG,KAAA,CAAM,MAAA,EAAQ,MAAM,KAAA,CAAM,IAAA,EAAM,UAAU,KAAA,EAAM;AAAA,IAC9D,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,UAAA,EAAY,SAAS,CAAC,CAAA;AAC5B;AAEO,IAAM,mBACX,MAAA,CAAA,IAAA,CAAY,GAAA,CAAI,GAAA,GAAM,kBAAA,GAAqB,CAAC,UAAA,KAAe","file":"chunk-EL6IDB5U.js","sourcesContent":["/**\n * Client-side store for the dev editor: theme-setting overrides and a dev-owned\n * home layout. Saved to `twilight.preview.json` through the dev server (see\n * `twilight-schema.plugin.ts`), not to localStorage, for three reasons: the\n * server render can read a file, so the page hydrates with the edited layout\n * instead of flashing the store's; the state survives a port or browser\n * change; and the developer can open, diff or delete it.\n *\n * The saved state reaches this module through `virtual:twilight/schema`, which\n * the root route imports on both sides before anything renders and which puts\n * it on `globalThis[DEV_PREVIEW_GLOBAL]`. Server snapshots read that value\n * (the server's modules are re-run after each save); the browser copies it once\n * and then owns the state.\n *\n * The theme editor (`/__twilight/editor`) frames the storefront, so two copies\n * of this store run side by side. Edits reach every copy on the origin at once\n * over a `BroadcastChannel` (the file save is debounced), and only the copy\n * that made an edit saves it. Everything else between an editor and its frame\n * (the home page's blocks, the store base, scroll-to-block) goes by\n * `postMessage` to that one window, so another storefront tab never answers.\n */\n\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport {\n DEV_LOOKUP_TIMEOUT_MS,\n DEV_PREVIEW_ENDPOINT,\n DEV_PREVIEW_EVENT,\n DEV_PREVIEW_GLOBAL,\n EMPTY_PREVIEW_STATE,\n isEditorFrame,\n normalizePreviewState,\n type DevLookupItem,\n type DevLookupSource,\n type DevPreviewBlock,\n type DevPreviewState,\n type DevSchema,\n} from './schema-types';\nimport { resolveStoreBase } from '../utils/store-identity';\n\nexport type DevSettingsState = DevPreviewState;\nexport type DevSaveStatus = 'idle' | 'saving' | 'saved' | 'error';\ntype LiveBlocks = { path?: string }[];\n\n/** Where the old localStorage-backed widget kept its state; migrated once. */\nconst LEGACY_STORAGE_KEY = 'twilight:dev-settings';\n/** Batch keystrokes into one write. */\nconst SAVE_DELAY_MS = 250;\n/** Same-browser channel every copy of the store listens on, for edits. */\nconst CHANNEL_NAME = 'twilight:preview';\n/** Envelope type of the editor ↔ frame `postMessage`s. */\nconst FRAME_MESSAGE = 'twilight:editor';\n/** How long the frame keeps looking for a block that is still rendering (just added, say). */\nconst FOCUS_WAIT_MS = 2000;\nconst FOCUS_FLASH_MS = 1200;\n\n/** Editor ↔ the storefront it frames. */\ntype FrameMessage =\n | { kind: 'live-blocks'; blocks: LiveBlocks | null }\n | { kind: 'frame-info'; base: string | null }\n | { kind: 'request-live-blocks' }\n | { kind: 'focus-block'; index: number }\n | { kind: 'lookup'; requestId: string; source: DevLookupSource; query: string }\n | { kind: 'lookup-result'; requestId: string; items?: DevLookupItem[]; error?: string };\n\ninterface PendingLookup {\n resolve: (items: DevLookupItem[]) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n}\nconst pendingLookups = new Map<string, PendingLookup>();\n\n/** What the editor shows besides the saved state. */\nexport interface DevEditorMeta {\n /** The blocks the framed home page shows; `null` when it is not on the home page. */\n liveBlocks: LiveBlocks | null;\n saveStatus: DevSaveStatus;\n /** The frame's store segment; `undefined` until the frame has said. */\n frameBase: string | null | undefined;\n}\n\n/**\n * A short random hex id. `getRandomValues`, not `randomUUID`: the latter only\n * exists in secure contexts, and the dev server may be opened on a LAN address.\n */\nfunction randomId(bytes = 6): string {\n const values = globalThis.crypto.getRandomValues(new Uint8Array(bytes));\n return Array.from(values, (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\nlet tabId: string | undefined;\n\n/**\n * Sent with every save so this tab can ignore its own broadcast. Made on first\n * use, never at module load: Cloudflare Workers refuse random values in global\n * scope, and this module is in the worker bundle (its use is dev-only, its\n * top level is not).\n */\nfunction myTabId(): string {\n tabId ??= randomId();\n return tabId;\n}\n\nlet seedSource: unknown;\nlet seedState: DevPreviewState = EMPTY_PREVIEW_STATE;\n\n/** The saved file as this page loaded it, normalized once per value so snapshots keep their identity. */\nfunction readSeed(): DevPreviewState {\n const raw = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL];\n if (raw !== seedSource) {\n seedSource = raw;\n seedState = normalizePreviewState(raw) ?? EMPTY_PREVIEW_STATE;\n }\n return seedState;\n}\n\n// The widget (bundled into the `/dev` entry) and the theme merge (bundled into\n// the engine index via `useTwilightInit`) import this module from two different\n// chunks, so each would otherwise get its OWN copy of the state — the widget\n// would enable a store the merge never reads. Back the state with a single\n// globalThis-keyed instance so every copy shares one source of truth. Dev-only,\n// so a global is acceptable (and lazy, so the module stays side-effect free and\n// tree-shakes out of production).\ninterface DevStoreSingleton {\n state: DevPreviewState;\n listeners: Set<() => void>;\n /** This page's own home blocks, when it is a storefront on its home page. Never saved. */\n ownBlocks: LiveBlocks | null;\n meta: DevEditorMeta;\n metaListeners: Set<() => void>;\n saveTimer: ReturnType<typeof setTimeout> | undefined;\n /** An edit that has not been sent yet. */\n dirty: boolean;\n /** A save request on its way; the next one waits for it, so saves land in order. */\n inFlight: boolean;\n /** The old localStorage copy is removed only once the file has the migrated values. */\n legacyPending: boolean;\n channel: BroadcastChannel | null;\n /** In the editor: the storefront frame's window. */\n getFrame: (() => Window | null) | null;\n /** Detach this copy's listeners and channel. A page keeps one copy for good; tests swap them. */\n dispose: () => void;\n}\n\nconst SINGLETON_KEY = '__twilightDevSettingsStore__';\n\nfunction singleton(): DevStoreSingleton {\n const g = globalThis as unknown as Record<string, DevStoreSingleton | undefined>;\n let s = g[SINGLETON_KEY];\n if (!s) {\n const seeded = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL] != null;\n s = {\n state: readSeed(),\n listeners: new Set(),\n ownBlocks: null,\n meta: { liveBlocks: null, saveStatus: 'idle', frameBase: undefined },\n metaListeners: new Set(),\n saveTimer: undefined,\n dirty: false,\n inFlight: false,\n legacyPending: false,\n channel: null,\n getFrame: null,\n dispose: () => {},\n };\n g[SINGLETON_KEY] = s;\n if (typeof window !== 'undefined') setUpBrowser(s, seeded);\n }\n return s;\n}\n\nfunction setUpBrowser(s: DevStoreSingleton, seeded: boolean): void {\n const listeners = new AbortController();\n const { signal } = listeners;\n if (!seeded) migrateLegacy(s);\n listenForOtherTabs();\n s.channel = openChannel();\n listenForFrameMessages(s, signal);\n window.addEventListener('pagehide', () => flushOnExit(s), { signal });\n s.dispose = () => {\n listeners.abort();\n s.channel?.close();\n clearTimeout(s.saveTimer);\n };\n if (isEditorFrame()) sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n}\n\n/** Carry the old widget's settings over; its per-block patches don't map to a layout. */\nfunction migrateLegacy(s: DevStoreSingleton): void {\n try {\n const raw = window.localStorage.getItem(LEGACY_STORAGE_KEY);\n if (!raw) return;\n const legacy = normalizePreviewState(JSON.parse(raw));\n if (!legacy) return;\n s.state = { enabled: legacy.enabled, settings: legacy.settings, layout: null };\n s.legacyPending = true;\n scheduleSave(s);\n } catch {\n // Storage blocked or the old value is corrupt: nothing worth keeping.\n }\n}\n\n/** Vite's HMR client, typed locally: the engine's `ImportMeta` must not clash with `vite/client`. */\ninterface HotContext {\n on(event: string, cb: (payload: { state?: unknown; from?: unknown }) => void): void;\n}\n\n/**\n * Take a state another copy committed. Not while this copy has an edit of its\n * own waiting to be saved: that edit is newer, and saving it will tell the rest.\n */\nfunction receive(raw: unknown): void {\n const s = singleton();\n if (s.dirty || s.inFlight || s.saveTimer) return;\n const next = normalizePreviewState(raw);\n if (next && JSON.stringify(next) !== JSON.stringify(s.state)) emit(next);\n}\n\n/** Tabs in another browser hear about a save from the dev server. */\nfunction listenForOtherTabs(): void {\n const hot = (import.meta as ImportMeta & { hot?: HotContext }).hot;\n if (!hot) return;\n hot.on(DEV_PREVIEW_EVENT, (payload) => {\n if (payload?.from !== myTabId()) receive(payload?.state);\n });\n}\n\nfunction openChannel(): BroadcastChannel | null {\n if (typeof BroadcastChannel === 'undefined') return null;\n const channel = new BroadcastChannel(CHANNEL_NAME);\n channel.onmessage = ({ data }: MessageEvent<{ state?: unknown; from?: string }>) => {\n if (data && data.from !== myTabId()) receive(data.state);\n };\n return channel;\n}\n\nfunction sendToEditor(message: FrameMessage): void {\n if (isEditorFrame())\n window.parent.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction sendToFrame(message: FrameMessage): void {\n singleton().getFrame?.()?.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction reportToEditor(s: DevStoreSingleton): void {\n sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n sendToEditor({ kind: 'live-blocks', blocks: s.ownBlocks });\n}\n\n/**\n * The editor ↔ frame conversation. A frame only takes requests from its own\n * parent; an editor only takes reports from the frame it shows.\n */\nfunction listenForFrameMessages(s: DevStoreSingleton, signal: AbortSignal): void {\n window.addEventListener(\n 'message',\n (event: MessageEvent) => {\n if (event.origin !== window.location.origin || event.data?.type !== FRAME_MESSAGE) return;\n const message = event.data.message as FrameMessage;\n if (window.parent !== window && event.source === window.parent) {\n if (message.kind === 'request-live-blocks') reportToEditor(s);\n else if (message.kind === 'focus-block') scrollToBlock(message.index);\n else if (message.kind === 'lookup') void answerLookup(message);\n return;\n }\n const frame = s.getFrame?.();\n if (!frame || event.source !== frame) return;\n if (message.kind === 'lookup-result') settleLookup(message);\n else if (message.kind === 'live-blocks') setMeta({ liveBlocks: message.blocks });\n else if (message.kind === 'frame-info') setMeta({ frameBase: message.base });\n },\n { signal }\n );\n}\n\n/** In the frame: look the request up in the store and send back what was found, or why not. */\nasync function answerLookup(message: Extract<FrameMessage, { kind: 'lookup' }>): Promise<void> {\n const { requestId, source, query } = message;\n try {\n const { lookupInStore } = await import('./store-lookup');\n sendToEditor({ kind: 'lookup-result', requestId, items: await lookupInStore(source, query) });\n } catch (error) {\n sendToEditor({\n kind: 'lookup-result',\n requestId,\n error: error instanceof Error ? error.message : 'lookup failed',\n });\n }\n}\n\nfunction settleLookup(message: Extract<FrameMessage, { kind: 'lookup-result' }>): void {\n const pending = pendingLookups.get(message.requestId);\n if (!pending) return;\n pendingLookups.delete(message.requestId);\n clearTimeout(pending.timer);\n if (message.items) pending.resolve(message.items);\n else pending.reject(new Error(message.error ?? 'lookup failed'));\n}\n\n/**\n * In the editor's frame: bring a home block into view and flash an outline on\n * it. Dev-only editor chrome, so it styles the element directly rather than\n * through the theme's React tree. A block added a moment ago may not be in the\n * DOM yet, so look for it for a little while.\n */\nfunction scrollToBlock(index: number): void {\n const started = Date.now();\n const find = () => {\n const el = document.querySelector<HTMLElement>(`[data-home-block=\"${index}\"]`);\n if (!el) {\n if (Date.now() - started < FOCUS_WAIT_MS) requestAnimationFrame(find);\n return;\n }\n const { outline, outlineOffset, scrollMarginTop } = el.style;\n // Clear a sticky header, which would otherwise cover the block's top.\n el.style.scrollMarginTop = '80px';\n el.scrollIntoView({ behavior: 'smooth', block: 'start' });\n el.style.outline = '2px solid #0d9488';\n el.style.outlineOffset = '-2px';\n setTimeout(() => {\n el.style.outline = outline;\n el.style.outlineOffset = outlineOffset;\n el.style.scrollMarginTop = scrollMarginTop;\n }, FOCUS_FLASH_MS);\n };\n find();\n}\n\nfunction emit(next: DevPreviewState): void {\n const s = singleton();\n s.state = next;\n s.listeners.forEach((l) => l());\n}\n\nfunction setMeta(patch: Partial<DevEditorMeta>): void {\n const s = singleton();\n s.meta = { ...s.meta, ...patch };\n s.metaListeners.forEach((l) => l());\n}\n\nfunction saveRequest(s: DevStoreSingleton, keepalive = false): Promise<Response> {\n return fetch(DEV_PREVIEW_ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ state: s.state, from: myTabId() }),\n keepalive,\n });\n}\n\n/** Send the current state, one request at a time; edits made meanwhile go in the next one. */\nasync function flush(s: DevStoreSingleton): Promise<void> {\n if (s.inFlight || !s.dirty) return;\n s.inFlight = true;\n s.dirty = false;\n let failed = false;\n try {\n const res = await saveRequest(s);\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n if (s.legacyPending) {\n s.legacyPending = false;\n try {\n window.localStorage.removeItem(LEGACY_STORAGE_KEY);\n } catch {\n // Storage went away; the file has the values now either way.\n }\n }\n if (!s.dirty && !s.saveTimer) setMeta({ saveStatus: 'saved' });\n } catch (error) {\n // Still unsaved: another tab's state must not replace it, and leaving the\n // page still sends it. Edits made while this request was out are sent once\n // more; the failed one alone waits for the next edit, so nothing loops.\n failed = !s.dirty;\n s.dirty = true;\n setMeta({ saveStatus: 'error' });\n console.error('[twilight-react:preview] could not save twilight.preview.json', error);\n } finally {\n s.inFlight = false;\n if (!failed && s.dirty && !s.saveTimer) void flush(s);\n }\n}\n\nfunction scheduleSave(s: DevStoreSingleton): void {\n if (typeof window === 'undefined' || typeof fetch === 'undefined') return;\n s.dirty = true;\n clearTimeout(s.saveTimer);\n setMeta({ saveStatus: 'saving' });\n s.saveTimer = setTimeout(() => {\n s.saveTimer = undefined;\n void flush(s);\n }, SAVE_DELAY_MS);\n}\n\n/** Closing or reloading the editor must not drop the last edit: send it on the way out. */\nfunction flushOnExit(s: DevStoreSingleton): void {\n if (!s.dirty) return;\n clearTimeout(s.saveTimer);\n s.saveTimer = undefined;\n s.dirty = false;\n void saveRequest(s, true).catch(() => {});\n}\n\nfunction commit(next: DevPreviewState): void {\n const s = singleton();\n emit(next);\n try {\n s.channel?.postMessage({ state: next, from: myTabId() });\n } catch {\n // A value that can't be cloned: the other copies pick it up from the save instead.\n }\n scheduleSave(s);\n}\n\nfunction newBlockId(): string {\n return `b-${randomId()}`;\n}\n\n/** Home loader spelling of a twilight.json path. */\nexport function blockPath(path: string): string {\n return path.replace(/^home\\./, '');\n}\n\nfunction updateLayout(update: (layout: DevPreviewBlock[]) => DevPreviewBlock[]): void {\n const { state } = singleton();\n commit({ ...state, layout: update(state.layout ?? []) });\n}\n\n/** A new block for a twilight.json component, filled with its defaults. */\nfunction blockFor(schema: DevSchema, path: string): DevPreviewBlock {\n const component = schema.components.find((c) => c.path === path);\n const defaults = schema.blockDefaults?.[path] ?? schema.componentDefaults[path] ?? {};\n return {\n id: newBlockId(),\n path: blockPath(path),\n fields: { ...(component?.key ? { key: component.key } : {}), ...defaults },\n };\n}\n\nexport const devSettingsStore = {\n get: (): DevPreviewState => singleton().state,\n /** What the server rendered: the saved file as of this page load. */\n getServer: (): DevPreviewState => readSeed(),\n subscribe(listener: () => void): () => void {\n const s = singleton();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n },\n /** Turn overrides on, seeding any unset setting with its twilight.json default. */\n enable(schema: DevSchema): void {\n const { state } = singleton();\n commit({\n ...state,\n enabled: true,\n settings: { ...schema.settingsDefaults, ...state.settings },\n });\n },\n disable(): void {\n commit({ ...singleton().state, enabled: false });\n },\n setSetting(id: string, value: unknown): void {\n const { state } = singleton();\n commit({ ...state, settings: { ...state.settings, [id]: value } });\n },\n /** Restore every setting to its twilight.json default (keeps enabled and the layout). */\n resetSettings(schema: DevSchema): void {\n commit({ ...singleton().state, settings: { ...schema.settingsDefaults } });\n },\n\n // ── Editor ↔ frame ───────────────────────────────────────────────────────\n\n /** The editor tells the store which window is its storefront frame. */\n connectFrame(getFrame: () => Window | null): () => void {\n const s = singleton();\n s.getFrame = getFrame;\n return () => {\n if (s.getFrame === getFrame) s.getFrame = null;\n };\n },\n /** A storefront's home page reports its blocks (`null` when it leaves); in the editor's frame they go to the editor. Not saved. */\n setLiveBlocks(blocks: LiveBlocks | null): void {\n const s = singleton();\n s.ownBlocks = blocks;\n sendToEditor({ kind: 'live-blocks', blocks });\n },\n /** Ask the frame for its home page's blocks and its store base. */\n requestLiveBlocks(): void {\n sendToFrame({ kind: 'request-live-blocks' });\n },\n /**\n * Search the dev store through the editor's frame. Rejects when there is no\n * frame, it doesn't answer in time, or the store refuses; pickers then fall\n * back to samples.\n */\n lookup(source: DevLookupSource, query: string): Promise<DevLookupItem[]> {\n const frame = singleton().getFrame?.();\n if (!frame) return Promise.reject(new Error('no storefront frame'));\n const requestId = randomId();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n pendingLookups.delete(requestId);\n reject(new Error('the storefront did not answer'));\n }, DEV_LOOKUP_TIMEOUT_MS);\n pendingLookups.set(requestId, { resolve, reject, timer });\n sendToFrame({ kind: 'lookup', requestId, source, query });\n });\n },\n /** Scroll the editor's frame to the home block at `index`. */\n focusBlock(index: number): void {\n sendToFrame({ kind: 'focus-block', index });\n },\n getMeta: (): DevEditorMeta => singleton().meta,\n subscribeMeta(listener: () => void): () => void {\n const s = singleton();\n s.metaListeners.add(listener);\n return () => {\n s.metaListeners.delete(listener);\n };\n },\n\n // ── Home layout ──────────────────────────────────────────────────────────\n\n /**\n * Take over the home layout. Starts from the blocks the home page showed (the\n * frame's in the editor; an empty page stays empty), otherwise from every\n * twilight.json component.\n */\n customizeLayout(schema: DevSchema): void {\n const s = singleton();\n const live = s.meta.liveBlocks ?? s.ownBlocks;\n const layout: DevPreviewBlock[] =\n live !== null\n ? live\n .filter((block): block is { path: string } => typeof block.path === 'string')\n .filter((block) => block.path !== '')\n .map(({ path, ...fields }) => ({ id: newBlockId(), path: blockPath(path), fields }))\n : schema.components.map((component) => blockFor(schema, component.path));\n commit({ ...s.state, enabled: true, layout });\n },\n startEmptyLayout(): void {\n commit({ ...singleton().state, enabled: true, layout: [] });\n },\n /** Back to the store's own blocks. */\n clearLayout(): void {\n commit({ ...singleton().state, layout: null });\n },\n /** Insert a twilight.json component at `at` (default: the end); returns the new block's id. */\n addBlock(schema: DevSchema, path: string, at?: number): string {\n const block = blockFor(schema, path);\n updateLayout((layout) => {\n const next = [...layout];\n next.splice(at ?? next.length, 0, block);\n return next;\n });\n return block.id;\n },\n removeBlock(id: string): void {\n updateLayout((layout) => layout.filter((block) => block.id !== id));\n },\n duplicateBlock(id: string): void {\n updateLayout((layout) => {\n const index = layout.findIndex((block) => block.id === id);\n if (index === -1) return layout;\n const copy = { ...layout[index], id: newBlockId(), fields: { ...layout[index].fields } };\n return [...layout.slice(0, index + 1), copy, ...layout.slice(index + 1)];\n });\n },\n /** Move a block to index `to` (its position after the move). */\n moveBlock(id: string, to: number): void {\n updateLayout((layout) => {\n const from = layout.findIndex((block) => block.id === id);\n if (from === -1) return layout;\n const target = Math.max(0, Math.min(to, layout.length - 1));\n if (target === from) return layout;\n const next = [...layout];\n const [block] = next.splice(from, 1);\n next.splice(target, 0, block);\n return next;\n });\n },\n setBlockField(id: string, fieldId: string, value: unknown): void {\n updateLayout((layout) =>\n layout.map((block) =>\n block.id === id ? { ...block, fields: { ...block.fields, [fieldId]: value } } : block\n )\n );\n },\n};\n\nconst SERVER_META: DevEditorMeta = { liveBlocks: null, saveStatus: 'idle', frameBase: undefined };\n\n/** The frame's blocks and store base, and the save status, for the editor. */\nexport function useDevEditorMeta(): DevEditorMeta {\n return useSyncExternalStore(\n devSettingsStore.subscribeMeta,\n devSettingsStore.getMeta,\n () => SERVER_META\n );\n}\n\n/** Raw store subscription. */\nexport function useDevSettingsState(): DevPreviewState {\n return useSyncExternalStore(\n devSettingsStore.subscribe,\n devSettingsStore.get,\n devSettingsStore.getServer\n );\n}\n\n/**\n * Overrides for SSR-rendered consumers (the theme). The server and the first\n * browser render both read the saved file, so they agree and nothing flashes.\n *\n * Which hook this is gets decided once, when the module loads: in production\n * `import.meta.env.DEV` is a static `false`, so only the empty one survives\n * bundling and the store subscription (and the whole store module, which has\n * no other prod consumer) is dead-code-eliminated. No hook is ever called\n * conditionally.\n */\nexport const useDevSettingsOverrides: () => DevPreviewState = import.meta.env.DEV\n ? useDevSettingsState\n : () => EMPTY_PREVIEW_STATE;\n\n/** A rendered home block; `__dev_id` keys a dev-layout block across reorders. */\nexport type DevHomeBlock<T> = T & { __dev_id?: string };\n\n/**\n * Whether a list in a block's fields gained, lost or reordered items. Blocks\n * often hand their items to a web component that takes them once when it\n * starts (a slider moves its slides into its own track), so such a change\n * never reaches the page until the block mounts again. Editing an item's\n * values is not one: the nodes stay put and update in place.\n */\nexport function listsReshaped(\n before: Record<string, unknown>,\n after: Record<string, unknown>\n): boolean {\n for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {\n const a = before[key];\n const b = after[key];\n if (!Array.isArray(a) && !Array.isArray(b)) continue;\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return true;\n const aItems = a.map((item) => JSON.stringify(item));\n const bItems = b.map((item) => JSON.stringify(item));\n const moved = aItems.some((item, i) => item !== bItems[i]);\n if (moved && [...aItems].sort().join('\\n') === [...bItems].sort().join('\\n')) return true;\n }\n return false;\n}\n\n/**\n * The home page's blocks: the dev layout when one is saved and enabled, else\n * the store's own blocks untouched. Also reports the store's blocks to the\n * editor so \"Customize\" can start from what the page showed, and withdraws\n * them when the page goes.\n *\n * Same production story as {@link useDevSettingsOverrides}: chosen once at\n * module load, so production keeps only the passthrough.\n */\nfunction useDevLayoutBlocks<T extends { path?: string }>(components: T[]): DevHomeBlock<T>[] {\n const overrides = useDevSettingsState();\n // Per block: the fields last rendered, and how often its lists were reshaped.\n const seen = useRef(new Map<string, { fields: Record<string, unknown>; mounts: number }>());\n useEffect(() => {\n devSettingsStore.setLiveBlocks(components);\n return () => devSettingsStore.setLiveBlocks(null);\n }, [components]);\n return useMemo(() => {\n if (!overrides.enabled || !overrides.layout) return components;\n return overrides.layout.map((block) => {\n const last = seen.current.get(block.id);\n const mounts =\n (last?.mounts ?? 0) + (last && listsReshaped(last.fields, block.fields) ? 1 : 0);\n seen.current.set(block.id, { fields: block.fields, mounts });\n // A new key mounts the block again, so a reshaped list reaches the page.\n const devId = mounts ? `${block.id}~${mounts}` : block.id;\n return { ...block.fields, path: block.path, __dev_id: devId } as DevHomeBlock<T>;\n });\n }, [components, overrides]);\n}\n\nexport const useDevHomeBlocks: <T extends { path?: string }>(components: T[]) => DevHomeBlock<T>[] =\n import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;\n"]}
1
+ {"version":3,"sources":["../src/dev/dev-settings-store.ts"],"names":["block"],"mappings":";;;;AA4CA,IAAM,kBAAA,GAAqB,uBAAA;AAE3B,IAAM,aAAA,GAAgB,GAAA;AAEtB,IAAM,YAAA,GAAe,kBAAA;AAErB,IAAM,aAAA,GAAgB,iBAAA;AAEtB,IAAM,aAAA,GAAgB,GAAA;AACtB,IAAM,cAAA,GAAiB,IAAA;AAgBvB,IAAM,cAAA,uBAAqB,GAAA,EAA2B;AAetD,SAAS,QAAA,CAAS,QAAQ,CAAA,EAAW;AACnC,EAAA,MAAM,SAAS,UAAA,CAAW,MAAA,CAAO,gBAAgB,IAAI,UAAA,CAAW,KAAK,CAAC,CAAA;AACtE,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,MAAA,EAAQ,CAAC,MAAM,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,SAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAE,KAAK,EAAE,CAAA;AAC3E;AAEA,IAAI,KAAA;AAQJ,SAAS,OAAA,GAAkB;AACzB,EAAA,KAAA,KAAU,QAAA,EAAS;AACnB,EAAA,OAAO,KAAA;AACT;AAEA,IAAI,UAAA;AACJ,IAAI,SAAA,GAA6B,mBAAA;AAGjC,SAAS,QAAA,GAA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MAAA,EAAQ,MAAM,KAAA,CAAM,IAAA,EAAM,UAAU,KAAA,EAAM;AAAA,IAC9D,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,UAAA,EAAY,SAAS,CAAC,CAAA;AAC5B;AAEO,IAAM,mBACX,MAAA,CAAA,IAAA,CAAY,GAAA,CAAI,GAAA,GAAM,kBAAA,GAAqB,CAAC,UAAA,KAAe","file":"chunk-EPPCSJGJ.js","sourcesContent":["/**\n * Client-side store for the dev editor: theme-setting overrides and a dev-owned\n * home layout. Saved to `twilight.preview.json` through the dev server (see\n * `twilight-schema.plugin.ts`), not to localStorage, for three reasons: the\n * server render can read a file, so the page hydrates with the edited layout\n * instead of flashing the store's; the state survives a port or browser\n * change; and the developer can open, diff or delete it.\n *\n * The saved state reaches this module through `virtual:twilight/schema`, which\n * the root route imports on both sides before anything renders and which puts\n * it on `globalThis[DEV_PREVIEW_GLOBAL]`. Server snapshots read that value\n * (the server's modules are re-run after each save); the browser copies it once\n * and then owns the state.\n *\n * The theme editor (`/__twilight/editor`) frames the storefront, so two copies\n * of this store run side by side. Edits reach every copy on the origin at once\n * over a `BroadcastChannel` (the file save is debounced), and only the copy\n * that made an edit saves it. Everything else between an editor and its frame\n * (the home page's blocks, the store base, scroll-to-block) goes by\n * `postMessage` to that one window, so another storefront tab never answers.\n */\n\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';\nimport {\n DEV_LOOKUP_TIMEOUT_MS,\n DEV_PREVIEW_ENDPOINT,\n DEV_PREVIEW_EVENT,\n DEV_PREVIEW_GLOBAL,\n EMPTY_PREVIEW_STATE,\n isEditorFrame,\n normalizePreviewState,\n type DevLookupItem,\n type DevLookupSource,\n type DevPreviewBlock,\n type DevPreviewState,\n type DevSchema,\n} from './schema-types';\nimport { resolveStoreBase } from '../utils/store-identity';\n\nexport type DevSettingsState = DevPreviewState;\nexport type DevSaveStatus = 'idle' | 'saving' | 'saved' | 'error';\ntype LiveBlocks = { path?: string }[];\n\n/** Where the old localStorage-backed widget kept its state; migrated once. */\nconst LEGACY_STORAGE_KEY = 'twilight:dev-settings';\n/** Batch keystrokes into one write. */\nconst SAVE_DELAY_MS = 250;\n/** Same-browser channel every copy of the store listens on, for edits. */\nconst CHANNEL_NAME = 'twilight:preview';\n/** Envelope type of the editor ↔ frame `postMessage`s. */\nconst FRAME_MESSAGE = 'twilight:editor';\n/** How long the frame keeps looking for a block that is still rendering (just added, say). */\nconst FOCUS_WAIT_MS = 2000;\nconst FOCUS_FLASH_MS = 1200;\n\n/** Editor ↔ the storefront it frames. */\ntype FrameMessage =\n | { kind: 'live-blocks'; blocks: LiveBlocks | null }\n | { kind: 'frame-info'; base: string | null }\n | { kind: 'request-live-blocks' }\n | { kind: 'focus-block'; index: number }\n | { kind: 'lookup'; requestId: string; source: DevLookupSource; query: string }\n | { kind: 'lookup-result'; requestId: string; items?: DevLookupItem[]; error?: string };\n\ninterface PendingLookup {\n resolve: (items: DevLookupItem[]) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n}\nconst pendingLookups = new Map<string, PendingLookup>();\n\n/** What the editor shows besides the saved state. */\nexport interface DevEditorMeta {\n /** The blocks the framed home page shows; `null` when it is not on the home page. */\n liveBlocks: LiveBlocks | null;\n saveStatus: DevSaveStatus;\n /** The frame's store segment; `undefined` until the frame has said. */\n frameBase: string | null | undefined;\n}\n\n/**\n * A short random hex id. `getRandomValues`, not `randomUUID`: the latter only\n * exists in secure contexts, and the dev server may be opened on a LAN address.\n */\nfunction randomId(bytes = 6): string {\n const values = globalThis.crypto.getRandomValues(new Uint8Array(bytes));\n return Array.from(values, (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\nlet tabId: string | undefined;\n\n/**\n * Sent with every save so this tab can ignore its own broadcast. Made on first\n * use, never at module load: Cloudflare Workers refuse random values in global\n * scope, and this module is in the worker bundle (its use is dev-only, its\n * top level is not).\n */\nfunction myTabId(): string {\n tabId ??= randomId();\n return tabId;\n}\n\nlet seedSource: unknown;\nlet seedState: DevPreviewState = EMPTY_PREVIEW_STATE;\n\n/** The saved file as this page loaded it, normalized once per value so snapshots keep their identity. */\nfunction readSeed(): DevPreviewState {\n const raw = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL];\n if (raw !== seedSource) {\n seedSource = raw;\n seedState = normalizePreviewState(raw) ?? EMPTY_PREVIEW_STATE;\n }\n return seedState;\n}\n\n// The widget (bundled into the `/dev` entry) and the theme merge (bundled into\n// the engine index via `useTwilightInit`) import this module from two different\n// chunks, so each would otherwise get its OWN copy of the state — the widget\n// would enable a store the merge never reads. Back the state with a single\n// globalThis-keyed instance so every copy shares one source of truth. Dev-only,\n// so a global is acceptable (and lazy, so the module stays side-effect free and\n// tree-shakes out of production).\ninterface DevStoreSingleton {\n state: DevPreviewState;\n listeners: Set<() => void>;\n /** This page's own home blocks, when it is a storefront on its home page. Never saved. */\n ownBlocks: LiveBlocks | null;\n meta: DevEditorMeta;\n metaListeners: Set<() => void>;\n saveTimer: ReturnType<typeof setTimeout> | undefined;\n /** An edit that has not been sent yet. */\n dirty: boolean;\n /** A save request on its way; the next one waits for it, so saves land in order. */\n inFlight: boolean;\n /** The old localStorage copy is removed only once the file has the migrated values. */\n legacyPending: boolean;\n channel: BroadcastChannel | null;\n /** In the editor: the storefront frame's window. */\n getFrame: (() => Window | null) | null;\n /** Detach this copy's listeners and channel. A page keeps one copy for good; tests swap them. */\n dispose: () => void;\n}\n\nconst SINGLETON_KEY = '__twilightDevSettingsStore__';\n\nfunction singleton(): DevStoreSingleton {\n const g = globalThis as unknown as Record<string, DevStoreSingleton | undefined>;\n let s = g[SINGLETON_KEY];\n if (!s) {\n const seeded = (globalThis as Record<string, unknown>)[DEV_PREVIEW_GLOBAL] != null;\n s = {\n state: readSeed(),\n listeners: new Set(),\n ownBlocks: null,\n meta: { liveBlocks: null, saveStatus: 'idle', frameBase: undefined },\n metaListeners: new Set(),\n saveTimer: undefined,\n dirty: false,\n inFlight: false,\n legacyPending: false,\n channel: null,\n getFrame: null,\n dispose: () => {},\n };\n g[SINGLETON_KEY] = s;\n if (typeof window !== 'undefined') setUpBrowser(s, seeded);\n }\n return s;\n}\n\nfunction setUpBrowser(s: DevStoreSingleton, seeded: boolean): void {\n const listeners = new AbortController();\n const { signal } = listeners;\n if (!seeded) migrateLegacy(s);\n listenForOtherTabs();\n s.channel = openChannel();\n listenForFrameMessages(s, signal);\n window.addEventListener('pagehide', () => flushOnExit(s), { signal });\n s.dispose = () => {\n listeners.abort();\n s.channel?.close();\n clearTimeout(s.saveTimer);\n };\n if (isEditorFrame()) sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n}\n\n/** Carry the old widget's settings over; its per-block patches don't map to a layout. */\nfunction migrateLegacy(s: DevStoreSingleton): void {\n try {\n const raw = window.localStorage.getItem(LEGACY_STORAGE_KEY);\n if (!raw) return;\n const legacy = normalizePreviewState(JSON.parse(raw));\n if (!legacy) return;\n s.state = { enabled: legacy.enabled, settings: legacy.settings, layout: null };\n s.legacyPending = true;\n scheduleSave(s);\n } catch {\n // Storage blocked or the old value is corrupt: nothing worth keeping.\n }\n}\n\n/** Vite's HMR client, typed locally: the engine's `ImportMeta` must not clash with `vite/client`. */\ninterface HotContext {\n on(event: string, cb: (payload: { state?: unknown; from?: unknown }) => void): void;\n}\n\n/**\n * Take a state another copy committed. Not while this copy has an edit of its\n * own waiting to be saved: that edit is newer, and saving it will tell the rest.\n */\nfunction receive(raw: unknown): void {\n const s = singleton();\n if (s.dirty || s.inFlight || s.saveTimer) return;\n const next = normalizePreviewState(raw);\n if (next && JSON.stringify(next) !== JSON.stringify(s.state)) emit(next);\n}\n\n/** Tabs in another browser hear about a save from the dev server. */\nfunction listenForOtherTabs(): void {\n const hot = (import.meta as ImportMeta & { hot?: HotContext }).hot;\n if (!hot) return;\n hot.on(DEV_PREVIEW_EVENT, (payload) => {\n if (payload?.from !== myTabId()) receive(payload?.state);\n });\n}\n\nfunction openChannel(): BroadcastChannel | null {\n if (typeof BroadcastChannel === 'undefined') return null;\n const channel = new BroadcastChannel(CHANNEL_NAME);\n channel.onmessage = ({ data }: MessageEvent<{ state?: unknown; from?: string }>) => {\n if (data && data.from !== myTabId()) receive(data.state);\n };\n return channel;\n}\n\nfunction sendToEditor(message: FrameMessage): void {\n if (isEditorFrame())\n window.parent.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction sendToFrame(message: FrameMessage): void {\n singleton().getFrame?.()?.postMessage({ type: FRAME_MESSAGE, message }, window.location.origin);\n}\n\nfunction reportToEditor(s: DevStoreSingleton): void {\n sendToEditor({ kind: 'frame-info', base: resolveStoreBase() });\n sendToEditor({ kind: 'live-blocks', blocks: s.ownBlocks });\n}\n\n/**\n * The editor ↔ frame conversation. A frame only takes requests from its own\n * parent; an editor only takes reports from the frame it shows.\n */\nfunction listenForFrameMessages(s: DevStoreSingleton, signal: AbortSignal): void {\n window.addEventListener(\n 'message',\n (event: MessageEvent) => {\n if (event.origin !== window.location.origin || event.data?.type !== FRAME_MESSAGE) return;\n const message = event.data.message as FrameMessage;\n if (window.parent !== window && event.source === window.parent) {\n if (message.kind === 'request-live-blocks') reportToEditor(s);\n else if (message.kind === 'focus-block') scrollToBlock(message.index);\n else if (message.kind === 'lookup') void answerLookup(message);\n return;\n }\n const frame = s.getFrame?.();\n if (!frame || event.source !== frame) return;\n if (message.kind === 'lookup-result') settleLookup(message);\n else if (message.kind === 'live-blocks') setMeta({ liveBlocks: message.blocks });\n else if (message.kind === 'frame-info') setMeta({ frameBase: message.base });\n },\n { signal }\n );\n}\n\n/** In the frame: look the request up in the store and send back what was found, or why not. */\nasync function answerLookup(message: Extract<FrameMessage, { kind: 'lookup' }>): Promise<void> {\n const { requestId, source, query } = message;\n try {\n const { lookupInStore } = await import('./store-lookup');\n sendToEditor({ kind: 'lookup-result', requestId, items: await lookupInStore(source, query) });\n } catch (error) {\n sendToEditor({\n kind: 'lookup-result',\n requestId,\n error: error instanceof Error ? error.message : 'lookup failed',\n });\n }\n}\n\nfunction settleLookup(message: Extract<FrameMessage, { kind: 'lookup-result' }>): void {\n const pending = pendingLookups.get(message.requestId);\n if (!pending) return;\n pendingLookups.delete(message.requestId);\n clearTimeout(pending.timer);\n if (message.items) pending.resolve(message.items);\n else pending.reject(new Error(message.error ?? 'lookup failed'));\n}\n\n/**\n * In the editor's frame: bring a home block into view and flash an outline on\n * it. Dev-only editor chrome, so it styles the element directly rather than\n * through the theme's React tree. A block added a moment ago may not be in the\n * DOM yet, so look for it for a little while.\n */\nfunction scrollToBlock(index: number): void {\n const started = Date.now();\n const find = () => {\n const el = document.querySelector<HTMLElement>(`[data-home-block=\"${index}\"]`);\n if (!el) {\n if (Date.now() - started < FOCUS_WAIT_MS) requestAnimationFrame(find);\n return;\n }\n const { outline, outlineOffset, scrollMarginTop } = el.style;\n // Clear a sticky header, which would otherwise cover the block's top.\n el.style.scrollMarginTop = '80px';\n el.scrollIntoView({ behavior: 'smooth', block: 'start' });\n el.style.outline = '2px solid #0d9488';\n el.style.outlineOffset = '-2px';\n setTimeout(() => {\n el.style.outline = outline;\n el.style.outlineOffset = outlineOffset;\n el.style.scrollMarginTop = scrollMarginTop;\n }, FOCUS_FLASH_MS);\n };\n find();\n}\n\nfunction emit(next: DevPreviewState): void {\n const s = singleton();\n s.state = next;\n s.listeners.forEach((l) => l());\n}\n\nfunction setMeta(patch: Partial<DevEditorMeta>): void {\n const s = singleton();\n s.meta = { ...s.meta, ...patch };\n s.metaListeners.forEach((l) => l());\n}\n\nfunction saveRequest(s: DevStoreSingleton, keepalive = false): Promise<Response> {\n return fetch(DEV_PREVIEW_ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ state: s.state, from: myTabId() }),\n keepalive,\n });\n}\n\n/** Send the current state, one request at a time; edits made meanwhile go in the next one. */\nasync function flush(s: DevStoreSingleton): Promise<void> {\n if (s.inFlight || !s.dirty) return;\n s.inFlight = true;\n s.dirty = false;\n let failed = false;\n try {\n const res = await saveRequest(s);\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n if (s.legacyPending) {\n s.legacyPending = false;\n try {\n window.localStorage.removeItem(LEGACY_STORAGE_KEY);\n } catch {\n // Storage went away; the file has the values now either way.\n }\n }\n if (!s.dirty && !s.saveTimer) setMeta({ saveStatus: 'saved' });\n } catch (error) {\n // Still unsaved: another tab's state must not replace it, and leaving the\n // page still sends it. Edits made while this request was out are sent once\n // more; the failed one alone waits for the next edit, so nothing loops.\n failed = !s.dirty;\n s.dirty = true;\n setMeta({ saveStatus: 'error' });\n console.error('[twilight-react:preview] could not save twilight.preview.json', error);\n } finally {\n s.inFlight = false;\n if (!failed && s.dirty && !s.saveTimer) void flush(s);\n }\n}\n\nfunction scheduleSave(s: DevStoreSingleton): void {\n if (typeof window === 'undefined' || typeof fetch === 'undefined') return;\n s.dirty = true;\n clearTimeout(s.saveTimer);\n setMeta({ saveStatus: 'saving' });\n s.saveTimer = setTimeout(() => {\n s.saveTimer = undefined;\n void flush(s);\n }, SAVE_DELAY_MS);\n}\n\n/** Closing or reloading the editor must not drop the last edit: send it on the way out. */\nfunction flushOnExit(s: DevStoreSingleton): void {\n if (!s.dirty) return;\n clearTimeout(s.saveTimer);\n s.saveTimer = undefined;\n s.dirty = false;\n void saveRequest(s, true).catch(() => {});\n}\n\nfunction commit(next: DevPreviewState): void {\n const s = singleton();\n emit(next);\n try {\n s.channel?.postMessage({ state: next, from: myTabId() });\n } catch {\n // A value that can't be cloned: the other copies pick it up from the save instead.\n }\n scheduleSave(s);\n}\n\nfunction newBlockId(): string {\n return `b-${randomId()}`;\n}\n\n/** Home loader spelling of a twilight.json path. */\nexport function blockPath(path: string): string {\n return path.replace(/^home\\./, '');\n}\n\nfunction updateLayout(update: (layout: DevPreviewBlock[]) => DevPreviewBlock[]): void {\n const { state } = singleton();\n commit({ ...state, layout: update(state.layout ?? []) });\n}\n\n/** A new block for a twilight.json component, filled with its defaults. */\nfunction blockFor(schema: DevSchema, path: string): DevPreviewBlock {\n const component = schema.components.find((c) => c.path === path);\n const defaults = schema.blockDefaults?.[path] ?? schema.componentDefaults[path] ?? {};\n return {\n id: newBlockId(),\n path: blockPath(path),\n fields: { ...(component?.key ? { key: component.key } : {}), ...defaults },\n };\n}\n\nexport const devSettingsStore = {\n get: (): DevPreviewState => singleton().state,\n /** What the server rendered: the saved file as of this page load. */\n getServer: (): DevPreviewState => readSeed(),\n subscribe(listener: () => void): () => void {\n const s = singleton();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n },\n /** Turn overrides on, seeding any unset setting with its twilight.json default. */\n enable(schema: DevSchema): void {\n const { state } = singleton();\n commit({\n ...state,\n enabled: true,\n settings: { ...schema.settingsDefaults, ...state.settings },\n });\n },\n disable(): void {\n commit({ ...singleton().state, enabled: false });\n },\n setSetting(id: string, value: unknown): void {\n const { state } = singleton();\n commit({ ...state, settings: { ...state.settings, [id]: value } });\n },\n /** Restore every setting to its twilight.json default (keeps enabled and the layout). */\n resetSettings(schema: DevSchema): void {\n commit({ ...singleton().state, settings: { ...schema.settingsDefaults } });\n },\n\n // ── Editor ↔ frame ───────────────────────────────────────────────────────\n\n /** The editor tells the store which window is its storefront frame. */\n connectFrame(getFrame: () => Window | null): () => void {\n const s = singleton();\n s.getFrame = getFrame;\n return () => {\n if (s.getFrame === getFrame) s.getFrame = null;\n };\n },\n /** A storefront's home page reports its blocks (`null` when it leaves); in the editor's frame they go to the editor. Not saved. */\n setLiveBlocks(blocks: LiveBlocks | null): void {\n const s = singleton();\n s.ownBlocks = blocks;\n sendToEditor({ kind: 'live-blocks', blocks });\n },\n /** Ask the frame for its home page's blocks and its store base. */\n requestLiveBlocks(): void {\n sendToFrame({ kind: 'request-live-blocks' });\n },\n /**\n * Search the dev store through the editor's frame. Rejects when there is no\n * frame, it doesn't answer in time, or the store refuses; pickers then fall\n * back to samples.\n */\n lookup(source: DevLookupSource, query: string): Promise<DevLookupItem[]> {\n const frame = singleton().getFrame?.();\n if (!frame) return Promise.reject(new Error('no storefront frame'));\n const requestId = randomId();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n pendingLookups.delete(requestId);\n reject(new Error('the storefront did not answer'));\n }, DEV_LOOKUP_TIMEOUT_MS);\n pendingLookups.set(requestId, { resolve, reject, timer });\n sendToFrame({ kind: 'lookup', requestId, source, query });\n });\n },\n /** Scroll the editor's frame to the home block at `index`. */\n focusBlock(index: number): void {\n sendToFrame({ kind: 'focus-block', index });\n },\n getMeta: (): DevEditorMeta => singleton().meta,\n subscribeMeta(listener: () => void): () => void {\n const s = singleton();\n s.metaListeners.add(listener);\n return () => {\n s.metaListeners.delete(listener);\n };\n },\n\n // ── Home layout ──────────────────────────────────────────────────────────\n\n /**\n * Take over the home layout. Starts from the blocks the home page showed (the\n * frame's in the editor; an empty page stays empty), otherwise from every\n * twilight.json component.\n */\n customizeLayout(schema: DevSchema): void {\n const s = singleton();\n const live = s.meta.liveBlocks ?? s.ownBlocks;\n const layout: DevPreviewBlock[] =\n live !== null\n ? live\n .filter((block): block is { path: string } => typeof block.path === 'string')\n .filter((block) => block.path !== '')\n .map(({ path, ...fields }) => ({ id: newBlockId(), path: blockPath(path), fields }))\n : schema.components.map((component) => blockFor(schema, component.path));\n commit({ ...s.state, enabled: true, layout });\n },\n startEmptyLayout(): void {\n commit({ ...singleton().state, enabled: true, layout: [] });\n },\n /** Back to the store's own blocks. */\n clearLayout(): void {\n commit({ ...singleton().state, layout: null });\n },\n /** Insert a twilight.json component at `at` (default: the end); returns the new block's id. */\n addBlock(schema: DevSchema, path: string, at?: number): string {\n const block = blockFor(schema, path);\n updateLayout((layout) => {\n const next = [...layout];\n next.splice(at ?? next.length, 0, block);\n return next;\n });\n return block.id;\n },\n removeBlock(id: string): void {\n updateLayout((layout) => layout.filter((block) => block.id !== id));\n },\n duplicateBlock(id: string): void {\n updateLayout((layout) => {\n const index = layout.findIndex((block) => block.id === id);\n if (index === -1) return layout;\n const copy = { ...layout[index], id: newBlockId(), fields: { ...layout[index].fields } };\n return [...layout.slice(0, index + 1), copy, ...layout.slice(index + 1)];\n });\n },\n /** Move a block to index `to` (its position after the move). */\n moveBlock(id: string, to: number): void {\n updateLayout((layout) => {\n const from = layout.findIndex((block) => block.id === id);\n if (from === -1) return layout;\n const target = Math.max(0, Math.min(to, layout.length - 1));\n if (target === from) return layout;\n const next = [...layout];\n const [block] = next.splice(from, 1);\n next.splice(target, 0, block);\n return next;\n });\n },\n setBlockField(id: string, fieldId: string, value: unknown): void {\n updateLayout((layout) =>\n layout.map((block) =>\n block.id === id ? { ...block, fields: { ...block.fields, [fieldId]: value } } : block\n )\n );\n },\n};\n\nconst SERVER_META: DevEditorMeta = { liveBlocks: null, saveStatus: 'idle', frameBase: undefined };\n\n/** The frame's blocks and store base, and the save status, for the editor. */\nexport function useDevEditorMeta(): DevEditorMeta {\n return useSyncExternalStore(\n devSettingsStore.subscribeMeta,\n devSettingsStore.getMeta,\n () => SERVER_META\n );\n}\n\n/** Raw store subscription. */\nexport function useDevSettingsState(): DevPreviewState {\n return useSyncExternalStore(\n devSettingsStore.subscribe,\n devSettingsStore.get,\n devSettingsStore.getServer\n );\n}\n\n/**\n * Overrides for SSR-rendered consumers (the theme). The server and the first\n * browser render both read the saved file, so they agree and nothing flashes.\n *\n * Which hook this is gets decided once, when the module loads: in production\n * `import.meta.env.DEV` is a static `false`, so only the empty one survives\n * bundling and the store subscription (and the whole store module, which has\n * no other prod consumer) is dead-code-eliminated. No hook is ever called\n * conditionally.\n */\nexport const useDevSettingsOverrides: () => DevPreviewState = import.meta.env.DEV\n ? useDevSettingsState\n : () => EMPTY_PREVIEW_STATE;\n\n/** A rendered home block; `__dev_id` keys a dev-layout block across reorders. */\nexport type DevHomeBlock<T> = T & { __dev_id?: string };\n\n/**\n * Whether a list in a block's fields gained, lost or reordered items. Blocks\n * often hand their items to a web component that takes them once when it\n * starts (a slider moves its slides into its own track), so such a change\n * never reaches the page until the block mounts again. Editing an item's\n * values is not one: the nodes stay put and update in place.\n */\nexport function listsReshaped(\n before: Record<string, unknown>,\n after: Record<string, unknown>\n): boolean {\n for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {\n const a = before[key];\n const b = after[key];\n if (!Array.isArray(a) && !Array.isArray(b)) continue;\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return true;\n const aItems = a.map((item) => JSON.stringify(item));\n const bItems = b.map((item) => JSON.stringify(item));\n const moved = aItems.some((item, i) => item !== bItems[i]);\n if (moved && [...aItems].sort().join('\\n') === [...bItems].sort().join('\\n')) return true;\n }\n return false;\n}\n\n/**\n * The home page's blocks: the dev layout when one is saved and enabled, else\n * the store's own blocks untouched. Also reports the store's blocks to the\n * editor so \"Customize\" can start from what the page showed, and withdraws\n * them when the page goes.\n *\n * Same production story as {@link useDevSettingsOverrides}: chosen once at\n * module load, so production keeps only the passthrough.\n */\nfunction useDevLayoutBlocks<T extends { path?: string }>(components: T[]): DevHomeBlock<T>[] {\n const overrides = useDevSettingsState();\n // Per block: the fields last rendered, and how often its lists were reshaped.\n const seen = useRef(new Map<string, { fields: Record<string, unknown>; mounts: number }>());\n useEffect(() => {\n devSettingsStore.setLiveBlocks(components);\n return () => devSettingsStore.setLiveBlocks(null);\n }, [components]);\n return useMemo(() => {\n if (!overrides.enabled || !overrides.layout) return components;\n return overrides.layout.map((block) => {\n const last = seen.current.get(block.id);\n const mounts =\n (last?.mounts ?? 0) + (last && listsReshaped(last.fields, block.fields) ? 1 : 0);\n seen.current.set(block.id, { fields: block.fields, mounts });\n // A new key mounts the block again, so a reshaped list reaches the page.\n const devId = mounts ? `${block.id}~${mounts}` : block.id;\n return { ...block.fields, path: block.path, __dev_id: devId } as DevHomeBlock<T>;\n });\n }, [components, overrides]);\n}\n\nexport const useDevHomeBlocks: <T extends { path?: string }>(components: T[]) => DevHomeBlock<T>[] =\n import.meta.env.DEV ? useDevLayoutBlocks : (components) => components;\n"]}
@@ -1,4 +1,4 @@
1
- import { filesCdn, cdn } from './chunk-6BQN4JKH.js';
1
+ import { filesCdn, cdn } from './chunk-IMCS5L4A.js';
2
2
  import { storeTranslationsQueryKey, translationsQueryKey, composeMessages, isPlainObject } from './chunk-7VNVCHID.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
@@ -126,5 +126,5 @@ var translations = {
126
126
  };
127
127
 
128
128
  export { commonTranslationsPath, storeTranslationsPath, translations };
129
- //# sourceMappingURL=chunk-QMKC7PA2.js.map
130
- //# sourceMappingURL=chunk-QMKC7PA2.js.map
129
+ //# sourceMappingURL=chunk-ESZBWB7X.js.map
130
+ //# sourceMappingURL=chunk-ESZBWB7X.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAAA;AAGpB,SAAS,uBAAuB,MAAA,EAAwB;AAC7D,EAAA,OAAO,uBAAuB,MAAM,CAAA,KAAA,CAAA;AACtC;AAWO,SAAS,qBAAA,CAAsB,SAA0B,MAAA,EAAwB;AACtF,EAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,CAAA;AAC1C;AAUA,eAAe,eACb,IAAA,EACA,EAAE,aAAa,KAAA,EAAM,GAA8B,EAAC,EAC1B;AAE1B,EAAA,MAAM,UAAA,GAAa,CAAC,MAAA,EAAgB,KAAA,KAA0B;AAC5D,IAAA,IAAI,UAAA,EAAY,MAAM,IAAI,KAAA,CAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,EAAI,EAAE,KAAA,EAAO,CAAA;AAC9E,IAAA,OAAA,CAAQ,IAAA,CAAK,gBAAA,EAAkB,MAAA,EAAQ,IAAA,EAAM,SAAS,EAAE,CAAA;AACxD,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,QAAA,GAAW,MAAM,QAAA,CAAS,GAAA,CAAI,IAAA,EAAM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AAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-QMKC7PA2.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),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AcA,QAAA,EAAU,OAAO,OAAA,EAA0B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQzC,cAAA,CAAe,sBAAsB,OAAA,EAAS,MAAM,GAAG,EAAE,UAAA,EAAY,MAAM;AAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc7E,KAAA,EAAO,CACL,MAAA,EACA,SAAA,EACA,WAC+B,eAAA,CAAgB,MAAA,EAAQ,SAAA,EAAW,MAAM,CAAA,IAAK,IAAA;AAAA,EAE/E,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBP,QAAA,EAAU,CAAC,MAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,qBAAqB,MAAM,CAAA;AAAA,MACrC,OAAA,EAAS,MAAM,YAAA,CAAa,GAAA,CAAI,MAAM;AAAA,KACvC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWH,OAAA,EAAS,CAAC,OAAA,EAA0B,MAAA,KAClC,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,yBAAA,CAA0B,OAAA,EAAS,MAAM,CAAA;AAAA,MACnD,OAAA,EAAS,MAAM,YAAA,CAAa,QAAA,CAAS,SAAS,MAAM;AAAA,KACrD;AAAA;AAEP","file":"chunk-ESZBWB7X.js","sourcesContent":["/**\n * @fileoverview Where a storefront's words come from.\n *\n * Two files, merged: the platform's copy for this language, and the merchant's\n * own edits for this language and this store. Both are plain JSON objects on\n * the uploader's CDN, one per language.\n *\n * ```\n * https://cdn.files.salla.network/translations/common/<locale>.json the platform's\n * https://cdn.files.salla.network/translations/<storeId>/<locale>.json the merchant's\n * ```\n *\n * **What this replaces, and why.** Until now the engine read a single global\n * file, `cdn.salla.network/js/translations.json`, holding every language keyed\n * `\"<locale>.trans\"`. Nothing publishes that file: it is an object last written\n * on 2026-03-26, carrying only `ar` and `en` where the platform has 39 locales,\n * 405 keys behind `Languages-Module` and 959 English strings textually\n * different from it. So every React storefront has been serving copy from\n * March, and a key added since has never reached one. It also carried no\n * merchant overrides at all — a merchant editing their theme's wording in the\n * Dashboard changed nothing on a React theme.\n *\n * **Merchant overrides are read, and only when there are any.** Getting here\n * took two corrections worth keeping.\n *\n * The first is the address. A merchant's own wording lives at\n * `translations/<storeId>/<locale>.json`, keyed by `store()->getRouteKey()` —\n * the Optimus-encoded numeric id. An early version addressed it with\n * `resolveStoreIdentifier()`, on the claim that the two are the same string.\n * That is true of the `store-identifier` *header*, which accepts a host, a\n * username or an id, and false of the R2 key: on a custom domain the resolver\n * returns `reefperfumes.com` and on a shared host a username like\n * `mtgr-alaatr-2`. Both 404, both then read as \"this store has no overrides\",\n * and the merchant's wording silently never appears — so the feature would have\n * worked under `?storeId=` alone, which is preview and localhost. It is\n * `settings.store.id` now, which is known only after the settings query.\n *\n * The second is when to ask at all. Most stores have never customised a word,\n * and a miss is an uncached round trip (`cf-cache-status: DYNAMIC` on the 404)\n * on the critical path of every SSR render. So the request is made only when\n * `settings.languages[<ISO>].has_custom_translations` says there is something\n * to get — a flag `Languages-Module` writes when a merchant saves a\n * translation. A store without overrides pays nothing, which is what made this\n * shippable at all.\n *\n * ⚠️ The flag is written on save, so a store whose wording predates it reads as\n * `false` until someone edits a translation or the backfill runs. That is a\n * store keeping today's behaviour, not a regression — React themes have never\n * read merchant overrides — but it does mean the feature is only as complete as\n * the backfill.\n *\n * **Rollout is by fallback, not by flag.** `translations/common/` is written by\n * a sync in the theme build service that may not have run yet, and a hard switch\n * would leave every storefront with no platform strings at all. A missing common\n * file therefore falls back to the old global one, which is exactly today's\n * behaviour — so this is safe to ship before the bucket is populated, and stops\n * using the fallback on its own once it is.\n */\nimport { queryOptions } from '@tanstack/react-query';\nimport { cdn, filesCdn } from './client';\nimport { storeTranslationsQueryKey, translationsQueryKey } from './translations-key';\nimport { composeMessages, isPlainObject, type Messages } from './messages';\nimport type { TranslationMessages } from '../providers/I18nProvider';\n\n/** The global file this used to be the only reader of. See the file comment. */\nconst LEGACY_GLOBAL_FILE = 'js/translations.json';\n\n/** One language of platform copy, shared by every store. */\nexport function commonTranslationsPath(locale: string): string {\n return `translations/common/${locale}.json`;\n}\n\n/**\n * One language of a single merchant's own wording.\n *\n * `storeId` is `settings.store.id`, which is the value `Languages-Module` names\n * the object with (`store()->getRouteKey()`, the Optimus-encoded numeric id).\n * It is **not** `resolveStoreIdentifier()`: that returns a hostname on a custom\n * domain and a username on a shared host, both of which 404 here and would read\n * as \"this merchant has no overrides\" — silently, on every store but a preview.\n */\nexport function storeTranslationsPath(storeId: string | number, locale: string): string {\n return `translations/${storeId}/${locale}.json`;\n}\n\n/**\n * Reads one language file, or `null` when there is nothing to read.\n *\n * A 404 is the ordinary answer, not a failure: most stores have never had a\n * word customised, so their file does not exist. Distinguishing it from a real\n * error matters only for the log — both end in `null` — but a warning on every\n * page load of every uncustomised store is a warning nobody will read.\n */\nasync function readLocaleFile(\n path: string,\n { failLoudly = false }: { failLoudly?: boolean } = {}\n): Promise<Messages | null> {\n /** A 404 always means \"absent\"; everything else is a failure to read. */\n const unreadable = (reason: string, cause?: unknown): null => {\n if (failLoudly) throw new Error(`[translations] ${path}: ${reason}`, { cause });\n console.warn('[translations]', reason, path, cause ?? '');\n return null;\n };\n\n try {\n const response = await filesCdn.get(path, { throwHttpErrors: false, timeout: 5000 });\n if (response.status === 404) return null;\n\n if (!response.ok) {\n return unreadable(`answered ${response.status}`);\n }\n\n const data: unknown = await response.json();\n if (!isPlainObject(data)) {\n return unreadable('is not a JSON object');\n }\n\n return data;\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('[translations]')) throw error;\n return unreadable('could not be read', error);\n }\n}\n\n/**\n * The pre-CDN global file, sliced to one language.\n *\n * Only reached when `translations/common/<locale>.json` is missing, which is\n * the state of the bucket until the sync has run once.\n */\nasync function readLegacyGlobal(locale: string): Promise<Messages | null> {\n try {\n const data = await cdn.get(LEGACY_GLOBAL_FILE, { timeout: 5000 }).json<TranslationMessages>();\n const forLocale = data?.[`${locale}.trans`];\n return isPlainObject(forLocale) ? forLocale : null;\n } catch {\n console.warn('[translations] the legacy global file could not be read either');\n return null;\n }\n}\n\nexport const translations = {\n /**\n * The platform's copy for `locale`.\n *\n * One file, so one request. See the file comment for why the merchant's own\n * wording is not merged in here yet and what it is waiting on.\n */\n get: async (locale: string): Promise<TranslationMessages | null> => {\n const common = await readLocaleFile(commonTranslationsPath(locale));\n const base = common ?? (await readLegacyGlobal(locale));\n if (!base) return null;\n\n // Still wrapped in the `<locale>.trans` shape the rest of the engine reads.\n // `createI18nInstance` slices by that key and so does the SDK bridge in\n // `I18nProvider`; changing the envelope here would be a second change for\n // no gain, since one language is all any of them ever take out of it.\n return { [`${locale}.trans`]: base as Record<string, string> };\n },\n\n /**\n * This merchant's own wording for `locale`, or `null` if they have none.\n *\n * Only worth calling when `settings.languages[<ISO>].has_custom_translations`\n * says there is something to get. Most stores have never customised a word,\n * and a miss here is an uncached round trip — `cf-cache-status: DYNAMIC` on a\n * 404 — on the critical path of an SSR render. The flag is what makes this\n * free for everyone who does not use it.\n *\n * Returned unwrapped, unlike {@link translations.get}: this is merged into\n * that one's messages rather than handed to i18next on its own.\n */\n forStore: async (storeId: string | number, locale: string): Promise<Messages | null> =>\n // `failLoudly`, unlike the platform file: this is only ever called because\n // the settings said overrides exist, so a 500, a timeout or a body that is\n // not JSON is a failure to read them — not a store that has none. Returning\n // `null` there would cache \"no overrides\" as a success, skip the query's\n // retry, and serve Salla's wording in place of the merchant's until the\n // entry expired. A 404 still means absent, and `rootBeforeLoad` catches the\n // throw and keeps the platform copy, so the worst case is unchanged.\n readLocaleFile(storeTranslationsPath(storeId, locale), { failLoudly: true }),\n\n /**\n * The platform's copy for `locale` with this merchant's wording laid over it.\n *\n * Takes the two as values rather than fetching them, so the caller decides\n * whether the second request happens at all and both stay separately cached.\n */\n /**\n * The platform's copy for `locale` with this merchant's wording over it.\n *\n * Delegates to `composeMessages`, which every other reader of these two\n * entries also uses — see `api/messages.ts` for why there is exactly one.\n */\n merge: (\n common: TranslationMessages | null,\n overrides: Messages | null,\n locale: string\n ): TranslationMessages | null => composeMessages(common, overrides, locale) ?? null,\n\n queries: {\n /**\n * @param locale taken as an argument rather than read from the twilight\n * context, and that is load-bearing. This key is built on the server, on\n * hydration, and again lazily from the context accessor; if any of the\n * three read a locale the others had not been given yet, the hydrated page\n * would miss the dehydrated entry and refetch both files it was just\n * handed. Every caller already has the locale in hand.\n *\n * The store is deliberately **not** in the key. One document serves one\n * store — a request that names a different one is redirected with\n * `reloadDocument`, so the client never changes store under a live cache —\n * and adding a value that resolves from the request on the server and from\n * the injected env on the client is how a key stops matching across\n * hydration.\n */\n byLocale: (locale: string) =>\n queryOptions({\n queryKey: translationsQueryKey(locale),\n queryFn: () => translations.get(locale),\n }),\n\n /**\n * This merchant's overrides, cached apart from the platform's copy.\n *\n * Its own entry rather than a wider `byLocale` key, so the common file is\n * fetched and dehydrated once per language whatever the store does, and a\n * store with no overrides never has an entry at all. Both sides compute the\n * key from the settings payload, so the hydrated page finds what the server\n * dehydrated instead of refetching it.\n */\n byStore: (storeId: string | number, locale: string) =>\n queryOptions({\n queryKey: storeTranslationsQueryKey(storeId, locale),\n queryFn: () => translations.forStore(storeId, locale),\n }),\n },\n};\n"]}
@@ -1,8 +1,8 @@
1
- import { order } from './chunk-LG5355UU.js';
1
+ import { order } from './chunk-3BIT754E.js';
2
2
  import { buildHreflangAlternates } from './chunk-OM2GRPDH.js';
3
- import { unauthorized, orUnauthorized, orThrow } from './chunk-Y57KRLGY.js';
3
+ import { unauthorized, orUnauthorized, orThrow } from './chunk-UBNOFV7C.js';
4
4
  import { RouteId } from './chunk-OUW6WESU.js';
5
- import { getAuthToken } from './chunk-6BQN4JKH.js';
5
+ import { getAuthToken } from './chunk-IMCS5L4A.js';
6
6
  import { getTwilightContext } from './chunk-7VNVCHID.js';
7
7
  import { lazy } from 'react';
8
8
 
@@ -55,9 +55,9 @@ async function orderSingleLoader({
55
55
  }
56
56
 
57
57
  // src/routes/account/orders/index.tsx
58
- var LazyOrdersPage = lazy(() => import('./OrdersPage-FPUE5T6O.js').then((m) => ({ default: m.OrdersPage })));
58
+ var LazyOrdersPage = lazy(() => import('./OrdersPage-JNIDVHV3.js').then((m) => ({ default: m.OrdersPage })));
59
59
  var LazyOrderSinglePage = lazy(
60
- () => import('./OrderSinglePage-IIC6JKFX.js').then((m) => ({ default: m.OrderSinglePage }))
60
+ () => import('./OrderSinglePage-EXVTMRJI.js').then((m) => ({ default: m.OrderSinglePage }))
61
61
  );
62
62
  var OrdersPage = LazyOrdersPage;
63
63
  var OrderSinglePage = LazyOrderSinglePage;
@@ -104,5 +104,5 @@ var OrderSingle = {
104
104
  };
105
105
 
106
106
  export { OrderSingle, OrderSinglePage, Orders, OrdersPage, orderSingleLoader, ordersLoader };
107
- //# sourceMappingURL=chunk-N6EWTAE4.js.map
108
- //# sourceMappingURL=chunk-N6EWTAE4.js.map
107
+ //# sourceMappingURL=chunk-FLTPDDL3.js.map
108
+ //# sourceMappingURL=chunk-FLTPDDL3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/account/orders/loader.ts","../src/routes/account/orders/index.tsx"],"names":[],"mappings":";;;;;;;;;AAQA,eAAsB,YAAA,CACpB,KACA,MAAA,EAI0B;AAC1B,EAAA,IAAI,CAAC,YAAA,EAAa,EAAG,MAAM,YAAA,EAAa;AACxC,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA;AAClB,EAAA,MAAM,SAAA,GAAY,OAAO,MAAA,KAAW,SAAA;AACpC,EAAA,MAAM,WAAW,MAAM,cAAA;AAAA,IACrB,MAAM,IAAA,CAAK;AAAA;AAAA,MAET,QAAQ,KAAA,EAAO,MAAA;AAAA,MACf,GAAI,IAAI,UAAA,GAAa,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iBAAA,CAAkB,EAAE,MAAA,EAAQ,GAAA,CAAI,QAAQ,CAAA;AAE3D,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,MAAM,KAAA,GAAQ,MAAM,MAAA,CAAO,IAAA,EAAM,GAAG,CAAA;AACpC,IAAA,OAAO,EAAE,GAAG,IAAA,EAAM,GAAG,KAAA,EAAM;AAAA,EAC7B;AACA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,eAAA,CAAgB,KAAsB,IAAA,EAA4C;AACzF,EAAA,MAAM,IAAA,GAAuB;AAAA,IAC3B,KAAA,EAAO,KAAK,IAAA,CAAK,KAAA;AAAA,IACjB,WAAA,EAAa,KAAK,IAAA,CAAK,WAAA;AAAA,IACvB,oBAAoB,uBAAA,CAAwB,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,SAAS,QAAQ;AAAA,GACjF;AAEA,EAAA,OAAO,IAAA;AACT;AAEO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAI,OAAA,CAAQ,qBAAA;AAAA,EACZ,MAAA,EAAQ,sBAAA;AAAA,EACR,IAAA,EAAM,UAAA;AAAA,EACN,SAAA,EAAW;AACb;AACO,IAAM,WAAA,GAAc;AAAA,EACzB,IAAI,OAAA,CAAQ,sBAAA;AAAA,EACZ,MAAA,EAAQ,2BAAA;AAAA,EACR,IAAA,EAAM,eAAA;AAAA,EACN,SAAA,EAAW;AACb","file":"chunk-N6EWTAE4.js","sourcesContent":["import { order } from '../../../api/order';\nimport { getTwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\nimport { orThrow, orUnauthorized, unauthorized } from '../../../providers/NavigationProvider';\nimport { getAuthToken } from '../../../api/client';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersQuery } from './types';\nimport type { IdParams } from '../../types';\n\nexport async function ordersLoader(\n ctx: { query?: OrdersQuery; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n if (!getAuthToken()) throw unauthorized();\n const query = ctx.query;\n const isPending = query?.status === 'pending';\n const response = await orUnauthorized(\n order.list({\n // Only decides the empty state; <salla-orders> applies its own review filter (`?tab=waiting`).\n status: query?.status,\n ...(ctx.with_items ? { with_items: ctx.with_items } : {}),\n })\n );\n const i18n = getTwilightContext().i18n;\n const pageData: OrdersPageProps = {\n page: {\n title: isPending ? i18n.t('common.titles.pending_orders') : i18n.t('common.titles.orders'),\n slug: RouteId.CUSTOMER_ORDERS_INDEX,\n },\n orders: response.data,\n cursor: response.cursor,\n query,\n };\n\n if (extend) {\n const extra = await extend(pageData, { params: {} });\n return { ...pageData, ...extra } as OrdersPageProps;\n }\n return pageData;\n}\n\nexport async function orderSingleLoader({\n params,\n}: {\n params: IdParams;\n}): Promise<OrderSinglePageProps> {\n if (!getAuthToken()) throw unauthorized();\n const [data, componentsOrder] = await Promise.all([\n order.findOrThrow(params.id),\n orThrow(orUnauthorized(order.findForComponents(params.id))),\n ]);\n const i18n = getTwilightContext().i18n;\n return {\n page: {\n slug: RouteId.CUSTOMER_ORDERS_SINGLE,\n id: String(params.id),\n title: i18n\n .t('pages.orders.order_details')\n .replace(':id', String(data.order.reference_id ?? params.id)),\n },\n order: data.order,\n componentsOrder,\n };\n}\n","import type { HeadDescriptor } from '../../../utils/head';\nimport { buildHreflangAlternates } from '../../../utils/baseHead';\nimport { lazy } from 'react';\nimport { ordersLoader, orderSingleLoader } from './loader';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersSearchParams } from './types';\nimport type { IdParams } from '../../types';\nimport type { TwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\n\n// Lazy-load components for code-splitting\nconst LazyOrdersPage = lazy(() => import('./OrdersPage').then((m) => ({ default: m.OrdersPage })));\nconst LazyOrderSinglePage = lazy(() =>\n import('./OrderSinglePage').then((m) => ({ default: m.OrderSinglePage }))\n);\n\nexport const OrdersPage = LazyOrdersPage;\nexport const OrderSinglePage = LazyOrderSinglePage;\nexport { ordersLoader, orderSingleLoader } from './loader';\nexport type {\n OrdersPageProps,\n OrderSinglePageProps,\n OrdersSearchParams,\n OrdersQuery,\n} from './types';\n\nasync function ordersLoaderWithExtend(\n ctx: { search?: OrdersSearchParams; locale?: string; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n const query = ctx.search;\n // ordersLoader already merges the result of `extend`; calling it again here ran it twice.\n return ordersLoader({ query, with_items: ctx.with_items }, extend);\n}\n\nfunction ordersHead(ctx: TwilightContext, data: OrdersPageProps): HeadDescriptor {\n const isPending = data.query?.status === 'pending';\n const base: HeadDescriptor = {\n title: ctx.i18n.t(isPending ? 'common.titles.pending_orders' : 'common.titles.orders'),\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nasync function orderSingleLoaderWithExtend(\n ctx: { params: IdParams; locale?: string },\n extend?: (\n data: OrderSinglePageProps,\n ctx: { params: IdParams }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrderSinglePageProps> {\n const data = await orderSingleLoader({ params: ctx.params });\n\n if (extend) {\n const extra = await extend(data, ctx);\n return { ...data, ...extra } as OrderSinglePageProps;\n }\n return data;\n}\n\nfunction orderSingleHead(ctx: TwilightContext, data: OrderSinglePageProps): HeadDescriptor {\n const base: HeadDescriptor = {\n title: data.page.title,\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nexport const Orders = {\n id: RouteId.CUSTOMER_ORDERS_INDEX,\n loader: ordersLoaderWithExtend,\n head: ordersHead,\n Component: LazyOrdersPage,\n} as const;\nexport const OrderSingle = {\n id: RouteId.CUSTOMER_ORDERS_SINGLE,\n loader: orderSingleLoaderWithExtend,\n head: orderSingleHead,\n Component: LazyOrderSinglePage,\n} as const;\n"]}
1
+ {"version":3,"sources":["../src/routes/account/orders/loader.ts","../src/routes/account/orders/index.tsx"],"names":[],"mappings":";;;;;;;;;AAQA,eAAsB,YAAA,CACpB,KACA,MAAA,EAI0B;AAC1B,EAAA,IAAI,CAAC,YAAA,EAAa,EAAG,MAAM,YAAA,EAAa;AACxC,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA;AAClB,EAAA,MAAM,SAAA,GAAY,OAAO,MAAA,KAAW,SAAA;AACpC,EAAA,MAAM,WAAW,MAAM,cAAA;AAAA,IACrB,MAAM,IAAA,CAAK;AAAA;AAAA,MAET,QAAQ,KAAA,EAAO,MAAA;AAAA,MACf,GAAI,IAAI,UAAA,GAAa,EAAE,YAAY,GAAA,CAAI,UAAA,KAAe;AAAC,KACxD;AAAA,GACH;AACA,EAAA,MAAM,IAAA,GAAO,oBAAmB,CAAE,IAAA;AAClC,EAAA,MAAM,QAAA,GAA4B;AAAA,IAChC,IAAA,EAAM;AAAA,MACJ,KAAA,EAAO,YAAY,IAAA,CAAK,CAAA,CAAE,8BAA8B,CAAA,GAAI,IAAA,CAAK,EAAE,sBAAsB,CAAA;AAAA,MACzF,MAAM,OAAA,CAAQ;AAAA,KAChB;AAAA,IACA,QAAQ,QAAA,CAAS,IAAA;AAAA,IACjB,QAAQ,QAAA,CAAS,MAAA;AAAA,IACjB;AAAA,GACF;AAEA,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,MAAM,KAAA,GAAQ,MAAM,MAAA,CAAO,QAAA,EAAU,EAAE,MAAA,EAAQ,IAAI,CAAA;AACnD,IAAA,OAAO,EAAE,GAAG,QAAA,EAAU,GAAG,KAAA,EAAM;AAAA,EACjC;AACA,EAAA,OAAO,QAAA;AACT;AAEA,eAAsB,iBAAA,CAAkB;AAAA,EACtC;AACF,CAAA,EAEkC;AAChC,EAAA,IAAI,CAAC,YAAA,EAAa,EAAG,MAAM,YAAA,EAAa;AACxC,EAAA,MAAM,CAAC,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A;AAAA,EACZ,MAAA,EAAQ,2BAAA;AAAA,EACR,IAAA,EAAM,eAAA;AAAA,EACN,SAAA,EAAW;AACb","file":"chunk-FLTPDDL3.js","sourcesContent":["import { order } from '../../../api/order';\nimport { getTwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\nimport { orThrow, orUnauthorized, unauthorized } from '../../../providers/NavigationProvider';\nimport { getAuthToken } from '../../../api/client';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersQuery } from './types';\nimport type { IdParams } from '../../types';\n\nexport async function ordersLoader(\n ctx: { query?: OrdersQuery; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n if (!getAuthToken()) throw unauthorized();\n const query = ctx.query;\n const isPending = query?.status === 'pending';\n const response = await orUnauthorized(\n order.list({\n // Only decides the empty state; <salla-orders> applies its own review filter (`?tab=waiting`).\n status: query?.status,\n ...(ctx.with_items ? { with_items: ctx.with_items } : {}),\n })\n );\n const i18n = getTwilightContext().i18n;\n const pageData: OrdersPageProps = {\n page: {\n title: isPending ? i18n.t('common.titles.pending_orders') : i18n.t('common.titles.orders'),\n slug: RouteId.CUSTOMER_ORDERS_INDEX,\n },\n orders: response.data,\n cursor: response.cursor,\n query,\n };\n\n if (extend) {\n const extra = await extend(pageData, { params: {} });\n return { ...pageData, ...extra } as OrdersPageProps;\n }\n return pageData;\n}\n\nexport async function orderSingleLoader({\n params,\n}: {\n params: IdParams;\n}): Promise<OrderSinglePageProps> {\n if (!getAuthToken()) throw unauthorized();\n const [data, componentsOrder] = await Promise.all([\n order.findOrThrow(params.id),\n orThrow(orUnauthorized(order.findForComponents(params.id))),\n ]);\n const i18n = getTwilightContext().i18n;\n return {\n page: {\n slug: RouteId.CUSTOMER_ORDERS_SINGLE,\n id: String(params.id),\n title: i18n\n .t('pages.orders.order_details')\n .replace(':id', String(data.order.reference_id ?? params.id)),\n },\n order: data.order,\n componentsOrder,\n };\n}\n","import type { HeadDescriptor } from '../../../utils/head';\nimport { buildHreflangAlternates } from '../../../utils/baseHead';\nimport { lazy } from 'react';\nimport { ordersLoader, orderSingleLoader } from './loader';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersSearchParams } from './types';\nimport type { IdParams } from '../../types';\nimport type { TwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\n\n// Lazy-load components for code-splitting\nconst LazyOrdersPage = lazy(() => import('./OrdersPage').then((m) => ({ default: m.OrdersPage })));\nconst LazyOrderSinglePage = lazy(() =>\n import('./OrderSinglePage').then((m) => ({ default: m.OrderSinglePage }))\n);\n\nexport const OrdersPage = LazyOrdersPage;\nexport const OrderSinglePage = LazyOrderSinglePage;\nexport { ordersLoader, orderSingleLoader } from './loader';\nexport type {\n OrdersPageProps,\n OrderSinglePageProps,\n OrdersSearchParams,\n OrdersQuery,\n} from './types';\n\nasync function ordersLoaderWithExtend(\n ctx: { search?: OrdersSearchParams; locale?: string; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n const query = ctx.search;\n // ordersLoader already merges the result of `extend`; calling it again here ran it twice.\n return ordersLoader({ query, with_items: ctx.with_items }, extend);\n}\n\nfunction ordersHead(ctx: TwilightContext, data: OrdersPageProps): HeadDescriptor {\n const isPending = data.query?.status === 'pending';\n const base: HeadDescriptor = {\n title: ctx.i18n.t(isPending ? 'common.titles.pending_orders' : 'common.titles.orders'),\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nasync function orderSingleLoaderWithExtend(\n ctx: { params: IdParams; locale?: string },\n extend?: (\n data: OrderSinglePageProps,\n ctx: { params: IdParams }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrderSinglePageProps> {\n const data = await orderSingleLoader({ params: ctx.params });\n\n if (extend) {\n const extra = await extend(data, ctx);\n return { ...data, ...extra } as OrderSinglePageProps;\n }\n return data;\n}\n\nfunction orderSingleHead(ctx: TwilightContext, data: OrderSinglePageProps): HeadDescriptor {\n const base: HeadDescriptor = {\n title: data.page.title,\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nexport const Orders = {\n id: RouteId.CUSTOMER_ORDERS_INDEX,\n loader: ordersLoaderWithExtend,\n head: ordersHead,\n Component: LazyOrdersPage,\n} as const;\nexport const OrderSingle = {\n id: RouteId.CUSTOMER_ORDERS_SINGLE,\n loader: orderSingleLoaderWithExtend,\n head: orderSingleHead,\n Component: LazyOrderSinglePage,\n} as const;\n"]}
@@ -1,4 +1,4 @@
1
- import { redirect } from './chunk-Y57KRLGY.js';
1
+ import { redirect } from './chunk-UBNOFV7C.js';
2
2
  import { clearAuthTokenCookie } from './chunk-FHU2MXZA.js';
3
3
  import { FALLBACK_LOCALE } from './chunk-T72DAX7R.js';
4
4
  import { useEffect } from 'react';
@@ -37,5 +37,5 @@ function LogoutRedirect() {
37
37
  }
38
38
 
39
39
  export { LogoutRedirect, accountRedirectLoader, pendingOrdersRedirectLoader, productsSourceRedirectLoader, ratingRedirectLoader, slugBrandRedirectLoader };
40
- //# sourceMappingURL=chunk-DEIABJV4.js.map
41
- //# sourceMappingURL=chunk-DEIABJV4.js.map
40
+ //# sourceMappingURL=chunk-FXYR563Z.js.map
41
+ //# sourceMappingURL=chunk-FXYR563Z.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":[],"mappings":";;;;;AAcA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,SAAS,CAAA,CAAA,EAAI,MAAM,WAAW,GAAA,CAAI,MAAA,CAAO,EA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G,IAAA,GAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,IACjF,UAAA,EAAY;AAAA,GACb,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-DEIABJV4.js","sourcesContent":["import { useEffect } from 'react';\nimport { redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE } from '../providers/locale-constants';\nimport { clearAuthTokenCookie } from '../utils/cookies';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/brands/${ctx.params.id}`);\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../src/routes/seo-redirects.ts"],"names":[],"mappings":";;;;;AAcA,eAAsB,wBAAwB,GAAA,EAAkD;AAC9F,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,CAAO,MAAA,IAAU,eAAA;AACpC,EAAA,MAAM,SAAS,CAAA,C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,CAAA,iBAAA,EAAoB,GAAA,CAAI,MAAM,CAAA,EAAG,IAAA,GAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA,EAAI;AAAA,IACjF,UAAA,EAAY;AAAA,GACb,CAAA;AACH;AAUO,SAAS,cAAA,GAAuB;AACrC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,oBAAA,EAAqB;AAErB,IAAA,MAAA,CAAO,QAAA,CAAS,QAAQ,MAAA,CAAO,QAAA,CAAS,KAAK,OAAA,CAAQ,8BAAA,EAAgC,EAAE,CAAC,CAAA;AAAA,EAC1F,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,IAAA;AACT","file":"chunk-FXYR563Z.js","sourcesContent":["import { useEffect } from 'react';\nimport { redirect } from '../providers/NavigationProvider';\nimport { FALLBACK_LOCALE } from '../providers/locale-constants';\nimport { clearAuthTokenCookie } from '../utils/cookies';\n\nexport interface SlugBrandParams {\n /** SEO slug segment (ignored — only here to match the route pattern). */\n slug: string;\n /** Brand numeric ID to redirect to. */\n id: string;\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function slugBrandRedirectLoader(ctx: { params: SlugBrandParams }): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/brands/${ctx.params.id}`);\n}\n\nexport interface PendingOrdersRedirectParams {\n /** Active locale from the `/$locale` parent layout (e.g. `'ar'`, `'en'`). */\n locale?: string;\n}\n\nexport async function pendingOrdersRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders?status=pending`);\n}\n\n/** `/account/rating`: the loyalty \"rate your orders\" link. Twig Raed has no rating page and sends it to the orders list. */\nexport async function ratingRedirectLoader(\n ctx: { params: PendingOrdersRedirectParams } = { params: {} }\n): Promise<never> {\n const locale = ctx.params.locale || FALLBACK_LOCALE;\n throw redirect(`/${locale}/account/orders`);\n}\n\n/** A Twig customer URL (`/profile`, `/orders`, …) kept working as its `/account/…` page. */\nexport async function accountRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n page: string;\n /** The incoming query string (`?status=pending`), kept on the account page. */\n search?: string;\n}): Promise<never> {\n // No locale in the URL stays without one: the locale layout adds it only where the store has several.\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n throw redirect(`${prefix}/account/${ctx.page}${ctx.search ?? ''}`, { statusCode: 301 });\n}\n\n/** `/latest-products`, `/most-sales-products` and `/offers` now live at `/products?source=`. */\nexport async function productsSourceRedirectLoader(ctx: {\n params: PendingOrdersRedirectParams;\n source: 'latest' | 'sales' | 'offers';\n search?: string;\n}): Promise<never> {\n const prefix = ctx.params.locale ? `/${ctx.params.locale}` : '';\n const query = new URLSearchParams(ctx.search);\n query.delete('source');\n const rest = query.toString();\n throw redirect(`${prefix}/products?source=${ctx.source}${rest ? `&${rest}` : ''}`, {\n statusCode: 301,\n });\n}\n\n/**\n * `/logout` — where the SDK sends the browser once `salla.auth.logout()` has run\n * (`salla.url.get('logout?from=…')`). The Twig storefront serves that URL server-side. Here\n * it renders nothing and, in the browser, removes the theme's own `token` cookie (the SDK's\n * `cookie.clearAll()` leaves it) and then does a full navigation home. It has to be a\n * component, not a loader redirect: a loader runs during server rendering, where the cookie\n * can't be cleared, so the redirect would leave the visitor signed in on the next request.\n */\nexport function LogoutRedirect(): null {\n useEffect(() => {\n clearAuthTokenCookie();\n // `/{store base}/{locale}/logout?from=…` → `/{store base}/{locale}`\n window.location.replace(window.location.href.replace(/\\/logout\\/?(\\?[^#]*)?(#.*)?$/, ''));\n }, []);\n return null;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { MadeWithSalla } from './chunk-OQIIJRAS.js';
2
2
  import { HookSlot, useIsClient } from './chunk-5XDPAKF5.js';
3
3
  import { useTranslation } from './chunk-TYNZ5B2B.js';
4
- import { Image } from './chunk-E5OVMQIA.js';
4
+ import { Image } from './chunk-N67C5QRH.js';
5
5
  import { Link } from './chunk-AXW67SY7.js';
6
6
  import { LazyImageModal } from './chunk-7V5HOZW4.js';
7
7
  import { useTwilight } from './chunk-DF6FBKDN.js';
@@ -281,5 +281,5 @@ function Footer({ inSheet = false } = {}) {
281
281
  }
282
282
 
283
283
  export { Footer };
284
- //# sourceMappingURL=chunk-WZOWGICV.js.map
285
- //# sourceMappingURL=chunk-WZOWGICV.js.map
284
+ //# sourceMappingURL=chunk-G2BBB5AI.js.map
285
+ //# sourceMappingURL=chunk-G2BBB5AI.js.map