@beamimpact/web-sdk 1.48.0 → 1.50.1
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/chunks/_share-dialog-dependencies-RmYWlyJ0.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-RmYWlyJ0.esm.js.map +1 -0
- package/dist/chunks/_share-dialog-dependencies-yCBFjXxQ.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-yCBFjXxQ.esm.js.map +1 -0
- package/dist/chunks/beam-errors-AMvTvR1C.esm.js +2 -0
- package/dist/chunks/beam-errors-AMvTvR1C.esm.js.map +1 -0
- package/dist/chunks/{beam-errors-fXDkG1zo.esm.d.ts → beam-errors-bKCZlkvr.esm.d.ts} +2 -7
- package/dist/chunks/cart-contents-6_ztOjrx.esm.d.ts +18 -0
- package/dist/chunks/cart-contents-h60geKWa.esm.js.map +1 -1
- package/dist/chunks/enforce-config-S8EGgEnO.esm.js +3 -0
- package/dist/chunks/enforce-config-S8EGgEnO.esm.js.map +1 -0
- package/dist/chunks/enforce-config-l-tNb_z7.esm.js +3 -0
- package/dist/chunks/enforce-config-l-tNb_z7.esm.js.map +1 -0
- package/dist/chunks/events-T3hYV1LF.esm.js +2 -0
- package/dist/chunks/events-T3hYV1LF.esm.js.map +1 -0
- package/dist/chunks/{events-ZCTR9JGZ.esm.d.ts → events-u_8n2LIU.esm.d.ts} +33 -4
- package/dist/chunks/{index-PA0NAKHV.esm.d.ts → index-0X3JKFYs.esm.d.ts} +1 -1
- package/dist/chunks/{index-XH3OS_sy.esm.d.ts → index-2qmtuEV_.esm.d.ts} +4 -4
- package/dist/chunks/index-44clOvXJ.esm.js +2 -0
- package/dist/chunks/index-44clOvXJ.esm.js.map +1 -0
- package/dist/chunks/index-B-9JPaCH.esm.js +2 -0
- package/dist/chunks/index-B-9JPaCH.esm.js.map +1 -0
- package/dist/chunks/{index-M7Ut5U3j.esm.js → index-CNVMNDM4.esm.js} +2 -2
- package/dist/chunks/index-CNVMNDM4.esm.js.map +1 -0
- package/dist/chunks/{index-XHm2EBaD.esm.js → index-HVGMpZIV.esm.js} +2 -2
- package/dist/chunks/{index-XHm2EBaD.esm.js.map → index-HVGMpZIV.esm.js.map} +1 -1
- package/dist/chunks/{index-WvOCqhxv.esm.js → index-UHchr4H_.esm.js} +2 -2
- package/dist/chunks/index-UHchr4H_.esm.js.map +1 -0
- package/dist/chunks/{index-JJjxnRZK.esm.js → index-XPlAZw7t.esm.js} +2 -2
- package/dist/chunks/{index-JJjxnRZK.esm.js.map → index-XPlAZw7t.esm.js.map} +1 -1
- package/dist/chunks/{index-v6fG3D6u.esm.d.ts → index-bhqIqVQJ.esm.d.ts} +1 -1
- package/dist/chunks/{index--z5MSe4-.esm.d.ts → index-cznI-EZa.esm.d.ts} +1 -1
- package/dist/chunks/index-dLnZQZlT.esm.js +2 -0
- package/dist/chunks/index-dLnZQZlT.esm.js.map +1 -0
- package/dist/chunks/index-f7fp9odj.esm.js +2 -0
- package/dist/chunks/index-f7fp9odj.esm.js.map +1 -0
- package/dist/chunks/index-kFulvjM4.esm.js +2 -0
- package/dist/chunks/index-kFulvjM4.esm.js.map +1 -0
- package/dist/chunks/index-m1LRybiJ.esm.js +2 -0
- package/dist/chunks/index-m1LRybiJ.esm.js.map +1 -0
- package/dist/chunks/index-puZGYsUA.esm.d.ts +46 -0
- package/dist/chunks/index-q2vZ79t1.esm.d.ts +46 -0
- package/dist/chunks/index-smGc5rsi.esm.js +2 -0
- package/dist/chunks/index-smGc5rsi.esm.js.map +1 -0
- package/dist/chunks/index-wz6Yfo37.esm.js +2 -0
- package/dist/chunks/index-wz6Yfo37.esm.js.map +1 -0
- package/dist/chunks/{localize-o-cYvHQf.esm.js → localize-7sMSg1W9.esm.js} +2 -2
- package/dist/chunks/{localize-o-cYvHQf.esm.js.map → localize-7sMSg1W9.esm.js.map} +1 -1
- package/dist/chunks/{localize-m-_ESmpk.esm.js → localize-OiRewTgu.esm.js} +2 -2
- package/dist/chunks/{localize-m-_ESmpk.esm.js.map → localize-OiRewTgu.esm.js.map} +1 -1
- package/dist/chunks/{openapi-spec-hjdK2L9Q.esm.d.ts → openapi-spec-bxGNhNMa.esm.d.ts} +332 -0
- package/dist/chunks/order-page-WPxvCNLM.esm.js +2 -0
- package/dist/chunks/{order-page-Z3WcYluU.esm.js.map → order-page-WPxvCNLM.esm.js.map} +1 -1
- package/dist/chunks/order-page-ZpOf35sP.esm.js +2 -0
- package/dist/chunks/{order-page-rrfJ4w9F.esm.js.map → order-page-ZpOf35sP.esm.js.map} +1 -1
- package/dist/chunks/{order-page-9clVUPaS.esm.d.ts → order-page-dlXIs0gJ.esm.d.ts} +6 -4
- package/dist/chunks/promo-types-aQ_hre6t.esm.d.ts +14 -0
- package/dist/chunks/promoManager--3WXq4at.esm.js +2 -0
- package/dist/chunks/promoManager--3WXq4at.esm.js.map +1 -0
- package/dist/chunks/promoManager-YUzbMtwY.esm.js +2 -0
- package/dist/chunks/promoManager-YUzbMtwY.esm.js.map +1 -0
- package/dist/chunks/routes-YPOoVIR2.esm.js +2 -0
- package/dist/chunks/routes-YPOoVIR2.esm.js.map +1 -0
- package/dist/chunks/{routes-iurI6dvR.esm.d.ts → routes-lGXt7ttd.esm.d.ts} +76 -3
- package/dist/chunks/routes-o-phF_L1.esm.js +2 -0
- package/dist/chunks/routes-o-phF_L1.esm.js.map +1 -0
- package/dist/chunks/{share-button-k_Xn5956.esm.js → share-button-EsUPw38-.esm.js} +2 -2
- package/dist/chunks/{share-button-diP8wKOc.esm.js.map → share-button-EsUPw38-.esm.js.map} +1 -1
- package/dist/chunks/{share-button-diP8wKOc.esm.js → share-button-r0y-bbwR.esm.js} +2 -2
- package/dist/chunks/{share-button-k_Xn5956.esm.js.map → share-button-r0y-bbwR.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components-wBxNHnyr.esm.js → shoelace-components-PB22pjfM.esm.js} +2 -2
- package/dist/chunks/{shoelace-components-wBxNHnyr.esm.js.map → shoelace-components-PB22pjfM.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components-xrhk189_.esm.js → shoelace-components-lr4iB8kL.esm.js} +2 -2
- package/dist/chunks/{shoelace-components-xrhk189_.esm.js.map → shoelace-components-lr4iB8kL.esm.js.map} +1 -1
- package/dist/chunks/{types-zbTZ8-KP.esm.d.ts → types-IbMT3Nwn.esm.d.ts} +5 -1
- package/dist/chunks/{update-cart-l86bU5uS.esm.d.ts → update-cart-JO4fuiim.esm.d.ts} +1 -1
- package/dist/chunks/update-cart-UuMHYehB.esm.js +2 -0
- package/dist/chunks/update-cart-UuMHYehB.esm.js.map +1 -0
- package/dist/chunks/update-cart-mNsQ9K-k.esm.js +2 -0
- package/dist/chunks/update-cart-mNsQ9K-k.esm.js.map +1 -0
- package/dist/components/community-impact.d.ts +1 -1
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.d.ts +1 -1
- package/dist/components/cumulative-impact.esm.js +1 -1
- package/dist/components/cumulative-impact.js +1 -1
- package/dist/components/impact-overview.d.ts +6 -2
- package/dist/components/impact-overview.esm.js +2 -2
- package/dist/components/impact-overview.esm.js.map +1 -1
- package/dist/components/impact-overview.js +2 -2
- package/dist/components/impact-overview.js.map +1 -1
- package/dist/components/index.d.ts +4 -4
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +11 -3
- package/dist/components/post-purchase.esm.js +4 -4
- package/dist/components/post-purchase.esm.js.map +1 -1
- package/dist/components/post-purchase.js +4 -4
- package/dist/components/post-purchase.js.map +1 -1
- package/dist/components/product-details-page.d.ts +23 -4
- package/dist/components/product-details-page.esm.js +24 -24
- package/dist/components/product-details-page.esm.js.map +1 -1
- package/dist/components/product-details-page.js +24 -24
- package/dist/components/product-details-page.js.map +1 -1
- package/dist/components/redeem-transaction.d.ts +5 -14
- package/dist/components/redeem-transaction.esm.js +27 -27
- package/dist/components/redeem-transaction.esm.js.map +1 -1
- package/dist/components/redeem-transaction.js +27 -27
- package/dist/components/redeem-transaction.js.map +1 -1
- package/dist/components/select-nonprofit.d.ts +10 -3
- package/dist/components/select-nonprofit.esm.js +50 -45
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +50 -45
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.d.ts +1 -1
- package/dist/components/select-subscription-nonprofit.esm.js +1 -1
- package/dist/components/select-subscription-nonprofit.js +1 -1
- package/dist/components/shopify.d.ts +8 -7
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.esm.js.map +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/shopify.js.map +1 -1
- package/dist/components/social-share.d.ts +1 -1
- package/dist/components/social-share.esm.js +1 -1
- package/dist/components/social-share.js +1 -1
- package/dist/components/subscription-impact.d.ts +2 -1
- package/dist/components/subscription-impact.esm.js +1 -1
- package/dist/components/subscription-impact.js +1 -1
- package/dist/components/subscription-management.d.ts +15 -4
- package/dist/components/subscription-management.esm.js +1 -1
- package/dist/components/subscription-management.js +1 -1
- package/dist/index.d.ts +16 -14
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.d.ts +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.d.ts +3 -3
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/index.d.ts +14 -12
- package/dist/integrations/index.esm.js +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/logs.d.ts +2 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/promoManager.d.ts +36 -0
- package/dist/integrations/promoManager.esm.js +2 -0
- package/dist/integrations/promoManager.esm.js.map +1 -0
- package/dist/integrations/promoManager.js +2 -0
- package/dist/integrations/promoManager.js.map +1 -0
- package/dist/integrations/session.esm.js +1 -1
- package/dist/integrations/session.js +1 -1
- package/dist/integrations/shopify.d.ts +6 -6
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.d.ts +1 -1
- package/dist/integrations/statsig.esm.js +1 -1
- package/dist/integrations/statsig.js +1 -1
- package/dist/integrations/utils.d.ts +7 -5
- package/dist/integrations/utils.esm.js +1 -1
- package/dist/integrations/utils.js +1 -1
- package/dist/react/community-impact.d.ts +1 -1
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.d.ts +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.d.ts +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.d.ts +6 -5
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +3 -3
- package/dist/react/post-purchase.esm.js +1 -1
- package/dist/react/post-purchase.esm.js.map +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/post-purchase.js.map +1 -1
- package/dist/react/product-details-page.d.ts +1 -1
- package/dist/react/product-details-page.esm.js +1 -1
- package/dist/react/product-details-page.esm.js.map +1 -1
- package/dist/react/product-details-page.js +1 -1
- package/dist/react/product-details-page.js.map +1 -1
- package/dist/react/redeem-transaction.d.ts +5 -4
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/select-nonprofit.d.ts +5 -4
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.esm.js.map +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/select-nonprofit.js.map +1 -1
- package/dist/react/select-subscription-nonprofit.d.ts +5 -4
- package/dist/react/select-subscription-nonprofit.esm.js +1 -1
- package/dist/react/select-subscription-nonprofit.js +1 -1
- package/dist/react/social-share.d.ts +1 -1
- package/dist/react/social-share.esm.js +1 -1
- package/dist/react/social-share.js +1 -1
- package/dist/react/subscription-impact.d.ts +1 -1
- package/dist/react/subscription-impact.esm.js +1 -1
- package/dist/react/subscription-impact.js +1 -1
- package/dist/react/subscription-management.d.ts +4 -4
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/utils/beam-errors.d.ts +1 -1
- package/dist/utils/beam-errors.esm.js +1 -1
- package/dist/utils/beam-errors.js +1 -1
- package/dist/utils/cart.esm.js +1 -1
- package/dist/utils/cart.js +1 -1
- package/dist/utils/cookies.esm.js +1 -1
- package/dist/utils/cookies.esm.js.map +1 -1
- package/dist/utils/cookies.js +1 -1
- package/dist/utils/cookies.js.map +1 -1
- package/dist/utils/events.d.ts +5 -4
- package/dist/utils/events.esm.js +1 -1
- package/dist/utils/events.js +1 -1
- package/dist/utils/index.d.ts +7 -5
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/local-storage.esm.js +1 -1
- package/dist/utils/local-storage.js +1 -1
- package/dist/utils/network-listeners.esm.js +1 -1
- package/dist/utils/network-listeners.esm.js.map +1 -1
- package/dist/utils/network-listeners.js +1 -1
- package/dist/utils/network-listeners.js.map +1 -1
- package/dist/utils/promoManager.d.ts +123 -0
- package/dist/utils/promoManager.esm.js +2 -0
- package/dist/utils/promoManager.esm.js.map +1 -0
- package/dist/utils/promoManager.js +2 -0
- package/dist/utils/promoManager.js.map +1 -0
- package/dist/utils/remote-session.esm.js +1 -1
- package/dist/utils/remote-session.js +1 -1
- package/dist/utils/wait-for-element.esm.js +1 -1
- package/dist/utils/wait-for-element.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/_share-dialog-dependencies-2jzbs44g.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-2jzbs44g.esm.js.map +0 -1
- package/dist/chunks/_share-dialog-dependencies-C8uChjuF.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-C8uChjuF.esm.js.map +0 -1
- package/dist/chunks/beam-errors-P-Lu07Ce.esm.js +0 -2
- package/dist/chunks/beam-errors-P-Lu07Ce.esm.js.map +0 -1
- package/dist/chunks/cart-contents-CMm57qu0.esm.d.ts +0 -11
- package/dist/chunks/enforce-config-ZAI7WYAd.esm.js +0 -3
- package/dist/chunks/enforce-config-ZAI7WYAd.esm.js.map +0 -1
- package/dist/chunks/enforce-config-ZyPq_4CF.esm.js +0 -3
- package/dist/chunks/enforce-config-ZyPq_4CF.esm.js.map +0 -1
- package/dist/chunks/events-6Z5MkCRr.esm.js +0 -2
- package/dist/chunks/events-6Z5MkCRr.esm.js.map +0 -1
- package/dist/chunks/index-2bLOkP4H.esm.d.ts +0 -32
- package/dist/chunks/index-CsWTfuok.esm.js +0 -2
- package/dist/chunks/index-CsWTfuok.esm.js.map +0 -1
- package/dist/chunks/index-GynYZRPI.esm.d.ts +0 -32
- package/dist/chunks/index-M7Ut5U3j.esm.js.map +0 -1
- package/dist/chunks/index-MIp7LlXH.esm.js +0 -2
- package/dist/chunks/index-MIp7LlXH.esm.js.map +0 -1
- package/dist/chunks/index-WvOCqhxv.esm.js.map +0 -1
- package/dist/chunks/index-YJNgLCif.esm.js +0 -2
- package/dist/chunks/index-YJNgLCif.esm.js.map +0 -1
- package/dist/chunks/index-a6oXV2ro.esm.js +0 -2
- package/dist/chunks/index-a6oXV2ro.esm.js.map +0 -1
- package/dist/chunks/index-dkwGkvOu.esm.js +0 -2
- package/dist/chunks/index-dkwGkvOu.esm.js.map +0 -1
- package/dist/chunks/index-iK195-B9.esm.js +0 -2
- package/dist/chunks/index-iK195-B9.esm.js.map +0 -1
- package/dist/chunks/index-nstmHC95.esm.js +0 -2
- package/dist/chunks/index-nstmHC95.esm.js.map +0 -1
- package/dist/chunks/index-vq14EaW4.esm.js +0 -2
- package/dist/chunks/index-vq14EaW4.esm.js.map +0 -1
- package/dist/chunks/order-page-Z3WcYluU.esm.js +0 -2
- package/dist/chunks/order-page-rrfJ4w9F.esm.js +0 -2
- package/dist/chunks/routes-Dmf2ZNnZ.esm.js +0 -2
- package/dist/chunks/routes-Dmf2ZNnZ.esm.js.map +0 -1
- package/dist/chunks/routes-o1QpF40R.esm.js +0 -2
- package/dist/chunks/routes-o1QpF40R.esm.js.map +0 -1
- package/dist/chunks/update-cart-EGTcbNRX.esm.js +0 -2
- package/dist/chunks/update-cart-EGTcbNRX.esm.js.map +0 -1
- package/dist/chunks/update-cart-FwtFnnGe.esm.js +0 -2
- package/dist/chunks/update-cart-FwtFnnGe.esm.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { b as TBeamCartLocalStorage } from '../chunks/cart-contents-6_ztOjrx.esm.js';
|
|
2
|
+
import { a as TPromoCodeResponse, b as TValidatedPromoResponse, T as TPromoCodeRequest, c as TPromoCodeAttribute } from '../chunks/promo-types-aQ_hre6t.esm.js';
|
|
3
|
+
import '../chunks/openapi-spec-bxGNhNMa.esm.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves all validated promo codes stored in the "beam_promo_codes" cookie and parses it
|
|
7
|
+
*
|
|
8
|
+
* @returns {TPromoCodeResponse | undefined} An array of `ValidatedPromoCode` objects if found and parsed successfully, otherwise `undefined`
|
|
9
|
+
*/
|
|
10
|
+
declare const getAllPromoCodesFromCookie: () => TPromoCodeResponse | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Stores the validated promo codes in the "beam_promo_codes" cookie, replaces and does not merge
|
|
13
|
+
*
|
|
14
|
+
* @param {TValidatedPromoResponse} validatedPromoCodes
|
|
15
|
+
* @param {string} domain
|
|
16
|
+
*/
|
|
17
|
+
declare const setPromoCodeInCookie: ({ validatedPromoCodes, domain, }: {
|
|
18
|
+
validatedPromoCodes: TValidatedPromoResponse;
|
|
19
|
+
domain?: string | undefined;
|
|
20
|
+
}) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves promo codes from localStorage, scoped by API key
|
|
23
|
+
* @param {string} apiKey API key used for storage scoping
|
|
24
|
+
* @returns {TPromoCodeRequest | null} - Returns stored promo codes object containing both
|
|
25
|
+
* validated and unvalidated codes
|
|
26
|
+
* - If no codes exist, returns a fresh object with empty arrays
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
declare const getPromoCodesLocalStorage: ({ apiKey }: {
|
|
30
|
+
apiKey: string;
|
|
31
|
+
}) => TPromoCodeRequest | null;
|
|
32
|
+
/**
|
|
33
|
+
* Sets promo codes in localStorage
|
|
34
|
+
* @param {TPromoCodeRequest} promoCodes New promo codes to add
|
|
35
|
+
* @param {string} apiKey API key for storage scoping
|
|
36
|
+
*/
|
|
37
|
+
declare const setPromoCodesInLocalStorage: ({ apiKey, promoCodes, }: {
|
|
38
|
+
apiKey?: string | undefined;
|
|
39
|
+
promoCodes: Partial<TPromoCodeRequest>;
|
|
40
|
+
}) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Merges new promo codes with existing ones and returns the combined result
|
|
43
|
+
* @param {Partial<TPromoCodeRequest>} newPromos New promo codes to add
|
|
44
|
+
* @param {string} apiKey API key for storage scoping
|
|
45
|
+
* @returns {TPromoCodeRequest} An object containing both validated and unvalidated promo codes
|
|
46
|
+
* @example
|
|
47
|
+
* const result = mergePromoCodes({
|
|
48
|
+
* apiKey: 'beam_123',
|
|
49
|
+
* newPromos: {
|
|
50
|
+
* unvalidatedPromoCodes: [
|
|
51
|
+
* { type: 'manual', attributes: { value: 'WINTER20' } },
|
|
52
|
+
* { type: 'url', attributes: { url: 'www.example.com/?promo=HOLIDAY25' } }
|
|
53
|
+
* ]
|
|
54
|
+
* }
|
|
55
|
+
* });
|
|
56
|
+
*/
|
|
57
|
+
declare const mergeStoreAndReturnPromos: ({ newPromos, apiKey, }: {
|
|
58
|
+
newPromos: Partial<TPromoCodeRequest>;
|
|
59
|
+
apiKey: string;
|
|
60
|
+
}) => TPromoCodeRequest;
|
|
61
|
+
/**
|
|
62
|
+
* Formats unvalidated promo codes by determining their source and attributes
|
|
63
|
+
* The function will assign `QueryParam` as the source if a `url` exists,
|
|
64
|
+
* otherwise, it will assign `Manual` as the source
|
|
65
|
+
*
|
|
66
|
+
* @param {TPromoCodeAttribute[]} promoAttributes An array of promo attributes to be formatted
|
|
67
|
+
* @returns {TUnvalidatedPromoRequest} - An array of UnvalidatedPromoCode objects,
|
|
68
|
+
* each with a source and attributes object
|
|
69
|
+
*/
|
|
70
|
+
declare const mapToUnvalidatedPromoCodes: (promoAttributes: TPromoCodeAttribute[]) => (Partial<{
|
|
71
|
+
type?: "manual" | "url" | undefined;
|
|
72
|
+
} & {
|
|
73
|
+
attributes?: {
|
|
74
|
+
value?: string | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
}> & Partial<{
|
|
77
|
+
type?: "manual" | "url" | undefined;
|
|
78
|
+
} & {
|
|
79
|
+
attributes?: {
|
|
80
|
+
url?: string | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
}>)[];
|
|
83
|
+
/**
|
|
84
|
+
* @param {TPromoCodeAttribute[]} promoAttributes An array of promo attributes to be formatted
|
|
85
|
+
* @param {string} apiKey API key for storage scoping
|
|
86
|
+
* @returns {TPromoCodeRequest} An object containing both validated and unvalidated promo codes
|
|
87
|
+
*/
|
|
88
|
+
declare const formatStoreAndReturnPromoCodes: (promoAttributes: TPromoCodeAttribute[], apiKey: string) => TPromoCodeRequest;
|
|
89
|
+
/**
|
|
90
|
+
* Extracts applicable promo codes from the cart object
|
|
91
|
+
* This function retrieves discounts stored in the cart's `content.discounts` array,
|
|
92
|
+
* filters out only the applicable promo codes, and returns them as an array of strings
|
|
93
|
+
*
|
|
94
|
+
* @param {TBeamCartLocalStorage} cart The cart object retrieved from local storage
|
|
95
|
+
* @returns {string[]} An array of applicable promo codes
|
|
96
|
+
*/
|
|
97
|
+
declare const getPromoCodesFromCart: (cart: TBeamCartLocalStorage) => string[];
|
|
98
|
+
/**
|
|
99
|
+
* Gets promo code exclusively from Shopify discount cookie
|
|
100
|
+
* @returns {string | null} Single discount code or null if not found
|
|
101
|
+
*/
|
|
102
|
+
declare const getPromoCodeFromShopifyCookie: () => string | null;
|
|
103
|
+
/**
|
|
104
|
+
* Safely parses a JSON string into an array of strings
|
|
105
|
+
* If parsing fails or the input is not a valid JSON array, it returns an empty array
|
|
106
|
+
*
|
|
107
|
+
* @param {string | undefined | null} jsonString The JSON string to parse
|
|
108
|
+
* @returns {string[]} The parsed array of strings or an empty array if parsing fails
|
|
109
|
+
*/
|
|
110
|
+
declare const parseJsonStringArray: (jsonString: string | undefined | null) => string[];
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves and sanitizes the current URL for storage, preserving only safe query parameters
|
|
113
|
+
*
|
|
114
|
+
* @returns {TPromoCodeAttribute} Returns an object with only the `url` property set
|
|
115
|
+
*/
|
|
116
|
+
declare const getSanitizedUrlForStorage: () => TPromoCodeAttribute | undefined;
|
|
117
|
+
declare const promoCodesAreEqual: (a: TPromoCodeRequest, b: TPromoCodeRequest) => boolean;
|
|
118
|
+
declare const isEmptyPromoData: (promos: {
|
|
119
|
+
unvalidatedPromoCodes?: unknown[];
|
|
120
|
+
validatedPromoCodes?: unknown[];
|
|
121
|
+
}) => boolean;
|
|
122
|
+
|
|
123
|
+
export { formatStoreAndReturnPromoCodes, getAllPromoCodesFromCookie, getPromoCodeFromShopifyCookie, getPromoCodesFromCart, getPromoCodesLocalStorage, getSanitizedUrlForStorage, isEmptyPromoData, mapToUnvalidatedPromoCodes, mergeStoreAndReturnPromos, parseJsonStringArray, promoCodesAreEqual, setPromoCodeInCookie, setPromoCodesInLocalStorage };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as m,c as d,b as i,h as C,g,a as p,i as n,m as P,j as S,e as l,p as A,s as f,k}from"../chunks/promoManager-YUzbMtwY.esm.js";import"../chunks/beam-errors-AMvTvR1C.esm.js";import"./cookies.esm.js";import"./local-storage.esm.js";import"./logger.esm.js";export{m as formatStoreAndReturnPromoCodes,d as getAllPromoCodesFromCookie,i as getPromoCodeFromShopifyCookie,C as getPromoCodesFromCart,g as getPromoCodesLocalStorage,p as getSanitizedUrlForStorage,n as isEmptyPromoData,P as mapToUnvalidatedPromoCodes,S as mergeStoreAndReturnPromos,l as parseJsonStringArray,A as promoCodesAreEqual,f as setPromoCodeInCookie,k as setPromoCodesInLocalStorage};
|
|
2
|
+
//# sourceMappingURL=promoManager.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promoManager.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as m,c as d,b as i,h as C,g,a as p,i as n,m as P,j as S,e as l,p as A,s as f,k}from"../chunks/promoManager--3WXq4at.esm.js";import"../chunks/beam-errors-AMvTvR1C.esm.js";import"./cookies.js";import"./local-storage.js";import"./logger.js";export{m as formatStoreAndReturnPromoCodes,d as getAllPromoCodesFromCookie,i as getPromoCodeFromShopifyCookie,C as getPromoCodesFromCart,g as getPromoCodesLocalStorage,p as getSanitizedUrlForStorage,n as isEmptyPromoData,P as mapToUnvalidatedPromoCodes,S as mergeStoreAndReturnPromos,l as parseJsonStringArray,A as promoCodesAreEqual,f as setPromoCodeInCookie,k as setPromoCodesInLocalStorage};
|
|
2
|
+
//# sourceMappingURL=promoManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promoManager.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createScopedLocalStorage as o}from"./local-storage.esm.js";import"../chunks/beam-errors-
|
|
1
|
+
import{createScopedLocalStorage as o}from"./local-storage.esm.js";import"../chunks/beam-errors-AMvTvR1C.esm.js";import"./logger.esm.js";const t="remote_session_id";function s({remoteSessionId:e,apiKey:i=""}){o({apiKey:i}).setItem(t,e)}function r({apiKey:e=""}){return o({apiKey:e}).getItem(t)}export{r as getRemoteSession,s as saveRemoteSession};
|
|
2
2
|
//# sourceMappingURL=remote-session.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createScopedLocalStorage as o}from"./local-storage.js";import"../chunks/beam-errors-
|
|
1
|
+
import{createScopedLocalStorage as o}from"./local-storage.js";import"../chunks/beam-errors-AMvTvR1C.esm.js";import"./logger.js";const t="remote_session_id";function s({remoteSessionId:e,apiKey:i=""}){o({apiKey:i}).setItem(t,e)}function r({apiKey:e=""}){return o({apiKey:e}).getItem(t)}export{r as getRemoteSession,s as saveRemoteSession};
|
|
2
2
|
//# sourceMappingURL=remote-session.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as s}from"../chunks/beam-errors-
|
|
1
|
+
import{B as s}from"../chunks/beam-errors-AMvTvR1C.esm.js";function l(t,{timeout:i=1e4}={}){return new Promise((r,m)=>{let e=document.querySelector(t);if(e){r(e);return}let o;const u=setTimeout(()=>{e||(o?.disconnect(),m(new s(`Timed out waiting for '${t}'`)))},i);new MutationObserver((a,n)=>{o=n,Array.from(document.querySelectorAll(t)).forEach(c=>{e=c,r(c),n.disconnect(),clearTimeout(u)})}).observe(document.documentElement,{childList:!0,subtree:!0})})}export{l as waitForElement};
|
|
2
2
|
//# sourceMappingURL=wait-for-element.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as s}from"../chunks/beam-errors-
|
|
1
|
+
import{B as s}from"../chunks/beam-errors-AMvTvR1C.esm.js";function l(t,{timeout:i=1e4}={}){return new Promise((r,m)=>{let e=document.querySelector(t);if(e){r(e);return}let o;const u=setTimeout(()=>{e||(o?.disconnect(),m(new s(`Timed out waiting for '${t}'`)))},i);new MutationObserver((a,n)=>{o=n,Array.from(document.querySelectorAll(t)).forEach(c=>{e=c,r(c),n.disconnect(),clearTimeout(u)})}).observe(document.documentElement,{childList:!0,subtree:!0})})}export{l as waitForElement};
|
|
2
2
|
//# sourceMappingURL=wait-for-element.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beamimpact/web-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.50.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"rollup-plugin-dts": "6.1.0",
|
|
96
96
|
"rollup-plugin-esbuild": "6.1.0",
|
|
97
97
|
"typescript": "4.9.5",
|
|
98
|
-
"vite": "4.5.
|
|
98
|
+
"vite": "4.5.3",
|
|
99
99
|
"wait-on": "7.2.0"
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_share-dialog-dependencies-2jzbs44g.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./vendor-GKiOHg2N.esm.js";import"./shoelace-components-xrhk189_.esm.js";import"./lit-iNN5L_Qk.esm.js";import"./routes-Dmf2ZNnZ.esm.js";import"./beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";
|
|
2
|
-
//# sourceMappingURL=_share-dialog-dependencies-C8uChjuF.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_share-dialog-dependencies-C8uChjuF.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
class e extends Error{constructor(r,{cause:o,name:t="BeamError"}={}){super(r,{cause:o}),this.name=t,this.supportUrl="https://beamimpact.com"}}class a extends e{constructor(r,o,t){super(t,{name:"BeamNetworkError"}),this.response=r,this.body=o}}class n extends e{constructor(r=[],o){super(o,{name:"BeamMissingConfig"}),this.missingConfigKeyNames=r}}class i extends e{constructor(r="Both transactionId and subscriptionId cannot be specified at the same time."){super(r,{name:"BeamInvalidAttributeCombinationError"})}}class c extends e{constructor(r){super(r,{name:"BeamLocalStorageError"})}}class m extends e{constructor(r){super(r,{name:"BeamSetupError"})}}var u=Object.freeze({__proto__:null,BeamError:e,InvalidAttributeCombinationError:i,LocalStorageError:c,MissingConfig:n,NetworkError:a,SetupError:m});export{e as B,i as I,c as L,n as M,a as N,m as S,u as b};
|
|
2
|
-
//# sourceMappingURL=beam-errors-P-Lu07Ce.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beam-errors-P-Lu07Ce.esm.js","sources":["../../src/utils/beam-errors.ts"],"sourcesContent":["export class BeamError extends Error {\n supportUrl: string;\n constructor(msg?: string, { cause, name = \"BeamError\" }: { cause?: any; name?: string } = {}) {\n super(msg, { cause });\n this.name = name;\n this.supportUrl = \"https://beamimpact.com\";\n }\n}\n\nexport class NetworkError extends BeamError {\n /** Fetch Response object with .ok, .status, etc.*/\n response: Response;\n /** If network response included JSON payload, it is parsed and available here */\n body?: Record<string, string>;\n constructor(response: Response, body?: Record<string, string>, msg?: string) {\n super(msg, { name: \"BeamNetworkError\" });\n this.response = response;\n this.body = body;\n }\n}\n\nexport class MissingConfig extends BeamError {\n missingConfigKeyNames: string[];\n constructor(missingConfigKeyNames: string[] = [], msg?: string) {\n super(msg, { name: \"BeamMissingConfig\" });\n this.missingConfigKeyNames = missingConfigKeyNames;\n }\n}\n\nexport class InvalidAttributeCombinationError extends BeamError {\n constructor(msg = \"Both transactionId and subscriptionId cannot be specified at the same time.\") {\n super(msg, { name: \"BeamInvalidAttributeCombinationError\" });\n }\n}\n\nexport class LocalStorageError extends BeamError {\n constructor(msg?: string) {\n super(msg, { name: \"BeamLocalStorageError\" });\n }\n}\n\nexport class SetupError extends BeamError {\n constructor(msg?: string) {\n super(msg, { name: \"BeamSetupError\" });\n }\n}\n"],"names":["BeamError","msg","cause","name","NetworkError","response","body","MissingConfig","missingConfigKeyNames","InvalidAttributeCombinationError","LocalStorageError","SetupError"],"mappings":"AAAa,MAAAA,UAAkB,KAAM,CAEnC,YAAYC,EAAc,CAAE,MAAAC,EAAO,KAAAC,EAAO,WAAY,EAAoC,CAAA,EAAI,CAC5F,MAAMF,EAAK,CAAE,MAAAC,CAAM,CAAC,EACpB,KAAK,KAAOC,EACZ,KAAK,WAAa,wBACpB,CACF,CAEO,MAAMC,UAAqBJ,CAAU,CAK1C,YAAYK,EAAoBC,EAA+BL,EAAc,CAC3E,MAAMA,EAAK,CAAE,KAAM,kBAAmB,CAAC,EACvC,KAAK,SAAWI,EAChB,KAAK,KAAOC,CACd,CACF,CAEO,MAAMC,UAAsBP,CAAU,CAE3C,YAAYQ,EAAkC,CAAIP,EAAAA,EAAc,CAC9D,MAAMA,EAAK,CAAE,KAAM,mBAAoB,CAAC,EACxC,KAAK,sBAAwBO,CAC/B,CACF,CAEO,MAAMC,UAAyCT,CAAU,CAC9D,YAAYC,EAAM,8EAA+E,CAC/F,MAAMA,EAAK,CAAE,KAAM,sCAAuC,CAAC,CAC7D,CACF,CAEa,MAAAS,UAA0BV,CAAU,CAC/C,YAAYC,EAAc,CACxB,MAAMA,EAAK,CAAE,KAAM,uBAAwB,CAAC,CAC9C,CACF,CAEa,MAAAU,UAAmBX,CAAU,CACxC,YAAYC,EAAc,CACxB,MAAMA,EAAK,CAAE,KAAM,gBAAiB,CAAC,CACvC,CACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { p as paths } from './openapi-spec-hjdK2L9Q.esm.js';
|
|
2
|
-
|
|
3
|
-
type TCartApi = paths["/chain/findEligibleNonprofitsForCart"]["post"]["requestBody"]["content"]["application/json"]["cart"];
|
|
4
|
-
type TCart = TCartApi & {
|
|
5
|
-
content: {
|
|
6
|
-
items: Record<string, any>[];
|
|
7
|
-
discounts?: Record<string, any>[] | undefined | null;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type { TCart as T, TCartApi as a };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{f as r}from"./lit-iNN5L_Qk.esm.js";import{M as s,I as a}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as l}from"../utils/logger.esm.js";const d=r`html,body,p,ol,ul,li,dl,dt,dd,blockquote,figure,fieldset,legend,textarea,pre,iframe,hr,h1,h2,h3,h4,h5,h6{margin:0;padding:0}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}ul{list-style:none}button,input,select{margin:0}html{box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}img,video{/*height:auto;*/max-width:100%}iframe{border:0}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}`;function f(i,e=i.tagName){customElements.get(e)||customElements.define(e,i)}function h(i,e){const t=[],n=e;for(const o of i)n[o]==null&&t.push(o);if(t.length>0)throw l.error(`Beam Impact - Missing Required Config Values:
|
|
2
|
-
`,t.join(", "),e),new s(t);return!0}function m(i,e){return i.every(t=>t in e&&e[t]!=null)}function u(i,e){if(i.every(t=>e[t]!==null&&e[t]!==void 0))throw new a}export{u as a,m as b,d as c,f as d,h as e};
|
|
3
|
-
//# sourceMappingURL=enforce-config-ZAI7WYAd.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-config-ZAI7WYAd.esm.js","sources":["../../src/shared/css-reset.ts","../../src/shared/defineCustomElement.ts","../../src/shared/enforce-config.ts"],"sourcesContent":["import { css } from \"lit\";\n\n// minireset.css v0.0.7 | MIT License | github.com/jgthms/minireset.css\n// prettier-ignore\nexport const cssReset = css`html,body,p,ol,ul,li,dl,dt,dd,blockquote,figure,fieldset,legend,textarea,pre,iframe,hr,h1,h2,h3,h4,h5,h6{margin:0;padding:0}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}ul{list-style:none}button,input,select{margin:0}html{box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}img,video{/*height:auto;*/max-width:100%}iframe{border:0}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}`;\n","/**\n * Defines a custom element based on its static tagName property\n */\nexport function defineCustomElement(\n CustomElementClass: CustomElementConstructor & { tagName: string },\n tagName = CustomElementClass[\"tagName\"]\n) {\n customElements.get(tagName) || customElements.define(tagName, CustomElementClass);\n}\n","import { InvalidAttributeCombinationError, MissingConfig } from \"../utils/beam-errors\";\nimport { logger } from \"../utils/logger\";\n\nexport function enforceConfig<T>(keys: (keyof T)[], input: unknown): input is Required<T> {\n const missingKeys: string[] = [];\n const check = input as Record<string | number | symbol, unknown>;\n for (const key of keys) {\n if (check[key] == null) {\n missingKeys.push(key as string);\n }\n }\n if (missingKeys.length > 0) {\n logger.error(\"Beam Impact - Missing Required Config Values:\\n\", missingKeys.join(\", \"), input);\n throw new MissingConfig(missingKeys);\n }\n return true;\n}\n\nexport function areRequiredKeysDefined<T extends object>(requiredKeys: (keyof T)[], config: T): boolean {\n return requiredKeys.every((key) => key in config && config[key] != null);\n}\n\nexport function checkForInvalidAttributeCombinations<T>(keys: (keyof T)[], config: T): void {\n const InvalidAttributeCombinationsPresent = keys.every((key) => config[key] !== null && config[key] !== undefined);\n if (InvalidAttributeCombinationsPresent) {\n throw new InvalidAttributeCombinationError();\n }\n}\n"],"names":["cssReset","css","defineCustomElement","CustomElementClass","tagName","enforceConfig","keys","input","missingKeys","check","key","logger","MissingConfig","areRequiredKeysDefined","requiredKeys","config","checkForInvalidAttributeCombinations","InvalidAttributeCombinationError"],"mappings":"mJAIO,MAAMA,EAAWC,gaCDjB,SAASC,EACdC,EACAC,EAAUD,EAAmB,QAC7B,CACA,eAAe,IAAIC,CAAO,GAAK,eAAe,OAAOA,EAASD,CAAkB,CAClF,CCLO,SAASE,EAAiBC,EAAmBC,EAAsC,CACxF,MAAMC,EAAwB,CAAA,EACxBC,EAAQF,EACd,UAAWG,KAAOJ,EACZG,EAAMC,CAAG,GAAK,MAChBF,EAAY,KAAKE,CAAa,EAGlC,GAAIF,EAAY,OAAS,EACvB,MAAAG,EAAO,MAAM;AAAA,EAAmDH,EAAY,KAAK,IAAI,EAAGD,CAAK,EACvF,IAAIK,EAAcJ,CAAW,EAErC,MAAO,EACT,CAEO,SAASK,EAAyCC,EAA2BC,EAAoB,CACtG,OAAOD,EAAa,MAAOJ,GAAQA,KAAOK,GAAUA,EAAOL,CAAG,GAAK,IAAI,CACzE,CAEO,SAASM,EAAwCV,EAAmBS,EAAiB,CAE1F,GAD4CT,EAAK,MAAOI,GAAQK,EAAOL,CAAG,IAAM,MAAQK,EAAOL,CAAG,IAAM,MAAS,EAE/G,MAAM,IAAIO,CAEd"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{f as r}from"./lit-iNN5L_Qk.esm.js";import{M as s,I as a}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as l}from"../utils/logger.js";const d=r`html,body,p,ol,ul,li,dl,dt,dd,blockquote,figure,fieldset,legend,textarea,pre,iframe,hr,h1,h2,h3,h4,h5,h6{margin:0;padding:0}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}ul{list-style:none}button,input,select{margin:0}html{box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}img,video{/*height:auto;*/max-width:100%}iframe{border:0}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}`;function f(i,e=i.tagName){customElements.get(e)||customElements.define(e,i)}function h(i,e){const t=[],n=e;for(const o of i)n[o]==null&&t.push(o);if(t.length>0)throw l.error(`Beam Impact - Missing Required Config Values:
|
|
2
|
-
`,t.join(", "),e),new s(t);return!0}function m(i,e){return i.every(t=>t in e&&e[t]!=null)}function u(i,e){if(i.every(t=>e[t]!==null&&e[t]!==void 0))throw new a}export{u as a,m as b,d as c,f as d,h as e};
|
|
3
|
-
//# sourceMappingURL=enforce-config-ZyPq_4CF.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-config-ZyPq_4CF.esm.js","sources":["../../src/shared/css-reset.ts","../../src/shared/defineCustomElement.ts","../../src/shared/enforce-config.ts"],"sourcesContent":["import { css } from \"lit\";\n\n// minireset.css v0.0.7 | MIT License | github.com/jgthms/minireset.css\n// prettier-ignore\nexport const cssReset = css`html,body,p,ol,ul,li,dl,dt,dd,blockquote,figure,fieldset,legend,textarea,pre,iframe,hr,h1,h2,h3,h4,h5,h6{margin:0;padding:0}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}ul{list-style:none}button,input,select{margin:0}html{box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}img,video{/*height:auto;*/max-width:100%}iframe{border:0}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}`;\n","/**\n * Defines a custom element based on its static tagName property\n */\nexport function defineCustomElement(\n CustomElementClass: CustomElementConstructor & { tagName: string },\n tagName = CustomElementClass[\"tagName\"]\n) {\n customElements.get(tagName) || customElements.define(tagName, CustomElementClass);\n}\n","import { InvalidAttributeCombinationError, MissingConfig } from \"../utils/beam-errors\";\nimport { logger } from \"../utils/logger\";\n\nexport function enforceConfig<T>(keys: (keyof T)[], input: unknown): input is Required<T> {\n const missingKeys: string[] = [];\n const check = input as Record<string | number | symbol, unknown>;\n for (const key of keys) {\n if (check[key] == null) {\n missingKeys.push(key as string);\n }\n }\n if (missingKeys.length > 0) {\n logger.error(\"Beam Impact - Missing Required Config Values:\\n\", missingKeys.join(\", \"), input);\n throw new MissingConfig(missingKeys);\n }\n return true;\n}\n\nexport function areRequiredKeysDefined<T extends object>(requiredKeys: (keyof T)[], config: T): boolean {\n return requiredKeys.every((key) => key in config && config[key] != null);\n}\n\nexport function checkForInvalidAttributeCombinations<T>(keys: (keyof T)[], config: T): void {\n const InvalidAttributeCombinationsPresent = keys.every((key) => config[key] !== null && config[key] !== undefined);\n if (InvalidAttributeCombinationsPresent) {\n throw new InvalidAttributeCombinationError();\n }\n}\n"],"names":["cssReset","css","defineCustomElement","CustomElementClass","tagName","enforceConfig","keys","input","missingKeys","check","key","logger","MissingConfig","areRequiredKeysDefined","requiredKeys","config","checkForInvalidAttributeCombinations","InvalidAttributeCombinationError"],"mappings":"+IAIO,MAAMA,EAAWC,gaCDjB,SAASC,EACdC,EACAC,EAAUD,EAAmB,QAC7B,CACA,eAAe,IAAIC,CAAO,GAAK,eAAe,OAAOA,EAASD,CAAkB,CAClF,CCLO,SAASE,EAAiBC,EAAmBC,EAAsC,CACxF,MAAMC,EAAwB,CAAA,EACxBC,EAAQF,EACd,UAAWG,KAAOJ,EACZG,EAAMC,CAAG,GAAK,MAChBF,EAAY,KAAKE,CAAa,EAGlC,GAAIF,EAAY,OAAS,EACvB,MAAAG,EAAO,MAAM;AAAA,EAAmDH,EAAY,KAAK,IAAI,EAAGD,CAAK,EACvF,IAAIK,EAAcJ,CAAW,EAErC,MAAO,EACT,CAEO,SAASK,EAAyCC,EAA2BC,EAAoB,CACtG,OAAOD,EAAa,MAAOJ,GAAQA,KAAOK,GAAUA,EAAOL,CAAG,GAAK,IAAI,CACzE,CAEO,SAASM,EAAwCV,EAAmBS,EAAiB,CAE1F,GAD4CT,EAAK,MAAOI,GAAQK,EAAOL,CAAG,IAAM,MAAQK,EAAOL,CAAG,IAAM,MAAS,EAE/G,MAAM,IAAIO,CAEd"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const t=class C extends CustomEvent{constructor(e){super(C.eventName,{detail:e,bubbles:!0,composed:!0})}};t.eventName="beamnetworkcall";let a=t;const s=class E extends CustomEvent{constructor(e){super(E.eventName,{detail:e,bubbles:!0,composed:!0})}};s.eventName="beamnonprofitselect";let n=s;const o=class N extends CustomEvent{constructor(e){super(N.eventName,{detail:e,bubbles:!0,composed:!0})}};o.eventName="beamcartchange";let r=o;const m=class i extends CustomEvent{constructor(e){super(i.eventName,{detail:e,bubbles:!0,composed:!0})}};m.eventName="beamcartcreated";let c=m;const l=class B extends CustomEvent{constructor(e){super(B.eventName,{detail:e,bubbles:!0,composed:!0})}};l.eventName="beamordercreated";let v=l;const d=class f extends CustomEvent{constructor(e){super(f.eventName,{detail:e,bubbles:!0,composed:!0})}};d.eventName="beamstatuschange";let u=d;const b=class x extends CustomEvent{constructor(e){super(x.eventName,{detail:e,bubbles:!0,composed:!0})}};b.eventName="beamnonprofitselectionremoved";let p=b;var g=Object.freeze({__proto__:null,BeamCartChangeEvent:r,BeamCartCreatedEvent:c,BeamNetworkCallEvent:a,BeamNonprofitSelectEvent:n,BeamNonprofitSelectionRemovedEvent:p,BeamOrderCreatedEvent:v,BeamStatusChangeEvent:u});export{u as B,v as a,n as b,a as c,r as d,g as e,c as f,p as g};
|
|
2
|
-
//# sourceMappingURL=events-6Z5MkCRr.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events-6Z5MkCRr.esm.js","sources":["../../src/utils/events.ts"],"sourcesContent":["import { TCartApi } from \"../shared/cart-contents\";\nimport { TId, WidgetName } from \"../shared/types\";\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype NetworkEventDetail =\n | { url: string; method: string; type: \"fetch\"; response: Response }\n | { url: string; method: string; type: \"xhr\"; xhr: XMLHttpRequest };\n\n/**\n * beamnetworkcall\n * Emitted by the Beam network listener whenever any API calls are made on the page\n */\nexport class BeamNetworkCallEvent extends CustomEvent<NetworkEventDetail> {\n static eventName = \"beamnetworkcall\" as const;\n constructor(detail: NetworkEventDetail) {\n super(BeamNetworkCallEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype NonprofitSelectDetail = {\n selectionId?: string;\n selectedNonprofitId?: number | null;\n nonprofitName?: string | null;\n source?: WidgetName | null;\n};\n\n/**\n * beamnonprofitselect\n * Emitted when the end user selects a nonprofit in the Beam widget, and when the previous selection was restored\n * automatically\n */\nexport class BeamNonprofitSelectEvent extends CustomEvent<NonprofitSelectDetail> {\n static eventName = \"beamnonprofitselect\" as const;\n constructor(detail: NonprofitSelectDetail) {\n super(BeamNonprofitSelectEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype CartChangeDetail = TCartApi & {\n cartId?: string;\n subtotal?: number;\n itemCount?: number;\n currencyCode?: string;\n};\n\n/**\n * beamcartchange\n * Emitted when Beam detects that cart contents have changed, and when items are added to the cart for the first time\n */\nexport class BeamCartChangeEvent extends CustomEvent<CartChangeDetail> {\n static eventName = \"beamcartchange\" as const;\n constructor(detail: CartChangeDetail) {\n super(BeamCartChangeEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype CartCreatedDetail = CartChangeDetail;\n\n/**\n * beamcartcreated\n * Emitted when a cart is created in Beam for the first time, but NOT when the cart is updated\n * Beam's cart expiration rules are used to determine when a returning visit counts as the same cart\n */\nexport class BeamCartCreatedEvent extends CustomEvent<CartCreatedDetail> {\n static eventName = \"beamcartcreated\" as const;\n constructor(detail: CartCreatedDetail) {\n super(BeamCartCreatedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\ntype OrderCreatedDetail = {\n orderId: TId;\n transactionId: TId;\n cartTotal: number;\n currencyCode: string;\n};\n\n/**\n * beamordercreated\n * Emitted when an order is registered with Beam for the first time, but NOT on repeat visits, page refreshes, etc.\n */\nexport class BeamOrderCreatedEvent extends CustomEvent<OrderCreatedDetail> {\n static eventName = \"beamordercreated\" as const;\n\n constructor(detail: OrderCreatedDetail) {\n super(BeamOrderCreatedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\n\n/**\n * beamstatuschange\n * Emitted when the Beam config object has finished initializing along with all plugins\n */\ntype BeamStatusChangeEventDetail = { status: \"pending\" } | { status: \"error\"; error: Error } | { status: \"ready\" };\nexport class BeamStatusChangeEvent extends CustomEvent<BeamStatusChangeEventDetail> {\n static eventName = \"beamstatuschange\" as const;\n\n constructor(detail: BeamStatusChangeEventDetail) {\n super(BeamStatusChangeEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n\n/* ------------------------------------------------------------------------------------------------------------------ */\ntype NonprofitSelectionRemovedDetail = {\n previousNonprofitId?: number | null;\n newNonprofitId?: number | null;\n selectionId?: string;\n};\n\n/**\n * beamnonprofitselectionremoved\n * Emitted when the nonprofit selection is removed from deselection or due to nonprofit cohort change\n */\nexport class BeamNonprofitSelectionRemovedEvent extends CustomEvent<NonprofitSelectionRemovedDetail> {\n static eventName = \"beamnonprofitselectionremoved\" as const;\n constructor(detail: NonprofitSelectionRemovedDetail) {\n super(BeamNonprofitSelectionRemovedEvent.eventName, { detail, bubbles: true, composed: true });\n }\n}\n"],"names":["_BeamNetworkCallEvent","detail","BeamNetworkCallEvent","_BeamNonprofitSelectEvent","BeamNonprofitSelectEvent","_BeamCartChangeEvent","BeamCartChangeEvent","_BeamCartCreatedEvent","BeamCartCreatedEvent","_BeamOrderCreatedEvent","BeamOrderCreatedEvent","_BeamStatusChangeEvent","BeamStatusChangeEvent","_BeamNonprofitSelectionRemovedEvent","BeamNonprofitSelectionRemovedEvent"],"mappings":"AAaO,MAAMA,EAAN,MAAMA,UAA6B,WAAgC,CAExE,YAAYC,EAA4B,CACtC,MAAMD,EAAqB,UAAW,CAAE,OAAAC,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACjF,CACF,EALaD,EACJ,UAAY,kBADd,IAAME,EAANF,EAqBA,MAAMG,EAAN,MAAMA,UAAiC,WAAmC,CAE/E,YAAYF,EAA+B,CACzC,MAAME,EAAyB,UAAW,CAAE,OAAAF,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACrF,CACF,EALaE,EACJ,UAAY,sBADd,IAAMC,EAAND,EAoBA,MAAME,EAAN,MAAMA,UAA4B,WAA8B,CAErE,YAAYJ,EAA0B,CACpC,MAAMI,EAAoB,UAAW,CAAE,OAAAJ,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAChF,CACF,EALaI,EACJ,UAAY,iBADR,IAAAC,EAAND,EAgBA,MAAME,EAAN,MAAMA,UAA6B,WAA+B,CAEvE,YAAYN,EAA2B,CACrC,MAAMM,EAAqB,UAAW,CAAE,OAAAN,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CACjF,CACF,EALaM,EACJ,UAAY,sBADRC,EAAND,EAoBA,MAAME,EAAN,MAAMA,UAA8B,WAAgC,CAGzE,YAAYR,EAA4B,CACtC,MAAMQ,EAAsB,UAAW,CAAE,OAAAR,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAClF,CACF,EANaQ,EACJ,UAAY,uBADRC,EAAND,EAeA,MAAME,EAAN,MAAMA,UAA8B,WAAyC,CAGlF,YAAYV,EAAqC,CAC/C,MAAMU,EAAsB,UAAW,CAAE,OAAAV,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAClF,CACF,EANaU,EACJ,UAAY,mBADR,IAAAC,EAAND,EAmBA,MAAME,EAAN,MAAMA,UAA2C,WAA6C,CAEnG,YAAYZ,EAAyC,CACnD,MAAMY,EAAmC,UAAW,CAAE,OAAAZ,EAAQ,QAAS,GAAM,SAAU,EAAK,CAAC,CAC/F,CACF,EALaY,EACJ,UAAY,gCADd,IAAMC,EAAND"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { b as beamErrors } from './beam-errors-fXDkG1zo.esm.js';
|
|
2
|
-
import { e as events } from './events-ZCTR9JGZ.esm.js';
|
|
3
|
-
import { logger } from '../utils/logger.js';
|
|
4
|
-
import { initNetworkListeners } from '../utils/network-listeners.js';
|
|
5
|
-
import { createScopedLocalStorage } from '../utils/local-storage.js';
|
|
6
|
-
import { waitForElement } from '../utils/wait-for-element.js';
|
|
7
|
-
import { CookieChangeEvent, deleteCookieValue, getCookieMap, getCookieValue, setCookieValue } from '../utils/cookies.js';
|
|
8
|
-
import { getRemoteSession, saveRemoteSession } from '../utils/remote-session.js';
|
|
9
|
-
import { memoizeLast } from '../utils/memoize-last.js';
|
|
10
|
-
import debounce from 'lodash-es/debounce';
|
|
11
|
-
import isEqual from 'lodash-es/isEqual';
|
|
12
|
-
|
|
13
|
-
declare const index_CookieChangeEvent: typeof CookieChangeEvent;
|
|
14
|
-
declare const index_createScopedLocalStorage: typeof createScopedLocalStorage;
|
|
15
|
-
declare const index_debounce: typeof debounce;
|
|
16
|
-
declare const index_deleteCookieValue: typeof deleteCookieValue;
|
|
17
|
-
declare const index_events: typeof events;
|
|
18
|
-
declare const index_getCookieMap: typeof getCookieMap;
|
|
19
|
-
declare const index_getCookieValue: typeof getCookieValue;
|
|
20
|
-
declare const index_getRemoteSession: typeof getRemoteSession;
|
|
21
|
-
declare const index_initNetworkListeners: typeof initNetworkListeners;
|
|
22
|
-
declare const index_isEqual: typeof isEqual;
|
|
23
|
-
declare const index_logger: typeof logger;
|
|
24
|
-
declare const index_memoizeLast: typeof memoizeLast;
|
|
25
|
-
declare const index_saveRemoteSession: typeof saveRemoteSession;
|
|
26
|
-
declare const index_setCookieValue: typeof setCookieValue;
|
|
27
|
-
declare const index_waitForElement: typeof waitForElement;
|
|
28
|
-
declare namespace index {
|
|
29
|
-
export { index_CookieChangeEvent as CookieChangeEvent, index_createScopedLocalStorage as createScopedLocalStorage, index_debounce as debounce, index_deleteCookieValue as deleteCookieValue, beamErrors as errors, index_events as events, index_getCookieMap as getCookieMap, index_getCookieValue as getCookieValue, index_getRemoteSession as getRemoteSession, index_initNetworkListeners as initNetworkListeners, index_isEqual as isEqual, index_logger as logger, index_memoizeLast as memoizeLast, index_saveRemoteSession as saveRemoteSession, index_setCookieValue as setCookieValue, index_waitForElement as waitForElement };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { index as i };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.esm.js";import{initNetworkListeners as r}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as i}from"../utils/local-storage.esm.js";import{waitForElement as m}from"../utils/wait-for-element.esm.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.esm.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.esm.js";import{memoizeLast as f}from"../utils/memoize-last.esm.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
-
//# sourceMappingURL=index-CsWTfuok.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-CsWTfuok.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { b as beamErrors } from './beam-errors-fXDkG1zo.esm.js';
|
|
2
|
-
import { e as events } from './events-ZCTR9JGZ.esm.js';
|
|
3
|
-
import { logger } from '../utils/logger.js';
|
|
4
|
-
import { initNetworkListeners } from '../utils/network-listeners.js';
|
|
5
|
-
import { createScopedLocalStorage } from '../utils/local-storage.js';
|
|
6
|
-
import { waitForElement } from '../utils/wait-for-element.js';
|
|
7
|
-
import { CookieChangeEvent, deleteCookieValue, getCookieMap, getCookieValue, setCookieValue } from '../utils/cookies.js';
|
|
8
|
-
import { getRemoteSession, saveRemoteSession } from '../utils/remote-session.js';
|
|
9
|
-
import { memoizeLast } from '../utils/memoize-last.js';
|
|
10
|
-
import debounce from 'lodash-es/debounce';
|
|
11
|
-
import isEqual from 'lodash-es/isEqual';
|
|
12
|
-
|
|
13
|
-
declare const index_CookieChangeEvent: typeof CookieChangeEvent;
|
|
14
|
-
declare const index_createScopedLocalStorage: typeof createScopedLocalStorage;
|
|
15
|
-
declare const index_debounce: typeof debounce;
|
|
16
|
-
declare const index_deleteCookieValue: typeof deleteCookieValue;
|
|
17
|
-
declare const index_events: typeof events;
|
|
18
|
-
declare const index_getCookieMap: typeof getCookieMap;
|
|
19
|
-
declare const index_getCookieValue: typeof getCookieValue;
|
|
20
|
-
declare const index_getRemoteSession: typeof getRemoteSession;
|
|
21
|
-
declare const index_initNetworkListeners: typeof initNetworkListeners;
|
|
22
|
-
declare const index_isEqual: typeof isEqual;
|
|
23
|
-
declare const index_logger: typeof logger;
|
|
24
|
-
declare const index_memoizeLast: typeof memoizeLast;
|
|
25
|
-
declare const index_saveRemoteSession: typeof saveRemoteSession;
|
|
26
|
-
declare const index_setCookieValue: typeof setCookieValue;
|
|
27
|
-
declare const index_waitForElement: typeof waitForElement;
|
|
28
|
-
declare namespace index {
|
|
29
|
-
export { index_CookieChangeEvent as CookieChangeEvent, index_createScopedLocalStorage as createScopedLocalStorage, index_debounce as debounce, index_deleteCookieValue as deleteCookieValue, beamErrors as errors, index_events as events, index_getCookieMap as getCookieMap, index_getCookieValue as getCookieValue, index_getRemoteSession as getRemoteSession, index_initNetworkListeners as initNetworkListeners, index_isEqual as isEqual, index_logger as logger, index_memoizeLast as memoizeLast, index_saveRemoteSession as saveRemoteSession, index_setCookieValue as setCookieValue, index_waitForElement as waitForElement };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { index as i };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-M7Ut5U3j.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.js";import{initNetworkListeners as r}from"../utils/network-listeners.js";import{createScopedLocalStorage as i}from"../utils/local-storage.js";import{waitForElement as m}from"../utils/wait-for-element.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.js";import{memoizeLast as f}from"../utils/memoize-last.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
-
//# sourceMappingURL=index-MIp7LlXH.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-MIp7LlXH.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-WvOCqhxv.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.js";import{initNetworkListeners as r}from"../utils/network-listeners.js";import{createScopedLocalStorage as i}from"../utils/local-storage.js";import{waitForElement as m}from"../utils/wait-for-element.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.js";import{memoizeLast as f}from"../utils/memoize-last.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
-
//# sourceMappingURL=index-YJNgLCif.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-YJNgLCif.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-a6oXV2ro.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i}from"./index-YJNgLCif.esm.js";import{i as o}from"./index-WvOCqhxv.esm.js";import{i as r}from"./index-JDZQClkA.esm.js";import{i as e}from"./index-a6oXV2ro.esm.js";import{i as m}from"./index-XHm2EBaD.esm.js";var s=Object.freeze({__proto__:null,Cart:e,Logs:m,Session:r,Shopify:o,Utils:i});export{s as i};
|
|
2
|
-
//# sourceMappingURL=index-dkwGkvOu.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-dkwGkvOu.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./beam-errors-P-Lu07Ce.esm.js";import{e as o}from"./events-6Z5MkCRr.esm.js";import{logger as t}from"../utils/logger.esm.js";import{initNetworkListeners as r}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as i}from"../utils/local-storage.esm.js";import{waitForElement as m}from"../utils/wait-for-element.esm.js";import{deleteCookieValue as a,getCookieMap as s,getCookieValue as l,setCookieValue as n}from"../utils/cookies.esm.js";import{getRemoteSession as p,saveRemoteSession as g}from"../utils/remote-session.esm.js";import{memoizeLast as f}from"../utils/memoize-last.esm.js";import{d as u,i as k}from"./lodash-P8OIs-at.esm.js";var c=Object.freeze({__proto__:null,createScopedLocalStorage:i,debounce:u,deleteCookieValue:a,errors:e,events:o,getCookieMap:s,getCookieValue:l,getRemoteSession:p,initNetworkListeners:r,isEqual:k,logger:t,memoizeLast:f,saveRemoteSession:g,setCookieValue:n,waitForElement:m});export{c as i};
|
|
2
|
-
//# sourceMappingURL=index-iK195-B9.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-iK195-B9.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-nstmHC95.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i}from"./index-CsWTfuok.esm.js";import{i as o}from"./index-M7Ut5U3j.esm.js";import{i as r}from"./index-eXilYHHK.esm.js";import{i as e}from"./index-nstmHC95.esm.js";import{i as m}from"./index-JJjxnRZK.esm.js";var s=Object.freeze({__proto__:null,Cart:e,Logs:m,Session:r,Shopify:o,Utils:i});export{s as i};
|
|
2
|
-
//# sourceMappingURL=index-vq14EaW4.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-vq14EaW4.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as O}from"./lodash-P8OIs-at.esm.js";import{c as D,b as R,g as k,f as P,d as x}from"./events-6Z5MkCRr.esm.js";import{logger as I}from"../utils/logger.js";import{initNetworkListeners as K}from"../utils/network-listeners.js";import{createScopedLocalStorage as J}from"../utils/local-storage.js";import{memoizeLast as j}from"../utils/memoize-last.js";import{B as g}from"./cart-contents-h60geKWa.esm.js";import{J as v}from"./update-cart-EGTcbNRX.esm.js";import{W as F,D as G}from"./routes-o1QpF40R.esm.js";import{getExternalCartId as E,getBeamCartId as h}from"../utils/cart.js";import"../components/post-purchase.js";import{waitForElement as M}from"../utils/wait-for-element.js";import{B as W}from"./beam-errors-P-Lu07Ce.esm.js";import{getCookieValue as q}from"../utils/cookies.js";const S=window.Shopify?.routes?.root||"/";let A=!1;const N="cart";async function z(e){if(A)return!1;K(),window.addEventListener(D.eventName,async r=>{const t=r,n=/cart\/(add|change|update|clear)/,a=t.detail.type==="xhr"?t.detail.xhr.responseURL:t.detail.response.url,c=new URL(a);if(!n.test(c.pathname))return;const o=await L(e);o.changed&&v(e,o.cart)});let s,d;window.addEventListener(R.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectEvent]",t.detail);const{source:n,selectedNonprofitId:a,selectionId:c}=t.detail;if(n===F.select_nonprofit){const o=E(N,e),l=h(g,e),{chainId:p,storeId:u}=e;if(s===a&&d===c)return;await y({selectedNonprofitId:a,selectionId:c,beamCartId:l||void 0,cartId:o||void 0,chainId:p,storeId:u}),d=c,s=a}}),window.addEventListener(k.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectionRemovedEvent]",t.detail);const{newNonprofitId:n,selectionId:a}=t.detail,c=E(N,e),o=h(g,e),{chainId:l,storeId:p}=e;s===n&&d===a||(await y({selectedNonprofitId:n,beamCartId:o||void 0,selectionId:a,cartId:c||void 0,chainId:l,storeId:p}),d=a,s=n)}),window.addEventListener(P.eventName,r=>{const t=r;I.debug("[cart-page][BeamCartCreatedEvent]",t.detail),B(e)}),window.addEventListener(x.eventName,async r=>{const t=r;I.debug("[cart-page][BeamCartChangeEvent]",t.detail),B(e)});const m=await L(e);return await v(e,m.cart,!0),A=!0,!0}async function B(e){let s,d;try{if(window.statsig){const m=window.statsig;s=m.getLayer("beam_trial_layer").get("show_beam",!1),d=m.getStableID();const r=E(N,e),t=h(g,e),{chainId:n,storeId:a}=e;y({showBeam:s,remoteSessionId:d,beamCartId:t||void 0,cartId:r||void 0,chainId:n,storeId:a})}}catch(m){I.error(m)}}async function L(e){const{token:s,total_price:d,item_count:m,currency:r,items:t,cart_level_discount_applications:n}=await T();let a=!1;const c=J(e).getItemJson("cart"),o=h(g,e),l={cartId:s,beamCartId:o,subtotal:d/100,itemCount:m,currencyCode:r,schema:{source:"generic"},content:{items:t.map(({sku:p,final_line_price:u,product_id:b,line_level_discount_allocations:C})=>{const f=p||String(b),w=u/100,i=C?.map(({discount_application:_})=>({code:_?.title,applicable:!0}));return{remoteProductIdentifier:f,localAmount:w,discounts:i}}),discounts:n.map(({title:p})=>({code:p,applicable:!0}))}};return O(l,{...c,beamCartId:c?.beamCartId})||(a=!0),{changed:a,cart:l}}const H=v,T=async function(){return await window.fetch(S+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json())},y=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t,showBeam:n,remoteSessionId:a}){const{attributes:c}=await T(),o=c?.beam;let l={};try{o&&(l=JSON.parse(o))}catch(u){I.error(u)}const p={beam:JSON.stringify({...l,nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};if(!O(p.beam,l))try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:p})})}catch(u){I.error(u)}}),V=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t}){let n,a;try{if(window.statsig){const o=window.statsig;n=o.getLayer("beam_trial_layer").get("show_beam",!1),a=o.getStableID()}}catch(o){I.error(o)}const c={beam:JSON.stringify({nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:c})})}catch(o){I.error(o)}});async function $({parentSelector:e=".step__sections",apiKey:s,baseUrl:d=G,storeId:m,postalCode:r,countryCode:t,orderId:n,email:a,cartTotal:c,cart:o,discountCodes:l,currencyCode:p="USD",domain:u,lang:b="en",debug:C=!1}){const f=document.querySelector(e)||await M(e);if(!f)throw new W(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const w=await q("cart");if(w){const _=J({apiKey:s}),U=_.getItemJson("cart")||{};_.setItemJson("cart",{...U,cartId:w})}const i=document.createElement("beam-post-purchase");i.apiKey=s,i.baseUrl=d,i.storeId=m,i.postalCode=r,i.countryCode=t,i.orderId=String(n),i.email=a,i.cartTotal=c,i.cart=o,i.discountCodes=l,i.currencyCode=p,i.domain=u,i.lang=b,i.debug=C,f.appendChild(i)}export{z as F,H as G,V as H,B as S,L as _,y as g,$ as s,T as v};
|
|
2
|
-
//# sourceMappingURL=order-page-Z3WcYluU.esm.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as O}from"./lodash-P8OIs-at.esm.js";import{c as D,b as R,g as k,f as P,d as x}from"./events-6Z5MkCRr.esm.js";import{logger as I}from"../utils/logger.esm.js";import{initNetworkListeners as K}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as J}from"../utils/local-storage.esm.js";import{memoizeLast as j}from"../utils/memoize-last.esm.js";import{B as g}from"./cart-contents-h60geKWa.esm.js";import{J as v}from"./update-cart-FwtFnnGe.esm.js";import{W as F,D as G}from"./routes-Dmf2ZNnZ.esm.js";import{getExternalCartId as E,getBeamCartId as h}from"../utils/cart.esm.js";import"../components/post-purchase.esm.js";import{waitForElement as M}from"../utils/wait-for-element.esm.js";import{B as W}from"./beam-errors-P-Lu07Ce.esm.js";import{getCookieValue as q}from"../utils/cookies.esm.js";const S=window.Shopify?.routes?.root||"/";let A=!1;const N="cart";async function z(e){if(A)return!1;K(),window.addEventListener(D.eventName,async r=>{const t=r,n=/cart\/(add|change|update|clear)/,a=t.detail.type==="xhr"?t.detail.xhr.responseURL:t.detail.response.url,c=new URL(a);if(!n.test(c.pathname))return;const o=await L(e);o.changed&&v(e,o.cart)});let s,d;window.addEventListener(R.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectEvent]",t.detail);const{source:n,selectedNonprofitId:a,selectionId:c}=t.detail;if(n===F.select_nonprofit){const o=E(N,e),l=h(g,e),{chainId:p,storeId:u}=e;if(s===a&&d===c)return;await y({selectedNonprofitId:a,selectionId:c,beamCartId:l||void 0,cartId:o||void 0,chainId:p,storeId:u}),d=c,s=a}}),window.addEventListener(k.eventName,async r=>{const t=r;I.debug("[cart-page][BeamNonprofitSelectionRemovedEvent]",t.detail);const{newNonprofitId:n,selectionId:a}=t.detail,c=E(N,e),o=h(g,e),{chainId:l,storeId:p}=e;s===n&&d===a||(await y({selectedNonprofitId:n,beamCartId:o||void 0,selectionId:a,cartId:c||void 0,chainId:l,storeId:p}),d=a,s=n)}),window.addEventListener(P.eventName,r=>{const t=r;I.debug("[cart-page][BeamCartCreatedEvent]",t.detail),B(e)}),window.addEventListener(x.eventName,async r=>{const t=r;I.debug("[cart-page][BeamCartChangeEvent]",t.detail),B(e)});const m=await L(e);return await v(e,m.cart,!0),A=!0,!0}async function B(e){let s,d;try{if(window.statsig){const m=window.statsig;s=m.getLayer("beam_trial_layer").get("show_beam",!1),d=m.getStableID();const r=E(N,e),t=h(g,e),{chainId:n,storeId:a}=e;y({showBeam:s,remoteSessionId:d,beamCartId:t||void 0,cartId:r||void 0,chainId:n,storeId:a})}}catch(m){I.error(m)}}async function L(e){const{token:s,total_price:d,item_count:m,currency:r,items:t,cart_level_discount_applications:n}=await T();let a=!1;const c=J(e).getItemJson("cart"),o=h(g,e),l={cartId:s,beamCartId:o,subtotal:d/100,itemCount:m,currencyCode:r,schema:{source:"generic"},content:{items:t.map(({sku:p,final_line_price:u,product_id:b,line_level_discount_allocations:C})=>{const f=p||String(b),w=u/100,i=C?.map(({discount_application:_})=>({code:_?.title,applicable:!0}));return{remoteProductIdentifier:f,localAmount:w,discounts:i}}),discounts:n.map(({title:p})=>({code:p,applicable:!0}))}};return O(l,{...c,beamCartId:c?.beamCartId})||(a=!0),{changed:a,cart:l}}const H=v,T=async function(){return await window.fetch(S+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json())},y=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t,showBeam:n,remoteSessionId:a}){const{attributes:c}=await T(),o=c?.beam;let l={};try{o&&(l=JSON.parse(o))}catch(u){I.error(u)}const p={beam:JSON.stringify({...l,nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};if(!O(p.beam,l))try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:p})})}catch(u){I.error(u)}}),V=j(async function({selectedNonprofitId:e,selectionId:s,beamCartId:d,cartId:m,chainId:r,storeId:t}){let n,a;try{if(window.statsig){const o=window.statsig;n=o.getLayer("beam_trial_layer").get("show_beam",!1),a=o.getStableID()}}catch(o){I.error(o)}const c={beam:JSON.stringify({nonprofit_id:e,selection_id:s,beam_cart_id:d,shopify_cart_id:m,chain_id:r,store_id:t,show_beam:n,remote_session_id:a})};try{await window.fetch(S+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:c})})}catch(o){I.error(o)}});async function $({parentSelector:e=".step__sections",apiKey:s,baseUrl:d=G,storeId:m,postalCode:r,countryCode:t,orderId:n,email:a,cartTotal:c,cart:o,discountCodes:l,currencyCode:p="USD",domain:u,lang:b="en",debug:C=!1}){const f=document.querySelector(e)||await M(e);if(!f)throw new W(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const w=await q("cart");if(w){const _=J({apiKey:s}),U=_.getItemJson("cart")||{};_.setItemJson("cart",{...U,cartId:w})}const i=document.createElement("beam-post-purchase");i.apiKey=s,i.baseUrl=d,i.storeId=m,i.postalCode=r,i.countryCode=t,i.orderId=String(n),i.email=a,i.cartTotal=c,i.cart=o,i.discountCodes=l,i.currencyCode=p,i.domain=u,i.lang=b,i.debug=C,f.appendChild(i)}export{z as F,H as G,V as H,B as S,L as _,y as g,$ as s,T as v};
|
|
2
|
-
//# sourceMappingURL=order-page-rrfJ4w9F.esm.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{B as v,N as m}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as p}from"../utils/logger.esm.js";var E="1.48.0",N={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.15.0",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function w(s,o){const c={method:"GET",...o,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":E,...o?.headers},preflightContinue:!0,mode:o?.mode||"cors",body:o?.body!=null?o.body:void 0};let i;try{i=await fetch(s,c)}catch(e){const a=new v(`Network call failed (${c?.method.toUpperCase()} ${s})`);throw a.cause=e,p.error(a,s),a}let r,n;try{n=await i.text(),n&&(r=JSON.parse(n))}catch(e){let a=e;throw e instanceof SyntaxError&&(a=new m(i,r,`Response invalid. Expected JSON. Received: "${n}"`),a.cause=e),p.error(a),a}if(!i.ok){const e=new m(i,r,"Response was not OK");throw p.error(e),e}return r}const u="https://api.beamimpact.com",C="https://production.beamimpactlogs.com",O={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},T={select_nonprofit:"select-nonprofit",redeem_transaction:"redeem-transaction",impact_overview:"impact-overview",community_impact:"community-impact",cumulative_impact:"cumulative-impact",product_details_page:"product-details-page",subscription_management:"subscription-management",subscription_impact:"subscription-impact",select_subscription_nonprofit:"select-subscription-nonprofit",social_share:"social-share"},t=(s,o,c)=>({[s]:async function({headers:i={},baseUrl:r=u,apiRoot:n="/api/v3",pathParams:e={},queryParams:a={},requestBody:d}){const h=Object.entries(e).reduce((S,[y,_])=>S.replace(`{${y}}`,_),s),f=JSON.parse(JSON.stringify(a)),l=new URLSearchParams(f).toString(),b=r+n+h+(l&&`?${l}`),g={headers:i,method:o,body:JSON.stringify(d)};return w(b,g)}})[s],U=t("/impact","get"),A=t("/chain/{chainId}/cumulativeImpact","get"),D=t("/selectNonprofit","post"),L=t("/transaction","post"),P=t("/transaction/{transactionId}","put"),R=t("/cart","post"),k=t("/chain/findEligibleNonprofitsForCart","post"),x=t("/logs","post"),B=t("/experimentSession","post"),I=t("/subscriptions/updateSubscriptionNonprofit","post"),J=t("/subscriptions/findOrCreateSubscription","post"),F=t("/productDetailsPage","get");export{u as D,O as S,T as W,C as a,R as b,x as c,N as d,B as e,k as f,U as g,J as h,D as i,P as j,A as k,F as l,L as p,I as u};
|
|
2
|
-
//# sourceMappingURL=routes-Dmf2ZNnZ.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes-Dmf2ZNnZ.esm.js","sources":["../../src/api-sdk/fetch-json.ts","../../src/api-sdk/constants.ts","../../src/api-sdk/v3/make-openapi-method.ts","../../src/api-sdk/v3/routes.ts"],"sourcesContent":["/**\n * Wrapper over window.fetch that expects/returns JSON\n */\nimport { BeamError, NetworkError } from \"../utils/beam-errors\";\nimport { logger } from \"../utils/logger\";\nimport { version as pkgVersion } from \"../../package.json\";\n\nexport async function fetchJson<T = unknown>(url: RequestInfo, options?: RequestInit): Promise<T> {\n const fetchOptions = {\n method: \"GET\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n \"X-Beam-Client\": \"WebSDK\",\n \"X-Beam-Client-Version\": pkgVersion,\n ...options?.headers,\n },\n preflightContinue: true,\n mode: options?.mode || \"cors\",\n body: options?.body != null ? options.body : undefined,\n };\n\n let response;\n try {\n response = await fetch(url, fetchOptions);\n // fetch can throw a TypeError if the server can't be reached, catch and log below\n } catch (err) {\n const error = new BeamError(`Network call failed (${fetchOptions?.method.toUpperCase()} ${url})`);\n error.cause = err;\n logger.error(error, url);\n throw error;\n }\n let body;\n let text;\n // This can throw a SyntaxError if response payload is malformed JSON\n try {\n text = await response.text();\n if (text) {\n // (response can be empty)\n body = JSON.parse(text);\n }\n } catch (err) {\n let error = err as Error;\n if (err instanceof SyntaxError) {\n error = new NetworkError(response, body, `Response invalid. Expected JSON. Received: \"${text}\"`);\n error.cause = err;\n }\n logger.error(error);\n throw error;\n }\n // Translate 4xx, 5xx status to runtime error\n if (!response.ok) {\n const error = new NetworkError(response, body, \"Response was not OK\");\n logger.error(error);\n throw error;\n }\n\n return body;\n}\n","import { LANGUAGES, TUrl } from \"./types\";\n\nexport const DEFAULT_BASE_URL: TUrl = \"https://api.beamimpact.com\";\n\nexport const DEFAULT_LOG_URL = \"https://production.beamimpactlogs.com\";\n\nexport const SUPPORTED_LANGUAGES: Record<string, LANGUAGES> = {\n en: \"en\",\n fr: \"fr\",\n de: \"de\",\n es: \"es\",\n it: \"it\",\n pl: \"pl\",\n};\n\nexport const WIDGET_NAMES = {\n select_nonprofit: \"select-nonprofit\",\n redeem_transaction: \"redeem-transaction\",\n impact_overview: \"impact-overview\",\n community_impact: \"community-impact\",\n cumulative_impact: \"cumulative-impact\",\n product_details_page: \"product-details-page\",\n subscription_management: \"subscription-management\",\n subscription_impact: \"subscription-impact\",\n select_subscription_nonprofit: \"select-subscription-nonprofit\",\n social_share: \"social-share\",\n} as const;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { fetchJson } from \"../fetch-json\";\nimport { DEFAULT_BASE_URL } from \"../constants\";\nimport { THttpMethod } from \"../types\";\nimport { paths } from \"./openapi-spec\";\n\nexport const makeOpenApiMethod = <\n TPathName extends keyof paths,\n TMethod extends keyof paths[TPathName],\n TStatusCode extends paths[TPathName][TMethod] extends { responses: any }\n ? keyof paths[TPathName][TMethod][\"responses\"]\n : never\n>(\n pathName: TPathName,\n method: TMethod,\n okHttpStatus: TStatusCode\n) => {\n type TRouteSpec = paths[typeof pathName];\n type TRouteMethod = TRouteSpec[typeof method];\n type TParams = \"parameters\" extends keyof TRouteMethod ? TRouteMethod[\"parameters\"] : never;\n type TPathParams = TParams extends { path: any } ? TParams[\"path\"] : Record<string, never>;\n type TQueryParams = TParams extends { query: any } ? TParams[\"query\"] : Record<string, never>;\n type TRequestBody = TRouteMethod extends { requestBody: { content: { \"application/json\": any } } }\n ? TRouteMethod[\"requestBody\"][\"content\"][\"application/json\"]\n : never;\n type TAllResponses = TRouteMethod extends { responses: any } ? TRouteMethod[\"responses\"] : never;\n type TOkResponse = TAllResponses[typeof okHttpStatus] extends { content: { \"application/json\": any } }\n ? TAllResponses[typeof okHttpStatus][\"content\"][\"application/json\"]\n : never;\n const openApi = {\n [pathName]: async function ({\n headers = {},\n baseUrl = DEFAULT_BASE_URL,\n apiRoot = \"/api/v3\",\n pathParams = {},\n queryParams = {},\n requestBody,\n }: {\n baseUrl?: string;\n apiRoot?: string;\n pathParams?: TPathParams;\n queryParams?: TQueryParams;\n requestBody?: TRequestBody;\n headers?: Record<string, string>;\n }) {\n const pathWithParams: string = Object.entries(pathParams).reduce((newPath: string, [k, v]) => {\n return newPath.replace(`{${k}}`, v as string);\n }, pathName as string);\n const cleanQueryParams = JSON.parse(JSON.stringify(queryParams));\n const search = new URLSearchParams(cleanQueryParams as unknown as Record<string, string>).toString();\n const url = baseUrl + apiRoot + pathWithParams + (search && `?${search}`);\n const options = { headers, method: method as THttpMethod, body: JSON.stringify(requestBody) };\n\n return fetchJson<TOkResponse>(url, options);\n },\n };\n\n // Use object to create function with dynamic name, for better stacktraces\n return openApi[pathName];\n};\n","import { makeOpenApiMethod } from \"./make-openapi-method\";\n\nexport const getChainNonprofits = makeOpenApiMethod(\"/chain/{chainId}/nonprofits\", \"get\", 200);\n\nexport const getImpact = makeOpenApiMethod(\"/impact\", \"get\", 200);\n\nexport const getCumulativeImpact = makeOpenApiMethod(\"/chain/{chainId}/cumulativeImpact\", \"get\", 200);\n\nexport const postSelectNonprofit = makeOpenApiMethod(\"/selectNonprofit\", \"post\", 201);\n\nexport const postTransaction = makeOpenApiMethod(\"/transaction\", \"post\", 201);\n\nexport const putTransaction = makeOpenApiMethod(\"/transaction/{transactionId}\", \"put\", 204);\n\nexport const postCart = makeOpenApiMethod(\"/cart\", \"post\", 200);\n\nexport const postChainEligibleNonprofitsForCart = makeOpenApiMethod(\n \"/chain/findEligibleNonprofitsForCart\",\n \"post\",\n 200\n);\n\nexport const postLogs = makeOpenApiMethod(\"/logs\", \"post\", 200);\n\nexport const postExperimentSession = makeOpenApiMethod(\"/experimentSession\", \"post\", 200);\n\nexport const updateSubscription = makeOpenApiMethod(\"/subscriptions/updateSubscriptionNonprofit\", \"post\", 200);\n\nexport const postFindOrCreateSubscription = makeOpenApiMethod(\"/subscriptions/findOrCreateSubscription\", \"post\", 200);\n\nexport const getProductDetailsPage = makeOpenApiMethod(\"/productDetailsPage\", \"get\", 200);\n"],"names":["fetchJson","url","options","fetchOptions","pkgVersion","response","err","error","BeamError","logger","body","text","NetworkError","DEFAULT_BASE_URL","DEFAULT_LOG_URL","SUPPORTED_LANGUAGES","WIDGET_NAMES","makeOpenApiMethod","pathName","method","okHttpStatus","headers","baseUrl","apiRoot","pathParams","queryParams","requestBody","pathWithParams","newPath","k","v","cleanQueryParams","search","getImpact","getCumulativeImpact","postSelectNonprofit","postTransaction","putTransaction","postCart","postChainEligibleNonprofitsForCart","postLogs","postExperimentSession","updateSubscription","postFindOrCreateSubscription","getProductDetailsPage"],"mappings":"wQAOA,eAAsBA,EAAuBC,EAAkBC,EAAmC,CAChG,MAAMC,EAAe,CACnB,OAAQ,MACR,GAAGD,EACH,QAAS,CACP,eAAgB,mBAChB,OAAQ,mBACR,gBAAiB,SACjB,wBAAyBE,EACzB,GAAGF,GAAS,OACd,EACA,kBAAmB,GACnB,KAAMA,GAAS,MAAQ,OACvB,KAAMA,GAAS,MAAQ,KAAOA,EAAQ,KAAO,MAC/C,EAEA,IAAIG,EACJ,GAAI,CACFA,EAAW,MAAM,MAAMJ,EAAKE,CAAY,CAE1C,OAASG,EAAK,CACZ,MAAMC,EAAQ,IAAIC,EAAU,wBAAwBL,GAAc,OAAO,YAAa,CAAA,IAAIF,CAAG,GAAG,EAChG,MAAAM,EAAM,MAAQD,EACdG,EAAO,MAAMF,EAAON,CAAG,EACjBM,CACR,CACA,IAAIG,EACAC,EAEJ,GAAI,CACFA,EAAO,MAAMN,EAAS,OAClBM,IAEFD,EAAO,KAAK,MAAMC,CAAI,EAE1B,OAASL,EAAK,CACZ,IAAIC,EAAQD,EACZ,MAAIA,aAAe,cACjBC,EAAQ,IAAIK,EAAaP,EAAUK,EAAM,+CAA+CC,CAAI,GAAG,EAC/FJ,EAAM,MAAQD,GAEhBG,EAAO,MAAMF,CAAK,EACZA,CACR,CAEA,GAAI,CAACF,EAAS,GAAI,CAChB,MAAME,EAAQ,IAAIK,EAAaP,EAAUK,EAAM,qBAAqB,EACpE,MAAAD,EAAO,MAAMF,CAAK,EACZA,CACR,CAEA,OAAOG,CACT,CCzDO,MAAMG,EAAyB,6BAEzBC,EAAkB,wCAElBC,EAAiD,CAC5D,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,IACN,EAEaC,EAAe,CAC1B,iBAAkB,mBAClB,mBAAoB,qBACpB,gBAAiB,kBACjB,iBAAkB,mBAClB,kBAAmB,oBACnB,qBAAsB,uBACtB,wBAAyB,0BACzB,oBAAqB,sBACrB,8BAA+B,gCAC/B,aAAc,cAChB,ECnBaC,EAAoB,CAO/BC,EACAC,EACAC,KAcgB,CACd,CAACF,CAAQ,EAAG,eAAgB,CAC1B,QAAAG,EAAU,CAAA,EACV,QAAAC,EAAUT,EACV,QAAAU,EAAU,UACV,WAAAC,EAAa,CACb,EAAA,YAAAC,EAAc,CAAA,EACd,YAAAC,CACF,EAOG,CACD,MAAMC,EAAyB,OAAO,QAAQH,CAAU,EAAE,OAAO,CAACI,EAAiB,CAACC,EAAGC,CAAC,IAC/EF,EAAQ,QAAQ,IAAIC,CAAC,IAAKC,CAAW,EAC3CZ,CAAkB,EACfa,EAAmB,KAAK,MAAM,KAAK,UAAUN,CAAW,CAAC,EACzDO,EAAS,IAAI,gBAAgBD,CAAqD,EAAE,SACpF9B,EAAAA,EAAMqB,EAAUC,EAAUI,GAAkBK,GAAU,IAAIA,CAAM,IAChE9B,EAAU,CAAE,QAAAmB,EAAS,OAAQF,EAAuB,KAAM,KAAK,UAAUO,CAAW,CAAE,EAE5F,OAAO1B,EAAuBC,EAAKC,CAAO,CAC5C,CACF,GAGegB,CAAQ,ECvDZe,EAAYhB,EAAkB,UAAW,KAAU,EAEnDiB,EAAsBjB,EAAkB,oCAAqC,KAAU,EAEvFkB,EAAsBlB,EAAkB,mBAAoB,MAAW,EAEvEmB,EAAkBnB,EAAkB,eAAgB,MAAW,EAE/DoB,EAAiBpB,EAAkB,+BAAgC,KAAU,EAE7EqB,EAAWrB,EAAkB,QAAS,MAAW,EAEjDsB,EAAqCtB,EAChD,uCACA,MAEF,EAEauB,EAAWvB,EAAkB,QAAS,MAAW,EAEjDwB,EAAwBxB,EAAkB,qBAAsB,MAAW,EAE3EyB,EAAqBzB,EAAkB,6CAA8C,MAAW,EAEhG0B,EAA+B1B,EAAkB,0CAA2C,MAAW,EAEvG2B,EAAwB3B,EAAkB,sBAAuB,KAAU"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{B as v,N as m}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as p}from"../utils/logger.js";var E="1.48.0",N={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.15.0",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function w(s,o){const c={method:"GET",...o,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":E,...o?.headers},preflightContinue:!0,mode:o?.mode||"cors",body:o?.body!=null?o.body:void 0};let i;try{i=await fetch(s,c)}catch(e){const a=new v(`Network call failed (${c?.method.toUpperCase()} ${s})`);throw a.cause=e,p.error(a,s),a}let r,n;try{n=await i.text(),n&&(r=JSON.parse(n))}catch(e){let a=e;throw e instanceof SyntaxError&&(a=new m(i,r,`Response invalid. Expected JSON. Received: "${n}"`),a.cause=e),p.error(a),a}if(!i.ok){const e=new m(i,r,"Response was not OK");throw p.error(e),e}return r}const u="https://api.beamimpact.com",C="https://production.beamimpactlogs.com",O={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},T={select_nonprofit:"select-nonprofit",redeem_transaction:"redeem-transaction",impact_overview:"impact-overview",community_impact:"community-impact",cumulative_impact:"cumulative-impact",product_details_page:"product-details-page",subscription_management:"subscription-management",subscription_impact:"subscription-impact",select_subscription_nonprofit:"select-subscription-nonprofit",social_share:"social-share"},t=(s,o,c)=>({[s]:async function({headers:i={},baseUrl:r=u,apiRoot:n="/api/v3",pathParams:e={},queryParams:a={},requestBody:d}){const h=Object.entries(e).reduce((S,[y,_])=>S.replace(`{${y}}`,_),s),f=JSON.parse(JSON.stringify(a)),l=new URLSearchParams(f).toString(),b=r+n+h+(l&&`?${l}`),g={headers:i,method:o,body:JSON.stringify(d)};return w(b,g)}})[s],U=t("/impact","get"),A=t("/chain/{chainId}/cumulativeImpact","get"),D=t("/selectNonprofit","post"),L=t("/transaction","post"),P=t("/transaction/{transactionId}","put"),R=t("/cart","post"),k=t("/chain/findEligibleNonprofitsForCart","post"),x=t("/logs","post"),B=t("/experimentSession","post"),I=t("/subscriptions/updateSubscriptionNonprofit","post"),J=t("/subscriptions/findOrCreateSubscription","post"),F=t("/productDetailsPage","get");export{u as D,O as S,T as W,C as a,R as b,x as c,N as d,B as e,k as f,U as g,J as h,D as i,P as j,A as k,F as l,L as p,I as u};
|
|
2
|
-
//# sourceMappingURL=routes-o1QpF40R.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes-o1QpF40R.esm.js","sources":["../../src/api-sdk/fetch-json.ts","../../src/api-sdk/constants.ts","../../src/api-sdk/v3/make-openapi-method.ts","../../src/api-sdk/v3/routes.ts"],"sourcesContent":["/**\n * Wrapper over window.fetch that expects/returns JSON\n */\nimport { BeamError, NetworkError } from \"../utils/beam-errors\";\nimport { logger } from \"../utils/logger\";\nimport { version as pkgVersion } from \"../../package.json\";\n\nexport async function fetchJson<T = unknown>(url: RequestInfo, options?: RequestInit): Promise<T> {\n const fetchOptions = {\n method: \"GET\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n \"X-Beam-Client\": \"WebSDK\",\n \"X-Beam-Client-Version\": pkgVersion,\n ...options?.headers,\n },\n preflightContinue: true,\n mode: options?.mode || \"cors\",\n body: options?.body != null ? options.body : undefined,\n };\n\n let response;\n try {\n response = await fetch(url, fetchOptions);\n // fetch can throw a TypeError if the server can't be reached, catch and log below\n } catch (err) {\n const error = new BeamError(`Network call failed (${fetchOptions?.method.toUpperCase()} ${url})`);\n error.cause = err;\n logger.error(error, url);\n throw error;\n }\n let body;\n let text;\n // This can throw a SyntaxError if response payload is malformed JSON\n try {\n text = await response.text();\n if (text) {\n // (response can be empty)\n body = JSON.parse(text);\n }\n } catch (err) {\n let error = err as Error;\n if (err instanceof SyntaxError) {\n error = new NetworkError(response, body, `Response invalid. Expected JSON. Received: \"${text}\"`);\n error.cause = err;\n }\n logger.error(error);\n throw error;\n }\n // Translate 4xx, 5xx status to runtime error\n if (!response.ok) {\n const error = new NetworkError(response, body, \"Response was not OK\");\n logger.error(error);\n throw error;\n }\n\n return body;\n}\n","import { LANGUAGES, TUrl } from \"./types\";\n\nexport const DEFAULT_BASE_URL: TUrl = \"https://api.beamimpact.com\";\n\nexport const DEFAULT_LOG_URL = \"https://production.beamimpactlogs.com\";\n\nexport const SUPPORTED_LANGUAGES: Record<string, LANGUAGES> = {\n en: \"en\",\n fr: \"fr\",\n de: \"de\",\n es: \"es\",\n it: \"it\",\n pl: \"pl\",\n};\n\nexport const WIDGET_NAMES = {\n select_nonprofit: \"select-nonprofit\",\n redeem_transaction: \"redeem-transaction\",\n impact_overview: \"impact-overview\",\n community_impact: \"community-impact\",\n cumulative_impact: \"cumulative-impact\",\n product_details_page: \"product-details-page\",\n subscription_management: \"subscription-management\",\n subscription_impact: \"subscription-impact\",\n select_subscription_nonprofit: \"select-subscription-nonprofit\",\n social_share: \"social-share\",\n} as const;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { fetchJson } from \"../fetch-json\";\nimport { DEFAULT_BASE_URL } from \"../constants\";\nimport { THttpMethod } from \"../types\";\nimport { paths } from \"./openapi-spec\";\n\nexport const makeOpenApiMethod = <\n TPathName extends keyof paths,\n TMethod extends keyof paths[TPathName],\n TStatusCode extends paths[TPathName][TMethod] extends { responses: any }\n ? keyof paths[TPathName][TMethod][\"responses\"]\n : never\n>(\n pathName: TPathName,\n method: TMethod,\n okHttpStatus: TStatusCode\n) => {\n type TRouteSpec = paths[typeof pathName];\n type TRouteMethod = TRouteSpec[typeof method];\n type TParams = \"parameters\" extends keyof TRouteMethod ? TRouteMethod[\"parameters\"] : never;\n type TPathParams = TParams extends { path: any } ? TParams[\"path\"] : Record<string, never>;\n type TQueryParams = TParams extends { query: any } ? TParams[\"query\"] : Record<string, never>;\n type TRequestBody = TRouteMethod extends { requestBody: { content: { \"application/json\": any } } }\n ? TRouteMethod[\"requestBody\"][\"content\"][\"application/json\"]\n : never;\n type TAllResponses = TRouteMethod extends { responses: any } ? TRouteMethod[\"responses\"] : never;\n type TOkResponse = TAllResponses[typeof okHttpStatus] extends { content: { \"application/json\": any } }\n ? TAllResponses[typeof okHttpStatus][\"content\"][\"application/json\"]\n : never;\n const openApi = {\n [pathName]: async function ({\n headers = {},\n baseUrl = DEFAULT_BASE_URL,\n apiRoot = \"/api/v3\",\n pathParams = {},\n queryParams = {},\n requestBody,\n }: {\n baseUrl?: string;\n apiRoot?: string;\n pathParams?: TPathParams;\n queryParams?: TQueryParams;\n requestBody?: TRequestBody;\n headers?: Record<string, string>;\n }) {\n const pathWithParams: string = Object.entries(pathParams).reduce((newPath: string, [k, v]) => {\n return newPath.replace(`{${k}}`, v as string);\n }, pathName as string);\n const cleanQueryParams = JSON.parse(JSON.stringify(queryParams));\n const search = new URLSearchParams(cleanQueryParams as unknown as Record<string, string>).toString();\n const url = baseUrl + apiRoot + pathWithParams + (search && `?${search}`);\n const options = { headers, method: method as THttpMethod, body: JSON.stringify(requestBody) };\n\n return fetchJson<TOkResponse>(url, options);\n },\n };\n\n // Use object to create function with dynamic name, for better stacktraces\n return openApi[pathName];\n};\n","import { makeOpenApiMethod } from \"./make-openapi-method\";\n\nexport const getChainNonprofits = makeOpenApiMethod(\"/chain/{chainId}/nonprofits\", \"get\", 200);\n\nexport const getImpact = makeOpenApiMethod(\"/impact\", \"get\", 200);\n\nexport const getCumulativeImpact = makeOpenApiMethod(\"/chain/{chainId}/cumulativeImpact\", \"get\", 200);\n\nexport const postSelectNonprofit = makeOpenApiMethod(\"/selectNonprofit\", \"post\", 201);\n\nexport const postTransaction = makeOpenApiMethod(\"/transaction\", \"post\", 201);\n\nexport const putTransaction = makeOpenApiMethod(\"/transaction/{transactionId}\", \"put\", 204);\n\nexport const postCart = makeOpenApiMethod(\"/cart\", \"post\", 200);\n\nexport const postChainEligibleNonprofitsForCart = makeOpenApiMethod(\n \"/chain/findEligibleNonprofitsForCart\",\n \"post\",\n 200\n);\n\nexport const postLogs = makeOpenApiMethod(\"/logs\", \"post\", 200);\n\nexport const postExperimentSession = makeOpenApiMethod(\"/experimentSession\", \"post\", 200);\n\nexport const updateSubscription = makeOpenApiMethod(\"/subscriptions/updateSubscriptionNonprofit\", \"post\", 200);\n\nexport const postFindOrCreateSubscription = makeOpenApiMethod(\"/subscriptions/findOrCreateSubscription\", \"post\", 200);\n\nexport const getProductDetailsPage = makeOpenApiMethod(\"/productDetailsPage\", \"get\", 200);\n"],"names":["fetchJson","url","options","fetchOptions","pkgVersion","response","err","error","BeamError","logger","body","text","NetworkError","DEFAULT_BASE_URL","DEFAULT_LOG_URL","SUPPORTED_LANGUAGES","WIDGET_NAMES","makeOpenApiMethod","pathName","method","okHttpStatus","headers","baseUrl","apiRoot","pathParams","queryParams","requestBody","pathWithParams","newPath","k","v","cleanQueryParams","search","getImpact","getCumulativeImpact","postSelectNonprofit","postTransaction","putTransaction","postCart","postChainEligibleNonprofitsForCart","postLogs","postExperimentSession","updateSubscription","postFindOrCreateSubscription","getProductDetailsPage"],"mappings":"oQAOA,eAAsBA,EAAuBC,EAAkBC,EAAmC,CAChG,MAAMC,EAAe,CACnB,OAAQ,MACR,GAAGD,EACH,QAAS,CACP,eAAgB,mBAChB,OAAQ,mBACR,gBAAiB,SACjB,wBAAyBE,EACzB,GAAGF,GAAS,OACd,EACA,kBAAmB,GACnB,KAAMA,GAAS,MAAQ,OACvB,KAAMA,GAAS,MAAQ,KAAOA,EAAQ,KAAO,MAC/C,EAEA,IAAIG,EACJ,GAAI,CACFA,EAAW,MAAM,MAAMJ,EAAKE,CAAY,CAE1C,OAASG,EAAK,CACZ,MAAMC,EAAQ,IAAIC,EAAU,wBAAwBL,GAAc,OAAO,YAAa,CAAA,IAAIF,CAAG,GAAG,EAChG,MAAAM,EAAM,MAAQD,EACdG,EAAO,MAAMF,EAAON,CAAG,EACjBM,CACR,CACA,IAAIG,EACAC,EAEJ,GAAI,CACFA,EAAO,MAAMN,EAAS,OAClBM,IAEFD,EAAO,KAAK,MAAMC,CAAI,EAE1B,OAASL,EAAK,CACZ,IAAIC,EAAQD,EACZ,MAAIA,aAAe,cACjBC,EAAQ,IAAIK,EAAaP,EAAUK,EAAM,+CAA+CC,CAAI,GAAG,EAC/FJ,EAAM,MAAQD,GAEhBG,EAAO,MAAMF,CAAK,EACZA,CACR,CAEA,GAAI,CAACF,EAAS,GAAI,CAChB,MAAME,EAAQ,IAAIK,EAAaP,EAAUK,EAAM,qBAAqB,EACpE,MAAAD,EAAO,MAAMF,CAAK,EACZA,CACR,CAEA,OAAOG,CACT,CCzDO,MAAMG,EAAyB,6BAEzBC,EAAkB,wCAElBC,EAAiD,CAC5D,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,IACN,EAEaC,EAAe,CAC1B,iBAAkB,mBAClB,mBAAoB,qBACpB,gBAAiB,kBACjB,iBAAkB,mBAClB,kBAAmB,oBACnB,qBAAsB,uBACtB,wBAAyB,0BACzB,oBAAqB,sBACrB,8BAA+B,gCAC/B,aAAc,cAChB,ECnBaC,EAAoB,CAO/BC,EACAC,EACAC,KAcgB,CACd,CAACF,CAAQ,EAAG,eAAgB,CAC1B,QAAAG,EAAU,CAAA,EACV,QAAAC,EAAUT,EACV,QAAAU,EAAU,UACV,WAAAC,EAAa,CACb,EAAA,YAAAC,EAAc,CAAA,EACd,YAAAC,CACF,EAOG,CACD,MAAMC,EAAyB,OAAO,QAAQH,CAAU,EAAE,OAAO,CAACI,EAAiB,CAACC,EAAGC,CAAC,IAC/EF,EAAQ,QAAQ,IAAIC,CAAC,IAAKC,CAAW,EAC3CZ,CAAkB,EACfa,EAAmB,KAAK,MAAM,KAAK,UAAUN,CAAW,CAAC,EACzDO,EAAS,IAAI,gBAAgBD,CAAqD,EAAE,SACpF9B,EAAAA,EAAMqB,EAAUC,EAAUI,GAAkBK,GAAU,IAAIA,CAAM,IAChE9B,EAAU,CAAE,QAAAmB,EAAS,OAAQF,EAAuB,KAAM,KAAK,UAAUO,CAAW,CAAE,EAE5F,OAAO1B,EAAuBC,EAAKC,CAAO,CAC5C,CACF,GAGegB,CAAQ,ECvDZe,EAAYhB,EAAkB,UAAW,KAAU,EAEnDiB,EAAsBjB,EAAkB,oCAAqC,KAAU,EAEvFkB,EAAsBlB,EAAkB,mBAAoB,MAAW,EAEvEmB,EAAkBnB,EAAkB,eAAgB,MAAW,EAE/DoB,EAAiBpB,EAAkB,+BAAgC,KAAU,EAE7EqB,EAAWrB,EAAkB,QAAS,MAAW,EAEjDsB,EAAqCtB,EAChD,uCACA,MAEF,EAEauB,EAAWvB,EAAkB,QAAS,MAAW,EAEjDwB,EAAwBxB,EAAkB,qBAAsB,MAAW,EAE3EyB,EAAqBzB,EAAkB,6CAA8C,MAAW,EAEhG0B,EAA+B1B,EAAkB,0CAA2C,MAAW,EAEvG2B,EAAwB3B,EAAkB,sBAAuB,KAAU"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d as B,i as g}from"./lodash-P8OIs-at.esm.js";import{D as A,b as v}from"./routes-o1QpF40R.esm.js";import{B as K}from"./beam-errors-P-Lu07Ce.esm.js";import{d as J,f as S}from"./events-6Z5MkCRr.esm.js";import{createScopedLocalStorage as _}from"../utils/local-storage.js";import{setCookieValue as L}from"../utils/cookies.js";import{getRemoteSession as U}from"../utils/remote-session.js";import{memoizeLast as x}from"../utils/memoize-last.js";import{B as f}from"./cart-contents-h60geKWa.esm.js";import{getBeamCartId as D}from"../utils/cart.js";const R=50,T=B(x(async function(t,m,l=!1){try{const e=_({apiKey:t.apiKey}),E=t.baseUrl??A,o=e.getItemJson("cart"),a=D(f,t),h=U(t)??void 0,{cartId:n,subtotal:i,itemCount:c,currencyCode:d,content:{items:u=[],discounts:C=[]}={},schema:p={source:"generic"}}=m,r={cartId:n,subtotal:i,itemCount:c,currencyCode:d,content:{items:u,discounts:C},schema:p,beamCartId:a};if(l&&!o&&m?.itemCount){e.setItemJson("cart",{...r,beamCartId:a});return}if(g(r,{...o,cartId:o?.cartId})||m.itemCount===0&&(!a||o?.itemCount===0)){e.setItemJson("cart",{...r,beamCartId:a});return}const w=await v({baseUrl:E,headers:{authorization:`Api-Key ${t.apiKey}`},requestBody:{beamCartId:a,storeId:t.storeId,remoteSessionId:h,cartId:n,subtotal:i,itemCount:c,currencyCode:d}}),{beamCartId:s,expiresAt:I,beamCartCreated:y}=w;s&&I&&await L({name:f,domain:t.domain,value:s,path:"/",expires:new Date(I).getTime()}),e.setItemJson("cart",{...r,beamCartId:s});const b={schema:p,content:{items:u,discounts:C},subtotal:i,itemCount:c,currencyCode:d,cartId:n,beamCartId:s};window.dispatchEvent(new J(b)),y&&window.dispatchEvent(new S(b))}catch(e){throw new K("Could not update cart in Beam",{cause:e})}}),R,{leading:!0});export{T as J};
|
|
2
|
-
//# sourceMappingURL=update-cart-EGTcbNRX.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-cart-EGTcbNRX.esm.js","sources":["../../src/integrations/cart/update-cart.ts"],"sourcesContent":["import isEqual from \"lodash-es/isEqual\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { BeamBaseAPIConfig } from \"../../api-sdk/types\";\nimport { postCart } from \"../../api-sdk/v3/routes\";\nimport { debounce, memoizeLast } from \"../../utils\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCartApi } from \"../../shared/cart-contents\";\nimport { setCookieValue } from \"../../utils/cookies\";\nimport { BeamCartChangeEvent, BeamCartCreatedEvent } from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { getRemoteSession } from \"../../utils/remote-session\";\nimport { getBeamCartId } from \"../../utils/cart\";\n\nexport type BeamCartAPIConfig = BeamBaseAPIConfig & {\n storeId: number;\n domain?: string; // Domain to set cookies on\n statsigExperiment?: string;\n};\n\nexport type BeamCartValues = {\n cartId?: string; // External (partner) cart ID\n itemCount?: number;\n subtotal?: number;\n currencyCode?: string;\n} & Partial<TCartApi>;\n\n/**\n * The debounce time in milliseconds for updating the cart - updateCart will delay until it hasn't been called for\n * this long before handling the last call.\n */\nconst UPDATE_CART_DEBOUNCE_MS = 50;\n\n/**\n * Sends cart information to Beam\n * Memoized based on previous arguments - if the objects are deep-equal, no update is made.\n * @side-effects Sets beam_cart cookie, set cart data in localstorage\n * @example\n * const BeamConfig = { apiKey: 'abc-123' }\n * const { beamCartId } = await updateCart(BeamConfig, { beamCartId, itemCount, subtotal, currencyCode })\n * */\nconst updateCart = debounce(\n memoizeLast(async function updateCart(\n config: BeamCartAPIConfig,\n cartValues: BeamCartValues,\n isFirstCartUpdateOnPageLoad = false\n ) {\n try {\n const localStorage = createScopedLocalStorage({ apiKey: config.apiKey });\n const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;\n\n // The cart cache is used to detect changes after page refreshes / across tabs\n const cachedCart: TBeamCartLocalStorage | null = localStorage.getItemJson(\"cart\");\n // The Beam cart cookie is used to identify the cart across subdomains\n // Use explicit null if empty because API requires it\n const beamCartId: string | null = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n // Remote session ID (ie, device ID from an A/B testing tool) will be linked to the cart\n const remoteSessionId: string | undefined = getRemoteSession(config) ?? undefined;\n\n const {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items = [], discounts = [] } = {},\n schema = { source: \"generic\" },\n } = cartValues;\n\n const cartWithDefaults = {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items, discounts },\n schema,\n beamCartId,\n };\n\n // If this is our first time calling \"updateCart\" on page load, and there is\n // no prior \"cachedCart\", and the current Platform cart is not empty,\n // we should assume that the cart has not been interacted with.\n // In this case, we want to cache the current cart, but not send it to Beam\n // so that the next time we call this method, it will compare to the existing\n // Platform cart\n if (isFirstCartUpdateOnPageLoad && !cachedCart && !!cartValues?.itemCount) {\n // logger.debug(\n // \"[update-cart] first attempt to update cart; no prior cart found, cart is not empty; skipping update to Beam\"\n // );\n localStorage.setItemJson(\"cart\", {\n ...cartWithDefaults,\n beamCartId: beamCartId,\n });\n\n return;\n }\n\n // Early return conditions. Skip sending cart to Beam if any apply:\n // 1. The cart has not changed\n // 2. Cart is empty, unless the cart was not empty before\n if (\n isEqual(cartWithDefaults, {\n ...cachedCart,\n cartId: cachedCart?.cartId /* make sure optional key is defined even if empty */,\n }) || // cart has not changed, OR\n (cartValues.itemCount === 0 && // nothing in current cart, AND\n (!beamCartId || cachedCart?.itemCount === 0)) // no/expired prev cart or prev cart was empty\n ) {\n // logger.debug(\"[update-cart] cart not changed\");\n // If the cart has not changed because the cart is empty now,\n // we still want to save that this changed happened in our cached cart\n // so the next update will compare against a current cart\n localStorage.setItemJson(\"cart\", {\n ...cartWithDefaults,\n beamCartId: beamCartId,\n });\n\n return;\n }\n\n // logger.debug(\"[update-cart] sending cart update request\");\n const response = await postCart({\n baseUrl,\n headers: {\n authorization: `Api-Key ${config.apiKey}`,\n },\n requestBody: {\n beamCartId, // backwards compat: explicitly sending null here is required to get initial beamCartId\n storeId: config.storeId,\n remoteSessionId,\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n },\n });\n\n // Response will contain a new beamCartId if one was not provided, or old one expired\n const { beamCartId: newBeamCartId, expiresAt, beamCartCreated } = response;\n\n if (newBeamCartId && expiresAt) {\n await setCookieValue({\n name: BEAM_CART_COOKIE_NAME,\n domain: config.domain,\n value: newBeamCartId,\n path: \"/\",\n // If we don't set an expiration, the cookie will be cleared when the tab is closed\n expires: new Date(expiresAt).getTime(),\n });\n }\n\n localStorage.setItemJson(\"cart\", {\n ...cartWithDefaults,\n beamCartId: newBeamCartId,\n });\n\n const eventDetail = {\n schema: schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: items as any,\n discounts: discounts as any,\n },\n subtotal,\n itemCount,\n currencyCode,\n cartId,\n beamCartId: newBeamCartId,\n };\n\n // emit change event on any create/update/delete of cart items\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n\n // emit created event only when the cart is new according to Beam\n if (beamCartCreated) {\n window.dispatchEvent(new BeamCartCreatedEvent(eventDetail));\n }\n } catch (err) {\n throw new BeamError(\"Could not update cart in Beam\", { cause: err });\n }\n }),\n UPDATE_CART_DEBOUNCE_MS,\n { leading: true } // handle first call immediately but delay for more calls within debounce window\n);\n\nexport { updateCart };\n"],"names":["UPDATE_CART_DEBOUNCE_MS","updateCart","debounce","memoizeLast","config","cartValues","isFirstCartUpdateOnPageLoad","localStorage","createScopedLocalStorage","baseUrl","DEFAULT_BASE_URL","cachedCart","beamCartId","getBeamCartId","BEAM_CART_COOKIE_NAME","remoteSessionId","getRemoteSession","cartId","subtotal","itemCount","currencyCode","items","discounts","schema","cartWithDefaults","isEqual","response","postCart","newBeamCartId","expiresAt","beamCartCreated","setCookieValue","eventDetail","BeamCartChangeEvent","BeamCartCreatedEvent","err","BeamError"],"mappings":"wiBA8BMA,EAA0B,GAU1BC,EAAaC,EACjBC,EAAY,eACVC,EACAC,EACAC,EAA8B,GAC9B,CACA,GAAI,CACF,MAAMC,EAAeC,EAAyB,CAAE,OAAQJ,EAAO,MAAO,CAAC,EACjEK,EAAUL,EAAO,SAAWM,EAG5BC,EAA2CJ,EAAa,YAAY,MAAM,EAG1EK,EAA4BC,EAAcC,EAAuBV,CAAM,EAEvEW,EAAsCC,EAAiBZ,CAAM,GAAK,OAElE,CACJ,OAAAa,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,EAAQ,CAAA,EAAI,UAAAC,EAAY,CAAG,CAAA,EAAI,CAAA,EAC1C,OAAAC,EAAS,CAAE,OAAQ,SAAU,CAC/B,EAAIlB,EAEEmB,EAAmB,CACvB,OAAAP,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,EAAO,UAAAC,CAAU,EAC5B,OAAAC,EACA,WAAAX,CACF,EAQA,GAAIN,GAA+B,CAACK,GAAgBN,GAAY,UAAW,CAIzEE,EAAa,YAAY,OAAQ,CAC/B,GAAGiB,EACH,WAAYZ,CACd,CAAC,EAED,MACF,CAKA,GACEa,EAAQD,EAAkB,CACxB,GAAGb,EACH,OAAQA,GAAY,MACtB,CAAC,GACAN,EAAW,YAAc,IACvB,CAACO,GAAcD,GAAY,YAAc,GAC5C,CAKAJ,EAAa,YAAY,OAAQ,CAC/B,GAAGiB,EACH,WAAYZ,CACd,CAAC,EAED,MACF,CAGA,MAAMc,EAAW,MAAMC,EAAS,CAC9B,QAAAlB,EACA,QAAS,CACP,cAAe,WAAWL,EAAO,MAAM,EACzC,EACA,YAAa,CACX,WAAAQ,EACA,QAASR,EAAO,QAChB,gBAAAW,EACA,OAAAE,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,CACF,CACF,CAAC,EAGK,CAAE,WAAYQ,EAAe,UAAAC,EAAW,gBAAAC,CAAgB,EAAIJ,EAE9DE,GAAiBC,GACnB,MAAME,EAAe,CACnB,KAAMjB,EACN,OAAQV,EAAO,OACf,MAAOwB,EACP,KAAM,IAEN,QAAS,IAAI,KAAKC,CAAS,EAAE,SAC/B,CAAC,EAGHtB,EAAa,YAAY,OAAQ,CAC/B,GAAGiB,EACH,WAAYI,CACd,CAAC,EAED,MAAMI,EAAc,CAClB,OAAQT,EACR,QAAS,CACP,MAAOF,EACP,UAAWC,CACb,EACA,SAAAJ,EACA,UAAAC,EACA,aAAAC,EACA,OAAAH,EACA,WAAYW,CACd,EAGA,OAAO,cAAc,IAAIK,EAAoBD,CAAW,CAAC,EAGrDF,GACF,OAAO,cAAc,IAAII,EAAqBF,CAAW,CAAC,CAE9D,OAASG,EAAK,CACZ,MAAM,IAAIC,EAAU,gCAAiC,CAAE,MAAOD,CAAI,CAAC,CACrE,CACF,CAAC,EACDnC,EACA,CAAE,QAAS,EAAK,CAClB"}
|