@salla.sa/twilight-theme-engine 1.0.212 → 1.0.213

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 (268) hide show
  1. package/dist/{AddToCartForm-6B45JALK.js → AddToCartForm-N4MMD6VL.js} +3 -3
  2. package/dist/{AddToCartForm-6B45JALK.js.map → AddToCartForm-N4MMD6VL.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-NUIE33SI.js → BlogAuthorPage-S2GUI5PU.js} +25 -25
  4. package/dist/{BlogAuthorPage-NUIE33SI.js.map → BlogAuthorPage-S2GUI5PU.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-NI7GRGIT.js → BlogCategoryPage-HOKJ3QWU.js} +25 -25
  6. package/dist/{BlogCategoryPage-NI7GRGIT.js.map → BlogCategoryPage-HOKJ3QWU.js.map} +1 -1
  7. package/dist/{BlogPage-EMGJ3RSW.js → BlogPage-UPC3QW3M.js} +23 -23
  8. package/dist/{BlogPage-EMGJ3RSW.js.map → BlogPage-UPC3QW3M.js.map} +1 -1
  9. package/dist/{BlogSinglePage-27XZ6GHV.js → BlogSinglePage-TD33OMSO.js} +23 -23
  10. package/dist/{BlogSinglePage-27XZ6GHV.js.map → BlogSinglePage-TD33OMSO.js.map} +1 -1
  11. package/dist/{BlogTagPage-6NTZP2JR.js → BlogTagPage-LOBT2JFV.js} +25 -25
  12. package/dist/{BlogTagPage-6NTZP2JR.js.map → BlogTagPage-LOBT2JFV.js.map} +1 -1
  13. package/dist/{BrandsPage-CD556YCT.js → BrandsPage-BC2AMBDU.js} +24 -24
  14. package/dist/{BrandsPage-CD556YCT.js.map → BrandsPage-BC2AMBDU.js.map} +1 -1
  15. package/dist/{Breadcrumb-DH25AXCC.js → Breadcrumb-S76SNC44.js} +23 -23
  16. package/dist/{Breadcrumb-DH25AXCC.js.map → Breadcrumb-S76SNC44.js.map} +1 -1
  17. package/dist/{CanvasOverlay-32RQIQKU.js → CanvasOverlay-HIE2LF6E.js} +3 -3
  18. package/dist/{CanvasOverlay-32RQIQKU.js.map → CanvasOverlay-HIE2LF6E.js.map} +1 -1
  19. package/dist/{CartItem-ZCL5CW3F.js → CartItem-YH4EVIL5.js} +23 -23
  20. package/dist/{CartItem-ZCL5CW3F.js.map → CartItem-YH4EVIL5.js.map} +1 -1
  21. package/dist/{CartSummary-HFPWKARM.js → CartSummary-BXOBMFSP.js} +23 -23
  22. package/dist/{CartSummary-HFPWKARM.js.map → CartSummary-BXOBMFSP.js.map} +1 -1
  23. package/dist/{Copyright-4J2OAPEG.js → Copyright-CDOSBXU2.js} +3 -3
  24. package/dist/{Copyright-4J2OAPEG.js.map → Copyright-CDOSBXU2.js.map} +1 -1
  25. package/dist/{CustomerLayout-4RSNDRPC.js → CustomerLayout-H2EWMBZB.js} +23 -23
  26. package/dist/{CustomerLayout-4RSNDRPC.js.map → CustomerLayout-H2EWMBZB.js.map} +1 -1
  27. package/dist/{Footer-GQMU5B7W.js → Footer-WJ7GSEUS.js} +3 -3
  28. package/dist/{Footer-GQMU5B7W.js.map → Footer-WJ7GSEUS.js.map} +1 -1
  29. package/dist/GoogleTag-KZV3WKSO.js +15 -0
  30. package/dist/{GoogleTag-2RBGGJG3.js.map → GoogleTag-KZV3WKSO.js.map} +1 -1
  31. package/dist/{Header-KYCJOGUR.js → Header-5UZ6TNSC.js} +10 -10
  32. package/dist/{Header-KYCJOGUR.js.map → Header-5UZ6TNSC.js.map} +1 -1
  33. package/dist/{LatestProducts-JTKG7N7C.js → LatestProducts-LQPDHIKA.js} +25 -25
  34. package/dist/{LatestProducts-JTKG7N7C.js.map → LatestProducts-LQPDHIKA.js.map} +1 -1
  35. package/dist/{LoyaltyPage-DLNKNRPG.js → LoyaltyPage-LNIMYHR3.js} +23 -23
  36. package/dist/{LoyaltyPage-DLNKNRPG.js.map → LoyaltyPage-LNIMYHR3.js.map} +1 -1
  37. package/dist/{LoyaltyPointsPage-JUPZGVJG.js → LoyaltyPointsPage-PHA3JHM2.js} +7 -7
  38. package/dist/{LoyaltyPointsPage-JUPZGVJG.js.map → LoyaltyPointsPage-PHA3JHM2.js.map} +1 -1
  39. package/dist/{MainMenu-YU3QUJ3J.js → MainMenu-PSN2ME5V.js} +6 -6
  40. package/dist/{MainMenu-YU3QUJ3J.js.map → MainMenu-PSN2ME5V.js.map} +1 -1
  41. package/dist/{MasterLayout-27562HUX.js → MasterLayout-LMG4AOWH.js} +23 -23
  42. package/dist/{MasterLayout-27562HUX.js.map → MasterLayout-LMG4AOWH.js.map} +1 -1
  43. package/dist/{MobileMenu-CSSJWHOF.js → MobileMenu-TA4JGR2O.js} +24 -24
  44. package/dist/{MobileMenu-CSSJWHOF.js.map → MobileMenu-TA4JGR2O.js.map} +1 -1
  45. package/dist/{NotificationsPage-XUQXWPRU.js → NotificationsPage-XFCTNVP2.js} +23 -23
  46. package/dist/{NotificationsPage-XUQXWPRU.js.map → NotificationsPage-XFCTNVP2.js.map} +1 -1
  47. package/dist/{OrderSinglePage-Q76JD52G.js → OrderSinglePage-HRS2SC4M.js} +24 -24
  48. package/dist/{OrderSinglePage-Q76JD52G.js.map → OrderSinglePage-HRS2SC4M.js.map} +1 -1
  49. package/dist/{OrdersPage-3MDI2IPJ.js → OrdersPage-I3OUPPDV.js} +23 -23
  50. package/dist/{OrdersPage-3MDI2IPJ.js.map → OrdersPage-I3OUPPDV.js.map} +1 -1
  51. package/dist/{PageSingle-YDCMHODA.js → PageSingle-3BSOPVBZ.js} +5 -5
  52. package/dist/{PageSingle-YDCMHODA.js.map → PageSingle-3BSOPVBZ.js.map} +1 -1
  53. package/dist/{ProductDetails-2EVEP5SX.js → ProductDetails-F35CZZCU.js} +7 -7
  54. package/dist/{ProductDetails-2EVEP5SX.js.map → ProductDetails-F35CZZCU.js.map} +1 -1
  55. package/dist/{ProfilePage-LAXMD2WO.js → ProfilePage-BMCTP3CH.js} +23 -23
  56. package/dist/{ProfilePage-LAXMD2WO.js.map → ProfilePage-BMCTP3CH.js.map} +1 -1
  57. package/dist/{ReviewsPage-HPTWKBPH.js → ReviewsPage-R6HB3MH2.js} +3 -3
  58. package/dist/{ReviewsPage-HPTWKBPH.js.map → ReviewsPage-R6HB3MH2.js.map} +1 -1
  59. package/dist/{SeoCartWidget-KBEVGXJI.js → SeoCartWidget-5ZDKLKMJ.js} +23 -23
  60. package/dist/{SeoCartWidget-KBEVGXJI.js.map → SeoCartWidget-5ZDKLKMJ.js.map} +1 -1
  61. package/dist/{SettingsPage-Q52PZLUI.js → SettingsPage-UYPJ6QO5.js} +23 -23
  62. package/dist/{SettingsPage-Q52PZLUI.js.map → SettingsPage-UYPJ6QO5.js.map} +1 -1
  63. package/dist/{StoreClosedNotification-PTZVNCCV.js → StoreClosedNotification-4CARFVOG.js} +24 -24
  64. package/dist/{StoreClosedNotification-PTZVNCCV.js.map → StoreClosedNotification-4CARFVOG.js.map} +1 -1
  65. package/dist/{TestimonialsPage-BZEUUKNO.js → TestimonialsPage-6PEBTBYZ.js} +5 -5
  66. package/dist/{TestimonialsPage-BZEUUKNO.js.map → TestimonialsPage-6PEBTBYZ.js.map} +1 -1
  67. package/dist/{ThankYouPage-RFY2WWN5.js → ThankYouPage-OBYA7FZW.js} +23 -23
  68. package/dist/{ThankYouPage-RFY2WWN5.js.map → ThankYouPage-OBYA7FZW.js.map} +1 -1
  69. package/dist/{WalletPage-MF2DTE3D.js → WalletPage-OQUQDIW3.js} +24 -24
  70. package/dist/{WalletPage-MF2DTE3D.js.map → WalletPage-OQUQDIW3.js.map} +1 -1
  71. package/dist/{WebMcpTools-FRDG7FRV.js → WebMcpTools-PT36R4Z2.js} +7 -7
  72. package/dist/{WebMcpTools-FRDG7FRV.js.map → WebMcpTools-PT36R4Z2.js.map} +1 -1
  73. package/dist/{WishlistPage-K2MI4KFF.js → WishlistPage-VP3EUOJF.js} +25 -25
  74. package/dist/{WishlistPage-K2MI4KFF.js.map → WishlistPage-VP3EUOJF.js.map} +1 -1
  75. package/dist/api/advertisement.js +3 -3
  76. package/dist/api/apps.js +3 -3
  77. package/dist/api/blog.js +5 -5
  78. package/dist/api/brands.js +5 -5
  79. package/dist/api/cart.js +5 -5
  80. package/dist/api/category.js +5 -5
  81. package/dist/api/client.js +2 -2
  82. package/dist/api/custom-url.js +3 -3
  83. package/dist/api/home.js +3 -3
  84. package/dist/api/loyalty.js +5 -5
  85. package/dist/api/menu.js +3 -3
  86. package/dist/api/notification.js +3 -3
  87. package/dist/api/order.js +5 -5
  88. package/dist/api/page.js +5 -5
  89. package/dist/api/product.js +5 -5
  90. package/dist/api/profile.js +2 -2
  91. package/dist/api/store.js +3 -3
  92. package/dist/api/translations.js +3 -3
  93. package/dist/api/user.js +3 -3
  94. package/dist/api/wallet.js +3 -3
  95. package/dist/api/wishlist.js +6 -6
  96. package/dist/{chunk-SF5AFS3A.js → chunk-22Z2HPHZ.js} +5 -5
  97. package/dist/{chunk-SF5AFS3A.js.map → chunk-22Z2HPHZ.js.map} +1 -1
  98. package/dist/{chunk-EJNBREFC.js → chunk-3OWXPBB3.js} +2 -2
  99. package/dist/{chunk-EJNBREFC.js.map → chunk-3OWXPBB3.js.map} +1 -1
  100. package/dist/{chunk-2DUC5HPY.js → chunk-5HOEY55Q.js} +3 -3
  101. package/dist/{chunk-2DUC5HPY.js.map → chunk-5HOEY55Q.js.map} +1 -1
  102. package/dist/{chunk-IOQLDBXY.js → chunk-5KJBDPHE.js} +6 -6
  103. package/dist/{chunk-IOQLDBXY.js.map → chunk-5KJBDPHE.js.map} +1 -1
  104. package/dist/{chunk-KM3KK4KZ.js → chunk-5UMVEBO5.js} +5 -5
  105. package/dist/{chunk-KM3KK4KZ.js.map → chunk-5UMVEBO5.js.map} +1 -1
  106. package/dist/{chunk-5B23EENL.js → chunk-5ZT225WZ.js} +5 -5
  107. package/dist/{chunk-5B23EENL.js.map → chunk-5ZT225WZ.js.map} +1 -1
  108. package/dist/{chunk-IIWQCEAD.js → chunk-6VZTX5U3.js} +3 -3
  109. package/dist/{chunk-IIWQCEAD.js.map → chunk-6VZTX5U3.js.map} +1 -1
  110. package/dist/{chunk-HYARGOSU.js → chunk-74HPO4GY.js} +3 -3
  111. package/dist/{chunk-HYARGOSU.js.map → chunk-74HPO4GY.js.map} +1 -1
  112. package/dist/{chunk-BUXWWPX4.js → chunk-AACB4TUN.js} +4 -4
  113. package/dist/{chunk-BUXWWPX4.js.map → chunk-AACB4TUN.js.map} +1 -1
  114. package/dist/{chunk-6RWMVAOC.js → chunk-AHMG3IFV.js} +5 -5
  115. package/dist/{chunk-6RWMVAOC.js.map → chunk-AHMG3IFV.js.map} +1 -1
  116. package/dist/{chunk-7326LK5W.js → chunk-BIIQ4FZA.js} +3 -3
  117. package/dist/{chunk-7326LK5W.js.map → chunk-BIIQ4FZA.js.map} +1 -1
  118. package/dist/{chunk-BZ2QSBXM.js → chunk-BO4WTPCA.js} +3 -3
  119. package/dist/{chunk-BZ2QSBXM.js.map → chunk-BO4WTPCA.js.map} +1 -1
  120. package/dist/{chunk-SL4VKTNK.js → chunk-BSFTK6UF.js} +5 -5
  121. package/dist/{chunk-SL4VKTNK.js.map → chunk-BSFTK6UF.js.map} +1 -1
  122. package/dist/{chunk-C2MAZFIT.js → chunk-C53BH5CR.js} +4 -4
  123. package/dist/{chunk-C2MAZFIT.js.map → chunk-C53BH5CR.js.map} +1 -1
  124. package/dist/{chunk-SIDYR6LZ.js → chunk-CTRBXAY7.js} +4 -4
  125. package/dist/{chunk-SIDYR6LZ.js.map → chunk-CTRBXAY7.js.map} +1 -1
  126. package/dist/{chunk-P5BIPOJ4.js → chunk-DHGZXSNJ.js} +3 -3
  127. package/dist/{chunk-P5BIPOJ4.js.map → chunk-DHGZXSNJ.js.map} +1 -1
  128. package/dist/{chunk-E22CFO2G.js → chunk-DM2A2E43.js} +4 -4
  129. package/dist/{chunk-E22CFO2G.js.map → chunk-DM2A2E43.js.map} +1 -1
  130. package/dist/{chunk-DVJGKIFQ.js → chunk-DRSS7TJ3.js} +3 -3
  131. package/dist/{chunk-DVJGKIFQ.js.map → chunk-DRSS7TJ3.js.map} +1 -1
  132. package/dist/{chunk-LC3M4HW7.js → chunk-EDSZX3QE.js} +4 -4
  133. package/dist/{chunk-LC3M4HW7.js.map → chunk-EDSZX3QE.js.map} +1 -1
  134. package/dist/{chunk-MZPX4EPS.js → chunk-EX4VX4GK.js} +36 -3
  135. package/dist/chunk-EX4VX4GK.js.map +1 -0
  136. package/dist/{chunk-K5EIRY5R.js → chunk-F4D4PJ3T.js} +4 -4
  137. package/dist/{chunk-K5EIRY5R.js.map → chunk-F4D4PJ3T.js.map} +1 -1
  138. package/dist/{chunk-Y7SL553A.js → chunk-F63K3HAG.js} +3 -3
  139. package/dist/{chunk-Y7SL553A.js.map → chunk-F63K3HAG.js.map} +1 -1
  140. package/dist/{chunk-UY4VIWNH.js → chunk-FFHLTFHB.js} +3 -3
  141. package/dist/{chunk-UY4VIWNH.js.map → chunk-FFHLTFHB.js.map} +1 -1
  142. package/dist/{chunk-ZC5TVFLI.js → chunk-GNLXRPBC.js} +3 -3
  143. package/dist/{chunk-ZC5TVFLI.js.map → chunk-GNLXRPBC.js.map} +1 -1
  144. package/dist/{chunk-6FAUK2WT.js → chunk-HCU5GODZ.js} +4 -4
  145. package/dist/{chunk-6FAUK2WT.js.map → chunk-HCU5GODZ.js.map} +1 -1
  146. package/dist/{chunk-E42GOEFC.js → chunk-HI7SDG3R.js} +4 -4
  147. package/dist/{chunk-E42GOEFC.js.map → chunk-HI7SDG3R.js.map} +1 -1
  148. package/dist/{chunk-DGPHTEZE.js → chunk-IAGMA4A4.js} +5 -5
  149. package/dist/{chunk-DGPHTEZE.js.map → chunk-IAGMA4A4.js.map} +1 -1
  150. package/dist/{chunk-JR5EDVZU.js → chunk-INQ7RGEJ.js} +3 -3
  151. package/dist/{chunk-JR5EDVZU.js.map → chunk-INQ7RGEJ.js.map} +1 -1
  152. package/dist/{chunk-ZLKCJBF7.js → chunk-IQMKVT2C.js} +5 -5
  153. package/dist/{chunk-ZLKCJBF7.js.map → chunk-IQMKVT2C.js.map} +1 -1
  154. package/dist/{chunk-2QDPVKV3.js → chunk-ISEQMLS3.js} +3 -3
  155. package/dist/{chunk-2QDPVKV3.js.map → chunk-ISEQMLS3.js.map} +1 -1
  156. package/dist/{chunk-YZVWVS3N.js → chunk-JMPVEH7U.js} +3 -3
  157. package/dist/{chunk-YZVWVS3N.js.map → chunk-JMPVEH7U.js.map} +1 -1
  158. package/dist/{chunk-6KARAWOF.js → chunk-KEB4BTPE.js} +4 -4
  159. package/dist/{chunk-6KARAWOF.js.map → chunk-KEB4BTPE.js.map} +1 -1
  160. package/dist/{chunk-DIYLHIAT.js → chunk-KQSI3TTP.js} +3 -3
  161. package/dist/{chunk-DIYLHIAT.js.map → chunk-KQSI3TTP.js.map} +1 -1
  162. package/dist/{chunk-7CZXUN6C.js → chunk-L7UJ77YE.js} +5 -5
  163. package/dist/{chunk-7CZXUN6C.js.map → chunk-L7UJ77YE.js.map} +1 -1
  164. package/dist/{chunk-JBKUYGDE.js → chunk-LD7EYT7B.js} +3 -3
  165. package/dist/{chunk-JBKUYGDE.js.map → chunk-LD7EYT7B.js.map} +1 -1
  166. package/dist/{chunk-V4ZRPTFE.js → chunk-LG3CUJ4V.js} +23 -22
  167. package/dist/chunk-LG3CUJ4V.js.map +1 -0
  168. package/dist/{chunk-HZECUTW5.js → chunk-LM7Y7MG4.js} +6 -6
  169. package/dist/{chunk-HZECUTW5.js.map → chunk-LM7Y7MG4.js.map} +1 -1
  170. package/dist/{chunk-7XEF3ITQ.js → chunk-MZU5ZEGL.js} +3 -3
  171. package/dist/{chunk-7XEF3ITQ.js.map → chunk-MZU5ZEGL.js.map} +1 -1
  172. package/dist/{chunk-OVRXYL5B.js → chunk-NFXCRFON.js} +5 -5
  173. package/dist/{chunk-OVRXYL5B.js.map → chunk-NFXCRFON.js.map} +1 -1
  174. package/dist/{chunk-UM3G3Q25.js → chunk-ODBQRDUU.js} +4 -4
  175. package/dist/{chunk-UM3G3Q25.js.map → chunk-ODBQRDUU.js.map} +1 -1
  176. package/dist/{chunk-4IISS5KO.js → chunk-ORC5ETTR.js} +5 -24
  177. package/dist/chunk-ORC5ETTR.js.map +1 -0
  178. package/dist/{chunk-TH6HPT3K.js → chunk-PXVA4CFK.js} +7 -7
  179. package/dist/{chunk-TH6HPT3K.js.map → chunk-PXVA4CFK.js.map} +1 -1
  180. package/dist/{chunk-R3FQW5X3.js → chunk-RG6VTJ3F.js} +3 -3
  181. package/dist/{chunk-R3FQW5X3.js.map → chunk-RG6VTJ3F.js.map} +1 -1
  182. package/dist/{chunk-VIUK32MB.js → chunk-RWGRWXIQ.js} +3 -3
  183. package/dist/{chunk-VIUK32MB.js.map → chunk-RWGRWXIQ.js.map} +1 -1
  184. package/dist/{chunk-RFPIGVAO.js → chunk-SV364K3U.js} +4 -4
  185. package/dist/{chunk-RFPIGVAO.js.map → chunk-SV364K3U.js.map} +1 -1
  186. package/dist/{chunk-F27WIIXS.js → chunk-UGIPX4L3.js} +15 -15
  187. package/dist/{chunk-F27WIIXS.js.map → chunk-UGIPX4L3.js.map} +1 -1
  188. package/dist/{chunk-GAZBRWMD.js → chunk-UYOVE4ST.js} +4 -4
  189. package/dist/{chunk-GAZBRWMD.js.map → chunk-UYOVE4ST.js.map} +1 -1
  190. package/dist/{chunk-XCWRUMLQ.js → chunk-VF4DW6KQ.js} +4 -4
  191. package/dist/{chunk-XCWRUMLQ.js.map → chunk-VF4DW6KQ.js.map} +1 -1
  192. package/dist/{chunk-KVEINIFK.js → chunk-VNOMGCMO.js} +4 -4
  193. package/dist/{chunk-KVEINIFK.js.map → chunk-VNOMGCMO.js.map} +1 -1
  194. package/dist/{chunk-KUROVEJP.js → chunk-W3EYJOD3.js} +4 -4
  195. package/dist/{chunk-KUROVEJP.js.map → chunk-W3EYJOD3.js.map} +1 -1
  196. package/dist/{chunk-P3E64ITB.js → chunk-X7E2KD2F.js} +7 -7
  197. package/dist/{chunk-P3E64ITB.js.map → chunk-X7E2KD2F.js.map} +1 -1
  198. package/dist/{chunk-PWUOIH5V.js → chunk-YB356GAD.js} +8 -8
  199. package/dist/{chunk-PWUOIH5V.js.map → chunk-YB356GAD.js.map} +1 -1
  200. package/dist/{chunk-ENA4XT5H.js → chunk-YND257SH.js} +4 -4
  201. package/dist/{chunk-ENA4XT5H.js.map → chunk-YND257SH.js.map} +1 -1
  202. package/dist/{chunk-JY4EI4ZA.js → chunk-ZLSHNQSO.js} +3 -3
  203. package/dist/{chunk-JY4EI4ZA.js.map → chunk-ZLSHNQSO.js.map} +1 -1
  204. package/dist/{chunk-CBZR37Z7.js → chunk-ZOEW4C2C.js} +3 -3
  205. package/dist/{chunk-CBZR37Z7.js.map → chunk-ZOEW4C2C.js.map} +1 -1
  206. package/dist/{chunk-HMPWFSWG.js → chunk-ZWPGS2V7.js} +4 -4
  207. package/dist/{chunk-HMPWFSWG.js.map → chunk-ZWPGS2V7.js.map} +1 -1
  208. package/dist/components/cart/index.js +1 -1
  209. package/dist/components/common/index.js +1 -1
  210. package/dist/components/drawer/index.js +21 -21
  211. package/dist/components/home/index.js +26 -26
  212. package/dist/components/layout/index.js +5 -5
  213. package/dist/components/product/index.js +23 -23
  214. package/dist/components/store/index.js +22 -22
  215. package/dist/components/toast/index.js +3 -3
  216. package/dist/components/tracking/index.js +8 -8
  217. package/dist/{custom-urls-QAOALCNQ.js → custom-urls-7JFXAHVF.js} +9 -9
  218. package/dist/{custom-urls-QAOALCNQ.js.map → custom-urls-7JFXAHVF.js.map} +1 -1
  219. package/dist/dev/editor/index.js +1 -1
  220. package/dist/dev/index.js +1 -1
  221. package/dist/{document-class-SMU7XYXA.js → document-class-DLQ7ZHXB.js} +19 -19
  222. package/dist/{document-class-SMU7XYXA.js.map → document-class-DLQ7ZHXB.js.map} +1 -1
  223. package/dist/hooks/index.js +21 -21
  224. package/dist/hooks/useComments.js +2 -2
  225. package/dist/hooks/useGtm.js +21 -21
  226. package/dist/hooks/useMoney.js +21 -21
  227. package/dist/hooks/useProduct.js +2 -2
  228. package/dist/hooks/useStore.js +21 -21
  229. package/dist/hooks/useUser.js +4 -4
  230. package/dist/hooks/useWishlist.js +2 -2
  231. package/dist/index.js +21 -21
  232. package/dist/native-app/index.js +2 -2
  233. package/dist/{navigation-DAGDU4UL.js → navigation-ILRUCZ3G.js} +7 -7
  234. package/dist/{navigation-DAGDU4UL.js.map → navigation-ILRUCZ3G.js.map} +1 -1
  235. package/dist/{navigation-2SB3WXJN.js → navigation-ZZQKRNBG.js} +6 -6
  236. package/dist/{navigation-2SB3WXJN.js.map → navigation-ZZQKRNBG.js.map} +1 -1
  237. package/dist/{not-found-25S7XQ6X.js → not-found-47B2WAO5.js} +24 -24
  238. package/dist/{not-found-25S7XQ6X.js.map → not-found-47B2WAO5.js.map} +1 -1
  239. package/dist/providers/index.js +21 -21
  240. package/dist/providers/twilight-init.d.ts.map +1 -1
  241. package/dist/routes/account/orders.js +6 -6
  242. package/dist/routes/account.js +15 -15
  243. package/dist/routes/blog.js +10 -10
  244. package/dist/routes/brands.js +6 -6
  245. package/dist/routes/cart.js +31 -31
  246. package/dist/routes/home.js +27 -27
  247. package/dist/routes/index.js +10 -10
  248. package/dist/routes/loyalty.js +7 -7
  249. package/dist/routes/page.js +6 -6
  250. package/dist/routes/product-listing.js +31 -31
  251. package/dist/routes/product.js +30 -30
  252. package/dist/routes/seo-redirects.js +10 -10
  253. package/dist/routes/testimonials.js +2 -2
  254. package/dist/routes/thank-you.js +6 -6
  255. package/dist/skeleton.js +29 -29
  256. package/dist/{store-lookup-ZSSUTV64.js → store-lookup-5ULOU7TP.js} +10 -10
  257. package/dist/{store-lookup-ZSSUTV64.js.map → store-lookup-5ULOU7TP.js.map} +1 -1
  258. package/dist/tanstack.js +19 -19
  259. package/dist/types/salla-sdk.d.ts +11 -0
  260. package/dist/types/salla-sdk.d.ts.map +1 -1
  261. package/dist/utils/index.js +3 -3
  262. package/dist/utils/sdk-helpers.d.ts +10 -0
  263. package/dist/utils/sdk-helpers.d.ts.map +1 -1
  264. package/package.json +1 -1
  265. package/dist/GoogleTag-2RBGGJG3.js +0 -15
  266. package/dist/chunk-4IISS5KO.js.map +0 -1
  267. package/dist/chunk-MZPX4EPS.js.map +0 -1
  268. package/dist/chunk-V4ZRPTFE.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { getActiveScope, api } from './chunk-LC3M4HW7.js';
1
+ import { getActiveScope, api } from './chunk-EDSZX3QE.js';
2
2
  import { queryOptions } from '@tanstack/react-query';
3
3
 
4
4
  async function list(params) {
@@ -45,5 +45,5 @@ var home = {
45
45
  };
46
46
 
47
47
  export { home };
48
- //# sourceMappingURL=chunk-JR5EDVZU.js.map
49
- //# sourceMappingURL=chunk-JR5EDVZU.js.map
48
+ //# sourceMappingURL=chunk-INQ7RGEJ.js.map
49
+ //# sourceMappingURL=chunk-INQ7RGEJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/home.ts"],"names":[],"mappings":";;;AAQA,eAAe,KAAK,MAAA,EAA+D;AACjF,EAAA,MAAM,KAAA,GAAQ,SAAS,CAAA,CAAA,EAAI,IAAI,gBAAgB,MAAM,CAAA,CAAE,QAAA,EAAU,CAAA,CAAA,GAAK,EAAA;AACtE,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,cAAA,EAAiB,KAAK,CAAA,CAAE,CAAA,CAAE,IAAA,EAAoC;AAC7F,EAAA,OAAO,QAAQ,EAAC;AAClB;AAGA,SAAS,OAAA,CAAQ,QAA6B,QAAA,EAAoD;AAChG,EAAA,IAAI,CAAC,QAAA,CAAS,MAAA,EAAQ,OAAO,MAAA;AAC7B,EAAA,MAAM,KAAA,GAAQ,IAAI,GAAA,CAAI,QAAA,CAAS,IAAI,CAAC,KAAA,KAAU,KAAA,CAAM,IAAI,CAAC,CAAA;AACzD,EAAA,MAAM,IAAA,GAAO,SAAS,GAAA,CAAI,CAAC,UAAU,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,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AAA,EAAS;AAAA,IACP,UAAA,EAAY,MACV,YAAA,CAAa;AAAA;AAAA,MAEX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAA,EAAc,EAAE,KAAA,EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,IAAA,CAAK,UAAA;AAAW,KAChC,CAAA;AAAA,IAEH,MAAA,EAAQ,CAAC,IAAA,EAAc,KAAA,KACrB,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,QAAA,EAAU,MAAM,KAAK,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,CAAO,MAAM,KAAK;AAAA,KACvC;AAAA;AAEP","file":"chunk-JR5EDVZU.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { HomeComponentData } from '../types';\n\n/** The page a hook's blocks render on; blocks can target specific products, categories or pages. */\nexport type BlockScope =\n { product_id: number | string } | { category_id: number | string } | { page_id: number | string };\n\nasync function list(params?: Record<string, string>): Promise<HomeComponentData[]> {\n const query = params ? `?${new URLSearchParams(params).toString()}` : '';\n const { data } = await api.get(`component/list${query}`).json<{ data: HomeComponentData[] }>();\n return data ?? [];\n}\n\n/** `blocks` minus each of `excluded`, matched by content: the API sends no id or order to match on. */\nfunction without(blocks: HomeComponentData[], excluded: HomeComponentData[]): HomeComponentData[] {\n if (!excluded.length) return blocks;\n const paths = new Set(excluded.map((block) => block.path));\n const left = excluded.map((block) => JSON.stringify(block));\n return blocks.filter((block) => {\n if (!paths.has(block.path)) return true;\n const index = left.indexOf(JSON.stringify(block));\n if (index === -1) return true;\n left.splice(index, 1);\n return false;\n });\n}\n\nexport const home = {\n components: async (): Promise<HomeComponentData[]> => {\n // The unfiltered list also has the product, category and page blocks, which the home leaves out.\n const [blocks, pageBlocks] = await Promise.all([list(), list({ show_in: 'pages' })]);\n return without(blocks, pageBlocks);\n },\n\n /** The blocks the merchant placed at `hook` on a product, category or page. */\n blocks: async (hook: string, scope: BlockScope): Promise<HomeComponentData[]> => {\n const scopeParams = Object.fromEntries(\n Object.entries(scope).map(([key, id]) => [key, String(id)])\n );\n const blocks = await list({ hooks: hook, ...scopeParams });\n return blocks.map((block) => ({ ...block, path: block.path.replace('home.', '') }));\n },\n\n queries: {\n components: () =>\n queryOptions({\n // Each market (scope) has its own theme version, and its own home page with it.\n queryKey: ['home', 'components', { scope: getActiveScope() }],\n queryFn: () => home.components(),\n }),\n\n blocks: (hook: string, scope: BlockScope) =>\n queryOptions({\n queryKey: ['home', 'blocks', hook, scope],\n queryFn: () => home.blocks(hook, scope),\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/home.ts"],"names":[],"mappings":";;;AAQA,eAAe,KAAK,MAAA,EAA+D;AACjF,EAAA,MAAM,KAAA,GAAQ,SAAS,CAAA,CAAA,EAAI,IAAI,gBAAgB,MAAM,CAAA,CAAE,QAAA,EAAU,CAAA,CAAA,GAAK,EAAA;AACtE,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,cAAA,EAAiB,KAAK,CAAA,CAAE,CAAA,CAAE,IAAA,EAAoC;AAC7F,EAAA,OAAO,QAAQ,EAAC;AAClB;AAGA,SAAS,OAAA,CAAQ,QAA6B,QAAA,EAAoD;AAChG,EAAA,IAAI,CAAC,QAAA,CAAS,MAAA,EAAQ,OAAO,MAAA;AAC7B,EAAA,MAAM,KAAA,GAAQ,IAAI,GAAA,CAAI,QAAA,CAAS,IAAI,CAAC,KAAA,KAAU,KAAA,CAAM,IAAI,CAAC,CAAA;AACzD,EAAA,MAAM,IAAA,GAAO,SAAS,GAAA,CAAI,CAAC,UAAU,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AAC1D,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,CAAC,KAAA,KAAU;AAC9B,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,KAAA,C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EAAO,cAAA,IAAkB,CAAA;AAAA,MAC5D,OAAA,EAAS,MAAM,IAAA,CAAK,UAAA;AAAW,KAChC,CAAA;AAAA,IAEH,MAAA,EAAQ,CAAC,IAAA,EAAc,KAAA,KACrB,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,QAAA,EAAU,MAAM,KAAK,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,CAAO,MAAM,KAAK;AAAA,KACvC;AAAA;AAEP","file":"chunk-INQ7RGEJ.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getActiveScope } from './client';\nimport type { HomeComponentData } from '../types';\n\n/** The page a hook's blocks render on; blocks can target specific products, categories or pages. */\nexport type BlockScope =\n { product_id: number | string } | { category_id: number | string } | { page_id: number | string };\n\nasync function list(params?: Record<string, string>): Promise<HomeComponentData[]> {\n const query = params ? `?${new URLSearchParams(params).toString()}` : '';\n const { data } = await api.get(`component/list${query}`).json<{ data: HomeComponentData[] }>();\n return data ?? [];\n}\n\n/** `blocks` minus each of `excluded`, matched by content: the API sends no id or order to match on. */\nfunction without(blocks: HomeComponentData[], excluded: HomeComponentData[]): HomeComponentData[] {\n if (!excluded.length) return blocks;\n const paths = new Set(excluded.map((block) => block.path));\n const left = excluded.map((block) => JSON.stringify(block));\n return blocks.filter((block) => {\n if (!paths.has(block.path)) return true;\n const index = left.indexOf(JSON.stringify(block));\n if (index === -1) return true;\n left.splice(index, 1);\n return false;\n });\n}\n\nexport const home = {\n components: async (): Promise<HomeComponentData[]> => {\n // The unfiltered list also has the product, category and page blocks, which the home leaves out.\n const [blocks, pageBlocks] = await Promise.all([list(), list({ show_in: 'pages' })]);\n return without(blocks, pageBlocks);\n },\n\n /** The blocks the merchant placed at `hook` on a product, category or page. */\n blocks: async (hook: string, scope: BlockScope): Promise<HomeComponentData[]> => {\n const scopeParams = Object.fromEntries(\n Object.entries(scope).map(([key, id]) => [key, String(id)])\n );\n const blocks = await list({ hooks: hook, ...scopeParams });\n return blocks.map((block) => ({ ...block, path: block.path.replace('home.', '') }));\n },\n\n queries: {\n components: () =>\n queryOptions({\n // Each market (scope) has its own theme version, and its own home page with it.\n queryKey: ['home', 'components', { scope: getActiveScope() }],\n queryFn: () => home.components(),\n }),\n\n blocks: (hook: string, scope: BlockScope) =>\n queryOptions({\n queryKey: ['home', 'blocks', hook, scope],\n queryFn: () => home.blocks(hook, scope),\n }),\n },\n};\n"]}
@@ -1,8 +1,8 @@
1
- import { customUrlRedirect } from './chunk-7CZXUN6C.js';
1
+ import { customUrlRedirect } from './chunk-L7UJ77YE.js';
2
2
  import { PRODUCT_SLUG_ROUTE_ID } from './chunk-NV4PF3O3.js';
3
- import { product } from './chunk-K5EIRY5R.js';
3
+ import { product } from './chunk-F4D4PJ3T.js';
4
4
  import { productKeyOfId, publicProductKeyPath } from './chunk-SDBR4X3K.js';
5
- import { notFound, orThrow, isMissingResource } from './chunk-KUROVEJP.js';
5
+ import { notFound, orThrow, isMissingResource } from './chunk-W3EYJOD3.js';
6
6
 
7
7
  // src/routes/product/id.ts
8
8
  var PRODUCT_ID = /^\d{1,18}$/;
@@ -42,5 +42,5 @@ async function resolveProductKeyPage(page, queryClient, address) {
42
42
  }
43
43
 
44
44
  export { isProductId, productOfKey, resolveProductKeyPage };
45
- //# sourceMappingURL=chunk-ZLKCJBF7.js.map
46
- //# sourceMappingURL=chunk-ZLKCJBF7.js.map
45
+ //# sourceMappingURL=chunk-IQMKVT2C.js.map
46
+ //# sourceMappingURL=chunk-IQMKVT2C.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/product/id.ts","../src/routes/product/key.ts"],"names":[],"mappings":";;;;;;;AAWA,IAAM,UAAA,GAAa,YAAA;AAGZ,SAAS,YAAY,KAAA,EAAoC;AAC9D,EAAA,OAAO,UAAA,CAAW,IAAA,CAAK,KAAA,IAAS,EAAE,CAAA;AACpC;;;ACAA,IAAM,MAAA,GAAS,UAAA;AAMf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,QAAA,EAAS;AAAA,EACX;AACF","file":"chunk-ZLKCJBF7.js","sourcesContent":["/**\n * A product id: 1 to 18 digits.\n *\n * The API keeps product ids in a signed 64-bit integer. Up to 9223372036854775807 it answers\n * a missing product with 410; one past that, it answers 417, which is neither 404 nor 410, so\n * the page went out as a 500 (`/-/p99999999999999999999999`, which scanners ask for). Every\n * 18-digit number fits; real ids have about 10.\n *\n * `TWIG_PRODUCT_URL` in `../seo-redirects.ts` carries the same cap. Both are literals, because static\n * analysis flags a `RegExp` built from a string.\n */\nconst PRODUCT_ID = /^\\d{1,18}$/;\n\n/** Whether `value` can be a product id the API answers 200 or 410 for. */\nexport function isProductId(value: string | undefined): boolean {\n return PRODUCT_ID.test(value ?? '');\n}\n","/**\n * @fileoverview The product at a SKU-link address (`/{key}-{name}`, see `router/product-key-urls`).\n *\n * The rewrite hands the product route an id of `~{key}`. The key is `p{id}` (the product id\n * itself) or a SKU of letters and digits, as Twig's `getProductBySkuOrId` reads it.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { Product } from '../../types';\nimport { product } from '../../api/product';\nimport { isMissingResource, notFound, orThrow } from '../../providers/NavigationProvider';\nimport { productKeyOfId, publicProductKeyPath } from '../../router/product-key-urls';\nimport { PRODUCT_SLUG_ROUTE_ID } from '../../router/slug-routes';\nimport { customUrlRedirect, type CustomUrlRedirectOptions } from '../custom-urls';\nimport { isProductId } from './id';\n\n/** `p{id}`: Sluggable's key for a product whose SKU is not letters and digits. */\nconst ID_KEY = /^p(\\d+)$/;\n\n/**\n * The product a key names: by id for `p{id}`, else by SKU. A SKU is read through the query cache,\n * which `resolveProductKeyPage` filled in the same navigation, so it costs one call.\n */\nexport async function productOfKey(\n key: string,\n queryClient?: QueryClient | null\n): Promise<Product> {\n const id = ID_KEY.exec(key)?.[1];\n if (id !== undefined) {\n // Past 18 digits the API answers 417, not 404 (see `./id`).\n if (!isProductId(id)) return notFound();\n return product.findOrThrow(id);\n }\n return orThrow(\n queryClient ? queryClient.ensureQueryData(product.queries.bySku(key)) : product.findBySku(key)\n );\n}\n\n/** The address a SKU-link lookup was made for, so a miss can still be one of the merchant's custom URLs. */\nexport interface ProductKeyAddress {\n /** The router's location: the internal path (`/{name}/p~{key}`) and the query string. */\n location: { pathname: string; searchStr: string };\n /** The language segment an item's page takes (the locale layout's rule). */\n targetLocale?: CustomUrlRedirectOptions['targetLocale'];\n}\n\n/**\n * Run by the locale layout's `beforeLoad`: a SKU that names no product is the not-found page, a\n * 404, as Twig's catch-all answers it, unless the address is one of the merchant's custom URLs.\n * Twig tries those after its SKU route: `/values-in-action` is first SKU `values`.\n *\n * It is resolved here, ahead of the product loader, because a theme may turn that loader's\n * not-found into something else: Raed sends it home with a toast. That suits a product that was\n * deleted, but not `/new-arrivals` or a scanner's path, which only look like a SKU link. The\n * answer stays in the query cache for the loader.\n */\nexport async function resolveProductKeyPage(\n page: { routeId: string; params: Record<string, string | undefined> } | undefined,\n queryClient: QueryClient,\n address?: ProductKeyAddress\n): Promise<void> {\n if (page?.routeId !== PRODUCT_SLUG_ROUTE_ID) return;\n const key = productKeyOfId(page.params.id);\n if (!key || ID_KEY.test(key)) return;\n try {\n await queryClient.ensureQueryData(product.queries.bySku(key));\n } catch (error) {\n if (!isMissingResource(error)) throw error;\n const publicPath = address && publicProductKeyPath(address.location.pathname);\n if (publicPath) {\n await customUrlRedirect(publicPath, address.location.searchStr, {\n queryClient,\n targetLocale: address.targetLocale,\n });\n }\n notFound();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/routes/product/id.ts","../src/routes/product/key.ts"],"names":[],"mappings":";;;;;;;AAWA,IAAM,UAAA,GAAa,YAAA;AAGZ,SAAS,YAAY,KAAA,EAAoC;AAC9D,EAAA,OAAO,UAAA,CAAW,IAAA,CAAK,KAAA,IAAS,EAAE,CAAA;AACpC;;;ACAA,IAAM,MAAA,GAAS,UAAA;AAMf,eAAsB,YAAA,CACpB,KACA,WAAA,EACkB;AAClB,EAAA,MAAM,EAAA,GAAK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A product id: 1 to 18 digits.\n *\n * The API keeps product ids in a signed 64-bit integer. Up to 9223372036854775807 it answers\n * a missing product with 410; one past that, it answers 417, which is neither 404 nor 410, so\n * the page went out as a 500 (`/-/p99999999999999999999999`, which scanners ask for). Every\n * 18-digit number fits; real ids have about 10.\n *\n * `TWIG_PRODUCT_URL` in `../seo-redirects.ts` carries the same cap. Both are literals, because static\n * analysis flags a `RegExp` built from a string.\n */\nconst PRODUCT_ID = /^\\d{1,18}$/;\n\n/** Whether `value` can be a product id the API answers 200 or 410 for. */\nexport function isProductId(value: string | undefined): boolean {\n return PRODUCT_ID.test(value ?? '');\n}\n","/**\n * @fileoverview The product at a SKU-link address (`/{key}-{name}`, see `router/product-key-urls`).\n *\n * The rewrite hands the product route an id of `~{key}`. The key is `p{id}` (the product id\n * itself) or a SKU of letters and digits, as Twig's `getProductBySkuOrId` reads it.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { Product } from '../../types';\nimport { product } from '../../api/product';\nimport { isMissingResource, notFound, orThrow } from '../../providers/NavigationProvider';\nimport { productKeyOfId, publicProductKeyPath } from '../../router/product-key-urls';\nimport { PRODUCT_SLUG_ROUTE_ID } from '../../router/slug-routes';\nimport { customUrlRedirect, type CustomUrlRedirectOptions } from '../custom-urls';\nimport { isProductId } from './id';\n\n/** `p{id}`: Sluggable's key for a product whose SKU is not letters and digits. */\nconst ID_KEY = /^p(\\d+)$/;\n\n/**\n * The product a key names: by id for `p{id}`, else by SKU. A SKU is read through the query cache,\n * which `resolveProductKeyPage` filled in the same navigation, so it costs one call.\n */\nexport async function productOfKey(\n key: string,\n queryClient?: QueryClient | null\n): Promise<Product> {\n const id = ID_KEY.exec(key)?.[1];\n if (id !== undefined) {\n // Past 18 digits the API answers 417, not 404 (see `./id`).\n if (!isProductId(id)) return notFound();\n return product.findOrThrow(id);\n }\n return orThrow(\n queryClient ? queryClient.ensureQueryData(product.queries.bySku(key)) : product.findBySku(key)\n );\n}\n\n/** The address a SKU-link lookup was made for, so a miss can still be one of the merchant's custom URLs. */\nexport interface ProductKeyAddress {\n /** The router's location: the internal path (`/{name}/p~{key}`) and the query string. */\n location: { pathname: string; searchStr: string };\n /** The language segment an item's page takes (the locale layout's rule). */\n targetLocale?: CustomUrlRedirectOptions['targetLocale'];\n}\n\n/**\n * Run by the locale layout's `beforeLoad`: a SKU that names no product is the not-found page, a\n * 404, as Twig's catch-all answers it, unless the address is one of the merchant's custom URLs.\n * Twig tries those after its SKU route: `/values-in-action` is first SKU `values`.\n *\n * It is resolved here, ahead of the product loader, because a theme may turn that loader's\n * not-found into something else: Raed sends it home with a toast. That suits a product that was\n * deleted, but not `/new-arrivals` or a scanner's path, which only look like a SKU link. The\n * answer stays in the query cache for the loader.\n */\nexport async function resolveProductKeyPage(\n page: { routeId: string; params: Record<string, string | undefined> } | undefined,\n queryClient: QueryClient,\n address?: ProductKeyAddress\n): Promise<void> {\n if (page?.routeId !== PRODUCT_SLUG_ROUTE_ID) return;\n const key = productKeyOfId(page.params.id);\n if (!key || ID_KEY.test(key)) return;\n try {\n await queryClient.ensureQueryData(product.queries.bySku(key));\n } catch (error) {\n if (!isMissingResource(error)) throw error;\n const publicPath = address && publicProductKeyPath(address.location.pathname);\n if (publicPath) {\n await customUrlRedirect(publicPath, address.location.searchStr, {\n queryClient,\n targetLocale: address.targetLocale,\n });\n }\n notFound();\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { isNativeApp } from './chunk-BZ2QSBXM.js';
1
+ import { isNativeApp } from './chunk-BO4WTPCA.js';
2
2
  import { useTwilight } from './chunk-3VFOVWOE.js';
3
3
  import { useRef, useState, useEffect } from 'react';
4
4
  import { toast, Toaster as Toaster$1 } from 'sonner';
@@ -137,5 +137,5 @@ function Toaster({
137
137
  }
138
138
 
139
139
  export { Toaster };
140
- //# sourceMappingURL=chunk-2QDPVKV3.js.map
141
- //# sourceMappingURL=chunk-2QDPVKV3.js.map
140
+ //# sourceMappingURL=chunk-ISEQMLS3.js.map
141
+ //#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,EAAE,CAAA;AAEL,EAAA,uBACE,GAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,QAAA;AAAA,MAIA,MAAA,EAAQ,EAAE,GAAA,EAAK,4CAAA,EAA6C;AAAA,MAC5D,YAAA,EAAc,EAAE,GAAA,EAAK,4CAAA,EAA6C;AAAA,MAClE,YAAA,EAAc;AAAA,QACZ,UAAA,EAAY,eAAA;AAAA,QACZ,KAAA,EAAO;AAAA,UACL,UAAA,EAAY;AAAA;AACd,OACF;AAAA,MACA,KAAA,EAAO;AAAA,QACL,UAAA,EAAY;AAAA;AACd;AAAA,GACF;AAEJ","file":"chunk-2QDPVKV3.js","sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { Toaster as SonnerToaster, toast } from 'sonner';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { isNativeApp } from '../../native-app';\nimport type { ToastPosition } from './types';\n\nconst toastClassNames = {\n toast: 'group bg-white border-2 rounded-xl shadow-2xl p-4 font-primary',\n title: 'text-base font-bold',\n description: 'text-sm mt-1 text-gray-600',\n actionButton: 'bg-primary text-white px-3 py-1 rounded',\n cancelButton: 'bg-gray-100 px-3 py-1 rounded',\n success: 'border-green-500 [&_svg]:text-green-500 [&_aside]:text-green-700',\n error: 'border-red-500 [&_svg]:text-red-500 [&_aside]:text-red-700',\n warning: 'border-yellow-500 [&_svg]:text-yellow-500 [&_aside]:text-yellow-700',\n info: 'border-blue-500 [&_svg]:text-blue-500 [&_aside]:text-blue-700',\n loading: 'border-gray-400',\n};\n\ntype RawMessage = string | { title?: string; text?: string; icon?: string };\ntype ToastVariant = 'success' | 'error' | 'warning' | 'info';\n\nconst MOBILE_BREAKPOINT = 768;\nconst NATIVE_ALERT_EVENT = 'ui::alert';\n\nfunction dispatchNativeAlert(type: ToastVariant, message: string, title?: string) {\n const salla = window.salla;\n if (!isNativeApp() || !salla?.event?.dispatch) return false;\n\n salla.event.dispatch(NATIVE_ALERT_EVENT, {\n type,\n message,\n ...(title ? { title } : {}),\n });\n return true;\n}\n\nexport function Toaster({\n mobilePosition = 'bottom-center',\n addToCartToast = true,\n}: {\n mobilePosition?: ToastPosition;\n /** Show the default add-to-cart toast. Themes whose cart badge is the feedback can turn it off. */\n addToCartToast?: boolean;\n}) {\n const { theme } = useTwilight();\n const themeRef = useRef(theme);\n themeRef.current = theme;\n const flashShownRef = useRef(false);\n\n const isRtl = theme.is_rtl;\n const desktopPosition: ToastPosition = isRtl ? 'top-left' : 'top-right';\n\n const [position, setPosition] = useState<ToastPosition>(() => {\n if (typeof window === 'undefined') return desktopPosition;\n return window.innerWidth < MOBILE_BREAKPOINT ? mobilePosition : desktopPosition;\n });\n\n useEffect(() => {\n const handleResize = () => {\n setPosition(window.innerWidth < MOBILE_BREAKPOINT ? mobilePosition : desktopPosition);\n };\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, [desktopPosition, mobilePosition]);\n\n useEffect(() => {\n const salla = window.salla;\n if (!salla) return;\n let active = true;\n\n const handleNotify = (message: RawMessage, type: string, data?: unknown) => {\n const eventData = data as { data?: { googleTags?: { event?: string } } } | undefined;\n const shouldSuppressAddToCartToast =\n (!addToCartToast || themeRef.current.settings?.enable_add_product_toast) &&\n eventData?.data?.googleTags?.event === 'addToCart';\n let title: string;\n let toastType: ToastVariant;\n\n if (typeof message === 'object' && message !== null) {\n title = message.title || message.text || '';\n toastType = (message.icon || type || 'info') as ToastVariant;\n } else {\n title = message;\n toastType = (type || 'info') as ToastVariant;\n }\n\n // Suppress the default addToCart toast when the theme opted out (addToCartToast=false)\n // or renders its own rich toast (enable_add_product_toast) so they don't double up.\n if (shouldSuppressAddToCartToast) {\n return;\n }\n\n if (dispatchNativeAlert(toastType, title)) {\n return;\n }\n\n if (toastType === 'success') {\n toast.success(title, { duration: 3000 });\n } else if (toastType === 'error') {\n toast.error(title, { duration: 3000 });\n } else if (toastType === 'warning') {\n toast.warning(title, { duration: 3000 });\n } else {\n toast.info(title, { duration: 3000 });\n }\n };\n\n // Before the SDK loads `salla` is the head stub, and the SDK's default notifier is alert().\n void (async () => {\n try {\n await salla.onReady?.();\n } catch {\n // onReady() may fail during partial initialization; the toast still beats alert().\n }\n if (active) salla.notify?.setNotifier?.(handleNotify);\n })();\n return () => {\n active = false;\n salla.notify?.setNotifier?.(() => {});\n };\n }, [addToCartToast]);\n\n useEffect(() => {\n if (flashShownRef.current || typeof window === 'undefined') return;\n\n const params = new URLSearchParams(window.location.search);\n const successMsg = params.get('success');\n const dangerMsg = params.get('danger');\n\n if (!successMsg && !dangerMsg) return;\n\n flashShownRef.current = true;\n\n const message = successMsg || dangerMsg || '';\n const toastType = dangerMsg ? 'error' : 'success';\n\n const url = new URL(window.location.href);\n url.searchParams.delete('success');\n url.searchParams.delete('danger');\n window.history.replaceState({}, '', url.toString());\n\n const timer = setTimeout(() => {\n if (dispatchNativeAlert(toastType, message)) return;\n\n if (toastType === 'success') {\n toast.success(message, { duration: 3000 });\n } else {\n toast.error(message, { duration: 3000 });\n }\n }, 100);\n\n return () => clearTimeout(timer);\n }, []);\n\n return (\n <SonnerToaster\n position={position}\n // Keep sonner's default gaps (24px desktop / 16px mobile) but clear the\n // native status bar inset (--app-safe-area-top, set by useSafeAreaInset)\n // so top-positioned toasts aren't covered in the app webview.\n offset={{ top: 'calc(var(--app-safe-area-top, 0px) + 24px)' }}\n mobileOffset={{ top: 'calc(var(--app-safe-area-top, 0px) + 16px)' }}\n toastOptions={{\n classNames: toastClassNames,\n style: {\n fontFamily: 'var(--font-main, inherit)',\n },\n }}\n style={{\n fontFamily: 'var(--font-main, inherit)',\n }}\n />\n );\n}\n\nexport type { ToasterProps } from 'sonner';\n"]}
1
+ {"version":3,"sources":["../src/components/toast/Toaster.tsx"],"names":["SonnerToaster"],"mappings":";;;;;;AAMA,IAAM,eAAA,GAAkB;AAAA,EACtB,KAAA,EAAO,gEAAA;AAAA,EACP,KAAA,EAAO,qBAAA;AAAA,EACP,WAAA,EAAa,4BAAA;AAAA,EACb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A,EAAY,eAAA;AAAA,QACZ,KAAA,EAAO;AAAA,UACL,UAAA,EAAY;AAAA;AACd,OACF;AAAA,MACA,KAAA,EAAO;AAAA,QACL,UAAA,EAAY;AAAA;AACd;AAAA,GACF;AAEJ","file":"chunk-ISEQMLS3.js","sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { Toaster as SonnerToaster, toast } from 'sonner';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { isNativeApp } from '../../native-app';\nimport type { ToastPosition } from './types';\n\nconst toastClassNames = {\n toast: 'group bg-white border-2 rounded-xl shadow-2xl p-4 font-primary',\n title: 'text-base font-bold',\n description: 'text-sm mt-1 text-gray-600',\n actionButton: 'bg-primary text-white px-3 py-1 rounded',\n cancelButton: 'bg-gray-100 px-3 py-1 rounded',\n success: 'border-green-500 [&_svg]:text-green-500 [&_aside]:text-green-700',\n error: 'border-red-500 [&_svg]:text-red-500 [&_aside]:text-red-700',\n warning: 'border-yellow-500 [&_svg]:text-yellow-500 [&_aside]:text-yellow-700',\n info: 'border-blue-500 [&_svg]:text-blue-500 [&_aside]:text-blue-700',\n loading: 'border-gray-400',\n};\n\ntype RawMessage = string | { title?: string; text?: string; icon?: string };\ntype ToastVariant = 'success' | 'error' | 'warning' | 'info';\n\nconst MOBILE_BREAKPOINT = 768;\nconst NATIVE_ALERT_EVENT = 'ui::alert';\n\nfunction dispatchNativeAlert(type: ToastVariant, message: string, title?: string) {\n const salla = window.salla;\n if (!isNativeApp() || !salla?.event?.dispatch) return false;\n\n salla.event.dispatch(NATIVE_ALERT_EVENT, {\n type,\n message,\n ...(title ? { title } : {}),\n });\n return true;\n}\n\nexport function Toaster({\n mobilePosition = 'bottom-center',\n addToCartToast = true,\n}: {\n mobilePosition?: ToastPosition;\n /** Show the default add-to-cart toast. Themes whose cart badge is the feedback can turn it off. */\n addToCartToast?: boolean;\n}) {\n const { theme } = useTwilight();\n const themeRef = useRef(theme);\n themeRef.current = theme;\n const flashShownRef = useRef(false);\n\n const isRtl = theme.is_rtl;\n const desktopPosition: ToastPosition = isRtl ? 'top-left' : 'top-right';\n\n const [position, setPosition] = useState<ToastPosition>(() => {\n if (typeof window === 'undefined') return desktopPosition;\n return window.innerWidth < MOBILE_BREAKPOINT ? mobilePosition : desktopPosition;\n });\n\n useEffect(() => {\n const handleResize = () => {\n setPosition(window.innerWidth < MOBILE_BREAKPOINT ? mobilePosition : desktopPosition);\n };\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, [desktopPosition, mobilePosition]);\n\n useEffect(() => {\n const salla = window.salla;\n if (!salla) return;\n let active = true;\n\n const handleNotify = (message: RawMessage, type: string, data?: unknown) => {\n const eventData = data as { data?: { googleTags?: { event?: string } } } | undefined;\n const shouldSuppressAddToCartToast =\n (!addToCartToast || themeRef.current.settings?.enable_add_product_toast) &&\n eventData?.data?.googleTags?.event === 'addToCart';\n let title: string;\n let toastType: ToastVariant;\n\n if (typeof message === 'object' && message !== null) {\n title = message.title || message.text || '';\n toastType = (message.icon || type || 'info') as ToastVariant;\n } else {\n title = message;\n toastType = (type || 'info') as ToastVariant;\n }\n\n // Suppress the default addToCart toast when the theme opted out (addToCartToast=false)\n // or renders its own rich toast (enable_add_product_toast) so they don't double up.\n if (shouldSuppressAddToCartToast) {\n return;\n }\n\n if (dispatchNativeAlert(toastType, title)) {\n return;\n }\n\n if (toastType === 'success') {\n toast.success(title, { duration: 3000 });\n } else if (toastType === 'error') {\n toast.error(title, { duration: 3000 });\n } else if (toastType === 'warning') {\n toast.warning(title, { duration: 3000 });\n } else {\n toast.info(title, { duration: 3000 });\n }\n };\n\n // Before the SDK loads `salla` is the head stub, and the SDK's default notifier is alert().\n void (async () => {\n try {\n await salla.onReady?.();\n } catch {\n // onReady() may fail during partial initialization; the toast still beats alert().\n }\n if (active) salla.notify?.setNotifier?.(handleNotify);\n })();\n return () => {\n active = false;\n salla.notify?.setNotifier?.(() => {});\n };\n }, [addToCartToast]);\n\n useEffect(() => {\n if (flashShownRef.current || typeof window === 'undefined') return;\n\n const params = new URLSearchParams(window.location.search);\n const successMsg = params.get('success');\n const dangerMsg = params.get('danger');\n\n if (!successMsg && !dangerMsg) return;\n\n flashShownRef.current = true;\n\n const message = successMsg || dangerMsg || '';\n const toastType = dangerMsg ? 'error' : 'success';\n\n const url = new URL(window.location.href);\n url.searchParams.delete('success');\n url.searchParams.delete('danger');\n window.history.replaceState({}, '', url.toString());\n\n const timer = setTimeout(() => {\n if (dispatchNativeAlert(toastType, message)) return;\n\n if (toastType === 'success') {\n toast.success(message, { duration: 3000 });\n } else {\n toast.error(message, { duration: 3000 });\n }\n }, 100);\n\n return () => clearTimeout(timer);\n }, []);\n\n return (\n <SonnerToaster\n position={position}\n // Keep sonner's default gaps (24px desktop / 16px mobile) but clear the\n // native status bar inset (--app-safe-area-top, set by useSafeAreaInset)\n // so top-positioned toasts aren't covered in the app webview.\n offset={{ top: 'calc(var(--app-safe-area-top, 0px) + 24px)' }}\n mobileOffset={{ top: 'calc(var(--app-safe-area-top, 0px) + 16px)' }}\n toastOptions={{\n classNames: toastClassNames,\n style: {\n fontFamily: 'var(--font-main, inherit)',\n },\n }}\n style={{\n fontFamily: 'var(--font-main, inherit)',\n }}\n />\n );\n}\n\nexport type { ToasterProps } from 'sonner';\n"]}
@@ -1,4 +1,4 @@
1
- import { useDate } from './chunk-V4ZRPTFE.js';
1
+ import { useDate } from './chunk-LG3CUJ4V.js';
2
2
  import { useTranslation } from './chunk-TYNZ5B2B.js';
3
3
  import { Image } from './chunk-IVO6YRRK.js';
4
4
  import { Link } from './chunk-3GFD7WTJ.js';
@@ -61,5 +61,5 @@ function BlogListLayout({
61
61
  }
62
62
 
63
63
  export { BlogArticleCard, BlogListLayout };
64
- //# sourceMappingURL=chunk-YZVWVS3N.js.map
65
- //# sourceMappingURL=chunk-YZVWVS3N.js.map
64
+ //# sourceMappingURL=chunk-JMPVEH7U.js.map
65
+ //# sourceMappingURL=chunk-JMPVEH7U.js.map
@@ -1 +1 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AU,wCAAA,EAA0C,kBAAQ,WAAA,EAAY;AAAA,KAAA,EAC7E;AAAA,GAAA,EACF,CAAA;AAEJ;AAEO,SAAS,cAAA,CAAe;AAAA,EAC7B,UAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,uCAAA,EACb,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,yBAAsB,UAAA,EAAwB,CAAA;AAAA,oBAC/C,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,4BAAA,EAA8B,QAAA,EAAS;AAAA,GAAA,EACxD,CAAA;AAEJ","file":"chunk-YZVWVS3N.js","sourcesContent":["import type { ReactNode } from 'react';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { useDate } from '../../hooks';\nimport { Image, Link } from '../../components/common';\nimport type { BlogCategory, ArticleSummary } from './types';\n\nexport function BlogCategoriesSidebar({ categories }: { categories: BlogCategory[] }) {\n const { t } = useTranslation();\n\n if (!categories.length) return null;\n\n return (\n <nav aria-label=\"Sidebar\" className=\"hidden lg:block lg:sticky shrink-0 top-24 col-span-2\">\n <h2 className=\"font-bold mb-3\">{t('pages.blog_categories.categories')}</h2>\n <ul>\n {categories.map((category) => (\n <li key={category.id} className={category.is_current ? 'text-primary' : ''}>\n <Link className=\"py-3 block text-sm hover:text-primary\" to={category.url}>\n {category.name}\n </Link>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\nexport function BlogArticleCard({\n article,\n showAuthor = false,\n}: {\n article: ArticleSummary;\n showAuthor?: boolean;\n}) {\n const { format: formatDate } = useDate();\n\n return (\n <div className=\"list-block post-entry relative h-full transition-shadow duration-500 bg-white hover:shadow-default rounded-lg justify-around overflow-hidden flex flex-col\">\n <Link\n to={article.url}\n className=\"post-entry__image relative overflow-hidden hover:opacity-90 w-full h-56 bg-border-color flex items-center justify-center\"\n >\n {article.image && (\n <Image\n className=\"h-full w-full object-cover\"\n src={article.image}\n alt={article.name}\n aspectRatio=\"16/9\"\n />\n )}\n </Link>\n <div className=\"flex-1 px-5 pt-5 pb-7\">\n <div className=\"mb-2.5 text-gray-500 rounded-md inline-flex text-sm rtl:space-x-reverse space-x-5\">\n <div className=\"flex items-center\">\n <i className=\"sicon-calendar-date rtl:ml-1 ltr:mr-1\"></i>\n <span>{formatDate(article.created_at)}</span>\n </div>\n {showAuthor && article.author && (\n <Link to={article.author.url} className=\"flex items-center hover:text-dark\">\n <i className=\"sicon-user rtl:ml-1 ltr:mr-1\"></i>\n <span>{article.author.name}</span>\n </Link>\n )}\n </div>\n <h3 className=\"post-entry__title text-sm font-bold text-gray-800 leading-6 mb-2.5\">\n <Link to={article.url}>{article.name}</Link>\n </h3>\n <p className=\"text-sm text-gray-500 leading-6 mb-2.5\">{article.description}</p>\n </div>\n </div>\n );\n}\n\nexport function BlogListLayout({\n categories,\n children,\n}: {\n categories: BlogCategory[];\n children: ReactNode;\n}) {\n return (\n <div className=\"grid grid-cols-1 lg:grid-cols-8 gap-8\">\n <BlogCategoriesSidebar categories={categories} />\n <div className=\"main-content lg:col-span-6\">{children}</div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/routes/blog/components.tsx"],"names":[],"mappings":";;;;;;AAMO,SAAS,qBAAA,CAAsB,EAAE,UAAA,EAAW,EAAmC;AACpF,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,cAAA,EAAe;AAE7B,EAAA,IAAI,CAAC,UAAA,CAAW,MAAA,EAAQ,OAAO,IAAA;AAE/B,EAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,YAAA,EAAW,SAAA,EAAU,WAAU,sDAAA,EAClC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,IAAA,EAAA,EAAG,SAAA,EAAU,gBAAA,EAAkB,QAAA,EAAA,CAAA,CAAE,kCAAkC,CAAA,EAAE,CAAA;AAAA,oBACtE,GAAA,CAAC,IAAA,EAAA,EACE,QAAA,EAAA,UAAA,CAAW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,EAAA,EAAM,QAAA,EAAA,UAAA,CAAW,OAAA,CAAQ,UAAU,CAAA,EAAE;AAAA,SAAA,EACxC,CAAA;AAAA,QACC,UAAA,IAAc,OAAA,CAAQ,MAAA,oBACrB,IAAA,CAAC,IAAA,EAAA,EAAK,IAAI,OAAA,CAAQ,MAAA,CAAO,GAAA,EAAK,SAAA,EAAU,mCAAA,EACtC,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,GAAA,EAAA,EAAE,WAAU,8BAAA,EAA+B,CAAA;AAAA,0BAC5C,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,OAAA,CAAQ,MAAA,CAAO,IAAA,EAAK;AAAA,SAAA,EAC7B;AAAA,OAAA,EAEJ,CAAA;AAAA,sBACA,GAAA,CAAC,IAAA,EAAA,EAAG,SAAA,EAAU,oEAAA,EACZ,QAAA,kBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,EAAA,EAAI,OAAA,CAAQ,GAAA,EAAM,QAAA,EAAA,OAAA,CAAQ,IAAA,EAAK,CAAA,EACvC,CAAA;AAAA,sBACA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,wCAAA,EAA0C,kBAAQ,WAAA,EAAY;AAAA,KAAA,EAC7E;AAAA,GAAA,EACF,CAAA;AAEJ;AAEO,SAAS,cAAA,CAAe;AAAA,EAC7B,UAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,uCAAA,EACb,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,yBAAsB,UAAA,EAAwB,CAAA;AAAA,oBAC/C,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,4BAAA,EAA8B,QAAA,EAAS;AAAA,GAAA,EACxD,CAAA;AAEJ","file":"chunk-JMPVEH7U.js","sourcesContent":["import type { ReactNode } from 'react';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { useDate } from '../../hooks';\nimport { Image, Link } from '../../components/common';\nimport type { BlogCategory, ArticleSummary } from './types';\n\nexport function BlogCategoriesSidebar({ categories }: { categories: BlogCategory[] }) {\n const { t } = useTranslation();\n\n if (!categories.length) return null;\n\n return (\n <nav aria-label=\"Sidebar\" className=\"hidden lg:block lg:sticky shrink-0 top-24 col-span-2\">\n <h2 className=\"font-bold mb-3\">{t('pages.blog_categories.categories')}</h2>\n <ul>\n {categories.map((category) => (\n <li key={category.id} className={category.is_current ? 'text-primary' : ''}>\n <Link className=\"py-3 block text-sm hover:text-primary\" to={category.url}>\n {category.name}\n </Link>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\nexport function BlogArticleCard({\n article,\n showAuthor = false,\n}: {\n article: ArticleSummary;\n showAuthor?: boolean;\n}) {\n const { format: formatDate } = useDate();\n\n return (\n <div className=\"list-block post-entry relative h-full transition-shadow duration-500 bg-white hover:shadow-default rounded-lg justify-around overflow-hidden flex flex-col\">\n <Link\n to={article.url}\n className=\"post-entry__image relative overflow-hidden hover:opacity-90 w-full h-56 bg-border-color flex items-center justify-center\"\n >\n {article.image && (\n <Image\n className=\"h-full w-full object-cover\"\n src={article.image}\n alt={article.name}\n aspectRatio=\"16/9\"\n />\n )}\n </Link>\n <div className=\"flex-1 px-5 pt-5 pb-7\">\n <div className=\"mb-2.5 text-gray-500 rounded-md inline-flex text-sm rtl:space-x-reverse space-x-5\">\n <div className=\"flex items-center\">\n <i className=\"sicon-calendar-date rtl:ml-1 ltr:mr-1\"></i>\n <span>{formatDate(article.created_at)}</span>\n </div>\n {showAuthor && article.author && (\n <Link to={article.author.url} className=\"flex items-center hover:text-dark\">\n <i className=\"sicon-user rtl:ml-1 ltr:mr-1\"></i>\n <span>{article.author.name}</span>\n </Link>\n )}\n </div>\n <h3 className=\"post-entry__title text-sm font-bold text-gray-800 leading-6 mb-2.5\">\n <Link to={article.url}>{article.name}</Link>\n </h3>\n <p className=\"text-sm text-gray-500 leading-6 mb-2.5\">{article.description}</p>\n </div>\n </div>\n );\n}\n\nexport function BlogListLayout({\n categories,\n children,\n}: {\n categories: BlogCategory[];\n children: ReactNode;\n}) {\n return (\n <div className=\"grid grid-cols-1 lg:grid-cols-8 gap-8\">\n <BlogCategoriesSidebar categories={categories} />\n <div className=\"main-content lg:col-span-6\">{children}</div>\n </div>\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow, orUnauthorized } from './chunk-KUROVEJP.js';
2
- import { api } from './chunk-LC3M4HW7.js';
1
+ import { orThrow, orUnauthorized } from './chunk-W3EYJOD3.js';
2
+ import { api } from './chunk-EDSZX3QE.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  async function twilightShape(path) {
@@ -89,5 +89,5 @@ var order = {
89
89
  };
90
90
 
91
91
  export { order };
92
- //# sourceMappingURL=chunk-6KARAWOF.js.map
93
- //# sourceMappingURL=chunk-6KARAWOF.js.map
92
+ //# sourceMappingURL=chunk-KEB4BTPE.js.map
93
+ //# sourceMappingURL=chunk-KEB4BTPE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/order.ts"],"names":[],"mappings":";;;;AAqDA,eAAe,cAAc,IAAA,EAAsC;AACjE,EAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CACpB,GAAA,CAAI,IAAA,EAAM;AAAA,IACT,KAAA,EAAO;AAAA;AAAA,MAEL,aAAA,EAAe,CAAC,CAAC,EAAE,OAAA,OAAc,OAAA,CAAQ,OAAA,CAAQ,MAAA,CAAO,cAAc,CAAC;AAAA;AACzE,GACD,EACA,IAAA,EAA8B;AACjC,EAAA,OAAO,QAAA,CAAS,IAAA;AAClB;AAEO,IAAM,KAAA,GAAQ;AAAA,EACnB,IAAA,EAAM,OAAO,MAAA,KAA2D;AACtE,IAAA,MAAM;AAAA,MACJ,IAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA,EAAiB,cAAA;AAAA,MACjB,UAAA,EAAY,SAAA;AAAA,MACZ;AAAA,KACF,GAAI,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,QAAA,EAAU,CAAC,QAAA,EAAU,MAAA,EAAQ,MAAM,CAAA;AAAA,MACnC,OAAA,EAAS,CAAC,EAAE,MAAA,EAAO,KAAM,KAAA,CAAM,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,MAAA,EAAQ;AAAA,KAC1D,CAAA;AAAA,IACH,IAAA,EAAM,CAAC,EAAA,KACL,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,QAAA,EAAU,EAAE,CAAA;AAAA,MACjC,OAAA,EAAS,MAAM,KAAA,CAAM,IAAA,CAAK,EAAE;AAAA,KAC7B,CAAA;AAAA,IACH,SAAA,EAAW,CAAC,OAAA,KACV,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,WAAA,EAAa,OAAO,CAAA;AAAA,MACzC,OAAA,EAAS,MAAM,KAAA,CAAM,SAAA,CAAU,OAAO;AAAA,KACvC,CAAA;AAAA,IACH,OAAA,EAAS,CAAC,OAAA,KACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,SAAA,EAAW,OAAO,CAAA;AAAA,MACvC,OAAA,EAAS,MAAM,KAAA,CAAM,OAAA,CAAQ,OAAO;AAAA,KACrC,CAAA;AAAA,IACH,QAAA,EAAU,CAAC,OAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,UAAA,EAAY,OAAO,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,OAAO;AAAA,KACtC;AAAA;AAEP","file":"chunk-6KARAWOF.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type {\n Order,\n OrderListItem,\n OrderShipmentItem,\n OrderRatingItem,\n} from '../routes/account/types';\nimport type { Pagination } from './types';\nimport { orThrow, orUnauthorized } from '../providers/NavigationProvider';\n\nexport interface OrderDetailResponse {\n order: Order;\n}\n\n/**\n * The order in the shape the Twilight web components read (`salla-order-details`,\n * `salla-order-totals-card`) and the Twig themes render: the API answers `orders/{id}` this\n * way when the request does not say it comes from a React theme (`s-theme-type`).\n */\nexport interface TwilightOrder {\n items: Array<{\n name: string;\n quantity: number;\n product?: { id: number; url?: string; type?: string; image?: { url?: string } };\n options?: unknown[];\n }>;\n [key: string]: unknown;\n}\n\nexport interface CheckoutThankYouData {\n thank_you_title?: string;\n messages?: string[];\n share_message?: string;\n short_share_message?: string;\n}\n\nexport interface OrdersListResponse {\n data: OrderListItem[];\n cursor?: Pagination;\n}\n\nexport interface OrdersListParams {\n page?: number;\n cursor?: string | null;\n status?: string;\n feedback_status?: string;\n /** When set, the list payload includes each order's `items[]` (`with_items=1`). */\n with_items?: boolean | number;\n signal?: AbortSignal;\n}\n\n/** Reads an order path without `s-theme-type`, so the API answers in the Twilight components' shape. */\nasync function twilightShape(path: string): Promise<TwilightOrder> {\n const response = await api\n .get(path, {\n hooks: {\n // Runs after the client's own hook, which marks every request as from a React theme.\n beforeRequest: [({ request }) => request.headers.delete('s-theme-type')],\n },\n })\n .json<{ data: TwilightOrder }>();\n return response.data;\n}\n\nexport const order = {\n list: async (params?: OrdersListParams): Promise<OrdersListResponse> => {\n const {\n page,\n cursor,\n status,\n feedback_status: feedbackStatus,\n with_items: withItems,\n signal,\n } = params ?? {};\n\n const searchParams = new URLSearchParams();\n if (page !== undefined) searchParams.set('page', String(page));\n if (cursor) searchParams.set('cursor', cursor);\n if (status) searchParams.set('status', status);\n if (feedbackStatus) searchParams.set('feedback_status', feedbackStatus);\n if (withItems) searchParams.set('with_items', '1');\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`orders?${searchParams.toString()}`, options as any)\n .json<{ data: OrderListItem[] | null; cursor?: Pagination }>();\n\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n find: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n findForComponents: async (id: string): Promise<TwilightOrder> => twilightShape(`orders/${id}`),\n\n /**\n * The order the thank-you page renders, `orders/{id}/thank-you`: the same payload as `find`, but a guest\n * (no customer token) may read it for the short window after checkout the Twig thank-you page allows.\n */\n findForThankYou: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}/thank-you`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n /** `findForThankYou` in the Twilight components' shape, as `findForComponents` is to `find`. */\n findForThankYouComponents: async (id: string): Promise<TwilightOrder> =>\n twilightShape(`orders/${id}/thank-you`),\n\n shipments: async (orderId: string): Promise<OrderShipmentItem[]> => {\n const response = await api\n .get(`orders/${orderId}/shipments`)\n .json<{ data: OrderShipmentItem[] }>();\n return response.data ?? [];\n },\n\n ratings: async (orderId: string): Promise<OrderRatingItem[]> => {\n const response = await api.get(`orders/${orderId}/ratings`).json<{ data: OrderRatingItem[] }>();\n return response.data ?? [];\n },\n\n findOrThrow: (id: string): Promise<OrderDetailResponse> =>\n orThrow(orUnauthorized(order.find(id))),\n\n thankYou: async (orderId: string): Promise<CheckoutThankYouData> => {\n const { data } = await api\n .get(`checkout/thank-you/${orderId}`)\n .json<{ data: CheckoutThankYouData }>();\n return data;\n },\n\n thankYouOrThrow: (orderId: string): Promise<CheckoutThankYouData> =>\n orThrow(order.thankYou(orderId)),\n\n queries: {\n list: (params?: Omit<OrdersListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['orders', 'list', params],\n queryFn: ({ signal }) => order.list({ ...params, signal }),\n }),\n find: (id: string) =>\n queryOptions({\n queryKey: ['orders', 'detail', id],\n queryFn: () => order.find(id),\n }),\n shipments: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'shipments', orderId],\n queryFn: () => order.shipments(orderId),\n }),\n ratings: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'ratings', orderId],\n queryFn: () => order.ratings(orderId),\n }),\n thankYou: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'thank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IACH,OAAA,EAAS,CAAC,OAAA,KACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,SAAA,EAAW,OAAO,CAAA;AAAA,MACvC,OAAA,EAAS,MAAM,KAAA,CAAM,OAAA,CAAQ,OAAO;AAAA,KACrC,CAAA;AAAA,IACH,QAAA,EAAU,CAAC,OAAA,KACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,QAAA,EAAU,UAAA,EAAY,OAAO,CAAA;AAAA,MACxC,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,CAAS,OAAO;AAAA,KACtC;AAAA;AAEP","file":"chunk-KEB4BTPE.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type {\n Order,\n OrderListItem,\n OrderShipmentItem,\n OrderRatingItem,\n} from '../routes/account/types';\nimport type { Pagination } from './types';\nimport { orThrow, orUnauthorized } from '../providers/NavigationProvider';\n\nexport interface OrderDetailResponse {\n order: Order;\n}\n\n/**\n * The order in the shape the Twilight web components read (`salla-order-details`,\n * `salla-order-totals-card`) and the Twig themes render: the API answers `orders/{id}` this\n * way when the request does not say it comes from a React theme (`s-theme-type`).\n */\nexport interface TwilightOrder {\n items: Array<{\n name: string;\n quantity: number;\n product?: { id: number; url?: string; type?: string; image?: { url?: string } };\n options?: unknown[];\n }>;\n [key: string]: unknown;\n}\n\nexport interface CheckoutThankYouData {\n thank_you_title?: string;\n messages?: string[];\n share_message?: string;\n short_share_message?: string;\n}\n\nexport interface OrdersListResponse {\n data: OrderListItem[];\n cursor?: Pagination;\n}\n\nexport interface OrdersListParams {\n page?: number;\n cursor?: string | null;\n status?: string;\n feedback_status?: string;\n /** When set, the list payload includes each order's `items[]` (`with_items=1`). */\n with_items?: boolean | number;\n signal?: AbortSignal;\n}\n\n/** Reads an order path without `s-theme-type`, so the API answers in the Twilight components' shape. */\nasync function twilightShape(path: string): Promise<TwilightOrder> {\n const response = await api\n .get(path, {\n hooks: {\n // Runs after the client's own hook, which marks every request as from a React theme.\n beforeRequest: [({ request }) => request.headers.delete('s-theme-type')],\n },\n })\n .json<{ data: TwilightOrder }>();\n return response.data;\n}\n\nexport const order = {\n list: async (params?: OrdersListParams): Promise<OrdersListResponse> => {\n const {\n page,\n cursor,\n status,\n feedback_status: feedbackStatus,\n with_items: withItems,\n signal,\n } = params ?? {};\n\n const searchParams = new URLSearchParams();\n if (page !== undefined) searchParams.set('page', String(page));\n if (cursor) searchParams.set('cursor', cursor);\n if (status) searchParams.set('status', status);\n if (feedbackStatus) searchParams.set('feedback_status', feedbackStatus);\n if (withItems) searchParams.set('with_items', '1');\n\n const options: Record<string, unknown> = {};\n if (signal) options.signal = signal;\n\n const response = await api\n .get(`orders?${searchParams.toString()}`, options as any)\n .json<{ data: OrderListItem[] | null; cursor?: Pagination }>();\n\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n find: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n findForComponents: async (id: string): Promise<TwilightOrder> => twilightShape(`orders/${id}`),\n\n /**\n * The order the thank-you page renders, `orders/{id}/thank-you`: the same payload as `find`, but a guest\n * (no customer token) may read it for the short window after checkout the Twig thank-you page allows.\n */\n findForThankYou: async (id: string): Promise<OrderDetailResponse> => {\n const response = await api.get(`orders/${id}/thank-you`).json<{ data: Order }>();\n\n return { order: response.data };\n },\n\n /** `findForThankYou` in the Twilight components' shape, as `findForComponents` is to `find`. */\n findForThankYouComponents: async (id: string): Promise<TwilightOrder> =>\n twilightShape(`orders/${id}/thank-you`),\n\n shipments: async (orderId: string): Promise<OrderShipmentItem[]> => {\n const response = await api\n .get(`orders/${orderId}/shipments`)\n .json<{ data: OrderShipmentItem[] }>();\n return response.data ?? [];\n },\n\n ratings: async (orderId: string): Promise<OrderRatingItem[]> => {\n const response = await api.get(`orders/${orderId}/ratings`).json<{ data: OrderRatingItem[] }>();\n return response.data ?? [];\n },\n\n findOrThrow: (id: string): Promise<OrderDetailResponse> =>\n orThrow(orUnauthorized(order.find(id))),\n\n thankYou: async (orderId: string): Promise<CheckoutThankYouData> => {\n const { data } = await api\n .get(`checkout/thank-you/${orderId}`)\n .json<{ data: CheckoutThankYouData }>();\n return data;\n },\n\n thankYouOrThrow: (orderId: string): Promise<CheckoutThankYouData> =>\n orThrow(order.thankYou(orderId)),\n\n queries: {\n list: (params?: Omit<OrdersListParams, 'signal'>) =>\n queryOptions({\n queryKey: ['orders', 'list', params],\n queryFn: ({ signal }) => order.list({ ...params, signal }),\n }),\n find: (id: string) =>\n queryOptions({\n queryKey: ['orders', 'detail', id],\n queryFn: () => order.find(id),\n }),\n shipments: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'shipments', orderId],\n queryFn: () => order.shipments(orderId),\n }),\n ratings: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'ratings', orderId],\n queryFn: () => order.ratings(orderId),\n }),\n thankYou: (orderId: string) =>\n queryOptions({\n queryKey: ['orders', 'thankYou', orderId],\n queryFn: () => order.thankYou(orderId),\n }),\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { filesCdn, cdn } from './chunk-LC3M4HW7.js';
1
+ import { filesCdn, cdn } from './chunk-EDSZX3QE.js';
2
2
  import { storeTranslationsQueryKey, translationsQueryKey, composeMessages, isPlainObject } from './chunk-MWUAHDQL.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-DIYLHIAT.js.map
130
- //# sourceMappingURL=chunk-DIYLHIAT.js.map
129
+ //# sourceMappingURL=chunk-KQSI3TTP.js.map
130
+ //# sourceMappingURL=chunk-KQSI3TTP.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/translations.ts"],"names":[],"mappings":";;;;AAiEA,IAAM,kBAAA,GAAqB,sBAA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,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-DIYLHIAT.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
+ {"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,KAA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AA,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-KQSI3TTP.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,6 +1,6 @@
1
- import { customUrl } from './chunk-VIUK32MB.js';
2
- import { store } from './chunk-4IISS5KO.js';
3
- import { redirect } from './chunk-KUROVEJP.js';
1
+ import { customUrl } from './chunk-RWGRWXIQ.js';
2
+ import { store } from './chunk-ORC5ETTR.js';
3
+ import { redirect } from './chunk-W3EYJOD3.js';
4
4
  import { isLocale } from './chunk-T72DAX7R.js';
5
5
 
6
6
  // src/routes/custom-urls.ts
@@ -87,5 +87,5 @@ async function customUrlRedirect(pathname, search, options) {
87
87
  }
88
88
 
89
89
  export { customUrlKey, customUrlPagePath, customUrlRedirect, storePathOf, withAddressQuery };
90
- //# sourceMappingURL=chunk-7CZXUN6C.js.map
91
- //# sourceMappingURL=chunk-7CZXUN6C.js.map
90
+ //# sourceMappingURL=chunk-L7UJ77YE.js.map
91
+ //# sourceMappingURL=chunk-L7UJ77YE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/custom-urls.ts"],"names":[],"mappings":";;;;;;AAiCO,SAAS,aAAa,QAAA,EAA2D;AACtF,EAAA,MAAM,WAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AACnD,EAAA,MAAM,MAAA,GAAS,SAAS,QAAA,CAAS,CAAC,CAAC,CAAA,GAA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AA,CAAA,GAAK,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,EAAG;AAAA,MAC/E,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AAC/B,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,IAAA,EAAM,MAAM,CAAA,EAAG,EAAE,UAAA,EAAY,GAAA,EAAK,cAAA,EAAgB,IAAA,EAAM,CAAA;AAAA,EAC1F;AACF","file":"chunk-7CZXUN6C.js","sourcesContent":["/**\n * @fileoverview A merchant's custom URLs (Dashboard → SEO → custom links) on a React storefront.\n *\n * Twig answers them in the Store's catch-all, its last fallback: after every route, and after the\n * product lookups by short code (`/{code}`) and by SKU (`/{sku}-{name}`). A React theme has no\n * catch-all, so the locale layout's `beforeLoad` asks the API (Store-Module#1798, the catch-all's\n * own lookup) at the same two points:\n * - an address no page answers (`twigUrlRedirect`, after the short code);\n * - a SKU-link address whose SKU names no product (`resolveProductKeyPage`).\n *\n * It asks only on a store that lists `custom-urls` in `store.features` (the plan has it, and the\n * store has an active one), so an address no page answers costs a store without one nothing. The answer is a 302, as Twig's, because the\n * merchant can point the URL elsewhere at any time.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport { customUrl, type CustomUrlTarget } from '../api/custom-url';\nimport { store } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport { redirect } from '../providers/NavigationProvider';\nimport { isLocale } from '../providers/locale-constants';\n\nexport interface CustomUrlRedirectOptions {\n /** The request's query client: the settings are in it already, and a lookup is shared. */\n queryClient: QueryClient;\n /** The language segment an item's page takes, given the one the address had (the locale layout's rule). */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n}\n\n/**\n * The path a custom URL is saved under, for an address the router hands over (the store base\n * already off): without a language segment, which the Store strips before its catch-all, and\n * without the slashes around it. `null` for a home page.\n */\nexport function customUrlKey(pathname: string): { key: string; locale?: string } | null {\n const segments = pathname.split('/').filter(Boolean);\n const locale = isLocale(segments[0]) ? segments.shift() : undefined;\n if (!segments.length) return null;\n return { key: segments.join('/'), locale };\n}\n\n/**\n * The path an item's URL has under the store root, without its language segment:\n * `https://salla.sa/dev-x/en/shoes/p1` with store URL `https://salla.sa/dev-x/` is `/shoes/p1`.\n * `null` when the URL is not on the store (another host, or outside the store's segment).\n */\nexport function storePathOf(url: string, storeUrl: string | undefined): string | null {\n let item: URL;\n let root: URL;\n try {\n item = new URL(url);\n root = new URL(storeUrl ?? '');\n } catch {\n return null;\n }\n if (item.host !== root.host) return null;\n const rootPath = root.pathname.replace(/\\/+$/, '');\n if (rootPath && item.pathname !== rootPath && !item.pathname.startsWith(`${rootPath}/`)) {\n return null;\n }\n const segments = item.pathname.slice(rootPath.length).split('/').filter(Boolean);\n if (isLocale(segments[0])) segments.shift();\n return `/${segments.join('/')}`;\n}\n\n/** Twig's brand address, `/{slug}/brand-{id}`: the engine's brand page is `/brands/{id}`. */\nconst TWIG_BRAND_PATH = /^\\/[^/]+\\/brand-(\\d+)$/;\n\n/**\n * The engine's page for the item a custom URL names, under the store root and with no language,\n * or `null` for a `custom` row or an item URL that is not on the store. The item's own address\n * is used: the engine serves Twig's product, category, tag and page addresses (and redirects a\n * hash URL itself), and only a brand is sent straight to its page, a hop shorter.\n */\nexport function customUrlPagePath(\n target: CustomUrlTarget,\n storeUrl: string | undefined\n): string | null {\n if (target.type === 'custom') return null;\n const path = storePathOf(target.url, storeUrl);\n if (!path) return null;\n const brand = TWIG_BRAND_PATH.exec(path);\n return brand ? `/brands/${brand[1]}` : path;\n}\n\n/**\n * `target` with the address's query string on it, as the Store's catch-all keeps it (an ad's\n * `utm_*`): after the target's own query, and before its fragment.\n */\nexport function withAddressQuery(target: string, search: string): string {\n const query = search.replace(/^\\?/, '');\n if (!query) return target;\n const hashAt = target.indexOf('#');\n const [head, fragment] =\n hashAt < 0 ? [target, ''] : [target.slice(0, hashAt), target.slice(hashAt)];\n return `${head}${head.includes('?') ? '&' : '?'}${query}${fragment}`;\n}\n\n/** A URL when it is http(s): the Dashboard asks for a URL, and the router refuses any other scheme. */\nfunction httpUrl(url: string): string | null {\n try {\n const { protocol } = new URL(url);\n return protocol === 'http:' || protocol === 'https:' ? url : null;\n } catch {\n return null;\n }\n}\n\n/** The settings, when they list `custom-urls` in the store's features; else `null`. */\nasync function settingsWithCustomUrls(queryClient: QueryClient): Promise<StoreContext | null> {\n try {\n const settings = await queryClient.ensureQueryData(store.queries.settings());\n return settings?.store?.features?.includes('custom-urls') ? settings : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The custom URL saved for `key`, or `undefined`. Any failure counts as none: an address no page\n * answers is also every scanner's, and an API error must leave it the 404 it was, not a 500.\n */\nasync function lookup(key: string, queryClient: QueryClient): Promise<CustomUrlTarget | undefined> {\n try {\n return await queryClient.ensureQueryData(customUrl.queries.resolve(key));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sends the visitor where the custom URL saved for `pathname` leads, with the address's query, by\n * a 302; returns when there is none, and the caller answers as it would have. An item on the store\n * is reached in one hop, in the language the locale layout would give it. A `custom` row's URL,\n * or an item URL on another site, is a full page load.\n */\nexport async function customUrlRedirect(\n pathname: string,\n search: string,\n options: CustomUrlRedirectOptions\n): Promise<void> {\n const address = customUrlKey(pathname);\n if (!address) return;\n const settings = await settingsWithCustomUrls(options.queryClient);\n if (!settings) return;\n const target = await lookup(address.key, options.queryClient);\n if (!target) return;\n\n const path = customUrlPagePath(target, settings.store?.url);\n if (path) {\n const locale = options.targetLocale\n ? await options.targetLocale(address.locale)\n : address.locale;\n throw redirect(withAddressQuery(`${locale ? `/${locale}` : ''}${path}`, search), {\n statusCode: 302,\n });\n }\n const href = httpUrl(target.url);\n if (href) {\n throw redirect(withAddressQuery(href, search), { statusCode: 302, reloadDocument: true });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/routes/custom-urls.ts"],"names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,MAAA,GAAS,QAAQ,YAAA,GACnB,MAAM,QAAQ,YAAA,CAAa,OAAA,CAAQ,MAAM,CAAA,GACzC,OAAA,CAAQ,MAAA;AACZ,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,CAAA,EAAG,MAAA,GAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,GAAK,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,EAAG;AAAA,MAC/E,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AAC/B,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,MAAM,QAAA,CAAS,gBAAA,CAAiB,IAAA,EAAM,MAAM,CAAA,EAAG,EAAE,UAAA,EAAY,GAAA,EAAK,cAAA,EAAgB,IAAA,EAAM,CAAA;AAAA,EAC1F;AACF","file":"chunk-L7UJ77YE.js","sourcesContent":["/**\n * @fileoverview A merchant's custom URLs (Dashboard → SEO → custom links) on a React storefront.\n *\n * Twig answers them in the Store's catch-all, its last fallback: after every route, and after the\n * product lookups by short code (`/{code}`) and by SKU (`/{sku}-{name}`). A React theme has no\n * catch-all, so the locale layout's `beforeLoad` asks the API (Store-Module#1798, the catch-all's\n * own lookup) at the same two points:\n * - an address no page answers (`twigUrlRedirect`, after the short code);\n * - a SKU-link address whose SKU names no product (`resolveProductKeyPage`).\n *\n * It asks only on a store that lists `custom-urls` in `store.features` (the plan has it, and the\n * store has an active one), so an address no page answers costs a store without one nothing. The answer is a 302, as Twig's, because the\n * merchant can point the URL elsewhere at any time.\n */\nimport type { QueryClient } from '@tanstack/react-query';\nimport { customUrl, type CustomUrlTarget } from '../api/custom-url';\nimport { store } from '../api/store';\nimport type { StoreContext } from '../api/store';\nimport { redirect } from '../providers/NavigationProvider';\nimport { isLocale } from '../providers/locale-constants';\n\nexport interface CustomUrlRedirectOptions {\n /** The request's query client: the settings are in it already, and a lookup is shared. */\n queryClient: QueryClient;\n /** The language segment an item's page takes, given the one the address had (the locale layout's rule). */\n targetLocale?: (addressLocale: string | undefined) => Promise<string | undefined>;\n}\n\n/**\n * The path a custom URL is saved under, for an address the router hands over (the store base\n * already off): without a language segment, which the Store strips before its catch-all, and\n * without the slashes around it. `null` for a home page.\n */\nexport function customUrlKey(pathname: string): { key: string; locale?: string } | null {\n const segments = pathname.split('/').filter(Boolean);\n const locale = isLocale(segments[0]) ? segments.shift() : undefined;\n if (!segments.length) return null;\n return { key: segments.join('/'), locale };\n}\n\n/**\n * The path an item's URL has under the store root, without its language segment:\n * `https://salla.sa/dev-x/en/shoes/p1` with store URL `https://salla.sa/dev-x/` is `/shoes/p1`.\n * `null` when the URL is not on the store (another host, or outside the store's segment).\n */\nexport function storePathOf(url: string, storeUrl: string | undefined): string | null {\n let item: URL;\n let root: URL;\n try {\n item = new URL(url);\n root = new URL(storeUrl ?? '');\n } catch {\n return null;\n }\n if (item.host !== root.host) return null;\n const rootPath = root.pathname.replace(/\\/+$/, '');\n if (rootPath && item.pathname !== rootPath && !item.pathname.startsWith(`${rootPath}/`)) {\n return null;\n }\n const segments = item.pathname.slice(rootPath.length).split('/').filter(Boolean);\n if (isLocale(segments[0])) segments.shift();\n return `/${segments.join('/')}`;\n}\n\n/** Twig's brand address, `/{slug}/brand-{id}`: the engine's brand page is `/brands/{id}`. */\nconst TWIG_BRAND_PATH = /^\\/[^/]+\\/brand-(\\d+)$/;\n\n/**\n * The engine's page for the item a custom URL names, under the store root and with no language,\n * or `null` for a `custom` row or an item URL that is not on the store. The item's own address\n * is used: the engine serves Twig's product, category, tag and page addresses (and redirects a\n * hash URL itself), and only a brand is sent straight to its page, a hop shorter.\n */\nexport function customUrlPagePath(\n target: CustomUrlTarget,\n storeUrl: string | undefined\n): string | null {\n if (target.type === 'custom') return null;\n const path = storePathOf(target.url, storeUrl);\n if (!path) return null;\n const brand = TWIG_BRAND_PATH.exec(path);\n return brand ? `/brands/${brand[1]}` : path;\n}\n\n/**\n * `target` with the address's query string on it, as the Store's catch-all keeps it (an ad's\n * `utm_*`): after the target's own query, and before its fragment.\n */\nexport function withAddressQuery(target: string, search: string): string {\n const query = search.replace(/^\\?/, '');\n if (!query) return target;\n const hashAt = target.indexOf('#');\n const [head, fragment] =\n hashAt < 0 ? [target, ''] : [target.slice(0, hashAt), target.slice(hashAt)];\n return `${head}${head.includes('?') ? '&' : '?'}${query}${fragment}`;\n}\n\n/** A URL when it is http(s): the Dashboard asks for a URL, and the router refuses any other scheme. */\nfunction httpUrl(url: string): string | null {\n try {\n const { protocol } = new URL(url);\n return protocol === 'http:' || protocol === 'https:' ? url : null;\n } catch {\n return null;\n }\n}\n\n/** The settings, when they list `custom-urls` in the store's features; else `null`. */\nasync function settingsWithCustomUrls(queryClient: QueryClient): Promise<StoreContext | null> {\n try {\n const settings = await queryClient.ensureQueryData(store.queries.settings());\n return settings?.store?.features?.includes('custom-urls') ? settings : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The custom URL saved for `key`, or `undefined`. Any failure counts as none: an address no page\n * answers is also every scanner's, and an API error must leave it the 404 it was, not a 500.\n */\nasync function lookup(key: string, queryClient: QueryClient): Promise<CustomUrlTarget | undefined> {\n try {\n return await queryClient.ensureQueryData(customUrl.queries.resolve(key));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Sends the visitor where the custom URL saved for `pathname` leads, with the address's query, by\n * a 302; returns when there is none, and the caller answers as it would have. An item on the store\n * is reached in one hop, in the language the locale layout would give it. A `custom` row's URL,\n * or an item URL on another site, is a full page load.\n */\nexport async function customUrlRedirect(\n pathname: string,\n search: string,\n options: CustomUrlRedirectOptions\n): Promise<void> {\n const address = customUrlKey(pathname);\n if (!address) return;\n const settings = await settingsWithCustomUrls(options.queryClient);\n if (!settings) return;\n const target = await lookup(address.key, options.queryClient);\n if (!target) return;\n\n const path = customUrlPagePath(target, settings.store?.url);\n if (path) {\n const locale = options.targetLocale\n ? await options.targetLocale(address.locale)\n : address.locale;\n throw redirect(withAddressQuery(`${locale ? `/${locale}` : ''}${path}`, search), {\n statusCode: 302,\n });\n }\n const href = httpUrl(target.url);\n if (href) {\n throw redirect(withAddressQuery(href, search), { statusCode: 302, reloadDocument: true });\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { RouteId } from './chunk-OUW6WESU.js';
2
- import { getActiveCurrency } from './chunk-LC3M4HW7.js';
2
+ import { getActiveCurrency } from './chunk-EDSZX3QE.js';
3
3
 
4
4
  // src/lib/analytics/gtm.ts
5
5
  function gtmEnabled(settings) {
@@ -301,5 +301,5 @@ function servicesInitEvents(externalServices, snippetServices) {
301
301
  }
302
302
 
303
303
  export { DATA_LAYER_PROXY_SCRIPT, gtmCartCheckout, gtmCustomer, gtmDetail, gtmEnabled, gtmImpressions, gtmPage, gtmPurchase, gtmStore, pushToDataLayer, servicesInitEvents };
304
- //# sourceMappingURL=chunk-JBKUYGDE.js.map
305
- //# sourceMappingURL=chunk-JBKUYGDE.js.map
304
+ //# sourceMappingURL=chunk-LD7EYT7B.js.map
305
+ //# sourceMappingURL=chunk-LD7EYT7B.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/analytics/gtm.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,WAAW,QAAA,EAA6C;AACtE,EAAA,OAAO,QAAQ,QAAA,EAAU,KAAA,EAAO,QAAA,EAAU,IAAA,EAAM,KAAK,MAAM,CAAA;AAC7D;AAEO,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACnC,EAAA,MAAA,CAAO,SAAA,GAAY,MAAA,CAAO,SAAA,IAAa,EAAC;AACxC,EAAA,MAAA,CAAO,SAAA,CAAU,KAAK,KAAK,CAAA;AAC7B;AAOO,IAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAerC,I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,IAAI,IAAI,CAAC,CAAA;AACvD,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,GAAA,CAAI,OAAO,GAAG,OAAO,KAAA;AACrD,IAAA,OAAO,CAAC,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,IAAK,0BAAA,CAA2B,IAAI,OAAO,CAAA;AAAA,EACzE,CAAC,CAAA;AACH","file":"chunk-JBKUYGDE.js","sourcesContent":["/**\n * The data a Twig storefront hands Google Tag Manager, built in the browser.\n *\n * On Twig the Store writes it on the server (the `Salla\\GoogleTags` package): each page opens\n * with one `dataLayer.push` naming the page, the store and the customer, plus the page's own\n * ecommerce block (a product's `detail`, the cart's `checkout`, an order's `purchase`). Salla's\n * container and the merchants' own containers read these exact keys, so every builder here\n * copies a PHP one, named beside it. A list's `impressions` copies `<salla-products-list>`\n * instead, which pushes them itself on Twig.\n */\nimport type { Cart, CartItem, Money, Product, User } from '../../types';\nimport type { Order, OrderItem } from '../../routes/account/types';\nimport type { StoreContext } from '../../api/store';\nimport type { PageContext } from '../../twilight/context';\nimport { getActiveCurrency } from '../../api/client';\nimport { RouteId } from '../../router/route-ids';\n\nexport type DataLayerEntry = Record<string, unknown>;\n\n/** True when the store loads a Tag Manager container; without one nothing reads the data layer. */\nexport function gtmEnabled(settings: StoreContext | undefined): boolean {\n return Boolean(settings?.store?.settings?.keys?.gtm?.length);\n}\n\nexport function pushToDataLayer(entry: DataLayerEntry): void {\n if (typeof window === 'undefined') return;\n window.dataLayer = window.dataLayer ?? [];\n window.dataLayer.push(entry);\n}\n\n/**\n * Twig's `dataLayer` proxy (`googletagmanager::head`): it drops request, payment and form\n * fields from every object pushed after it. The root head runs it before anything is pushed;\n * GTM's own script runs it too, for a theme that loads GTM by hand. Once per page.\n */\nexport const DATA_LAYER_PROXY_SCRIPT = `\nwindow.dataLayer = window.dataLayer || [];\nif (!window.__sallaDataLayerProxy) {\n window.__sallaDataLayerProxy = true;\n window.dataLayer = new Proxy(window.dataLayer, {\n set(target, property, value) {\n target[property] = value;\n if (typeof value === 'object') {\n ['form_data', 'data', 'gateway', 'config', 'request', 'headers']\n .forEach(function(key) { value && value.hasOwnProperty(key) && delete value[key]; });\n }\n return true;\n }\n });\n}\n`.trim();\n\n// ─── page ────────────────────────────────────────────────────────────────────\n\n/**\n * `page.pageName`: the Laravel route that renders the page on Twig, camel-cased without\n * `store` (`RequestResolver::getPageName`). The containers compare it: `productShow`,\n * `catShow`, `cartShow`, `search`, `brandsShow`, `thankyou`.\n */\nconst PAGE_NAMES: Record<string, string> = {\n [RouteId.INDEX]: 'home', // store.home\n [RouteId.PRODUCT_SINGLE]: 'productShow', // product.showWithSlug → product.show\n [RouteId.PRODUCT_INDEX]: 'catShow', // cat.showWithSlug → cat.show\n [RouteId.SEARCH]: 'search', // store.search\n [RouteId.PRODUCT_INDEX_LATEST]: 'latestProducts', // store.latest-products\n [RouteId.PRODUCT_INDEX_OFFERS]: 'productOffers', // product.offers\n [RouteId.BRANDS_INDEX]: 'brands', // store.brands\n [RouteId.BRANDS_SINGLE]: 'brandsShow', // store.brands.show\n [RouteId.CART]: 'cartShow', // cart.show\n [RouteId.THANK_YOU]: 'thankyou', // store.thankyou\n [RouteId.BLOG_INDEX]: 'blogIndex', // blog.index\n [RouteId.BLOG_SINGLE]: 'articlesShow', // articles.show\n [RouteId.BLOG_INDEX_CATEGORY]: 'articlesCategoryShow', // articles.category.show\n [RouteId.BLOG_INDEX_TAG]: 'articlesTagShow', // articles.tag.show\n [RouteId.PAGE_SINGLE]: 'pagesSlugShow', // pages.slug.show\n [RouteId.CUSTOMER_PROFILE]: 'userIndex', // user.index\n [RouteId.CUSTOMER_ORDERS_INDEX]: 'myorders', // store.myorders\n [RouteId.CUSTOMER_ORDERS_INDEX_PENDING]: 'myPendingOrders', // store.my_pending_orders\n [RouteId.CUSTOMER_ORDERS_SINGLE]: 'myOrder', // store.my_order\n [RouteId.CUSTOMER_WISHLIST]: 'myWishes', // store.my_wishes\n [RouteId.CUSTOMER_NOTIFICATIONS]: 'userNotificationsIndex', // user.notifications.index\n [RouteId.CUSTOMER_WALLET]: 'wallet', // wallet\n [RouteId.CUSTOMER_LOYALTY_POINTS]: 'customerLoyaltyPoints', // customer.loyalty_points\n [RouteId.LOYALTY]: 'loyaltyProgram', // store.loyalty_program\n [RouteId.TESTIMONIALS]: 'reviewsIndex', // store.reviews.index\n};\n\n/** A page with no known Twig route is named after its slug, camel-cased the same way. */\nexport function gtmPageName(slug: string): string {\n return (\n PAGE_NAMES[slug] ??\n slug.replace(/[._-]+([a-z0-9])/gi, (_, letter: string) => letter.toUpperCase())\n );\n}\n\n/** A fresh 40-hex id, as Twig's `sha1(… now()->timestamp)` gives each page and event one. */\nexport function gtmEventId(): string {\n const bytes = new Uint8Array(20);\n globalThis.crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** `config('theme.name')`: a number on Salla's themes. */\nfunction themeName(settings: StoreContext | undefined): string | number | undefined {\n const name = settings?.theme?.name;\n return name && /^\\d+$/.test(name) ? Number(name) : name;\n}\n\nexport interface GtmPageInput {\n slug: string;\n referrer: string;\n /** Inside the Salla app's webview (`mobileAgent()->is()`). */\n mobileApp: boolean;\n}\n\n/** `RequestResolver::getData`. */\nexport function gtmPage(input: GtmPageInput, settings: StoreContext | undefined): DataLayerEntry {\n return {\n fingerprint: gtmEventId(),\n pageName: gtmPageName(input.slug),\n mobileApp: input.mobileApp ? 1 : 0,\n referrer: input.referrer,\n theme: themeName(settings),\n };\n}\n\n/**\n * `StoreResolver::getData`. The settings API sends none of the legacy built-in pixel ids\n * (`facebook_pixel_id`, …), so they are null, as Twig sends them for a store that set none.\n */\nexport function gtmStore(settings: StoreContext | undefined): DataLayerEntry {\n return {\n store: settings?.store?.username ?? '',\n facebook_pixel_id: null,\n google_analytics_id: null,\n snapchat_pixel_id: null,\n };\n}\n\n// ─── customer ────────────────────────────────────────────────────────────────\n\nasync function sha256(value: string): Promise<string | null> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return null;\n const digest = await subtle.digest('SHA-256', new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** Lower-cased, no whitespace, and only a valid address (Twig: `FILTER_VALIDATE_EMAIL`). */\nfunction cleanEmail(email: string | undefined): string | null {\n const clean = email?.replace(/\\s+/g, '').toLowerCase();\n return clean && /^[^@]+@[^@]+\\.[^@]+$/.test(clean) ? clean : null;\n}\n\n/** E.164 without the plus (`966501234567`), as `fullMobileFormat(false)`; null when it isn't one. */\nfunction cleanPhone(mobile: string | undefined): string | null {\n const compact = mobile?.replace(/[\\s()-]+/g, '') ?? '';\n const digits = compact.startsWith('+')\n ? compact.slice(1)\n : compact.startsWith('00')\n ? compact.slice(2)\n : compact;\n return /^[1-9]\\d{7,14}$/.test(digits) ? digits : null;\n}\n\n/** `Store\\CustomerResolver::getData`: a guest is `{ isGuest: true }`. */\nexport async function gtmCustomer(\n user: User | null | undefined,\n settings: StoreContext | undefined\n): Promise<DataLayerEntry> {\n if (!user) return { isGuest: true };\n const email = cleanEmail(user.email);\n const phone = cleanPhone(user.mobile);\n const phoneWithPlus = phone ? `+${phone}` : null;\n const [firstName, lastName, emailHashed, phoneHashed, phoneWithPlusHashed] = await Promise.all([\n sha256(user.first_name ?? ''),\n sha256(user.last_name ?? ''),\n email ? sha256(email) : null,\n phone ? sha256(phone) : null,\n phoneWithPlus ? sha256(phoneWithPlus) : null,\n ]);\n return {\n isGuest: false,\n name: [user.first_name, user.last_name].filter(Boolean).join(' '),\n first_name: firstName,\n last_name: lastName,\n created_at: user.created_at ?? Math.floor(Date.now() / 1000),\n email,\n phone,\n phone_with_plus: phoneWithPlus,\n phone_with_plus_hashed: phoneWithPlusHashed,\n currency: user.preferences?.currency_code ?? settings?.user?.currency_code ?? 'SAR',\n email_hashed: emailHashed,\n phone_hashed: phoneHashed,\n };\n}\n\n// ─── money ───────────────────────────────────────────────────────────────────\n\nconst amountOf = (value: number | string | Money | null | undefined): number =>\n value && typeof value === 'object' ? Number(value.amount) || 0 : Number(value) || 0;\n\n/**\n * The currency prices are shown in: the visitor's choice, else the market's own (settings\n * `user.currency_code`; `OMR` on an Omani market of a Saudi store), as `currency()` on Twig.\n */\nexport function gtmCurrency(settings: StoreContext | undefined, fallback?: string): string {\n return getActiveCurrency() ?? fallback ?? settings?.user?.currency_code ?? 'SAR';\n}\n\n/**\n * `getGoogleTagManagerExchangeRate`: riyals per unit of `code`, as moneyphp prints a ratio.\n * Settings give each currency's `amount` per riyal.\n */\nexport function gtmExchangeRate(code: string, settings: StoreContext | undefined): string {\n const perRiyal = Number(settings?.currencies?.[code]?.amount);\n if (code === 'SAR' || !(perRiyal > 0)) return '1';\n return String(Number((1 / perRiyal).toPrecision(14)));\n}\n\n// ─── ecommerce ───────────────────────────────────────────────────────────────\n\nexport interface GtmProduct {\n id: number | string;\n name: string;\n categories: Array<{ id?: number | string; name: string }>;\n category: string;\n price: number;\n quantity: number;\n variant: string | null;\n brand: string;\n image: string;\n}\n\n/** `IsTaggingProduct::getGoogleTagManagerData`. */\nexport function gtmProduct(product: Product): GtmProduct {\n const categories = product.category\n ? [{ id: product.category.id, name: product.category.name }]\n : [];\n return {\n id: product.id,\n name: product.name,\n categories,\n category: categories.map((category) => category.name).join('/'),\n price: amountOf(product.price),\n quantity: 1,\n variant: '',\n brand: product.brand?.name ?? '',\n image: product.image?.url ?? '',\n };\n}\n\n/** `GoogleTagManager::detail`, which the product page pushes with its page data. */\nexport function gtmDetail(product: Product, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = gtmCurrency(settings, product.currency);\n return {\n event: 'detail',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n detail: { products: [gtmProduct(product)] },\n },\n };\n}\n\n/** `CartItem::getGoogleTagManagerData`: the cart line's taxed total as its price. */\nfunction gtmCartItem(item: CartItem, currency: string): DataLayerEntry {\n return {\n id: item.product_id,\n name: item.product_name,\n categories: [],\n category: '',\n price: amountOf(item.total),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.product_image ?? '',\n cart_item_id: item.id,\n currency,\n };\n}\n\n/**\n * `GoogleTagManager::checkout`, from the cart page's `SeoCartWidget` (step 1). It sets no\n * `event`: on Twig it rides on the page's own push. Only the available lines, and no order\n * options, as `getAvailableItems()` and the macro leave them out.\n */\nexport function gtmCartCheckout(\n cart: Cart,\n settings: StoreContext | undefined,\n step = 1\n): DataLayerEntry {\n const currencyCode = gtmCurrency(settings);\n const total = amountOf(cart.total);\n return {\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n checkout: {\n actionField: {\n id: cart.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step,\n },\n products: cart.items\n .filter((item) => item.is_available !== false && String(item.type) !== 'order_option')\n .map((item) => gtmCartItem(item, currencyCode)),\n },\n },\n };\n}\n\n/** `OrderItems::getGoogleTagManagerData`: the line before its discount, tax included. */\nfunction gtmOrderItem(item: OrderItem, currency: string): DataLayerEntry | null {\n const productId = item.product_id ?? item.product?.id;\n if (productId == null) return null;\n\n const discount = item.amounts?.total_discount ?? item.amounts?.discount;\n return {\n id: productId,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(discount),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.thumbnail ?? item.product_thumbnail ?? item.image ?? '',\n currency,\n };\n}\n\n/** `GoogleTagManager::purchase`, from the thank-you page's `SeoThankYouWidget`. */\nexport function gtmPurchase(order: Order, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = order.currency || gtmCurrency(settings);\n const total = amountOf(order.amounts?.total);\n const grandTotal = order.amounts?.total?.amount;\n const useGtmSubtotal = settings?.store?.settings?.gtm_order_completed === true;\n return {\n event: 'purchase',\n // Salla's GTM container reads 0.subtotal. Null clears any previous order's value.\n 0: { subtotal: useGtmSubtotal && Number.isFinite(grandTotal) ? grandTotal : null },\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: order.id,\n purchase: {\n actionField: {\n id: order.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step: null,\n },\n products: (order.items ?? [])\n .map((item) => gtmOrderItem(item, currencyCode))\n .filter((item): item is DataLayerEntry => item !== null),\n },\n },\n };\n}\n\n/**\n * The `impressions` `<salla-products-list>` pushes for each page of products it fetches\n * (`appendDataLayer`), with the page's title and id where a product names no category.\n */\nexport function gtmImpressions(\n products: Product[],\n page: PageContext | undefined,\n settings: StoreContext | undefined\n): DataLayerEntry {\n return {\n event: 'impressions',\n ecommerce: {\n currencyCode: gtmCurrency(settings),\n impressions: products.map((product, index) => {\n const category = product.category?.name || page?.title;\n return {\n id: product.id,\n name: product.name,\n price: amountOf(product.price),\n brand: product.brand?.name || '',\n quantity: product.quantity,\n categories: [{ name: category, id: page?.id }],\n category,\n position: index + 1,\n };\n }),\n },\n };\n}\n\n// ─── services ────────────────────────────────────────────────────────────────\n\n/** Services Twig renders itself rather than announcing (`ExternalServicesWidget::$serviceWidgets`). */\nconst WIDGET_SERVICES = new Set([\n 'google_tags_manager',\n 'mailchimp',\n 'addon-mailchimp-marketing',\n 'klaviyo',\n]);\n\n/** Apps with a snippet that Twig still announces (`ExternalServicesWidget::$serviceTracking`). */\nconst ANNOUNCED_SNIPPET_SERVICES = new Set(['facebook_pixel', 'tiktok_pixel', 'google_analytics']);\n\n/**\n * The `services::<name>.init` events a Twig page dispatches through the SDK, which copies each\n * into the data layer, where Salla's container loads GA4, Google Ads, Clarity and the pixels\n * from them. The settings API lists every active service; Twig leaves out the ones it renders\n * as a widget and the apps whose snippet the page loads instead.\n */\nexport function servicesInitEvents(\n externalServices: StoreContext['external_services'],\n snippetServices: Iterable<string>\n): Array<[name: string, payload: unknown]> {\n const snippets = new Set(snippetServices);\n return Object.entries(externalServices ?? {}).filter(([name]) => {\n const service = /^services::(.+)\\.init$/.exec(name)?.[1];\n if (!service || WIDGET_SERVICES.has(service)) return false;\n return !snippets.has(service) || ANNOUNCED_SNIPPET_SERVICES.has(service);\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/analytics/gtm.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,WAAW,QAAA,EAA6C;AACtE,EAAA,OAAO,QAAQ,QAAA,EAAU,KAAA,EAAO,QAAA,EAAU,IAAA,EAAM,KAAK,MAAM,CAAA;AAC7D;AAEO,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACnC,EAAA,MAAA,CAAO,SAAA,GAAY,MAAA,CAAO,SAAA,IAAa,EAAC;AACxC,EAAA,MAAA,CAAO,SAAA,CAAU,KAAK,KAAK,CAAA;AAC7B;AAOO,IAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAerC,IAAA;AASF,IAAM,UAAA,GAAqC;AAAA,EACzC,CAAC,OAAA,CAAQ,KAAK,GAAG,MAAA;AAAA;AAAA,EACjB,CAAC,OAAA,CAAQ,cAAc,GAAG,aAAA;AAAA;AAAA,EAC1B,CAAC,OAAA,CAAQ,aAAa,GAAG,SAAA;AAAA;AAAA,EACzB,CAAC,OAAA,CAAQ,MAAM,GAAG,QAAA;AAAA;AAAA,EAClB,CAAC,OAAA,CAAQ,oBAAoB,GAAG,gBAAA;AAAA;AAAA,EAChC,CAAC,OAAA,CAAQ,oBAAoB,GAAG,eAAA;AAAA;AAAA,EAChC,CAAC,OAAA,CAAQ,YAAY,GAAG,QAAA;AAAA;AAAA,EACxB,CAAC,OAAA,CAAQ,aAAa,GAAG,YAAA;AAAA;AAAA,EACzB,CAAC,OAAA,CAAQ,IAAI,GAAG,UAAA;AAAA;AAAA,EAChB,CAAC,OAAA,CAAQ,SAAS,GAAG,UA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CAAC,EAAE,IAAA,EAAM,UAAU,EAAA,EAAI,IAAA,EAAM,IAAI,CAAA;AAAA,UAC7C,QAAA;AAAA,UACA,UAAU,KAAA,GAAQ;AAAA,SACpB;AAAA,MACF,CAAC;AAAA;AACH,GACF;AACF;AAKA,IAAM,eAAA,uBAAsB,GAAA,CAAI;AAAA,EAC9B,qBAAA;AAAA,EACA,WAAA;AAAA,EACA,2BAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,6CAA6B,IAAI,GAAA,CAAI,CAAC,gBAAA,EAAkB,cAAA,EAAgB,kBAAkB,CAAC,CAAA;AAQ1F,SAAS,kBAAA,CACd,kBACA,eAAA,EACyC;AACzC,EAAA,MAAM,QAAA,GAAW,IAAI,GAAA,CAAI,eAAe,CAAA;AACxC,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,gBAAA,IAAoB,EAAE,EAAE,MAAA,CAAO,CAAC,CAAC,IAAI,CAAA,KAAM;AAC/D,IAAA,MAAM,OAAA,GAAU,wBAAA,CAAyB,IAAA,CAAK,IAAI,IAAI,CAAC,CAAA;AACvD,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,GAAA,CAAI,OAAO,GAAG,OAAO,KAAA;AACrD,IAAA,OAAO,CAAC,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,IAAK,0BAAA,CAA2B,IAAI,OAAO,CAAA;AAAA,EACzE,CAAC,CAAA;AACH","file":"chunk-LD7EYT7B.js","sourcesContent":["/**\n * The data a Twig storefront hands Google Tag Manager, built in the browser.\n *\n * On Twig the Store writes it on the server (the `Salla\\GoogleTags` package): each page opens\n * with one `dataLayer.push` naming the page, the store and the customer, plus the page's own\n * ecommerce block (a product's `detail`, the cart's `checkout`, an order's `purchase`). Salla's\n * container and the merchants' own containers read these exact keys, so every builder here\n * copies a PHP one, named beside it. A list's `impressions` copies `<salla-products-list>`\n * instead, which pushes them itself on Twig.\n */\nimport type { Cart, CartItem, Money, Product, User } from '../../types';\nimport type { Order, OrderItem } from '../../routes/account/types';\nimport type { StoreContext } from '../../api/store';\nimport type { PageContext } from '../../twilight/context';\nimport { getActiveCurrency } from '../../api/client';\nimport { RouteId } from '../../router/route-ids';\n\nexport type DataLayerEntry = Record<string, unknown>;\n\n/** True when the store loads a Tag Manager container; without one nothing reads the data layer. */\nexport function gtmEnabled(settings: StoreContext | undefined): boolean {\n return Boolean(settings?.store?.settings?.keys?.gtm?.length);\n}\n\nexport function pushToDataLayer(entry: DataLayerEntry): void {\n if (typeof window === 'undefined') return;\n window.dataLayer = window.dataLayer ?? [];\n window.dataLayer.push(entry);\n}\n\n/**\n * Twig's `dataLayer` proxy (`googletagmanager::head`): it drops request, payment and form\n * fields from every object pushed after it. The root head runs it before anything is pushed;\n * GTM's own script runs it too, for a theme that loads GTM by hand. Once per page.\n */\nexport const DATA_LAYER_PROXY_SCRIPT = `\nwindow.dataLayer = window.dataLayer || [];\nif (!window.__sallaDataLayerProxy) {\n window.__sallaDataLayerProxy = true;\n window.dataLayer = new Proxy(window.dataLayer, {\n set(target, property, value) {\n target[property] = value;\n if (typeof value === 'object') {\n ['form_data', 'data', 'gateway', 'config', 'request', 'headers']\n .forEach(function(key) { value && value.hasOwnProperty(key) && delete value[key]; });\n }\n return true;\n }\n });\n}\n`.trim();\n\n// ─── page ────────────────────────────────────────────────────────────────────\n\n/**\n * `page.pageName`: the Laravel route that renders the page on Twig, camel-cased without\n * `store` (`RequestResolver::getPageName`). The containers compare it: `productShow`,\n * `catShow`, `cartShow`, `search`, `brandsShow`, `thankyou`.\n */\nconst PAGE_NAMES: Record<string, string> = {\n [RouteId.INDEX]: 'home', // store.home\n [RouteId.PRODUCT_SINGLE]: 'productShow', // product.showWithSlug → product.show\n [RouteId.PRODUCT_INDEX]: 'catShow', // cat.showWithSlug → cat.show\n [RouteId.SEARCH]: 'search', // store.search\n [RouteId.PRODUCT_INDEX_LATEST]: 'latestProducts', // store.latest-products\n [RouteId.PRODUCT_INDEX_OFFERS]: 'productOffers', // product.offers\n [RouteId.BRANDS_INDEX]: 'brands', // store.brands\n [RouteId.BRANDS_SINGLE]: 'brandsShow', // store.brands.show\n [RouteId.CART]: 'cartShow', // cart.show\n [RouteId.THANK_YOU]: 'thankyou', // store.thankyou\n [RouteId.BLOG_INDEX]: 'blogIndex', // blog.index\n [RouteId.BLOG_SINGLE]: 'articlesShow', // articles.show\n [RouteId.BLOG_INDEX_CATEGORY]: 'articlesCategoryShow', // articles.category.show\n [RouteId.BLOG_INDEX_TAG]: 'articlesTagShow', // articles.tag.show\n [RouteId.PAGE_SINGLE]: 'pagesSlugShow', // pages.slug.show\n [RouteId.CUSTOMER_PROFILE]: 'userIndex', // user.index\n [RouteId.CUSTOMER_ORDERS_INDEX]: 'myorders', // store.myorders\n [RouteId.CUSTOMER_ORDERS_INDEX_PENDING]: 'myPendingOrders', // store.my_pending_orders\n [RouteId.CUSTOMER_ORDERS_SINGLE]: 'myOrder', // store.my_order\n [RouteId.CUSTOMER_WISHLIST]: 'myWishes', // store.my_wishes\n [RouteId.CUSTOMER_NOTIFICATIONS]: 'userNotificationsIndex', // user.notifications.index\n [RouteId.CUSTOMER_WALLET]: 'wallet', // wallet\n [RouteId.CUSTOMER_LOYALTY_POINTS]: 'customerLoyaltyPoints', // customer.loyalty_points\n [RouteId.LOYALTY]: 'loyaltyProgram', // store.loyalty_program\n [RouteId.TESTIMONIALS]: 'reviewsIndex', // store.reviews.index\n};\n\n/** A page with no known Twig route is named after its slug, camel-cased the same way. */\nexport function gtmPageName(slug: string): string {\n return (\n PAGE_NAMES[slug] ??\n slug.replace(/[._-]+([a-z0-9])/gi, (_, letter: string) => letter.toUpperCase())\n );\n}\n\n/** A fresh 40-hex id, as Twig's `sha1(… now()->timestamp)` gives each page and event one. */\nexport function gtmEventId(): string {\n const bytes = new Uint8Array(20);\n globalThis.crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** `config('theme.name')`: a number on Salla's themes. */\nfunction themeName(settings: StoreContext | undefined): string | number | undefined {\n const name = settings?.theme?.name;\n return name && /^\\d+$/.test(name) ? Number(name) : name;\n}\n\nexport interface GtmPageInput {\n slug: string;\n referrer: string;\n /** Inside the Salla app's webview (`mobileAgent()->is()`). */\n mobileApp: boolean;\n}\n\n/** `RequestResolver::getData`. */\nexport function gtmPage(input: GtmPageInput, settings: StoreContext | undefined): DataLayerEntry {\n return {\n fingerprint: gtmEventId(),\n pageName: gtmPageName(input.slug),\n mobileApp: input.mobileApp ? 1 : 0,\n referrer: input.referrer,\n theme: themeName(settings),\n };\n}\n\n/**\n * `StoreResolver::getData`. The settings API sends none of the legacy built-in pixel ids\n * (`facebook_pixel_id`, …), so they are null, as Twig sends them for a store that set none.\n */\nexport function gtmStore(settings: StoreContext | undefined): DataLayerEntry {\n return {\n store: settings?.store?.username ?? '',\n facebook_pixel_id: null,\n google_analytics_id: null,\n snapchat_pixel_id: null,\n };\n}\n\n// ─── customer ────────────────────────────────────────────────────────────────\n\nasync function sha256(value: string): Promise<string | null> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return null;\n const digest = await subtle.digest('SHA-256', new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** Lower-cased, no whitespace, and only a valid address (Twig: `FILTER_VALIDATE_EMAIL`). */\nfunction cleanEmail(email: string | undefined): string | null {\n const clean = email?.replace(/\\s+/g, '').toLowerCase();\n return clean && /^[^@]+@[^@]+\\.[^@]+$/.test(clean) ? clean : null;\n}\n\n/** E.164 without the plus (`966501234567`), as `fullMobileFormat(false)`; null when it isn't one. */\nfunction cleanPhone(mobile: string | undefined): string | null {\n const compact = mobile?.replace(/[\\s()-]+/g, '') ?? '';\n const digits = compact.startsWith('+')\n ? compact.slice(1)\n : compact.startsWith('00')\n ? compact.slice(2)\n : compact;\n return /^[1-9]\\d{7,14}$/.test(digits) ? digits : null;\n}\n\n/** `Store\\CustomerResolver::getData`: a guest is `{ isGuest: true }`. */\nexport async function gtmCustomer(\n user: User | null | undefined,\n settings: StoreContext | undefined\n): Promise<DataLayerEntry> {\n if (!user) return { isGuest: true };\n const email = cleanEmail(user.email);\n const phone = cleanPhone(user.mobile);\n const phoneWithPlus = phone ? `+${phone}` : null;\n const [firstName, lastName, emailHashed, phoneHashed, phoneWithPlusHashed] = await Promise.all([\n sha256(user.first_name ?? ''),\n sha256(user.last_name ?? ''),\n email ? sha256(email) : null,\n phone ? sha256(phone) : null,\n phoneWithPlus ? sha256(phoneWithPlus) : null,\n ]);\n return {\n isGuest: false,\n name: [user.first_name, user.last_name].filter(Boolean).join(' '),\n first_name: firstName,\n last_name: lastName,\n created_at: user.created_at ?? Math.floor(Date.now() / 1000),\n email,\n phone,\n phone_with_plus: phoneWithPlus,\n phone_with_plus_hashed: phoneWithPlusHashed,\n currency: user.preferences?.currency_code ?? settings?.user?.currency_code ?? 'SAR',\n email_hashed: emailHashed,\n phone_hashed: phoneHashed,\n };\n}\n\n// ─── money ───────────────────────────────────────────────────────────────────\n\nconst amountOf = (value: number | string | Money | null | undefined): number =>\n value && typeof value === 'object' ? Number(value.amount) || 0 : Number(value) || 0;\n\n/**\n * The currency prices are shown in: the visitor's choice, else the market's own (settings\n * `user.currency_code`; `OMR` on an Omani market of a Saudi store), as `currency()` on Twig.\n */\nexport function gtmCurrency(settings: StoreContext | undefined, fallback?: string): string {\n return getActiveCurrency() ?? fallback ?? settings?.user?.currency_code ?? 'SAR';\n}\n\n/**\n * `getGoogleTagManagerExchangeRate`: riyals per unit of `code`, as moneyphp prints a ratio.\n * Settings give each currency's `amount` per riyal.\n */\nexport function gtmExchangeRate(code: string, settings: StoreContext | undefined): string {\n const perRiyal = Number(settings?.currencies?.[code]?.amount);\n if (code === 'SAR' || !(perRiyal > 0)) return '1';\n return String(Number((1 / perRiyal).toPrecision(14)));\n}\n\n// ─── ecommerce ───────────────────────────────────────────────────────────────\n\nexport interface GtmProduct {\n id: number | string;\n name: string;\n categories: Array<{ id?: number | string; name: string }>;\n category: string;\n price: number;\n quantity: number;\n variant: string | null;\n brand: string;\n image: string;\n}\n\n/** `IsTaggingProduct::getGoogleTagManagerData`. */\nexport function gtmProduct(product: Product): GtmProduct {\n const categories = product.category\n ? [{ id: product.category.id, name: product.category.name }]\n : [];\n return {\n id: product.id,\n name: product.name,\n categories,\n category: categories.map((category) => category.name).join('/'),\n price: amountOf(product.price),\n quantity: 1,\n variant: '',\n brand: product.brand?.name ?? '',\n image: product.image?.url ?? '',\n };\n}\n\n/** `GoogleTagManager::detail`, which the product page pushes with its page data. */\nexport function gtmDetail(product: Product, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = gtmCurrency(settings, product.currency);\n return {\n event: 'detail',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n detail: { products: [gtmProduct(product)] },\n },\n };\n}\n\n/** `CartItem::getGoogleTagManagerData`: the cart line's taxed total as its price. */\nfunction gtmCartItem(item: CartItem, currency: string): DataLayerEntry {\n return {\n id: item.product_id,\n name: item.product_name,\n categories: [],\n category: '',\n price: amountOf(item.total),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.product_image ?? '',\n cart_item_id: item.id,\n currency,\n };\n}\n\n/**\n * `GoogleTagManager::checkout`, from the cart page's `SeoCartWidget` (step 1). It sets no\n * `event`: on Twig it rides on the page's own push. Only the available lines, and no order\n * options, as `getAvailableItems()` and the macro leave them out.\n */\nexport function gtmCartCheckout(\n cart: Cart,\n settings: StoreContext | undefined,\n step = 1\n): DataLayerEntry {\n const currencyCode = gtmCurrency(settings);\n const total = amountOf(cart.total);\n return {\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n checkout: {\n actionField: {\n id: cart.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step,\n },\n products: cart.items\n .filter((item) => item.is_available !== false && String(item.type) !== 'order_option')\n .map((item) => gtmCartItem(item, currencyCode)),\n },\n },\n };\n}\n\n/** `OrderItems::getGoogleTagManagerData`: the line before its discount, tax included. */\nfunction gtmOrderItem(item: OrderItem, currency: string): DataLayerEntry | null {\n const productId = item.product_id ?? item.product?.id;\n if (productId == null) return null;\n\n const discount = item.amounts?.total_discount ?? item.amounts?.discount;\n return {\n id: productId,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(discount),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.thumbnail ?? item.product_thumbnail ?? item.image ?? '',\n currency,\n };\n}\n\n/** `GoogleTagManager::purchase`, from the thank-you page's `SeoThankYouWidget`. */\nexport function gtmPurchase(order: Order, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = order.currency || gtmCurrency(settings);\n const total = amountOf(order.amounts?.total);\n const grandTotal = order.amounts?.total?.amount;\n const useGtmSubtotal = settings?.store?.settings?.gtm_order_completed === true;\n return {\n event: 'purchase',\n // Salla's GTM container reads 0.subtotal. Null clears any previous order's value.\n 0: { subtotal: useGtmSubtotal && Number.isFinite(grandTotal) ? grandTotal : null },\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: order.id,\n purchase: {\n actionField: {\n id: order.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step: null,\n },\n products: (order.items ?? [])\n .map((item) => gtmOrderItem(item, currencyCode))\n .filter((item): item is DataLayerEntry => item !== null),\n },\n },\n };\n}\n\n/**\n * The `impressions` `<salla-products-list>` pushes for each page of products it fetches\n * (`appendDataLayer`), with the page's title and id where a product names no category.\n */\nexport function gtmImpressions(\n products: Product[],\n page: PageContext | undefined,\n settings: StoreContext | undefined\n): DataLayerEntry {\n return {\n event: 'impressions',\n ecommerce: {\n currencyCode: gtmCurrency(settings),\n impressions: products.map((product, index) => {\n const category = product.category?.name || page?.title;\n return {\n id: product.id,\n name: product.name,\n price: amountOf(product.price),\n brand: product.brand?.name || '',\n quantity: product.quantity,\n categories: [{ name: category, id: page?.id }],\n category,\n position: index + 1,\n };\n }),\n },\n };\n}\n\n// ─── services ────────────────────────────────────────────────────────────────\n\n/** Services Twig renders itself rather than announcing (`ExternalServicesWidget::$serviceWidgets`). */\nconst WIDGET_SERVICES = new Set([\n 'google_tags_manager',\n 'mailchimp',\n 'addon-mailchimp-marketing',\n 'klaviyo',\n]);\n\n/** Apps with a snippet that Twig still announces (`ExternalServicesWidget::$serviceTracking`). */\nconst ANNOUNCED_SNIPPET_SERVICES = new Set(['facebook_pixel', 'tiktok_pixel', 'google_analytics']);\n\n/**\n * The `services::<name>.init` events a Twig page dispatches through the SDK, which copies each\n * into the data layer, where Salla's container loads GA4, Google Ads, Clarity and the pixels\n * from them. The settings API lists every active service; Twig leaves out the ones it renders\n * as a widget and the apps whose snippet the page loads instead.\n */\nexport function servicesInitEvents(\n externalServices: StoreContext['external_services'],\n snippetServices: Iterable<string>\n): Array<[name: string, payload: unknown]> {\n const snippets = new Set(snippetServices);\n return Object.entries(externalServices ?? {}).filter(([name]) => {\n const service = /^services::(.+)\\.init$/.exec(name)?.[1];\n if (!service || WIDGET_SERVICES.has(service)) return false;\n return !snippets.has(service) || ANNOUNCED_SNIPPET_SERVICES.has(service);\n });\n}\n"]}