@beamimpact/web-sdk 1.31.2 → 1.31.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/chunks/{_share-dialog-dependencies-lvdVUIId.esm.js → _share-dialog-dependencies-UT3NgapK.esm.js} +2 -2
  2. package/dist/chunks/_share-dialog-dependencies-UT3NgapK.esm.js.map +1 -0
  3. package/dist/chunks/{_share-dialog-dependencies-OkmQDHff.esm.js → _share-dialog-dependencies-yxOcNNpK.esm.js} +2 -2
  4. package/dist/chunks/_share-dialog-dependencies-yxOcNNpK.esm.js.map +1 -0
  5. package/dist/chunks/cookies-H8TCP4v0.esm.js +2 -0
  6. package/dist/chunks/cookies-H8TCP4v0.esm.js.map +1 -0
  7. package/dist/chunks/{index-qMGAQ3oX.esm.js → index-4ckY2-Lc.esm.js} +2 -2
  8. package/dist/chunks/index-4ckY2-Lc.esm.js.map +1 -0
  9. package/dist/chunks/index-FZ0yrk2j.esm.js +2 -0
  10. package/dist/chunks/index-FZ0yrk2j.esm.js.map +1 -0
  11. package/dist/chunks/index-PXYriqGw.esm.js +2 -0
  12. package/dist/chunks/index-PXYriqGw.esm.js.map +1 -0
  13. package/dist/chunks/{index-jFZJm9-Y.esm.js → index-UODI8bvb.esm.js} +2 -2
  14. package/dist/chunks/{index-jFZJm9-Y.esm.js.map → index-UODI8bvb.esm.js.map} +1 -1
  15. package/dist/chunks/index-YKvnw1cF.esm.js +2 -0
  16. package/dist/chunks/index-YKvnw1cF.esm.js.map +1 -0
  17. package/dist/chunks/{index-KoM7lmw7.esm.js → index-f-fjpKtx.esm.js} +2 -2
  18. package/dist/chunks/{index-KoM7lmw7.esm.js.map → index-f-fjpKtx.esm.js.map} +1 -1
  19. package/dist/chunks/index-fXIUzndi.esm.js +2 -0
  20. package/dist/chunks/index-fXIUzndi.esm.js.map +1 -0
  21. package/dist/chunks/{index-x9eqVqQD.esm.js → index-hrwZmHHJ.esm.js} +2 -2
  22. package/dist/chunks/index-hrwZmHHJ.esm.js.map +1 -0
  23. package/dist/chunks/index-stfehQ0s.esm.js +2 -0
  24. package/dist/chunks/index-stfehQ0s.esm.js.map +1 -0
  25. package/dist/chunks/{localize-Vmeu1g_0.esm.js → localize-z-KGe7Y5.esm.js} +2 -2
  26. package/dist/chunks/{localize-Vmeu1g_0.esm.js.map → localize-z-KGe7Y5.esm.js.map} +1 -1
  27. package/dist/chunks/order-page-8P0D98JI.esm.js +2 -0
  28. package/dist/chunks/order-page-8P0D98JI.esm.js.map +1 -0
  29. package/dist/chunks/order-page-cWc57Sl-.esm.js +2 -0
  30. package/dist/chunks/order-page-cWc57Sl-.esm.js.map +1 -0
  31. package/dist/chunks/{routes-5ojB8NiU.esm.js → routes-RQDFRUiD.esm.js} +2 -2
  32. package/dist/chunks/{routes-5ojB8NiU.esm.js.map → routes-RQDFRUiD.esm.js.map} +1 -1
  33. package/dist/chunks/{update-cart-Lmma11Zd.esm.js → update-cart-qXTq0EoJ.esm.js} +2 -2
  34. package/dist/chunks/{update-cart-Lmma11Zd.esm.js.map → update-cart-qXTq0EoJ.esm.js.map} +1 -1
  35. package/dist/components/community-impact.esm.js +1 -1
  36. package/dist/components/community-impact.js +1 -1
  37. package/dist/components/cumulative-impact.esm.js +1 -1
  38. package/dist/components/cumulative-impact.js +1 -1
  39. package/dist/components/impact-overview.esm.js +1 -1
  40. package/dist/components/impact-overview.js +1 -1
  41. package/dist/components/index.esm.js +1 -1
  42. package/dist/components/index.js +1 -1
  43. package/dist/components/post-purchase.esm.js +1 -1
  44. package/dist/components/post-purchase.js +1 -1
  45. package/dist/components/redeem-transaction.esm.js +1 -1
  46. package/dist/components/redeem-transaction.js +1 -1
  47. package/dist/components/select-nonprofit.esm.js +1 -1
  48. package/dist/components/select-nonprofit.js +1 -1
  49. package/dist/components/shopify.esm.js +1 -1
  50. package/dist/components/shopify.js +1 -1
  51. package/dist/index.esm.js +1 -1
  52. package/dist/index.js +1 -1
  53. package/dist/integrations/beam.esm.js +1 -1
  54. package/dist/integrations/beam.js +1 -1
  55. package/dist/integrations/cart.esm.js +1 -1
  56. package/dist/integrations/cart.js +1 -1
  57. package/dist/integrations/index.esm.js +1 -1
  58. package/dist/integrations/index.js +1 -1
  59. package/dist/integrations/logs.esm.js +1 -1
  60. package/dist/integrations/logs.js +1 -1
  61. package/dist/integrations/session.esm.js +1 -1
  62. package/dist/integrations/session.js +1 -1
  63. package/dist/integrations/shopify.esm.js +1 -1
  64. package/dist/integrations/shopify.js +1 -1
  65. package/dist/integrations/statsig.esm.js +1 -1
  66. package/dist/integrations/statsig.js +1 -1
  67. package/dist/integrations/utils.esm.js +1 -1
  68. package/dist/integrations/utils.js +1 -1
  69. package/dist/react/community-impact.esm.js +1 -1
  70. package/dist/react/community-impact.js +1 -1
  71. package/dist/react/cumulative-impact.esm.js +1 -1
  72. package/dist/react/cumulative-impact.js +1 -1
  73. package/dist/react/impact-overview.esm.js +1 -1
  74. package/dist/react/impact-overview.js +1 -1
  75. package/dist/react/index.esm.js +1 -1
  76. package/dist/react/index.js +1 -1
  77. package/dist/react/post-purchase.esm.js +1 -1
  78. package/dist/react/post-purchase.js +1 -1
  79. package/dist/react/redeem-transaction.esm.js +1 -1
  80. package/dist/react/redeem-transaction.js +1 -1
  81. package/dist/react/select-nonprofit.esm.js +1 -1
  82. package/dist/react/select-nonprofit.js +1 -1
  83. package/package.json +1 -1
  84. package/dist/chunks/_share-dialog-dependencies-OkmQDHff.esm.js.map +0 -1
  85. package/dist/chunks/_share-dialog-dependencies-lvdVUIId.esm.js.map +0 -1
  86. package/dist/chunks/cookies-BnIoXWd0.esm.js +0 -2
  87. package/dist/chunks/cookies-BnIoXWd0.esm.js.map +0 -1
  88. package/dist/chunks/index-06P5EVfg.esm.js +0 -2
  89. package/dist/chunks/index-06P5EVfg.esm.js.map +0 -1
  90. package/dist/chunks/index-2IemHU8t.esm.js +0 -2
  91. package/dist/chunks/index-2IemHU8t.esm.js.map +0 -1
  92. package/dist/chunks/index-OwDDJB1x.esm.js +0 -2
  93. package/dist/chunks/index-OwDDJB1x.esm.js.map +0 -1
  94. package/dist/chunks/index-gWKY7OT9.esm.js +0 -2
  95. package/dist/chunks/index-gWKY7OT9.esm.js.map +0 -1
  96. package/dist/chunks/index-jWjc4wuH.esm.js +0 -2
  97. package/dist/chunks/index-jWjc4wuH.esm.js.map +0 -1
  98. package/dist/chunks/index-qMGAQ3oX.esm.js.map +0 -1
  99. package/dist/chunks/index-x9eqVqQD.esm.js.map +0 -1
  100. package/dist/chunks/order-page-DUppEHVi.esm.js +0 -2
  101. package/dist/chunks/order-page-DUppEHVi.esm.js.map +0 -1
  102. package/dist/chunks/order-page-uz8xgMT0.esm.js +0 -2
  103. package/dist/chunks/order-page-uz8xgMT0.esm.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import"./vendor-IGhQoYCM.esm.js";import"../components/impact-overview.js";import"./lit-h1W25hjN.esm.js";import"./lodash-ZxBiuGue.esm.js";import"./routes-5ojB8NiU.esm.js";import"./beam-errors-AMvTvR1C.esm.js";import"./progress-bar-w3yfrrxD.esm.js";import"./localize-Vmeu1g_0.esm.js";import"./is-all-html-elements-SdSkxirh.esm.js";import"../components/beam-partner-logos.js";import"./responsive-Rehmv-eo.esm.js";
2
- //# sourceMappingURL=_share-dialog-dependencies-lvdVUIId.esm.js.map
1
+ import"./vendor-IGhQoYCM.esm.js";import"../components/impact-overview.js";import"./lit-h1W25hjN.esm.js";import"./lodash-ZxBiuGue.esm.js";import"./routes-RQDFRUiD.esm.js";import"./beam-errors-AMvTvR1C.esm.js";import"./progress-bar-w3yfrrxD.esm.js";import"./localize-z-KGe7Y5.esm.js";import"./is-all-html-elements-SdSkxirh.esm.js";import"../components/beam-partner-logos.js";import"./responsive-Rehmv-eo.esm.js";
2
+ //# sourceMappingURL=_share-dialog-dependencies-UT3NgapK.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_share-dialog-dependencies-UT3NgapK.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import"./vendor-IGhQoYCM.esm.js";import"../components/impact-overview.esm.js";import"./lit-h1W25hjN.esm.js";import"./lodash-ZxBiuGue.esm.js";import"./routes-5ojB8NiU.esm.js";import"./beam-errors-AMvTvR1C.esm.js";import"./progress-bar-w3yfrrxD.esm.js";import"./localize-Vmeu1g_0.esm.js";import"./is-all-html-elements-SdSkxirh.esm.js";import"../components/beam-partner-logos.esm.js";import"./responsive-Rehmv-eo.esm.js";
2
- //# sourceMappingURL=_share-dialog-dependencies-OkmQDHff.esm.js.map
1
+ import"./vendor-IGhQoYCM.esm.js";import"../components/impact-overview.esm.js";import"./lit-h1W25hjN.esm.js";import"./lodash-ZxBiuGue.esm.js";import"./routes-RQDFRUiD.esm.js";import"./beam-errors-AMvTvR1C.esm.js";import"./progress-bar-w3yfrrxD.esm.js";import"./localize-z-KGe7Y5.esm.js";import"./is-all-html-elements-SdSkxirh.esm.js";import"../components/beam-partner-logos.esm.js";import"./responsive-Rehmv-eo.esm.js";
2
+ //# sourceMappingURL=_share-dialog-dependencies-yxOcNNpK.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_share-dialog-dependencies-yxOcNNpK.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ const a=()=>document.cookie.split("; ").reduce((e,t)=>{const[n,...o]=t.split("="),i=decodeURIComponent(o.join("="));return e.set(n,i)},new Map),C=e=>a().get(e),l=e=>{const{name:t,value:n,expires:o,...i}=e,c=encodeURIComponent(n),p=`${t}=${c}`,u=o!=null?` ;expires=${new Date(o).toUTCString()}`:"",d=Object.entries(i).map(([r,s])=>s!=null?` ;${r}=${s}`:"").join("");document.cookie=p+d+u},g=e=>l({...e,value:"",expires:0});export{C as a,g as d,a as g,l as s};
2
+ //# sourceMappingURL=cookies-H8TCP4v0.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies-H8TCP4v0.esm.js","sources":["../../src/shared/cookies.ts"],"sourcesContent":["/*\n * Wrapper functions for CookieStore using document.cookie as a fallback if not supported\n */\n\nexport const getCookieMap = () => {\n return document.cookie.split(\"; \").reduce((res, x) => {\n const [key, ...restOfString] = x.split(\"=\");\n const value = decodeURIComponent(restOfString.join(\"=\"));\n return res.set(key, value);\n }, new Map<string, string>());\n};\n\nexport const getCookieValue = (name: string): string | undefined => {\n // New Async API, not supported in FF/Safari:\n // if (window.cookieStore) {\n // return (await window.cookieStore.get(name))?.value;\n // }\n return getCookieMap().get(name);\n};\n\nexport const setCookieValue = (options: CookieInit): undefined => {\n // New Async API, not supported in FF/Safari:\n // if (window.cookieStore) {\n // const { domain, ...rest } = options;\n // const validatedDomain = domain === \"localhost\" ? undefined : domain;\n // return await window.cookieStore.set({ ...rest, domain: validatedDomain });\n // }\n // https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#write_a_new_cookie\n const { name, value, expires, ...rest } = options;\n const encodedValue = encodeURIComponent(value);\n const base = `${name}=${encodedValue}`;\n const expiration = expires != null ? ` ;expires=${new Date(expires).toUTCString()}` : \"\";\n const modifiers = Object.entries(rest)\n .map(([key, val]) => (val != null ? ` ;${key}=${val}` : \"\"))\n .join(\"\");\n document.cookie = base + modifiers + expiration;\n return;\n};\n\nexport const deleteCookieValue = (options: { name: string; domain?: string; path?: string }): undefined => {\n return setCookieValue({ ...options, value: \"\", expires: 0 });\n};\n\n/*\n * CookieStore API Types\n * https://developer.mozilla.org/en-US/docs/Web/API/CookieStore#browser_compatibility\n */\n\ninterface CookieListItem {\n name: string;\n value: string;\n path: string;\n domain: string | null;\n expires: number | null; // timestamp, unix time in ms\n secure: boolean;\n sameSite: \"strict\" | \"lax\" | \"none\";\n}\n\ninterface CookieInit {\n name: string;\n value: string;\n path?: string;\n domain?: string;\n expires?: number; // timestamp, unix time in ms\n sameSite?: \"strict\" | \"lax\" | \"none\";\n}\n\n// https://wicg.github.io/cookie-store/#CookieChangeEvent\nexport interface CookieChangeEvent extends Event {\n readonly changed: CookieListItem[];\n readonly deleted: CookieListItem[];\n type: \"deleted\" | \"changed\";\n}\n\ntype SetCookie = {\n (options: CookieInit): Promise<undefined>;\n (name: string, value: string): Promise<undefined>;\n};\n\n// https://wicg.github.io/cookie-store/#CookieStore\ninterface CookieStore extends EventTarget {\n get: (name: string | { name: string; url: string }) => Promise<CookieListItem | undefined>;\n getAll: (name: string | { name: string; url: string }) => Promise<CookieListItem[]>;\n set: SetCookie; // function overload for multiple signatures\n delete: (name: string | { name: string; domain?: string | null; path?: string }) => Promise<undefined>;\n onchange: (event: CookieChangeEvent) => boolean | void | Promise<boolean | void>;\n}\n\ndeclare global {\n interface Window {\n cookieStore: CookieStore;\n }\n}\n"],"names":["getCookieMap","res","x","key","restOfString","value","getCookieValue","name","setCookieValue","options","expires","rest","encodedValue","base","expiration","modifiers","val","deleteCookieValue"],"mappings":"AAIa,MAAAA,EAAe,IACnB,SAAS,OAAO,MAAM,IAAI,EAAE,OAAO,CAACC,EAAKC,IAAM,CACpD,KAAM,CAACC,EAAK,GAAGC,CAAY,EAAIF,EAAE,MAAM,GAAG,EACpCG,EAAQ,mBAAmBD,EAAa,KAAK,GAAG,CAAC,EACvD,OAAOH,EAAI,IAAIE,EAAKE,CAAK,CAC3B,EAAG,IAAI,GAAqB,EAGjBC,EAAkBC,GAKtBP,IAAe,IAAIO,CAAI,EAGnBC,EAAkBC,GAAmC,CAQhE,KAAM,CAAE,KAAAF,EAAM,MAAAF,EAAO,QAAAK,EAAS,GAAGC,CAAK,EAAIF,EACpCG,EAAe,mBAAmBP,CAAK,EACvCQ,EAAO,GAAGN,CAAI,IAAIK,CAAY,GAC9BE,EAAaJ,GAAW,KAAO,aAAa,IAAI,KAAKA,CAAO,EAAE,YAAa,CAAA,GAAK,GAChFK,EAAY,OAAO,QAAQJ,CAAI,EAClC,IAAI,CAAC,CAACR,EAAKa,CAAG,IAAOA,GAAO,KAAO,KAAKb,CAAG,IAAIa,CAAG,GAAK,EAAG,EAC1D,KAAK,EAAE,EACV,SAAS,OAASH,EAAOE,EAAYD,CAEvC,EAEaG,EAAqBR,GACzBD,EAAe,CAAE,GAAGC,EAAS,MAAO,GAAI,QAAS,CAAE,CAAC"}
@@ -1,2 +1,2 @@
1
- import{getConfig as e,init as o}from"../integrations/beam.esm.js";import{b as t}from"./beam-errors-AMvTvR1C.esm.js";import{e as r}from"./events-wNy5BoJV.esm.js";import{l as i}from"./routes-5ojB8NiU.esm.js";import{f as s,i as a,w as m,x as g}from"./network-listeners-O5LKv8Yy.esm.js";import{c as n}from"./local-storage-GYvYzZ_j.esm.js";import{d as l,g as f,a as p,s as c}from"./cookies-BnIoXWd0.esm.js";import{g as k,s as C}from"./remote-session-V4YG-mcS.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:n,deleteCookieValue:l,errors:t,events:r,fetchProxy:s,getConfig:e,getCookieMap:f,getCookieValue:p,getRemoteSession:k,init:o,initNetworkListeners:a,logger:i,saveRemoteSession:C,setCookieValue:c,waitForElement:m,xhrProxy:g});export{x as i};
2
- //# sourceMappingURL=index-qMGAQ3oX.esm.js.map
1
+ import{getConfig as e,init as o}from"../integrations/beam.esm.js";import{b as t}from"./beam-errors-AMvTvR1C.esm.js";import{e as r}from"./events-wNy5BoJV.esm.js";import{l as i}from"./routes-RQDFRUiD.esm.js";import{f as s,i as a,w as m,x as g}from"./network-listeners-O5LKv8Yy.esm.js";import{c as n}from"./local-storage-GYvYzZ_j.esm.js";import{d as l,g as f,a as p,s as c}from"./cookies-H8TCP4v0.esm.js";import{g as k,s as C}from"./remote-session-V4YG-mcS.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:n,deleteCookieValue:l,errors:t,events:r,fetchProxy:s,getConfig:e,getCookieMap:f,getCookieValue:p,getRemoteSession:k,init:o,initNetworkListeners:a,logger:i,saveRemoteSession:C,setCookieValue:c,waitForElement:m,xhrProxy:g});export{x as i};
2
+ //# sourceMappingURL=index-4ckY2-Lc.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-4ckY2-Lc.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{h as e,C as r,B as t,s as a,N as o}from"./order-page-8P0D98JI.esm.js";var s=Object.freeze({__proto__:null,addBeamAttributesToCart:e,getCurrentCart:r,registerCartIntegration:t,showBeamOrderPageWidgets:a,trackCart:o});export{s as i};
2
+ //# sourceMappingURL=index-FZ0yrk2j.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-FZ0yrk2j.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{L as e}from"./update-cart-qXTq0EoJ.esm.js";var r=Object.freeze({__proto__:null,updateCart:e});export{r as i};
2
+ //# sourceMappingURL=index-PXYriqGw.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-PXYriqGw.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{v as d}from"./vendor-IGhQoYCM.esm.js";import{a as i,s as p,d as l}from"./cookies-BnIoXWd0.esm.js";import{c as n}from"./local-storage-GYvYzZ_j.esm.js";const s="beam_session";async function c({cookieName:e=s,domain:o=window.location.hostname,apiKey:t=""}={}){if(await i(e))return;const a=d(),m=Date.now()+30*24*60*60*1e3;await p({name:e,value:a,domain:o,path:"/",expires:m}),n({apiKey:t}).setItemJson("cart",{cartId:a})}async function r({cookieName:e=s,domain:o=window.location.hostname,apiKey:t=""}={}){const a=await i(e);a&&(n({apiKey:t}).setItemJson("cart",{cartId:a}),await l({name:e,domain:o}))}var u=Object.freeze({__proto__:null,createSession:c,endSession:r});export{c,r as e,u as i};
2
- //# sourceMappingURL=index-jFZJm9-Y.esm.js.map
1
+ import{v as d}from"./vendor-IGhQoYCM.esm.js";import{a as i,s as p,d as l}from"./cookies-H8TCP4v0.esm.js";import{c as n}from"./local-storage-GYvYzZ_j.esm.js";const s="beam_session";async function c({cookieName:e=s,domain:o=window.location.hostname,apiKey:t=""}={}){if(await i(e))return;const a=d(),m=Date.now()+30*24*60*60*1e3;await p({name:e,value:a,domain:o,path:"/",expires:m}),n({apiKey:t}).setItemJson("cart",{cartId:a})}async function r({cookieName:e=s,domain:o=window.location.hostname,apiKey:t=""}={}){const a=await i(e);a&&(n({apiKey:t}).setItemJson("cart",{cartId:a}),await l({name:e,domain:o}))}var u=Object.freeze({__proto__:null,createSession:c,endSession:r});export{c,r as e,u as i};
2
+ //# sourceMappingURL=index-UODI8bvb.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-jFZJm9-Y.esm.js","sources":["../../src/integrations/session/index.ts"],"sourcesContent":["/**\n If checkout and order page are on different subdomains, we can't access localStorage for nonprofitId/selectionId\n We can make post-transaction work by copying a \"cartID\"-style cookie to the expected localStorage key on the current\n domain, which will allow the post-transaction widgets to send that to the backend which can restore the selection\n from the cart.\n\n This will also work if we don't have a cart cookie for some other reason, although it is not directly integrated\n with the host site's concept of a cart (e.g., line items and expiration dates).\n\n Note: Use a module import rather than a self-executing script so that we can set cookies on the host domain\n rather than our 3rd party CDN domain, and customize the options via arguments.\n\n Usage:\n <script type=\"module\">\n import { createSession } from 'https://...';\n createSession({domain: 'mystore.com'})\n </script>\n */\n\nimport { v4 as uuid } from \"@lukeed/uuid/secure\";\nimport { deleteCookieValue, getCookieValue, setCookieValue } from \"../../shared/cookies\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\n\nconst DEFAULT_COOKIE_NAME = \"beam_session\";\n\nexport async function createSession({\n cookieName = DEFAULT_COOKIE_NAME,\n domain = window.location.hostname, // domain or subdomain to set cookie on\n apiKey = \"\", // optional unless scoping localStorage to api key\n} = {}) {\n const existingValue = await getCookieValue(cookieName);\n\n if (existingValue) {\n return; // do nothing\n }\n\n const cookieValue = uuid();\n\n const expires = Date.now() + 30 * 24 * 60 * 60 * 1000; // 30 days\n\n await setCookieValue({ name: cookieName, value: cookieValue, domain, path: \"/\", expires });\n\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n beamLocalStorage.setItemJson(\"cart\", { cartId: cookieValue });\n}\n\nexport async function endSession({\n cookieName = DEFAULT_COOKIE_NAME,\n domain = window.location.hostname, // domain to remove cookie from\n apiKey = \"\", // optional unless scoping localStorage to api key\n} = {}) {\n const cookieValue = await getCookieValue(cookieName);\n\n if (!cookieValue) {\n return; // do nothing\n }\n\n // copy cookie value into localStorage for widgets to use\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n beamLocalStorage.setItemJson(\"cart\", { cartId: cookieValue });\n\n // delete cookie to end session (will generate new one on next visit)\n await deleteCookieValue({ name: cookieName, domain });\n}\n"],"names":["DEFAULT_COOKIE_NAME","createSession","cookieName","domain","apiKey","getCookieValue","cookieValue","uuid","expires","setCookieValue","createScopedLocalStorage","endSession","deleteCookieValue"],"mappings":"6JAuBA,MAAMA,EAAsB,eAE5B,eAAsBC,EAAc,CAClC,WAAAC,EAAaF,EACb,OAAAG,EAAS,OAAO,SAAS,SACzB,OAAAC,EAAS,EACX,EAAI,CAAI,EAAA,CAGN,GAFsB,MAAMC,EAAeH,CAAU,EAGnD,OAGF,MAAMI,EAAcC,EAAK,EAEnBC,EAAU,KAAK,IAAA,EAAQ,GAAK,GAAK,GAAK,GAAK,IAEjD,MAAMC,EAAe,CAAE,KAAMP,EAAY,MAAOI,EAAa,OAAAH,EAAQ,KAAM,IAAK,QAAAK,CAAQ,CAAC,EAEhEE,EAAyB,CAAE,OAAAN,CAAO,CAAC,EAC3C,YAAY,OAAQ,CAAE,OAAQE,CAAY,CAAC,CAC9D,CAEA,eAAsBK,EAAW,CAC/B,WAAAT,EAAaF,EACb,OAAAG,EAAS,OAAO,SAAS,SACzB,OAAAC,EAAS,EACX,EAAI,GAAI,CACN,MAAME,EAAc,MAAMD,EAAeH,CAAU,EAE9CI,IAKoBI,EAAyB,CAAE,OAAAN,CAAO,CAAC,EAC3C,YAAY,OAAQ,CAAE,OAAQE,CAAY,CAAC,EAG5D,MAAMM,EAAkB,CAAE,KAAMV,EAAY,OAAAC,CAAO,CAAC,EACtD"}
1
+ {"version":3,"file":"index-UODI8bvb.esm.js","sources":["../../src/integrations/session/index.ts"],"sourcesContent":["/**\n If checkout and order page are on different subdomains, we can't access localStorage for nonprofitId/selectionId\n We can make post-transaction work by copying a \"cartID\"-style cookie to the expected localStorage key on the current\n domain, which will allow the post-transaction widgets to send that to the backend which can restore the selection\n from the cart.\n\n This will also work if we don't have a cart cookie for some other reason, although it is not directly integrated\n with the host site's concept of a cart (e.g., line items and expiration dates).\n\n Note: Use a module import rather than a self-executing script so that we can set cookies on the host domain\n rather than our 3rd party CDN domain, and customize the options via arguments.\n\n Usage:\n <script type=\"module\">\n import { createSession } from 'https://...';\n createSession({domain: 'mystore.com'})\n </script>\n */\n\nimport { v4 as uuid } from \"@lukeed/uuid/secure\";\nimport { deleteCookieValue, getCookieValue, setCookieValue } from \"../../shared/cookies\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\n\nconst DEFAULT_COOKIE_NAME = \"beam_session\";\n\nexport async function createSession({\n cookieName = DEFAULT_COOKIE_NAME,\n domain = window.location.hostname, // domain or subdomain to set cookie on\n apiKey = \"\", // optional unless scoping localStorage to api key\n} = {}) {\n const existingValue = await getCookieValue(cookieName);\n\n if (existingValue) {\n return; // do nothing\n }\n\n const cookieValue = uuid();\n\n const expires = Date.now() + 30 * 24 * 60 * 60 * 1000; // 30 days\n\n await setCookieValue({ name: cookieName, value: cookieValue, domain, path: \"/\", expires });\n\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n beamLocalStorage.setItemJson(\"cart\", { cartId: cookieValue });\n}\n\nexport async function endSession({\n cookieName = DEFAULT_COOKIE_NAME,\n domain = window.location.hostname, // domain to remove cookie from\n apiKey = \"\", // optional unless scoping localStorage to api key\n} = {}) {\n const cookieValue = await getCookieValue(cookieName);\n\n if (!cookieValue) {\n return; // do nothing\n }\n\n // copy cookie value into localStorage for widgets to use\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n beamLocalStorage.setItemJson(\"cart\", { cartId: cookieValue });\n\n // delete cookie to end session (will generate new one on next visit)\n await deleteCookieValue({ name: cookieName, domain });\n}\n"],"names":["DEFAULT_COOKIE_NAME","createSession","cookieName","domain","apiKey","getCookieValue","cookieValue","uuid","expires","setCookieValue","createScopedLocalStorage","endSession","deleteCookieValue"],"mappings":"6JAuBA,MAAMA,EAAsB,eAE5B,eAAsBC,EAAc,CAClC,WAAAC,EAAaF,EACb,OAAAG,EAAS,OAAO,SAAS,SACzB,OAAAC,EAAS,EACX,EAAI,CAAI,EAAA,CAGN,GAFsB,MAAMC,EAAeH,CAAU,EAGnD,OAGF,MAAMI,EAAcC,EAAK,EAEnBC,EAAU,KAAK,IAAA,EAAQ,GAAK,GAAK,GAAK,GAAK,IAEjD,MAAMC,EAAe,CAAE,KAAMP,EAAY,MAAOI,EAAa,OAAAH,EAAQ,KAAM,IAAK,QAAAK,CAAQ,CAAC,EAEhEE,EAAyB,CAAE,OAAAN,CAAO,CAAC,EAC3C,YAAY,OAAQ,CAAE,OAAQE,CAAY,CAAC,CAC9D,CAEA,eAAsBK,EAAW,CAC/B,WAAAT,EAAaF,EACb,OAAAG,EAAS,OAAO,SAAS,SACzB,OAAAC,EAAS,EACX,EAAI,GAAI,CACN,MAAME,EAAc,MAAMD,EAAeH,CAAU,EAE9CI,IAKoBI,EAAyB,CAAE,OAAAN,CAAO,CAAC,EAC3C,YAAY,OAAQ,CAAE,OAAQE,CAAY,CAAC,EAG5D,MAAMM,EAAkB,CAAE,KAAMV,EAAY,OAAAC,CAAO,CAAC,EACtD"}
@@ -0,0 +1,2 @@
1
+ import{i}from"./index-4ckY2-Lc.esm.js";import{i as o}from"./index-FZ0yrk2j.esm.js";import{i as r}from"./index-UODI8bvb.esm.js";import{i as e}from"./index-PXYriqGw.esm.js";import{i as m}from"./index-f-fjpKtx.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-YKvnw1cF.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-YKvnw1cF.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{b as i,c as n,l}from"./routes-5ojB8NiU.esm.js";async function e(o,s){const{apiKey:a,baseUrl:r}=o;try{await n({baseUrl:r||i,headers:{authorization:`Api-Key ${a}`},requestBody:{...s}})}catch(t){l.error("Failed to send log",t)}}var c=Object.freeze({__proto__:null,sendLog:e});export{c as i,e as s};
2
- //# sourceMappingURL=index-KoM7lmw7.esm.js.map
1
+ import{b as i,c as n,l}from"./routes-RQDFRUiD.esm.js";async function e(o,s){const{apiKey:a,baseUrl:r}=o;try{await n({baseUrl:r||i,headers:{authorization:`Api-Key ${a}`},requestBody:{...s}})}catch(t){l.error("Failed to send log",t)}}var c=Object.freeze({__proto__:null,sendLog:e});export{c as i,e as s};
2
+ //# sourceMappingURL=index-f-fjpKtx.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-KoM7lmw7.esm.js","sources":["../../src/integrations/logs/index.ts"],"sourcesContent":["import { postLogs } from \"../../api-sdk/v3/routes\";\nimport { paths } from \"../../api-sdk/v3/openapi-spec\";\nimport { logger } from \"../../shared/logger\";\nimport { DEFAULT_LOG_URL } from \"../../api-sdk/constants\";\n\ntype PostLogsReq = paths[\"/logs\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\n\ninterface SendLogConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport async function sendLog(config: SendLogConfig, payload: PostLogsReq): Promise<void> {\n const { apiKey, baseUrl } = config;\n try {\n await postLogs({\n baseUrl: baseUrl || DEFAULT_LOG_URL,\n headers: {\n authorization: `Api-Key ${apiKey}`,\n },\n requestBody: {\n ...payload,\n },\n });\n } catch (err) {\n logger.error(\"Failed to send log\", err);\n }\n}\n"],"names":["sendLog","config","payload","apiKey","baseUrl","postLogs","DEFAULT_LOG_URL","err","logger"],"mappings":"sDAYA,eAAsBA,EAAQC,EAAuBC,EAAqC,CACxF,KAAM,CAAE,OAAAC,EAAQ,QAAAC,CAAQ,EAAIH,EAC5B,GAAI,CACF,MAAMI,EAAS,CACb,QAASD,GAAWE,EACpB,QAAS,CACP,cAAe,WAAWH,CAAM,EAClC,EACA,YAAa,CACX,GAAGD,CACL,CACF,CAAC,CACH,OAASK,EAAK,CACZC,EAAO,MAAM,qBAAsBD,CAAG,CACxC,CACF"}
1
+ {"version":3,"file":"index-f-fjpKtx.esm.js","sources":["../../src/integrations/logs/index.ts"],"sourcesContent":["import { postLogs } from \"../../api-sdk/v3/routes\";\nimport { paths } from \"../../api-sdk/v3/openapi-spec\";\nimport { logger } from \"../../shared/logger\";\nimport { DEFAULT_LOG_URL } from \"../../api-sdk/constants\";\n\ntype PostLogsReq = paths[\"/logs\"][\"post\"][\"requestBody\"][\"content\"][\"application/json\"];\n\ninterface SendLogConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport async function sendLog(config: SendLogConfig, payload: PostLogsReq): Promise<void> {\n const { apiKey, baseUrl } = config;\n try {\n await postLogs({\n baseUrl: baseUrl || DEFAULT_LOG_URL,\n headers: {\n authorization: `Api-Key ${apiKey}`,\n },\n requestBody: {\n ...payload,\n },\n });\n } catch (err) {\n logger.error(\"Failed to send log\", err);\n }\n}\n"],"names":["sendLog","config","payload","apiKey","baseUrl","postLogs","DEFAULT_LOG_URL","err","logger"],"mappings":"sDAYA,eAAsBA,EAAQC,EAAuBC,EAAqC,CACxF,KAAM,CAAE,OAAAC,EAAQ,QAAAC,CAAQ,EAAIH,EAC5B,GAAI,CACF,MAAMI,EAAS,CACb,QAASD,GAAWE,EACpB,QAAS,CACP,cAAe,WAAWH,CAAM,EAClC,EACA,YAAa,CACX,GAAGD,CACL,CACF,CAAC,CACH,OAASK,EAAK,CACZC,EAAO,MAAM,qBAAsBD,CAAG,CACxC,CACF"}
@@ -0,0 +1,2 @@
1
+ import{h as e,C as r,B as t,s as a,N as o}from"./order-page-cWc57Sl-.esm.js";var s=Object.freeze({__proto__:null,addBeamAttributesToCart:e,getCurrentCart:r,registerCartIntegration:t,showBeamOrderPageWidgets:a,trackCart:o});export{s as i};
2
+ //# sourceMappingURL=index-fXIUzndi.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-fXIUzndi.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{getConfig as e,init as o}from"../integrations/beam.js";import{b as t}from"./beam-errors-AMvTvR1C.esm.js";import{e as r}from"./events-wNy5BoJV.esm.js";import{l as i}from"./routes-5ojB8NiU.esm.js";import{f as s,i as a,w as m,x as g}from"./network-listeners-O5LKv8Yy.esm.js";import{c as n}from"./local-storage-GYvYzZ_j.esm.js";import{d as l,g as f,a as p,s as c}from"./cookies-BnIoXWd0.esm.js";import{g as k,s as C}from"./remote-session-V4YG-mcS.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:n,deleteCookieValue:l,errors:t,events:r,fetchProxy:s,getConfig:e,getCookieMap:f,getCookieValue:p,getRemoteSession:k,init:o,initNetworkListeners:a,logger:i,saveRemoteSession:C,setCookieValue:c,waitForElement:m,xhrProxy:g});export{x as i};
2
- //# sourceMappingURL=index-x9eqVqQD.esm.js.map
1
+ import{getConfig as e,init as o}from"../integrations/beam.js";import{b as t}from"./beam-errors-AMvTvR1C.esm.js";import{e as r}from"./events-wNy5BoJV.esm.js";import{l as i}from"./routes-RQDFRUiD.esm.js";import{f as s,i as a,w as m,x as g}from"./network-listeners-O5LKv8Yy.esm.js";import{c as n}from"./local-storage-GYvYzZ_j.esm.js";import{d as l,g as f,a as p,s as c}from"./cookies-H8TCP4v0.esm.js";import{g as k,s as C}from"./remote-session-V4YG-mcS.esm.js";var x=Object.freeze({__proto__:null,createScopedLocalStorage:n,deleteCookieValue:l,errors:t,events:r,fetchProxy:s,getConfig:e,getCookieMap:f,getCookieValue:p,getRemoteSession:k,init:o,initNetworkListeners:a,logger:i,saveRemoteSession:C,setCookieValue:c,waitForElement:m,xhrProxy:g});export{x as i};
2
+ //# sourceMappingURL=index-hrwZmHHJ.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-hrwZmHHJ.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{i}from"./index-hrwZmHHJ.esm.js";import{i as o}from"./index-fXIUzndi.esm.js";import{i as r}from"./index-UODI8bvb.esm.js";import{i as e}from"./index-PXYriqGw.esm.js";import{i as m}from"./index-f-fjpKtx.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-stfehQ0s.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-stfehQ0s.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import{h as p,y as o,j as d}from"./lit-h1W25hjN.esm.js";import{N as u,M as f,B as $}from"./beam-errors-AMvTvR1C.esm.js";import{l as m}from"./routes-5ojB8NiU.esm.js";const b=p`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 y(t,e=t.tagName){customElements.get(e)||customElements.define(e,t)}const x=t=>Object.entries(t).map(([e,r])=>`${e}: ${r};`).join(`
1
+ import{h as p,y as o,j as d}from"./lit-h1W25hjN.esm.js";import{N as u,M as f,B as $}from"./beam-errors-AMvTvR1C.esm.js";import{l as m}from"./routes-RQDFRUiD.esm.js";const b=p`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 y(t,e=t.tagName){customElements.get(e)||customElements.define(e,t)}const x=t=>Object.entries(t).map(([e,r])=>`${e}: ${r};`).join(`
2
2
  `);class w{constructor(e,r){this.data=null,this.loading=!1,this.error=null,(this.host=e).addController(this),this.asyncFn=r}async exec(...e){this.lastArgs=e,this.loading=!0,this.host.requestUpdate();try{this.data=await this.asyncFn(...e),this.error=null}catch(r){r instanceof Error&&(this.error=r,this.data=null)}return this.loading=!1,this.host.requestUpdate(),this.data}async retry(){return this.exec(...this.lastArgs||[])}hostDisconnected(){}}const g={errorTitle:"Beam encountered an error. Please try again.",retry:"Retry"},T=({error:t,retry:e})=>{let r=o``;if(t instanceof u){const i=JSON.stringify({status:t.response.status,statusText:t.response.statusText,url:t.response.url,body:t.body},null,4);r=o`
3
3
  <p><b>Network Response:</b></p>
4
4
  <p>${i}</p>
@@ -27,4 +27,4 @@ import{h as p,y as o,j as d}from"./lit-h1W25hjN.esm.js";import{N as u,M as f,B a
27
27
  color: var(${n}-color, ${c});
28
28
  `)};function z(t,e){const r=[],i=e;for(const s of t)i[s]==null&&r.push(s);if(r.length>0)throw m.error(`Beam Impact - Missing Required Config Values:
29
29
  `,r.join(", "),e),new f(r);return!0}const F=(t,e)=>{if(e.startsWith("{"))try{const r=JSON.parse(e);return r[t]??r.en??e}catch{return m.error(new $("Failed to extract JSON translation from string"),e),e}return e};export{w as A,T as _,S as a,C as b,b as c,y as d,z as e,x as f,F as i,N as u};
30
- //# sourceMappingURL=localize-Vmeu1g_0.esm.js.map
30
+ //# sourceMappingURL=localize-z-KGe7Y5.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"localize-Vmeu1g_0.esm.js","sources":["../../src/shared/css-reset.ts","../../src/shared/defineCustomElement.ts","../../src/shared/fragments/css-variable-map.ts","../../src/shared/controllers/async-controller.ts","../../src/shared/fragments/error-message-template.ts","../../src/shared/fragments/loading-template.ts","../../src/shared/fragments/custom-text.ts","../../src/shared/enforce-config.ts","../../src/shared/localize.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","export const _cssVariableMap = (variables: Record<string, string>) => {\n return Object.entries(variables)\n .map(([k, v]) => `${k}: ${v};`)\n .join(\"\\n\");\n};\n","import { ReactiveController, ReactiveControllerHost } from \"lit\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncFunction = (...args: any[]) => Promise<any>;\n\n/**\n * Creates a declarative wrapper around async operations\n * @example\n * class MyElement extends LitElement {\n * private user = new AsyncController(\n * this,\n * async ({ id }) => get(url, { id }));\n *\n * async updated(changedProperties) {\n * if (changedProperties.has(\"userId\")) {\n * await this.user.exec({ id: this.userId })\n * }\n * }\n *\n * render() {\n * const { data, loading, error } = this.user;\n * if (loading) return html`Please wait...`\n * if (error) return html`Error! <button @click=${this.user.retry}>Reload</button>`;\n * return html`My name is: ${data.name}`\n * }\n * }\n */\nexport class AsyncController<TFn extends AsyncFunction> implements ReactiveController {\n public data: Awaited<ReturnType<TFn>> | null = null;\n public loading = false;\n public error: Error | null = null;\n\n private readonly host: ReactiveControllerHost;\n private readonly asyncFn: TFn;\n private lastArgs?: Parameters<TFn>;\n\n constructor(host: ReactiveControllerHost, asyncFn: TFn) {\n (this.host = host).addController(this);\n this.asyncFn = asyncFn;\n }\n\n public async exec(...args: Parameters<TFn>): Promise<ReturnType<TFn> | null> {\n this.lastArgs = args;\n this.loading = true;\n this.host.requestUpdate();\n try {\n // TODO: prevent race condition if later invocation returns before earlier\n this.data = await this.asyncFn(...args);\n this.error = null;\n } catch (err) {\n if (err instanceof Error) {\n this.error = err;\n this.data = null;\n }\n }\n this.loading = false;\n this.host.requestUpdate();\n return this.data;\n }\n\n public async retry() {\n return this.exec(...((this.lastArgs || []) as Parameters<TFn>));\n }\n\n hostDisconnected() {\n // TODO: cancel API calls\n }\n}\n","import { html } from \"lit\";\nimport { MissingConfig, NetworkError } from \"../beam-errors\";\n\nconst strings = {\n errorTitle: `Beam encountered an error. Please try again.`,\n retry: `Retry`,\n};\n\nexport const _errorMessage = ({ error, retry }: { error: Error; retry?: (...args: never) => void }) => {\n let details = html``;\n if (error instanceof NetworkError) {\n const response = JSON.stringify(\n {\n status: error.response.status,\n statusText: error.response.statusText,\n url: error.response.url,\n body: error.body,\n },\n null,\n 4\n );\n details = html`\n <p><b>Network Response:</b></p>\n <p>${response}</p>\n `;\n }\n if (error instanceof MissingConfig) {\n details = html`\n <p><b>Missing Required Config Options:</b></p>\n <p>${error.missingConfigKeyNames.join(\", \")}</p>\n `;\n }\n return html`<div class=\"beam-error\" style=\"text-align: left\">\n <p>${strings.errorTitle} ${retry ? html` <button type=\"reset\" @click=\"${retry}\">${strings.retry}</button>` : \"\"}</p>\n <br />\n <details>\n <div style=\"white-space: pre-wrap; font-family: monospace; line-height: 1;\">\n ${details}\n <p><b>Message:</b> ${error.message || html`<i>None</i>`}</p>\n <p><b>Stack:</b> ${error.stack}</p>\n </div>\n </details>\n <br />\n <p>Help: <a href=\"https://www.beamimpact.com\">www.beamimpact.com</a></p>\n </div>`;\n};\n","import { html } from \"lit\";\n\nconst strings = {\n loading: \"\", // Default is no loading content\n};\n\nexport const _loading = () => {\n return html`<p class=\"beam-loading\">${strings.loading}</p>`;\n};\n","import { CSSResult, unsafeCSS } from \"lit\";\n\n/**\n * Create an object that can be passed to cssVariableMap\n * to define CSS variables in a style tag. The default properties\n * are the ones exposed for customization in the remote config interface.\n * @example\n * const variables = {\n * ...customizableTextJs(\"widget-header\",\n * \"widget-border-color\": \"red\"\n * };\n *\n * html`<style>:host { ${_cssVariableMap(variables)} }</style>`;\n * @returns {{[p: string]: string}}\n */\nexport const defineCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n [`${prefix}-fontFamily`]: fontFamily,\n [`${prefix}-fontStyle`]: fontStyle,\n [`${prefix}-fontSize`]: fontSize,\n [`${prefix}-fontWeight`]: fontWeight,\n [`${prefix}-textTransform`]: textTransform,\n [`${prefix}-marginTop`]: marginTop,\n [`${prefix}-lineHeight`]: lineHeight,\n [`${prefix}-color`]: color,\n };\n};\n\n/**\n * Returns a string that defines css properties based on variables,\n * which can be used in a css`` template. The default properties are the\n * ones exposed for customization in the remote config interface.\n * @example\n * css`.widget-header { ${customizableTextCss(\"widget-header\")} border: none; }`\n * @returns {CSSResult}\n */\nexport const useCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n } = {}\n): CSSResult => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return unsafeCSS(`\\\n font-family: var(${prefix}-fontFamily, ${fontFamily});\n font-style: var(${prefix}-fontStyle, ${fontStyle});\n font-size: var(${prefix}-fontSize, ${fontSize});\n font-weight: var(${prefix}-fontWeight, ${fontWeight});\n text-transform: var(${prefix}-textTransform, ${textTransform});\n margin-top: var(${prefix}-marginTop, ${marginTop});\n line-height: var(${prefix}-lineHeight, ${lineHeight});\n color: var(${prefix}-color, ${color});\n `);\n};\n\n/**\n * Same as useCustomText except returns an object that can be passed to styleMap\n */\nexport const useCustomTextMap = (\n namespace = \"\",\n {\n fontSize = \"inherit\",\n fontStyle = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n fontSize: `var(${prefix}-fontSize, ${fontSize})`,\n fontStyle: `var(${prefix}-fontStyle, ${fontStyle})`,\n fontWeight: `var(${prefix}-fontWeight, ${fontWeight})`,\n textTransform: `var(${prefix}-textTransform, ${textTransform})`,\n marginTop: `var(${prefix}-marginTop, ${marginTop})`,\n lineHeight: `var(${prefix}-lineHeight, ${lineHeight})`,\n };\n};\n","import { MissingConfig } from \"./beam-errors\";\nimport { logger } from \"./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","import { LANGUAGES } from \"../api-sdk/types\";\nimport { logger } from \"./logger\";\nimport { BeamError } from \"./beam-errors\";\n\n/**\n * User-provided strings may include embedded translations in JSON form\n * This function extracts the string for the provided language\n * If it fails to parse, or the string is not json-like, it returns the whole string\n * TODO: consider returning unsafeHtml() or adding an option for it\n */\nconst localizeUserString = (lang: LANGUAGES, str: string): string => {\n const isJson = str.startsWith(\"{\");\n if (isJson) {\n try {\n const json = JSON.parse(str);\n return json[lang] ?? json[\"en\"] ?? str;\n } catch (err) {\n logger.error(new BeamError(\"Failed to extract JSON translation from string\"), str);\n return str;\n }\n }\n return str;\n};\n\nexport { localizeUserString };\n"],"names":["cssReset","css","defineCustomElement","CustomElementClass","tagName","_cssVariableMap","variables","k","v","AsyncController","host","asyncFn","args","err","strings","_errorMessage","error","retry","details","html","NetworkError","response","MissingConfig","_loading","defineCustomText","namespace","fontFamily","fontStyle","fontSize","fontWeight","textTransform","marginTop","lineHeight","color","prefix","useCustomText","unsafeCSS","enforceConfig","keys","input","missingKeys","check","key","logger","localizeUserString","lang","str","json","BeamError"],"mappings":"qKAIO,MAAMA,EAAWC,gaCDjB,SAASC,EACdC,EACAC,EAAUD,EAAmB,QAC7B,CACA,eAAe,IAAIC,CAAO,GAAK,eAAe,OAAOA,EAASD,CAAkB,CAClF,CCRO,MAAME,EAAmBC,GACvB,OAAO,QAAQA,CAAS,EAC5B,IAAI,CAAC,CAACC,EAAGC,CAAC,IAAM,GAAGD,CAAC,KAAKC,CAAC,GAAG,EAC7B,KAAK;AAAA,CAAI,ECwBP,MAAMC,CAAyE,CASpF,YAAYC,EAA8BC,EAAc,CARxD,KAAO,KAAwC,KAC/C,KAAO,QAAU,GACjB,KAAO,MAAsB,MAO1B,KAAK,KAAOD,GAAM,cAAc,IAAI,EACrC,KAAK,QAAUC,CACjB,CAEA,MAAa,QAAQC,EAAwD,CAC3E,KAAK,SAAWA,EAChB,KAAK,QAAU,GACf,KAAK,KAAK,gBACV,GAAI,CAEF,KAAK,KAAO,MAAM,KAAK,QAAQ,GAAGA,CAAI,EACtC,KAAK,MAAQ,IACf,OAASC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ErC,MAAO,EACT,CCNMI,MAAAA,EAAqB,CAACC,EAAiBC,IAAwB,CAEnE,GADeA,EAAI,WAAW,GAAG,EAE/B,GAAI,CACF,MAAMC,EAAO,KAAK,MAAMD,CAAG,EAC3B,OAAOC,EAAKF,CAAI,GAAKE,EAAK,IAASD,CACrC,MAAc,CACZ,OAAAH,EAAO,MAAM,IAAIK,EAAU,gDAAgD,EAAGF,CAAG,EAC1EA,CACT,CAEF,OAAOA,CACT"}
1
+ {"version":3,"file":"localize-z-KGe7Y5.esm.js","sources":["../../src/shared/css-reset.ts","../../src/shared/defineCustomElement.ts","../../src/shared/fragments/css-variable-map.ts","../../src/shared/controllers/async-controller.ts","../../src/shared/fragments/error-message-template.ts","../../src/shared/fragments/loading-template.ts","../../src/shared/fragments/custom-text.ts","../../src/shared/enforce-config.ts","../../src/shared/localize.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","export const _cssVariableMap = (variables: Record<string, string>) => {\n return Object.entries(variables)\n .map(([k, v]) => `${k}: ${v};`)\n .join(\"\\n\");\n};\n","import { ReactiveController, ReactiveControllerHost } from \"lit\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncFunction = (...args: any[]) => Promise<any>;\n\n/**\n * Creates a declarative wrapper around async operations\n * @example\n * class MyElement extends LitElement {\n * private user = new AsyncController(\n * this,\n * async ({ id }) => get(url, { id }));\n *\n * async updated(changedProperties) {\n * if (changedProperties.has(\"userId\")) {\n * await this.user.exec({ id: this.userId })\n * }\n * }\n *\n * render() {\n * const { data, loading, error } = this.user;\n * if (loading) return html`Please wait...`\n * if (error) return html`Error! <button @click=${this.user.retry}>Reload</button>`;\n * return html`My name is: ${data.name}`\n * }\n * }\n */\nexport class AsyncController<TFn extends AsyncFunction> implements ReactiveController {\n public data: Awaited<ReturnType<TFn>> | null = null;\n public loading = false;\n public error: Error | null = null;\n\n private readonly host: ReactiveControllerHost;\n private readonly asyncFn: TFn;\n private lastArgs?: Parameters<TFn>;\n\n constructor(host: ReactiveControllerHost, asyncFn: TFn) {\n (this.host = host).addController(this);\n this.asyncFn = asyncFn;\n }\n\n public async exec(...args: Parameters<TFn>): Promise<ReturnType<TFn> | null> {\n this.lastArgs = args;\n this.loading = true;\n this.host.requestUpdate();\n try {\n // TODO: prevent race condition if later invocation returns before earlier\n this.data = await this.asyncFn(...args);\n this.error = null;\n } catch (err) {\n if (err instanceof Error) {\n this.error = err;\n this.data = null;\n }\n }\n this.loading = false;\n this.host.requestUpdate();\n return this.data;\n }\n\n public async retry() {\n return this.exec(...((this.lastArgs || []) as Parameters<TFn>));\n }\n\n hostDisconnected() {\n // TODO: cancel API calls\n }\n}\n","import { html } from \"lit\";\nimport { MissingConfig, NetworkError } from \"../beam-errors\";\n\nconst strings = {\n errorTitle: `Beam encountered an error. Please try again.`,\n retry: `Retry`,\n};\n\nexport const _errorMessage = ({ error, retry }: { error: Error; retry?: (...args: never) => void }) => {\n let details = html``;\n if (error instanceof NetworkError) {\n const response = JSON.stringify(\n {\n status: error.response.status,\n statusText: error.response.statusText,\n url: error.response.url,\n body: error.body,\n },\n null,\n 4\n );\n details = html`\n <p><b>Network Response:</b></p>\n <p>${response}</p>\n `;\n }\n if (error instanceof MissingConfig) {\n details = html`\n <p><b>Missing Required Config Options:</b></p>\n <p>${error.missingConfigKeyNames.join(\", \")}</p>\n `;\n }\n return html`<div class=\"beam-error\" style=\"text-align: left\">\n <p>${strings.errorTitle} ${retry ? html` <button type=\"reset\" @click=\"${retry}\">${strings.retry}</button>` : \"\"}</p>\n <br />\n <details>\n <div style=\"white-space: pre-wrap; font-family: monospace; line-height: 1;\">\n ${details}\n <p><b>Message:</b> ${error.message || html`<i>None</i>`}</p>\n <p><b>Stack:</b> ${error.stack}</p>\n </div>\n </details>\n <br />\n <p>Help: <a href=\"https://www.beamimpact.com\">www.beamimpact.com</a></p>\n </div>`;\n};\n","import { html } from \"lit\";\n\nconst strings = {\n loading: \"\", // Default is no loading content\n};\n\nexport const _loading = () => {\n return html`<p class=\"beam-loading\">${strings.loading}</p>`;\n};\n","import { CSSResult, unsafeCSS } from \"lit\";\n\n/**\n * Create an object that can be passed to cssVariableMap\n * to define CSS variables in a style tag. The default properties\n * are the ones exposed for customization in the remote config interface.\n * @example\n * const variables = {\n * ...customizableTextJs(\"widget-header\",\n * \"widget-border-color\": \"red\"\n * };\n *\n * html`<style>:host { ${_cssVariableMap(variables)} }</style>`;\n * @returns {{[p: string]: string}}\n */\nexport const defineCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n [`${prefix}-fontFamily`]: fontFamily,\n [`${prefix}-fontStyle`]: fontStyle,\n [`${prefix}-fontSize`]: fontSize,\n [`${prefix}-fontWeight`]: fontWeight,\n [`${prefix}-textTransform`]: textTransform,\n [`${prefix}-marginTop`]: marginTop,\n [`${prefix}-lineHeight`]: lineHeight,\n [`${prefix}-color`]: color,\n };\n};\n\n/**\n * Returns a string that defines css properties based on variables,\n * which can be used in a css`` template. The default properties are the\n * ones exposed for customization in the remote config interface.\n * @example\n * css`.widget-header { ${customizableTextCss(\"widget-header\")} border: none; }`\n * @returns {CSSResult}\n */\nexport const useCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n } = {}\n): CSSResult => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return unsafeCSS(`\\\n font-family: var(${prefix}-fontFamily, ${fontFamily});\n font-style: var(${prefix}-fontStyle, ${fontStyle});\n font-size: var(${prefix}-fontSize, ${fontSize});\n font-weight: var(${prefix}-fontWeight, ${fontWeight});\n text-transform: var(${prefix}-textTransform, ${textTransform});\n margin-top: var(${prefix}-marginTop, ${marginTop});\n line-height: var(${prefix}-lineHeight, ${lineHeight});\n color: var(${prefix}-color, ${color});\n `);\n};\n\n/**\n * Same as useCustomText except returns an object that can be passed to styleMap\n */\nexport const useCustomTextMap = (\n namespace = \"\",\n {\n fontSize = \"inherit\",\n fontStyle = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n fontSize: `var(${prefix}-fontSize, ${fontSize})`,\n fontStyle: `var(${prefix}-fontStyle, ${fontStyle})`,\n fontWeight: `var(${prefix}-fontWeight, ${fontWeight})`,\n textTransform: `var(${prefix}-textTransform, ${textTransform})`,\n marginTop: `var(${prefix}-marginTop, ${marginTop})`,\n lineHeight: `var(${prefix}-lineHeight, ${lineHeight})`,\n };\n};\n","import { MissingConfig } from \"./beam-errors\";\nimport { logger } from \"./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","import { LANGUAGES } from \"../api-sdk/types\";\nimport { logger } from \"./logger\";\nimport { BeamError } from \"./beam-errors\";\n\n/**\n * User-provided strings may include embedded translations in JSON form\n * This function extracts the string for the provided language\n * If it fails to parse, or the string is not json-like, it returns the whole string\n * TODO: consider returning unsafeHtml() or adding an option for it\n */\nconst localizeUserString = (lang: LANGUAGES, str: string): string => {\n const isJson = str.startsWith(\"{\");\n if (isJson) {\n try {\n const json = JSON.parse(str);\n return json[lang] ?? json[\"en\"] ?? str;\n } catch (err) {\n logger.error(new BeamError(\"Failed to extract JSON translation from string\"), str);\n return str;\n }\n }\n return str;\n};\n\nexport { localizeUserString };\n"],"names":["cssReset","css","defineCustomElement","CustomElementClass","tagName","_cssVariableMap","variables","k","v","AsyncController","host","asyncFn","args","err","strings","_errorMessage","error","retry","details","html","NetworkError","response","MissingConfig","_loading","defineCustomText","namespace","fontFamily","fontStyle","fontSize","fontWeight","textTransform","marginTop","lineHeight","color","prefix","useCustomText","unsafeCSS","enforceConfig","keys","input","missingKeys","check","key","logger","localizeUserString","lang","str","json","BeamError"],"mappings":"qKAIO,MAAMA,EAAWC,gaCDjB,SAASC,EACdC,EACAC,EAAUD,EAAmB,QAC7B,CACA,eAAe,IAAIC,CAAO,GAAK,eAAe,OAAOA,EAASD,CAAkB,CAClF,CCRO,MAAME,EAAmBC,GACvB,OAAO,QAAQA,CAAS,EAC5B,IAAI,CAAC,CAACC,EAAGC,CAAC,IAAM,GAAGD,CAAC,KAAKC,CAAC,GAAG,EAC7B,KAAK;AAAA,CAAI,ECwBP,MAAMC,CAAyE,CASpF,YAAYC,EAA8BC,EAAc,CARxD,KAAO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ACL,ECtEgB,SAAAI,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,IAAIjB,EAAckB,CAAW,EAErC,MAAO,EACT,CCNMI,MAAAA,EAAqB,CAACC,EAAiBC,IAAwB,CAEnE,GADeA,EAAI,WAAW,GAAG,EAE/B,GAAI,CACF,MAAMC,EAAO,KAAK,MAAMD,CAAG,EAC3B,OAAOC,EAAKF,CAAI,GAAKE,EAAK,IAASD,CACrC,MAAc,CACZ,OAAAH,EAAO,MAAM,IAAIK,EAAU,gDAAgD,EAAGF,CAAG,EAC1EA,CACT,CAEF,OAAOA,CACT"}
@@ -0,0 +1,2 @@
1
+ import{i as B}from"./lodash-ZxBiuGue.esm.js";import{a as u}from"./cookies-H8TCP4v0.esm.js";import{i as v,w as L}from"./network-listeners-O5LKv8Yy.esm.js";import{f as T,c as U,b as A}from"./events-wNy5BoJV.esm.js";import{c as C}from"./local-storage-GYvYzZ_j.esm.js";import{B as O}from"./cart-contents-h60geKWa.esm.js";import{L as f}from"./update-cart-qXTq0EoJ.esm.js";import"../components/post-purchase.esm.js";import{D as j}from"./routes-RQDFRUiD.esm.js";import{B as k}from"./beam-errors-AMvTvR1C.esm.js";const g=window.Shopify?.routes?.root||"/";let _=!1;const J="cart";async function K(e){if(_)return!1;const i=await w(e);await f(e,i.cart),v(),window.addEventListener(T.eventName,async c=>{const r=c,a=/cart\/(add|change|update|clear)/,o=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,m=new URL(o);if(!a.test(m.pathname))return;const n=await w(e);if(!n.changed)return;const l={schema:n.cart.schema,content:{items:n.cart.content.items}};window.dispatchEvent(new U(l)),await f(e,n.cart)});let s,d;return window.addEventListener(A.eventName,async c=>{const r=c,{selectedNonprofitId:a,selectionId:o}=r.detail,m=await u(J),n=await u(O),{chainId:l,storeId:p}=e;s===a&&d===o||(await E({selectedNonprofitId:a,selectionId:o,beamCartId:n,cartId:m,chainId:l,storeId:p}),d=o,s=a)}),_=!0,!0}async function w(e){const{token:i,total_price:s,item_count:d,currency:c,items:r}=await window.fetch(g+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()),a={cartId:i,subtotal:s/100,itemCount:d,currencyCode:c,schema:{source:"generic"},content:{items:r.map(({sku:n,final_line_price:l})=>({remoteProductIdentifier:n,localAmount:l}))}};let o=!1;const m=C(e).getItemJson("cart");return B(a,m)||(o=!0),{changed:o,cart:a}}const R=f;async function E({selectedNonprofitId:e,selectionId:i,beamCartId:s,cartId:d,chainId:c,storeId:r}){const a={beam:JSON.stringify({nonprofit_id:e,selection_id:i,beam_cart_id:s,shopify_cart_id:d,chain_id:c,store_id:r})};try{await window.fetch(g+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:a})})}catch(o){console.error(o)}}async function x({parentSelector:e=".step__sections",apiKey:i,baseUrl:s=j,storeId:d,postalCode:c,countryCode:r,orderId:a,email:o,cartTotal:m,cart:n,discountCodes:l,currencyCode:p="USD",lang:b="en",debug:N=!1}){const h=document.querySelector(e)||await L(e);if(!h)throw new k(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const I=await u("cart");if(I){const y=C({apiKey:i}),S=y.getItemJson("cart")||{};y.setItemJson("cart",{...S,cartId:I})}const t=document.createElement("beam-post-purchase");t.apiKey=i,t.baseUrl=s,t.storeId=d,t.postalCode=c,t.countryCode=r,t.orderId=String(a),t.email=o,t.cartTotal=m,t.cart=n,t.discountCodes=l,t.currencyCode=p,t.lang=b,t.debug=N,h.appendChild(t)}export{K as B,w as C,R as N,E as h,x as s};
2
+ //# sourceMappingURL=order-page-8P0D98JI.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-page-8P0D98JI.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { getCookieValue } from \"../../shared/cookies\";\nimport { initNetworkListeners } from \"../../shared/network-listeners\";\nimport { BeamCartChangeEvent, BeamNetworkCallEvent, BeamNonprofitSelectEvent } from \"../../shared/events\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TCart, TCartApi, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\n\ntype BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n const currentCart = await getCurrentCart(config);\n await updateCart(config, currentCart.cart);\n\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n return;\n }\n const eventDetail: TCartApi = {\n schema: currentCart.cart.schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: currentCart.cart.content.items as any,\n },\n };\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n await updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n const { selectedNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME); // Shopify cart ID cookie\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME); // Beam cart ID cookie\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n });\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n } = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n\n const cart = {\n cartId: token,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price }) => {\n return { remoteProductIdentifier: sku, localAmount: final_line_price };\n }),\n },\n };\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n const cachedCart = localStorage.getItemJson(\"cart\");\n\n if (!isEqual(cart, cachedCart)) {\n changed = true;\n }\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/** Sends Beam data to Shopify to integrate with order as custom attributes */\nasync function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n console.error(err); // don't throw, allow later calls to continue\n }\n}\n\nexport { trackCart, getCurrentCart, addBeamAttributesToCart, registerCartIntegration };\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../shared/wait-for-element\";\nimport { BeamError } from \"../../shared/beam-errors\";\nimport { getCookieValue } from \"../../shared/cookies\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","currentCart","getCurrentCart","updateCart","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","eventDetail","BeamCartChangeEvent","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","selectedNonprofitId","selectionId","cartId","getCookieValue","beamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","addBeamAttributesToCart","token","total_price","item_count","currency","items","res","cart","sku","final_line_price","changed","cachedCart","createScopedLocalStorage","isEqual","trackCart","beamCartAttrs","err","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","lang","debug","parentElement","waitForElement","BeamError","beamLocalStorage","existingValue","widget"],"mappings":"yfAcA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKT,MAAMI,EAAc,MAAMC,EAAeF,CAAM,EAC/C,MAAMG,EAAWH,EAAQC,EAAY,IAAI,EAGzCG,EAEA,EAAA,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,MAAMC,EAAQD,EACRE,EAAkB,kCAElBC,EAAgBF,EAAM,OAAO,OAAS,MAAQA,EAAM,OAAO,IAAI,YAAcA,EAAM,OAAO,SAAS,IACnGG,EAAM,IAAI,IAAID,CAAa,EACjC,GAAI,CAACD,EAAgB,KAAKE,EAAI,QAAQ,EACpC,OAEF,MAAMT,EAAc,MAAMC,EAAeF,CAAM,EAC/C,GAAI,CAACC,EAAY,QACf,OAEF,MAAM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AASjB,EAChBiB,EAAO,QAAUhB,EACjBgB,EAAO,QAAUrC,EACjBqC,EAAO,WAAad,EACpBc,EAAO,YAAcb,EACrBa,EAAO,QAAU,OAAOZ,CAAO,EAC/BY,EAAO,MAAQX,EACfW,EAAO,UAAYV,EACnBU,EAAO,KAAO7B,EACd6B,EAAO,cAAgBT,EACvBS,EAAO,aAAeR,EACtBQ,EAAO,KAAOP,EACdO,EAAO,MAAQN,EAGfC,EAAc,YAAYK,CAAM,CAClC"}
@@ -0,0 +1,2 @@
1
+ import{i as B}from"./lodash-ZxBiuGue.esm.js";import{a as u}from"./cookies-H8TCP4v0.esm.js";import{i as v,w as L}from"./network-listeners-O5LKv8Yy.esm.js";import{f as T,c as U,b as A}from"./events-wNy5BoJV.esm.js";import{c as C}from"./local-storage-GYvYzZ_j.esm.js";import{B as O}from"./cart-contents-h60geKWa.esm.js";import{L as f}from"./update-cart-qXTq0EoJ.esm.js";import"../components/post-purchase.js";import{D as j}from"./routes-RQDFRUiD.esm.js";import{B as k}from"./beam-errors-AMvTvR1C.esm.js";const g=window.Shopify?.routes?.root||"/";let _=!1;const J="cart";async function K(e){if(_)return!1;const i=await w(e);await f(e,i.cart),v(),window.addEventListener(T.eventName,async c=>{const r=c,a=/cart\/(add|change|update|clear)/,o=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,m=new URL(o);if(!a.test(m.pathname))return;const n=await w(e);if(!n.changed)return;const l={schema:n.cart.schema,content:{items:n.cart.content.items}};window.dispatchEvent(new U(l)),await f(e,n.cart)});let s,d;return window.addEventListener(A.eventName,async c=>{const r=c,{selectedNonprofitId:a,selectionId:o}=r.detail,m=await u(J),n=await u(O),{chainId:l,storeId:p}=e;s===a&&d===o||(await E({selectedNonprofitId:a,selectionId:o,beamCartId:n,cartId:m,chainId:l,storeId:p}),d=o,s=a)}),_=!0,!0}async function w(e){const{token:i,total_price:s,item_count:d,currency:c,items:r}=await window.fetch(g+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()),a={cartId:i,subtotal:s/100,itemCount:d,currencyCode:c,schema:{source:"generic"},content:{items:r.map(({sku:n,final_line_price:l})=>({remoteProductIdentifier:n,localAmount:l}))}};let o=!1;const m=C(e).getItemJson("cart");return B(a,m)||(o=!0),{changed:o,cart:a}}const R=f;async function E({selectedNonprofitId:e,selectionId:i,beamCartId:s,cartId:d,chainId:c,storeId:r}){const a={beam:JSON.stringify({nonprofit_id:e,selection_id:i,beam_cart_id:s,shopify_cart_id:d,chain_id:c,store_id:r})};try{await window.fetch(g+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:a})})}catch(o){console.error(o)}}async function x({parentSelector:e=".step__sections",apiKey:i,baseUrl:s=j,storeId:d,postalCode:c,countryCode:r,orderId:a,email:o,cartTotal:m,cart:n,discountCodes:l,currencyCode:p="USD",lang:b="en",debug:N=!1}){const h=document.querySelector(e)||await L(e);if(!h)throw new k(`Timed out waiting for selector '${e}'. Could not render Beam post-purchase widget.`);const I=await u("cart");if(I){const y=C({apiKey:i}),S=y.getItemJson("cart")||{};y.setItemJson("cart",{...S,cartId:I})}const t=document.createElement("beam-post-purchase");t.apiKey=i,t.baseUrl=s,t.storeId=d,t.postalCode=c,t.countryCode=r,t.orderId=String(a),t.email=o,t.cartTotal=m,t.cart=n,t.discountCodes=l,t.currencyCode=p,t.lang=b,t.debug=N,h.appendChild(t)}export{K as B,w as C,R as N,E as h,x as s};
2
+ //# sourceMappingURL=order-page-cWc57Sl-.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-page-cWc57Sl-.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { getCookieValue } from \"../../shared/cookies\";\nimport { initNetworkListeners } from \"../../shared/network-listeners\";\nimport { BeamCartChangeEvent, BeamNetworkCallEvent, BeamNonprofitSelectEvent } from \"../../shared/events\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TCart, TCartApi, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\n\ntype BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n const currentCart = await getCurrentCart(config);\n await updateCart(config, currentCart.cart);\n\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n return;\n }\n const eventDetail: TCartApi = {\n schema: currentCart.cart.schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: currentCart.cart.content.items as any,\n },\n };\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n await updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n const { selectedNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME); // Shopify cart ID cookie\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME); // Beam cart ID cookie\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n });\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n } = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n\n const cart = {\n cartId: token,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price }) => {\n return { remoteProductIdentifier: sku, localAmount: final_line_price };\n }),\n },\n };\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n const cachedCart = localStorage.getItemJson(\"cart\");\n\n if (!isEqual(cart, cachedCart)) {\n changed = true;\n }\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/** Sends Beam data to Shopify to integrate with order as custom attributes */\nasync function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n console.error(err); // don't throw, allow later calls to continue\n }\n}\n\nexport { trackCart, getCurrentCart, addBeamAttributesToCart, registerCartIntegration };\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../shared/wait-for-element\";\nimport { BeamError } from \"../../shared/beam-errors\";\nimport { getCookieValue } from \"../../shared/cookies\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","currentCart","getCurrentCart","updateCart","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","eventDetail","BeamCartChangeEvent","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","selectedNonprofitId","selectionId","cartId","getCookieValue","beamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","addBeamAttributesToCart","token","total_price","item_count","currency","items","res","cart","sku","final_line_price","changed","cachedCart","createScopedLocalStorage","isEqual","trackCart","beamCartAttrs","err","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","lang","debug","parentElement","waitForElement","BeamError","beamLocalStorage","existingValue","widget"],"mappings":"qfAcA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKT,MAAMI,EAAc,MAAMC,EAAeF,CAAM,EAC/C,MAAMG,EAAWH,EAAQC,EAAY,IAAI,EAGzCG,EAEA,EAAA,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,MAAMC,EAAQD,EACRE,EAAkB,kCAElBC,EAAgBF,EAAM,OAAO,OAAS,MAAQA,EAAM,OAAO,IAAI,YAAcA,EAAM,OAAO,SAAS,IACnGG,EAAM,IAAI,IAAID,CAAa,EACjC,GAAI,CAACD,EAAgB,KAAKE,EAAI,QAAQ,EACpC,OAEF,MAAMT,EAAc,MAAMC,EAAeF,CAAM,EAC/C,GAAI,CAACC,EAAY,QACf,OAEF,MAAMU,EAAwB,CAC5B,OAAQV,EAAY,KAAK,OACzB,QAAS,CACP,MAAOA,EAAY,KAAK,QAAQ,KAClC,CACF,EACA,OAAO,cAAc,IAAIW,EAAoBD,CAAW,CAAC,EAEzD,MAAMR,EAAWH,EAAQC,EAAY,IAAI,CAC3C,CAAC,EAGD,IAAIY,EACAC,EACJ,cAAO,iBAAiBC,EAAyB,UAAW,MAAOT,GAAW,CAC5E,MAAMC,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,EAGfC,EAAc,YAAYK,CAAM,CAClC"}
@@ -1,2 +1,2 @@
1
- import{B as E,N as h}from"./beam-errors-AMvTvR1C.esm.js";const c="\u{1F308} Beam:",p={error:(...e)=>console.error(c,...e),log:(...e)=>console.log(c,...e),warn:(...e)=>console.warn(c,...e),debug:(...e)=>console.debug(c,...e)};var C="1.31.2",O={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.11.2",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function v(e,s){const l={method:"GET",...s,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":C,...s?.headers},preflightContinue:!0,mode:s?.mode||"cors",body:s?.body!=null?s.body:void 0};let r;try{r=await fetch(e,l)}catch(t){const o=new E(`Network call failed (${l?.method.toUpperCase()} ${e})`);throw o.cause=t,p.error(o,e),o}let n,i;try{i=await r.text(),i&&(n=JSON.parse(i))}catch(t){let o=t;throw t instanceof SyntaxError&&(o=new h(r,n,`Response invalid. Expected JSON. Received: "${i}"`),o.cause=t),p.error(o),o}if(!r.ok){const t=new h(r,n,"Response was not OK");throw p.error(t),t}return n}const m="https://production-central-backend-ne.beamimpact.com",U="https://production.beamimpactlogs.com",L={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},a=(e,s,l)=>({[e]:async function({headers:r={},baseUrl:n=m,apiRoot:i="/api/v3",pathParams:t={},queryParams:o={},requestBody:u}){const f=Object.entries(t).reduce((b,[w,N])=>b.replace(`{${w}}`,N),e),g=JSON.parse(JSON.stringify(o)),d=new URLSearchParams(g).toString(),y=n+i+f+(d&&`?${d}`),S={headers:r,method:s,body:JSON.stringify(u)};return v(y,S)}})[e],R=a("/chain/{chainId}/nonprofits","get"),T=a("/impact","get"),k=a("/chain/{chainId}/cumulativeImpact","get"),A=a("/selectNonprofit","post"),B=a("/transaction","post"),x=a("/transaction/{transactionId}","put"),I=a("/cart","post"),J=a("/chain/findEligibleNonprofitsForCart","post"),D=a("/logs","post"),F=a("/experimentSession","post");export{m as D,L as S,I as a,U as b,D as c,B as d,T as e,J as f,R as g,A as h,x as i,k as j,O as k,p as l,F as p};
2
- //# sourceMappingURL=routes-5ojB8NiU.esm.js.map
1
+ import{B as E,N as h}from"./beam-errors-AMvTvR1C.esm.js";const c="\u{1F308} Beam:",p={error:(...e)=>console.error(c,...e),log:(...e)=>console.log(c,...e),warn:(...e)=>console.warn(c,...e),debug:(...e)=>console.debug(c,...e)};var C="1.31.4",O={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.11.2",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function v(e,s){const l={method:"GET",...s,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":C,...s?.headers},preflightContinue:!0,mode:s?.mode||"cors",body:s?.body!=null?s.body:void 0};let r;try{r=await fetch(e,l)}catch(t){const o=new E(`Network call failed (${l?.method.toUpperCase()} ${e})`);throw o.cause=t,p.error(o,e),o}let n,i;try{i=await r.text(),i&&(n=JSON.parse(i))}catch(t){let o=t;throw t instanceof SyntaxError&&(o=new h(r,n,`Response invalid. Expected JSON. Received: "${i}"`),o.cause=t),p.error(o),o}if(!r.ok){const t=new h(r,n,"Response was not OK");throw p.error(t),t}return n}const m="https://production-central-backend-ne.beamimpact.com",U="https://production.beamimpactlogs.com",L={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},a=(e,s,l)=>({[e]:async function({headers:r={},baseUrl:n=m,apiRoot:i="/api/v3",pathParams:t={},queryParams:o={},requestBody:u}){const f=Object.entries(t).reduce((b,[w,N])=>b.replace(`{${w}}`,N),e),g=JSON.parse(JSON.stringify(o)),d=new URLSearchParams(g).toString(),y=n+i+f+(d&&`?${d}`),S={headers:r,method:s,body:JSON.stringify(u)};return v(y,S)}})[e],R=a("/chain/{chainId}/nonprofits","get"),T=a("/impact","get"),k=a("/chain/{chainId}/cumulativeImpact","get"),A=a("/selectNonprofit","post"),B=a("/transaction","post"),x=a("/transaction/{transactionId}","put"),I=a("/cart","post"),J=a("/chain/findEligibleNonprofitsForCart","post"),D=a("/logs","post"),F=a("/experimentSession","post");export{m as D,L as S,I as a,U as b,D as c,B as d,T as e,J as f,R as g,A as h,x as i,k as j,O as k,p as l,F as p};
2
+ //# sourceMappingURL=routes-RQDFRUiD.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes-5ojB8NiU.esm.js","sources":["../../src/shared/logger.ts","../../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":["const LOG_PREFIX = \"🌈 Beam:\";\n\n// This may eventually log output to Beam servers, control log verbosity, etc.\n// For now it is an alias of the default JS console\nexport const logger = {\n error: (...args: any[]) => console.error(LOG_PREFIX, ...args),\n log: (...args: any[]) => console.log(LOG_PREFIX, ...args),\n warn: (...args: any[]) => console.warn(LOG_PREFIX, ...args),\n debug: (...args: any[]) => console.debug(LOG_PREFIX, ...args),\n};\n","/**\n * Wrapper over window.fetch that expects/returns JSON\n */\nimport { BeamError, NetworkError } from \"../shared/beam-errors\";\nimport { logger } from \"../shared/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://production-central-backend-ne.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","/* 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"],"names":["LOG_PREFIX","logger","args","fetchJson","url","options","fetchOptions","pkgVersion","response","err","error","BeamError","body","text","NetworkError","DEFAULT_BASE_URL","DEFAULT_LOG_URL","SUPPORTED_LANGUAGES","makeOpenApiMethod","pathName","method","okHttpStatus","headers","baseUrl","apiRoot","pathParams","queryParams","requestBody","pathWithParams","newPath","k","v","cleanQueryParams","search","getChainNonprofits","getImpact","getCumulativeImpact","postSelectNonprofit","postTransaction","putTransaction","postCart","postChainEligibleNonprofitsForCart","postLogs","postExperimentSession"],"mappings":"yDAAA,MAAMA,EAAa,kBAINC,EAAS,CACpB,MAAO,IAAIC,IAAgB,QAAQ,MAAMF,EAAY,GAAGE,CAAI,EAC5D,IAAK,IAAIA,IAAgB,QAAQ,IAAIF,EAAY,GAAGE,CAAI,EACxD,KAAM,IAAIA,IAAgB,QAAQ,KAAKF,EAAY,GAAGE,CAAI,EAC1D,MAAO,IAAIA,IAAgB,QAAQ,MAAMF,EAAY,GAAGE,CAAI,CAC9D,iKCFA,eAAsBC,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,EACdR,EAAO,MAAMS,EAAON,CAAG,EACjBM,CAC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hB,EAAkB,8BAA+B,KAAU,EAEhFiB,EAAYjB,EAAkB,UAAW,KAAU,EAEnDkB,EAAsBlB,EAAkB,oCAAqC,KAAU,EAEvFmB,EAAsBnB,EAAkB,mBAAoB,MAAW,EAEvEoB,EAAkBpB,EAAkB,eAAgB,MAAW,EAE/DqB,EAAiBrB,EAAkB,+BAAgC,KAAU,EAE7EsB,EAAWtB,EAAkB,QAAS,MAAW,EAEjDuB,EAAqCvB,EAChD,uCACA,MAEF,EAEawB,EAAWxB,EAAkB,QAAS,MAAW,EAEjDyB,EAAwBzB,EAAkB,qBAAsB,MAAW"}
1
+ {"version":3,"file":"routes-RQDFRUiD.esm.js","sources":["../../src/shared/logger.ts","../../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":["const LOG_PREFIX = \"🌈 Beam:\";\n\n// This may eventually log output to Beam servers, control log verbosity, etc.\n// For now it is an alias of the default JS console\nexport const logger = {\n error: (...args: any[]) => console.error(LOG_PREFIX, ...args),\n log: (...args: any[]) => console.log(LOG_PREFIX, ...args),\n warn: (...args: any[]) => console.warn(LOG_PREFIX, ...args),\n debug: (...args: any[]) => console.debug(LOG_PREFIX, ...args),\n};\n","/**\n * Wrapper over window.fetch that expects/returns JSON\n */\nimport { BeamError, NetworkError } from \"../shared/beam-errors\";\nimport { logger } from \"../shared/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://production-central-backend-ne.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","/* 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"],"names":["LOG_PREFIX","logger","args","fetchJson","url","options","fetchOptions","pkgVersion","response","err","error","BeamError","body","text","NetworkError","DEFAULT_BASE_URL","DEFAULT_LOG_URL","SUPPORTED_LANGUAGES","makeOpenApiMethod","pathName","method","okHttpStatus","headers","baseUrl","apiRoot","pathParams","queryParams","requestBody","pathWithParams","newPath","k","v","cleanQueryParams","search","getChainNonprofits","getImpact","getCumulativeImpact","postSelectNonprofit","postTransaction","putTransaction","postCart","postChainEligibleNonprofitsForCart","postLogs","postExperimentSession"],"mappings":"yDAAA,MAAMA,EAAa,kBAINC,EAAS,CACpB,MAAO,IAAIC,IAAgB,QAAQ,MAAMF,EAAY,GAAGE,CAAI,EAC5D,IAAK,IAAIA,IAAgB,QAAQ,IAAIF,EAAY,GAAGE,CAAI,EACxD,KAAM,IAAIA,IAAgB,QAAQ,KAAKF,EAAY,GAAGE,CAAI,EAC1D,MAAO,IAAIA,IAAgB,QAAQ,MAAMF,EAAY,GAAGE,CAAI,CAC9D,iKCFA,eAAsBC,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,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UO,CAAW,CAAE,EAE5F,OAAOxB,EAAuBC,EAAKC,CAAO,CAC5C,CACF,GAGec,CAAQ,ECzDZe,EAAqBhB,EAAkB,8BAA+B,KAAU,EAEhFiB,EAAYjB,EAAkB,UAAW,KAAU,EAEnDkB,EAAsBlB,EAAkB,oCAAqC,KAAU,EAEvFmB,EAAsBnB,EAAkB,mBAAoB,MAAW,EAEvEoB,EAAkBpB,EAAkB,eAAgB,MAAW,EAE/DqB,EAAiBrB,EAAkB,+BAAgC,KAAU,EAE7EsB,EAAWtB,EAAkB,QAAS,MAAW,EAEjDuB,EAAqCvB,EAChD,uCACA,MAEF,EAEawB,EAAWxB,EAAkB,QAAS,MAAW,EAEjDyB,EAAwBzB,EAAkB,qBAAsB,MAAW"}
@@ -1,2 +1,2 @@
1
- import{i as y}from"./lodash-ZxBiuGue.esm.js";import{D as B,a as E}from"./routes-5ojB8NiU.esm.js";import{B as g}from"./beam-errors-AMvTvR1C.esm.js";import{B as l}from"./cart-contents-h60geKWa.esm.js";import{a as A,s as v}from"./cookies-BnIoXWd0.esm.js";import{c as K,B as S}from"./events-wNy5BoJV.esm.js";import{c as _}from"./local-storage-GYvYzZ_j.esm.js";import{g as L}from"./remote-session-V4YG-mcS.esm.js";async function U(e,c){try{const t=_({apiKey:e.apiKey}),w=e.baseUrl??B,a=t.getItemJson("cart"),o=await A(l)??null,b=L(e)??void 0,{cartId:r,subtotal:s,itemCount:i,currencyCode:n,content:{items:d=[]}={},schema:u={source:"generic"}}=c,C={cartId:r,subtotal:s,itemCount:i,currencyCode:n,content:{items:d},schema:u,beamCartId:o};if(y(C,{...a,cartId:a?.cartId})||c.itemCount===0&&(!o||a?.itemCount===0))return;const f=await E({baseUrl:w,headers:{authorization:`Api-Key ${e.apiKey}`},requestBody:{beamCartId:o,storeId:e.storeId,remoteSessionId:b,cartId:r,subtotal:s,itemCount:i,currencyCode:n}}),{beamCartId:m,expiresAt:p,beamCartCreated:h}=f;m&&p&&await v({name:l,domain:e.domain,value:m,path:"/",expires:new Date(p).getTime()}),t.setItemJson("cart",{...C,beamCartId:m});const I={schema:u,content:{items:d},subtotal:s,itemCount:i,currencyCode:n,cartId:r};window.dispatchEvent(new K(I)),h&&window.dispatchEvent(new S(I))}catch(t){throw new g("Could not update cart in Beam",{cause:t})}}export{U as L};
2
- //# sourceMappingURL=update-cart-Lmma11Zd.esm.js.map
1
+ import{i as y}from"./lodash-ZxBiuGue.esm.js";import{D as B,a as E}from"./routes-RQDFRUiD.esm.js";import{B as g}from"./beam-errors-AMvTvR1C.esm.js";import{B as l}from"./cart-contents-h60geKWa.esm.js";import{a as A,s as v}from"./cookies-H8TCP4v0.esm.js";import{c as K,B as S}from"./events-wNy5BoJV.esm.js";import{c as _}from"./local-storage-GYvYzZ_j.esm.js";import{g as L}from"./remote-session-V4YG-mcS.esm.js";async function U(e,c){try{const t=_({apiKey:e.apiKey}),w=e.baseUrl??B,a=t.getItemJson("cart"),o=await A(l)??null,b=L(e)??void 0,{cartId:r,subtotal:s,itemCount:i,currencyCode:n,content:{items:d=[]}={},schema:u={source:"generic"}}=c,C={cartId:r,subtotal:s,itemCount:i,currencyCode:n,content:{items:d},schema:u,beamCartId:o};if(y(C,{...a,cartId:a?.cartId})||c.itemCount===0&&(!o||a?.itemCount===0))return;const f=await E({baseUrl:w,headers:{authorization:`Api-Key ${e.apiKey}`},requestBody:{beamCartId:o,storeId:e.storeId,remoteSessionId:b,cartId:r,subtotal:s,itemCount:i,currencyCode:n}}),{beamCartId:m,expiresAt:p,beamCartCreated:h}=f;m&&p&&await v({name:l,domain:e.domain,value:m,path:"/",expires:new Date(p).getTime()}),t.setItemJson("cart",{...C,beamCartId:m});const I={schema:u,content:{items:d},subtotal:s,itemCount:i,currencyCode:n,cartId:r};window.dispatchEvent(new K(I)),h&&window.dispatchEvent(new S(I))}catch(t){throw new g("Could not update cart in Beam",{cause:t})}}export{U as L};
2
+ //# sourceMappingURL=update-cart-qXTq0EoJ.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-cart-Lmma11Zd.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 { BeamError } from \"../../shared/beam-errors\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCartApi } from \"../../shared/cart-contents\";\nimport { getCookieValue, setCookieValue } from \"../../shared/cookies\";\nimport { BeamCartChangeEvent, BeamCartCreatedEvent } from \"../../shared/events\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\nimport { getRemoteSession } from \"../../shared/remote-session\";\n\nexport type BeamCartAPIConfig = BeamBaseAPIConfig & {\n storeId: number;\n domain?: string; // Domain to set cookies on\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 * Sends cart information to Beam\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 * */\nasync function updateCart(config: BeamCartAPIConfig, cartValues: BeamCartValues) {\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 = (await getCookieValue(BEAM_CART_COOKIE_NAME)) ?? null;\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 = [] } = {},\n schema = { source: \"generic\" },\n } = cartValues;\n\n const cartWithDefaults = {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items },\n schema,\n beamCartId,\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\n // 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 return;\n }\n\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 },\n subtotal,\n itemCount,\n currencyCode,\n cartId,\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\nexport { updateCart };\n"],"names":["updateCart","config","cartValues","localStorage","createScopedLocalStorage","baseUrl","DEFAULT_BASE_URL","cachedCart","beamCartId","getCookieValue","BEAM_CART_COOKIE_NAME","remoteSessionId","getRemoteSession","cartId","subtotal","itemCount","currencyCode","items","schema","cartWithDefaults","isEqual","response","postCart","newBeamCartId","expiresAt","beamCartCreated","setCookieValue","eventDetail","BeamCartChangeEvent","BeamCartCreatedEvent","err","BeamError"],"mappings":"yZA8BA,eAAeA,EAAWC,EAA2BC,EAA4B,CAC/E,GAAI,CACF,MAAMC,EAAeC,EAAyB,CAAE,OAAQH,EAAO,MAAO,CAAC,EACjEI,EAAUJ,EAAO,SAAWK,EAG5BC,EAA2CJ,EAAa,YAAY,MAAM,EAG1EK,EAA6B,MAAMC,EAAeC,CAAqB,GAAM,KAE7EC,EAAsCC,EAAiBX,CAAM,GAAK,OAElE,CACJ,OAAAY,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,EAAQ,EAAG,EAAI,GAC1B,OAAAC,EAAS,CAAE,OAAQ,SAAU,CAC/B,EAAIhB,EAEEiB,EAAmB,CACvB,OAAAN,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,CAAM,EACjB,OAAAC,EACA,WAAAV,CACF,EAKA,GACEY,EAAQD,EAAkB,CACxB,GAAGZ,EACH,OAAQA,GAAY,MACtB,CAAC,GAEAL,EAAW,YAAc,IACvB,CAACM,GAAcD,GAAY,YAAc,GAE5C,OAGF,MAAMc,EAAW,MAAMC,EAAS,CAC9B,QAAAjB,EACA,QAAS,CACP,cAAe,WAAWJ,EAAO,MAAM,EACzC,EACA,YAAa,CACX,WAAAO,EACA,QAASP,EAAO,QAChB,gBAAAU,EACA,OAAAE,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,CACF,CACF,CAAC,EAGK,CAAE,WAAYO,EAAe,UAAAC,EAAW,gBAAAC,CAAgB,EAAIJ,EAE9DE,GAAiBC,GACnB,MAAME,EAAe,CACnB,KAAMhB,EACN,OAAQT,EAAO,OACf,MAAOsB,EACP,KAAM,IAEN,QAAS,IAAI,KAAKC,CAAS,EAAE,QAC/B,CAAA,CAAC,EAGHrB,EAAa,YAAY,OAAQ,CAC/B,GAAGgB,EACH,WAAYI,CACd,CAAC,EAED,MAAMI,EAAc,CAClB,OAAQT,EACR,QAAS,CACP,MAAOD,CACT,EACA,SAAAH,EACA,UAAAC,EACA,aAAAC,EACA,OAAAH,CACF,EAGA,OAAO,cAAc,IAAIe,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"}
1
+ {"version":3,"file":"update-cart-qXTq0EoJ.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 { BeamError } from \"../../shared/beam-errors\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCartApi } from \"../../shared/cart-contents\";\nimport { getCookieValue, setCookieValue } from \"../../shared/cookies\";\nimport { BeamCartChangeEvent, BeamCartCreatedEvent } from \"../../shared/events\";\nimport { createScopedLocalStorage } from \"../../shared/local-storage\";\nimport { getRemoteSession } from \"../../shared/remote-session\";\n\nexport type BeamCartAPIConfig = BeamBaseAPIConfig & {\n storeId: number;\n domain?: string; // Domain to set cookies on\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 * Sends cart information to Beam\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 * */\nasync function updateCart(config: BeamCartAPIConfig, cartValues: BeamCartValues) {\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 = (await getCookieValue(BEAM_CART_COOKIE_NAME)) ?? null;\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 = [] } = {},\n schema = { source: \"generic\" },\n } = cartValues;\n\n const cartWithDefaults = {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items },\n schema,\n beamCartId,\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\n // 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 return;\n }\n\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 },\n subtotal,\n itemCount,\n currencyCode,\n cartId,\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\nexport { updateCart };\n"],"names":["updateCart","config","cartValues","localStorage","createScopedLocalStorage","baseUrl","DEFAULT_BASE_URL","cachedCart","beamCartId","getCookieValue","BEAM_CART_COOKIE_NAME","remoteSessionId","getRemoteSession","cartId","subtotal","itemCount","currencyCode","items","schema","cartWithDefaults","isEqual","response","postCart","newBeamCartId","expiresAt","beamCartCreated","setCookieValue","eventDetail","BeamCartChangeEvent","BeamCartCreatedEvent","err","BeamError"],"mappings":"yZA8BA,eAAeA,EAAWC,EAA2BC,EAA4B,CAC/E,GAAI,CACF,MAAMC,EAAeC,EAAyB,CAAE,OAAQH,EAAO,MAAO,CAAC,EACjEI,EAAUJ,EAAO,SAAWK,EAG5BC,EAA2CJ,EAAa,YAAY,MAAM,EAG1EK,EAA6B,MAAMC,EAAeC,CAAqB,GAAM,KAE7EC,EAAsCC,EAAiBX,CAAM,GAAK,OAElE,CACJ,OAAAY,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,EAAQ,EAAG,EAAI,GAC1B,OAAAC,EAAS,CAAE,OAAQ,SAAU,CAC/B,EAAIhB,EAEEiB,EAAmB,CACvB,OAAAN,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,CAAM,EACjB,OAAAC,EACA,WAAAV,CACF,EAKA,GACEY,EAAQD,EAAkB,CACxB,GAAGZ,EACH,OAAQA,GAAY,MACtB,CAAC,GAEAL,EAAW,YAAc,IACvB,CAACM,GAAcD,GAAY,YAAc,GAE5C,OAGF,MAAMc,EAAW,MAAMC,EAAS,CAC9B,QAAAjB,EACA,QAAS,CACP,cAAe,WAAWJ,EAAO,MAAM,EACzC,EACA,YAAa,CACX,WAAAO,EACA,QAASP,EAAO,QAChB,gBAAAU,EACA,OAAAE,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,CACF,CACF,CAAC,EAGK,CAAE,WAAYO,EAAe,UAAAC,EAAW,gBAAAC,CAAgB,EAAIJ,EAE9DE,GAAiBC,GACnB,MAAME,EAAe,CACnB,KAAMhB,EACN,OAAQT,EAAO,OACf,MAAOsB,EACP,KAAM,IAEN,QAAS,IAAI,KAAKC,CAAS,EAAE,QAC/B,CAAA,CAAC,EAGHrB,EAAa,YAAY,OAAQ,CAC/B,GAAGgB,EACH,WAAYI,CACd,CAAC,EAED,MAAMI,EAAc,CAClB,OAAQT,EACR,QAAS,CACP,MAAOD,CACT,EACA,SAAAH,EACA,UAAAC,EACA,aAAAC,EACA,OAAAH,CACF,EAGA,OAAO,cAAc,IAAIe,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"}
@@ -1,4 +1,4 @@
1
- import{h as x,f as g,t as I,g as v,y as p,k as b,m as u}from"../chunks/lit-h1W25hjN.esm.js";import{p as $}from"../chunks/progress-bar-w3yfrrxD.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.esm.js";import{c as k,u as n,d as w,e as S,A,i as c,a as L,_ as C,b as m,f as z}from"../chunks/localize-Vmeu1g_0.esm.js";import{D as F,e as D,S as M}from"../chunks/routes-5ojB8NiU.esm.js";import{B as U}from"../chunks/beam-errors-AMvTvR1C.esm.js";import{c as f}from"../chunks/css-card-grid-RRkoiUTl.esm.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var E=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&E(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=F,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),D({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:"community-impact",version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
1
+ import{h as x,f as g,t as I,g as v,y as p,k as b,m as u}from"../chunks/lit-h1W25hjN.esm.js";import{p as $}from"../chunks/progress-bar-w3yfrrxD.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.esm.js";import{c as k,u as n,d as w,e as S,A,i as c,a as L,_ as C,b as m,f as z}from"../chunks/localize-z-KGe7Y5.esm.js";import{D as F,e as D,S as M}from"../chunks/routes-RQDFRUiD.esm.js";import{B as U}from"../chunks/beam-errors-AMvTvR1C.esm.js";import{c as f}from"../chunks/css-card-grid-RRkoiUTl.esm.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var E=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&E(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=F,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),D({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:"community-impact",version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
2
2
  <div class="image-card" part="nonprofit-card" style="display: flex; flex-direction: column;">
3
3
  <div class="image-card-image-box" style="background-image: url('${a.imageUrl}');">
4
4
  <p class="image-card-cause">${c(this.configLang,a.nonprofit?.cause||"")}</p>
@@ -1,4 +1,4 @@
1
- import{h as x,f as g,t as I,g as v,y as p,k as b,m as u}from"../chunks/lit-h1W25hjN.esm.js";import{p as $}from"../chunks/progress-bar-w3yfrrxD.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.js";import{c as k,u as n,d as w,e as S,A,i as c,a as L,_ as C,b as m,f as z}from"../chunks/localize-Vmeu1g_0.esm.js";import{D as F,e as D,S as M}from"../chunks/routes-5ojB8NiU.esm.js";import{B as U}from"../chunks/beam-errors-AMvTvR1C.esm.js";import{c as f}from"../chunks/css-card-grid-RRkoiUTl.esm.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var E=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&E(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=F,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),D({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:"community-impact",version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
1
+ import{h as x,f as g,t as I,g as v,y as p,k as b,m as u}from"../chunks/lit-h1W25hjN.esm.js";import{p as $}from"../chunks/progress-bar-w3yfrrxD.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.js";import{c as k,u as n,d as w,e as S,A,i as c,a as L,_ as C,b as m,f as z}from"../chunks/localize-z-KGe7Y5.esm.js";import{D as F,e as D,S as M}from"../chunks/routes-RQDFRUiD.esm.js";import{B as U}from"../chunks/beam-errors-AMvTvR1C.esm.js";import{c as f}from"../chunks/css-card-grid-RRkoiUTl.esm.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var E=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&E(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=F,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),D({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:"community-impact",version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
2
2
  <div class="image-card" part="nonprofit-card" style="display: flex; flex-direction: column;">
3
3
  <div class="image-card-image-box" style="background-image: url('${a.imageUrl}');">
4
4
  <p class="image-card-cause">${c(this.configLang,a.nonprofit?.cause||"")}</p>
@@ -1,4 +1,4 @@
1
- import{t as y,g as b,y as u,f as c,h as C,u as I}from"../chunks/lit-h1W25hjN.esm.js";import{d as x}from"../chunks/lodash-ZxBiuGue.esm.js";import{c as T,u as p,d as S,e as E,A as z,a as B,_ as f,i as d,b as v,f as D}from"../chunks/localize-Vmeu1g_0.esm.js";import{D as L,j as $,S as k}from"../chunks/routes-5ojB8NiU.esm.js";import{B as V}from"../chunks/beam-errors-AMvTvR1C.esm.js";import{i as j}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";var A=Object.defineProperty,R=Object.getOwnPropertyDescriptor,h=(n,e,t,a)=>{for(var i=a>1?void 0:a?R(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&A(e,t,i),i};class m extends b{constructor(){super(...arguments),this.finalValue=0,this.duration=1500,this.counter=0,this.intervalId=0,this.handleCounterAnimateIfInView=e=>{e.some(t=>t.isIntersecting)&&(this.animateCounter(),this.unobserveScrollTarget())},this.animateCounter=()=>{const e=41.666666666666664,t=e/this.duration*this.finalValue;this.intervalId=setInterval(()=>{const a=this.counter+t;if(a>=this.finalValue){this.counter=this.finalValue,clearInterval(this.intervalId);return}else this.counter=a},e)},this.observer=new IntersectionObserver(this.handleCounterAnimateIfInView,{threshold:.1}),this.observeScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.observe(e)},this.unobserveScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.unobserve(e)}}connectedCallback(){super.connectedCallback();const e=window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.duration===0||e?this.counter=this.finalValue:this.observeScrollTarget()}disconnectedCallback(){super.disconnectedCallback(),this.unobserveScrollTarget(),clearInterval(this.intervalId)}get scrollTargetElement(){return this.scrollTarget?document.querySelector(this.scrollTarget):this}render(){return u`${Math.ceil(this.counter).toLocaleString()}`}}h([c({type:Number})],m.prototype,"finalValue",2),h([c({type:Number})],m.prototype,"duration",2),h([c({type:String})],m.prototype,"scrollTarget",2),h([y()],m.prototype,"counter",2),customElements.get("animated-counter")||customElements.define("animated-counter",m);const O=n=>{const e=n instanceof NodeList?Array.from(n):n;if(e.length===0||!j(e))return;const t=e.sort((i,o)=>{const r=getComputedStyle(i).getPropertyValue("width").replace("px",""),g=getComputedStyle(o).getPropertyValue("width").replace("px","");return parseInt(g)-parseInt(r)})[0],a=getComputedStyle(t).getPropertyValue("width");for(const i of e)getComputedStyle(i).getPropertyValue("width")!==a&&(i.style.width=a)},w={en:{cumulativeImpactTitle:()=>"What we've funded",cumulativeImpactDescription:()=>"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day\u2014 scroll to check out the goals we're working toward together right now."},fr:{cumulativeImpactTitle:()=>"Ce que nous avons financ\xE9",cumulativeImpactDescription:()=>"Voici l'impact que notre communaut\xE9 a eu jusqu'\xE0 pr\xE9sent en partenariat avec Beam. Notre impact grandit chaque jour : faites d\xE9filer pour d\xE9couvrir les objectifs vers lesquels nous travaillons ensemble en ce moment."},de:{cumulativeImpactTitle:()=>"Was wir finanziert haben",cumulativeImpactDescription:()=>"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung w\xE4chst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten."},es:{cumulativeImpactTitle:()=>"Lo que hemos financiado",cumulativeImpactDescription:()=>"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociaci\xF3n con Beam. Nuestro impacto crece cada d\xEDa; despl\xE1cese para ver los objetivos por los que estamos trabajando juntos en este momento."},it:{cumulativeImpactTitle:()=>"Cosa abbiamo finanziato",cumulativeImpactDescription:()=>"Ecco l'impatto che la nostra comunit\xE0 ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento."},pl:{cumulativeImpactTitle:()=>"Co sfinansowali\u015Bmy",cumulativeImpactDescription:()=>"Oto wp\u0142yw, jaki nasza spo\u0142eczno\u015B\u0107 wywar\u0142a dotychczas we wsp\xF3\u0142pracy z Beam. Nasz wp\u0142yw ro\u015Bnie z ka\u017Cdym dniem \u2014 przewi\u0144, aby sprawdzi\u0107 cele, nad kt\xF3rymi obecnie wsp\xF3lnie pracujemy."}};var P=Object.defineProperty,q=Object.getOwnPropertyDescriptor,l=(n,e,t,a)=>{for(var i=a>1?void 0:a?q(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&P(e,t,i),i};const U=1.5*1e3;class s extends b{constructor(){super(...arguments),this.baseUrl=L,this.lang="en",this.disableAnimation=!1,this.debug=!1,this.getCumulativeImpactData=async()=>(E(["apiKey","chainId"],this),await $({baseUrl:this.baseUrl,pathParams:{chainId:this.chainId},headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{version:"1.0.0",lang:this.configLang}})),this.cumulativeImpactDataController=new z(this,this.getCumulativeImpactData),this.resizeElements=x(()=>{O(this.impactRowRefs)},50,{maxWait:50,leading:!0})}get configLang(){return k[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const t=["chainId","baseUrl","lang"];for(const a of t)if(e.has(a)){await this.cumulativeImpactDataController.exec();break}this.resizeElements()}render(){const{data:e,error:t,loading:a}=this.cumulativeImpactDataController;return a?B():t?this.debug?f({error:t}):"":e==null?this.debug?f({error:new V("Missing data")}):"":u`
1
+ import{t as y,g as b,y as u,f as c,h as C,u as I}from"../chunks/lit-h1W25hjN.esm.js";import{d as x}from"../chunks/lodash-ZxBiuGue.esm.js";import{c as T,u as p,d as S,e as E,A as z,a as B,_ as f,i as d,b as v,f as D}from"../chunks/localize-z-KGe7Y5.esm.js";import{D as L,j as $,S as k}from"../chunks/routes-RQDFRUiD.esm.js";import{B as V}from"../chunks/beam-errors-AMvTvR1C.esm.js";import{i as j}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";var A=Object.defineProperty,R=Object.getOwnPropertyDescriptor,h=(n,e,t,a)=>{for(var i=a>1?void 0:a?R(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&A(e,t,i),i};class m extends b{constructor(){super(...arguments),this.finalValue=0,this.duration=1500,this.counter=0,this.intervalId=0,this.handleCounterAnimateIfInView=e=>{e.some(t=>t.isIntersecting)&&(this.animateCounter(),this.unobserveScrollTarget())},this.animateCounter=()=>{const e=41.666666666666664,t=e/this.duration*this.finalValue;this.intervalId=setInterval(()=>{const a=this.counter+t;if(a>=this.finalValue){this.counter=this.finalValue,clearInterval(this.intervalId);return}else this.counter=a},e)},this.observer=new IntersectionObserver(this.handleCounterAnimateIfInView,{threshold:.1}),this.observeScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.observe(e)},this.unobserveScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.unobserve(e)}}connectedCallback(){super.connectedCallback();const e=window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.duration===0||e?this.counter=this.finalValue:this.observeScrollTarget()}disconnectedCallback(){super.disconnectedCallback(),this.unobserveScrollTarget(),clearInterval(this.intervalId)}get scrollTargetElement(){return this.scrollTarget?document.querySelector(this.scrollTarget):this}render(){return u`${Math.ceil(this.counter).toLocaleString()}`}}h([c({type:Number})],m.prototype,"finalValue",2),h([c({type:Number})],m.prototype,"duration",2),h([c({type:String})],m.prototype,"scrollTarget",2),h([y()],m.prototype,"counter",2),customElements.get("animated-counter")||customElements.define("animated-counter",m);const O=n=>{const e=n instanceof NodeList?Array.from(n):n;if(e.length===0||!j(e))return;const t=e.sort((i,o)=>{const r=getComputedStyle(i).getPropertyValue("width").replace("px",""),g=getComputedStyle(o).getPropertyValue("width").replace("px","");return parseInt(g)-parseInt(r)})[0],a=getComputedStyle(t).getPropertyValue("width");for(const i of e)getComputedStyle(i).getPropertyValue("width")!==a&&(i.style.width=a)},w={en:{cumulativeImpactTitle:()=>"What we've funded",cumulativeImpactDescription:()=>"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day\u2014 scroll to check out the goals we're working toward together right now."},fr:{cumulativeImpactTitle:()=>"Ce que nous avons financ\xE9",cumulativeImpactDescription:()=>"Voici l'impact que notre communaut\xE9 a eu jusqu'\xE0 pr\xE9sent en partenariat avec Beam. Notre impact grandit chaque jour : faites d\xE9filer pour d\xE9couvrir les objectifs vers lesquels nous travaillons ensemble en ce moment."},de:{cumulativeImpactTitle:()=>"Was wir finanziert haben",cumulativeImpactDescription:()=>"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung w\xE4chst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten."},es:{cumulativeImpactTitle:()=>"Lo que hemos financiado",cumulativeImpactDescription:()=>"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociaci\xF3n con Beam. Nuestro impacto crece cada d\xEDa; despl\xE1cese para ver los objetivos por los que estamos trabajando juntos en este momento."},it:{cumulativeImpactTitle:()=>"Cosa abbiamo finanziato",cumulativeImpactDescription:()=>"Ecco l'impatto che la nostra comunit\xE0 ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento."},pl:{cumulativeImpactTitle:()=>"Co sfinansowali\u015Bmy",cumulativeImpactDescription:()=>"Oto wp\u0142yw, jaki nasza spo\u0142eczno\u015B\u0107 wywar\u0142a dotychczas we wsp\xF3\u0142pracy z Beam. Nasz wp\u0142yw ro\u015Bnie z ka\u017Cdym dniem \u2014 przewi\u0144, aby sprawdzi\u0107 cele, nad kt\xF3rymi obecnie wsp\xF3lnie pracujemy."}};var P=Object.defineProperty,q=Object.getOwnPropertyDescriptor,l=(n,e,t,a)=>{for(var i=a>1?void 0:a?q(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&P(e,t,i),i};const U=1.5*1e3;class s extends b{constructor(){super(...arguments),this.baseUrl=L,this.lang="en",this.disableAnimation=!1,this.debug=!1,this.getCumulativeImpactData=async()=>(E(["apiKey","chainId"],this),await $({baseUrl:this.baseUrl,pathParams:{chainId:this.chainId},headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{version:"1.0.0",lang:this.configLang}})),this.cumulativeImpactDataController=new z(this,this.getCumulativeImpactData),this.resizeElements=x(()=>{O(this.impactRowRefs)},50,{maxWait:50,leading:!0})}get configLang(){return k[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const t=["chainId","baseUrl","lang"];for(const a of t)if(e.has(a)){await this.cumulativeImpactDataController.exec();break}this.resizeElements()}render(){const{data:e,error:t,loading:a}=this.cumulativeImpactDataController;return a?B():t?this.debug?f({error:t}):"":e==null?this.debug?f({error:new V("Missing data")}):"":u`
2
2
  <style>
3
3
  :host {
4
4
  ${this.cssVariables.toCSS()}