@salla.sa/twilight-theme-engine 1.0.59 → 1.0.60

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 (207) hide show
  1. package/dist/{AddToCartForm-IFK5P6XK.js → AddToCartForm-GFAJUB4Y.js} +3 -3
  2. package/dist/{AddToCartForm-IFK5P6XK.js.map → AddToCartForm-GFAJUB4Y.js.map} +1 -1
  3. package/dist/{BlogAuthorPage-KA3EWFJC.js → BlogAuthorPage-WWA75UTA.js} +15 -15
  4. package/dist/{BlogAuthorPage-KA3EWFJC.js.map → BlogAuthorPage-WWA75UTA.js.map} +1 -1
  5. package/dist/{BlogCategoryPage-EWFNGPTS.js → BlogCategoryPage-VGIAMWPH.js} +15 -15
  6. package/dist/{BlogCategoryPage-EWFNGPTS.js.map → BlogCategoryPage-VGIAMWPH.js.map} +1 -1
  7. package/dist/{BlogPage-E3CN2WJL.js → BlogPage-5MW4WSOH.js} +13 -13
  8. package/dist/{BlogPage-E3CN2WJL.js.map → BlogPage-5MW4WSOH.js.map} +1 -1
  9. package/dist/{BlogSinglePage-Z4GIRBWI.js → BlogSinglePage-67E3PVMP.js} +13 -13
  10. package/dist/{BlogSinglePage-Z4GIRBWI.js.map → BlogSinglePage-67E3PVMP.js.map} +1 -1
  11. package/dist/{BlogTagPage-4D6GMTHN.js → BlogTagPage-EEOIAALL.js} +15 -15
  12. package/dist/{BlogTagPage-4D6GMTHN.js.map → BlogTagPage-EEOIAALL.js.map} +1 -1
  13. package/dist/{BrandsPage-C6EZVXQC.js → BrandsPage-SNVIBZGR.js} +13 -13
  14. package/dist/{BrandsPage-C6EZVXQC.js.map → BrandsPage-SNVIBZGR.js.map} +1 -1
  15. package/dist/{Breadcrumb-HZVWJZC4.js → Breadcrumb-4I2HVAFR.js} +13 -13
  16. package/dist/{Breadcrumb-HZVWJZC4.js.map → Breadcrumb-4I2HVAFR.js.map} +1 -1
  17. package/dist/{CartItem-OBF3TBDK.js → CartItem-A7Y6MZXS.js} +13 -13
  18. package/dist/{CartItem-OBF3TBDK.js.map → CartItem-A7Y6MZXS.js.map} +1 -1
  19. package/dist/{CartSummary-GHMZ5LAL.js → CartSummary-MUCVTNKG.js} +13 -13
  20. package/dist/{CartSummary-GHMZ5LAL.js.map → CartSummary-MUCVTNKG.js.map} +1 -1
  21. package/dist/{Copyright-XLIZFWVM.js → Copyright-VJYMP42V.js} +3 -3
  22. package/dist/{Copyright-XLIZFWVM.js.map → Copyright-VJYMP42V.js.map} +1 -1
  23. package/dist/{CustomerLayout-JG4GOVSO.js → CustomerLayout-L3Y2TIPF.js} +13 -13
  24. package/dist/{CustomerLayout-JG4GOVSO.js.map → CustomerLayout-L3Y2TIPF.js.map} +1 -1
  25. package/dist/{Footer-FV7ZXLY4.js → Footer-OQFU25J4.js} +13 -13
  26. package/dist/{Footer-FV7ZXLY4.js.map → Footer-OQFU25J4.js.map} +1 -1
  27. package/dist/{Header-WQ675B65.js → Header-QNNAHZJL.js} +6 -6
  28. package/dist/{Header-WQ675B65.js.map → Header-QNNAHZJL.js.map} +1 -1
  29. package/dist/{LoyaltyPage-SJUUOW3V.js → LoyaltyPage-IULR2XKZ.js} +14 -14
  30. package/dist/{LoyaltyPage-SJUUOW3V.js.map → LoyaltyPage-IULR2XKZ.js.map} +1 -1
  31. package/dist/{MainMenu-SH3YM2CA.js → MainMenu-3KKSHFCS.js} +7 -7
  32. package/dist/{MainMenu-SH3YM2CA.js.map → MainMenu-3KKSHFCS.js.map} +1 -1
  33. package/dist/{MasterLayout-VJQDAL7N.js → MasterLayout-HJWMQHWO.js} +13 -13
  34. package/dist/{MasterLayout-VJQDAL7N.js.map → MasterLayout-HJWMQHWO.js.map} +1 -1
  35. package/dist/{MobileMenu-JGO33EPX.js → MobileMenu-DBJ23EKX.js} +14 -14
  36. package/dist/{MobileMenu-JGO33EPX.js.map → MobileMenu-DBJ23EKX.js.map} +1 -1
  37. package/dist/{NotificationsPage-DBXZUQW6.js → NotificationsPage-PUS3WBU6.js} +13 -13
  38. package/dist/{NotificationsPage-DBXZUQW6.js.map → NotificationsPage-PUS3WBU6.js.map} +1 -1
  39. package/dist/{OrderSinglePage-2ME6HVFH.js → OrderSinglePage-4CK6OT6U.js} +14 -14
  40. package/dist/{OrderSinglePage-2ME6HVFH.js.map → OrderSinglePage-4CK6OT6U.js.map} +1 -1
  41. package/dist/{OrdersPage-6XMYJQAB.js → OrdersPage-EGIDHSYS.js} +14 -14
  42. package/dist/{OrdersPage-6XMYJQAB.js.map → OrdersPage-EGIDHSYS.js.map} +1 -1
  43. package/dist/{PageSingle-ATWHQBS7.js → PageSingle-ORPH52QX.js} +3 -3
  44. package/dist/{PageSingle-ATWHQBS7.js.map → PageSingle-ORPH52QX.js.map} +1 -1
  45. package/dist/{ProductDetails-DH2MRJQ2.js → ProductDetails-RY6PNKKJ.js} +3 -3
  46. package/dist/{ProductDetails-DH2MRJQ2.js.map → ProductDetails-RY6PNKKJ.js.map} +1 -1
  47. package/dist/{ProfilePage-FGJHE5AD.js → ProfilePage-IO2MDE53.js} +13 -13
  48. package/dist/{ProfilePage-FGJHE5AD.js.map → ProfilePage-IO2MDE53.js.map} +1 -1
  49. package/dist/{SeoCartWidget-ALMYKXRG.js → SeoCartWidget-TPSVEGMI.js} +13 -13
  50. package/dist/{SeoCartWidget-ALMYKXRG.js.map → SeoCartWidget-TPSVEGMI.js.map} +1 -1
  51. package/dist/{SettingsPage-K5EM4BLS.js → SettingsPage-ZTD4ALAA.js} +13 -13
  52. package/dist/{SettingsPage-K5EM4BLS.js.map → SettingsPage-ZTD4ALAA.js.map} +1 -1
  53. package/dist/{StoreClosedNotification-3NKLFBKL.js → StoreClosedNotification-52REE2T5.js} +14 -14
  54. package/dist/{StoreClosedNotification-3NKLFBKL.js.map → StoreClosedNotification-52REE2T5.js.map} +1 -1
  55. package/dist/{TestimonialsPage-UBRVYDQW.js → TestimonialsPage-QDBHJADT.js} +3 -3
  56. package/dist/{TestimonialsPage-UBRVYDQW.js.map → TestimonialsPage-QDBHJADT.js.map} +1 -1
  57. package/dist/{ThankYouPage-WPR576XD.js → ThankYouPage-IRLZI3HI.js} +13 -13
  58. package/dist/{ThankYouPage-WPR576XD.js.map → ThankYouPage-IRLZI3HI.js.map} +1 -1
  59. package/dist/{WalletPage-ZMTV7GVF.js → WalletPage-ZTSSGFMO.js} +14 -14
  60. package/dist/{WalletPage-ZMTV7GVF.js.map → WalletPage-ZTSSGFMO.js.map} +1 -1
  61. package/dist/{WishlistPage-BRB7RZEF.js → WishlistPage-OADS7B5J.js} +15 -15
  62. package/dist/{WishlistPage-BRB7RZEF.js.map → WishlistPage-OADS7B5J.js.map} +1 -1
  63. package/dist/api/apps.js +4 -4
  64. package/dist/api/brands.js +5 -5
  65. package/dist/api/cart.js +5 -5
  66. package/dist/api/category.js +5 -5
  67. package/dist/api/client.js +3 -3
  68. package/dist/api/home.js +4 -4
  69. package/dist/api/loyalty.js +5 -5
  70. package/dist/api/menu.js +4 -4
  71. package/dist/api/messages.d.ts +58 -0
  72. package/dist/api/messages.d.ts.map +1 -0
  73. package/dist/api/notification.js +4 -4
  74. package/dist/api/order.js +5 -5
  75. package/dist/api/page.js +5 -5
  76. package/dist/api/product.js +5 -5
  77. package/dist/api/profile.js +3 -3
  78. package/dist/api/store.js +4 -4
  79. package/dist/api/translations.d.ts +7 -2
  80. package/dist/api/translations.d.ts.map +1 -1
  81. package/dist/api/translations.js +4 -4
  82. package/dist/api/user.js +4 -4
  83. package/dist/api/wishlist.js +6 -6
  84. package/dist/{chunk-G5ZVKWD7.js → chunk-6DVYW7OA.js} +4 -4
  85. package/dist/{chunk-G5ZVKWD7.js.map → chunk-6DVYW7OA.js.map} +1 -1
  86. package/dist/chunk-6EES4C7J.js +14 -0
  87. package/dist/{chunk-MU4ACHQU.js.map → chunk-6EES4C7J.js.map} +1 -1
  88. package/dist/{chunk-SDXKGWMC.js → chunk-6LIGRH4O.js} +5 -5
  89. package/dist/{chunk-SDXKGWMC.js.map → chunk-6LIGRH4O.js.map} +1 -1
  90. package/dist/{chunk-B3Z7WNO5.js → chunk-ANWDPISS.js} +15 -15
  91. package/dist/{chunk-B3Z7WNO5.js.map → chunk-ANWDPISS.js.map} +1 -1
  92. package/dist/{chunk-35B7ACNO.js → chunk-AODO3GFK.js} +3 -3
  93. package/dist/{chunk-35B7ACNO.js.map → chunk-AODO3GFK.js.map} +1 -1
  94. package/dist/{chunk-NQHOKDDF.js → chunk-AVUX6GAG.js} +4 -4
  95. package/dist/{chunk-NQHOKDDF.js.map → chunk-AVUX6GAG.js.map} +1 -1
  96. package/dist/{chunk-POLSCD5O.js → chunk-BHU25UEW.js} +4 -4
  97. package/dist/{chunk-POLSCD5O.js.map → chunk-BHU25UEW.js.map} +1 -1
  98. package/dist/{chunk-JMBO6VHQ.js → chunk-CUX7O42G.js} +3 -3
  99. package/dist/{chunk-JMBO6VHQ.js.map → chunk-CUX7O42G.js.map} +1 -1
  100. package/dist/{chunk-MFL6R2WL.js → chunk-GX3EDS32.js} +6 -6
  101. package/dist/{chunk-MFL6R2WL.js.map → chunk-GX3EDS32.js.map} +1 -1
  102. package/dist/{chunk-JR2NYBZS.js → chunk-GXXWHVLS.js} +5 -5
  103. package/dist/{chunk-JR2NYBZS.js.map → chunk-GXXWHVLS.js.map} +1 -1
  104. package/dist/{chunk-JNCLDK5D.js → chunk-GZKCZ6X7.js} +5 -5
  105. package/dist/{chunk-JNCLDK5D.js.map → chunk-GZKCZ6X7.js.map} +1 -1
  106. package/dist/{chunk-JVKDYZMW.js → chunk-HAV32VZS.js} +3 -3
  107. package/dist/{chunk-JVKDYZMW.js.map → chunk-HAV32VZS.js.map} +1 -1
  108. package/dist/{chunk-232SREMP.js → chunk-HF6RCUMD.js} +4 -4
  109. package/dist/{chunk-232SREMP.js.map → chunk-HF6RCUMD.js.map} +1 -1
  110. package/dist/{chunk-IUZ2IZFK.js → chunk-ICPO2ELD.js} +3 -3
  111. package/dist/{chunk-IUZ2IZFK.js.map → chunk-ICPO2ELD.js.map} +1 -1
  112. package/dist/{chunk-G2UPOKZZ.js → chunk-IFWQTDEY.js} +6 -6
  113. package/dist/{chunk-G2UPOKZZ.js.map → chunk-IFWQTDEY.js.map} +1 -1
  114. package/dist/{chunk-ODNUSQLR.js → chunk-J7BQY4ZK.js} +4 -4
  115. package/dist/{chunk-ODNUSQLR.js.map → chunk-J7BQY4ZK.js.map} +1 -1
  116. package/dist/{chunk-NXJJ3IP3.js → chunk-JDDQHFIW.js} +4 -4
  117. package/dist/{chunk-NXJJ3IP3.js.map → chunk-JDDQHFIW.js.map} +1 -1
  118. package/dist/{chunk-RA6FYDRQ.js → chunk-K34A2LBY.js} +4 -4
  119. package/dist/{chunk-RA6FYDRQ.js.map → chunk-K34A2LBY.js.map} +1 -1
  120. package/dist/{chunk-UIC4FUJM.js → chunk-KRCPBXFJ.js} +4 -4
  121. package/dist/{chunk-UIC4FUJM.js.map → chunk-KRCPBXFJ.js.map} +1 -1
  122. package/dist/{chunk-WD7HOPT5.js → chunk-KZMUU5ZD.js} +3 -3
  123. package/dist/{chunk-WD7HOPT5.js.map → chunk-KZMUU5ZD.js.map} +1 -1
  124. package/dist/{chunk-XJDQHKV6.js → chunk-NK2V2SW5.js} +5 -5
  125. package/dist/{chunk-XJDQHKV6.js.map → chunk-NK2V2SW5.js.map} +1 -1
  126. package/dist/{chunk-AEQ6NRTE.js → chunk-NKLKKZM6.js} +3 -3
  127. package/dist/{chunk-AEQ6NRTE.js.map → chunk-NKLKKZM6.js.map} +1 -1
  128. package/dist/{chunk-JNB2WC5Z.js → chunk-NOB7OWFA.js} +3 -3
  129. package/dist/{chunk-JNB2WC5Z.js.map → chunk-NOB7OWFA.js.map} +1 -1
  130. package/dist/{chunk-WOFJ3WBJ.js → chunk-NYD5Z4RJ.js} +4 -4
  131. package/dist/{chunk-WOFJ3WBJ.js.map → chunk-NYD5Z4RJ.js.map} +1 -1
  132. package/dist/{chunk-YDU4K4M7.js → chunk-OGQXRBCR.js} +41 -5
  133. package/dist/chunk-OGQXRBCR.js.map +1 -0
  134. package/dist/{chunk-55NGYH3V.js → chunk-R2ULWW5T.js} +14 -15
  135. package/dist/chunk-R2ULWW5T.js.map +1 -0
  136. package/dist/{chunk-PU6G2UIX.js → chunk-R3TPJHLI.js} +4 -4
  137. package/dist/{chunk-PU6G2UIX.js.map → chunk-R3TPJHLI.js.map} +1 -1
  138. package/dist/{chunk-FLAJQXOM.js → chunk-RLSYCDI4.js} +3 -3
  139. package/dist/{chunk-FLAJQXOM.js.map → chunk-RLSYCDI4.js.map} +1 -1
  140. package/dist/{chunk-GJXCHLKY.js → chunk-S7JSNUU2.js} +3 -3
  141. package/dist/{chunk-GJXCHLKY.js.map → chunk-S7JSNUU2.js.map} +1 -1
  142. package/dist/{chunk-UFOSIY3P.js → chunk-T26Y47JL.js} +4 -4
  143. package/dist/{chunk-UFOSIY3P.js.map → chunk-T26Y47JL.js.map} +1 -1
  144. package/dist/{chunk-K3WTFB6A.js → chunk-T63KKKW2.js} +4 -4
  145. package/dist/{chunk-K3WTFB6A.js.map → chunk-T63KKKW2.js.map} +1 -1
  146. package/dist/{chunk-5EPR726Z.js → chunk-UQAUDOI7.js} +7 -7
  147. package/dist/{chunk-5EPR726Z.js.map → chunk-UQAUDOI7.js.map} +1 -1
  148. package/dist/{chunk-RLNBEDA4.js → chunk-VRV5F6G7.js} +3 -3
  149. package/dist/{chunk-RLNBEDA4.js.map → chunk-VRV5F6G7.js.map} +1 -1
  150. package/dist/{chunk-RQOCJRHY.js → chunk-WPHI6Q6N.js} +4 -4
  151. package/dist/{chunk-RQOCJRHY.js.map → chunk-WPHI6Q6N.js.map} +1 -1
  152. package/dist/{chunk-MJGW6YZQ.js → chunk-X7P2WSNU.js} +3 -3
  153. package/dist/{chunk-MJGW6YZQ.js.map → chunk-X7P2WSNU.js.map} +1 -1
  154. package/dist/{chunk-POATRFUM.js → chunk-YGDAYFQY.js} +3 -3
  155. package/dist/{chunk-POATRFUM.js.map → chunk-YGDAYFQY.js.map} +1 -1
  156. package/dist/{chunk-RL4VZU3P.js → chunk-YGSU36MZ.js} +3 -3
  157. package/dist/{chunk-RL4VZU3P.js.map → chunk-YGSU36MZ.js.map} +1 -1
  158. package/dist/{chunk-SHHF6XXL.js → chunk-ZOZLNUNA.js} +31 -34
  159. package/dist/chunk-ZOZLNUNA.js.map +1 -0
  160. package/dist/components/cart/index.js +1 -1
  161. package/dist/components/common/index.js +1 -1
  162. package/dist/components/drawer/index.js +11 -11
  163. package/dist/components/home/index.js +14 -14
  164. package/dist/components/layout/index.js +5 -5
  165. package/dist/components/product/index.js +12 -12
  166. package/dist/components/store/index.js +13 -13
  167. package/dist/document-class-SX2LHILG.js +25 -0
  168. package/dist/{document-class-QLK3MMHA.js.map → document-class-SX2LHILG.js.map} +1 -1
  169. package/dist/hooks/index.js +11 -11
  170. package/dist/hooks/useGtm.js +11 -11
  171. package/dist/hooks/useMoney.js +11 -11
  172. package/dist/hooks/useStore.js +11 -11
  173. package/dist/hooks/useUser.js +5 -5
  174. package/dist/index.js +11 -11
  175. package/dist/{navigation-ZRCCK54S.js → navigation-7WGWEDLB.js} +4 -4
  176. package/dist/{navigation-ZRCCK54S.js.map → navigation-7WGWEDLB.js.map} +1 -1
  177. package/dist/{navigation-7ZIYPM45.js → navigation-Z6JMJ4FZ.js} +5 -5
  178. package/dist/{navigation-7ZIYPM45.js.map → navigation-Z6JMJ4FZ.js.map} +1 -1
  179. package/dist/{not-found-M6PIZHJW.js → not-found-CDXSWL7T.js} +14 -14
  180. package/dist/{not-found-M6PIZHJW.js.map → not-found-CDXSWL7T.js.map} +1 -1
  181. package/dist/providers/index.js +11 -11
  182. package/dist/routes/account/orders.js +6 -6
  183. package/dist/routes/account.js +15 -15
  184. package/dist/routes/blog.js +10 -10
  185. package/dist/routes/brands.js +6 -6
  186. package/dist/routes/cart.js +19 -19
  187. package/dist/routes/home.js +16 -16
  188. package/dist/routes/index.js +3 -3
  189. package/dist/routes/loyalty.js +6 -6
  190. package/dist/routes/page.js +6 -6
  191. package/dist/routes/product-listing.js +16 -16
  192. package/dist/routes/product.js +14 -14
  193. package/dist/routes/seo-redirects.js +3 -3
  194. package/dist/routes/testimonials.js +2 -2
  195. package/dist/routes/thank-you.js +6 -6
  196. package/dist/skeleton.js +16 -16
  197. package/dist/tanstack/router.d.ts.map +1 -1
  198. package/dist/tanstack.js +15 -15
  199. package/dist/twilight/context.d.ts.map +1 -1
  200. package/dist/utils/index.js +4 -4
  201. package/dist/vite/index.js +2 -2
  202. package/package.json +1 -1
  203. package/dist/chunk-55NGYH3V.js.map +0 -1
  204. package/dist/chunk-MU4ACHQU.js +0 -14
  205. package/dist/chunk-SHHF6XXL.js.map +0 -1
  206. package/dist/chunk-YDU4K4M7.js.map +0 -1
  207. package/dist/document-class-QLK3MMHA.js +0 -25
@@ -1,6 +1,6 @@
1
1
  import { RouteId } from './chunk-TFB3QXYH.js';
2
2
  import { withoutStoreUrlBase } from './chunk-XTMHHLNK.js';
3
- import { subscribeTwilight, getTwilightContext } from './chunk-YDU4K4M7.js';
3
+ import { subscribeTwilight, getTwilightContext } from './chunk-OGQXRBCR.js';
4
4
  import { useTwilight } from './chunk-DF6FBKDN.js';
5
5
  import { createContext, createElement, useContext, useSyncExternalStore, useRef, useEffect, useCallback } from 'react';
6
6
 
@@ -241,5 +241,5 @@ function useNavigationInterceptor(navigate, storeUrl, username) {
241
241
  }
242
242
 
243
243
  export { NavigationInterceptor, NavigationProvider, NotFoundError, RedirectError, UnauthorizedError, configureNavigation, defaultNavigate, notFound, orThrow, orUnauthorized, redirect, unauthorized, useIsBlog, useIsBrands, useIsCart, useIsCustomer, useIsHome, useIsProduct, useIsSearch, useLocation, useNavigate, useRouteId };
244
- //# sourceMappingURL=chunk-FLAJQXOM.js.map
245
- //# sourceMappingURL=chunk-FLAJQXOM.js.map
244
+ //# sourceMappingURL=chunk-RLSYCDI4.js.map
245
+ //# sourceMappingURL=chunk-RLSYCDI4.js.map
@@ -1 +1 @@
1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Aa,EAAE,OAAA,EAAS,MAAM,CAAA;AACpE,MAAA,QAAA,CAAS,mBAAA,CAAoB,eAAe,iBAAiB,CAAA;AAC7D,MAAA,QAAA,CAAS,mBAAA,CAAoB,aAAa,eAAe,CAAA;AACzD,MAAA,IAAI,aAAA,EAAe;AACjB,QAAA,IAAI;AACF,UAAA,MAAA,CAAO,SAAS,MAAA,GAAS,UAAA;AAAA,QAC3B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AACA,MAAA,IAAI,cAAA,EAAgB;AAClB,QAAA,IAAI;AACF,UAAA,MAAA,CAAO,SAAS,OAAA,GAAU,WAAA;AAAA,QAC5B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AAClB","file":"chunk-FLAJQXOM.js","sourcesContent":["import {\n createElement,\n createContext,\n useContext,\n useCallback,\n useRef,\n useEffect,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { useTwilight } from './twilight-context';\nimport { getTwilightContext, subscribeTwilight, type TwilightLocation } from '../twilight/context';\nimport { RouteId } from '../router/route-ids';\nimport { withoutStoreUrlBase } from '../utils/store-base';\n\n// Re-export RouteId from centralized location\nexport { RouteId } from '../router/route-ids';\nexport type { RouteIdType } from '../router/route-ids';\n\n// Re-export TwilightLocation as Location for convenience\nexport type { TwilightLocation as Location } from '../twilight/context';\n\nexport type NavigateOptions = { replace?: boolean };\nexport type NavigateFn = (to: string, opts?: NavigateOptions) => void;\n\n/** Redirect error - thrown to trigger a redirect */\nexport class RedirectError extends Error {\n constructor(\n public path: string,\n public replace = false\n ) {\n super(`Redirect to ${path}`);\n this.name = 'RedirectError';\n }\n}\n\n/** NotFound error - thrown to trigger 404 */\nexport class NotFoundError extends Error {\n constructor(message?: string) {\n super(message ?? 'Not Found');\n this.name = 'NotFoundError';\n }\n}\n\n/** Unauthorized error - thrown to trigger 401 */\nexport class UnauthorizedError extends Error {\n constructor(message?: string) {\n super(message ?? 'Unauthorized');\n this.name = 'UnauthorizedError';\n }\n}\n\nexport { SettingsError } from '../utils/errors';\n\nexport const defaultNavigate: NavigateFn = (to, opts) => {\n if (opts?.replace) window.location.replace(to);\n else window.location.href = to;\n};\n\n/** Default redirect - throws RedirectError with browser navigation as fallback */\nexport const defaultRedirect = (path: string, opts?: { replace?: boolean }): never => {\n const replace = opts?.replace ?? false;\n\n // In browser, perform actual navigation before throwing\n if (typeof window !== 'undefined') {\n if (replace) window.location.replace(path);\n else window.location.href = path;\n }\n\n throw new RedirectError(path, replace);\n};\n\n/** Default notFound - throws generic error */\nexport const defaultNotFound = (message?: string): never => {\n throw new NotFoundError(message);\n};\n\n/** Default unauthorized - throws generic error */\nexport const defaultUnauthorized = (message?: string): never => {\n throw new UnauthorizedError(message);\n};\n\n// ─── Framework-agnostic functions for loaders (outside React context) ──────\n\n/**\n * Throw a notFound error. Use in route loaders.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * // In loader\n * import { notFound } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!data) throw notFound();\n * ```\n */\nexport let notFound = defaultNotFound;\n\n/**\n * Throw an unauthorized error. Use in route loaders to protect authenticated routes.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * import { unauthorized } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!user) throw unauthorized();\n * ```\n */\nexport let unauthorized = defaultUnauthorized;\n\n/**\n * Throw a redirect. Use in route loaders.\n * Framework adapters will override this to throw framework-specific redirects.\n *\n * @param path - Path to redirect to\n * @param opts - Redirect options\n *\n * @example\n * ```ts\n * // In loader\n * import { redirect } from '@salla.sa/twilight-theme-engine/providers';\n *\n * throw redirect('/ar/cart');\n * ```\n */\nexport let redirect = defaultRedirect;\n\n/**\n * Configure navigation functions for a specific framework.\n * Called by framework adapters during setup.\n */\nexport function configureNavigation(config: {\n notFound?: (message?: string) => never;\n redirect?: (path: string, opts?: { replace?: boolean }) => never;\n unauthorized?: (_message?: string) => never;\n}): void {\n if (config.notFound) notFound = config.notFound;\n if (config.redirect) redirect = config.redirect;\n if (config.unauthorized) unauthorized = config.unauthorized;\n}\n\n// ─── Loader Error Handling Helpers ─────────────────────────────────────────────\n\n/**\n * Wraps an API promise with error handling for route loaders.\n * On any error, logs debug info and throws notFound() for clean UX.\n *\n * @example\n * ```ts\n * findOrThrow: (id, locale) => orThrow(product.find(id, locale)),\n * const data = await product.findOrThrow(id, locale);\n * ```\n */\nexport async function orThrow<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n console.debug('[loader error]', error);\n throw new NotFoundError();\n }\n}\n\n/**\n * Wraps an API promise with error handling for authenticated route loaders.\n * On a 401/403 response throws unauthorized(); other errors propagate.\n *\n * @example\n * ```ts\n * const data = await orUnauthorized(order.find(id, locale));\n * ```\n */\nexport async function orUnauthorized<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n if (status === 401 || status === 403) {\n throw unauthorized();\n }\n throw error;\n }\n}\n\n// ─── Navigation Context ──────────────────────────────────────────────────────\n\ninterface NavigationContextValue {\n navigate: NavigateFn;\n}\n\nconst NavigationContext = createContext<NavigationContextValue>({\n navigate: defaultNavigate,\n});\n\nexport function NavigationProvider({\n navigate,\n children,\n}: {\n navigate: NavigateFn;\n children: ReactNode;\n}) {\n return createElement(NavigationContext.Provider, { value: { navigate } }, children);\n}\n\n// ─── Primary Hooks (High Compatibility) ───────────────────────────────────────\n\n/**\n * Get the navigate function.\n * Matches React Router, TanStack Router, and Remix naming convention.\n *\n * @returns Navigate function\n *\n * @example\n * ```tsx\n * const navigate = useNavigate();\n * navigate('/cart');\n * navigate('/cart', { replace: true });\n * ```\n */\nexport function useNavigate(): NavigateFn {\n return useContext(NavigationContext).navigate;\n}\n\n/**\n * Get the current route ID.\n * Used for route detection (isHome, isProduct, etc.)\n *\n * @returns Current route ID string\n *\n * @example\n * ```tsx\n * const routeId = useRouteId();\n * if (routeId === RouteId.INDEX) { ... }\n * ```\n */\nexport function useRouteId(): string {\n return useSyncExternalStore(\n subscribeTwilight,\n () => getTwilightContext().routeId,\n () => getTwilightContext().routeId\n );\n}\n\n/**\n * Get the current location (TanStack Router compatible).\n * Reads from the router context for SSR compatibility.\n *\n * @returns Location object matching TanStack's ParsedLocation\n *\n * @example\n * ```tsx\n * const location = useLocation();\n * console.log(location.pathname); // '/ar/products'\n * console.log(location.searchStr); // '?q=shoes&page=2'\n * console.log(location.search); // { q: 'shoes', page: '2' }\n * console.log(location.href); // 'https://store.com/ar/products?q=shoes'\n * console.log(location.hash); // '#section-1'\n * console.log(location.state); // { scrollY: 100 }\n * ```\n */\nexport function useLocation<TSearch = Record<string, unknown>>(): TwilightLocation<TSearch> {\n useTwilight();\n return getTwilightContext().location as TwilightLocation<TSearch>;\n}\n\n// ─── Selector Hooks ───────────────────────────────────────────────────────────\n\n/**\n * Check if current page is homepage */\nexport function useIsHome(): boolean {\n return useRouteId() === RouteId.INDEX;\n}\n\n/** Check if current page is product detail */\nexport function useIsProduct(): boolean {\n return useRouteId() === RouteId.PRODUCT_SINGLE;\n}\n\n/** Check if current page is cart */\nexport function useIsCart(): boolean {\n return useRouteId() === RouteId.CART;\n}\n\n/** Check if current page is in customer area */\nexport function useIsCustomer(): boolean {\n return useRouteId().startsWith('customer');\n}\n\n/** Check if current page is blog related */\nexport function useIsBlog(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BLOG_INDEX || routeId === RouteId.BLOG_SINGLE;\n}\n\n/** Check if current page is brands related */\nexport function useIsBrands(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BRANDS_INDEX || routeId === RouteId.BRANDS_SINGLE;\n}\n\n/** Check if current page is search */\nexport function useIsSearch(): boolean {\n return useRouteId() === RouteId.SEARCH;\n}\n\n// ─── Navigation Interceptor ──────────────────────────────────────────────────\n\n/**\n * NavigationInterceptor - Framework-agnostic SPA navigation interceptor.\n *\n * Uses navigate function from NavigationProvider context and store URL\n * from TwilightProvider to intercept same-origin navigations.\n */\nexport function NavigationInterceptor(): null {\n const navigate = useNavigate();\n const { store } = useTwilight();\n useNavigationInterceptor(navigate, store?.url, store?.username);\n return null;\n}\n\n/**\n * resolveRelativePath - Resolve href to store-relative path\n *\n * Returns `null` when the URL is not on the same origin as the store,\n * keeping this helper safe against open-redirect misuse.\n *\n * The path is the application's, not the address on Salla's host: a store served\n * under its username there (`https://demostore.salla.sa/ar/dev-…/`) hands out links\n * carrying that segment, and it is removed. On a host where the store is the root\n * of every URL, the router adds its own segment back when it navigates.\n *\n * @param href - The URL to resolve\n * @param storeUrl - The store's base URL\n * @param username - The store's username, which tells that segment apart from a\n * locale spelled the same way (see `withoutStoreUrlBase`)\n * @returns The relative path string, or null if the URL is external\n */\nexport function resolveRelativePath(\n href: string,\n storeUrl: string,\n username?: string | null\n): string | null {\n try {\n const target = new URL(href, window.location.href);\n const base = new URL(storeUrl);\n\n if (target.origin !== base.origin) return null;\n\n const pathname = withoutStoreUrlBase(target.pathname, base.pathname, username);\n const path = pathname + target.search + target.hash;\n return path || '/';\n } catch {\n return null;\n }\n}\n\n/**\n * EXTERNAL_TARGETS - Target attribute values that indicate external navigation\n */\nconst EXTERNAL_TARGETS = new Set(['_blank', '_parent', '_top']);\n\n/**\n * shouldIntercept - Determine if an anchor click should be intercepted by SPA router\n *\n * Follows browser conventions: modifier keys, external targets, downloads,\n * and non-HTTP(S) protocols are left to the browser's default behavior.\n *\n * @param anchor - The anchor element that was clicked\n * @param event - The click event\n * @returns true if the click should be intercepted by the router\n */\nexport function shouldIntercept(anchor: HTMLAnchorElement, event: MouseEvent): boolean {\n if (event.defaultPrevented) return false;\n\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return false;\n\n const targetAttr = anchor.getAttribute('target');\n if (targetAttr && EXTERNAL_TARGETS.has(targetAttr)) return false;\n\n if (anchor.hasAttribute('download')) return false;\n\n const rel = (anchor.getAttribute('rel') ?? '').split(/\\s+/);\n if (rel.includes('external')) return false;\n\n const href = anchor.getAttribute('href') ?? '';\n if (!href) return false;\n\n try {\n const url = new URL(href, window.location.href);\n if (url.protocol.startsWith('javascript:')) return false;\n } catch {\n return false;\n }\n\n return true;\n}\n\n// ─── Navigation Interceptor Hook (framework-agnostic) ─────────────────────────\n\n/**\n * Hook for navigation interception using framework-agnostic navigate function.\n * Framework adapters call this with their navigate implementation.\n */\nexport function useNavigationInterceptor(\n navigate: NavigateFn,\n storeUrl: string | undefined,\n username?: string\n): void {\n const storeUrlRef = useRef<string | undefined>(storeUrl);\n const usernameRef = useRef<string | undefined>(username);\n\n useEffect(() => {\n storeUrlRef.current = storeUrl;\n usernameRef.current = username;\n }, [storeUrl, username]);\n\n const tryNavigate = useCallback(\n (href: string, replace = false): boolean => {\n const currentStoreUrl = storeUrlRef.current;\n if (!currentStoreUrl) return false;\n\n const relativePath = resolveRelativePath(href, currentStoreUrl, usernameRef.current);\n if (!relativePath) return false;\n\n navigate(relativePath, { replace });\n return true;\n },\n [navigate]\n );\n\n useEffect(() => {\n // ── Pointer movement tracking ────────────────────────────────────────────\n // Detect drag/scroll gestures to avoid intercepting clicks from swipes.\n let pointerStartX = 0;\n let pointerStartY = 0;\n let pointerSwiped = false;\n const MOVE_THRESHOLD = 10;\n\n function handlePointerDown(event: PointerEvent): void {\n pointerStartX = event.clientX;\n pointerStartY = event.clientY;\n pointerSwiped = false;\n }\n\n function handlePointerUp(event: PointerEvent): void {\n const dx = Math.abs(event.clientX - pointerStartX);\n const dy = Math.abs(event.clientY - pointerStartY);\n pointerSwiped = dx > MOVE_THRESHOLD || dy > MOVE_THRESHOLD;\n }\n\n // ── Anchor click interception ────────────────────────────────────────────\n function handleClick(event: MouseEvent): void {\n // Ignore clicks that resulted from swipe/drag gestures.\n if (pointerSwiped) {\n pointerSwiped = false;\n return;\n }\n\n const path = event.composedPath();\n const anchor = path.find((el): el is HTMLAnchorElement => el instanceof HTMLAnchorElement);\n\n if (!anchor || !shouldIntercept(anchor, event)) return;\n\n if (tryNavigate(anchor.href, false)) {\n event.preventDefault();\n }\n }\n\n // ── window.location.assign patch ─────────────────────────────────────────\n const origAssign = window.location.assign;\n function patchedAssign(url: string): void {\n if (!tryNavigate(url, false)) origAssign.call(window.location, url);\n }\n\n // ── window.location.replace patch ────────────────────────────────────────\n const origReplace = window.location.replace;\n function patchedReplace(url: string): void {\n if (!tryNavigate(url, true)) origReplace.call(window.location, url);\n }\n\n let assignPatched = false;\n let replacePatched = false;\n try {\n window.location.assign = patchedAssign;\n assignPatched = true;\n } catch {\n /* non-writable in this environment */\n }\n try {\n window.location.replace = patchedReplace;\n replacePatched = true;\n } catch {\n /* non-writable in this environment */\n }\n\n document.addEventListener('click', handleClick, { capture: true });\n document.addEventListener('pointerdown', handlePointerDown, { passive: true });\n document.addEventListener('pointerup', handlePointerUp, { passive: true });\n\n return () => {\n document.removeEventListener('click', handleClick, { capture: true });\n document.removeEventListener('pointerdown', handlePointerDown);\n document.removeEventListener('pointerup', handlePointerUp);\n if (assignPatched) {\n try {\n window.location.assign = origAssign;\n } catch {\n /* ignore */\n }\n }\n if (replacePatched) {\n try {\n window.location.replace = origReplace;\n } catch {\n /* ignore */\n }\n }\n };\n }, [tryNavigate]);\n}\n\n// ─── Client navigation config ─────────────────────────────────────────────────\n\nexport interface ClientNav {\n /** Framework adapter to use for client-side navigation. @default 'tanstack' */\n framework?: 'tanstack' | 'nextjs';\n /**\n * Intercept same-origin `<a>` clicks and `window.location` calls from web\n * components and route them through the framework router.\n * @default true\n */\n interceptLinks?: boolean;\n}\n\n// Framework adapter setups are registered in navigation-setups.ts to avoid circular imports.\n"]}
1
+ {"version":3,"sources":["../src/providers/NavigationProvider.ts"],"names":[],"mappings":";;;;;;AA0BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,WAAA,CACS,IAAA,EACA,OAAA,GAAU,KAAA,EACjB;AACA,IA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I,aAAA,EAAe;AACjB,QAAA,IAAI;AACF,UAAA,MAAA,CAAO,SAAS,MAAA,GAAS,UAAA;AAAA,QAC3B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AACA,MAAA,IAAI,cAAA,EAAgB;AAClB,QAAA,IAAI;AACF,UAAA,MAAA,CAAO,SAAS,OAAA,GAAU,WAAA;AAAA,QAC5B,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAW,CAAC,CAAA;AAClB","file":"chunk-RLSYCDI4.js","sourcesContent":["import {\n createElement,\n createContext,\n useContext,\n useCallback,\n useRef,\n useEffect,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { useTwilight } from './twilight-context';\nimport { getTwilightContext, subscribeTwilight, type TwilightLocation } from '../twilight/context';\nimport { RouteId } from '../router/route-ids';\nimport { withoutStoreUrlBase } from '../utils/store-base';\n\n// Re-export RouteId from centralized location\nexport { RouteId } from '../router/route-ids';\nexport type { RouteIdType } from '../router/route-ids';\n\n// Re-export TwilightLocation as Location for convenience\nexport type { TwilightLocation as Location } from '../twilight/context';\n\nexport type NavigateOptions = { replace?: boolean };\nexport type NavigateFn = (to: string, opts?: NavigateOptions) => void;\n\n/** Redirect error - thrown to trigger a redirect */\nexport class RedirectError extends Error {\n constructor(\n public path: string,\n public replace = false\n ) {\n super(`Redirect to ${path}`);\n this.name = 'RedirectError';\n }\n}\n\n/** NotFound error - thrown to trigger 404 */\nexport class NotFoundError extends Error {\n constructor(message?: string) {\n super(message ?? 'Not Found');\n this.name = 'NotFoundError';\n }\n}\n\n/** Unauthorized error - thrown to trigger 401 */\nexport class UnauthorizedError extends Error {\n constructor(message?: string) {\n super(message ?? 'Unauthorized');\n this.name = 'UnauthorizedError';\n }\n}\n\nexport { SettingsError } from '../utils/errors';\n\nexport const defaultNavigate: NavigateFn = (to, opts) => {\n if (opts?.replace) window.location.replace(to);\n else window.location.href = to;\n};\n\n/** Default redirect - throws RedirectError with browser navigation as fallback */\nexport const defaultRedirect = (path: string, opts?: { replace?: boolean }): never => {\n const replace = opts?.replace ?? false;\n\n // In browser, perform actual navigation before throwing\n if (typeof window !== 'undefined') {\n if (replace) window.location.replace(path);\n else window.location.href = path;\n }\n\n throw new RedirectError(path, replace);\n};\n\n/** Default notFound - throws generic error */\nexport const defaultNotFound = (message?: string): never => {\n throw new NotFoundError(message);\n};\n\n/** Default unauthorized - throws generic error */\nexport const defaultUnauthorized = (message?: string): never => {\n throw new UnauthorizedError(message);\n};\n\n// ─── Framework-agnostic functions for loaders (outside React context) ──────\n\n/**\n * Throw a notFound error. Use in route loaders.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * // In loader\n * import { notFound } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!data) throw notFound();\n * ```\n */\nexport let notFound = defaultNotFound;\n\n/**\n * Throw an unauthorized error. Use in route loaders to protect authenticated routes.\n * Framework adapters will override this to throw framework-specific errors.\n *\n * @example\n * ```ts\n * import { unauthorized } from '@salla.sa/twilight-theme-engine/providers';\n *\n * if (!user) throw unauthorized();\n * ```\n */\nexport let unauthorized = defaultUnauthorized;\n\n/**\n * Throw a redirect. Use in route loaders.\n * Framework adapters will override this to throw framework-specific redirects.\n *\n * @param path - Path to redirect to\n * @param opts - Redirect options\n *\n * @example\n * ```ts\n * // In loader\n * import { redirect } from '@salla.sa/twilight-theme-engine/providers';\n *\n * throw redirect('/ar/cart');\n * ```\n */\nexport let redirect = defaultRedirect;\n\n/**\n * Configure navigation functions for a specific framework.\n * Called by framework adapters during setup.\n */\nexport function configureNavigation(config: {\n notFound?: (message?: string) => never;\n redirect?: (path: string, opts?: { replace?: boolean }) => never;\n unauthorized?: (_message?: string) => never;\n}): void {\n if (config.notFound) notFound = config.notFound;\n if (config.redirect) redirect = config.redirect;\n if (config.unauthorized) unauthorized = config.unauthorized;\n}\n\n// ─── Loader Error Handling Helpers ─────────────────────────────────────────────\n\n/**\n * Wraps an API promise with error handling for route loaders.\n * On any error, logs debug info and throws notFound() for clean UX.\n *\n * @example\n * ```ts\n * findOrThrow: (id, locale) => orThrow(product.find(id, locale)),\n * const data = await product.findOrThrow(id, locale);\n * ```\n */\nexport async function orThrow<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n console.debug('[loader error]', error);\n throw new NotFoundError();\n }\n}\n\n/**\n * Wraps an API promise with error handling for authenticated route loaders.\n * On a 401/403 response throws unauthorized(); other errors propagate.\n *\n * @example\n * ```ts\n * const data = await orUnauthorized(order.find(id, locale));\n * ```\n */\nexport async function orUnauthorized<T>(promise: Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error) {\n const status = (error as unknown as { response?: { status?: number } })?.response?.status;\n if (status === 401 || status === 403) {\n throw unauthorized();\n }\n throw error;\n }\n}\n\n// ─── Navigation Context ──────────────────────────────────────────────────────\n\ninterface NavigationContextValue {\n navigate: NavigateFn;\n}\n\nconst NavigationContext = createContext<NavigationContextValue>({\n navigate: defaultNavigate,\n});\n\nexport function NavigationProvider({\n navigate,\n children,\n}: {\n navigate: NavigateFn;\n children: ReactNode;\n}) {\n return createElement(NavigationContext.Provider, { value: { navigate } }, children);\n}\n\n// ─── Primary Hooks (High Compatibility) ───────────────────────────────────────\n\n/**\n * Get the navigate function.\n * Matches React Router, TanStack Router, and Remix naming convention.\n *\n * @returns Navigate function\n *\n * @example\n * ```tsx\n * const navigate = useNavigate();\n * navigate('/cart');\n * navigate('/cart', { replace: true });\n * ```\n */\nexport function useNavigate(): NavigateFn {\n return useContext(NavigationContext).navigate;\n}\n\n/**\n * Get the current route ID.\n * Used for route detection (isHome, isProduct, etc.)\n *\n * @returns Current route ID string\n *\n * @example\n * ```tsx\n * const routeId = useRouteId();\n * if (routeId === RouteId.INDEX) { ... }\n * ```\n */\nexport function useRouteId(): string {\n return useSyncExternalStore(\n subscribeTwilight,\n () => getTwilightContext().routeId,\n () => getTwilightContext().routeId\n );\n}\n\n/**\n * Get the current location (TanStack Router compatible).\n * Reads from the router context for SSR compatibility.\n *\n * @returns Location object matching TanStack's ParsedLocation\n *\n * @example\n * ```tsx\n * const location = useLocation();\n * console.log(location.pathname); // '/ar/products'\n * console.log(location.searchStr); // '?q=shoes&page=2'\n * console.log(location.search); // { q: 'shoes', page: '2' }\n * console.log(location.href); // 'https://store.com/ar/products?q=shoes'\n * console.log(location.hash); // '#section-1'\n * console.log(location.state); // { scrollY: 100 }\n * ```\n */\nexport function useLocation<TSearch = Record<string, unknown>>(): TwilightLocation<TSearch> {\n useTwilight();\n return getTwilightContext().location as TwilightLocation<TSearch>;\n}\n\n// ─── Selector Hooks ───────────────────────────────────────────────────────────\n\n/**\n * Check if current page is homepage */\nexport function useIsHome(): boolean {\n return useRouteId() === RouteId.INDEX;\n}\n\n/** Check if current page is product detail */\nexport function useIsProduct(): boolean {\n return useRouteId() === RouteId.PRODUCT_SINGLE;\n}\n\n/** Check if current page is cart */\nexport function useIsCart(): boolean {\n return useRouteId() === RouteId.CART;\n}\n\n/** Check if current page is in customer area */\nexport function useIsCustomer(): boolean {\n return useRouteId().startsWith('customer');\n}\n\n/** Check if current page is blog related */\nexport function useIsBlog(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BLOG_INDEX || routeId === RouteId.BLOG_SINGLE;\n}\n\n/** Check if current page is brands related */\nexport function useIsBrands(): boolean {\n const routeId = useRouteId();\n return routeId === RouteId.BRANDS_INDEX || routeId === RouteId.BRANDS_SINGLE;\n}\n\n/** Check if current page is search */\nexport function useIsSearch(): boolean {\n return useRouteId() === RouteId.SEARCH;\n}\n\n// ─── Navigation Interceptor ──────────────────────────────────────────────────\n\n/**\n * NavigationInterceptor - Framework-agnostic SPA navigation interceptor.\n *\n * Uses navigate function from NavigationProvider context and store URL\n * from TwilightProvider to intercept same-origin navigations.\n */\nexport function NavigationInterceptor(): null {\n const navigate = useNavigate();\n const { store } = useTwilight();\n useNavigationInterceptor(navigate, store?.url, store?.username);\n return null;\n}\n\n/**\n * resolveRelativePath - Resolve href to store-relative path\n *\n * Returns `null` when the URL is not on the same origin as the store,\n * keeping this helper safe against open-redirect misuse.\n *\n * The path is the application's, not the address on Salla's host: a store served\n * under its username there (`https://demostore.salla.sa/ar/dev-…/`) hands out links\n * carrying that segment, and it is removed. On a host where the store is the root\n * of every URL, the router adds its own segment back when it navigates.\n *\n * @param href - The URL to resolve\n * @param storeUrl - The store's base URL\n * @param username - The store's username, which tells that segment apart from a\n * locale spelled the same way (see `withoutStoreUrlBase`)\n * @returns The relative path string, or null if the URL is external\n */\nexport function resolveRelativePath(\n href: string,\n storeUrl: string,\n username?: string | null\n): string | null {\n try {\n const target = new URL(href, window.location.href);\n const base = new URL(storeUrl);\n\n if (target.origin !== base.origin) return null;\n\n const pathname = withoutStoreUrlBase(target.pathname, base.pathname, username);\n const path = pathname + target.search + target.hash;\n return path || '/';\n } catch {\n return null;\n }\n}\n\n/**\n * EXTERNAL_TARGETS - Target attribute values that indicate external navigation\n */\nconst EXTERNAL_TARGETS = new Set(['_blank', '_parent', '_top']);\n\n/**\n * shouldIntercept - Determine if an anchor click should be intercepted by SPA router\n *\n * Follows browser conventions: modifier keys, external targets, downloads,\n * and non-HTTP(S) protocols are left to the browser's default behavior.\n *\n * @param anchor - The anchor element that was clicked\n * @param event - The click event\n * @returns true if the click should be intercepted by the router\n */\nexport function shouldIntercept(anchor: HTMLAnchorElement, event: MouseEvent): boolean {\n if (event.defaultPrevented) return false;\n\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return false;\n\n const targetAttr = anchor.getAttribute('target');\n if (targetAttr && EXTERNAL_TARGETS.has(targetAttr)) return false;\n\n if (anchor.hasAttribute('download')) return false;\n\n const rel = (anchor.getAttribute('rel') ?? '').split(/\\s+/);\n if (rel.includes('external')) return false;\n\n const href = anchor.getAttribute('href') ?? '';\n if (!href) return false;\n\n try {\n const url = new URL(href, window.location.href);\n if (url.protocol.startsWith('javascript:')) return false;\n } catch {\n return false;\n }\n\n return true;\n}\n\n// ─── Navigation Interceptor Hook (framework-agnostic) ─────────────────────────\n\n/**\n * Hook for navigation interception using framework-agnostic navigate function.\n * Framework adapters call this with their navigate implementation.\n */\nexport function useNavigationInterceptor(\n navigate: NavigateFn,\n storeUrl: string | undefined,\n username?: string\n): void {\n const storeUrlRef = useRef<string | undefined>(storeUrl);\n const usernameRef = useRef<string | undefined>(username);\n\n useEffect(() => {\n storeUrlRef.current = storeUrl;\n usernameRef.current = username;\n }, [storeUrl, username]);\n\n const tryNavigate = useCallback(\n (href: string, replace = false): boolean => {\n const currentStoreUrl = storeUrlRef.current;\n if (!currentStoreUrl) return false;\n\n const relativePath = resolveRelativePath(href, currentStoreUrl, usernameRef.current);\n if (!relativePath) return false;\n\n navigate(relativePath, { replace });\n return true;\n },\n [navigate]\n );\n\n useEffect(() => {\n // ── Pointer movement tracking ────────────────────────────────────────────\n // Detect drag/scroll gestures to avoid intercepting clicks from swipes.\n let pointerStartX = 0;\n let pointerStartY = 0;\n let pointerSwiped = false;\n const MOVE_THRESHOLD = 10;\n\n function handlePointerDown(event: PointerEvent): void {\n pointerStartX = event.clientX;\n pointerStartY = event.clientY;\n pointerSwiped = false;\n }\n\n function handlePointerUp(event: PointerEvent): void {\n const dx = Math.abs(event.clientX - pointerStartX);\n const dy = Math.abs(event.clientY - pointerStartY);\n pointerSwiped = dx > MOVE_THRESHOLD || dy > MOVE_THRESHOLD;\n }\n\n // ── Anchor click interception ────────────────────────────────────────────\n function handleClick(event: MouseEvent): void {\n // Ignore clicks that resulted from swipe/drag gestures.\n if (pointerSwiped) {\n pointerSwiped = false;\n return;\n }\n\n const path = event.composedPath();\n const anchor = path.find((el): el is HTMLAnchorElement => el instanceof HTMLAnchorElement);\n\n if (!anchor || !shouldIntercept(anchor, event)) return;\n\n if (tryNavigate(anchor.href, false)) {\n event.preventDefault();\n }\n }\n\n // ── window.location.assign patch ─────────────────────────────────────────\n const origAssign = window.location.assign;\n function patchedAssign(url: string): void {\n if (!tryNavigate(url, false)) origAssign.call(window.location, url);\n }\n\n // ── window.location.replace patch ────────────────────────────────────────\n const origReplace = window.location.replace;\n function patchedReplace(url: string): void {\n if (!tryNavigate(url, true)) origReplace.call(window.location, url);\n }\n\n let assignPatched = false;\n let replacePatched = false;\n try {\n window.location.assign = patchedAssign;\n assignPatched = true;\n } catch {\n /* non-writable in this environment */\n }\n try {\n window.location.replace = patchedReplace;\n replacePatched = true;\n } catch {\n /* non-writable in this environment */\n }\n\n document.addEventListener('click', handleClick, { capture: true });\n document.addEventListener('pointerdown', handlePointerDown, { passive: true });\n document.addEventListener('pointerup', handlePointerUp, { passive: true });\n\n return () => {\n document.removeEventListener('click', handleClick, { capture: true });\n document.removeEventListener('pointerdown', handlePointerDown);\n document.removeEventListener('pointerup', handlePointerUp);\n if (assignPatched) {\n try {\n window.location.assign = origAssign;\n } catch {\n /* ignore */\n }\n }\n if (replacePatched) {\n try {\n window.location.replace = origReplace;\n } catch {\n /* ignore */\n }\n }\n };\n }, [tryNavigate]);\n}\n\n// ─── Client navigation config ─────────────────────────────────────────────────\n\nexport interface ClientNav {\n /** Framework adapter to use for client-side navigation. @default 'tanstack' */\n framework?: 'tanstack' | 'nextjs';\n /**\n * Intercept same-origin `<a>` clicks and `window.location` calls from web\n * components and route them through the framework router.\n * @default true\n */\n interceptLinks?: boolean;\n}\n\n// Framework adapter setups are registered in navigation-setups.ts to avoid circular imports.\n"]}
@@ -1,4 +1,4 @@
1
- import { getTwilightContext } from './chunk-YDU4K4M7.js';
1
+ import { getTwilightContext } from './chunk-OGQXRBCR.js';
2
2
 
3
3
  // src/utils/sdk-events.ts
4
4
  function dispatchRouteChanged() {
@@ -10,5 +10,5 @@ function dispatchRouteChanged() {
10
10
  }
11
11
 
12
12
  export { dispatchRouteChanged };
13
- //# sourceMappingURL=chunk-GJXCHLKY.js.map
14
- //# sourceMappingURL=chunk-GJXCHLKY.js.map
13
+ //# sourceMappingURL=chunk-S7JSNUU2.js.map
14
+ //# sourceMappingURL=chunk-S7JSNUU2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/sdk-events.ts"],"names":[],"mappings":";;;AA0BO,SAAS,oBAAA,GAA6B;AAC3C,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAEnC,EAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,EAAA,IAAI,CAAC,KAAA,EAAO,KAAA,EAAO,QAAA,EAAU;AAE7B,EAAA,MAAM,MAAM,kBAAA,EAAmB;AAC/B,EAAA,KAAA,CAAM,MAAM,QAAA,CAAS,gBAAA,EAAkB,GAAA,CAAI,IAAA,IAAQ,EAAE,CAAA;AACvD","file":"chunk-GJXCHLKY.js","sourcesContent":["import { getTwilightContext } from '../twilight/context';\nimport type { PageContext } from '../twilight/context';\n\n/**\n * Payload dispatched via `salla.event.dispatch('route::changed', payload)`\n * after each client-side navigation completes.\n *\n * The page config fields are spread at root level. When the matched route\n * has no page data (e.g., 404, error boundary), an empty object is dispatched.\n *\n * @example\n * ```ts\n * salla.event.on('route::changed', (page: RouteChangedEvent) => {\n * console.log(page.slug, page.title, page.id);\n * });\n * ```\n */\nexport type RouteChangedEvent = PageContext;\n\n/**\n * Dispatch the `route::changed` Salla SDK event with the current page config.\n *\n * Framework-agnostic — reads from the twilight context store which is\n * populated by whichever framework adapter is active (TanStack, Next.js, etc.).\n * Each adapter should call this after navigation resolves.\n */\nexport function dispatchRouteChanged(): void {\n if (typeof window === 'undefined') return;\n\n const salla = window.salla;\n if (!salla?.event?.dispatch) return;\n\n const ctx = getTwilightContext();\n salla.event.dispatch('route::changed', ctx.page ?? {});\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/sdk-events.ts"],"names":[],"mappings":";;;AA0BO,SAAS,oBAAA,GAA6B;AAC3C,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAEnC,EAAA,MAAM,QAAQ,MAAA,CAAO,KAAA;AACrB,EAAA,IAAI,CAAC,KAAA,EAAO,KAAA,EAAO,QAAA,EAAU;AAE7B,EAAA,MAAM,MAAM,kBAAA,EAAmB;AAC/B,EAAA,KAAA,CAAM,MAAM,QAAA,CAAS,gBAAA,EAAkB,GAAA,CAAI,IAAA,IAAQ,EAAE,CAAA;AACvD","file":"chunk-S7JSNUU2.js","sourcesContent":["import { getTwilightContext } from '../twilight/context';\nimport type { PageContext } from '../twilight/context';\n\n/**\n * Payload dispatched via `salla.event.dispatch('route::changed', payload)`\n * after each client-side navigation completes.\n *\n * The page config fields are spread at root level. When the matched route\n * has no page data (e.g., 404, error boundary), an empty object is dispatched.\n *\n * @example\n * ```ts\n * salla.event.on('route::changed', (page: RouteChangedEvent) => {\n * console.log(page.slug, page.title, page.id);\n * });\n * ```\n */\nexport type RouteChangedEvent = PageContext;\n\n/**\n * Dispatch the `route::changed` Salla SDK event with the current page config.\n *\n * Framework-agnostic — reads from the twilight context store which is\n * populated by whichever framework adapter is active (TanStack, Next.js, etc.).\n * Each adapter should call this after navigation resolves.\n */\nexport function dispatchRouteChanged(): void {\n if (typeof window === 'undefined') return;\n\n const salla = window.salla;\n if (!salla?.event?.dispatch) return;\n\n const ctx = getTwilightContext();\n salla.event.dispatch('route::changed', ctx.page ?? {});\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { api } from './chunk-POLSCD5O.js';
2
- import { getTwilightContext } from './chunk-YDU4K4M7.js';
1
+ import { api } from './chunk-BHU25UEW.js';
2
+ import { getTwilightContext } from './chunk-OGQXRBCR.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var menu = {
@@ -23,5 +23,5 @@ var menu = {
23
23
  };
24
24
 
25
25
  export { menu };
26
- //# sourceMappingURL=chunk-UFOSIY3P.js.map
27
- //# sourceMappingURL=chunk-UFOSIY3P.js.map
26
+ //# sourceMappingURL=chunk-T26Y47JL.js.map
27
+ //# sourceMappingURL=chunk-T26Y47JL.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/menu.ts"],"names":[],"mappings":";;;;AAKO,IAAM,IAAA,GAAO;AAAA,EAClB,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,UAAU,CAAC,OAAA,EAAS,QAAA,EAAU,kBAAA,GAAqB,MAAM,CAAA;AAAA,MACzD,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,EAAO;AAAA,MAC3B,SAAA,EAAW,IAAI,EAAA,GAAK;AAAA,KACrB;AAAA;AAEP","file":"chunk-UFOSIY3P.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport { getTwilightContext } from '../twilight/context';\nimport type { MenuItem } from '../types';\n\nexport const menu = {\n header: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/header?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n footer: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/footer?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n queries: {\n header: () =>\n queryOptions({\n queryKey: ['menus', 'header', getTwilightContext().locale],\n queryFn: () => menu.header(),\n staleTime: 5 * 60 * 1000,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/menu.ts"],"names":[],"mappings":";;;;AAKO,IAAM,IAAA,GAAO;AAAA,EAClB,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,QAAQ,YAAiC;AACvC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,kBAAA,EAAmB;AACtC,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,kBAAA,EAAqB,MAAM,CAAA,CAAE,CAAA,CAAE,IAAA,EAA2B;AACzF,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,UAAU,CAAC,OAAA,EAAS,QAAA,EAAU,kBAAA,GAAqB,MAAM,CAAA;AAAA,MACzD,OAAA,EAAS,MAAM,IAAA,CAAK,MAAA,EAAO;AAAA,MAC3B,SAAA,EAAW,IAAI,EAAA,GAAK;AAAA,KACrB;AAAA;AAEP","file":"chunk-T26Y47JL.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport { getTwilightContext } from '../twilight/context';\nimport type { MenuItem } from '../types';\n\nexport const menu = {\n header: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/header?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n footer: async (): Promise<MenuItem[]> => {\n const { locale } = getTwilightContext();\n const { data } = await api.get(`menus/footer?lang=${locale}`).json<{ data: MenuItem[] }>();\n return data || [];\n },\n\n queries: {\n header: () =>\n queryOptions({\n queryKey: ['menus', 'header', getTwilightContext().locale],\n queryFn: () => menu.header(),\n staleTime: 5 * 60 * 1000,\n }),\n },\n};\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow } from './chunk-FLAJQXOM.js';
2
- import { api } from './chunk-POLSCD5O.js';
1
+ import { orThrow } from './chunk-RLSYCDI4.js';
2
+ import { api } from './chunk-BHU25UEW.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var page = {
@@ -17,5 +17,5 @@ var page = {
17
17
  };
18
18
 
19
19
  export { page };
20
- //# sourceMappingURL=chunk-K3WTFB6A.js.map
21
- //# sourceMappingURL=chunk-K3WTFB6A.js.map
20
+ //# sourceMappingURL=chunk-T63KKKW2.js.map
21
+ //# sourceMappingURL=chunk-T63KKKW2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/page.ts"],"names":[],"mappings":";;;;AAKO,IAAM,IAAA,GAAO;AAAA,EAClB,IAAA,EAAM,OAAO,IAAA,KAA2C;AACtD,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,MAAA,EAAS,IAAI,CAAA,CAAE,CAAA,CAAE,IAAA,EAAgC;AAChF,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,IAAA,KAA2C,QAAQ,IAAA,CAAK,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,EAEhF,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,IAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,OAAA,EAAS,QAAA,EAAU,IAAI,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,IAAA,CAAK,IAAA,CAAK,IAAI;AAAA,KAC9B;AAAA;AAEP","file":"chunk-K3WTFB6A.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { ApiPageResponse } from '../routes/page/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const page = {\n find: async (slug: string): Promise<ApiPageResponse> => {\n const { data } = await api.get(`pages/${slug}`).json<{ data: ApiPageResponse }>();\n return data;\n },\n\n findOrThrow: (slug: string): Promise<ApiPageResponse> => orThrow(page.find(slug)),\n\n queries: {\n detail: (slug: string) =>\n queryOptions({\n queryKey: ['pages', 'detail', slug],\n queryFn: () => page.find(slug),\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/page.ts"],"names":[],"mappings":";;;;AAKO,IAAM,IAAA,GAAO;AAAA,EAClB,IAAA,EAAM,OAAO,IAAA,KAA2C;AACtD,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CAAI,IAAI,CAAA,MAAA,EAAS,IAAI,CAAA,CAAE,CAAA,CAAE,IAAA,EAAgC;AAChF,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,aAAa,CAAC,IAAA,KAA2C,QAAQ,IAAA,CAAK,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,EAEhF,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,CAAC,IAAA,KACP,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,OAAA,EAAS,QAAA,EAAU,IAAI,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,IAAA,CAAK,IAAA,CAAK,IAAI;AAAA,KAC9B;AAAA;AAEP","file":"chunk-T63KKKW2.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { ApiPageResponse } from '../routes/page/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const page = {\n find: async (slug: string): Promise<ApiPageResponse> => {\n const { data } = await api.get(`pages/${slug}`).json<{ data: ApiPageResponse }>();\n return data;\n },\n\n findOrThrow: (slug: string): Promise<ApiPageResponse> => orThrow(page.find(slug)),\n\n queries: {\n detail: (slug: string) =>\n queryOptions({\n queryKey: ['pages', 'detail', slug],\n queryFn: () => page.find(slug),\n }),\n },\n};\n"]}
@@ -1,8 +1,8 @@
1
- import { order } from './chunk-232SREMP.js';
1
+ import { order } from './chunk-HF6RCUMD.js';
2
2
  import { buildHreflangAlternates } from './chunk-TZ3E5BN4.js';
3
- import { orUnauthorized } from './chunk-FLAJQXOM.js';
3
+ import { orUnauthorized } from './chunk-RLSYCDI4.js';
4
4
  import { RouteId } from './chunk-TFB3QXYH.js';
5
- import { getTwilightContext } from './chunk-YDU4K4M7.js';
5
+ import { getTwilightContext } from './chunk-OGQXRBCR.js';
6
6
  import { lazy } from 'react';
7
7
 
8
8
  // src/routes/account/orders/loader.ts
@@ -48,9 +48,9 @@ async function orderSingleLoader({
48
48
  }
49
49
 
50
50
  // src/routes/account/orders/index.tsx
51
- var LazyOrdersPage = lazy(() => import('./OrdersPage-6XMYJQAB.js').then((m) => ({ default: m.OrdersPage })));
51
+ var LazyOrdersPage = lazy(() => import('./OrdersPage-EGIDHSYS.js').then((m) => ({ default: m.OrdersPage })));
52
52
  var LazyOrderSinglePage = lazy(
53
- () => import('./OrderSinglePage-2ME6HVFH.js').then((m) => ({ default: m.OrderSinglePage }))
53
+ () => import('./OrderSinglePage-4CK6OT6U.js').then((m) => ({ default: m.OrderSinglePage }))
54
54
  );
55
55
  var OrdersPage = LazyOrdersPage;
56
56
  var OrderSinglePage = LazyOrderSinglePage;
@@ -102,5 +102,5 @@ var OrderSingle = {
102
102
  };
103
103
 
104
104
  export { OrderSingle, OrderSinglePage, Orders, OrdersPage, orderSingleLoader, ordersLoader };
105
- //# sourceMappingURL=chunk-5EPR726Z.js.map
106
- //# sourceMappingURL=chunk-5EPR726Z.js.map
105
+ //# sourceMappingURL=chunk-UQAUDOI7.js.map
106
+ //# sourceMappingURL=chunk-UQAUDOI7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/routes/account/orders/loader.ts","../src/routes/account/orders/index.tsx"],"names":[],"mappings":";;;;;;;;AAOA,eAAsB,YAAA,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ilight/context';\nimport { RouteId } from '../../../router/route-ids';\nimport { orUnauthorized } from '../../../providers/NavigationProvider';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersQuery } from './types';\nimport type { IdParams } from '../../types';\n\nexport async function ordersLoader(\n ctx: { query?: OrdersQuery; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n const query = ctx.query;\n const isPending = query?.status === 'pending';\n const response = await orUnauthorized(\n order.list({\n status: query?.status,\n feedback_status: query?.feedback_status,\n ...(ctx.with_items ? { with_items: ctx.with_items } : {}),\n })\n );\n const i18n = getTwilightContext().i18n;\n const pageData: OrdersPageProps = {\n page: {\n title: isPending\n ? i18n.t('common.titles.pending_orders') || 'Pending Orders'\n : i18n.t('common.titles.orders') || 'Orders',\n slug: 'orders',\n },\n orders: response.data,\n cursor: response.cursor,\n query,\n };\n\n if (extend) {\n const extra = await extend(pageData, { params: {} });\n return { ...pageData, ...extra } as OrdersPageProps;\n }\n return pageData;\n}\n\nexport async function orderSingleLoader({\n params,\n}: {\n params: IdParams;\n}): Promise<OrderSinglePageProps> {\n const data = await order.findOrThrow(params.id);\n const i18n = getTwilightContext().i18n;\n return {\n page: {\n slug: RouteId.CUSTOMER_ORDERS_SINGLE,\n id: String(params.id),\n title: (i18n.t('pages.orders.order_details') || 'Order Details').replace(':id', params.id),\n },\n order: data.order,\n };\n}\n","import type { HeadDescriptor } from '../../../utils/head';\nimport { buildHreflangAlternates } from '../../../utils/baseHead';\nimport { lazy } from 'react';\nimport { ordersLoader, orderSingleLoader } from './loader';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersSearchParams } from './types';\nimport type { IdParams } from '../../types';\nimport type { TwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\n\n// Lazy-load components for code-splitting\nconst LazyOrdersPage = lazy(() => import('./OrdersPage').then((m) => ({ default: m.OrdersPage })));\nconst LazyOrderSinglePage = lazy(() =>\n import('./OrderSinglePage').then((m) => ({ default: m.OrderSinglePage }))\n);\n\nexport const OrdersPage = LazyOrdersPage;\nexport const OrderSinglePage = LazyOrderSinglePage;\nexport { ordersLoader, orderSingleLoader } from './loader';\nexport type {\n OrdersPageProps,\n OrderSinglePageProps,\n OrdersSearchParams,\n OrdersQuery,\n} from './types';\n\nasync function ordersLoaderWithExtend(\n ctx: { search?: OrdersSearchParams; locale?: string; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n const query = ctx.search;\n const data = await ordersLoader({ query, with_items: ctx.with_items }, extend);\n\n if (extend) {\n const extra = await extend(data, { params: {} });\n return { ...data, ...extra } as OrdersPageProps;\n }\n return data;\n}\n\nfunction ordersHead(ctx: TwilightContext, data: OrdersPageProps): HeadDescriptor {\n const isPending = ctx.location.search?.status === 'pending';\n const base: HeadDescriptor = {\n title: ctx.i18n.t(isPending ? 'common.titles.pending_orders' : 'common.titles.orders'),\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nasync function orderSingleLoaderWithExtend(\n ctx: { params: IdParams; locale?: string },\n extend?: (\n data: OrderSinglePageProps,\n ctx: { params: IdParams }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrderSinglePageProps> {\n const data = await orderSingleLoader({ params: ctx.params });\n\n if (extend) {\n const extra = await extend(data, ctx);\n return { ...data, ...extra } as OrderSinglePageProps;\n }\n return data;\n}\n\nfunction orderSingleHead(ctx: TwilightContext, data: OrderSinglePageProps): HeadDescriptor {\n const base: HeadDescriptor = {\n title: data.page.title,\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nexport const Orders = {\n id: RouteId.CUSTOMER_ORDERS_INDEX,\n loader: ordersLoaderWithExtend,\n head: ordersHead,\n Component: LazyOrdersPage,\n} as const;\nexport const OrderSingle = {\n id: RouteId.CUSTOMER_ORDERS_SINGLE,\n loader: orderSingleLoaderWithExtend,\n head: orderSingleHead,\n Component: LazyOrderSinglePage,\n} as const;\n"]}
1
+ {"version":3,"sources":["../src/routes/account/orders/loader.ts","../src/routes/account/orders/index.tsx"],"names":[],"mappings":";;;;;;;;AAOA,eAAsB,YAAA,CACpB,KACA,MAAA,EAI0B;AAC1B,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA;AAClB,EAAA,MAAM,SAAA,GAAY,OAAO,MAAA,KAAW,SAAA;AACpC,EAAA,MAAM,WAAW,MAAM,cAAA;AAAA,IACrB,MAAM,IAAA,CAAK;AAAA,MACT,QAAQ,KAAA,EAAO,MAAA;AAAA,MACf,iBAAiB,KAAA,EAAO,eAAA;AAAA,MACxB,GAAI,IAAI,UAAA,GAAa,EAAE,YAAY,GAAA,CAAI,UAAA,KAAe;AAAC,KACxD;AAAA,GACH;AACA,EAAA,MAAM,IAAA,GAAO,oBAAmB,CAAE,IAAA;AAClC,EAAA,MAAM,QAAA,GAA4B;AAAA,IAChC,IAAA,EAAM;AAAA,MACJ,KAAA,EAAO,SAAA,GACH,IAAA,CAAK,CAAA,CAAE,8BAA8B,KAAK,gBAAA,GAC1C,IAAA,CAAK,CAAA,CAAE,sBAAsB,CAAA,IAAK,QAAA;AAAA,MACtC,IAAA,EAAM;AAAA,KACR;AAAA,IACA,QAAQ,QAAA,CAAS,IAAA;AAAA,IACjB,QAAQ,QAAA,CAAS,MAAA;AAAA,IACjB;AAAA,GACF;AAEA,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,MAAM,KAAA,GAAQ,MAAM,MAAA,CAAO,QAAA,EAAU,EAAE,MAAA,EAAQ,IAAI,CAAA;AACnD,IAAA,OAAO,EAAE,GAAG,QAAA,EAAU,GAAG,KAAA,EAAM;AAAA,EACjC;AACA,EAAA,OAAO,QAAA;AACT;AAEA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AA,EACR,IAAA,EAAM,UAAA;AAAA,EACN,SAAA,EAAW;AACb;AACO,IAAM,WAAA,GAAc;AAAA,EACzB,IAAI,OAAA,CAAQ,sBAAA;AAAA,EACZ,MAAA,EAAQ,2BAAA;AAAA,EACR,IAAA,EAAM,eAAA;AAAA,EACN,SAAA,EAAW;AACb","file":"chunk-UQAUDOI7.js","sourcesContent":["import { order } from '../../../api/order';\nimport { getTwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\nimport { orUnauthorized } from '../../../providers/NavigationProvider';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersQuery } from './types';\nimport type { IdParams } from '../../types';\n\nexport async function ordersLoader(\n ctx: { query?: OrdersQuery; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n const query = ctx.query;\n const isPending = query?.status === 'pending';\n const response = await orUnauthorized(\n order.list({\n status: query?.status,\n feedback_status: query?.feedback_status,\n ...(ctx.with_items ? { with_items: ctx.with_items } : {}),\n })\n );\n const i18n = getTwilightContext().i18n;\n const pageData: OrdersPageProps = {\n page: {\n title: isPending\n ? i18n.t('common.titles.pending_orders') || 'Pending Orders'\n : i18n.t('common.titles.orders') || 'Orders',\n slug: 'orders',\n },\n orders: response.data,\n cursor: response.cursor,\n query,\n };\n\n if (extend) {\n const extra = await extend(pageData, { params: {} });\n return { ...pageData, ...extra } as OrdersPageProps;\n }\n return pageData;\n}\n\nexport async function orderSingleLoader({\n params,\n}: {\n params: IdParams;\n}): Promise<OrderSinglePageProps> {\n const data = await order.findOrThrow(params.id);\n const i18n = getTwilightContext().i18n;\n return {\n page: {\n slug: RouteId.CUSTOMER_ORDERS_SINGLE,\n id: String(params.id),\n title: (i18n.t('pages.orders.order_details') || 'Order Details').replace(':id', params.id),\n },\n order: data.order,\n };\n}\n","import type { HeadDescriptor } from '../../../utils/head';\nimport { buildHreflangAlternates } from '../../../utils/baseHead';\nimport { lazy } from 'react';\nimport { ordersLoader, orderSingleLoader } from './loader';\nimport type { OrdersPageProps, OrderSinglePageProps, OrdersSearchParams } from './types';\nimport type { IdParams } from '../../types';\nimport type { TwilightContext } from '../../../twilight/context';\nimport { RouteId } from '../../../router/route-ids';\n\n// Lazy-load components for code-splitting\nconst LazyOrdersPage = lazy(() => import('./OrdersPage').then((m) => ({ default: m.OrdersPage })));\nconst LazyOrderSinglePage = lazy(() =>\n import('./OrderSinglePage').then((m) => ({ default: m.OrderSinglePage }))\n);\n\nexport const OrdersPage = LazyOrdersPage;\nexport const OrderSinglePage = LazyOrderSinglePage;\nexport { ordersLoader, orderSingleLoader } from './loader';\nexport type {\n OrdersPageProps,\n OrderSinglePageProps,\n OrdersSearchParams,\n OrdersQuery,\n} from './types';\n\nasync function ordersLoaderWithExtend(\n ctx: { search?: OrdersSearchParams; locale?: string; with_items?: boolean | number },\n extend?: (\n data: OrdersPageProps,\n ctx: { params: Record<string, never> }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrdersPageProps> {\n const query = ctx.search;\n const data = await ordersLoader({ query, with_items: ctx.with_items }, extend);\n\n if (extend) {\n const extra = await extend(data, { params: {} });\n return { ...data, ...extra } as OrdersPageProps;\n }\n return data;\n}\n\nfunction ordersHead(ctx: TwilightContext, data: OrdersPageProps): HeadDescriptor {\n const isPending = ctx.location.search?.status === 'pending';\n const base: HeadDescriptor = {\n title: ctx.i18n.t(isPending ? 'common.titles.pending_orders' : 'common.titles.orders'),\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nasync function orderSingleLoaderWithExtend(\n ctx: { params: IdParams; locale?: string },\n extend?: (\n data: OrderSinglePageProps,\n ctx: { params: IdParams }\n ) => Promise<Record<string, unknown>> | Record<string, unknown>\n): Promise<OrderSinglePageProps> {\n const data = await orderSingleLoader({ params: ctx.params });\n\n if (extend) {\n const extra = await extend(data, ctx);\n return { ...data, ...extra } as OrderSinglePageProps;\n }\n return data;\n}\n\nfunction orderSingleHead(ctx: TwilightContext, data: OrderSinglePageProps): HeadDescriptor {\n const base: HeadDescriptor = {\n title: data.page.title,\n description: data.page.description,\n alternateLanguages: buildHreflangAlternates(ctx.settings, ctx.location.pathname),\n };\n\n return base;\n}\n\nexport const Orders = {\n id: RouteId.CUSTOMER_ORDERS_INDEX,\n loader: ordersLoaderWithExtend,\n head: ordersHead,\n Component: LazyOrdersPage,\n} as const;\nexport const OrderSingle = {\n id: RouteId.CUSTOMER_ORDERS_SINGLE,\n loader: orderSingleLoaderWithExtend,\n head: orderSingleHead,\n Component: LazyOrderSinglePage,\n} as const;\n"]}
@@ -1,5 +1,5 @@
1
1
  import { hostIdentifiesStore, resolveRequestStoreBase, storeBaseRedirectHref } from './chunk-XTMHHLNK.js';
2
- import { getRequestStore } from './chunk-YDU4K4M7.js';
2
+ import { getRequestStore } from './chunk-OGQXRBCR.js';
3
3
 
4
4
  // src/utils/inline-script.ts
5
5
  function escapeForInlineScript(value) {
@@ -97,5 +97,5 @@ function syncSdkLocale(locale) {
97
97
  }
98
98
 
99
99
  export { escapeForInlineScript, getInjectedRuntimeEnv, getSallaSDK, getStoreIdentifier, readEnv, renderRuntimeEnvScript, resolveStoreBase, resolveStoreBaseRedirect, resolveStoreIdentifier, syncSdkLocale };
100
- //# sourceMappingURL=chunk-RLNBEDA4.js.map
101
- //# sourceMappingURL=chunk-RLNBEDA4.js.map
100
+ //# sourceMappingURL=chunk-VRV5F6G7.js.map
101
+ //# sourceMappingURL=chunk-VRV5F6G7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/inline-script.ts","../src/utils/runtime-env.ts","../src/utils/store-identity.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAMO,SAAS,sBAAsB,KAAA,EAAuB;AAC3D,EAAA,OAAO,MACJ,OAAA,CAAQ,IAAA,EAAM,SAAS,CAAA,CACvB,OAA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;AAAA,EAChD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-RLNBEDA4.js","sourcesContent":["/**\n * Escape a JSON-stringified value for safe embedding inside an inline `<script>` body.\n *\n * The head injects script bodies raw, so a `</script>` inside partner-set data would break out\n * of the tag; U+2028/U+2029 are line terminators in JS but not in JSON, so they must go too.\n */\nexport function escapeForInlineScript(value: string): string {\n return value\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n","import { escapeForInlineScript } from './inline-script';\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore } from './cookies';\n\n/** Where `rootHead` publishes the SSR-resolved env for the browser bundle to read. */\nconst RUNTIME_ENV_KEY = '__SALLA_RUNTIME_ENV__';\n\n/** The env values that must agree between the SSR render and the hydrated client. */\nexport interface RuntimeEnv {\n /** Store API base — `VITE_API_URL`. */\n apiBase?: string;\n /** Store identifier — `VITE_STORE_DOMAIN`. */\n storeIdentifier?: string;\n /**\n * The theme-settings version the request named, if any.\n *\n * Published for the same reason `storeIdentifier` is: the dispatcher strips\n * `?versionId=` on the way in, so by the time the browser has the page its own\n * URL no longer says which version it is showing. Without this the hydrated\n * client would ask the API about the store's live version and quietly replace\n * the draft it was handed.\n *\n * Absent — not empty — when nothing named one, so it drops out of the inline\n * script entirely rather than publishing a value that means \"live\".\n */\n versionId?: string;\n /**\n * The store segment at the root of this page's paths, when the store is\n * addressed that way — see `resolveStoreBase`.\n *\n * Published because the browser's address is not always the URL the server\n * read: the dispatcher removes `?storeId=` from the request it forwards but not\n * from the address bar, and a URL carrying it is never read for a segment. The\n * client builds its router from this, and a router that disagreed with the\n * server about the root would hydrate a different page.\n */\n storeBase?: string;\n}\n\n/**\n * A build-time `import.meta.env` var, falling back to the worker's runtime `process.env`\n * (wrangler `vars`, exposed via the `nodejs_compat_populate_process_env` flag).\n */\nexport function readEnv(key: string): string | undefined {\n try {\n const vite = (import.meta as unknown as { env?: Record<string, string | undefined> }).env?.[\n key\n ];\n if (vite) return vite;\n } catch {\n /* import.meta.env not available in all environments */\n }\n return typeof process !== 'undefined' ? process.env?.[key] : undefined;\n}\n\n/**\n * What this runtime resolves from its own env — server-side that includes the worker vars.\n * Prefers what the server already published, so re-rendering the head during hydration yields\n * the same script instead of dropping it.\n */\nexport function resolveRuntimeEnv(): RuntimeEnv {\n const injected = getInjectedRuntimeEnv();\n const { storeId, storeBase, versionId, requestHost } = getRequestStore();\n return {\n apiBase: injected.apiBase || readEnv('VITE_API_URL'),\n // The request outranks the build-time var here for the same reason it does\n // in `resolveStoreIdentifier`, and this is the copy that reaches the\n // browser: publish the store SSR actually rendered, or hydration resolves\n // again from a URL whose `?storeId=` the dispatcher has already stripped and\n // queries a different store than the markup it is hydrating.\n storeIdentifier:\n injected.storeIdentifier ||\n storeId ||\n storeBase ||\n (hostIdentifiesStore(requestHost) ? requestHost : null) ||\n readEnv('VITE_STORE_DOMAIN'),\n // Absent rather than empty when the path named no store, so it drops out of\n // the inline script, like `versionId`.\n storeBase: injected.storeBase || storeBase || undefined,\n // No env fallback on purpose. A store identifier has one because a build can\n // legitimately be pinned to a store; a version is something a request asks\n // for, and a build-time default would make every visitor of every store see\n // whichever draft was current when the theme was compiled.\n versionId: injected.versionId || versionId || undefined,\n };\n}\n\n/**\n * The env the SSR worker resolved, as handed to the browser by `rootHead`. Empty on the server\n * and on a client whose head carried nothing.\n *\n * Worker `vars` are *runtime* env: they live in `process.env` on the server only, while\n * `import.meta.env` is substituted at build time. A bundle built without those vars therefore\n * sees `undefined` in the browser and silently falls back to the production defaults — SSR\n * would render off the configured backend while every post-hydration fetch hits another one.\n */\nexport function getInjectedRuntimeEnv(): RuntimeEnv {\n const holder = globalThis as typeof globalThis & { [RUNTIME_ENV_KEY]?: RuntimeEnv };\n return holder[RUNTIME_ENV_KEY] ?? {};\n}\n\n/**\n * Inline head `<script>` body publishing the server-resolved env, or null when there is nothing\n * to publish (no overrides configured — the defaults already agree on both sides).\n */\nexport function renderRuntimeEnvScript(env: RuntimeEnv = resolveRuntimeEnv()): string | null {\n const set = Object.entries(env).filter(([, value]) => Boolean(value));\n if (!set.length) return null;\n const json = escapeForInlineScript(JSON.stringify(Object.fromEntries(set)));\n return `window.${RUNTIME_ENV_KEY}=${json};`;\n}\n","/**\n * @fileoverview Which store to ask about — the one answer, in one place.\n *\n * This lived in two places once. `api/store.ts` learned to read the store a\n * request names, and `utils/sdk-helpers.ts` — the copy `api/client.ts` actually\n * sets the `store-identifier` header from — did not. So the resolver that had\n * been taught the answer was consulted for a null check and thrown away, every\n * outgoing request carried an empty identifier, the API answered\n * `422 Store Identifier not found`, and every published theme rendered\n * \"Store Unavailable\" while its tests passed: the client's suite mocked the\n * resolver, and the resolver's suite never went near a request.\n *\n * Hence one module, imported by both. If a third place ever needs a store\n * identifier, it imports this — a second implementation is the bug, not a\n * refactor away from it.\n *\n * See `docs/store-identity.md` for the full picture, including the security\n * boundary on who may name a store.\n */\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore, resolveRequestStoreBase } from './cookies';\nimport { getInjectedRuntimeEnv, readEnv } from './runtime-env';\nimport { storeBaseRedirectHref } from './store-base';\n\n/**\n * Which store to ask about, in the order the answers can be trusted.\n *\n * A deployed theme worker is published with **no vars and no bindings** — the\n * script metadata carries `main_module`, compatibility settings, assets and tags\n * and nothing else — so `VITE_STORE_DOMAIN` exists only where a build baked it\n * in, which is local development. In production this function used to reach the\n * end of that chain and return the empty string, `store.settings` refused to\n * call with no identifier, and the root loader threw \"Store Unavailable\" — a\n * theme that renders its own failure page for every visitor of every store.\n *\n * The order:\n *\n * 1. what the caller passed, which is always deliberate;\n * 2. the store this request names — the `?storeId=` a preview was opened with,\n * then the cookie remembering it — seeded by `twilightMiddleware`, and only\n * on a host permitted to name one;\n * 3. the store the first segment of the path names, on those same hosts — its\n * username, which the API accepts as an identifier as readily as an id (see\n * {@link resolveStoreBase});\n * 4. what SSR already resolved and published, so the hydrated client asks about\n * the same store the server rendered instead of resolving again from a URL\n * that no longer names it;\n * 5. the request's own host, which *is* the identity of a live storefront —\n * but only when that host is a storefront. `preview.salla.design` and\n * `localhost` serve many stores, so their names identify none;\n * 6. `VITE_STORE_DOMAIN`, last, because a build-time constant is a development\n * convenience and must never outrank what the request actually said.\n *\n * Steps 2 and 3 never both answer: a path that names a store takes the place of\n * the cookie, and a URL carrying `?storeId=` is not read for a path segment.\n */\nexport function resolveStoreIdentifier(explicit?: string): string {\n if (explicit) return explicit;\n\n const { storeId, requestHost } = getRequestStore();\n if (storeId) return storeId;\n\n const storeBase = resolveStoreBase();\n if (storeBase) return storeBase;\n\n const injected = getInjectedRuntimeEnv().storeIdentifier;\n if (injected) return injected;\n\n if (hostIdentifiesStore(requestHost)) return requestHost as string;\n\n // The browser's own address, for a client render that reached neither of the\n // above — a live storefront, where the host is the store.\n const browserHost = typeof window !== 'undefined' ? window.location.host : null;\n if (hostIdentifiesStore(browserHost)) return browserHost as string;\n\n return readEnv('VITE_STORE_DOMAIN') || readEnv('STORE_DOMAIN') || '';\n}\n\n/**\n * The store segment at the root of this page's paths, or null when the store is\n * not addressed that way.\n *\n * On the server it is what `twilightMiddleware` read off the request. In the\n * browser it is what SSR published, because the address bar is not always the\n * URL the server rendered: on the preview host the dispatcher removes\n * `?storeId=` from the request it forwards and leaves it in the browser's, and a\n * URL carrying `storeId` is never read for a segment. Re-reading\n * `window.location` would, for `/ar?storeId=…`, route the page under a different\n * store than the one it was rendered for.\n *\n * The address bar is read only when SSR published nothing at all: a page the dev\n * server answered with its client shell instead of a render, where there is no\n * server decision to agree with.\n */\nexport function resolveStoreBase(): string | null {\n const { storeBase } = getRequestStore();\n if (storeBase) return storeBase;\n if (typeof window === 'undefined') return null;\n\n const published = getInjectedRuntimeEnv();\n if (published.storeBase) return published.storeBase;\n if (Object.keys(published).length > 0) return null;\n\n return resolveRequestStoreBase(window.location.href, window.location.host);\n}\n\n/**\n * The address this page should be loaded from instead, when the store is the root\n * of every URL on this host and this request did not use it; null otherwise.\n *\n * @param username - the store's username, from the settings the request loaded\n * @param href - the router's own href for the page, without any store segment\n *\n * See `storeBaseRedirectHref` for the rules. The host is the request's on the\n * server and the browser's own in the browser, so the decision is gated the same\n * way on both sides.\n */\nexport function resolveStoreBaseRedirect(\n username: string | null | undefined,\n href: string\n): string | null {\n const host =\n getRequestStore().requestHost ?? (typeof window !== 'undefined' ? window.location.host : null);\n return storeBaseRedirectHref({ host, base: resolveStoreBase(), username, href });\n}\n","export type { StoreContext } from '../api/store';\nimport { resolveStoreIdentifier } from './store-identity';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/inline-script.ts","../src/utils/runtime-env.ts","../src/utils/store-identity.ts","../src/utils/sdk-helpers.ts"],"names":[],"mappings":";;;;AAMO,SAAS,sBAAsB,KAAA,EAAuB;AAC3D,EAAA,OAAO,MACJ,OAAA,CAAQ,IAAA,EAAM,SAAS,CAAA,CACvB,OAAA,CAAQ,MAAM,SAAS,CAAA,CACvB,QAAQ,IAAA,EAAM,SAAS,EACvB,OAAA,CAAQ,SAAA,EAAW,SAAS,CAAA,CAC5B,OAAA,CAAQ,WAAW,SAAS,CAAA;AACjC;;;ACRA,IAAM,eAAA,GAAkB,uBAAA;AAsCjB,SAAS,QAAQ,GAAA,EAAiC;AACvD,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,GAAQ,MAAA,CAAA,IAAA,CAAwE,GAAA,GACpF,GACF,CAAA;AACA,IAAA,IAAI,MAAM,OAAO,IAAA;AAAA,EACnB,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,OAAO,OAAA,KAAY,WAAA,GAAc,OAAA,CAAQ,GAAA,GAAM,GAAG,CAAA,GAAI,MAAA;AAC/D;AAOO,SAAS,iBAAA,GAAgC;AAC9C,EAAA,MAAM,WAAW,qBAAA,EAAsB;AACvC,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAW,S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G,QAAA,EAAU,MAAM,CAAA;AACjF;;;ACzHA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AAc7B,SAAS,mBAAmB,QAAA,EAA2B;AAC5D,EAAA,OAAO,uBAAuB,QAAQ,CAAA;AACxC;AAKO,SAAS,WAAA,GAA+C;AAC7D,EAAA,IAAI,CAAC,WAAW,OAAO,MAAA;AACvB,EAAA,OAAO,MAAA,CAAO,KAAA;AAChB;AAoBO,SAAS,cAAc,MAAA,EAAsB;AAClD,EAAA,MAAM,MAAM,WAAA,EAAY;AACxB,EAAA,IAAI,CAAC,GAAA,IAAO,CAAC,MAAA,EAAQ;AACrB,EAAA,IAAI;AACF,IAAA,GAAA,CAAI,IAAA,EAAM,YAAY,MAAM,CAAA;AAC5B,IAAA,GAAA,CAAI,GAAA,EAAK,SAAA,GAAY,iBAAA,EAAmB,MAAM,CAAA;AAG9C,IAAA,GAAA,CAAI,MAAA,EAAQ,GAAA,GAAM,oBAAA,EAAsB,MAAM,CAAA;AAAA,EAChD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-VRV5F6G7.js","sourcesContent":["/**\n * Escape a JSON-stringified value for safe embedding inside an inline `<script>` body.\n *\n * The head injects script bodies raw, so a `</script>` inside partner-set data would break out\n * of the tag; U+2028/U+2029 are line terminators in JS but not in JSON, so they must go too.\n */\nexport function escapeForInlineScript(value: string): string {\n return value\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n","import { escapeForInlineScript } from './inline-script';\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore } from './cookies';\n\n/** Where `rootHead` publishes the SSR-resolved env for the browser bundle to read. */\nconst RUNTIME_ENV_KEY = '__SALLA_RUNTIME_ENV__';\n\n/** The env values that must agree between the SSR render and the hydrated client. */\nexport interface RuntimeEnv {\n /** Store API base — `VITE_API_URL`. */\n apiBase?: string;\n /** Store identifier — `VITE_STORE_DOMAIN`. */\n storeIdentifier?: string;\n /**\n * The theme-settings version the request named, if any.\n *\n * Published for the same reason `storeIdentifier` is: the dispatcher strips\n * `?versionId=` on the way in, so by the time the browser has the page its own\n * URL no longer says which version it is showing. Without this the hydrated\n * client would ask the API about the store's live version and quietly replace\n * the draft it was handed.\n *\n * Absent — not empty — when nothing named one, so it drops out of the inline\n * script entirely rather than publishing a value that means \"live\".\n */\n versionId?: string;\n /**\n * The store segment at the root of this page's paths, when the store is\n * addressed that way — see `resolveStoreBase`.\n *\n * Published because the browser's address is not always the URL the server\n * read: the dispatcher removes `?storeId=` from the request it forwards but not\n * from the address bar, and a URL carrying it is never read for a segment. The\n * client builds its router from this, and a router that disagreed with the\n * server about the root would hydrate a different page.\n */\n storeBase?: string;\n}\n\n/**\n * A build-time `import.meta.env` var, falling back to the worker's runtime `process.env`\n * (wrangler `vars`, exposed via the `nodejs_compat_populate_process_env` flag).\n */\nexport function readEnv(key: string): string | undefined {\n try {\n const vite = (import.meta as unknown as { env?: Record<string, string | undefined> }).env?.[\n key\n ];\n if (vite) return vite;\n } catch {\n /* import.meta.env not available in all environments */\n }\n return typeof process !== 'undefined' ? process.env?.[key] : undefined;\n}\n\n/**\n * What this runtime resolves from its own env — server-side that includes the worker vars.\n * Prefers what the server already published, so re-rendering the head during hydration yields\n * the same script instead of dropping it.\n */\nexport function resolveRuntimeEnv(): RuntimeEnv {\n const injected = getInjectedRuntimeEnv();\n const { storeId, storeBase, versionId, requestHost } = getRequestStore();\n return {\n apiBase: injected.apiBase || readEnv('VITE_API_URL'),\n // The request outranks the build-time var here for the same reason it does\n // in `resolveStoreIdentifier`, and this is the copy that reaches the\n // browser: publish the store SSR actually rendered, or hydration resolves\n // again from a URL whose `?storeId=` the dispatcher has already stripped and\n // queries a different store than the markup it is hydrating.\n storeIdentifier:\n injected.storeIdentifier ||\n storeId ||\n storeBase ||\n (hostIdentifiesStore(requestHost) ? requestHost : null) ||\n readEnv('VITE_STORE_DOMAIN'),\n // Absent rather than empty when the path named no store, so it drops out of\n // the inline script, like `versionId`.\n storeBase: injected.storeBase || storeBase || undefined,\n // No env fallback on purpose. A store identifier has one because a build can\n // legitimately be pinned to a store; a version is something a request asks\n // for, and a build-time default would make every visitor of every store see\n // whichever draft was current when the theme was compiled.\n versionId: injected.versionId || versionId || undefined,\n };\n}\n\n/**\n * The env the SSR worker resolved, as handed to the browser by `rootHead`. Empty on the server\n * and on a client whose head carried nothing.\n *\n * Worker `vars` are *runtime* env: they live in `process.env` on the server only, while\n * `import.meta.env` is substituted at build time. A bundle built without those vars therefore\n * sees `undefined` in the browser and silently falls back to the production defaults — SSR\n * would render off the configured backend while every post-hydration fetch hits another one.\n */\nexport function getInjectedRuntimeEnv(): RuntimeEnv {\n const holder = globalThis as typeof globalThis & { [RUNTIME_ENV_KEY]?: RuntimeEnv };\n return holder[RUNTIME_ENV_KEY] ?? {};\n}\n\n/**\n * Inline head `<script>` body publishing the server-resolved env, or null when there is nothing\n * to publish (no overrides configured — the defaults already agree on both sides).\n */\nexport function renderRuntimeEnvScript(env: RuntimeEnv = resolveRuntimeEnv()): string | null {\n const set = Object.entries(env).filter(([, value]) => Boolean(value));\n if (!set.length) return null;\n const json = escapeForInlineScript(JSON.stringify(Object.fromEntries(set)));\n return `window.${RUNTIME_ENV_KEY}=${json};`;\n}\n","/**\n * @fileoverview Which store to ask about — the one answer, in one place.\n *\n * This lived in two places once. `api/store.ts` learned to read the store a\n * request names, and `utils/sdk-helpers.ts` — the copy `api/client.ts` actually\n * sets the `store-identifier` header from — did not. So the resolver that had\n * been taught the answer was consulted for a null check and thrown away, every\n * outgoing request carried an empty identifier, the API answered\n * `422 Store Identifier not found`, and every published theme rendered\n * \"Store Unavailable\" while its tests passed: the client's suite mocked the\n * resolver, and the resolver's suite never went near a request.\n *\n * Hence one module, imported by both. If a third place ever needs a store\n * identifier, it imports this — a second implementation is the bug, not a\n * refactor away from it.\n *\n * See `docs/store-identity.md` for the full picture, including the security\n * boundary on who may name a store.\n */\nimport { getRequestStore } from '../twilight/context';\nimport { hostIdentifiesStore, resolveRequestStoreBase } from './cookies';\nimport { getInjectedRuntimeEnv, readEnv } from './runtime-env';\nimport { storeBaseRedirectHref } from './store-base';\n\n/**\n * Which store to ask about, in the order the answers can be trusted.\n *\n * A deployed theme worker is published with **no vars and no bindings** — the\n * script metadata carries `main_module`, compatibility settings, assets and tags\n * and nothing else — so `VITE_STORE_DOMAIN` exists only where a build baked it\n * in, which is local development. In production this function used to reach the\n * end of that chain and return the empty string, `store.settings` refused to\n * call with no identifier, and the root loader threw \"Store Unavailable\" — a\n * theme that renders its own failure page for every visitor of every store.\n *\n * The order:\n *\n * 1. what the caller passed, which is always deliberate;\n * 2. the store this request names — the `?storeId=` a preview was opened with,\n * then the cookie remembering it — seeded by `twilightMiddleware`, and only\n * on a host permitted to name one;\n * 3. the store the first segment of the path names, on those same hosts — its\n * username, which the API accepts as an identifier as readily as an id (see\n * {@link resolveStoreBase});\n * 4. what SSR already resolved and published, so the hydrated client asks about\n * the same store the server rendered instead of resolving again from a URL\n * that no longer names it;\n * 5. the request's own host, which *is* the identity of a live storefront —\n * but only when that host is a storefront. `preview.salla.design` and\n * `localhost` serve many stores, so their names identify none;\n * 6. `VITE_STORE_DOMAIN`, last, because a build-time constant is a development\n * convenience and must never outrank what the request actually said.\n *\n * Steps 2 and 3 never both answer: a path that names a store takes the place of\n * the cookie, and a URL carrying `?storeId=` is not read for a path segment.\n */\nexport function resolveStoreIdentifier(explicit?: string): string {\n if (explicit) return explicit;\n\n const { storeId, requestHost } = getRequestStore();\n if (storeId) return storeId;\n\n const storeBase = resolveStoreBase();\n if (storeBase) return storeBase;\n\n const injected = getInjectedRuntimeEnv().storeIdentifier;\n if (injected) return injected;\n\n if (hostIdentifiesStore(requestHost)) return requestHost as string;\n\n // The browser's own address, for a client render that reached neither of the\n // above — a live storefront, where the host is the store.\n const browserHost = typeof window !== 'undefined' ? window.location.host : null;\n if (hostIdentifiesStore(browserHost)) return browserHost as string;\n\n return readEnv('VITE_STORE_DOMAIN') || readEnv('STORE_DOMAIN') || '';\n}\n\n/**\n * The store segment at the root of this page's paths, or null when the store is\n * not addressed that way.\n *\n * On the server it is what `twilightMiddleware` read off the request. In the\n * browser it is what SSR published, because the address bar is not always the\n * URL the server rendered: on the preview host the dispatcher removes\n * `?storeId=` from the request it forwards and leaves it in the browser's, and a\n * URL carrying `storeId` is never read for a segment. Re-reading\n * `window.location` would, for `/ar?storeId=…`, route the page under a different\n * store than the one it was rendered for.\n *\n * The address bar is read only when SSR published nothing at all: a page the dev\n * server answered with its client shell instead of a render, where there is no\n * server decision to agree with.\n */\nexport function resolveStoreBase(): string | null {\n const { storeBase } = getRequestStore();\n if (storeBase) return storeBase;\n if (typeof window === 'undefined') return null;\n\n const published = getInjectedRuntimeEnv();\n if (published.storeBase) return published.storeBase;\n if (Object.keys(published).length > 0) return null;\n\n return resolveRequestStoreBase(window.location.href, window.location.host);\n}\n\n/**\n * The address this page should be loaded from instead, when the store is the root\n * of every URL on this host and this request did not use it; null otherwise.\n *\n * @param username - the store's username, from the settings the request loaded\n * @param href - the router's own href for the page, without any store segment\n *\n * See `storeBaseRedirectHref` for the rules. The host is the request's on the\n * server and the browser's own in the browser, so the decision is gated the same\n * way on both sides.\n */\nexport function resolveStoreBaseRedirect(\n username: string | null | undefined,\n href: string\n): string | null {\n const host =\n getRequestStore().requestHost ?? (typeof window !== 'undefined' ? window.location.host : null);\n return storeBaseRedirectHref({ host, base: resolveStoreBase(), username, href });\n}\n","export type { StoreContext } from '../api/store';\nimport { resolveStoreIdentifier } from './store-identity';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Which store to ask the API about — see {@link resolveStoreIdentifier}.\n *\n * A delegation, not a second implementation. This name is the one on the wire\n * (`api/client.ts` sets the `store-identifier` header from it) and the one\n * themes import from `@salla.sa/twilight-theme-engine/utils`, so it stays; what\n * it must never do again is answer differently from the resolver everything\n * else asks. It had its own copy of the order once, missing the store the\n * request names and preferring the build-time `VITE_STORE_DOMAIN` that a\n * deployed worker does not have — so every published theme sent an empty\n * identifier and rendered \"Store Unavailable\".\n */\nexport function getStoreIdentifier(explicit?: string): string {\n return resolveStoreIdentifier(explicit);\n}\n\n/**\n * Get Salla SDK instance if available\n */\nexport function getSallaSDK(): typeof window.salla | undefined {\n if (!isBrowser) return undefined;\n return window.salla;\n}\n\n/**\n * Push the active route locale onto the Salla SDK.\n *\n * Why this is needed (and why it must run on every navigation):\n * - The SDK seeds its locale from `navigator.language` — the theme sets no `s-lang`\n * cookie or `window.locale` — so an English browser starts the SDK in `en` even on\n * an `/ar` store.\n * - The SDK fixes its axios `accept-language` header ONCE, at init. `salla.lang.setLocale`\n * only swaps UI translations (it never touches the header), and `salla.init()` is a\n * no-op after `Salla.status === 'ready'`, so the header never refreshes on its own.\n * - `profile::info.fetched` (login / profile refresh on navigation) overrides the header\n * to the *account's* language.\n *\n * Net result without this: `salla.api.*` calls (cart/product details) return data in the\n * wrong locale — e.g. English cart item names on `/ar/cart` — intermittently, depending on\n * load order and whether a profile fetch ran. Re-asserting the URL locale here keeps the\n * header correct. No-op on the server and until the SDK exposes the methods.\n */\nexport function syncSdkLocale(locale: string): void {\n const sdk = getSallaSDK();\n if (!sdk || !locale) return;\n try {\n sdk.lang?.setLocale?.(locale);\n sdk.api?.setHeader?.('accept-language', locale);\n // The localization modal swaps `/${user.language_code}/` in the URL on submit;\n // the SDK never sets this locally, so without it the switch reloads the same page.\n sdk.config?.set?.('user.language_code', locale);\n } catch {\n // SDK partially loaded — the header is re-asserted on the next navigation.\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { orThrow } from './chunk-FLAJQXOM.js';
2
- import { getAuthToken, api } from './chunk-POLSCD5O.js';
1
+ import { orThrow } from './chunk-RLSYCDI4.js';
2
+ import { getAuthToken, api } from './chunk-BHU25UEW.js';
3
3
  import { queryOptions } from '@tanstack/react-query';
4
4
 
5
5
  var loyalty = {
@@ -29,5 +29,5 @@ var loyalty = {
29
29
  };
30
30
 
31
31
  export { loyalty };
32
- //# sourceMappingURL=chunk-RQOCJRHY.js.map
33
- //# sourceMappingURL=chunk-RQOCJRHY.js.map
32
+ //# sourceMappingURL=chunk-WPHI6Q6N.js.map
33
+ //# sourceMappingURL=chunk-WPHI6Q6N.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/loyalty.ts"],"names":[],"mappings":";;;;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,KAAK,YAA8B;AACjC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,SAAS,EAAE,IAAA,EAAwB;AAClE,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,UAAA,EAAY,MAAwB,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,EAEzD,kBAAkB,YAA6B;AAC7C,IAAA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,gBAAgB,EAAE,IAAA,EAA2B;AAC5E,IAAA,OAAO,QAAA,CAAS,OAAA;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,MACpB,OAAA,EAAS,MAAM,OAAA,CAAQ,GAAA;AAAI,KAC5B,CAAA;AAAA,IACH,MAAA,EAAQ,MACN,YAAA,CAA4B;AAAA,MAC1B,QAAA,EAAU,CAAC,SAAA,EAAW,QAAQ,CAAA;AAAA,MAC9B,OAAA,EAAS,MAAM,OAAA,CAAQ,gBAAA,EAAiB;AAAA;AAAA;AAAA,MAGxC,OAAA,EAAS,CAAC,CAAC,YAAA,EAAa;AAAA,MACxB,SAAA,EAAW;AAAA,KACZ;AAAA;AAEP","file":"chunk-RQOCJRHY.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getAuthToken } from './client';\nimport type { Loyalty, PointBalanceResponse } from '../routes/loyalty/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const loyalty = {\n get: async (): Promise<Loyalty> => {\n const { data } = await api.get('loyalty').json<{ data: Loyalty }>();\n return data;\n },\n\n getOrThrow: (): Promise<Loyalty> => orThrow(loyalty.get()),\n\n getPointsBalance: async (): Promise<number> => {\n const response = await api.get('balance/points').json<PointBalanceResponse>();\n return response.balance;\n },\n\n queries: {\n detail: () =>\n queryOptions({\n queryKey: ['loyalty'],\n queryFn: () => loyalty.get(),\n }),\n points: () =>\n queryOptions<number | null>({\n queryKey: ['loyalty', 'points'],\n queryFn: () => loyalty.getPointsBalance(),\n // Points are customer-scoped; skip for guests (no token) — the request would\n // otherwise 400 with `token_not_provided`.\n enabled: !!getAuthToken(),\n staleTime: 30_000,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/loyalty.ts"],"names":[],"mappings":";;;;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,KAAK,YAA8B;AACjC,IAAA,MAAM,EAAE,MAAK,GAAI,MAAM,IAAI,GAAA,CAAI,SAAS,EAAE,IAAA,EAAwB;AAClE,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AAAA,EAEA,UAAA,EAAY,MAAwB,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,EAEzD,kBAAkB,YAA6B;AAC7C,IAAA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,gBAAgB,EAAE,IAAA,EAA2B;AAC5E,IAAA,OAAO,QAAA,CAAS,OAAA;AAAA,EAClB,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,MAAA,EAAQ,MACN,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,MACpB,OAAA,EAAS,MAAM,OAAA,CAAQ,GAAA;AAAI,KAC5B,CAAA;AAAA,IACH,MAAA,EAAQ,MACN,YAAA,CAA4B;AAAA,MAC1B,QAAA,EAAU,CAAC,SAAA,EAAW,QAAQ,CAAA;AAAA,MAC9B,OAAA,EAAS,MAAM,OAAA,CAAQ,gBAAA,EAAiB;AAAA;AAAA;AAAA,MAGxC,OAAA,EAAS,CAAC,CAAC,YAAA,EAAa;AAAA,MACxB,SAAA,EAAW;AAAA,KACZ;AAAA;AAEP","file":"chunk-WPHI6Q6N.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api, getAuthToken } from './client';\nimport type { Loyalty, PointBalanceResponse } from '../routes/loyalty/types';\nimport { orThrow } from '../providers/NavigationProvider';\n\nexport const loyalty = {\n get: async (): Promise<Loyalty> => {\n const { data } = await api.get('loyalty').json<{ data: Loyalty }>();\n return data;\n },\n\n getOrThrow: (): Promise<Loyalty> => orThrow(loyalty.get()),\n\n getPointsBalance: async (): Promise<number> => {\n const response = await api.get('balance/points').json<PointBalanceResponse>();\n return response.balance;\n },\n\n queries: {\n detail: () =>\n queryOptions({\n queryKey: ['loyalty'],\n queryFn: () => loyalty.get(),\n }),\n points: () =>\n queryOptions<number | null>({\n queryKey: ['loyalty', 'points'],\n queryFn: () => loyalty.getPointsBalance(),\n // Points are customer-scoped; skip for guests (no token) — the request would\n // otherwise 400 with `token_not_provided`.\n enabled: !!getAuthToken(),\n staleTime: 30_000,\n }),\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-POLSCD5O.js';
1
+ import { api } from './chunk-BHU25UEW.js';
2
2
  import { queryOptions } from '@tanstack/react-query';
3
3
 
4
4
  var apps = {
@@ -40,5 +40,5 @@ var apps = {
40
40
  };
41
41
 
42
42
  export { apps };
43
- //# sourceMappingURL=chunk-MJGW6YZQ.js.map
44
- //# sourceMappingURL=chunk-MJGW6YZQ.js.map
43
+ //# sourceMappingURL=chunk-X7P2WSNU.js.map
44
+ //# sourceMappingURL=chunk-X7P2WSNU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/apps.ts"],"names":[],"mappings":";;;AAmCO,IAAM,IAAA,GAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlB,UAAU,YAAmC;AAC3C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,eAAA,EAAiB,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CACtC,IAAA,EAA8B;AACjC,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAkC;AAC1C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,wBAAA,EAA0B,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CAC/C,IAAA,EAAsC;AACzC,IAAA,OAAO,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,IAAQ,EAAC,EAAE;AAAA,EAClC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA;AAAA;AAAA;AAAA,MAIX,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,IAEH,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA,MACX,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-MJGW6YZQ.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\n\nexport interface AppSnippetRow {\n place: string;\n content: string;\n url?: string | null;\n /**\n * Raw snippet id, emitted as `data-snippet-id`. Present only on CDN rows — the\n * inline branch of the backend's snippet parser omits the key entirely.\n */\n id?: number;\n /** `{{customer.x}}` placeholders in `content` to substitute from SDK config `user.*` keys. */\n customer_parameters?: string[];\n}\n\nexport interface AppSnippet {\n service: string;\n app_id: string;\n /** Encoded app id (`getRouteKey()`): the scope id its snippets bind to via `data-scope-id`,\n * and its settings-bucket key. Absent on payloads predating the settings API. */\n id?: string;\n app_slug: string;\n status: string;\n snippets: AppSnippetRow[];\n}\n\n/**\n * Per-app public `app.*` buckets for CDN snippets, keyed by encoded app id (== `AppSnippet.id`,\n * the `Salla.appScope` scope id). One isolated bucket per app; reads within a scope are bare `app.*`.\n */\nexport interface AppSettings {\n apps: Record<string, Record<string, unknown>>;\n}\n\nexport const apps = {\n /**\n * Installed apps' snippets (scripts/HTML to inject). Timeout-bounded because it's awaited in\n * rootBeforeLoad (SSR/TTFB): a slow response degrades to no CDN tags, never stalls the page.\n */\n snippets: async (): Promise<AppSnippet[]> => {\n const { data } = await api\n .get('apps/snippets', { timeout: 2500 })\n .json<{ data?: AppSnippet[] }>();\n return data ?? [];\n },\n\n /**\n * Per-app public `app.*` buckets, keyed by encoded app id. Timeout-bounded (SSR-awaited):\n * a slow response degrades to empty buckets (fail-open), never strands injection.\n */\n settings: async (): Promise<AppSettings> => {\n const { data } = await api\n .get('apps/snippets/settings', { timeout: 2500 })\n .json<{ data?: Partial<AppSettings> }>();\n return { apps: data?.apps ?? {} };\n },\n\n queries: {\n snippets: () =>\n queryOptions({\n queryKey: ['apps', 'snippets'],\n queryFn: () => apps.snippets(),\n // Snippets are static per session; one fetch per page load is enough.\n staleTime: Infinity,\n // No retry: this is awaited in rootBeforeLoad, so the router's default `retry: 1` would\n // make the SSR wait 2 x the 2500ms timeout (plus backoff) before failing open. The\n // 2500ms timeout must be the whole budget; the client fallback query does the retrying.\n retry: 0,\n }),\n\n settings: () =>\n queryOptions({\n queryKey: ['apps', 'settings'],\n queryFn: () => apps.settings(),\n // Encoded app ids and their buckets are stable per page; one fetch is enough.\n staleTime: Infinity,\n retry: 0,\n }),\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/api/apps.ts"],"names":[],"mappings":";;;AAmCO,IAAM,IAAA,GAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlB,UAAU,YAAmC;AAC3C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,eAAA,EAAiB,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CACtC,IAAA,EAA8B;AACjC,IAAA,OAAO,QAAQ,EAAC;AAAA,EAClB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAkC;AAC1C,IAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,GAAA,CACpB,GAAA,CAAI,wBAAA,EAA0B,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA,CAC/C,IAAA,EAAsC;AACzC,IAAA,OAAO,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,IAAQ,EAAC,EAAE;AAAA,EAClC,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA;AAAA;AAAA;AAAA,MAIX,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,IAEH,QAAA,EAAU,MACR,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,UAAU,CAAA;AAAA,MAC7B,OAAA,EAAS,MAAM,IAAA,CAAK,QAAA,EAAS;AAAA;AAAA,MAE7B,SAAA,EAAW,QAAA;AAAA,MACX,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-X7P2WSNU.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\n\nexport interface AppSnippetRow {\n place: string;\n content: string;\n url?: string | null;\n /**\n * Raw snippet id, emitted as `data-snippet-id`. Present only on CDN rows — the\n * inline branch of the backend's snippet parser omits the key entirely.\n */\n id?: number;\n /** `{{customer.x}}` placeholders in `content` to substitute from SDK config `user.*` keys. */\n customer_parameters?: string[];\n}\n\nexport interface AppSnippet {\n service: string;\n app_id: string;\n /** Encoded app id (`getRouteKey()`): the scope id its snippets bind to via `data-scope-id`,\n * and its settings-bucket key. Absent on payloads predating the settings API. */\n id?: string;\n app_slug: string;\n status: string;\n snippets: AppSnippetRow[];\n}\n\n/**\n * Per-app public `app.*` buckets for CDN snippets, keyed by encoded app id (== `AppSnippet.id`,\n * the `Salla.appScope` scope id). One isolated bucket per app; reads within a scope are bare `app.*`.\n */\nexport interface AppSettings {\n apps: Record<string, Record<string, unknown>>;\n}\n\nexport const apps = {\n /**\n * Installed apps' snippets (scripts/HTML to inject). Timeout-bounded because it's awaited in\n * rootBeforeLoad (SSR/TTFB): a slow response degrades to no CDN tags, never stalls the page.\n */\n snippets: async (): Promise<AppSnippet[]> => {\n const { data } = await api\n .get('apps/snippets', { timeout: 2500 })\n .json<{ data?: AppSnippet[] }>();\n return data ?? [];\n },\n\n /**\n * Per-app public `app.*` buckets, keyed by encoded app id. Timeout-bounded (SSR-awaited):\n * a slow response degrades to empty buckets (fail-open), never strands injection.\n */\n settings: async (): Promise<AppSettings> => {\n const { data } = await api\n .get('apps/snippets/settings', { timeout: 2500 })\n .json<{ data?: Partial<AppSettings> }>();\n return { apps: data?.apps ?? {} };\n },\n\n queries: {\n snippets: () =>\n queryOptions({\n queryKey: ['apps', 'snippets'],\n queryFn: () => apps.snippets(),\n // Snippets are static per session; one fetch per page load is enough.\n staleTime: Infinity,\n // No retry: this is awaited in rootBeforeLoad, so the router's default `retry: 1` would\n // make the SSR wait 2 x the 2500ms timeout (plus backoff) before failing open. The\n // 2500ms timeout must be the whole budget; the client fallback query does the retrying.\n retry: 0,\n }),\n\n settings: () =>\n queryOptions({\n queryKey: ['apps', 'settings'],\n queryFn: () => apps.settings(),\n // Encoded app ids and their buckets are stable per page; one fetch is enough.\n staleTime: Infinity,\n retry: 0,\n }),\n },\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { escapeForInlineScript } from './chunk-RLNBEDA4.js';
1
+ import { escapeForInlineScript } from './chunk-VRV5F6G7.js';
2
2
 
3
3
  // src/utils/app-scope.ts
4
4
  var isBrowser = typeof window !== "undefined";
@@ -132,5 +132,5 @@ function renderThemeHookSlotsScript(names = getRegisteredThemeHookSlots()) {
132
132
  }
133
133
 
134
134
  export { applyAppScopeMocks, applyThemeHookSlots, installAppScope, registerThemeHookSlots, renderAppScopeInstallScript, renderThemeHookSlotsScript };
135
- //# sourceMappingURL=chunk-POATRFUM.js.map
136
- //# sourceMappingURL=chunk-POATRFUM.js.map
135
+ //# sourceMappingURL=chunk-YGDAYFQY.js.map
136
+ //# sourceMappingURL=chunk-YGDAYFQY.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAAA,KAAwB,GAAA,CAAI,MAAM,CAAC,CAAA;AACtD,EAAA,MAAM,YAAY,MAA+B,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,SAAS,EAAC;AACxE,EAAA,MAAM,UAAA,GAAa,MAChB,SAAA,EAAU,CAAE,UAAsC,EAAC;AACtD,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,EAA8B,IAAA,KAAmC;AACpF,IAAA,MAAM,MAAA,GAAS,IAAI,IAAc,CAAA;AACjC,IAAA,OAAO,OA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ClC,EAAA,KAAA,MAAW,IAAA,IAAQ,UAAA,EAAY,IAAI,CAAC,KAAA,CAAM,SAAS,IAAI,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AACzE,EAAA,OAAO,IAAA;AACT;AAYO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-POATRFUM.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAAA,KAAwB,GAAA,CAAI,MAAM,CAAC,CAAA;AACtD,EAAA,MAAM,YAAY,MAA+B,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,SAAS,EAAC;AACxE,EAAA,MAAM,UAAA,GAAa,MAChB,SAAA,EAAU,CAAE,UAAsC,EAAC;AACtD,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,EAA8B,IAAA,KAAmC;AACpF,IAAA,MAAM,MAAA,GAAS,IAAI,IAAc,CAAA;AACjC,IAAA,OAAO,OAAO,MAAA,KAAW,UAAA,GAAa,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,GAAI,MAAA;AAA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AI,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AACzE,EAAA,OAAO,IAAA;AACT;AAYO,SAAS,mBAAA,GAA4B;AAC1C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-YGDAYFQY.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-POLSCD5O.js';
1
+ import { api } from './chunk-BHU25UEW.js';
2
2
  import { queryOptions } from '@tanstack/react-query';
3
3
 
4
4
  var notification = {
@@ -24,5 +24,5 @@ var notification = {
24
24
  };
25
25
 
26
26
  export { notification };
27
- //# sourceMappingURL=chunk-RL4VZU3P.js.map
28
- //# sourceMappingURL=chunk-RL4VZU3P.js.map
27
+ //# sourceMappingURL=chunk-YGSU36MZ.js.map
28
+ //# sourceMappingURL=chunk-YGSU36MZ.js.map