@salla.sa/twilight-theme-engine 1.0.189 → 1.0.190
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.
- package/dist/{AddToCartForm-BWFPHUHX.js → AddToCartForm-KAAJU4A2.js} +3 -3
- package/dist/{AddToCartForm-BWFPHUHX.js.map → AddToCartForm-KAAJU4A2.js.map} +1 -1
- package/dist/{BlogAuthorPage-VNRW7X2Y.js → BlogAuthorPage-VHN6OZN4.js} +19 -19
- package/dist/{BlogAuthorPage-VNRW7X2Y.js.map → BlogAuthorPage-VHN6OZN4.js.map} +1 -1
- package/dist/{BlogCategoryPage-C36ICGKN.js → BlogCategoryPage-FS2AXU4F.js} +19 -19
- package/dist/{BlogCategoryPage-C36ICGKN.js.map → BlogCategoryPage-FS2AXU4F.js.map} +1 -1
- package/dist/{BlogPage-4FADHN2F.js → BlogPage-DSKNHKBP.js} +17 -17
- package/dist/{BlogPage-4FADHN2F.js.map → BlogPage-DSKNHKBP.js.map} +1 -1
- package/dist/{BlogSinglePage-IME2E4GJ.js → BlogSinglePage-UWLK2ZVI.js} +17 -17
- package/dist/{BlogSinglePage-IME2E4GJ.js.map → BlogSinglePage-UWLK2ZVI.js.map} +1 -1
- package/dist/{BlogTagPage-CD5AL2XW.js → BlogTagPage-7B5HNL4Y.js} +19 -19
- package/dist/{BlogTagPage-CD5AL2XW.js.map → BlogTagPage-7B5HNL4Y.js.map} +1 -1
- package/dist/{BrandsPage-CEST6CGM.js → BrandsPage-623N44WS.js} +18 -18
- package/dist/{BrandsPage-CEST6CGM.js.map → BrandsPage-623N44WS.js.map} +1 -1
- package/dist/{Breadcrumb-OHEBG52R.js → Breadcrumb-WCILVFL4.js} +17 -17
- package/dist/{Breadcrumb-OHEBG52R.js.map → Breadcrumb-WCILVFL4.js.map} +1 -1
- package/dist/{CanvasOverlay-76UNNNJB.js → CanvasOverlay-4NHVIGXV.js} +3 -3
- package/dist/{CanvasOverlay-76UNNNJB.js.map → CanvasOverlay-4NHVIGXV.js.map} +1 -1
- package/dist/{CartItem-NS3NDDFL.js → CartItem-S4YI6O3D.js} +17 -17
- package/dist/{CartItem-NS3NDDFL.js.map → CartItem-S4YI6O3D.js.map} +1 -1
- package/dist/{CartSummary-V4WNFZ24.js → CartSummary-23I56XYM.js} +17 -17
- package/dist/{CartSummary-V4WNFZ24.js.map → CartSummary-23I56XYM.js.map} +1 -1
- package/dist/{Copyright-53LMJ65T.js → Copyright-WQ3QGJXA.js} +3 -3
- package/dist/{Copyright-53LMJ65T.js.map → Copyright-WQ3QGJXA.js.map} +1 -1
- package/dist/{CustomerLayout-P242XSMS.js → CustomerLayout-YDY6LCDF.js} +17 -17
- package/dist/{CustomerLayout-P242XSMS.js.map → CustomerLayout-YDY6LCDF.js.map} +1 -1
- package/dist/{Footer-ZCA4FBVY.js → Footer-OD3OASSX.js} +3 -3
- package/dist/{Footer-ZCA4FBVY.js.map → Footer-OD3OASSX.js.map} +1 -1
- package/dist/GoogleTag-R65O7SU7.js +15 -0
- package/dist/{GoogleTag-7GT3QOSS.js.map → GoogleTag-R65O7SU7.js.map} +1 -1
- package/dist/{Header-76K42Z67.js → Header-W26NSLVJ.js} +8 -8
- package/dist/{Header-76K42Z67.js.map → Header-W26NSLVJ.js.map} +1 -1
- package/dist/{LatestProducts-O2JEC2KM.js → LatestProducts-POBEIWGZ.js} +19 -19
- package/dist/{LatestProducts-O2JEC2KM.js.map → LatestProducts-POBEIWGZ.js.map} +1 -1
- package/dist/{LoyaltyPage-ZRNDDTLO.js → LoyaltyPage-DMFCII37.js} +17 -17
- package/dist/{LoyaltyPage-ZRNDDTLO.js.map → LoyaltyPage-DMFCII37.js.map} +1 -1
- package/dist/{LoyaltyPointsPage-7KZPWPSL.js → LoyaltyPointsPage-5YSQZYNZ.js} +6 -6
- package/dist/{LoyaltyPointsPage-7KZPWPSL.js.map → LoyaltyPointsPage-5YSQZYNZ.js.map} +1 -1
- package/dist/{MainMenu-TLPXXM7G.js → MainMenu-4GTPNG6U.js} +5 -5
- package/dist/{MainMenu-TLPXXM7G.js.map → MainMenu-4GTPNG6U.js.map} +1 -1
- package/dist/{MasterLayout-5EKKDTNV.js → MasterLayout-4SYCEUHL.js} +17 -17
- package/dist/{MasterLayout-5EKKDTNV.js.map → MasterLayout-4SYCEUHL.js.map} +1 -1
- package/dist/{MobileMenu-B4YH7I5I.js → MobileMenu-WIAETV7Y.js} +18 -18
- package/dist/{MobileMenu-B4YH7I5I.js.map → MobileMenu-WIAETV7Y.js.map} +1 -1
- package/dist/{NotificationsPage-7MOC7QJV.js → NotificationsPage-WGX7XV7G.js} +17 -17
- package/dist/{NotificationsPage-7MOC7QJV.js.map → NotificationsPage-WGX7XV7G.js.map} +1 -1
- package/dist/{OrderSinglePage-4IEFMNCB.js → OrderSinglePage-4NILJOAP.js} +18 -18
- package/dist/{OrderSinglePage-4IEFMNCB.js.map → OrderSinglePage-4NILJOAP.js.map} +1 -1
- package/dist/{OrdersPage-MXSRURTW.js → OrdersPage-QMJQKKGN.js} +17 -17
- package/dist/{OrdersPage-MXSRURTW.js.map → OrdersPage-QMJQKKGN.js.map} +1 -1
- package/dist/{PageSingle-ZABEKG66.js → PageSingle-QUTX2362.js} +3 -3
- package/dist/{PageSingle-ZABEKG66.js.map → PageSingle-QUTX2362.js.map} +1 -1
- package/dist/{ProductDetails-LBBONHCT.js → ProductDetails-V5RXYS4P.js} +5 -5
- package/dist/{ProductDetails-LBBONHCT.js.map → ProductDetails-V5RXYS4P.js.map} +1 -1
- package/dist/{ProfilePage-ZAVX7QGJ.js → ProfilePage-UKIOGUTD.js} +17 -17
- package/dist/{ProfilePage-ZAVX7QGJ.js.map → ProfilePage-UKIOGUTD.js.map} +1 -1
- package/dist/{ReviewsPage-JSJLJ64A.js → ReviewsPage-S4OWAYLR.js} +3 -3
- package/dist/{ReviewsPage-JSJLJ64A.js.map → ReviewsPage-S4OWAYLR.js.map} +1 -1
- package/dist/{SeoCartWidget-6IIHJ3W4.js → SeoCartWidget-PV47GU6C.js} +17 -17
- package/dist/{SeoCartWidget-6IIHJ3W4.js.map → SeoCartWidget-PV47GU6C.js.map} +1 -1
- package/dist/{SettingsPage-SFYQLYIE.js → SettingsPage-BJTJ67GK.js} +17 -17
- package/dist/{SettingsPage-SFYQLYIE.js.map → SettingsPage-BJTJ67GK.js.map} +1 -1
- package/dist/{StoreClosedNotification-GFSUE6V2.js → StoreClosedNotification-LY7QRBFD.js} +18 -18
- package/dist/{StoreClosedNotification-GFSUE6V2.js.map → StoreClosedNotification-LY7QRBFD.js.map} +1 -1
- package/dist/{TestimonialsPage-RXPSVE5R.js → TestimonialsPage-Y52XDRGH.js} +3 -3
- package/dist/{TestimonialsPage-RXPSVE5R.js.map → TestimonialsPage-Y52XDRGH.js.map} +1 -1
- package/dist/{ThankYouPage-WBXUOEFT.js → ThankYouPage-TUBSFLBE.js} +17 -17
- package/dist/{ThankYouPage-WBXUOEFT.js.map → ThankYouPage-TUBSFLBE.js.map} +1 -1
- package/dist/{WalletPage-75H3YA2Y.js → WalletPage-EP5ZDLWY.js} +18 -18
- package/dist/{WalletPage-75H3YA2Y.js.map → WalletPage-EP5ZDLWY.js.map} +1 -1
- package/dist/{WebMcpTools-4H7PUDZH.js → WebMcpTools-KPAKY4SD.js} +5 -5
- package/dist/{WebMcpTools-4H7PUDZH.js.map → WebMcpTools-KPAKY4SD.js.map} +1 -1
- package/dist/{WishlistPage-6GNC53MS.js → WishlistPage-6HCY2FMS.js} +19 -19
- package/dist/{WishlistPage-6GNC53MS.js.map → WishlistPage-6HCY2FMS.js.map} +1 -1
- package/dist/api/advertisement.js +2 -2
- package/dist/api/apps.js +2 -2
- package/dist/api/blog.js +3 -3
- package/dist/api/brands.js +3 -3
- package/dist/api/cart.js +3 -3
- package/dist/api/category.js +3 -3
- package/dist/api/client.js +1 -1
- package/dist/api/custom-url.js +2 -2
- package/dist/api/home.js +2 -2
- package/dist/api/loyalty.js +3 -3
- package/dist/api/menu.js +2 -2
- package/dist/api/notification.js +2 -2
- package/dist/api/order.js +3 -3
- package/dist/api/page.js +3 -3
- package/dist/api/product.js +3 -3
- package/dist/api/profile.js +1 -1
- package/dist/api/store.js +2 -2
- package/dist/api/translations.js +2 -2
- package/dist/api/user.js +2 -2
- package/dist/api/wallet.js +2 -2
- package/dist/api/wishlist.js +4 -4
- package/dist/{chunk-QZU3SW5N.js → chunk-4IJGARZP.js} +4 -4
- package/dist/{chunk-QZU3SW5N.js.map → chunk-4IJGARZP.js.map} +1 -1
- package/dist/{chunk-YZOYXYGO.js → chunk-5IPAWSCV.js} +4 -4
- package/dist/{chunk-YZOYXYGO.js.map → chunk-5IPAWSCV.js.map} +1 -1
- package/dist/{chunk-G4ZPIYXS.js → chunk-6444ZQQB.js} +7 -7
- package/dist/{chunk-G4ZPIYXS.js.map → chunk-6444ZQQB.js.map} +1 -1
- package/dist/{chunk-QMKPBCLM.js → chunk-67R54ONG.js} +5 -5
- package/dist/{chunk-QMKPBCLM.js.map → chunk-67R54ONG.js.map} +1 -1
- package/dist/{chunk-XXWYFOZ7.js → chunk-7FQHDIX5.js} +7 -7
- package/dist/{chunk-XXWYFOZ7.js.map → chunk-7FQHDIX5.js.map} +1 -1
- package/dist/{chunk-7FUP3FET.js → chunk-7J35UKLU.js} +4 -4
- package/dist/{chunk-7FUP3FET.js.map → chunk-7J35UKLU.js.map} +1 -1
- package/dist/{chunk-IMXX46KD.js → chunk-7UEQP3EQ.js} +4 -4
- package/dist/{chunk-IMXX46KD.js.map → chunk-7UEQP3EQ.js.map} +1 -1
- package/dist/{chunk-7AROYBE2.js → chunk-AXNUUBGZ.js} +6 -6
- package/dist/{chunk-7AROYBE2.js.map → chunk-AXNUUBGZ.js.map} +1 -1
- package/dist/{chunk-I7S6WWHW.js → chunk-BM43QN4L.js} +3 -3
- package/dist/{chunk-I7S6WWHW.js.map → chunk-BM43QN4L.js.map} +1 -1
- package/dist/{chunk-QCGHFFS6.js → chunk-BVONGI6Z.js} +4 -4
- package/dist/{chunk-QCGHFFS6.js.map → chunk-BVONGI6Z.js.map} +1 -1
- package/dist/{chunk-G4CSD4PD.js → chunk-DYY7Y7DZ.js} +3 -3
- package/dist/{chunk-G4CSD4PD.js.map → chunk-DYY7Y7DZ.js.map} +1 -1
- package/dist/{chunk-BYP5CQ57.js → chunk-EYSQQR7T.js} +3 -3
- package/dist/{chunk-BYP5CQ57.js.map → chunk-EYSQQR7T.js.map} +1 -1
- package/dist/{chunk-P75KDTGI.js → chunk-FF5HNVZ7.js} +4 -4
- package/dist/{chunk-P75KDTGI.js.map → chunk-FF5HNVZ7.js.map} +1 -1
- package/dist/{chunk-OHK7OO4L.js → chunk-FF7FJJYG.js} +4 -4
- package/dist/{chunk-OHK7OO4L.js.map → chunk-FF7FJJYG.js.map} +1 -1
- package/dist/{chunk-O3ZL24KN.js → chunk-FLPDMPVB.js} +3 -3
- package/dist/{chunk-O3ZL24KN.js.map → chunk-FLPDMPVB.js.map} +1 -1
- package/dist/{chunk-MI4DFSQ3.js → chunk-GMBOYIH5.js} +3 -3
- package/dist/{chunk-MI4DFSQ3.js.map → chunk-GMBOYIH5.js.map} +1 -1
- package/dist/{chunk-KAB5TEFM.js → chunk-GSPD3FOY.js} +3 -3
- package/dist/{chunk-KAB5TEFM.js.map → chunk-GSPD3FOY.js.map} +1 -1
- package/dist/{chunk-O4LQHEW2.js → chunk-HPKOZDZC.js} +4 -4
- package/dist/{chunk-O4LQHEW2.js.map → chunk-HPKOZDZC.js.map} +1 -1
- package/dist/{chunk-V4CHJEOW.js → chunk-IKOLXZ72.js} +4 -4
- package/dist/{chunk-V4CHJEOW.js.map → chunk-IKOLXZ72.js.map} +1 -1
- package/dist/{chunk-RZNFP6GR.js → chunk-ILDV6JVU.js} +19 -19
- package/dist/{chunk-RZNFP6GR.js.map → chunk-ILDV6JVU.js.map} +1 -1
- package/dist/{chunk-VU6H32IM.js → chunk-IQS7EDB3.js} +4 -4
- package/dist/{chunk-VU6H32IM.js.map → chunk-IQS7EDB3.js.map} +1 -1
- package/dist/{chunk-UQK6WVCM.js → chunk-J76Y33NU.js} +7 -7
- package/dist/{chunk-UQK6WVCM.js.map → chunk-J76Y33NU.js.map} +1 -1
- package/dist/{chunk-ELV6T6VA.js → chunk-JQWLQIDO.js} +5 -5
- package/dist/{chunk-ELV6T6VA.js.map → chunk-JQWLQIDO.js.map} +1 -1
- package/dist/{chunk-M6ASPT2Y.js → chunk-JRJZXUWY.js} +3 -3
- package/dist/{chunk-M6ASPT2Y.js.map → chunk-JRJZXUWY.js.map} +1 -1
- package/dist/{chunk-UO4TOXPT.js → chunk-JWMLMLON.js} +3 -3
- package/dist/{chunk-UO4TOXPT.js.map → chunk-JWMLMLON.js.map} +1 -1
- package/dist/{chunk-XX26RQCL.js → chunk-KE2NSE4A.js} +3 -3
- package/dist/{chunk-XX26RQCL.js.map → chunk-KE2NSE4A.js.map} +1 -1
- package/dist/{chunk-EY5WH7BT.js → chunk-KSZD7ZFY.js} +3 -3
- package/dist/{chunk-EY5WH7BT.js.map → chunk-KSZD7ZFY.js.map} +1 -1
- package/dist/{chunk-GKVDCDJZ.js → chunk-LRKJBY26.js} +3 -3
- package/dist/{chunk-GKVDCDJZ.js.map → chunk-LRKJBY26.js.map} +1 -1
- package/dist/{chunk-L7B7TS4R.js → chunk-MTTKSFUF.js} +3 -3
- package/dist/{chunk-L7B7TS4R.js.map → chunk-MTTKSFUF.js.map} +1 -1
- package/dist/{chunk-K7F7ATZO.js → chunk-N2XBQN2S.js} +2 -2
- package/dist/{chunk-K7F7ATZO.js.map → chunk-N2XBQN2S.js.map} +1 -1
- package/dist/{chunk-YC5OTW4F.js → chunk-NOYFPIZR.js} +3 -3
- package/dist/{chunk-YC5OTW4F.js.map → chunk-NOYFPIZR.js.map} +1 -1
- package/dist/{chunk-MY2DW3E6.js → chunk-NQ42AV7D.js} +3 -3
- package/dist/{chunk-MY2DW3E6.js.map → chunk-NQ42AV7D.js.map} +1 -1
- package/dist/{chunk-5QLEAUQ6.js → chunk-NTBL5QFW.js} +3 -3
- package/dist/{chunk-5QLEAUQ6.js.map → chunk-NTBL5QFW.js.map} +1 -1
- package/dist/{chunk-QGQJI25U.js → chunk-O7YSKG2A.js} +14 -14
- package/dist/{chunk-QGQJI25U.js.map → chunk-O7YSKG2A.js.map} +1 -1
- package/dist/{chunk-XN47C7SG.js → chunk-PGNAIM6L.js} +4 -4
- package/dist/{chunk-XN47C7SG.js.map → chunk-PGNAIM6L.js.map} +1 -1
- package/dist/{chunk-6G5EAXGA.js → chunk-PSG2U2GG.js} +5 -5
- package/dist/{chunk-6G5EAXGA.js.map → chunk-PSG2U2GG.js.map} +1 -1
- package/dist/{chunk-DFPTSQ7E.js → chunk-Q3237344.js} +3 -3
- package/dist/{chunk-DFPTSQ7E.js.map → chunk-Q3237344.js.map} +1 -1
- package/dist/{chunk-NIJLJAKS.js → chunk-Q54E3MRF.js} +3 -3
- package/dist/{chunk-NIJLJAKS.js.map → chunk-Q54E3MRF.js.map} +1 -1
- package/dist/{chunk-XQFFFNJ4.js → chunk-QCXWLQCL.js} +4 -4
- package/dist/{chunk-XQFFFNJ4.js.map → chunk-QCXWLQCL.js.map} +1 -1
- package/dist/{chunk-4CLP7VQN.js → chunk-RLT3D2LR.js} +3 -3
- package/dist/{chunk-4CLP7VQN.js.map → chunk-RLT3D2LR.js.map} +1 -1
- package/dist/{chunk-GHBUMBGM.js → chunk-RZN7X72V.js} +3 -3
- package/dist/{chunk-GHBUMBGM.js.map → chunk-RZN7X72V.js.map} +1 -1
- package/dist/{chunk-ACQUG3H4.js → chunk-TBOPWHG4.js} +3 -3
- package/dist/{chunk-ACQUG3H4.js.map → chunk-TBOPWHG4.js.map} +1 -1
- package/dist/{chunk-WGUKNVWJ.js → chunk-TP2GMZEK.js} +4 -4
- package/dist/{chunk-WGUKNVWJ.js.map → chunk-TP2GMZEK.js.map} +1 -1
- package/dist/{chunk-5RTPNCH3.js → chunk-TQW7A42X.js} +4 -4
- package/dist/{chunk-5RTPNCH3.js.map → chunk-TQW7A42X.js.map} +1 -1
- package/dist/{chunk-T3ZC6QJT.js → chunk-TXMG7FIA.js} +4 -4
- package/dist/{chunk-T3ZC6QJT.js.map → chunk-TXMG7FIA.js.map} +1 -1
- package/dist/{chunk-N5EFDFMY.js → chunk-U5QRBIEL.js} +3 -3
- package/dist/{chunk-N5EFDFMY.js.map → chunk-U5QRBIEL.js.map} +1 -1
- package/dist/{chunk-Z4VXLTDZ.js → chunk-USEGCCT3.js} +4 -4
- package/dist/{chunk-Z4VXLTDZ.js.map → chunk-USEGCCT3.js.map} +1 -1
- package/dist/{chunk-5A5FYUZQ.js → chunk-VHLRX3JJ.js} +4 -4
- package/dist/{chunk-5A5FYUZQ.js.map → chunk-VHLRX3JJ.js.map} +1 -1
- package/dist/{chunk-G3YKFVXS.js → chunk-VHTVAZEE.js} +5 -5
- package/dist/{chunk-G3YKFVXS.js.map → chunk-VHTVAZEE.js.map} +1 -1
- package/dist/{chunk-JRM7WGZ7.js → chunk-XBZIPRTK.js} +3 -3
- package/dist/{chunk-JRM7WGZ7.js.map → chunk-XBZIPRTK.js.map} +1 -1
- package/dist/components/cart/index.js +1 -1
- package/dist/components/common/index.js +1 -1
- package/dist/components/drawer/index.js +15 -15
- package/dist/components/home/index.js +20 -20
- package/dist/components/layout/index.js +4 -4
- package/dist/components/product/index.js +17 -17
- package/dist/components/store/index.js +16 -16
- package/dist/components/tracking/index.js +6 -6
- package/dist/{custom-urls-KEFBDGXJ.js → custom-urls-7N3FYOTY.js} +7 -7
- package/dist/{custom-urls-KEFBDGXJ.js.map → custom-urls-7N3FYOTY.js.map} +1 -1
- package/dist/dev/editor/index.js +1 -1
- package/dist/dev/index.js +1 -1
- package/dist/{document-class-K6N7E4YJ.js → document-class-5G7JJUGH.js} +17 -17
- package/dist/{document-class-K6N7E4YJ.js.map → document-class-5G7JJUGH.js.map} +1 -1
- package/dist/hooks/index.js +15 -15
- package/dist/hooks/useGtm.js +15 -15
- package/dist/hooks/useMoney.js +15 -15
- package/dist/hooks/useStore.js +15 -15
- package/dist/hooks/useUser.js +3 -3
- package/dist/index.js +15 -15
- package/dist/{navigation-V63GDB47.js → navigation-7MC7R6WS.js} +5 -5
- package/dist/{navigation-V63GDB47.js.map → navigation-7MC7R6WS.js.map} +1 -1
- package/dist/{navigation-HB6EQOHP.js → navigation-XKSFWNDB.js} +4 -4
- package/dist/{navigation-HB6EQOHP.js.map → navigation-XKSFWNDB.js.map} +1 -1
- package/dist/{not-found-6SFVCMIP.js → not-found-C7QUZLNB.js} +18 -18
- package/dist/{not-found-6SFVCMIP.js.map → not-found-C7QUZLNB.js.map} +1 -1
- package/dist/providers/index.js +15 -15
- package/dist/routes/account/orders.js +4 -4
- package/dist/routes/account.js +13 -13
- package/dist/routes/blog.js +8 -8
- package/dist/routes/brands.js +4 -4
- package/dist/routes/cart.js +25 -25
- package/dist/routes/home.js +21 -21
- package/dist/routes/index.js +8 -8
- package/dist/routes/loyalty.js +5 -5
- package/dist/routes/page/index.d.ts +4 -0
- package/dist/routes/page/index.d.ts.map +1 -1
- package/dist/routes/page.js +9 -6
- package/dist/routes/page.js.map +1 -1
- package/dist/routes/product-listing.js +25 -25
- package/dist/routes/product.js +24 -24
- package/dist/routes/seo-redirects.js +8 -8
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +4 -4
- package/dist/skeleton.js +23 -23
- package/dist/{store-lookup-6UAAG4BA.js → store-lookup-RNC4M3Q6.js} +8 -8
- package/dist/{store-lookup-6UAAG4BA.js.map → store-lookup-RNC4M3Q6.js.map} +1 -1
- package/dist/tanstack.js +17 -17
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/tailwind/routes/page/index.tsx.txt +12 -2
- package/dist/GoogleTag-7GT3QOSS.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/language-cookie.ts","../src/utils/native-app-headers.ts","../src/api/store.ts"],"names":["createIsomorphicFn","setCookie"],"mappings":";;;;;;;;;;A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,GAAQ,uBAAA,CAAwB,UAAA,EAAY,KAAK,CAAA;AACvD,IAAA,OAAA,CAAQ,KAAA,CAAM,kBAAA,EAAoB,KAAA,CAAM,OAAA,EAAS,GAAI,KAAA,KAAU,KAAA,GAAQ,EAAC,GAAI,CAAC,KAAK,CAAE,CAAA;AACpF,IAAA,MAAM,KAAA;AAAA,EACR;AACF;AAEO,IAAM,KAAA,GAAQ;AAAA,EACnB,QAAA,EAAU,OAAO,eAAA,KAA2D;AAC1E,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,cAAc,eAAe,CAAA;AAAA,IAC5C,CAAA,CAAA,MAAQ;AAEN,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,CAAC,eAAA,KACT,YAAA,CAAkC;AAAA,MAChC,QAAA,EAAU;AAAA,QACR,OAAA;AAAA,QACA,UAAA;AAAA,QACA,eAAA;AAAA,QACA,oBAAmB,CAAE,MAAA;AAAA,QACrB,cAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQf,uBAAA;AAAwB,OAC1B;AAAA;AAAA,MAEA,OAAA,EAAS,MAAM,aAAA,CAAc,eAAe,CAAA;AAAA;AAAA;AAAA,MAG5C,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-4CLP7VQN.js","sourcesContent":["/**\n * @fileoverview Reading and writing the `s-lang` cookie, on the server and in the browser.\n *\n * The server reads it from the request the framework is handling and writes it to that\n * request's response. The server-only import is stripped from the client bundle by\n * `createIsomorphicFn`, as in `routes/root/beforeLoad.ts`. The browser uses `document.cookie`.\n * Either side outside a request (a prerender, a test) has nothing to read or write and says so\n * quietly.\n */\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getRequestHeader, getRequestUrl, setCookie } from '@tanstack/react-start/server';\nimport { LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME } from './cookies';\n\nconst readServerCookieHeader = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getRequestHeader('cookie') ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nconst writeServerLanguageCookie = createIsomorphicFn()\n .server((code: string): void => {\n try {\n setCookie(LANGUAGE_COOKIE_NAME, code, {\n path: '/',\n maxAge: LANGUAGE_COOKIE_MAX_AGE,\n sameSite: 'lax',\n });\n } catch {\n // Outside a request: there is no response to write to.\n }\n })\n .client((): void => {});\n\nconst readServerSearch = createIsomorphicFn()\n .server((): string => {\n try {\n return getRequestUrl().search;\n } catch {\n return '';\n }\n })\n .client((): string => '');\n\n/**\n * The query string of the page being rendered (`?lang=en`, or `''`): the request's on the\n * server, the address bar's in the browser, so both sides read the same one.\n */\nexport function readPageSearch(): string {\n return readServerSearch() || (typeof window !== 'undefined' ? window.location.search : '');\n}\n\n/** The `Cookie` header of the request being handled, or `document.cookie` in the browser. */\nexport function readCookieHeader(): string | null {\n return readServerCookieHeader() ?? (typeof document !== 'undefined' ? document.cookie : null);\n}\n\n/** Remembers `code` as the visitor's language for every store on this host. */\nexport function persistLanguageCookie(code: string): void {\n writeServerLanguageCookie(code);\n if (typeof document !== 'undefined') {\n document.cookie = `${LANGUAGE_COOKIE_NAME}=${encodeURIComponent(code)}; path=/; max-age=${LANGUAGE_COOKIE_MAX_AGE}; SameSite=Lax`;\n }\n}\n","/** The headers the Salla native app sends with every page it loads in its webview. */\nexport const NATIVE_APP_HEADERS = [\n 's-app-os',\n 's-app-version',\n 's-app-full-version',\n 's-app-os-version',\n];\n\n/**\n * The native app's own headers on this request, or null when it is not the app.\n *\n * On a Twig theme Laravel copies them into the settings' `jitsu.context.extra.headers`,\n * where the SDK reads the app's platform and version from (`salla.config.isMobileApp()`).\n * A React theme asks for its settings from the server, through the API, so the app's\n * headers never reach that call: the request is the only place they are.\n */\nexport function readNativeAppHeaders(headers: Headers): Record<string, string> | null {\n const os = headers.get('s-app-os')?.toLowerCase();\n if (os !== 'ios' && os !== 'android') return null;\n const found: Record<string, string> = {};\n for (const name of NATIVE_APP_HEADERS) {\n const value = headers.get(name);\n if (value) found[name] = value;\n }\n return found;\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { setCookie } from '@tanstack/react-start/server';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport { api, getActiveScope, getAuthToken, STORE_IDENTIFIER_HEADER } from './client';\nimport { devSettingsFetchedAt } from './dev-settings-cache';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext, revokeAuthToken } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { AUTH_TOKEN_COOKIE_NAME, extractScopeFromUrl, parseStoreId } from '../utils/cookies';\nimport { readPageSearch } from '../utils/language-cookie';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\nimport { isNotLaunchedNotice } from '../utils/maintenance';\n\nexport { resolveStoreIdentifier };\n\nconst DEFAULT_INCLUDE_ITEMS = [\n 'store',\n 'settings',\n 'theme',\n 'theme_settings',\n 'external_services',\n 'currencies',\n 'languages',\n 'payments',\n 'product_widgets',\n 'rating',\n 'ratings',\n 'user',\n];\n\n/** Twig's `salla.init({ user })` object; the endpoint ignores the token, so always the guest. */\nexport interface SettingsUser {\n type: 'guest' | 'user';\n id?: number | string | null;\n language_code?: string;\n currency_code?: string;\n country_code?: string;\n [key: string]: unknown;\n}\n\n/**\n * Raw API response for settings endpoint.\n * Languages come as object: { \"AR\": { code, name, ... }, \"EN\": {...} }\n */\ninterface SettingsApiResponse {\n store?: Store;\n theme?: Theme;\n languages?: Record<string, Language>;\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean;\n policy_url?: string;\n user?: SettingsUser;\n jitsu?: JitsuConfig;\n maintenance?: boolean;\n maintenance_details?: MaintenanceDetails;\n}\n\n/**\n * Central settings context - single source of truth for all API data.\n * Contains everything from the settings endpoint response after processing.\n */\nexport interface StoreContext {\n store?: Store;\n theme?: Theme;\n /** Languages as array after conversion from API object format */\n languages?: Language[];\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean; // todo:: remove it\n policy_url?: string;\n user?: SettingsUser;\n /** Where the SDK's analytics send events, and which ones; without it the SDK tracks nothing. */\n jitsu?: JitsuConfig;\n /**\n * The store is closed: by the merchant from the dashboard, by the platform, or\n * for the selected market only. The engine then renders the maintenance page\n * to everyone but the merchant; see `rootBeforeLoad`.\n */\n maintenance?: boolean;\n /** What the maintenance page says; sent beside `maintenance`. */\n maintenance_details?: MaintenanceDetails;\n /**\n * `false` while the store has not launched yet: `maintenance` is then `true` and the\n * engine's maintenance page says the store is launching soon. Absent otherwise. Not\n * from the API: read off `maintenance_details` by `store.settings`, since the\n * backend sends the merchant's \"finish launching\" notice there for every visitor,\n * which is not for a customer's eyes.\n */\n launched?: false;\n /**\n * The scope these settings were requested with; absent when none was. Not from\n * the API: stamped by `store.settings`, so `resolveThemeVersionId` can tell\n * whether the version they name still answers the scope that is active now.\n */\n requestedScopeId?: string;\n /** Which answer of the API these settings are; see {@link SettingsAnswer}. */\n answer?: SettingsAnswer;\n /**\n * When the dev server fetched these settings from the API (epoch ms). It reuses\n * them for a while (see `dev-settings-cache.ts`) and the theme editor says how old\n * they are. Only on a dev server render; absent everywhere else.\n */\n devFetchedAt?: number;\n}\n\n/**\n * Which answer of the settings API a set of settings came from, read off the\n * response rather than the body: the API's request id, the Store's trace, and\n * whether Cloudflare served it from its cache and how old it was. A decision the\n * settings drive for every visitor alike (the maintenance page) can then be\n * traced to the exact request the backend logged, or to a cached copy of it.\n */\nexport interface SettingsAnswer {\n requestId?: string;\n traceId?: string;\n cacheStatus?: string;\n age?: string;\n}\n\nconst ANSWER_HEADERS: Record<keyof SettingsAnswer, string> = {\n requestId: 's-request-id',\n traceId: 'x-trace-id',\n cacheStatus: 'cf-cache-status',\n age: 'age',\n};\n\nfunction settingsAnswerOf(headers: Headers | undefined): SettingsAnswer | undefined {\n if (!headers) return undefined;\n const answer: SettingsAnswer = {};\n for (const [field, name] of Object.entries(ANSWER_HEADERS) as [keyof SettingsAnswer, string][]) {\n const value = headers.get(name);\n if (value) answer[field] = value;\n }\n return Object.keys(answer).length ? answer : undefined;\n}\n\n/**\n * Converts languages object from API to array format.\n * API returns: { \"AR\": { code, name, ... }, \"EN\": { ... } }\n * We need: [{ code, name, ... }, { code, name, ... }]\n * todo:: return the languages as object from the APIs to avoid this\n */\nfunction languagesToArray(languages?: Record<string, Language>): Language[] | undefined {\n if (!languages) return undefined;\n // The SDK's localization modal reads `lang.iso_code` (not `code`) when a language is\n // selected — without it the switch navigates to `/undefined/...`.\n return Object.values(languages).map((lang) => ({ iso_code: lang.code, ...lang }));\n}\n\n/**\n * The settings' analytics context with the native app's headers in it, as Laravel\n * writes it for a Twig theme: the SDK reads the app's platform and version from there.\n * The API answers a server-side call with the engine's own headers, never the app's.\n */\nfunction withNativeAppHeaders(jitsu?: JitsuConfig): JitsuConfig | undefined {\n if (!jitsu || typeof window !== 'undefined') return jitsu;\n let appHeaders: Record<string, string> | null = null;\n try {\n appHeaders = getTwilightContext().nativeAppHeaders;\n } catch {\n return jitsu;\n }\n if (!appHeaders) return jitsu;\n const extra = jitsu.context?.extra;\n // The engine's own app headers go, so an app that sends no version doesn't get the engine's.\n const headers = { ...extra?.headers };\n for (const name of NATIVE_APP_HEADERS) delete headers[name];\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers: { ...headers, ...appHeaders } },\n },\n };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\n/**\n * Whether the page's own address switches market (`?scope=`).\n *\n * Only then does the settings request name the scope in its query string. The API\n * reads `?scope=` as a switch and lets it override the market a market's own domain\n * is pinned to, which the `s-scope-id` header never does. Sent on every request, a\n * market remembered from another visit would win over the host the shopper is on: the\n * settings, and the SDK seeded from them, would answer for that market while every\n * call without the parameter (the cart, among them) answers for the host's, and a\n * guest's cart created in one is refused by the other (TD-17588).\n */\nfunction pageSwitchesScope(): boolean {\n return extractScopeFromUrl(`http://page.invalid/${readPageSearch()}`) !== null;\n}\n\nasync function requestSettings(identifier: string): Promise<StoreContext> {\n const includeParams = DEFAULT_INCLUDE_ITEMS.map((i) => `include[]=${i}`).join('&');\n const scope = getActiveScope();\n const params =\n scope != null && pageSwitchesScope() ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const request = api\n // Sent explicitly rather than left to the client's own resolution, so\n // the identifier this function checked is the identifier that travels.\n // They agree today; a caller passing one and being answered about\n // another is the failure this makes impossible rather than unlikely.\n .get(`store/settings?${params}`, {\n timeout: SETTINGS_TIMEOUT_MS,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n });\n const json = await request.json<{ data?: SettingsApiResponse }>();\n // The same response, already settled; only its headers are read.\n const headers = (await request)?.headers;\n const answer = settingsAnswerOf(headers);\n const devFetchedAt = devSettingsFetchedAt(headers);\n\n const data = json?.data;\n if (!data) {\n throw new SettingsError(\n `The Salla API answered the settings request for store \"${identifier}\" without settings.`,\n { reason: 'empty' }\n );\n }\n\n // Convert languages from object to array\n const languages = languagesToArray(data.languages);\n\n return {\n store: data.store,\n theme: data.theme,\n languages,\n currencies: data.currencies,\n external_services: data.external_services,\n headers: data.headers,\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(data.maintenance === true &&\n isNotLaunchedNotice(data.maintenance_details) && { launched: false as const }),\n ...(scope && { requestedScopeId: scope.id }),\n ...(answer && { answer }),\n ...(devFetchedAt && { devFetchedAt }),\n };\n}\n\n/** The message the API put in an error body, `{ error: { message } }`, when it sent one. */\nfunction apiErrorMessage(data: unknown): string | undefined {\n const message = (data as { error?: { message?: unknown } } | undefined)?.error?.message;\n return typeof message === 'string' && message.length > 0 && message.length <= 200\n ? message\n : undefined;\n}\n\n/**\n * What core's `CurrentStoreMiddleware` answers, with a 422, when no store has the\n * username or domain it was given (or the store's status is `deleted`). The lookup is\n * `loadUseUsernameOrDomain`, the same one Twig's `checkUsername` turns into its 410.\n * The literal is not translated: it reads the same whatever language was asked for.\n */\nconst STORE_NOT_FOUND_MESSAGE = 'المتجر غير موجود';\n\n/**\n * Whether the API answered that no store has this identifier. A numeric identifier\n * is looked up with `findOrFail`, which Store's exception handler answers with a 410;\n * a username or domain gets {@link STORE_NOT_FOUND_MESSAGE}. A 410 for a username is\n * not read as one: nothing on that path answers it, and a store that does exist must\n * never be told it does not.\n */\nfunction isStoreNotFound(identifier: string, status: number, said: string | undefined): boolean {\n if (status === 410) return parseStoreId(identifier) !== null;\n return status === 422 && said === STORE_NOT_FOUND_MESSAGE;\n}\n\n/**\n * Whether the API answered that the token was signed out of all devices. `unauthorized`\n * alone: `token_invalid` is refreshed by the SDK, and a limited token (a review link)\n * gets `policy_token_not_allowed` so that its customer stays signed in.\n */\nfunction isRevokedToken(error: unknown): boolean {\n if (!isHTTPError(error) || error.response.status !== 401) return false;\n return (error.data as { error?: { code?: unknown } } | undefined)?.error?.code === 'unauthorized';\n}\n\n/**\n * Drops a token the API answered as signed out everywhere (401 `unauthorized`), for the\n * rest of this server render and from the visitor's cookie. Without it the render stopped\n * at \"Store Unavailable\" and every reload sent the same token again; the SDK, which signs\n * the customer out on that answer, never loaded to do it.\n *\n * Answers whether there was a token to drop, so the caller knows a retry can differ.\n */\nconst dropRevokedToken = createIsomorphicFn()\n .server((): boolean => {\n // An uncompiled build runs this branch in the browser too; the SDK signs out there.\n if (typeof document !== 'undefined' || !getAuthToken()) return false;\n revokeAuthToken();\n try {\n setCookie(AUTH_TOKEN_COOKIE_NAME, '', { path: '/', maxAge: 0 });\n } catch {\n // Outside a request (prerender): there is no response to write to.\n }\n return true;\n })\n .client((): boolean => false);\n\n/**\n * Names what went wrong, because the page, the server log and Sentry all carry\n * this message. Every failure used to read \"Make sure VITE_STORE_DOMAIN is set\",\n * a local-development variable no deployed theme has, so a slow API looked like\n * a misconfigured theme.\n */\nfunction describeSettingsFailure(identifier: string, error: unknown): SettingsError {\n if (error instanceof SettingsError) return error;\n const request = `the settings request for store \"${identifier}\"`;\n if (isTimeoutError(error)) {\n return new SettingsError(\n `The Salla API did not answer ${request} within ${SETTINGS_TIMEOUT_MS} ms.`,\n { reason: 'timeout' }\n );\n }\n if (isHTTPError(error)) {\n const { status } = error.response;\n const said = apiErrorMessage(error.data);\n return new SettingsError(\n `The Salla API answered ${request} with HTTP ${status}${said ? `: ${said}` : ''}.`,\n { reason: isStoreNotFound(identifier, status, said) ? 'not-found' : 'http', status }\n );\n }\n if (isNetworkError(error)) {\n return new SettingsError(`The Salla API could not be reached for ${request}.`, {\n reason: 'network',\n });\n }\n const detail = error instanceof Error ? `: ${error.message}` : '';\n return new SettingsError(`The settings request for store \"${identifier}\" failed${detail}.`);\n}\n\n/**\n * The settings, or a {@link SettingsError} that says why there are none. The\n * query throws it so the root route can say why the store did not load;\n * `store.settings` keeps answering `null` for its own callers.\n */\nasync function fetchSettings(storeIdentifier?: string): Promise<StoreContext> {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n const error = new SettingsError(\n 'No store is named for this request: add `?storeId=` on the preview host, or set VITE_STORE_DOMAIN in local development.',\n { reason: 'no-store' }\n );\n console.warn('[store.settings]', error.message);\n throw error;\n }\n\n try {\n return await requestSettings(identifier);\n } catch (cause) {\n // Asked again as a guest, once: the second time there is no token left to drop.\n if (isRevokedToken(cause) && dropRevokedToken()) return fetchSettings(identifier);\n const error = describeSettingsFailure(identifier, cause);\n console.error('[store.settings]', error.message, ...(cause === error ? [] : [cause]));\n throw error;\n }\n}\n\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n try {\n return await fetchSettings(storeIdentifier);\n } catch {\n // Already logged, with the reason.\n return null;\n }\n },\n\n queries: {\n settings: (storeIdentifier?: string) =>\n queryOptions<StoreContext | null>({\n queryKey: [\n 'store',\n 'settings',\n storeIdentifier,\n getTwilightContext().locale,\n getActiveScope(),\n // Two versions of one store's settings are two different answers, and\n // this is the query whose answer decides what every other call is\n // pinned to. `requestedThemeVersionId` rather than the resolved one:\n // the resolved value falls back to what these settings report, so it\n // is not knowable until after this query has run — the key would be\n // one thing on the server and another on the client, and the hydrated\n // page would refetch the settings it was just handed.\n requestedThemeVersionId(),\n ],\n // Throws rather than resolving `null`, so the failure keeps its reason.\n queryFn: () => fetchSettings(storeIdentifier),\n // A null never retried, and the root route waits on this: the router's\n // default `retry: 1` would sit through the timeout twice.\n retry: 0,\n }),\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/language-cookie.ts","../src/utils/native-app-headers.ts","../src/api/store.ts"],"names":["createIsomorphicFn","setCookie"],"mappings":";;;;;;;;;;AAaA,IAAM,sBAAA,GAAyB,kBAAA,EAAmB,CAC/C,MAAA,CAAO,MAAqB;AAC3B,EAAA,IAAI;AACF,IAAA,OAAO,gBAAA,CAAiB,QAAQ,CAAA,IAAK,IAAA;AAAA,EACvC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAC,CAAA,CACA,MAAA,CAAO,MAAqB,IAAI,CAAA;AAEnC,IAAM,yBAAA,GAA4B,kBAAA,EAAmB,CAClD,MAAA,CAAO,CAAC,IAAA,KAAuB;AAC9B,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,sBAAsB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;AAEN,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,CAAC,eAAA,KACT,YAAA,CAAkC;AAAA,MAChC,QAAA,EAAU;AAAA,QACR,OAAA;AAAA,QACA,UAAA;AAAA,QACA,eAAA;AAAA,QACA,oBAAmB,CAAE,MAAA;AAAA,QACrB,cAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQf,uBAAA;AAAwB,OAC1B;AAAA;AAAA,MAEA,OAAA,EAAS,MAAM,aAAA,CAAc,eAAe,CAAA;AAAA;AAAA;AAAA,MAG5C,KAAA,EAAO;AAAA,KACR;AAAA;AAEP","file":"chunk-RLT3D2LR.js","sourcesContent":["/**\n * @fileoverview Reading and writing the `s-lang` cookie, on the server and in the browser.\n *\n * The server reads it from the request the framework is handling and writes it to that\n * request's response. The server-only import is stripped from the client bundle by\n * `createIsomorphicFn`, as in `routes/root/beforeLoad.ts`. The browser uses `document.cookie`.\n * Either side outside a request (a prerender, a test) has nothing to read or write and says so\n * quietly.\n */\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getRequestHeader, getRequestUrl, setCookie } from '@tanstack/react-start/server';\nimport { LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_COOKIE_NAME } from './cookies';\n\nconst readServerCookieHeader = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getRequestHeader('cookie') ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => null);\n\nconst writeServerLanguageCookie = createIsomorphicFn()\n .server((code: string): void => {\n try {\n setCookie(LANGUAGE_COOKIE_NAME, code, {\n path: '/',\n maxAge: LANGUAGE_COOKIE_MAX_AGE,\n sameSite: 'lax',\n });\n } catch {\n // Outside a request: there is no response to write to.\n }\n })\n .client((): void => {});\n\nconst readServerSearch = createIsomorphicFn()\n .server((): string => {\n try {\n return getRequestUrl().search;\n } catch {\n return '';\n }\n })\n .client((): string => '');\n\n/**\n * The query string of the page being rendered (`?lang=en`, or `''`): the request's on the\n * server, the address bar's in the browser, so both sides read the same one.\n */\nexport function readPageSearch(): string {\n return readServerSearch() || (typeof window !== 'undefined' ? window.location.search : '');\n}\n\n/** The `Cookie` header of the request being handled, or `document.cookie` in the browser. */\nexport function readCookieHeader(): string | null {\n return readServerCookieHeader() ?? (typeof document !== 'undefined' ? document.cookie : null);\n}\n\n/** Remembers `code` as the visitor's language for every store on this host. */\nexport function persistLanguageCookie(code: string): void {\n writeServerLanguageCookie(code);\n if (typeof document !== 'undefined') {\n document.cookie = `${LANGUAGE_COOKIE_NAME}=${encodeURIComponent(code)}; path=/; max-age=${LANGUAGE_COOKIE_MAX_AGE}; SameSite=Lax`;\n }\n}\n","/** The headers the Salla native app sends with every page it loads in its webview. */\nexport const NATIVE_APP_HEADERS = [\n 's-app-os',\n 's-app-version',\n 's-app-full-version',\n 's-app-os-version',\n];\n\n/**\n * The native app's own headers on this request, or null when it is not the app.\n *\n * On a Twig theme Laravel copies them into the settings' `jitsu.context.extra.headers`,\n * where the SDK reads the app's platform and version from (`salla.config.isMobileApp()`).\n * A React theme asks for its settings from the server, through the API, so the app's\n * headers never reach that call: the request is the only place they are.\n */\nexport function readNativeAppHeaders(headers: Headers): Record<string, string> | null {\n const os = headers.get('s-app-os')?.toLowerCase();\n if (os !== 'ios' && os !== 'android') return null;\n const found: Record<string, string> = {};\n for (const name of NATIVE_APP_HEADERS) {\n const value = headers.get(name);\n if (value) found[name] = value;\n }\n return found;\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { setCookie } from '@tanstack/react-start/server';\nimport { isHTTPError, isNetworkError, isTimeoutError } from 'ky';\nimport { api, getActiveScope, getAuthToken, STORE_IDENTIFIER_HEADER } from './client';\nimport { devSettingsFetchedAt } from './dev-settings-cache';\nimport { SettingsError } from '../utils/errors';\nimport type { Store, Theme, Language, JitsuConfig, MaintenanceDetails } from '../types';\nimport { getTwilightContext, revokeAuthToken } from '../twilight/context';\nimport { resolveStoreIdentifier } from '../utils/store-identity';\nimport { AUTH_TOKEN_COOKIE_NAME, extractScopeFromUrl, parseStoreId } from '../utils/cookies';\nimport { readPageSearch } from '../utils/language-cookie';\nimport { requestedThemeVersionId } from '../utils/theme-version';\nimport { NATIVE_APP_HEADERS } from '../utils/native-app-headers';\nimport { isNotLaunchedNotice } from '../utils/maintenance';\n\nexport { resolveStoreIdentifier };\n\nconst DEFAULT_INCLUDE_ITEMS = [\n 'store',\n 'settings',\n 'theme',\n 'theme_settings',\n 'external_services',\n 'currencies',\n 'languages',\n 'payments',\n 'product_widgets',\n 'rating',\n 'ratings',\n 'user',\n];\n\n/** Twig's `salla.init({ user })` object; the endpoint ignores the token, so always the guest. */\nexport interface SettingsUser {\n type: 'guest' | 'user';\n id?: number | string | null;\n language_code?: string;\n currency_code?: string;\n country_code?: string;\n [key: string]: unknown;\n}\n\n/**\n * Raw API response for settings endpoint.\n * Languages come as object: { \"AR\": { code, name, ... }, \"EN\": {...} }\n */\ninterface SettingsApiResponse {\n store?: Store;\n theme?: Theme;\n languages?: Record<string, Language>;\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean;\n policy_url?: string;\n user?: SettingsUser;\n jitsu?: JitsuConfig;\n maintenance?: boolean;\n maintenance_details?: MaintenanceDetails;\n}\n\n/**\n * Central settings context - single source of truth for all API data.\n * Contains everything from the settings endpoint response after processing.\n */\nexport interface StoreContext {\n store?: Store;\n theme?: Theme;\n /** Languages as array after conversion from API object format */\n languages?: Language[];\n currencies?: Record<\n string,\n { code: string; name: string; symbol: string; amount: number; country_code: string }\n >;\n external_services?: Record<string, unknown>;\n headers?: Record<string, unknown>;\n login?: { url: string; turnstile_site_key: string };\n affiliate?: { utm_url: string; cta_enabled: boolean };\n debug?: boolean;\n trace_console?: boolean; // todo:: remove it\n policy_url?: string;\n user?: SettingsUser;\n /** Where the SDK's analytics send events, and which ones; without it the SDK tracks nothing. */\n jitsu?: JitsuConfig;\n /**\n * The store is closed: by the merchant from the dashboard, by the platform, or\n * for the selected market only. The engine then renders the maintenance page\n * to everyone but the merchant; see `rootBeforeLoad`.\n */\n maintenance?: boolean;\n /** What the maintenance page says; sent beside `maintenance`. */\n maintenance_details?: MaintenanceDetails;\n /**\n * `false` while the store has not launched yet: `maintenance` is then `true` and the\n * engine's maintenance page says the store is launching soon. Absent otherwise. Not\n * from the API: read off `maintenance_details` by `store.settings`, since the\n * backend sends the merchant's \"finish launching\" notice there for every visitor,\n * which is not for a customer's eyes.\n */\n launched?: false;\n /**\n * The scope these settings were requested with; absent when none was. Not from\n * the API: stamped by `store.settings`, so `resolveThemeVersionId` can tell\n * whether the version they name still answers the scope that is active now.\n */\n requestedScopeId?: string;\n /** Which answer of the API these settings are; see {@link SettingsAnswer}. */\n answer?: SettingsAnswer;\n /**\n * When the dev server fetched these settings from the API (epoch ms). It reuses\n * them for a while (see `dev-settings-cache.ts`) and the theme editor says how old\n * they are. Only on a dev server render; absent everywhere else.\n */\n devFetchedAt?: number;\n}\n\n/**\n * Which answer of the settings API a set of settings came from, read off the\n * response rather than the body: the API's request id, the Store's trace, and\n * whether Cloudflare served it from its cache and how old it was. A decision the\n * settings drive for every visitor alike (the maintenance page) can then be\n * traced to the exact request the backend logged, or to a cached copy of it.\n */\nexport interface SettingsAnswer {\n requestId?: string;\n traceId?: string;\n cacheStatus?: string;\n age?: string;\n}\n\nconst ANSWER_HEADERS: Record<keyof SettingsAnswer, string> = {\n requestId: 's-request-id',\n traceId: 'x-trace-id',\n cacheStatus: 'cf-cache-status',\n age: 'age',\n};\n\nfunction settingsAnswerOf(headers: Headers | undefined): SettingsAnswer | undefined {\n if (!headers) return undefined;\n const answer: SettingsAnswer = {};\n for (const [field, name] of Object.entries(ANSWER_HEADERS) as [keyof SettingsAnswer, string][]) {\n const value = headers.get(name);\n if (value) answer[field] = value;\n }\n return Object.keys(answer).length ? answer : undefined;\n}\n\n/**\n * Converts languages object from API to array format.\n * API returns: { \"AR\": { code, name, ... }, \"EN\": { ... } }\n * We need: [{ code, name, ... }, { code, name, ... }]\n * todo:: return the languages as object from the APIs to avoid this\n */\nfunction languagesToArray(languages?: Record<string, Language>): Language[] | undefined {\n if (!languages) return undefined;\n // The SDK's localization modal reads `lang.iso_code` (not `code`) when a language is\n // selected — without it the switch navigates to `/undefined/...`.\n return Object.values(languages).map((lang) => ({ iso_code: lang.code, ...lang }));\n}\n\n/**\n * The settings' analytics context with the native app's headers in it, as Laravel\n * writes it for a Twig theme: the SDK reads the app's platform and version from there.\n * The API answers a server-side call with the engine's own headers, never the app's.\n */\nfunction withNativeAppHeaders(jitsu?: JitsuConfig): JitsuConfig | undefined {\n if (!jitsu || typeof window !== 'undefined') return jitsu;\n let appHeaders: Record<string, string> | null = null;\n try {\n appHeaders = getTwilightContext().nativeAppHeaders;\n } catch {\n return jitsu;\n }\n if (!appHeaders) return jitsu;\n const extra = jitsu.context?.extra;\n // The engine's own app headers go, so an app that sends no version doesn't get the engine's.\n const headers = { ...extra?.headers };\n for (const name of NATIVE_APP_HEADERS) delete headers[name];\n return {\n ...jitsu,\n context: {\n ...jitsu.context,\n extra: { ...extra, headers: { ...headers, ...appHeaders } },\n },\n };\n}\n\nconst SETTINGS_TIMEOUT_MS = 5000;\n\n/**\n * Whether the page's own address switches market (`?scope=`).\n *\n * Only then does the settings request name the scope in its query string. The API\n * reads `?scope=` as a switch and lets it override the market a market's own domain\n * is pinned to, which the `s-scope-id` header never does. Sent on every request, a\n * market remembered from another visit would win over the host the shopper is on: the\n * settings, and the SDK seeded from them, would answer for that market while every\n * call without the parameter (the cart, among them) answers for the host's, and a\n * guest's cart created in one is refused by the other (TD-17588).\n */\nfunction pageSwitchesScope(): boolean {\n return extractScopeFromUrl(`http://page.invalid/${readPageSearch()}`) !== null;\n}\n\nasync function requestSettings(identifier: string): Promise<StoreContext> {\n const includeParams = DEFAULT_INCLUDE_ITEMS.map((i) => `include[]=${i}`).join('&');\n const scope = getActiveScope();\n const params =\n scope != null && pageSwitchesScope() ? `${includeParams}&scope=${scope.id}` : includeParams;\n\n const request = api\n // Sent explicitly rather than left to the client's own resolution, so\n // the identifier this function checked is the identifier that travels.\n // They agree today; a caller passing one and being answered about\n // another is the failure this makes impossible rather than unlikely.\n .get(`store/settings?${params}`, {\n timeout: SETTINGS_TIMEOUT_MS,\n headers: { [STORE_IDENTIFIER_HEADER]: identifier },\n });\n const json = await request.json<{ data?: SettingsApiResponse }>();\n // The same response, already settled; only its headers are read.\n const headers = (await request)?.headers;\n const answer = settingsAnswerOf(headers);\n const devFetchedAt = devSettingsFetchedAt(headers);\n\n const data = json?.data;\n if (!data) {\n throw new SettingsError(\n `The Salla API answered the settings request for store \"${identifier}\" without settings.`,\n { reason: 'empty' }\n );\n }\n\n // Convert languages from object to array\n const languages = languagesToArray(data.languages);\n\n return {\n store: data.store,\n theme: data.theme,\n languages,\n currencies: data.currencies,\n external_services: data.external_services,\n headers: data.headers,\n login: data.login,\n affiliate: data.affiliate,\n policy_url: data.policy_url,\n user: data.user,\n jitsu: withNativeAppHeaders(data.jitsu),\n maintenance: data.maintenance,\n maintenance_details: data.maintenance_details,\n ...(data.maintenance === true &&\n isNotLaunchedNotice(data.maintenance_details) && { launched: false as const }),\n ...(scope && { requestedScopeId: scope.id }),\n ...(answer && { answer }),\n ...(devFetchedAt && { devFetchedAt }),\n };\n}\n\n/** The message the API put in an error body, `{ error: { message } }`, when it sent one. */\nfunction apiErrorMessage(data: unknown): string | undefined {\n const message = (data as { error?: { message?: unknown } } | undefined)?.error?.message;\n return typeof message === 'string' && message.length > 0 && message.length <= 200\n ? message\n : undefined;\n}\n\n/**\n * What core's `CurrentStoreMiddleware` answers, with a 422, when no store has the\n * username or domain it was given (or the store's status is `deleted`). The lookup is\n * `loadUseUsernameOrDomain`, the same one Twig's `checkUsername` turns into its 410.\n * The literal is not translated: it reads the same whatever language was asked for.\n */\nconst STORE_NOT_FOUND_MESSAGE = 'المتجر غير موجود';\n\n/**\n * Whether the API answered that no store has this identifier. A numeric identifier\n * is looked up with `findOrFail`, which Store's exception handler answers with a 410;\n * a username or domain gets {@link STORE_NOT_FOUND_MESSAGE}. A 410 for a username is\n * not read as one: nothing on that path answers it, and a store that does exist must\n * never be told it does not.\n */\nfunction isStoreNotFound(identifier: string, status: number, said: string | undefined): boolean {\n if (status === 410) return parseStoreId(identifier) !== null;\n return status === 422 && said === STORE_NOT_FOUND_MESSAGE;\n}\n\n/**\n * Whether the API answered that the token was signed out of all devices. `unauthorized`\n * alone: `token_invalid` is refreshed by the SDK, and a limited token (a review link)\n * gets `policy_token_not_allowed` so that its customer stays signed in.\n */\nfunction isRevokedToken(error: unknown): boolean {\n if (!isHTTPError(error) || error.response.status !== 401) return false;\n return (error.data as { error?: { code?: unknown } } | undefined)?.error?.code === 'unauthorized';\n}\n\n/**\n * Drops a token the API answered as signed out everywhere (401 `unauthorized`), for the\n * rest of this server render and from the visitor's cookie. Without it the render stopped\n * at \"Store Unavailable\" and every reload sent the same token again; the SDK, which signs\n * the customer out on that answer, never loaded to do it.\n *\n * Answers whether there was a token to drop, so the caller knows a retry can differ.\n */\nconst dropRevokedToken = createIsomorphicFn()\n .server((): boolean => {\n // An uncompiled build runs this branch in the browser too; the SDK signs out there.\n if (typeof document !== 'undefined' || !getAuthToken()) return false;\n revokeAuthToken();\n try {\n setCookie(AUTH_TOKEN_COOKIE_NAME, '', { path: '/', maxAge: 0 });\n } catch {\n // Outside a request (prerender): there is no response to write to.\n }\n return true;\n })\n .client((): boolean => false);\n\n/**\n * Names what went wrong, because the page, the server log and Sentry all carry\n * this message. Every failure used to read \"Make sure VITE_STORE_DOMAIN is set\",\n * a local-development variable no deployed theme has, so a slow API looked like\n * a misconfigured theme.\n */\nfunction describeSettingsFailure(identifier: string, error: unknown): SettingsError {\n if (error instanceof SettingsError) return error;\n const request = `the settings request for store \"${identifier}\"`;\n if (isTimeoutError(error)) {\n return new SettingsError(\n `The Salla API did not answer ${request} within ${SETTINGS_TIMEOUT_MS} ms.`,\n { reason: 'timeout' }\n );\n }\n if (isHTTPError(error)) {\n const { status } = error.response;\n const said = apiErrorMessage(error.data);\n return new SettingsError(\n `The Salla API answered ${request} with HTTP ${status}${said ? `: ${said}` : ''}.`,\n { reason: isStoreNotFound(identifier, status, said) ? 'not-found' : 'http', status }\n );\n }\n if (isNetworkError(error)) {\n return new SettingsError(`The Salla API could not be reached for ${request}.`, {\n reason: 'network',\n });\n }\n const detail = error instanceof Error ? `: ${error.message}` : '';\n return new SettingsError(`The settings request for store \"${identifier}\" failed${detail}.`);\n}\n\n/**\n * The settings, or a {@link SettingsError} that says why there are none. The\n * query throws it so the root route can say why the store did not load;\n * `store.settings` keeps answering `null` for its own callers.\n */\nasync function fetchSettings(storeIdentifier?: string): Promise<StoreContext> {\n const identifier = storeIdentifier ?? resolveStoreIdentifier();\n\n if (!identifier) {\n const error = new SettingsError(\n 'No store is named for this request: add `?storeId=` on the preview host, or set VITE_STORE_DOMAIN in local development.',\n { reason: 'no-store' }\n );\n console.warn('[store.settings]', error.message);\n throw error;\n }\n\n try {\n return await requestSettings(identifier);\n } catch (cause) {\n // Asked again as a guest, once: the second time there is no token left to drop.\n if (isRevokedToken(cause) && dropRevokedToken()) return fetchSettings(identifier);\n const error = describeSettingsFailure(identifier, cause);\n console.error('[store.settings]', error.message, ...(cause === error ? [] : [cause]));\n throw error;\n }\n}\n\nexport const store = {\n settings: async (storeIdentifier?: string): Promise<StoreContext | null> => {\n try {\n return await fetchSettings(storeIdentifier);\n } catch {\n // Already logged, with the reason.\n return null;\n }\n },\n\n queries: {\n settings: (storeIdentifier?: string) =>\n queryOptions<StoreContext | null>({\n queryKey: [\n 'store',\n 'settings',\n storeIdentifier,\n getTwilightContext().locale,\n getActiveScope(),\n // Two versions of one store's settings are two different answers, and\n // this is the query whose answer decides what every other call is\n // pinned to. `requestedThemeVersionId` rather than the resolved one:\n // the resolved value falls back to what these settings report, so it\n // is not knowable until after this query has run — the key would be\n // one thing on the server and another on the client, and the hydrated\n // page would refetch the settings it was just handed.\n requestedThemeVersionId(),\n ],\n // Throws rather than resolving `null`, so the failure keeps its reason.\n queryFn: () => fetchSettings(storeIdentifier),\n // A null never retried, and the root route waits on this: the router's\n // default `retry: 1` would sit through the timeout twice.\n retry: 0,\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from './chunk-
|
|
1
|
+
import { api } from './chunk-BM43QN4L.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-
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-RZN7X72V.js.map
|
|
28
|
+
//# sourceMappingURL=chunk-RZN7X72V.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/notification.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAA,GAAe;AAAA,EAC1B,MAAM,YAAgD;AACpD,IAAA,MAAM,WAAW,MAAM,GAAA,CACpB,GAAA,CAAI,eAAe,EACnB,IAAA,EAAmF;AACtF,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,QAAA,CAAS,IAAA,IAAQ,EAAC;AAAA,MACxB,QAAQ,QAAA,CAAS;AAAA,KACnB;AAAA,EACF,CAAA;AAAA,EAEA,UAAA,EAAY,OAAO,EAAA,KAA8B;AAC/C,IAAA,MAAM,IAAI,GAAA,CAAI,CAAA,cAAA,EAAiB,EAAE,CAAA,KAAA,CAAO,EAAE,IAAA,EAAK;AAAA,EACjD,CAAA;AAAA,EAEA,eAAe,YAA2B;AACxC,IAAA,MAAM,GAAA,CAAI,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,EAAK;AAAA,EAC/C,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,eAAA,EAAiB,MAAM,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,YAAA,CAAa,IAAA;AAAK,KAClC;AAAA;AAEP","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/api/notification.ts"],"names":[],"mappings":";;;AAcO,IAAM,YAAA,GAAe;AAAA,EAC1B,MAAM,YAAgD;AACpD,IAAA,MAAM,WAAW,MAAM,GAAA,CACpB,GAAA,CAAI,eAAe,EACnB,IAAA,EAAmF;AACtF,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,QAAA,CAAS,IAAA,IAAQ,EAAC;AAAA,MACxB,QAAQ,QAAA,CAAS;AAAA,KACnB;AAAA,EACF,CAAA;AAAA,EAEA,UAAA,EAAY,OAAO,EAAA,KAA8B;AAC/C,IAAA,MAAM,IAAI,GAAA,CAAI,CAAA,cAAA,EAAiB,EAAE,CAAA,KAAA,CAAO,EAAE,IAAA,EAAK;AAAA,EACjD,CAAA;AAAA,EAEA,eAAe,YAA2B;AACxC,IAAA,MAAM,GAAA,CAAI,GAAA,CAAI,wBAAwB,CAAA,CAAE,IAAA,EAAK;AAAA,EAC/C,CAAA;AAAA,EAEA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,MACJ,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,eAAA,EAAiB,MAAM,CAAA;AAAA,MAClC,OAAA,EAAS,MAAM,YAAA,CAAa,IAAA;AAAK,KAClC;AAAA;AAEP","file":"chunk-RZN7X72V.js","sourcesContent":["import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Notification } from '../routes/account/notifications/types';\n\nexport interface NotificationsListResponse {\n data: Notification[];\n cursor: {\n current: number;\n previous: number | null;\n next: number | null;\n count: number;\n };\n}\n\nexport const notification = {\n list: async (): Promise<NotificationsListResponse> => {\n const response = await api\n .get('notifications')\n .json<{ data: Notification[] | null; cursor: NotificationsListResponse['cursor'] }>();\n return {\n data: response.data ?? [],\n cursor: response.cursor,\n };\n },\n\n markAsRead: async (id: number): Promise<void> => {\n await api.put(`notifications/${id}/read`).json();\n },\n\n markAllAsRead: async (): Promise<void> => {\n await api.put('notifications/read-all').json();\n },\n\n queries: {\n list: () =>\n queryOptions({\n queryKey: ['notifications', 'list'],\n queryFn: () => notification.list(),\n }),\n },\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { user } from './chunk-
|
|
1
|
+
import { user } from './chunk-GMBOYIH5.js';
|
|
2
2
|
import { getTwilightContext } from './chunk-MWUAHDQL.js';
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -13,5 +13,5 @@ function useUser() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export { useUser };
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-TBOPWHG4.js.map
|
|
17
|
+
//# sourceMappingURL=chunk-TBOPWHG4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useUser.ts"],"names":[],"mappings":";;;;AAUO,SAAS,OAAA,GAAyB;AACvC,EAAA,MAAM,KAAA,GAAQ,oBAAmB,CAAE,SAAA;AAEnC,EAAA,MAAM,QAAQ,QAAA,CAAS;AAAA,IACrB,GAAG,IAAA,CAAK,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACxB,OAAA,EAAS,CAAC,CAAC,KAAA;AAAA,IACX,eAAA,EAAiB;AAAA,GAClB,CAAA;AAED,EAAA,OAAO,EAAE,GAAG,KAAA,EAAO,UAAA,EAAY,CAAC,CAAC,KAAA,EAAM;AACzC","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useUser.ts"],"names":[],"mappings":";;;;AAUO,SAAS,OAAA,GAAyB;AACvC,EAAA,MAAM,KAAA,GAAQ,oBAAmB,CAAE,SAAA;AAEnC,EAAA,MAAM,QAAQ,QAAA,CAAS;AAAA,IACrB,GAAG,IAAA,CAAK,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACxB,OAAA,EAAS,CAAC,CAAC,KAAA;AAAA,IACX,eAAA,EAAiB;AAAA,GAClB,CAAA;AAED,EAAA,OAAO,EAAE,GAAG,KAAA,EAAO,UAAA,EAAY,CAAC,CAAC,KAAA,EAAM;AACzC","file":"chunk-TBOPWHG4.js","sourcesContent":["import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { getTwilightContext } from '../twilight/context';\nimport { user } from '../api/user';\nimport type { User } from '../types';\n\nexport type UseUserReturn = UseQueryResult<User | null> & {\n /** True when an auth token exists (regardless of query state). */\n isLoggedIn: boolean;\n};\n\nexport function useUser(): UseUserReturn {\n const token = getTwilightContext().authToken;\n\n const query = useQuery({\n ...user.queries.current(),\n enabled: !!token,\n placeholderData: null,\n });\n\n return { ...query, isLoggedIn: !!token };\n}\n"]}
|
|
@@ -11,10 +11,10 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
11
11
|
|
|
12
12
|
// src/components/product/lazy.ts
|
|
13
13
|
var LazyProductDetails = lazyComponent(
|
|
14
|
-
() => import('./ProductDetails-
|
|
14
|
+
() => import('./ProductDetails-V5RXYS4P.js').then((m) => ({ default: m.ProductDetails }))
|
|
15
15
|
);
|
|
16
16
|
var LazyAddToCartForm = lazyComponent(
|
|
17
|
-
() => import('./AddToCartForm-
|
|
17
|
+
() => import('./AddToCartForm-KAAJU4A2.js').then((m) => ({ default: m.AddToCartForm }))
|
|
18
18
|
);
|
|
19
19
|
var PRODUCT_GALLERY_KEY = "product:gallery";
|
|
20
20
|
function legacyGalleryMedia(images) {
|
|
@@ -202,5 +202,5 @@ function ThumbSlide({ image, index }) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
export { LazyAddToCartForm, LazyProductDetails, ProductGallery };
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
206
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
//# sourceMappingURL=chunk-TP2GMZEK.js.map
|
|
206
|
+
//# sourceMappingURL=chunk-TP2GMZEK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/product/lazy.ts","../src/components/product/ProductGallery.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEO,IAAM,kBAAA,GAAqB,aAAA;AAAA,EAAc,MAC9C,OAAO,8BAAkB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,cAAA,EAAe,CAAE;AACxE;AAEO,IAAM,iBAAA,GAAoB,aAAA;AAAA,EAAc,MAC7C,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE;ACEA,IAAM,mBAAA,GAAsB,iBAAA;AAc5B,SAAS,mBAAmB,MAAA,EAAwC;AAClE,EAAA,OAAO,MAAA,CAAO,OAAA,CAAsB,CAAC,KAAA,KAAU;AAC7C,IAAA,IAAI,KAAA,CAAM,iBAAA,EAAmB,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,iBAAA,EAAmB,IAAA,EAAM,UAAA,EAAY,CAAA;AACvF,IAAA,IAAI,KAAA,CAAM,SAAA,EAAW,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,SAAA,EAAW,IAAA,EAAM,OAAA,EAAS,CAAA;AACpE,IAAA,OAAO,KAAA,CAAM,GAAA,GAAM,CAAC,EAAE,GAAA,EAAK,KAAA,CAAM,GAAA,EAAK,IAAA,EAAM,OAAA,EAAS,CAAA,GAAI,EAAC;AAAA,EAC5D,CAAC,CAAA;AACH;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KAAA;AAAA,UACZ,UAAU,KAAA,KAAU,CAAA;AAAA,UACpB,SAAA,EAAS,IAAA;AAAA,UACT,MAAA,EAAQ,MAAM,SAAA,CAAU,IAAI;AAAA;AAAA,OAC9B,EACF;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAM,EAA2C;AAC5E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,CAAA,kBAAA,EAAqB,KAAA,CAAM,SAAA,GAAY,aAAA,GAAgB,EAAE,CAAA,CAAA,EAAI,KAAA,CAAM,iBAAA,GAAoB,aAAA,GAAgB,EAAE,CAAA,CAAA;AAAA,MACpH,gBAAc,KAAA,CAAM,GAAA;AAAA,MAEpB,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAK,KAAA,CAAM,GAAA;AAAA,UACX,GAAA,EAAK,MAAM,GAAA,IAAO,EAAA;AAAA,UAClB,SAAA,EAAU,mEAAA;AAAA,UACV,OAAO,KAAA,CAAM,GAAA;AAAA,UACb,UAAU,KAAA,GAAQ,CAAA;AAAA,UAClB,SAAA,EAAS;AAAA;AAAA;AACX;AAAA,GACF;AAEJ","file":"chunk-WGUKNVWJ.js","sourcesContent":["import { lazyComponent } from '../../utils/lazy-component';\n\nexport const LazyProductDetails = lazyComponent(() =>\n import('./ProductDetails').then((m) => ({ default: m.ProductDetails }))\n);\n\nexport const LazyAddToCartForm = lazyComponent(() =>\n import('./AddToCartForm').then((m) => ({ default: m.AddToCartForm }))\n);\n","import { SallaSlider } from '@salla.sa/twilight-components-react/slider';\nimport { Suspense, useEffect, useMemo, useState } from 'react';\nimport { registry } from '../ComponentRegistry';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Product, ProductImage } from '../../types';\nimport { Image } from '../common/Image';\nimport { ImageModal } from '../modal';\nimport { isNativeApp } from '../../native-app';\n\nconst PRODUCT_GALLERY_KEY = 'product:gallery';\n\nexport interface ProductGalleryProps {\n product: Product;\n}\n\ntype ImagePreview = { src: string; alt: string };\ntype GalleryMedia = { url: string; type: 'image' | 'video' | '3d-image' };\n\n/**\n * The engine's own `mobile::gallery.open` payload from before `salla.mobile.openGallery`: a video's\n * link and a 3D model's file go in `url`, with no ids. Sent when the SDK has no `openGallery`\n * (Twilight before 2.14.569) or declines inside the app, so those stores keep the gallery they had.\n */\nfunction legacyGalleryMedia(images: ProductImage[]): GalleryMedia[] {\n return images.flatMap<GalleryMedia>((image) => {\n if (image.three_d_image_url) return [{ url: image.three_d_image_url, type: '3d-image' }];\n if (image.video_url) return [{ url: image.video_url, type: 'video' }];\n return image.url ? [{ url: image.url, type: 'image' }] : [];\n });\n}\n\nfunction ProductGalleryContent({ product }: ProductGalleryProps) {\n const { t } = useTranslation();\n const { theme } = useTwilight();\n const sliderId = `details-slider-${product.id}`;\n const objectFit = theme.settings.slider_background_size ?? 'cover';\n\n // Clicking an image opens an in-app lightbox instead of navigating to the CDN URL.\n const [preview, setPreview] = useState<ImagePreview | null>(null);\n\n useEffect(() => {\n const raf = requestAnimationFrame(() => {\n const el = document.getElementById(sliderId);\n if (!el?.parentElement) return;\n const { parentElement, nextSibling } = el;\n parentElement.removeChild(el);\n parentElement.insertBefore(el, nextSibling);\n });\n return () => cancelAnimationFrame(raf);\n }, [sliderId]);\n\n // The product-details API only returns `image` (singular).\n // Fall back so the main image always renders even without the full gallery array.\n const images: ProductImage[] =\n product.images && product.images.length > 0\n ? product.images\n : product.image?.url\n ? [product.image]\n : [];\n\n const hasManyImages = images.length > 1;\n const openNativeGallery = (selected: ProductImage) => {\n if (!isNativeApp()) return false;\n if (window.salla?.mobile?.openGallery?.(images, selected)) return true;\n window.salla?.event.dispatch('mobile::gallery.open', { images: legacyGalleryMedia(images) });\n return true;\n };\n\n return (\n <div className=\"sidebar md:sticky top-24 w-full md:!w-2/4 rtl:ml-8 ltr:mr-8 pb-8 md:pb-16 overflow-hidden shrink-0\">\n <SallaSlider\n id={sliderId}\n className=\"details-slider rounded-md image-slider\"\n type=\"thumbs\"\n loop={false}\n autoHeight\n listenToThumbnailsOption\n showThumbsControls={false}\n sliderConfig={{ watchOverflow: true, autoHeight: true }}\n >\n {product.promotion_title && (\n <div className=\"promotion-title\">{product.promotion_title}</div>\n )}\n\n {product.calories && (\n <div className=\"absolute z-[2] top-4 rtl:left-4 ltr:right-4 bg-white shadow-sm flex flex-col justify-center items-center rounded-full w-20 h-20 md:w-24 md:h-24\">\n <span className=\"text-red-500 text-xl leading-none font-bold\">{product.calories}</span>\n <span className=\"text-xs text-gray-500\">\n {t('pages.products.calories', 'Calories')}\n </span>\n </div>\n )}\n\n <div slot=\"items\">\n {images.map((image, index) => (\n <ImageSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n product={product}\n index={index}\n objectFit={objectFit}\n onPreview={setPreview}\n onNativeOpen={openNativeGallery}\n />\n ))}\n </div>\n\n {hasManyImages && (\n <div slot=\"thumbs\">\n {images.map((image, index) => (\n <ThumbSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n index={index}\n />\n ))}\n </div>\n )}\n </SallaSlider>\n\n <Suspense fallback={null}>\n <ImageModal\n isOpen={!!preview}\n onClose={() => setPreview(null)}\n src={preview?.src ?? ''}\n alt={preview?.alt}\n />\n </Suspense>\n </div>\n );\n}\n\nexport function ProductGallery(props: ProductGalleryProps) {\n const Component = useMemo(() => {\n const resolved = registry.resolve<ProductGalleryProps>(PRODUCT_GALLERY_KEY);\n // A theme that seeds the key with this component (register + override) would\n // otherwise recurse into itself when it has not actually overridden anything.\n return resolved === ProductGallery ? null : resolved;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductGalleryContent {...props} />;\n}\n\nfunction ImageSlide({\n image,\n product,\n index,\n objectFit,\n onPreview,\n onNativeOpen,\n}: {\n image: ProductImage;\n product: Product;\n index: number;\n objectFit: 'cover' | 'contain';\n onPreview: (preview: ImagePreview) => void;\n onNativeOpen: (image: ProductImage) => boolean;\n}) {\n const [loaded, setLoaded] = useState(false);\n const isVideo = Boolean(image.video_url);\n\n if (image.three_d_image_url) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: model-viewer is an interactive web component.\n <model-viewer\n style={{ minHeight: '500px' }}\n className=\"swiper-slide model-entry w-full h-full\"\n loading=\"lazy\"\n camera-controls\n touch-action=\"pan-y\"\n auto-rotate\n poster={image.url || undefined}\n src={image.three_d_image_url}\n shadow-intensity=\"1\"\n alt={image.alt}\n onClick={() => onNativeOpen(image)}\n ></model-viewer>\n );\n }\n\n return (\n <a\n data-fslightbox={`product_${product.id}`}\n data-img-id={image.id}\n data-slid-index={index}\n {...(image.video_url ? { 'data-video-src': image.video_url } : {})}\n data-caption={image.alt}\n data-infinite=\"false\"\n data-type={image.video_url ? 'youtube' : 'image'}\n href={image.video_url || image.url}\n // FsLightbox isn't loaded in this React theme, so the bare href would leave the SPA.\n // Open images in an in-app lightbox; let videos open in a new tab.\n {...(isVideo ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n onClick={(event) => {\n if (onNativeOpen(image)) {\n event.preventDefault();\n return;\n }\n if (isVideo || !image.url) return;\n event.preventDefault();\n onPreview({ src: image.url, alt: image.alt || product.name });\n }}\n aria-label={product.name}\n className={`swiper-slide magnify-wrapper homeslider__slide ${image.video_url ? 'video-entry' : ''}`}\n >\n <div className={`w-full ${loaded ? '' : 'aspect-square bg-gray-100 animate-pulse'}`}>\n <Image\n id={String(image.id)}\n src={image.url}\n alt={image.alt || product.name}\n className={`h-full w-full object-${objectFit}`}\n aspectRatio=\"1/1\"\n priority={index === 0}\n noWrapper\n onLoad={() => setLoaded(true)}\n />\n </div>\n </a>\n );\n}\n\nfunction ThumbSlide({ image, index }: { image: ProductImage; index: number }) {\n return (\n <div\n className={`slide--one-fourth ${image.video_url ? 'video-entry' : ''} ${image.three_d_image_url ? 'model-entry' : ''}`}\n data-caption={image.alt}\n >\n <Image\n src={image.url}\n alt={image.alt || ''}\n className=\"object-cover w-full h-full bg-gray-100 rounded-md overflow-hidden\"\n title={image.alt}\n priority={index < 5}\n noWrapper\n />\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/product/lazy.ts","../src/components/product/ProductGallery.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEO,IAAM,kBAAA,GAAqB,aAAA;AAAA,EAAc,MAC9C,OAAO,8BAAkB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,cAAA,EAAe,CAAE;AACxE;AAEO,IAAM,iBAAA,GAAoB,aAAA;AAAA,EAAc,MAC7C,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE;ACEA,IAAM,mBAAA,GAAsB,iBAAA;AAc5B,SAAS,mBAAmB,MAAA,EAAwC;AAClE,EAAA,OAAO,MAAA,CAAO,OAAA,CAAsB,CAAC,KAAA,KAAU;AAC7C,IAAA,IAAI,KAAA,CAAM,iBAAA,EAAmB,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,iBAAA,EAAmB,IAAA,EAAM,UAAA,EAAY,CAAA;AACvF,IAAA,IAAI,KAAA,CAAM,SAAA,EAAW,OAAO,CAAC,EAAE,KAAK,KAAA,CAAM,SAAA,EAAW,IAAA,EAAM,OAAA,EAAS,CAAA;AACpE,IAAA,OAAO,KAAA,CAAM,GAAA,GAAM,CAAC,EAAE,GAAA,EAAK,KAAA,CAAM,GAAA,EAAK,IAAA,EAAM,OAAA,EAAS,CAAA,GAAI,EAAC;AAAA,EAC5D,CAAC,CAAA;AACH;AAEA,SAAS,qBAAA,CAAsB,EAAE,OAAA,EAAQ,EAAwB;AAC/D,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,c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AAM,SAAA,CAAU,IAAI;AAAA;AAAA,OAC9B,EACF;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAM,EAA2C;AAC5E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,CAAA,kBAAA,EAAqB,KAAA,CAAM,SAAA,GAAY,aAAA,GAAgB,EAAE,CAAA,CAAA,EAAI,KAAA,CAAM,iBAAA,GAAoB,aAAA,GAAgB,EAAE,CAAA,CAAA;AAAA,MACpH,gBAAc,KAAA,CAAM,GAAA;AAAA,MAEpB,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,KAAK,KAAA,CAAM,GAAA;AAAA,UACX,GAAA,EAAK,MAAM,GAAA,IAAO,EAAA;AAAA,UAClB,SAAA,EAAU,mEAAA;AAAA,UACV,OAAO,KAAA,CAAM,GAAA;AAAA,UACb,UAAU,KAAA,GAAQ,CAAA;AAAA,UAClB,SAAA,EAAS;AAAA;AAAA;AACX;AAAA,GACF;AAEJ","file":"chunk-TP2GMZEK.js","sourcesContent":["import { lazyComponent } from '../../utils/lazy-component';\n\nexport const LazyProductDetails = lazyComponent(() =>\n import('./ProductDetails').then((m) => ({ default: m.ProductDetails }))\n);\n\nexport const LazyAddToCartForm = lazyComponent(() =>\n import('./AddToCartForm').then((m) => ({ default: m.AddToCartForm }))\n);\n","import { SallaSlider } from '@salla.sa/twilight-components-react/slider';\nimport { Suspense, useEffect, useMemo, useState } from 'react';\nimport { registry } from '../ComponentRegistry';\nimport { useTwilight } from '../../providers/TwilightProvider';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport type { Product, ProductImage } from '../../types';\nimport { Image } from '../common/Image';\nimport { ImageModal } from '../modal';\nimport { isNativeApp } from '../../native-app';\n\nconst PRODUCT_GALLERY_KEY = 'product:gallery';\n\nexport interface ProductGalleryProps {\n product: Product;\n}\n\ntype ImagePreview = { src: string; alt: string };\ntype GalleryMedia = { url: string; type: 'image' | 'video' | '3d-image' };\n\n/**\n * The engine's own `mobile::gallery.open` payload from before `salla.mobile.openGallery`: a video's\n * link and a 3D model's file go in `url`, with no ids. Sent when the SDK has no `openGallery`\n * (Twilight before 2.14.569) or declines inside the app, so those stores keep the gallery they had.\n */\nfunction legacyGalleryMedia(images: ProductImage[]): GalleryMedia[] {\n return images.flatMap<GalleryMedia>((image) => {\n if (image.three_d_image_url) return [{ url: image.three_d_image_url, type: '3d-image' }];\n if (image.video_url) return [{ url: image.video_url, type: 'video' }];\n return image.url ? [{ url: image.url, type: 'image' }] : [];\n });\n}\n\nfunction ProductGalleryContent({ product }: ProductGalleryProps) {\n const { t } = useTranslation();\n const { theme } = useTwilight();\n const sliderId = `details-slider-${product.id}`;\n const objectFit = theme.settings.slider_background_size ?? 'cover';\n\n // Clicking an image opens an in-app lightbox instead of navigating to the CDN URL.\n const [preview, setPreview] = useState<ImagePreview | null>(null);\n\n useEffect(() => {\n const raf = requestAnimationFrame(() => {\n const el = document.getElementById(sliderId);\n if (!el?.parentElement) return;\n const { parentElement, nextSibling } = el;\n parentElement.removeChild(el);\n parentElement.insertBefore(el, nextSibling);\n });\n return () => cancelAnimationFrame(raf);\n }, [sliderId]);\n\n // The product-details API only returns `image` (singular).\n // Fall back so the main image always renders even without the full gallery array.\n const images: ProductImage[] =\n product.images && product.images.length > 0\n ? product.images\n : product.image?.url\n ? [product.image]\n : [];\n\n const hasManyImages = images.length > 1;\n const openNativeGallery = (selected: ProductImage) => {\n if (!isNativeApp()) return false;\n if (window.salla?.mobile?.openGallery?.(images, selected)) return true;\n window.salla?.event.dispatch('mobile::gallery.open', { images: legacyGalleryMedia(images) });\n return true;\n };\n\n return (\n <div className=\"sidebar md:sticky top-24 w-full md:!w-2/4 rtl:ml-8 ltr:mr-8 pb-8 md:pb-16 overflow-hidden shrink-0\">\n <SallaSlider\n id={sliderId}\n className=\"details-slider rounded-md image-slider\"\n type=\"thumbs\"\n loop={false}\n autoHeight\n listenToThumbnailsOption\n showThumbsControls={false}\n sliderConfig={{ watchOverflow: true, autoHeight: true }}\n >\n {product.promotion_title && (\n <div className=\"promotion-title\">{product.promotion_title}</div>\n )}\n\n {product.calories && (\n <div className=\"absolute z-[2] top-4 rtl:left-4 ltr:right-4 bg-white shadow-sm flex flex-col justify-center items-center rounded-full w-20 h-20 md:w-24 md:h-24\">\n <span className=\"text-red-500 text-xl leading-none font-bold\">{product.calories}</span>\n <span className=\"text-xs text-gray-500\">\n {t('pages.products.calories', 'Calories')}\n </span>\n </div>\n )}\n\n <div slot=\"items\">\n {images.map((image, index) => (\n <ImageSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n product={product}\n index={index}\n objectFit={objectFit}\n onPreview={setPreview}\n onNativeOpen={openNativeGallery}\n />\n ))}\n </div>\n\n {hasManyImages && (\n <div slot=\"thumbs\">\n {images.map((image, index) => (\n <ThumbSlide\n key={image.id ?? image.three_d_image_url ?? image.video_url ?? image.url}\n image={image}\n index={index}\n />\n ))}\n </div>\n )}\n </SallaSlider>\n\n <Suspense fallback={null}>\n <ImageModal\n isOpen={!!preview}\n onClose={() => setPreview(null)}\n src={preview?.src ?? ''}\n alt={preview?.alt}\n />\n </Suspense>\n </div>\n );\n}\n\nexport function ProductGallery(props: ProductGalleryProps) {\n const Component = useMemo(() => {\n const resolved = registry.resolve<ProductGalleryProps>(PRODUCT_GALLERY_KEY);\n // A theme that seeds the key with this component (register + override) would\n // otherwise recurse into itself when it has not actually overridden anything.\n return resolved === ProductGallery ? null : resolved;\n }, []);\n\n if (Component) {\n return <Component {...props} />;\n }\n\n return <ProductGalleryContent {...props} />;\n}\n\nfunction ImageSlide({\n image,\n product,\n index,\n objectFit,\n onPreview,\n onNativeOpen,\n}: {\n image: ProductImage;\n product: Product;\n index: number;\n objectFit: 'cover' | 'contain';\n onPreview: (preview: ImagePreview) => void;\n onNativeOpen: (image: ProductImage) => boolean;\n}) {\n const [loaded, setLoaded] = useState(false);\n const isVideo = Boolean(image.video_url);\n\n if (image.three_d_image_url) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: model-viewer is an interactive web component.\n <model-viewer\n style={{ minHeight: '500px' }}\n className=\"swiper-slide model-entry w-full h-full\"\n loading=\"lazy\"\n camera-controls\n touch-action=\"pan-y\"\n auto-rotate\n poster={image.url || undefined}\n src={image.three_d_image_url}\n shadow-intensity=\"1\"\n alt={image.alt}\n onClick={() => onNativeOpen(image)}\n ></model-viewer>\n );\n }\n\n return (\n <a\n data-fslightbox={`product_${product.id}`}\n data-img-id={image.id}\n data-slid-index={index}\n {...(image.video_url ? { 'data-video-src': image.video_url } : {})}\n data-caption={image.alt}\n data-infinite=\"false\"\n data-type={image.video_url ? 'youtube' : 'image'}\n href={image.video_url || image.url}\n // FsLightbox isn't loaded in this React theme, so the bare href would leave the SPA.\n // Open images in an in-app lightbox; let videos open in a new tab.\n {...(isVideo ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n onClick={(event) => {\n if (onNativeOpen(image)) {\n event.preventDefault();\n return;\n }\n if (isVideo || !image.url) return;\n event.preventDefault();\n onPreview({ src: image.url, alt: image.alt || product.name });\n }}\n aria-label={product.name}\n className={`swiper-slide magnify-wrapper homeslider__slide ${image.video_url ? 'video-entry' : ''}`}\n >\n <div className={`w-full ${loaded ? '' : 'aspect-square bg-gray-100 animate-pulse'}`}>\n <Image\n id={String(image.id)}\n src={image.url}\n alt={image.alt || product.name}\n className={`h-full w-full object-${objectFit}`}\n aspectRatio=\"1/1\"\n priority={index === 0}\n noWrapper\n onLoad={() => setLoaded(true)}\n />\n </div>\n </a>\n );\n}\n\nfunction ThumbSlide({ image, index }: { image: ProductImage; index: number }) {\n return (\n <div\n className={`slide--one-fourth ${image.video_url ? 'video-entry' : ''} ${image.three_d_image_url ? 'model-entry' : ''}`}\n data-caption={image.alt}\n >\n <Image\n src={image.url}\n alt={image.alt || ''}\n className=\"object-cover w-full h-full bg-gray-100 rounded-md overflow-hidden\"\n title={image.alt}\n priority={index < 5}\n noWrapper\n />\n </div>\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from './chunk-
|
|
2
|
-
import { DATA_LAYER_PROXY_SCRIPT } from './chunk-
|
|
1
|
+
import { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from './chunk-USEGCCT3.js';
|
|
2
|
+
import { DATA_LAYER_PROXY_SCRIPT } from './chunk-U5QRBIEL.js';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
|
|
5
5
|
function containerScript(gtmId) {
|
|
@@ -63,5 +63,5 @@ function GoogleTagBody({ gtmIds }) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export { GTM_LOAD_DELAY_MS, GoogleTagBody };
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-TQW7A42X.js.map
|
|
67
|
+
//# sourceMappingURL=chunk-TQW7A42X.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/tracking/GoogleTag.tsx"],"names":[],"mappings":";;;;AAUA,SAAS,gBAAgB,KAAA,EAAuB;AAC9C,EAAA,OAAO,CAAA;AAAA;AAAA;AAAA;AAAA,wCAAA,EAIiC,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA,EAAA,CAAA;AAC/D;AAGA,SAAS,UAAU,MAAA,EAAmC;AACpD,EAAA,OAAO,CAAC,yBAAyB,GAAG,MAAA,CAAO,IAAI,eAAe,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA;AAC5E;AAEA,IAAM,qBAAqB,CAAC,aAAA,EAAe,SAAA,EAAW,YAAA,EAAc,UAAU,OAAO,CAAA;AAG9E,IAAM,iBAAA,GAAoB;AAGjC,SAAS,aAAa,MAAA,EAAiD;AACrE,EAAA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A,CAAO,EAAA,GAAK,YAAA;AACZ,MAAA,MAAA,CAAO,WAAA,GAAc,UAAU,UAAU,CAAA;AACzC,MAAA,QAAA,CAAS,IAAA,CAAK,YAAY,MAAM,CAAA;AAAA,IAClC;AACA,IAAA,SAAS,MAAA,GAAS;AAChB,MAAA,WAAA,EAAY;AAEZ,MAAA,aAAA,GAAgB,MAAA,CAAO,UAAA,CAAW,MAAA,EAAQ,qBAAqB,CAAA;AAC/D,MAAA,KAAK,eAAA,EAAgB,CAAE,IAAA,CAAK,MAAM,CAAA;AAAA,IACpC;AACA,IAAA,SAAS,MAAA,GAAS;AAChB,MAAA,KAAA,GAAQ,MAAA,CAAO,UAAA,CAAW,MAAA,EAAQ,iBAAiB,CAAA;AAAA,IACrD;AAEA,IAAA,kBAAA,CAAmB,OAAA;AAAA,MAAQ,CAAC,IAAA,KAC1B,MAAA,CAAO,gBAAA,CAAiB,IAAA,EAAM,MAAA,EAAQ,EAAE,IAAA,EAAM,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM;AAAA,KACrE;AACA,IAAA,IAAI,QAAA,CAAS,UAAA,KAAe,UAAA,EAAY,MAAA,EAAO;AAAA,gBACnC,gBAAA,CAAiB,MAAA,EAAQ,QAAQ,EAAE,IAAA,EAAM,MAAM,CAAA;AAE3D,IAAA,OAAO,MAAM;AACX,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA,WAAA,EAAY;AACZ,MAAA,MAAA,CAAO,aAAa,aAAa,CAAA;AACjC,MAAA,QAAA,CAAS,cAAA,CAAe,YAAY,CAAA,EAAG,MAAA,EAAO;AAAA,IAChD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,OAAO,IAAA;AACT","file":"chunk-TQW7A42X.js","sourcesContent":["import { useEffect } from 'react';\nimport { DATA_LAYER_PROXY_SCRIPT } from '../../lib/analytics/gtm';\nimport { GTM_PAGE_DATA_WAIT_MS, whenGtmPageData } from '../../lib/analytics/gtm-page';\n\nexport interface GoogleTagBodyProps {\n /** GTM container IDs; every one is loaded, as on Twig. Empty or missing renders nothing. */\n gtmIds?: string[];\n}\n\n/** One container's loader, Google's snippet. */\nfunction containerScript(gtmId: string): string {\n return `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\nnew Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer',${JSON.stringify(gtmId)});`;\n}\n\n/** Every container, in the settings' order: Salla's first, then the merchant's own. */\nfunction gtmScript(gtmIds: readonly string[]): string {\n return [DATA_LAYER_PROXY_SCRIPT, ...gtmIds.map(containerScript)].join('\\n');\n}\n\nconst INTERACTION_EVENTS = ['pointerdown', 'keydown', 'touchstart', 'scroll', 'wheel'] as const;\n\n/** How long after `load` GTM waits for a visitor who never interacts. */\nexport const GTM_LOAD_DELAY_MS = 4000;\n\n/** Distinct container ids, in order. */\nfunction containerIds(gtmIds: readonly string[] | undefined): string[] {\n return [...new Set((gtmIds ?? []).map((id) => id?.trim()).filter(Boolean))];\n}\n\n/**\n * Injects GTM on the first interaction or GTM_LOAD_DELAY_MS after `load`, off the page's load\n * path, once the first page's data is in the data layer (at most GTM_PAGE_DATA_WAIT_MS later).\n */\nexport function GoogleTagBody({ gtmIds }: GoogleTagBodyProps): null {\n const ids = containerIds(gtmIds);\n const idsKey = ids.join(',');\n\n useEffect(() => {\n const containers = idsKey ? idsKey.split(',') : [];\n if (!containers.length) return;\n\n let timer: number | undefined;\n let pageDataTimer: number | undefined;\n let cancelled = false;\n const stopWaiting = () => {\n window.clearTimeout(timer);\n window.removeEventListener('load', onLoad);\n INTERACTION_EVENTS.forEach((type) => window.removeEventListener(type, inject));\n };\n function append() {\n window.clearTimeout(pageDataTimer);\n if (cancelled || document.getElementById('gtm-script')) return;\n const script = document.createElement('script');\n script.id = 'gtm-script';\n script.textContent = gtmScript(containers);\n document.head.appendChild(script);\n }\n function inject() {\n stopWaiting();\n // A container's tags read the page's data when `gtm.js` fires, as on Twig.\n pageDataTimer = window.setTimeout(append, GTM_PAGE_DATA_WAIT_MS);\n void whenGtmPageData().then(append);\n }\n function onLoad() {\n timer = window.setTimeout(inject, GTM_LOAD_DELAY_MS);\n }\n\n INTERACTION_EVENTS.forEach((type) =>\n window.addEventListener(type, inject, { once: true, passive: true })\n );\n if (document.readyState === 'complete') onLoad();\n else window.addEventListener('load', onLoad, { once: true });\n\n return () => {\n cancelled = true;\n stopWaiting();\n window.clearTimeout(pageDataTimer);\n document.getElementById('gtm-script')?.remove();\n };\n }, [idsKey]);\n\n return null;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { orThrow } from './chunk-
|
|
2
|
-
import { api } from './chunk-
|
|
1
|
+
import { orThrow } from './chunk-FLPDMPVB.js';
|
|
2
|
+
import { api } from './chunk-BM43QN4L.js';
|
|
3
3
|
import { getSallaSDK } from './chunk-MZPX4EPS.js';
|
|
4
4
|
import { queryOptions } from '@tanstack/react-query';
|
|
5
5
|
|
|
@@ -100,5 +100,5 @@ var cart = {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
export { cart, replaceSdkCart };
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-TXMG7FIA.js.map
|
|
104
|
+
//# sourceMappingURL=chunk-TXMG7FIA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/sdk-cart.ts","../src/api/cart.ts"],"names":[],"mappings":";;;;;;AAGO,IAAM,SAAA,GAAY,MAAc,MAAA,CAAO,WAAA,IAAe,OAAA,EAAS,GAAA,CAAI,SAAS,CAAA,IAAK,EAAE,CAAA;AAO1F,eAAsB,cAAA,GAAkD;AACtE,EAAA,MAAM,QA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A;AAAA,IACH,SAAA,EAAW,MACT,YAAA,CAAa;AAAA,MACX,QAAA,EAAU,CAAC,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC/B,OAAA,EAAS,MAAM,IAAA,CAAK,YAAA,EAAa;AAAA;AAAA,MAEjC,SAAA,EAAW,CAAA;AAAA,MACX,MAAA,EAAQ;AAAA,KACT;AAAA;AAEP","file":"chunk-TXMG7FIA.js","sourcesContent":["import { getSallaSDK } from '../utils/sdk-helpers';\n\n/** The cart id the SDK holds, or `''` when it holds none. */\nexport const sdkCartId = (): string => String(getSallaSDK()?.storage?.get('cart.id') ?? '');\n\n/**\n * Drops the SDK's cart and loads the visitor's current one, since nothing tells the SDK that\n * checkout (a separate app) turned its cart into an order. Cart badges listen to\n * `cart::updated`, which the SDK fires for the cart it loads and this fires when there is none.\n */\nexport async function replaceSdkCart(): Promise<number | string | null> {\n const salla = getSallaSDK();\n // The head stub stands in for the SDK until it loads: it holds no cart to replace.\n if (!salla?.cart?.api) return null;\n salla.cart.api.reset?.();\n const announceNoCart = () => {\n salla.event.dispatch('cart::updated', { count: 0, total: 0 });\n return null;\n };\n // `cart/latest` would create an empty cart for a guest, who gets one on their next add anyway.\n if (salla.config.isGuest?.()) return announceNoCart();\n // A failed `cart/latest` leaves the SDK without a cart, and tells no badge either.\n return salla.cart.api.getCurrentCartId(true, 'engine::cart.replaced').catch(announceNoCart);\n}\n","import { queryOptions } from '@tanstack/react-query';\nimport { api } from './client';\nimport type { Cart } from '../types';\nimport { orThrow } from '../providers/NavigationProvider';\nimport { getSallaSDK } from '../utils/sdk-helpers';\nimport { replaceSdkCart, sdkCartId } from './sdk-cart';\n\nexport interface CartApiResponse {\n /** Absent once the cart was turned into an order (the body then carries a top-level `redirect`). */\n cart?: Omit<Cart, 'loyalty'>;\n loyalty?: Cart['loyalty'];\n gift?: Cart['gift'];\n}\n\nfunction normalizeCartResponse(data: CartApiResponse): Cart | null {\n if (!data.cart) return null;\n return {\n ...data.cart,\n loyalty: data.loyalty ?? null,\n // The API sends `gift` inside `cart`.\n gift: data.gift ?? data.cart.gift ?? null,\n } as Cart;\n}\n\ntype CartId = number | string;\n\nasync function fetchCart(cartId: CartId): Promise<Cart | null> {\n const { data } = await api.get(`cart/${cartId}`).json<{ data: CartApiResponse }>();\n return normalizeCartResponse(data);\n}\n\n/**\n * Whether the API refused the cart id itself. An ordered cart answers 403 to anyone but its\n * buyer, and 404 once it is cleaned up; to the buyer it answers 200 with no `cart`.\n */\nfunction isGone(error: unknown): boolean {\n const status = (error as { response?: { status?: number } } | null)?.response?.status;\n return status === 403 || status === 404;\n}\n\n/** Carts the API stopped serving, each with the id of the cart the visitor has instead. */\nconst replacedCarts = new Map<string, Promise<CartId | null>>();\n\n/** Reads of the SDK's cart still in flight, so overlapping callers share one request and one reset. */\nconst sdkCartReads = new Map<string, Promise<Cart | null>>();\n\n/** The cart that took the place of `staleId`, or `null` when the visitor has none. */\nfunction readReplacement(staleId: string, currentId: CartId | null): Promise<Cart | null> {\n const isSameCart = currentId == null || String(currentId) === staleId;\n return isSameCart ? Promise.resolve(null) : fetchCart(currentId);\n}\n\n/** Reads the cart the SDK holds, and replaces it in the SDK when the API no longer serves it. */\nasync function readSdkCart(cartId: CartId): Promise<Cart | null> {\n const key = String(cartId);\n let found: Cart | null = null;\n try {\n found = await fetchCart(cartId);\n } catch (error) {\n if (!isGone(error)) throw error;\n }\n if (found) return found;\n // A newer cart in the SDK stays: an add to cart replaces a refused one while this request is\n // out. No cart in the SDK is the SDK having reset on its own 403, without telling the badges.\n const held = sdkCartId();\n const replacement =\n held && held !== key ? Promise.resolve<CartId | null>(held) : replaceSdkCart();\n replacedCarts.set(key, replacement);\n return readReplacement(key, await replacement);\n}\n\nexport const cart = {\n /**\n * The cart, or `null` when it was turned into an order. Unless the SDK holds another cart by\n * then, the SDK is moved to the visitor's current cart and that one is returned.\n */\n get: async (cartId: CartId): Promise<Cart | null> => {\n const key = String(cartId);\n const replacement = replacedCarts.get(key);\n if (replacement) return readReplacement(key, await replacement);\n // The SDK holds another cart, or there is no SDK (on the server): a plain read.\n const held = sdkCartId();\n if (!getSallaSDK() || (held && held !== key)) return fetchCart(cartId);\n\n let read = sdkCartReads.get(key);\n if (!read) {\n read = readSdkCart(cartId).finally(() => sdkCartReads.delete(key));\n sdkCartReads.set(key, read);\n }\n return read;\n },\n\n getOrThrow: (cartId: CartId): Promise<Cart | null> => orThrow(cart.get(cartId)),\n\n /** The visitor's cart id, which only the Salla SDK knows; `null` outside the browser. */\n getCurrentId: async (): Promise<number | null> => {\n const salla = getSallaSDK();\n if (!salla) return null;\n // The app bundle can run before the SDK module, when `salla` is still the head stub.\n await salla.onReady().catch(() => undefined);\n return salla.cart.api.getCurrentCartId();\n },\n\n queries: {\n detail: (cartId: CartId) =>\n queryOptions({\n queryKey: ['cart', cartId],\n queryFn: () => cart.get(cartId),\n // The SDK changes the cart from any page, so a cached copy is never safe to show.\n staleTime: 0,\n gcTime: 0,\n }),\n currentId: () =>\n queryOptions({\n queryKey: ['cart', 'current-id'],\n queryFn: () => cart.getCurrentId(),\n // Completing an order starts a new cart, so an earlier id is never reused.\n staleTime: 0,\n gcTime: 0,\n }),\n },\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RouteId } from './chunk-OUW6WESU.js';
|
|
2
|
-
import { getActiveCurrency } from './chunk-
|
|
2
|
+
import { getActiveCurrency } from './chunk-BM43QN4L.js';
|
|
3
3
|
|
|
4
4
|
// src/lib/analytics/gtm.ts
|
|
5
5
|
function gtmEnabled(settings) {
|
|
@@ -295,5 +295,5 @@ function servicesInitEvents(externalServices, snippetServices) {
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
export { DATA_LAYER_PROXY_SCRIPT, gtmCartCheckout, gtmCustomer, gtmDetail, gtmEnabled, gtmImpressions, gtmPage, gtmPurchase, gtmStore, pushToDataLayer, servicesInitEvents };
|
|
298
|
-
//# sourceMappingURL=chunk-
|
|
299
|
-
//# sourceMappingUR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BAAA,CACd,kBACA,eAAA,EACyC;AACzC,EAAA,MAAM,QAAA,GAAW,IAAI,GAAA,CAAI,eAAe,CAAA;AACxC,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,gBAAA,IAAoB,EAAE,EAAE,MAAA,CAAO,CAAC,CAAC,IAAI,CAAA,KAAM;AAC/D,IAAA,MAAM,OAAA,GAAU,wBAAA,CAAyB,IAAA,CAAK,IAAI,IAAI,CAAC,CAAA;AACvD,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,GAAA,CAAI,OAAO,GAAG,OAAO,KAAA;AACrD,IAAA,OAAO,CAAC,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,IAAK,0BAAA,CAA2B,IAAI,OAAO,CAAA;AAAA,EACzE,CAAC,CAAA;AACH","file":"chunk-N5EFDFMY.js","sourcesContent":["/**\n * The data a Twig storefront hands Google Tag Manager, built in the browser.\n *\n * On Twig the Store writes it on the server (the `Salla\\GoogleTags` package): each page opens\n * with one `dataLayer.push` naming the page, the store and the customer, plus the page's own\n * ecommerce block (a product's `detail`, the cart's `checkout`, an order's `purchase`). Salla's\n * container and the merchants' own containers read these exact keys, so every builder here\n * copies a PHP one, named beside it. A list's `impressions` copies `<salla-products-list>`\n * instead, which pushes them itself on Twig.\n */\nimport type { Cart, CartItem, Money, Product, User } from '../../types';\nimport type { Order, OrderItem } from '../../routes/account/types';\nimport type { StoreContext } from '../../api/store';\nimport type { PageContext } from '../../twilight/context';\nimport { getActiveCurrency } from '../../api/client';\nimport { RouteId } from '../../router/route-ids';\n\nexport type DataLayerEntry = Record<string, unknown>;\n\n/** True when the store loads a Tag Manager container; without one nothing reads the data layer. */\nexport function gtmEnabled(settings: StoreContext | undefined): boolean {\n return Boolean(settings?.store?.settings?.keys?.gtm?.length);\n}\n\nexport function pushToDataLayer(entry: DataLayerEntry): void {\n if (typeof window === 'undefined') return;\n window.dataLayer = window.dataLayer ?? [];\n window.dataLayer.push(entry);\n}\n\n/**\n * Twig's `dataLayer` proxy (`googletagmanager::head`): it drops request, payment and form\n * fields from every object pushed after it. The root head runs it before anything is pushed;\n * GTM's own script runs it too, for a theme that loads GTM by hand. Once per page.\n */\nexport const DATA_LAYER_PROXY_SCRIPT = `\nwindow.dataLayer = window.dataLayer || [];\nif (!window.__sallaDataLayerProxy) {\n window.__sallaDataLayerProxy = true;\n window.dataLayer = new Proxy(window.dataLayer, {\n set(target, property, value) {\n target[property] = value;\n if (typeof value === 'object') {\n ['form_data', 'data', 'gateway', 'config', 'request', 'headers']\n .forEach(function(key) { value && value.hasOwnProperty(key) && delete value[key]; });\n }\n return true;\n }\n });\n}\n`.trim();\n\n// ─── page ────────────────────────────────────────────────────────────────────\n\n/**\n * `page.pageName`: the Laravel route that renders the page on Twig, camel-cased without\n * `store` (`RequestResolver::getPageName`). The containers compare it: `productShow`,\n * `catShow`, `cartShow`, `search`, `brandsShow`, `thankyou`.\n */\nconst PAGE_NAMES: Record<string, string> = {\n [RouteId.INDEX]: 'home', // store.home\n [RouteId.PRODUCT_SINGLE]: 'productShow', // product.showWithSlug → product.show\n [RouteId.PRODUCT_INDEX]: 'catShow', // cat.showWithSlug → cat.show\n [RouteId.SEARCH]: 'search', // store.search\n [RouteId.PRODUCT_INDEX_LATEST]: 'latestProducts', // store.latest-products\n [RouteId.PRODUCT_INDEX_OFFERS]: 'productOffers', // product.offers\n [RouteId.BRANDS_INDEX]: 'brands', // store.brands\n [RouteId.BRANDS_SINGLE]: 'brandsShow', // store.brands.show\n [RouteId.CART]: 'cartShow', // cart.show\n [RouteId.THANK_YOU]: 'thankyou', // store.thankyou\n [RouteId.BLOG_INDEX]: 'blogIndex', // blog.index\n [RouteId.BLOG_SINGLE]: 'articlesShow', // articles.show\n [RouteId.BLOG_INDEX_CATEGORY]: 'articlesCategoryShow', // articles.category.show\n [RouteId.BLOG_INDEX_TAG]: 'articlesTagShow', // articles.tag.show\n [RouteId.PAGE_SINGLE]: 'pagesSlugShow', // pages.slug.show\n [RouteId.CUSTOMER_PROFILE]: 'userIndex', // user.index\n [RouteId.CUSTOMER_ORDERS_INDEX]: 'myorders', // store.myorders\n [RouteId.CUSTOMER_ORDERS_INDEX_PENDING]: 'myPendingOrders', // store.my_pending_orders\n [RouteId.CUSTOMER_ORDERS_SINGLE]: 'myOrder', // store.my_order\n [RouteId.CUSTOMER_WISHLIST]: 'myWishes', // store.my_wishes\n [RouteId.CUSTOMER_NOTIFICATIONS]: 'userNotificationsIndex', // user.notifications.index\n [RouteId.CUSTOMER_WALLET]: 'wallet', // wallet\n [RouteId.CUSTOMER_LOYALTY_POINTS]: 'customerLoyaltyPoints', // customer.loyalty_points\n [RouteId.LOYALTY]: 'loyaltyProgram', // store.loyalty_program\n [RouteId.TESTIMONIALS]: 'reviewsIndex', // store.reviews.index\n};\n\n/** A page with no known Twig route is named after its slug, camel-cased the same way. */\nexport function gtmPageName(slug: string): string {\n return (\n PAGE_NAMES[slug] ??\n slug.replace(/[._-]+([a-z0-9])/gi, (_, letter: string) => letter.toUpperCase())\n );\n}\n\n/** A fresh 40-hex id, as Twig's `sha1(… now()->timestamp)` gives each page and event one. */\nexport function gtmEventId(): string {\n const bytes = new Uint8Array(20);\n globalThis.crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** `config('theme.name')`: a number on Salla's themes. */\nfunction themeName(settings: StoreContext | undefined): string | number | undefined {\n const name = settings?.theme?.name;\n return name && /^\\d+$/.test(name) ? Number(name) : name;\n}\n\nexport interface GtmPageInput {\n slug: string;\n referrer: string;\n /** Inside the Salla app's webview (`mobileAgent()->is()`). */\n mobileApp: boolean;\n}\n\n/** `RequestResolver::getData`. */\nexport function gtmPage(input: GtmPageInput, settings: StoreContext | undefined): DataLayerEntry {\n return {\n fingerprint: gtmEventId(),\n pageName: gtmPageName(input.slug),\n mobileApp: input.mobileApp ? 1 : 0,\n referrer: input.referrer,\n theme: themeName(settings),\n };\n}\n\n/**\n * `StoreResolver::getData`. The settings API sends none of the legacy built-in pixel ids\n * (`facebook_pixel_id`, …), so they are null, as Twig sends them for a store that set none.\n */\nexport function gtmStore(settings: StoreContext | undefined): DataLayerEntry {\n return {\n store: settings?.store?.username ?? '',\n facebook_pixel_id: null,\n google_analytics_id: null,\n snapchat_pixel_id: null,\n };\n}\n\n// ─── customer ────────────────────────────────────────────────────────────────\n\nasync function sha256(value: string): Promise<string | null> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return null;\n const digest = await subtle.digest('SHA-256', new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** Lower-cased, no whitespace, and only a valid address (Twig: `FILTER_VALIDATE_EMAIL`). */\nfunction cleanEmail(email: string | undefined): string | null {\n const clean = email?.replace(/\\s+/g, '').toLowerCase();\n return clean && /^[^@]+@[^@]+\\.[^@]+$/.test(clean) ? clean : null;\n}\n\n/** E.164 without the plus (`966501234567`), as `fullMobileFormat(false)`; null when it isn't one. */\nfunction cleanPhone(mobile: string | undefined): string | null {\n const compact = mobile?.replace(/[\\s()-]+/g, '') ?? '';\n const digits = compact.startsWith('+')\n ? compact.slice(1)\n : compact.startsWith('00')\n ? compact.slice(2)\n : compact;\n return /^[1-9]\\d{7,14}$/.test(digits) ? digits : null;\n}\n\n/** `Store\\CustomerResolver::getData`: a guest is `{ isGuest: true }`. */\nexport async function gtmCustomer(\n user: User | null | undefined,\n settings: StoreContext | undefined\n): Promise<DataLayerEntry> {\n if (!user) return { isGuest: true };\n const email = cleanEmail(user.email);\n const phone = cleanPhone(user.mobile);\n const phoneWithPlus = phone ? `+${phone}` : null;\n const [firstName, lastName, emailHashed, phoneHashed, phoneWithPlusHashed] = await Promise.all([\n sha256(user.first_name ?? ''),\n sha256(user.last_name ?? ''),\n email ? sha256(email) : null,\n phone ? sha256(phone) : null,\n phoneWithPlus ? sha256(phoneWithPlus) : null,\n ]);\n return {\n isGuest: false,\n name: [user.first_name, user.last_name].filter(Boolean).join(' '),\n first_name: firstName,\n last_name: lastName,\n created_at: user.created_at ?? Math.floor(Date.now() / 1000),\n email,\n phone,\n phone_with_plus: phoneWithPlus,\n phone_with_plus_hashed: phoneWithPlusHashed,\n currency: user.preferences?.currency_code ?? settings?.user?.currency_code ?? 'SAR',\n email_hashed: emailHashed,\n phone_hashed: phoneHashed,\n };\n}\n\n// ─── money ───────────────────────────────────────────────────────────────────\n\nconst amountOf = (value: number | string | Money | null | undefined): number =>\n value && typeof value === 'object' ? Number(value.amount) || 0 : Number(value) || 0;\n\n/**\n * The currency prices are shown in: the visitor's choice, else the market's own (settings\n * `user.currency_code`; `OMR` on an Omani market of a Saudi store), as `currency()` on Twig.\n */\nexport function gtmCurrency(settings: StoreContext | undefined, fallback?: string): string {\n return getActiveCurrency() ?? fallback ?? settings?.user?.currency_code ?? 'SAR';\n}\n\n/**\n * `getGoogleTagManagerExchangeRate`: riyals per unit of `code`, as moneyphp prints a ratio.\n * Settings give each currency's `amount` per riyal.\n */\nexport function gtmExchangeRate(code: string, settings: StoreContext | undefined): string {\n const perRiyal = Number(settings?.currencies?.[code]?.amount);\n if (code === 'SAR' || !(perRiyal > 0)) return '1';\n return String(Number((1 / perRiyal).toPrecision(14)));\n}\n\n// ─── ecommerce ───────────────────────────────────────────────────────────────\n\nexport interface GtmProduct {\n id: number | string;\n name: string;\n categories: Array<{ id?: number | string; name: string }>;\n category: string;\n price: number;\n quantity: number;\n variant: string | null;\n brand: string;\n image: string;\n}\n\n/** `IsTaggingProduct::getGoogleTagManagerData`. */\nexport function gtmProduct(product: Product): GtmProduct {\n const categories = product.category\n ? [{ id: product.category.id, name: product.category.name }]\n : [];\n return {\n id: product.id,\n name: product.name,\n categories,\n category: categories.map((category) => category.name).join('/'),\n price: amountOf(product.price),\n quantity: 1,\n variant: '',\n brand: product.brand?.name ?? '',\n image: product.image?.url ?? '',\n };\n}\n\n/** `GoogleTagManager::detail`, which the product page pushes with its page data. */\nexport function gtmDetail(product: Product, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = gtmCurrency(settings, product.currency);\n return {\n event: 'detail',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n detail: { products: [gtmProduct(product)] },\n },\n };\n}\n\n/** `CartItem::getGoogleTagManagerData`: the cart line's taxed total as its price. */\nfunction gtmCartItem(item: CartItem, currency: string): DataLayerEntry {\n return {\n id: item.product_id,\n name: item.product_name,\n categories: [],\n category: '',\n price: amountOf(item.total),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.product_image ?? '',\n cart_item_id: item.id,\n currency,\n };\n}\n\n/**\n * `GoogleTagManager::checkout`, from the cart page's `SeoCartWidget` (step 1). It sets no\n * `event`: on Twig it rides on the page's own push. Only the available lines, and no order\n * options, as `getAvailableItems()` and the macro leave them out.\n */\nexport function gtmCartCheckout(\n cart: Cart,\n settings: StoreContext | undefined,\n step = 1\n): DataLayerEntry {\n const currencyCode = gtmCurrency(settings);\n const total = amountOf(cart.total);\n return {\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n checkout: {\n actionField: {\n id: cart.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step,\n },\n products: cart.items\n .filter((item) => item.is_available !== false && String(item.type) !== 'order_option')\n .map((item) => gtmCartItem(item, currencyCode)),\n },\n },\n };\n}\n\n/** `OrderItems::getGoogleTagManagerData`: the line before its discount, tax included. */\nfunction gtmOrderItem(item: OrderItem, currency: string): DataLayerEntry | null {\n if (!item.product) return null;\n return {\n id: item.product.id,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(item.amounts?.total_discount),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.thumbnail ?? item.product_thumbnail ?? item.image ?? '',\n currency,\n };\n}\n\n/** `GoogleTagManager::purchase`, from the thank-you page's `SeoThankYouWidget`. */\nexport function gtmPurchase(order: Order, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = order.currency || gtmCurrency(settings);\n const total = amountOf(order.amounts?.total);\n return {\n event: 'purchase',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: order.id,\n purchase: {\n actionField: {\n id: order.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step: null,\n },\n products: (order.items ?? [])\n .map((item) => gtmOrderItem(item, currencyCode))\n .filter((item): item is DataLayerEntry => item !== null),\n },\n },\n };\n}\n\n/**\n * The `impressions` `<salla-products-list>` pushes for each page of products it fetches\n * (`appendDataLayer`), with the page's title and id where a product names no category.\n */\nexport function gtmImpressions(\n products: Product[],\n page: PageContext | undefined,\n settings: StoreContext | undefined\n): DataLayerEntry {\n return {\n event: 'impressions',\n ecommerce: {\n currencyCode: gtmCurrency(settings),\n impressions: products.map((product, index) => {\n const category = product.category?.name || page?.title;\n return {\n id: product.id,\n name: product.name,\n price: amountOf(product.price),\n brand: product.brand?.name || '',\n quantity: product.quantity,\n categories: [{ name: category, id: page?.id }],\n category,\n position: index + 1,\n };\n }),\n },\n };\n}\n\n// ─── services ────────────────────────────────────────────────────────────────\n\n/** Services Twig renders itself rather than announcing (`ExternalServicesWidget::$serviceWidgets`). */\nconst WIDGET_SERVICES = new Set([\n 'google_tags_manager',\n 'mailchimp',\n 'addon-mailchimp-marketing',\n 'klaviyo',\n]);\n\n/** Apps with a snippet that Twig still announces (`ExternalServicesWidget::$serviceTracking`). */\nconst ANNOUNCED_SNIPPET_SERVICES = new Set(['facebook_pixel', 'tiktok_pixel', 'google_analytics']);\n\n/**\n * The `services::<name>.init` events a Twig page dispatches through the SDK, which copies each\n * into the data layer, where Salla's container loads GA4, Google Ads, Clarity and the pixels\n * from them. The settings API lists every active service; Twig leaves out the ones it renders\n * as a widget and the apps whose snippet the page loads instead.\n */\nexport function servicesInitEvents(\n externalServices: StoreContext['external_services'],\n snippetServices: Iterable<string>\n): Array<[name: string, payload: unknown]> {\n const snippets = new Set(snippetServices);\n return Object.entries(externalServices ?? {}).filter(([name]) => {\n const service = /^services::(.+)\\.init$/.exec(name)?.[1];\n if (!service || WIDGET_SERVICES.has(service)) return false;\n return !snippets.has(service) || ANNOUNCED_SNIPPET_SERVICES.has(service);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/analytics/gtm.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,WAAW,QAAA,EAA6C;AACtE,EAAA,OAAO,QAAQ,QAAA,EAAU,KAAA,EAAO,QAAA,EAAU,IAAA,EAAM,KAAK,MAAM,CAAA;AAC7D;AAEO,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACnC,EAAA,MAAA,CAAO,SAAA,GAAY,MAAA,CAAO,SAAA,IAAa,EAAC;AACxC,EAAA,MAAA,CAAO,SAAA,CAAU,KAAK,KAAK,CAAA;AAC7B;AAOO,IAAM,uBAAA,GAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAerC,IAAA;AASF,IAAM,UAAA,GAAqC;AAAA,EACzC,CAAC,OAAA,CAAQ,KAAK,GAAG,MAAA;AAAA;AAAA,EACjB,CAAC,OAAA,CAAQ,cAAc,GAAG,aAAA;AAAA;AAAA,EAC1B,CAAC,OAAA,CAAQ,aAAa,GAAG,SAAA;AAAA;AAAA,EACzB,CAAC,OAAA,CAAQ,MAAM,GAAG,QAAA;AAAA;AAAA,EAClB,CAAC,OAAA,CAAQ,oBAAoB,GAAG,gBAAA;AAAA;AAAA,EAChC,CAAC,OAAA,CAAQ,oBAAoB,GAAG,eAAA;AAAA;AAAA,EAChC,CAAC,OAAA,CAAQ,YAAY,GAAG,QAAA;AAAA;AAAA,EACxB,CAAC,OAAA,CAAQ,aAAa,GAAG,YAAA;AAAA;AAAA,EACzB,CAAC,OAAA,CAAQ,IAAI,GAAG,UAA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AAkB,cAAA,EAAgB,kBAAkB,CAAC,CAAA;AAQ1F,SAAS,kBAAA,CACd,kBACA,eAAA,EACyC;AACzC,EAAA,MAAM,QAAA,GAAW,IAAI,GAAA,CAAI,eAAe,CAAA;AACxC,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,gBAAA,IAAoB,EAAE,EAAE,MAAA,CAAO,CAAC,CAAC,IAAI,CAAA,KAAM;AAC/D,IAAA,MAAM,OAAA,GAAU,wBAAA,CAAyB,IAAA,CAAK,IAAI,IAAI,CAAC,CAAA;AACvD,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,GAAA,CAAI,OAAO,GAAG,OAAO,KAAA;AACrD,IAAA,OAAO,CAAC,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,IAAK,0BAAA,CAA2B,IAAI,OAAO,CAAA;AAAA,EACzE,CAAC,CAAA;AACH","file":"chunk-U5QRBIEL.js","sourcesContent":["/**\n * The data a Twig storefront hands Google Tag Manager, built in the browser.\n *\n * On Twig the Store writes it on the server (the `Salla\\GoogleTags` package): each page opens\n * with one `dataLayer.push` naming the page, the store and the customer, plus the page's own\n * ecommerce block (a product's `detail`, the cart's `checkout`, an order's `purchase`). Salla's\n * container and the merchants' own containers read these exact keys, so every builder here\n * copies a PHP one, named beside it. A list's `impressions` copies `<salla-products-list>`\n * instead, which pushes them itself on Twig.\n */\nimport type { Cart, CartItem, Money, Product, User } from '../../types';\nimport type { Order, OrderItem } from '../../routes/account/types';\nimport type { StoreContext } from '../../api/store';\nimport type { PageContext } from '../../twilight/context';\nimport { getActiveCurrency } from '../../api/client';\nimport { RouteId } from '../../router/route-ids';\n\nexport type DataLayerEntry = Record<string, unknown>;\n\n/** True when the store loads a Tag Manager container; without one nothing reads the data layer. */\nexport function gtmEnabled(settings: StoreContext | undefined): boolean {\n return Boolean(settings?.store?.settings?.keys?.gtm?.length);\n}\n\nexport function pushToDataLayer(entry: DataLayerEntry): void {\n if (typeof window === 'undefined') return;\n window.dataLayer = window.dataLayer ?? [];\n window.dataLayer.push(entry);\n}\n\n/**\n * Twig's `dataLayer` proxy (`googletagmanager::head`): it drops request, payment and form\n * fields from every object pushed after it. The root head runs it before anything is pushed;\n * GTM's own script runs it too, for a theme that loads GTM by hand. Once per page.\n */\nexport const DATA_LAYER_PROXY_SCRIPT = `\nwindow.dataLayer = window.dataLayer || [];\nif (!window.__sallaDataLayerProxy) {\n window.__sallaDataLayerProxy = true;\n window.dataLayer = new Proxy(window.dataLayer, {\n set(target, property, value) {\n target[property] = value;\n if (typeof value === 'object') {\n ['form_data', 'data', 'gateway', 'config', 'request', 'headers']\n .forEach(function(key) { value && value.hasOwnProperty(key) && delete value[key]; });\n }\n return true;\n }\n });\n}\n`.trim();\n\n// ─── page ────────────────────────────────────────────────────────────────────\n\n/**\n * `page.pageName`: the Laravel route that renders the page on Twig, camel-cased without\n * `store` (`RequestResolver::getPageName`). The containers compare it: `productShow`,\n * `catShow`, `cartShow`, `search`, `brandsShow`, `thankyou`.\n */\nconst PAGE_NAMES: Record<string, string> = {\n [RouteId.INDEX]: 'home', // store.home\n [RouteId.PRODUCT_SINGLE]: 'productShow', // product.showWithSlug → product.show\n [RouteId.PRODUCT_INDEX]: 'catShow', // cat.showWithSlug → cat.show\n [RouteId.SEARCH]: 'search', // store.search\n [RouteId.PRODUCT_INDEX_LATEST]: 'latestProducts', // store.latest-products\n [RouteId.PRODUCT_INDEX_OFFERS]: 'productOffers', // product.offers\n [RouteId.BRANDS_INDEX]: 'brands', // store.brands\n [RouteId.BRANDS_SINGLE]: 'brandsShow', // store.brands.show\n [RouteId.CART]: 'cartShow', // cart.show\n [RouteId.THANK_YOU]: 'thankyou', // store.thankyou\n [RouteId.BLOG_INDEX]: 'blogIndex', // blog.index\n [RouteId.BLOG_SINGLE]: 'articlesShow', // articles.show\n [RouteId.BLOG_INDEX_CATEGORY]: 'articlesCategoryShow', // articles.category.show\n [RouteId.BLOG_INDEX_TAG]: 'articlesTagShow', // articles.tag.show\n [RouteId.PAGE_SINGLE]: 'pagesSlugShow', // pages.slug.show\n [RouteId.CUSTOMER_PROFILE]: 'userIndex', // user.index\n [RouteId.CUSTOMER_ORDERS_INDEX]: 'myorders', // store.myorders\n [RouteId.CUSTOMER_ORDERS_INDEX_PENDING]: 'myPendingOrders', // store.my_pending_orders\n [RouteId.CUSTOMER_ORDERS_SINGLE]: 'myOrder', // store.my_order\n [RouteId.CUSTOMER_WISHLIST]: 'myWishes', // store.my_wishes\n [RouteId.CUSTOMER_NOTIFICATIONS]: 'userNotificationsIndex', // user.notifications.index\n [RouteId.CUSTOMER_WALLET]: 'wallet', // wallet\n [RouteId.CUSTOMER_LOYALTY_POINTS]: 'customerLoyaltyPoints', // customer.loyalty_points\n [RouteId.LOYALTY]: 'loyaltyProgram', // store.loyalty_program\n [RouteId.TESTIMONIALS]: 'reviewsIndex', // store.reviews.index\n};\n\n/** A page with no known Twig route is named after its slug, camel-cased the same way. */\nexport function gtmPageName(slug: string): string {\n return (\n PAGE_NAMES[slug] ??\n slug.replace(/[._-]+([a-z0-9])/gi, (_, letter: string) => letter.toUpperCase())\n );\n}\n\n/** A fresh 40-hex id, as Twig's `sha1(… now()->timestamp)` gives each page and event one. */\nexport function gtmEventId(): string {\n const bytes = new Uint8Array(20);\n globalThis.crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** `config('theme.name')`: a number on Salla's themes. */\nfunction themeName(settings: StoreContext | undefined): string | number | undefined {\n const name = settings?.theme?.name;\n return name && /^\\d+$/.test(name) ? Number(name) : name;\n}\n\nexport interface GtmPageInput {\n slug: string;\n referrer: string;\n /** Inside the Salla app's webview (`mobileAgent()->is()`). */\n mobileApp: boolean;\n}\n\n/** `RequestResolver::getData`. */\nexport function gtmPage(input: GtmPageInput, settings: StoreContext | undefined): DataLayerEntry {\n return {\n fingerprint: gtmEventId(),\n pageName: gtmPageName(input.slug),\n mobileApp: input.mobileApp ? 1 : 0,\n referrer: input.referrer,\n theme: themeName(settings),\n };\n}\n\n/**\n * `StoreResolver::getData`. The settings API sends none of the legacy built-in pixel ids\n * (`facebook_pixel_id`, …), so they are null, as Twig sends them for a store that set none.\n */\nexport function gtmStore(settings: StoreContext | undefined): DataLayerEntry {\n return {\n store: settings?.store?.username ?? '',\n facebook_pixel_id: null,\n google_analytics_id: null,\n snapchat_pixel_id: null,\n };\n}\n\n// ─── customer ────────────────────────────────────────────────────────────────\n\nasync function sha256(value: string): Promise<string | null> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return null;\n const digest = await subtle.digest('SHA-256', new TextEncoder().encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/** Lower-cased, no whitespace, and only a valid address (Twig: `FILTER_VALIDATE_EMAIL`). */\nfunction cleanEmail(email: string | undefined): string | null {\n const clean = email?.replace(/\\s+/g, '').toLowerCase();\n return clean && /^[^@]+@[^@]+\\.[^@]+$/.test(clean) ? clean : null;\n}\n\n/** E.164 without the plus (`966501234567`), as `fullMobileFormat(false)`; null when it isn't one. */\nfunction cleanPhone(mobile: string | undefined): string | null {\n const compact = mobile?.replace(/[\\s()-]+/g, '') ?? '';\n const digits = compact.startsWith('+')\n ? compact.slice(1)\n : compact.startsWith('00')\n ? compact.slice(2)\n : compact;\n return /^[1-9]\\d{7,14}$/.test(digits) ? digits : null;\n}\n\n/** `Store\\CustomerResolver::getData`: a guest is `{ isGuest: true }`. */\nexport async function gtmCustomer(\n user: User | null | undefined,\n settings: StoreContext | undefined\n): Promise<DataLayerEntry> {\n if (!user) return { isGuest: true };\n const email = cleanEmail(user.email);\n const phone = cleanPhone(user.mobile);\n const phoneWithPlus = phone ? `+${phone}` : null;\n const [firstName, lastName, emailHashed, phoneHashed, phoneWithPlusHashed] = await Promise.all([\n sha256(user.first_name ?? ''),\n sha256(user.last_name ?? ''),\n email ? sha256(email) : null,\n phone ? sha256(phone) : null,\n phoneWithPlus ? sha256(phoneWithPlus) : null,\n ]);\n return {\n isGuest: false,\n name: [user.first_name, user.last_name].filter(Boolean).join(' '),\n first_name: firstName,\n last_name: lastName,\n created_at: user.created_at ?? Math.floor(Date.now() / 1000),\n email,\n phone,\n phone_with_plus: phoneWithPlus,\n phone_with_plus_hashed: phoneWithPlusHashed,\n currency: user.preferences?.currency_code ?? settings?.user?.currency_code ?? 'SAR',\n email_hashed: emailHashed,\n phone_hashed: phoneHashed,\n };\n}\n\n// ─── money ───────────────────────────────────────────────────────────────────\n\nconst amountOf = (value: number | string | Money | null | undefined): number =>\n value && typeof value === 'object' ? Number(value.amount) || 0 : Number(value) || 0;\n\n/**\n * The currency prices are shown in: the visitor's choice, else the market's own (settings\n * `user.currency_code`; `OMR` on an Omani market of a Saudi store), as `currency()` on Twig.\n */\nexport function gtmCurrency(settings: StoreContext | undefined, fallback?: string): string {\n return getActiveCurrency() ?? fallback ?? settings?.user?.currency_code ?? 'SAR';\n}\n\n/**\n * `getGoogleTagManagerExchangeRate`: riyals per unit of `code`, as moneyphp prints a ratio.\n * Settings give each currency's `amount` per riyal.\n */\nexport function gtmExchangeRate(code: string, settings: StoreContext | undefined): string {\n const perRiyal = Number(settings?.currencies?.[code]?.amount);\n if (code === 'SAR' || !(perRiyal > 0)) return '1';\n return String(Number((1 / perRiyal).toPrecision(14)));\n}\n\n// ─── ecommerce ───────────────────────────────────────────────────────────────\n\nexport interface GtmProduct {\n id: number | string;\n name: string;\n categories: Array<{ id?: number | string; name: string }>;\n category: string;\n price: number;\n quantity: number;\n variant: string | null;\n brand: string;\n image: string;\n}\n\n/** `IsTaggingProduct::getGoogleTagManagerData`. */\nexport function gtmProduct(product: Product): GtmProduct {\n const categories = product.category\n ? [{ id: product.category.id, name: product.category.name }]\n : [];\n return {\n id: product.id,\n name: product.name,\n categories,\n category: categories.map((category) => category.name).join('/'),\n price: amountOf(product.price),\n quantity: 1,\n variant: '',\n brand: product.brand?.name ?? '',\n image: product.image?.url ?? '',\n };\n}\n\n/** `GoogleTagManager::detail`, which the product page pushes with its page data. */\nexport function gtmDetail(product: Product, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = gtmCurrency(settings, product.currency);\n return {\n event: 'detail',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n detail: { products: [gtmProduct(product)] },\n },\n };\n}\n\n/** `CartItem::getGoogleTagManagerData`: the cart line's taxed total as its price. */\nfunction gtmCartItem(item: CartItem, currency: string): DataLayerEntry {\n return {\n id: item.product_id,\n name: item.product_name,\n categories: [],\n category: '',\n price: amountOf(item.total),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.product_image ?? '',\n cart_item_id: item.id,\n currency,\n };\n}\n\n/**\n * `GoogleTagManager::checkout`, from the cart page's `SeoCartWidget` (step 1). It sets no\n * `event`: on Twig it rides on the page's own push. Only the available lines, and no order\n * options, as `getAvailableItems()` and the macro leave them out.\n */\nexport function gtmCartCheckout(\n cart: Cart,\n settings: StoreContext | undefined,\n step = 1\n): DataLayerEntry {\n const currencyCode = gtmCurrency(settings);\n const total = amountOf(cart.total);\n return {\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: gtmEventId(),\n checkout: {\n actionField: {\n id: cart.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step,\n },\n products: cart.items\n .filter((item) => item.is_available !== false && String(item.type) !== 'order_option')\n .map((item) => gtmCartItem(item, currencyCode)),\n },\n },\n };\n}\n\n/** `OrderItems::getGoogleTagManagerData`: the line before its discount, tax included. */\nfunction gtmOrderItem(item: OrderItem, currency: string): DataLayerEntry | null {\n if (!item.product) return null;\n return {\n id: item.product.id,\n name: item.name,\n categories: [],\n category: '',\n price: amountOf(item.amounts?.total) + amountOf(item.amounts?.total_discount),\n quantity: item.quantity,\n variant: null,\n brand: '',\n image: item.thumbnail ?? item.product_thumbnail ?? item.image ?? '',\n currency,\n };\n}\n\n/** `GoogleTagManager::purchase`, from the thank-you page's `SeoThankYouWidget`. */\nexport function gtmPurchase(order: Order, settings: StoreContext | undefined): DataLayerEntry {\n const currencyCode = order.currency || gtmCurrency(settings);\n const total = amountOf(order.amounts?.total);\n return {\n event: 'purchase',\n ecommerce: {\n currencyCode,\n exchangeRate: gtmExchangeRate(currencyCode, settings),\n event_id: order.id,\n purchase: {\n actionField: {\n id: order.id,\n total,\n revenue: total,\n currency_code: currencyCode,\n step: null,\n },\n products: (order.items ?? [])\n .map((item) => gtmOrderItem(item, currencyCode))\n .filter((item): item is DataLayerEntry => item !== null),\n },\n },\n };\n}\n\n/**\n * The `impressions` `<salla-products-list>` pushes for each page of products it fetches\n * (`appendDataLayer`), with the page's title and id where a product names no category.\n */\nexport function gtmImpressions(\n products: Product[],\n page: PageContext | undefined,\n settings: StoreContext | undefined\n): DataLayerEntry {\n return {\n event: 'impressions',\n ecommerce: {\n currencyCode: gtmCurrency(settings),\n impressions: products.map((product, index) => {\n const category = product.category?.name || page?.title;\n return {\n id: product.id,\n name: product.name,\n price: amountOf(product.price),\n brand: product.brand?.name || '',\n quantity: product.quantity,\n categories: [{ name: category, id: page?.id }],\n category,\n position: index + 1,\n };\n }),\n },\n };\n}\n\n// ─── services ────────────────────────────────────────────────────────────────\n\n/** Services Twig renders itself rather than announcing (`ExternalServicesWidget::$serviceWidgets`). */\nconst WIDGET_SERVICES = new Set([\n 'google_tags_manager',\n 'mailchimp',\n 'addon-mailchimp-marketing',\n 'klaviyo',\n]);\n\n/** Apps with a snippet that Twig still announces (`ExternalServicesWidget::$serviceTracking`). */\nconst ANNOUNCED_SNIPPET_SERVICES = new Set(['facebook_pixel', 'tiktok_pixel', 'google_analytics']);\n\n/**\n * The `services::<name>.init` events a Twig page dispatches through the SDK, which copies each\n * into the data layer, where Salla's container loads GA4, Google Ads, Clarity and the pixels\n * from them. The settings API lists every active service; Twig leaves out the ones it renders\n * as a widget and the apps whose snippet the page loads instead.\n */\nexport function servicesInitEvents(\n externalServices: StoreContext['external_services'],\n snippetServices: Iterable<string>\n): Array<[name: string, payload: unknown]> {\n const snippets = new Set(snippetServices);\n return Object.entries(externalServices ?? {}).filter(([name]) => {\n const service = /^services::(.+)\\.init$/.exec(name)?.[1];\n if (!service || WIDGET_SERVICES.has(service)) return false;\n return !snippets.has(service) || ANNOUNCED_SNIPPET_SERVICES.has(service);\n });\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { gtmEnabled, gtmDetail, gtmCartCheckout, gtmImpressions, gtmPurchase, gtmCustomer, gtmPage, gtmStore, pushToDataLayer, servicesInitEvents } from './chunk-
|
|
1
|
+
import { gtmEnabled, gtmDetail, gtmCartCheckout, gtmImpressions, gtmPurchase, gtmCustomer, gtmPage, gtmStore, pushToDataLayer, servicesInitEvents } from './chunk-U5QRBIEL.js';
|
|
2
2
|
import { RouteId } from './chunk-OUW6WESU.js';
|
|
3
|
-
import { user } from './chunk-
|
|
3
|
+
import { user } from './chunk-GMBOYIH5.js';
|
|
4
4
|
import { isNativeApp } from './chunk-BZ2QSBXM.js';
|
|
5
5
|
import { onSallaEvent, whenSallaLoaded } from './chunk-MZPX4EPS.js';
|
|
6
6
|
import { getTwilightContext } from './chunk-MWUAHDQL.js';
|
|
@@ -167,5 +167,5 @@ function watchListImpressions() {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
export { GTM_PAGE_DATA_WAIT_MS, gtmPageEcommerce, reportGtmPageView, whenGtmPageData };
|
|
170
|
-
//# sourceMappingURL=chunk-
|
|
171
|
-
//# sourceMappingURL=chunk-
|
|
170
|
+
//# sourceMappingURL=chunk-USEGCCT3.js.map
|
|
171
|
+
//# sourceMappingURL=chunk-USEGCCT3.js.map
|