@beamimpact/web-sdk 1.38.1 → 1.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/chunks/_share-dialog-dependencies-45VkuwV_.esm.js +2 -0
  2. package/dist/chunks/_share-dialog-dependencies-45VkuwV_.esm.js.map +1 -0
  3. package/dist/chunks/_share-dialog-dependencies-zjR-bLve.esm.js +2 -0
  4. package/dist/chunks/_share-dialog-dependencies-zjR-bLve.esm.js.map +1 -0
  5. package/dist/chunks/{cart-contents-dKdDg09p.esm.d.ts → cart-contents-3-9fB-7m.esm.d.ts} +1 -1
  6. package/dist/chunks/{css-card-grid-inRnKSWs.esm.js → css-card-grid-7tObtoJx.esm.js} +2 -2
  7. package/dist/chunks/{css-card-grid-inRnKSWs.esm.js.map → css-card-grid-7tObtoJx.esm.js.map} +1 -1
  8. package/dist/chunks/{events-zF9NDtBD.esm.d.ts → events-7W7i4aV5.esm.d.ts} +1 -1
  9. package/dist/chunks/index-07spDV_A.esm.js +2 -0
  10. package/dist/chunks/index-07spDV_A.esm.js.map +1 -0
  11. package/dist/chunks/{index-tqTROh5B.esm.d.ts → index-HBDtoJlQ.esm.d.ts} +1 -1
  12. package/dist/chunks/{index-oLz4lmx2.esm.d.ts → index-Hb-jziQs.esm.d.ts} +3 -1
  13. package/dist/chunks/{index-UCh8HjVN.esm.js → index-IO0Z_buU.esm.js} +2 -2
  14. package/dist/chunks/{index-UCh8HjVN.esm.js.map → index-IO0Z_buU.esm.js.map} +1 -1
  15. package/dist/chunks/index-NF6VKqmo.esm.js +2 -0
  16. package/dist/chunks/index-NF6VKqmo.esm.js.map +1 -0
  17. package/dist/chunks/{index-6iInzwnG.esm.js → index-Q1vx4WtG.esm.js} +2 -2
  18. package/dist/chunks/{index-6iInzwnG.esm.js.map → index-Q1vx4WtG.esm.js.map} +1 -1
  19. package/dist/chunks/{index-EjqeU7Mu.esm.d.ts → index-SxFKifVJ.esm.d.ts} +1 -1
  20. package/dist/chunks/index-TD6ZYob2.esm.js +2 -0
  21. package/dist/chunks/index-TD6ZYob2.esm.js.map +1 -0
  22. package/dist/chunks/{index-cRyQ6D5G.esm.d.ts → index-TOzSFOvI.esm.d.ts} +1 -1
  23. package/dist/chunks/index-V-BsPYtl.esm.js +2 -0
  24. package/dist/chunks/index-V-BsPYtl.esm.js.map +1 -0
  25. package/dist/chunks/{index-dDBsHD_s.esm.d.ts → index-YwDVLm67.esm.d.ts} +1 -1
  26. package/dist/chunks/{index-Tnwxn22c.esm.d.ts → index-Zk634mW7.esm.d.ts} +4 -4
  27. package/dist/chunks/{index-iYxrQMxt.esm.d.ts → index-b-AHDeDB.esm.d.ts} +1 -1
  28. package/dist/chunks/index-b9nIxcaS.esm.js +2 -0
  29. package/dist/chunks/index-b9nIxcaS.esm.js.map +1 -0
  30. package/dist/chunks/index-cekgAcEE.esm.js +2 -0
  31. package/dist/chunks/index-cekgAcEE.esm.js.map +1 -0
  32. package/dist/chunks/index-i1kXw_4Z.esm.js +2 -0
  33. package/dist/chunks/index-i1kXw_4Z.esm.js.map +1 -0
  34. package/dist/chunks/index-qFEb98cw.esm.js +2 -0
  35. package/dist/chunks/index-qFEb98cw.esm.js.map +1 -0
  36. package/dist/chunks/{index-l7Ao8g5B.esm.js → index-uCfdsWtt.esm.js} +2 -2
  37. package/dist/chunks/{index-l7Ao8g5B.esm.js.map → index-uCfdsWtt.esm.js.map} +1 -1
  38. package/dist/chunks/{index-_WQFoMIz.esm.js → index-wrvDFuaS.esm.js} +2 -2
  39. package/dist/chunks/{index-_WQFoMIz.esm.js.map → index-wrvDFuaS.esm.js.map} +1 -1
  40. package/dist/chunks/{lit-HCWbxxT7.esm.js → lit-qtGbjGnK.esm.js} +2 -2
  41. package/dist/chunks/{lit-HCWbxxT7.esm.js.map → lit-qtGbjGnK.esm.js.map} +1 -1
  42. package/dist/chunks/loading-template-Av0IUyKF.esm.js +2 -0
  43. package/dist/chunks/loading-template-Av0IUyKF.esm.js.map +1 -0
  44. package/dist/chunks/localize-F31ae3j6.esm.js +30 -0
  45. package/dist/chunks/localize-F31ae3j6.esm.js.map +1 -0
  46. package/dist/chunks/localize-fH8KOrMi.esm.js +30 -0
  47. package/dist/chunks/localize-fH8KOrMi.esm.js.map +1 -0
  48. package/dist/chunks/{openapi-spec-fxMWpEwU.esm.d.ts → openapi-spec--MzXvfCC.esm.d.ts} +139 -10
  49. package/dist/chunks/{order-page-AezeN9KY.esm.d.ts → order-page-DPx5SUKM.esm.d.ts} +2 -2
  50. package/dist/chunks/{order-page-5VQO1Sil.esm.js → order-page-DTWyo57K.esm.js} +2 -2
  51. package/dist/chunks/{order-page-5VQO1Sil.esm.js.map → order-page-DTWyo57K.esm.js.map} +1 -1
  52. package/dist/chunks/{order-page-E7Kyu1JP.esm.js → order-page-r0Bn2_wR.esm.js} +2 -2
  53. package/dist/chunks/{order-page-E7Kyu1JP.esm.js.map → order-page-r0Bn2_wR.esm.js.map} +1 -1
  54. package/dist/chunks/{progress-bar-9vfd2JYm.esm.js → progress-bar-Sn2QspHy.esm.js} +2 -2
  55. package/dist/chunks/{progress-bar-9vfd2JYm.esm.js.map → progress-bar-Sn2QspHy.esm.js.map} +1 -1
  56. package/dist/chunks/{promo-pill-label-vCWNyiaj.esm.js → promo-pill-label-j0A8qZ0c.esm.js} +2 -2
  57. package/dist/chunks/{promo-pill-label-vCWNyiaj.esm.js.map → promo-pill-label-j0A8qZ0c.esm.js.map} +1 -1
  58. package/dist/chunks/{responsive-Bzkkpj11.esm.js → responsive-aWj_7ZN_.esm.js} +2 -2
  59. package/dist/chunks/responsive-aWj_7ZN_.esm.js.map +1 -0
  60. package/dist/chunks/routes-eEIGOCLH.esm.js +2 -0
  61. package/dist/chunks/{routes-UBDDazXd.esm.js.map → routes-eEIGOCLH.esm.js.map} +1 -1
  62. package/dist/chunks/routes-mFdr3VNw.esm.js +2 -0
  63. package/dist/chunks/{routes-t5eRHMRc.esm.js.map → routes-mFdr3VNw.esm.js.map} +1 -1
  64. package/dist/chunks/shoelace-components-jVPXTZPS.esm.js +2 -0
  65. package/dist/chunks/shoelace-components-jVPXTZPS.esm.js.map +1 -0
  66. package/dist/chunks/shoelace-components-yvcqUObE.esm.js +2 -0
  67. package/dist/chunks/shoelace-components-yvcqUObE.esm.js.map +1 -0
  68. package/dist/chunks/{update-cart-6fMyZd34.esm.js → update-cart--5PpQSrY.esm.js} +2 -2
  69. package/dist/chunks/{update-cart-6fMyZd34.esm.js.map → update-cart--5PpQSrY.esm.js.map} +1 -1
  70. package/dist/chunks/{update-cart-WfOplzik.esm.js → update-cart-TDb6pWxk.esm.js} +2 -2
  71. package/dist/chunks/{update-cart-WfOplzik.esm.js.map → update-cart-TDb6pWxk.esm.js.map} +1 -1
  72. package/dist/chunks/{update-cart-43LEXveI.esm.d.ts → update-cart-xaWdPxse.esm.d.ts} +1 -1
  73. package/dist/chunks/vendor-jQ8cxMpw.esm.js +1284 -0
  74. package/dist/chunks/vendor-jQ8cxMpw.esm.js.map +1 -0
  75. package/dist/components/beam-partner-logos.esm.js +1 -1
  76. package/dist/components/beam-partner-logos.js +1 -1
  77. package/dist/components/community-impact.esm.js +1 -1
  78. package/dist/components/community-impact.esm.js.map +1 -1
  79. package/dist/components/community-impact.js +1 -1
  80. package/dist/components/community-impact.js.map +1 -1
  81. package/dist/components/cumulative-impact.esm.js +1 -1
  82. package/dist/components/cumulative-impact.esm.js.map +1 -1
  83. package/dist/components/cumulative-impact.js +1 -1
  84. package/dist/components/cumulative-impact.js.map +1 -1
  85. package/dist/components/impact-overview.esm.js +7 -7
  86. package/dist/components/impact-overview.esm.js.map +1 -1
  87. package/dist/components/impact-overview.js +7 -7
  88. package/dist/components/impact-overview.js.map +1 -1
  89. package/dist/components/index.d.ts +3 -2
  90. package/dist/components/index.esm.js +1 -1
  91. package/dist/components/index.js +1 -1
  92. package/dist/components/post-purchase.d.ts +3 -3
  93. package/dist/components/post-purchase.esm.js +1 -1
  94. package/dist/components/post-purchase.esm.js.map +1 -1
  95. package/dist/components/post-purchase.js +1 -1
  96. package/dist/components/post-purchase.js.map +1 -1
  97. package/dist/components/product-details-page.d.ts +75 -0
  98. package/dist/components/product-details-page.esm.js +114 -0
  99. package/dist/components/product-details-page.esm.js.map +1 -0
  100. package/dist/components/product-details-page.js +114 -0
  101. package/dist/components/product-details-page.js.map +1 -0
  102. package/dist/components/redeem-transaction.d.ts +3 -3
  103. package/dist/components/redeem-transaction.esm.js +1 -1
  104. package/dist/components/redeem-transaction.esm.js.map +1 -1
  105. package/dist/components/redeem-transaction.js +1 -1
  106. package/dist/components/redeem-transaction.js.map +1 -1
  107. package/dist/components/select-nonprofit.d.ts +3 -3
  108. package/dist/components/select-nonprofit.esm.js +1 -1
  109. package/dist/components/select-nonprofit.esm.js.map +1 -1
  110. package/dist/components/select-nonprofit.js +1 -1
  111. package/dist/components/select-nonprofit.js.map +1 -1
  112. package/dist/components/shopify.d.ts +5 -5
  113. package/dist/components/shopify.esm.js +1 -1
  114. package/dist/components/shopify.esm.js.map +1 -1
  115. package/dist/components/shopify.js +1 -1
  116. package/dist/components/shopify.js.map +1 -1
  117. package/dist/components/subscription-management.d.ts +10 -3
  118. package/dist/components/subscription-management.esm.js +4 -4
  119. package/dist/components/subscription-management.esm.js.map +1 -1
  120. package/dist/components/subscription-management.js +4 -4
  121. package/dist/components/subscription-management.js.map +1 -1
  122. package/dist/index.d.ts +13 -12
  123. package/dist/index.esm.js +1 -1
  124. package/dist/index.js +1 -1
  125. package/dist/integrations/beam.esm.js +1 -1
  126. package/dist/integrations/beam.js +1 -1
  127. package/dist/integrations/cart.d.ts +3 -3
  128. package/dist/integrations/cart.esm.js +1 -1
  129. package/dist/integrations/cart.js +1 -1
  130. package/dist/integrations/index.d.ts +9 -9
  131. package/dist/integrations/index.esm.js +1 -1
  132. package/dist/integrations/index.js +1 -1
  133. package/dist/integrations/logs.d.ts +2 -2
  134. package/dist/integrations/logs.esm.js +1 -1
  135. package/dist/integrations/logs.js +1 -1
  136. package/dist/integrations/session.esm.js +1 -1
  137. package/dist/integrations/session.js +1 -1
  138. package/dist/integrations/shopify.d.ts +4 -4
  139. package/dist/integrations/shopify.esm.js +1 -1
  140. package/dist/integrations/shopify.js +1 -1
  141. package/dist/integrations/statsig.esm.js +3 -2
  142. package/dist/integrations/statsig.esm.js.map +1 -1
  143. package/dist/integrations/statsig.js +3 -2
  144. package/dist/integrations/statsig.js.map +1 -1
  145. package/dist/integrations/utils.d.ts +3 -3
  146. package/dist/react/beam-partner-logos.esm.js +1 -1
  147. package/dist/react/beam-partner-logos.js +1 -1
  148. package/dist/react/community-impact.esm.js +1 -1
  149. package/dist/react/community-impact.esm.js.map +1 -1
  150. package/dist/react/community-impact.js +1 -1
  151. package/dist/react/community-impact.js.map +1 -1
  152. package/dist/react/cumulative-impact.esm.js +1 -1
  153. package/dist/react/cumulative-impact.esm.js.map +1 -1
  154. package/dist/react/cumulative-impact.js +1 -1
  155. package/dist/react/cumulative-impact.js.map +1 -1
  156. package/dist/react/impact-overview.esm.js +1 -1
  157. package/dist/react/impact-overview.esm.js.map +1 -1
  158. package/dist/react/impact-overview.js +1 -1
  159. package/dist/react/impact-overview.js.map +1 -1
  160. package/dist/react/index.d.ts +3 -3
  161. package/dist/react/index.esm.js +1 -1
  162. package/dist/react/index.js +1 -1
  163. package/dist/react/post-purchase.d.ts +2 -2
  164. package/dist/react/post-purchase.esm.js +1 -1
  165. package/dist/react/post-purchase.esm.js.map +1 -1
  166. package/dist/react/post-purchase.js +1 -1
  167. package/dist/react/post-purchase.js.map +1 -1
  168. package/dist/react/product-details-page.d.ts +9 -0
  169. package/dist/react/product-details-page.esm.js +2 -0
  170. package/dist/react/product-details-page.esm.js.map +1 -0
  171. package/dist/react/product-details-page.js +2 -0
  172. package/dist/react/product-details-page.js.map +1 -0
  173. package/dist/react/redeem-transaction.d.ts +3 -3
  174. package/dist/react/redeem-transaction.esm.js +1 -1
  175. package/dist/react/redeem-transaction.esm.js.map +1 -1
  176. package/dist/react/redeem-transaction.js +1 -1
  177. package/dist/react/redeem-transaction.js.map +1 -1
  178. package/dist/react/select-nonprofit.d.ts +3 -3
  179. package/dist/react/select-nonprofit.esm.js +1 -1
  180. package/dist/react/select-nonprofit.esm.js.map +1 -1
  181. package/dist/react/select-nonprofit.js +1 -1
  182. package/dist/react/select-nonprofit.js.map +1 -1
  183. package/dist/react/subscription-management.d.ts +9 -2
  184. package/dist/react/subscription-management.esm.js +1 -1
  185. package/dist/react/subscription-management.esm.js.map +1 -1
  186. package/dist/react/subscription-management.js +1 -1
  187. package/dist/react/subscription-management.js.map +1 -1
  188. package/dist/utils/events.d.ts +3 -3
  189. package/dist/utils/index.d.ts +3 -3
  190. package/dist/utils/makeApiKeyHeader.d.ts +5 -0
  191. package/dist/utils/makeApiKeyHeader.esm.js +2 -0
  192. package/dist/utils/makeApiKeyHeader.esm.js.map +1 -0
  193. package/dist/utils/makeApiKeyHeader.js +2 -0
  194. package/dist/utils/makeApiKeyHeader.js.map +1 -0
  195. package/package.json +2 -2
  196. package/dist/chunks/_share-dialog-dependencies-0yVtRIRR.esm.js +0 -2
  197. package/dist/chunks/_share-dialog-dependencies-0yVtRIRR.esm.js.map +0 -1
  198. package/dist/chunks/_share-dialog-dependencies-HWissVga.esm.js +0 -2
  199. package/dist/chunks/_share-dialog-dependencies-HWissVga.esm.js.map +0 -1
  200. package/dist/chunks/enforce-config-7R9KCF_i.esm.js +0 -22
  201. package/dist/chunks/enforce-config-7R9KCF_i.esm.js.map +0 -1
  202. package/dist/chunks/enforce-config-iFdf1QkH.esm.js +0 -22
  203. package/dist/chunks/enforce-config-iFdf1QkH.esm.js.map +0 -1
  204. package/dist/chunks/index-5yFqo0yl.esm.js +0 -2
  205. package/dist/chunks/index-5yFqo0yl.esm.js.map +0 -1
  206. package/dist/chunks/index-FsVWk2WD.esm.js +0 -2
  207. package/dist/chunks/index-FsVWk2WD.esm.js.map +0 -1
  208. package/dist/chunks/index-IKTofhFw.esm.js +0 -2
  209. package/dist/chunks/index-IKTofhFw.esm.js.map +0 -1
  210. package/dist/chunks/index-IWF7IfQk.esm.js +0 -2
  211. package/dist/chunks/index-IWF7IfQk.esm.js.map +0 -1
  212. package/dist/chunks/index-IzAvjker.esm.js +0 -2
  213. package/dist/chunks/index-IzAvjker.esm.js.map +0 -1
  214. package/dist/chunks/index-MG0WE1Fz.esm.js +0 -2
  215. package/dist/chunks/index-MG0WE1Fz.esm.js.map +0 -1
  216. package/dist/chunks/index-NU6RpwSa.esm.js +0 -2
  217. package/dist/chunks/index-NU6RpwSa.esm.js.map +0 -1
  218. package/dist/chunks/index-QrlkSlnv.esm.js +0 -2
  219. package/dist/chunks/index-QrlkSlnv.esm.js.map +0 -1
  220. package/dist/chunks/localize-ZHtlNltZ.esm.js +0 -10
  221. package/dist/chunks/localize-ZHtlNltZ.esm.js.map +0 -1
  222. package/dist/chunks/localize-jRg7W6Ul.esm.js +0 -10
  223. package/dist/chunks/localize-jRg7W6Ul.esm.js.map +0 -1
  224. package/dist/chunks/responsive-Bzkkpj11.esm.js.map +0 -1
  225. package/dist/chunks/routes-UBDDazXd.esm.js +0 -2
  226. package/dist/chunks/routes-t5eRHMRc.esm.js +0 -2
  227. package/dist/chunks/vendor-h5FNKy-G.esm.js +0 -1147
  228. package/dist/chunks/vendor-h5FNKy-G.esm.js.map +0 -1
@@ -2,8 +2,15 @@ import * as lit from 'lit';
2
2
  import { LitElement } from 'lit';
3
3
  import * as lit_html from 'lit-html';
4
4
  import { L as LANGUAGES } from '../chunks/types-aju0qrRe.esm.js';
5
- import { T as TCart } from '../chunks/cart-contents-dKdDg09p.esm.js';
6
- import '../chunks/openapi-spec-fxMWpEwU.esm.js';
5
+ import { T as TCart } from '../chunks/cart-contents-3-9fB-7m.esm.js';
6
+ import './redeem-transaction.js';
7
+ import './impact-overview.js';
8
+ import '../chunks/openapi-spec--MzXvfCC.esm.js';
9
+ import 'lodash';
10
+ import '../chunks/progress-bar-0VS_AmEf.esm.js';
11
+ import '../chunks/promo-pill-label-3bA1z-la.esm.js';
12
+ import './beam-partner-logos.js';
13
+ import '../chunks/types-7kSi85Gv.esm.js';
7
14
 
8
15
  interface RequiredDataPropsWithEmail {
9
16
  email: string;
@@ -127,7 +134,7 @@ declare class BeamSubscriptionManagement extends LitElement {
127
134
  } | null;
128
135
  }>;
129
136
  handleSwapNonprofitButtonClick(): void;
130
- renderSwapNonprofitButton(): lit_html.TemplateResult<1> | "";
137
+ renderSwapNonprofitButton(): "" | lit_html.TemplateResult<1>;
131
138
  get cssVariables(): any;
132
139
  static styles: lit.CSSResult[];
133
140
  render(): lit_html.TemplateResult<1>;
@@ -1,6 +1,6 @@
1
- import{f as h,g as o,t as p,h as g,y as d}from"../chunks/lit-HCWbxxT7.esm.js";import{D as f,e as y,f as w}from"../chunks/routes-UBDDazXd.esm.js";import{c as S,d as v,A as u,e as b,a as C,_ as m}from"../chunks/enforce-config-7R9KCF_i.esm.js";import{c as x}from"../chunks/events-Y8fYvSqM.esm.js";import{M as N}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";const I={en:{nonprofitSwapText:({brandName:i=""})=>`Support a new nonprofit with your next ${i} recurring order`},fr:{nonprofitSwapText:({brandName:i=""})=>`Soutenez une nouvelle organisation \xE0 but non lucratif avec votre prochaine commande r\xE9currente ${i}`},de:{nonprofitSwapText:({brandName:i=""})=>`Unterst\xFCtzen Sie eine neue gemeinn\xFCtzige Organisation mit Ihrer n\xE4chsten wiederkehrenden Bestellung bei ${i}`},es:{nonprofitSwapText:({brandName:i=""})=>`Apoye a una nueva organizaci\xF3n sin fines de lucro con su pr\xF3ximo pedido recurrente ${i}`},it:{nonprofitSwapText:({brandName:i=""})=>`Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${i}`},pl:{nonprofitSwapText:({brandName:i=""})=>`Wesprzyj now\u0105 organizacj\u0119 non-profit przy kolejnym zam\xF3wieniu cyklicznym ${i}`}};var M=Object.defineProperty,$=Object.getOwnPropertyDescriptor,n=(i,t,r,a)=>{for(var s=a>1?void 0:a?$(t,r):t,l=i.length-1,c;l>=0;l--)(c=i[l])&&(s=(a?c(t,r,s):c(s))||s);return a&&s&&M(t,r,s),s};class e extends g{constructor(){super(...arguments),this.baseUrl=f,this.lang="en",this.debug=!1,this.activeWidget=null,this.nonprofitId=null,this.userId=null,this.chainName=null,this.subscriptionDataController=new u(this,this.fetchSubscription),this.eligibleNonprofitsDataController=new u(this,this.fetchEligibleNonprofits)}async firstUpdated(){if(!this.email&&!this.partnerUserId)throw new N(["email","partnerUserId"],"One of the following properties needs to be specified: email, partnerUserId ");b(["apiKey","subscriptionId"],this),await this.loadWidget()}async loadWidget(){await Promise.all([this.fetchEligibleNonprofits(),this.fetchSubscription()]),this.activeWidget=this.nonprofitId?"impact-overview":"redeem-transaction"}async fetchEligibleNonprofits(){b(["apiKey","subscriptionId"],this);const t=await y({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId||void 0,postalCode:this.postalCode||void 0,countryCode:this.countryCode||void 0,widgetName:"subscription-management",version:"1.0.0"}});return this.chainName=t.chain.name,this.storeId=t.store.id,this.eligibleNonprofitsDataController.data=t,t}async fetchSubscription(){b(["apiKey","subscriptionId"],this);const t=await w({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return this.userId=t.beamUserId,this.nonprofitId=t.nonprofit?.id||null,t}handleSwapNonprofitButtonClick(){this.activeWidget="redeem-transaction"}renderSwapNonprofitButton(){return this.activeWidget==="impact-overview"?d`<button class="swap-nonprofit-button" @click="${this.handleSwapNonprofitButtonClick}">
1
+ import{f as h,g as r,t as p,h as g,y as d}from"../chunks/lit-qtGbjGnK.esm.js";import{D as f,f as y,h as w}from"../chunks/routes-mFdr3VNw.esm.js";import{c as S,d as v,A as c,e as b,b as C,_ as u}from"../chunks/localize-F31ae3j6.esm.js";import{c as x}from"../chunks/events-Y8fYvSqM.esm.js";import{M as N}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import"./redeem-transaction.esm.js";import"./impact-overview.esm.js";import"../utils/logger.esm.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/progress-bar-Sn2QspHy.esm.js";import"../chunks/promo-pill-label-j0A8qZ0c.esm.js";import"../chunks/vendor-jQ8cxMpw.esm.js";import"./beam-partner-logos.esm.js";import"../chunks/loading-template-Av0IUyKF.esm.js";import"../utils/local-storage.esm.js";import"../chunks/css-card-grid-7tObtoJx.esm.js";import"../chunks/shoelace-components-jVPXTZPS.esm.js";import"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../chunks/responsive-aWj_7ZN_.esm.js";const I={en:{nonprofitSwapText:({brandName:i=""})=>`Support a new nonprofit with your next ${i} recurring order`},fr:{nonprofitSwapText:({brandName:i=""})=>`Soutenez une nouvelle organisation \xE0 but non lucratif avec votre prochaine commande r\xE9currente ${i}`},de:{nonprofitSwapText:({brandName:i=""})=>`Unterst\xFCtzen Sie eine neue gemeinn\xFCtzige Organisation mit Ihrer n\xE4chsten wiederkehrenden Bestellung bei ${i}`},es:{nonprofitSwapText:({brandName:i=""})=>`Apoye a una nueva organizaci\xF3n sin fines de lucro con su pr\xF3ximo pedido recurrente ${i}`},it:{nonprofitSwapText:({brandName:i=""})=>`Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${i}`},pl:{nonprofitSwapText:({brandName:i=""})=>`Wesprzyj now\u0105 organizacj\u0119 non-profit przy kolejnym zam\xF3wieniu cyklicznym ${i}`}};var M=Object.defineProperty,$=Object.getOwnPropertyDescriptor,o=(i,t,n,a)=>{for(var s=a>1?void 0:a?$(t,n):t,l=i.length-1,m;l>=0;l--)(m=i[l])&&(s=(a?m(t,n,s):m(s))||s);return a&&s&&M(t,n,s),s};class e extends g{constructor(){super(...arguments),this.baseUrl=f,this.lang="en",this.debug=!1,this.activeWidget=null,this.nonprofitId=null,this.userId=null,this.chainName=null,this.subscriptionDataController=new c(this,this.fetchSubscription),this.eligibleNonprofitsDataController=new c(this,this.fetchEligibleNonprofits)}async firstUpdated(){if(!this.email&&!this.partnerUserId)throw new N(["email","partnerUserId"],"One of the following properties needs to be specified: email, partnerUserId ");b(["apiKey","subscriptionId"],this),await this.loadWidget()}async loadWidget(){await Promise.all([this.fetchEligibleNonprofits(),this.fetchSubscription()]),this.activeWidget=this.nonprofitId?"impact-overview":"redeem-transaction"}async fetchEligibleNonprofits(){b(["apiKey","subscriptionId"],this);const t=await y({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId||void 0,postalCode:this.postalCode||void 0,countryCode:this.countryCode||void 0,widgetName:"subscription-management",version:"1.0.0"}});return this.chainName=t.chain.name,this.storeId=t.store.id,this.eligibleNonprofitsDataController.data=t,t}async fetchSubscription(){b(["apiKey","subscriptionId"],this);const t=await w({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return this.userId=t.beamUserId,this.nonprofitId=t.nonprofit?.id||null,t}handleSwapNonprofitButtonClick(){this.activeWidget="redeem-transaction"}renderSwapNonprofitButton(){return this.activeWidget==="impact-overview"?d`<button class="swap-nonprofit-button" @click="${this.handleSwapNonprofitButtonClick}">
2
2
  ${I[this.lang].nonprofitSwapText({brandName:this.chainName||""})}
3
- </button>`:""}get cssVariables(){const t={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-borderColor":"#d5d5d5","--beam-SubscriptionManagement-widgetContainer-borderRadius":"4px","--beam-SubscriptionManagement-widgetContainer-padding":"15px","--beam-SubscriptionManagement-widgetContainer-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-maxWidth":"800px","--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration":"underline","--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop":"10px","--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-color":"inherit"},r=this.eligibleNonprofitsDataController?.data?.config?.web?.theme||{},a={...t,...r};return Object.assign(Object.create({toCSS(){return C(this)}}),a)}render(){let t;if((this.subscriptionDataController.loading||this.eligibleNonprofitsDataController.loading)&&(t=""),(this.subscriptionDataController.error||this.eligibleNonprofitsDataController.error)&&this.debug){if(this.subscriptionDataController.error!==null)return m({error:this.subscriptionDataController.error});if(this.eligibleNonprofitsDataController.error!==null)return m({error:this.eligibleNonprofitsDataController.error})}else t="";return this.activeWidget==="redeem-transaction"?t=d` <beam-redeem-transaction
3
+ </button>`:""}get cssVariables(){const t={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-borderColor":"#d5d5d5","--beam-SubscriptionManagement-widgetContainer-borderRadius":"4px","--beam-SubscriptionManagement-widgetContainer-padding":"15px","--beam-SubscriptionManagement-widgetContainer-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-maxWidth":"800px","--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration":"underline","--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop":"10px","--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-color":"inherit"},n=this.eligibleNonprofitsDataController?.data?.config?.web?.theme||{},a={...t,...n};return Object.assign(Object.create({toCSS(){return C(this)}}),a)}render(){let t;if((this.subscriptionDataController.loading||this.eligibleNonprofitsDataController.loading)&&(t=""),(this.subscriptionDataController.error||this.eligibleNonprofitsDataController.error)&&this.debug){if(this.subscriptionDataController.error!==null)return u({error:this.subscriptionDataController.error});if(this.eligibleNonprofitsDataController.error!==null)return u({error:this.eligibleNonprofitsDataController.error})}else t="";return this.activeWidget==="redeem-transaction"?t=d` <beam-redeem-transaction
4
4
  part="redeem-transaction"
5
5
  storeId="${this.storeId}"
6
6
  subscriptionId="${this.subscriptionId}"
@@ -11,7 +11,7 @@ import{f as h,g as o,t as p,h as g,y as d}from"../chunks/lit-HCWbxxT7.esm.js";im
11
11
  countryCode="${this.countryCode}"
12
12
  lang="${this.lang}"
13
13
  ?debug="${this.debug}"
14
- @beamnonprofitselect="${r=>{if(!(r instanceof x))return;const{selectedNonprofitId:a}=r.detail;this.nonprofitId=a??null,this.activeWidget="impact-overview"}}"
14
+ @beamnonprofitselect="${n=>{if(!(n instanceof x))return;const{selectedNonprofitId:a}=n.detail;this.nonprofitId=a??null,this.activeWidget="impact-overview"}}"
15
15
  ></beam-redeem-transaction>`:this.activeWidget==="impact-overview"&&(t=d`
16
16
  <beam-impact-overview
17
17
  part="impact-overview"
@@ -61,5 +61,5 @@ import{f as h,g as o,t as p,h as g,y as d}from"../chunks/lit-HCWbxxT7.esm.js";im
61
61
  padding: var(--beam-SubscriptionManagement-widgetContainer-padding, 15px);
62
62
  max-width: var(--beam-SubscriptionManagement-widgetContainer-maxWidth, 800px);
63
63
  }
64
- }`],n([o({type:String})],e.prototype,"baseUrl",2),n([o({type:String})],e.prototype,"apiKey",2),n([o({type:String})],e.prototype,"subscriptionId",2),n([o({type:Number,reflect:!0})],e.prototype,"storeId",2),n([o({type:String})],e.prototype,"email",2),n([o({type:String})],e.prototype,"partnerUserId",2),n([o({type:String})],e.prototype,"postalCode",2),n([o({type:String})],e.prototype,"countryCode",2),n([o({type:String})],e.prototype,"lang",2),n([o({type:Object})],e.prototype,"cart",2),n([o({type:Boolean})],e.prototype,"debug",2),n([p()],e.prototype,"activeWidget",2),n([p()],e.prototype,"nonprofitId",2),n([p()],e.prototype,"userId",2),n([p()],e.prototype,"chainName",2),v(e);export{e as BeamSubscriptionManagement};
64
+ }`],o([r({type:String})],e.prototype,"baseUrl",2),o([r({type:String})],e.prototype,"apiKey",2),o([r({type:String})],e.prototype,"subscriptionId",2),o([r({type:Number,reflect:!0})],e.prototype,"storeId",2),o([r({type:String})],e.prototype,"email",2),o([r({type:String})],e.prototype,"partnerUserId",2),o([r({type:String})],e.prototype,"postalCode",2),o([r({type:String})],e.prototype,"countryCode",2),o([r({type:String})],e.prototype,"lang",2),o([r({type:Object})],e.prototype,"cart",2),o([r({type:Boolean})],e.prototype,"debug",2),o([p()],e.prototype,"activeWidget",2),o([p()],e.prototype,"nonprofitId",2),o([p()],e.prototype,"userId",2),o([p()],e.prototype,"chainName",2),v(e);export{e as BeamSubscriptionManagement};
65
65
  //# sourceMappingURL=subscription-management.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-management.esm.js","sources":["../../src/components/subscription-management/strings.ts","../../src/components/subscription-management/index.ts"],"sourcesContent":["export const strings = {\n en: {\n nonprofitSwapText: ({ brandName = \"\" }) => `Support a new nonprofit with your next ${brandName} recurring order`,\n },\n fr: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Soutenez une nouvelle organisation à but non lucratif avec votre prochaine commande récurrente ${brandName}`,\n },\n de: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Unterstützen Sie eine neue gemeinnützige Organisation mit Ihrer nächsten wiederkehrenden Bestellung bei ${brandName}`,\n },\n es: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Apoye a una nueva organización sin fines de lucro con su próximo pedido recurrente ${brandName}`,\n },\n it: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${brandName}`,\n },\n pl: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Wesprzyj nową organizację non-profit przy kolejnym zamówieniu cyklicznym ${brandName}`,\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { TCart } from \"../../shared/cart-contents\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { postFindOrCreateSubscription, postChainEligibleNonprofitsForCart } from \"../../api-sdk/v3/routes\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { BeamNonprofitSelectEvent } from \"../../utils/events\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { strings } from \"./strings\";\n\ninterface RequiredDataPropsWithEmail {\n email: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ninterface RequiredDataPropsWithPartnerUserId {\n partnerUserId: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ntype TRequiredDataProps = RequiredDataPropsWithEmail | RequiredDataPropsWithPartnerUserId;\nexport class BeamSubscriptionManagement extends LitElement {\n static tagName = \"beam-subscription-management\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: TRequiredDataProps[\"apiKey\"];\n\n @property({ type: String })\n public subscriptionId!: TRequiredDataProps[\"subscriptionId\"];\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public email?: RequiredDataPropsWithEmail[\"email\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public partnerUserId?: RequiredDataPropsWithPartnerUserId[\"partnerUserId\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // Based on /findSubscriptionByRemoteId\n @state() private nonprofitId: number | null = null; // From /findSubscriptionByRemoteId response\n @state() private userId: string | null = null; // From findSubscriptionByRemoteId\n @state() private chainName: string | null = null; // From findEligibleNonprofitsForCart\n\n private subscriptionDataController = new AsyncController<typeof this.fetchSubscription>(this, this.fetchSubscription);\n private eligibleNonprofitsDataController = new AsyncController<typeof this.fetchEligibleNonprofits>(\n this,\n this.fetchEligibleNonprofits\n );\n\n async firstUpdated() {\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [\"email\", \"partnerUserId\"],\n \"One of the following properties needs to be specified: email, partnerUserId \"\n );\n }\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n await this.loadWidget();\n }\n\n async loadWidget() {\n // In parallel:\n // (1). Fetch eligible nonprofits [storeId and chainName]\n // (2). Fetch subscription [userId and nonprofitId]\n await Promise.all([this.fetchEligibleNonprofits(), this.fetchSubscription()]);\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n }\n\n async fetchEligibleNonprofits() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const res = await postChainEligibleNonprofitsForCart({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n storeId: this.storeId || undefined,\n postalCode: this.postalCode || undefined,\n countryCode: this.countryCode || undefined,\n widgetName: \"subscription-management\",\n version: \"1.0.0\",\n },\n });\n this.chainName = res.chain.name;\n this.storeId = res.store.id;\n this.eligibleNonprofitsDataController.data = res;\n return res;\n }\n\n async fetchSubscription() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const result = await postFindOrCreateSubscription({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n remoteSubscriptionId: this.subscriptionId,\n email: this.email,\n partnerUserId: this.partnerUserId,\n },\n });\n\n this.userId = result.beamUserId; // Returned in response regardless of subscription redemption\n this.nonprofitId = result.nonprofit?.id || null;\n return result;\n }\n\n handleSwapNonprofitButtonClick() {\n this.activeWidget = \"redeem-transaction\";\n }\n\n renderSwapNonprofitButton() {\n if (this.activeWidget === \"impact-overview\") {\n return html`<button class=\"swap-nonprofit-button\" @click=\"${this.handleSwapNonprofitButtonClick}\">\n ${strings[this.lang].nonprofitSwapText({ brandName: this.chainName || \"\" })}\n </button>`;\n } else {\n return \"\";\n }\n }\n\n public get cssVariables() {\n const defaults = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"inherit\",\n \"--beam-textColor\": \"inherit\",\n \"--beam-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-borderColor\": \"#d5d5d5\",\n \"--beam-SubscriptionManagement-widgetContainer-borderRadius\": \"4px\",\n \"--beam-SubscriptionManagement-widgetContainer-padding\": \"15px\",\n \"--beam-SubscriptionManagement-widgetContainer-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-maxWidth\": \"800px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration\": \"underline\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop\": \"10px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-color\": \"inherit\",\n };\n\n const remoteConfig = this.eligibleNonprofitsDataController?.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily);\n font-style: var(--beam-fontStyle);\n font-size: var(--beam-fontSize);\n background-color: var(--beam-backgroundColor);\n color: var(--beam-textColor);\n word-break: normal;\n }\n .swap-nonprofit-button {\n margin-top: var(--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop, 10px);\n color: var(--beam-SubscriptionManagement-swapNonprofitButtonText-color, inherit);\n font-size: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize, inherit);\n text-decoration: var(--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration, underline);\n font-family: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily, inherit);\n font-style: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle, inherit);\n font-weight: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight, inherit);\n line-height: var(--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight, inherit);\n background: none;\n border: none;\n cursor: pointer;\n }\n .sub-widget-container {\n background-color: var(--beam-SubscriptionManagement-widgetContainer-backgroundColor, inherit);\n border: 1px solid var(--beam-SubscriptionManagement-widgetContainer-borderColor, #d5d5d5);\n border-radius: var(--beam-SubscriptionManagement-widgetContainer-borderRadius, 4px);\n overflow: hidden; /* maintain clean border-radius */\n padding: var(--beam-SubscriptionManagement-widgetContainer-padding, 15px);\n max-width: var(--beam-SubscriptionManagement-widgetContainer-maxWidth, 800px);\n }\n }`,\n ];\n\n render() {\n let content;\n\n if (this.subscriptionDataController.loading || this.eligibleNonprofitsDataController.loading) {\n content = \"\";\n }\n\n if ((this.subscriptionDataController.error || this.eligibleNonprofitsDataController.error) && this.debug) {\n if (this.subscriptionDataController.error !== null) {\n return _errorMessage({ error: this.subscriptionDataController.error });\n } else if (this.eligibleNonprofitsDataController.error !== null) {\n return _errorMessage({ error: this.eligibleNonprofitsDataController.error });\n }\n } else {\n content = \"\";\n }\n\n if (this.activeWidget === \"redeem-transaction\") {\n content = html` <beam-redeem-transaction\n part=\"redeem-transaction\"\n storeId=\"${this.storeId}\"\n subscriptionId=\"${this.subscriptionId}\"\n nonprofitId=${this.nonprofitId}\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof BeamNonprofitSelectEvent)) return; // TS guard\n const { selectedNonprofitId } = event.detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>`;\n } else if (this.activeWidget === \"impact-overview\") {\n content = html`\n <beam-impact-overview\n part=\"impact-overview\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div class=\"sub-widget-container\">${content}</div>\n ${this.renderSwapNonprofitButton()}\n `;\n }\n}\n\ndefineCustomElement(BeamSubscriptionManagement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-subscription-management\": BeamSubscriptionManagement;\n }\n}\n"],"names":["strings","brandName","m","h","e","l","n","t","o","i","a","d","BeamSubscriptionManagement","LitElement","DEFAULT_BASE_URL","AsyncController","MissingConfig","enforceConfig","res","postChainEligibleNonprofitsForCart","result","postFindOrCreateSubscription","html","defaults","remoteConfig","config","_cssVariableMap","content","_errorMessage","event","BeamNonprofitSelectEvent","selectedNonprofitId","cssReset","css","__decorateClass","property","state","defineCustomElement"],"mappings":"+XAAO,MAAMA,EAAU,CACrB,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAC,EAAY,EAAG,IAAM,0CAA0CA,CAAS,kBAChG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,wGAAkGA,CAAS,EAC/G,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,oHAA2GA,CAAS,EACxH,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,4FAAsFA,CAAS,EACnG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,sFAAsFA,CAAS,EACnG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,yFAA4EA,CAAS,EACzF,CACF,ECxBA,IAAAC,EAAA,OAAA,eAAAC,EAAA,OAAA,yBAAAC,EAAA,CAAAC,EAAAC,EAAAC,EAAAC,IAAA,CAAA,QAAAC,EAAAD,EAAA,EAAA,OAAAA,EAAAL,EAAAG,EAAAC,CAAA,EAAAD,EAAAI,EAAAL,EAAA,OAAA,EAAAM,EAAAD,GAAA,EAAAA,KAAAC,EAAAN,EAAAK,CAAA,KAAAD,GAAAD,EAAAG,EAAAL,EAAAC,EAAAE,CAAA,EAAAE,EAAAF,CAAA,IAAAA,GAAA,OAAAD,GAAAC,GAAAP,EAAAI,EAAAC,EAAAE,CAAA,EAAAA,CAAA,EA8Ba,MAAAG,UAAmCC,CAAW,CAApD,aAIL,CAAA,MA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AAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CATf,EAAAvB,EAUJ,8BAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,CAZ9B,EAAAvB,EAaJ,UAGAsB,UAAAA,CAAAA,EAAAA,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAffvB,EAgBJ,UAAA,QAAA,CAAA,EAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAlBf,EAAAvB,EAmBJ,UAGAsB,gBAAAA,CAAAA,EAAAA,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EArBfvB,EAsBJ,UAAA,aAAA,CAAA,EAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAxBfvB,EAyBJ,UAAA,cAAA,CAAA,EAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CA3Bf,EAAAvB,EA4BJ,oBAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EA9BfvB,EA+BJ,UAGAsB,OAAAA,CAAAA,EAAAA,EAAA,CADNC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAjChBvB,EAkCJ,UAAA,QAAA,CAAA,EAEUsB,EAAA,CAAhBE,EAAM,CAAA,EApCIxB,EAoCM,UAAA,eAAA,CAAA,EACAsB,EAAA,CAAhBE,GArCU,EAAAxB,EAqCM,UACAsB,cAAAA,CAAAA,EAAAA,EAAA,CAAhBE,KAtCUxB,EAsCM,UAAA,SAAA,CAAA,EACAsB,EAAA,CAAhBE,EAAM,CAAA,EAvCIxB,EAuCM,UAAA,YAAA,CAAA,EAoNnByB,EAAoBzB,CAA0B"}
1
+ {"version":3,"file":"subscription-management.esm.js","sources":["../../src/components/subscription-management/strings.ts","../../src/components/subscription-management/index.ts"],"sourcesContent":["export const strings = {\n en: {\n nonprofitSwapText: ({ brandName = \"\" }) => `Support a new nonprofit with your next ${brandName} recurring order`,\n },\n fr: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Soutenez une nouvelle organisation à but non lucratif avec votre prochaine commande récurrente ${brandName}`,\n },\n de: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Unterstützen Sie eine neue gemeinnützige Organisation mit Ihrer nächsten wiederkehrenden Bestellung bei ${brandName}`,\n },\n es: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Apoye a una nueva organización sin fines de lucro con su próximo pedido recurrente ${brandName}`,\n },\n it: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${brandName}`,\n },\n pl: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Wesprzyj nową organizację non-profit przy kolejnym zamówieniu cyklicznym ${brandName}`,\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { TCart } from \"../../shared/cart-contents\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { postFindOrCreateSubscription, postChainEligibleNonprofitsForCart } from \"../../api-sdk/v3/routes\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { BeamNonprofitSelectEvent } from \"../../utils/events\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { strings } from \"./strings\";\nimport \"../redeem-transaction\";\nimport \"../impact-overview\";\n\ninterface RequiredDataPropsWithEmail {\n email: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ninterface RequiredDataPropsWithPartnerUserId {\n partnerUserId: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ntype TRequiredDataProps = RequiredDataPropsWithEmail | RequiredDataPropsWithPartnerUserId;\nexport class BeamSubscriptionManagement extends LitElement {\n static tagName = \"beam-subscription-management\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: TRequiredDataProps[\"apiKey\"];\n\n @property({ type: String })\n public subscriptionId!: TRequiredDataProps[\"subscriptionId\"];\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public email?: RequiredDataPropsWithEmail[\"email\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public partnerUserId?: RequiredDataPropsWithPartnerUserId[\"partnerUserId\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // Based on /findSubscriptionByRemoteId\n @state() private nonprofitId: number | null = null; // From /findSubscriptionByRemoteId response\n @state() private userId: string | null = null; // From findSubscriptionByRemoteId\n @state() private chainName: string | null = null; // From findEligibleNonprofitsForCart\n\n private subscriptionDataController = new AsyncController<typeof this.fetchSubscription>(this, this.fetchSubscription);\n private eligibleNonprofitsDataController = new AsyncController<typeof this.fetchEligibleNonprofits>(\n this,\n this.fetchEligibleNonprofits\n );\n\n async firstUpdated() {\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [\"email\", \"partnerUserId\"],\n \"One of the following properties needs to be specified: email, partnerUserId \"\n );\n }\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n await this.loadWidget();\n }\n\n async loadWidget() {\n // In parallel:\n // (1). Fetch eligible nonprofits [storeId and chainName]\n // (2). Fetch subscription [userId and nonprofitId]\n await Promise.all([this.fetchEligibleNonprofits(), this.fetchSubscription()]);\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n }\n\n async fetchEligibleNonprofits() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const res = await postChainEligibleNonprofitsForCart({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n storeId: this.storeId || undefined,\n postalCode: this.postalCode || undefined,\n countryCode: this.countryCode || undefined,\n widgetName: \"subscription-management\",\n version: \"1.0.0\",\n },\n });\n this.chainName = res.chain.name;\n this.storeId = res.store.id;\n this.eligibleNonprofitsDataController.data = res;\n return res;\n }\n\n async fetchSubscription() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const result = await postFindOrCreateSubscription({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n remoteSubscriptionId: this.subscriptionId,\n email: this.email,\n partnerUserId: this.partnerUserId,\n },\n });\n\n this.userId = result.beamUserId; // Returned in response regardless of subscription redemption\n this.nonprofitId = result.nonprofit?.id || null;\n return result;\n }\n\n handleSwapNonprofitButtonClick() {\n this.activeWidget = \"redeem-transaction\";\n }\n\n renderSwapNonprofitButton() {\n if (this.activeWidget === \"impact-overview\") {\n return html`<button class=\"swap-nonprofit-button\" @click=\"${this.handleSwapNonprofitButtonClick}\">\n ${strings[this.lang].nonprofitSwapText({ brandName: this.chainName || \"\" })}\n </button>`;\n } else {\n return \"\";\n }\n }\n\n public get cssVariables() {\n const defaults = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"inherit\",\n \"--beam-textColor\": \"inherit\",\n \"--beam-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-borderColor\": \"#d5d5d5\",\n \"--beam-SubscriptionManagement-widgetContainer-borderRadius\": \"4px\",\n \"--beam-SubscriptionManagement-widgetContainer-padding\": \"15px\",\n \"--beam-SubscriptionManagement-widgetContainer-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-maxWidth\": \"800px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration\": \"underline\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop\": \"10px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-color\": \"inherit\",\n };\n\n const remoteConfig = this.eligibleNonprofitsDataController?.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily);\n font-style: var(--beam-fontStyle);\n font-size: var(--beam-fontSize);\n background-color: var(--beam-backgroundColor);\n color: var(--beam-textColor);\n word-break: normal;\n }\n .swap-nonprofit-button {\n margin-top: var(--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop, 10px);\n color: var(--beam-SubscriptionManagement-swapNonprofitButtonText-color, inherit);\n font-size: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize, inherit);\n text-decoration: var(--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration, underline);\n font-family: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily, inherit);\n font-style: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle, inherit);\n font-weight: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight, inherit);\n line-height: var(--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight, inherit);\n background: none;\n border: none;\n cursor: pointer;\n }\n .sub-widget-container {\n background-color: var(--beam-SubscriptionManagement-widgetContainer-backgroundColor, inherit);\n border: 1px solid var(--beam-SubscriptionManagement-widgetContainer-borderColor, #d5d5d5);\n border-radius: var(--beam-SubscriptionManagement-widgetContainer-borderRadius, 4px);\n overflow: hidden; /* maintain clean border-radius */\n padding: var(--beam-SubscriptionManagement-widgetContainer-padding, 15px);\n max-width: var(--beam-SubscriptionManagement-widgetContainer-maxWidth, 800px);\n }\n }`,\n ];\n\n render() {\n let content;\n\n if (this.subscriptionDataController.loading || this.eligibleNonprofitsDataController.loading) {\n content = \"\";\n }\n\n if ((this.subscriptionDataController.error || this.eligibleNonprofitsDataController.error) && this.debug) {\n if (this.subscriptionDataController.error !== null) {\n return _errorMessage({ error: this.subscriptionDataController.error });\n } else if (this.eligibleNonprofitsDataController.error !== null) {\n return _errorMessage({ error: this.eligibleNonprofitsDataController.error });\n }\n } else {\n content = \"\";\n }\n\n if (this.activeWidget === \"redeem-transaction\") {\n content = html` <beam-redeem-transaction\n part=\"redeem-transaction\"\n storeId=\"${this.storeId}\"\n subscriptionId=\"${this.subscriptionId}\"\n nonprofitId=${this.nonprofitId}\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof BeamNonprofitSelectEvent)) return; // TS guard\n const { selectedNonprofitId } = event.detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>`;\n } else if (this.activeWidget === \"impact-overview\") {\n content = html`\n <beam-impact-overview\n part=\"impact-overview\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div class=\"sub-widget-container\">${content}</div>\n ${this.renderSwapNonprofitButton()}\n `;\n }\n}\n\ndefineCustomElement(BeamSubscriptionManagement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-subscription-management\": BeamSubscriptionManagement;\n }\n}\n"],"names":["strings","brandName","m","h","e","l","n","t","o","i","a","d","BeamSubscriptionManagement","LitElement","DEFAULT_BASE_URL","AsyncController","MissingConfig","enforceConfig","res","postChainEligibleNonprofitsForCart","result","postFindOrCreateSubscription","html","defaults","remoteConfig","config","_cssVariableMap","content","_errorMessage","event","BeamNonprofitSelectEvent","selectedNonprofitId","cssReset","css","__decorateClass","property","state","defineCustomElement"],"mappings":"y7BAAO,MAAMA,EAAU,CACrB,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAC,EAAY,EAAG,IAAM,0CAA0CA,CAAS,kBAChG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,wGAAkGA,CAAS,EAC/G,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,oHAA2GA,CAAS,EACxH,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,4FAAsFA,CAAS,EACnG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,sFAAsFA,CAAS,EACnG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,yFAA4EA,CAAS,EACzF,CACF,ECxBA,IAAAC,EAAA,OAAA,eAAAC,EAAA,OAAA,yBAAAC,EAAA,CAAAC,EAAAC,EAAAC,EAAAC,IAAA,CAAA,QAAAC,EAAAD,EAAA,EAAA,OA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UACAsB,cAAAA,CAAAA,EAAAA,EAAA,CAAhBE,KAtCUxB,EAsCM,UAAA,SAAA,CAAA,EACAsB,EAAA,CAAhBE,EAAM,CAAA,EAvCIxB,EAuCM,UAAA,YAAA,CAAA,EAoNnByB,EAAoBzB,CAA0B"}
@@ -1,6 +1,6 @@
1
- import{f as h,g as o,t as p,h as g,y as d}from"../chunks/lit-HCWbxxT7.esm.js";import{D as f,e as y,f as w}from"../chunks/routes-t5eRHMRc.esm.js";import{c as S,d as v,A as u,e as b,a as C,_ as m}from"../chunks/enforce-config-iFdf1QkH.esm.js";import{c as x}from"../chunks/events-Y8fYvSqM.esm.js";import{M as N}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.js";const I={en:{nonprofitSwapText:({brandName:i=""})=>`Support a new nonprofit with your next ${i} recurring order`},fr:{nonprofitSwapText:({brandName:i=""})=>`Soutenez une nouvelle organisation \xE0 but non lucratif avec votre prochaine commande r\xE9currente ${i}`},de:{nonprofitSwapText:({brandName:i=""})=>`Unterst\xFCtzen Sie eine neue gemeinn\xFCtzige Organisation mit Ihrer n\xE4chsten wiederkehrenden Bestellung bei ${i}`},es:{nonprofitSwapText:({brandName:i=""})=>`Apoye a una nueva organizaci\xF3n sin fines de lucro con su pr\xF3ximo pedido recurrente ${i}`},it:{nonprofitSwapText:({brandName:i=""})=>`Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${i}`},pl:{nonprofitSwapText:({brandName:i=""})=>`Wesprzyj now\u0105 organizacj\u0119 non-profit przy kolejnym zam\xF3wieniu cyklicznym ${i}`}};var M=Object.defineProperty,$=Object.getOwnPropertyDescriptor,n=(i,t,r,a)=>{for(var s=a>1?void 0:a?$(t,r):t,l=i.length-1,c;l>=0;l--)(c=i[l])&&(s=(a?c(t,r,s):c(s))||s);return a&&s&&M(t,r,s),s};class e extends g{constructor(){super(...arguments),this.baseUrl=f,this.lang="en",this.debug=!1,this.activeWidget=null,this.nonprofitId=null,this.userId=null,this.chainName=null,this.subscriptionDataController=new u(this,this.fetchSubscription),this.eligibleNonprofitsDataController=new u(this,this.fetchEligibleNonprofits)}async firstUpdated(){if(!this.email&&!this.partnerUserId)throw new N(["email","partnerUserId"],"One of the following properties needs to be specified: email, partnerUserId ");b(["apiKey","subscriptionId"],this),await this.loadWidget()}async loadWidget(){await Promise.all([this.fetchEligibleNonprofits(),this.fetchSubscription()]),this.activeWidget=this.nonprofitId?"impact-overview":"redeem-transaction"}async fetchEligibleNonprofits(){b(["apiKey","subscriptionId"],this);const t=await y({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId||void 0,postalCode:this.postalCode||void 0,countryCode:this.countryCode||void 0,widgetName:"subscription-management",version:"1.0.0"}});return this.chainName=t.chain.name,this.storeId=t.store.id,this.eligibleNonprofitsDataController.data=t,t}async fetchSubscription(){b(["apiKey","subscriptionId"],this);const t=await w({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return this.userId=t.beamUserId,this.nonprofitId=t.nonprofit?.id||null,t}handleSwapNonprofitButtonClick(){this.activeWidget="redeem-transaction"}renderSwapNonprofitButton(){return this.activeWidget==="impact-overview"?d`<button class="swap-nonprofit-button" @click="${this.handleSwapNonprofitButtonClick}">
1
+ import{f as h,g as r,t as p,h as g,y as d}from"../chunks/lit-qtGbjGnK.esm.js";import{D as f,f as y,h as w}from"../chunks/routes-eEIGOCLH.esm.js";import{c as S,d as v,A as c,e as b,b as C,_ as u}from"../chunks/localize-fH8KOrMi.esm.js";import{c as x}from"../chunks/events-Y8fYvSqM.esm.js";import{M as N}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import"./redeem-transaction.js";import"./impact-overview.js";import"../utils/logger.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/progress-bar-Sn2QspHy.esm.js";import"../chunks/promo-pill-label-j0A8qZ0c.esm.js";import"../chunks/vendor-jQ8cxMpw.esm.js";import"./beam-partner-logos.js";import"../chunks/loading-template-Av0IUyKF.esm.js";import"../utils/local-storage.js";import"../chunks/css-card-grid-7tObtoJx.esm.js";import"../chunks/shoelace-components-yvcqUObE.esm.js";import"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../chunks/responsive-aWj_7ZN_.esm.js";const I={en:{nonprofitSwapText:({brandName:i=""})=>`Support a new nonprofit with your next ${i} recurring order`},fr:{nonprofitSwapText:({brandName:i=""})=>`Soutenez une nouvelle organisation \xE0 but non lucratif avec votre prochaine commande r\xE9currente ${i}`},de:{nonprofitSwapText:({brandName:i=""})=>`Unterst\xFCtzen Sie eine neue gemeinn\xFCtzige Organisation mit Ihrer n\xE4chsten wiederkehrenden Bestellung bei ${i}`},es:{nonprofitSwapText:({brandName:i=""})=>`Apoye a una nueva organizaci\xF3n sin fines de lucro con su pr\xF3ximo pedido recurrente ${i}`},it:{nonprofitSwapText:({brandName:i=""})=>`Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${i}`},pl:{nonprofitSwapText:({brandName:i=""})=>`Wesprzyj now\u0105 organizacj\u0119 non-profit przy kolejnym zam\xF3wieniu cyklicznym ${i}`}};var M=Object.defineProperty,$=Object.getOwnPropertyDescriptor,o=(i,t,n,a)=>{for(var s=a>1?void 0:a?$(t,n):t,l=i.length-1,m;l>=0;l--)(m=i[l])&&(s=(a?m(t,n,s):m(s))||s);return a&&s&&M(t,n,s),s};class e extends g{constructor(){super(...arguments),this.baseUrl=f,this.lang="en",this.debug=!1,this.activeWidget=null,this.nonprofitId=null,this.userId=null,this.chainName=null,this.subscriptionDataController=new c(this,this.fetchSubscription),this.eligibleNonprofitsDataController=new c(this,this.fetchEligibleNonprofits)}async firstUpdated(){if(!this.email&&!this.partnerUserId)throw new N(["email","partnerUserId"],"One of the following properties needs to be specified: email, partnerUserId ");b(["apiKey","subscriptionId"],this),await this.loadWidget()}async loadWidget(){await Promise.all([this.fetchEligibleNonprofits(),this.fetchSubscription()]),this.activeWidget=this.nonprofitId?"impact-overview":"redeem-transaction"}async fetchEligibleNonprofits(){b(["apiKey","subscriptionId"],this);const t=await y({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId||void 0,postalCode:this.postalCode||void 0,countryCode:this.countryCode||void 0,widgetName:"subscription-management",version:"1.0.0"}});return this.chainName=t.chain.name,this.storeId=t.store.id,this.eligibleNonprofitsDataController.data=t,t}async fetchSubscription(){b(["apiKey","subscriptionId"],this);const t=await w({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return this.userId=t.beamUserId,this.nonprofitId=t.nonprofit?.id||null,t}handleSwapNonprofitButtonClick(){this.activeWidget="redeem-transaction"}renderSwapNonprofitButton(){return this.activeWidget==="impact-overview"?d`<button class="swap-nonprofit-button" @click="${this.handleSwapNonprofitButtonClick}">
2
2
  ${I[this.lang].nonprofitSwapText({brandName:this.chainName||""})}
3
- </button>`:""}get cssVariables(){const t={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-borderColor":"#d5d5d5","--beam-SubscriptionManagement-widgetContainer-borderRadius":"4px","--beam-SubscriptionManagement-widgetContainer-padding":"15px","--beam-SubscriptionManagement-widgetContainer-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-maxWidth":"800px","--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration":"underline","--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop":"10px","--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-color":"inherit"},r=this.eligibleNonprofitsDataController?.data?.config?.web?.theme||{},a={...t,...r};return Object.assign(Object.create({toCSS(){return C(this)}}),a)}render(){let t;if((this.subscriptionDataController.loading||this.eligibleNonprofitsDataController.loading)&&(t=""),(this.subscriptionDataController.error||this.eligibleNonprofitsDataController.error)&&this.debug){if(this.subscriptionDataController.error!==null)return m({error:this.subscriptionDataController.error});if(this.eligibleNonprofitsDataController.error!==null)return m({error:this.eligibleNonprofitsDataController.error})}else t="";return this.activeWidget==="redeem-transaction"?t=d` <beam-redeem-transaction
3
+ </button>`:""}get cssVariables(){const t={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-borderColor":"#d5d5d5","--beam-SubscriptionManagement-widgetContainer-borderRadius":"4px","--beam-SubscriptionManagement-widgetContainer-padding":"15px","--beam-SubscriptionManagement-widgetContainer-backgroundColor":"inherit","--beam-SubscriptionManagement-widgetContainer-maxWidth":"800px","--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration":"underline","--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop":"10px","--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize":"inherit","--beam-SubscriptionManagement-swapNonprofitButtonText-color":"inherit"},n=this.eligibleNonprofitsDataController?.data?.config?.web?.theme||{},a={...t,...n};return Object.assign(Object.create({toCSS(){return C(this)}}),a)}render(){let t;if((this.subscriptionDataController.loading||this.eligibleNonprofitsDataController.loading)&&(t=""),(this.subscriptionDataController.error||this.eligibleNonprofitsDataController.error)&&this.debug){if(this.subscriptionDataController.error!==null)return u({error:this.subscriptionDataController.error});if(this.eligibleNonprofitsDataController.error!==null)return u({error:this.eligibleNonprofitsDataController.error})}else t="";return this.activeWidget==="redeem-transaction"?t=d` <beam-redeem-transaction
4
4
  part="redeem-transaction"
5
5
  storeId="${this.storeId}"
6
6
  subscriptionId="${this.subscriptionId}"
@@ -11,7 +11,7 @@ import{f as h,g as o,t as p,h as g,y as d}from"../chunks/lit-HCWbxxT7.esm.js";im
11
11
  countryCode="${this.countryCode}"
12
12
  lang="${this.lang}"
13
13
  ?debug="${this.debug}"
14
- @beamnonprofitselect="${r=>{if(!(r instanceof x))return;const{selectedNonprofitId:a}=r.detail;this.nonprofitId=a??null,this.activeWidget="impact-overview"}}"
14
+ @beamnonprofitselect="${n=>{if(!(n instanceof x))return;const{selectedNonprofitId:a}=n.detail;this.nonprofitId=a??null,this.activeWidget="impact-overview"}}"
15
15
  ></beam-redeem-transaction>`:this.activeWidget==="impact-overview"&&(t=d`
16
16
  <beam-impact-overview
17
17
  part="impact-overview"
@@ -61,5 +61,5 @@ import{f as h,g as o,t as p,h as g,y as d}from"../chunks/lit-HCWbxxT7.esm.js";im
61
61
  padding: var(--beam-SubscriptionManagement-widgetContainer-padding, 15px);
62
62
  max-width: var(--beam-SubscriptionManagement-widgetContainer-maxWidth, 800px);
63
63
  }
64
- }`],n([o({type:String})],e.prototype,"baseUrl",2),n([o({type:String})],e.prototype,"apiKey",2),n([o({type:String})],e.prototype,"subscriptionId",2),n([o({type:Number,reflect:!0})],e.prototype,"storeId",2),n([o({type:String})],e.prototype,"email",2),n([o({type:String})],e.prototype,"partnerUserId",2),n([o({type:String})],e.prototype,"postalCode",2),n([o({type:String})],e.prototype,"countryCode",2),n([o({type:String})],e.prototype,"lang",2),n([o({type:Object})],e.prototype,"cart",2),n([o({type:Boolean})],e.prototype,"debug",2),n([p()],e.prototype,"activeWidget",2),n([p()],e.prototype,"nonprofitId",2),n([p()],e.prototype,"userId",2),n([p()],e.prototype,"chainName",2),v(e);export{e as BeamSubscriptionManagement};
64
+ }`],o([r({type:String})],e.prototype,"baseUrl",2),o([r({type:String})],e.prototype,"apiKey",2),o([r({type:String})],e.prototype,"subscriptionId",2),o([r({type:Number,reflect:!0})],e.prototype,"storeId",2),o([r({type:String})],e.prototype,"email",2),o([r({type:String})],e.prototype,"partnerUserId",2),o([r({type:String})],e.prototype,"postalCode",2),o([r({type:String})],e.prototype,"countryCode",2),o([r({type:String})],e.prototype,"lang",2),o([r({type:Object})],e.prototype,"cart",2),o([r({type:Boolean})],e.prototype,"debug",2),o([p()],e.prototype,"activeWidget",2),o([p()],e.prototype,"nonprofitId",2),o([p()],e.prototype,"userId",2),o([p()],e.prototype,"chainName",2),v(e);export{e as BeamSubscriptionManagement};
65
65
  //# sourceMappingURL=subscription-management.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-management.js","sources":["../../src/components/subscription-management/strings.ts","../../src/components/subscription-management/index.ts"],"sourcesContent":["export const strings = {\n en: {\n nonprofitSwapText: ({ brandName = \"\" }) => `Support a new nonprofit with your next ${brandName} recurring order`,\n },\n fr: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Soutenez une nouvelle organisation à but non lucratif avec votre prochaine commande récurrente ${brandName}`,\n },\n de: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Unterstützen Sie eine neue gemeinnützige Organisation mit Ihrer nächsten wiederkehrenden Bestellung bei ${brandName}`,\n },\n es: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Apoye a una nueva organización sin fines de lucro con su próximo pedido recurrente ${brandName}`,\n },\n it: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${brandName}`,\n },\n pl: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Wesprzyj nową organizację non-profit przy kolejnym zamówieniu cyklicznym ${brandName}`,\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { TCart } from \"../../shared/cart-contents\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { postFindOrCreateSubscription, postChainEligibleNonprofitsForCart } from \"../../api-sdk/v3/routes\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { BeamNonprofitSelectEvent } from \"../../utils/events\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { strings } from \"./strings\";\n\ninterface RequiredDataPropsWithEmail {\n email: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ninterface RequiredDataPropsWithPartnerUserId {\n partnerUserId: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ntype TRequiredDataProps = RequiredDataPropsWithEmail | RequiredDataPropsWithPartnerUserId;\nexport class BeamSubscriptionManagement extends LitElement {\n static tagName = \"beam-subscription-management\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: TRequiredDataProps[\"apiKey\"];\n\n @property({ type: String })\n public subscriptionId!: TRequiredDataProps[\"subscriptionId\"];\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public email?: RequiredDataPropsWithEmail[\"email\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public partnerUserId?: RequiredDataPropsWithPartnerUserId[\"partnerUserId\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // Based on /findSubscriptionByRemoteId\n @state() private nonprofitId: number | null = null; // From /findSubscriptionByRemoteId response\n @state() private userId: string | null = null; // From findSubscriptionByRemoteId\n @state() private chainName: string | null = null; // From findEligibleNonprofitsForCart\n\n private subscriptionDataController = new AsyncController<typeof this.fetchSubscription>(this, this.fetchSubscription);\n private eligibleNonprofitsDataController = new AsyncController<typeof this.fetchEligibleNonprofits>(\n this,\n this.fetchEligibleNonprofits\n );\n\n async firstUpdated() {\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [\"email\", \"partnerUserId\"],\n \"One of the following properties needs to be specified: email, partnerUserId \"\n );\n }\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n await this.loadWidget();\n }\n\n async loadWidget() {\n // In parallel:\n // (1). Fetch eligible nonprofits [storeId and chainName]\n // (2). Fetch subscription [userId and nonprofitId]\n await Promise.all([this.fetchEligibleNonprofits(), this.fetchSubscription()]);\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n }\n\n async fetchEligibleNonprofits() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const res = await postChainEligibleNonprofitsForCart({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n storeId: this.storeId || undefined,\n postalCode: this.postalCode || undefined,\n countryCode: this.countryCode || undefined,\n widgetName: \"subscription-management\",\n version: \"1.0.0\",\n },\n });\n this.chainName = res.chain.name;\n this.storeId = res.store.id;\n this.eligibleNonprofitsDataController.data = res;\n return res;\n }\n\n async fetchSubscription() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const result = await postFindOrCreateSubscription({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n remoteSubscriptionId: this.subscriptionId,\n email: this.email,\n partnerUserId: this.partnerUserId,\n },\n });\n\n this.userId = result.beamUserId; // Returned in response regardless of subscription redemption\n this.nonprofitId = result.nonprofit?.id || null;\n return result;\n }\n\n handleSwapNonprofitButtonClick() {\n this.activeWidget = \"redeem-transaction\";\n }\n\n renderSwapNonprofitButton() {\n if (this.activeWidget === \"impact-overview\") {\n return html`<button class=\"swap-nonprofit-button\" @click=\"${this.handleSwapNonprofitButtonClick}\">\n ${strings[this.lang].nonprofitSwapText({ brandName: this.chainName || \"\" })}\n </button>`;\n } else {\n return \"\";\n }\n }\n\n public get cssVariables() {\n const defaults = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"inherit\",\n \"--beam-textColor\": \"inherit\",\n \"--beam-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-borderColor\": \"#d5d5d5\",\n \"--beam-SubscriptionManagement-widgetContainer-borderRadius\": \"4px\",\n \"--beam-SubscriptionManagement-widgetContainer-padding\": \"15px\",\n \"--beam-SubscriptionManagement-widgetContainer-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-maxWidth\": \"800px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration\": \"underline\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop\": \"10px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-color\": \"inherit\",\n };\n\n const remoteConfig = this.eligibleNonprofitsDataController?.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily);\n font-style: var(--beam-fontStyle);\n font-size: var(--beam-fontSize);\n background-color: var(--beam-backgroundColor);\n color: var(--beam-textColor);\n word-break: normal;\n }\n .swap-nonprofit-button {\n margin-top: var(--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop, 10px);\n color: var(--beam-SubscriptionManagement-swapNonprofitButtonText-color, inherit);\n font-size: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize, inherit);\n text-decoration: var(--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration, underline);\n font-family: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily, inherit);\n font-style: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle, inherit);\n font-weight: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight, inherit);\n line-height: var(--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight, inherit);\n background: none;\n border: none;\n cursor: pointer;\n }\n .sub-widget-container {\n background-color: var(--beam-SubscriptionManagement-widgetContainer-backgroundColor, inherit);\n border: 1px solid var(--beam-SubscriptionManagement-widgetContainer-borderColor, #d5d5d5);\n border-radius: var(--beam-SubscriptionManagement-widgetContainer-borderRadius, 4px);\n overflow: hidden; /* maintain clean border-radius */\n padding: var(--beam-SubscriptionManagement-widgetContainer-padding, 15px);\n max-width: var(--beam-SubscriptionManagement-widgetContainer-maxWidth, 800px);\n }\n }`,\n ];\n\n render() {\n let content;\n\n if (this.subscriptionDataController.loading || this.eligibleNonprofitsDataController.loading) {\n content = \"\";\n }\n\n if ((this.subscriptionDataController.error || this.eligibleNonprofitsDataController.error) && this.debug) {\n if (this.subscriptionDataController.error !== null) {\n return _errorMessage({ error: this.subscriptionDataController.error });\n } else if (this.eligibleNonprofitsDataController.error !== null) {\n return _errorMessage({ error: this.eligibleNonprofitsDataController.error });\n }\n } else {\n content = \"\";\n }\n\n if (this.activeWidget === \"redeem-transaction\") {\n content = html` <beam-redeem-transaction\n part=\"redeem-transaction\"\n storeId=\"${this.storeId}\"\n subscriptionId=\"${this.subscriptionId}\"\n nonprofitId=${this.nonprofitId}\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof BeamNonprofitSelectEvent)) return; // TS guard\n const { selectedNonprofitId } = event.detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>`;\n } else if (this.activeWidget === \"impact-overview\") {\n content = html`\n <beam-impact-overview\n part=\"impact-overview\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div class=\"sub-widget-container\">${content}</div>\n ${this.renderSwapNonprofitButton()}\n `;\n }\n}\n\ndefineCustomElement(BeamSubscriptionManagement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-subscription-management\": BeamSubscriptionManagement;\n }\n}\n"],"names":["strings","brandName","m","h","e","l","n","t","o","i","a","d","BeamSubscriptionManagement","LitElement","DEFAULT_BASE_URL","AsyncController","MissingConfig","enforceConfig","res","postChainEligibleNonprofitsForCart","result","postFindOrCreateSubscription","html","defaults","remoteConfig","config","_cssVariableMap","content","_errorMessage","event","BeamNonprofitSelectEvent","selectedNonprofitId","cssReset","css","__decorateClass","property","state","defineCustomElement"],"mappings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,CAAA,EAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAlBf,EAAAvB,EAmBJ,UAGAsB,gBAAAA,CAAAA,EAAAA,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EArBfvB,EAsBJ,UAAA,aAAA,CAAA,EAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAxBfvB,EAyBJ,UAAA,cAAA,CAAA,EAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CA3Bf,EAAAvB,EA4BJ,oBAGAsB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EA9BfvB,EA+BJ,UAGAsB,OAAAA,CAAAA,EAAAA,EAAA,CADNC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAjChBvB,EAkCJ,UAAA,QAAA,CAAA,EAEUsB,EAAA,CAAhBE,EAAM,CAAA,EApCIxB,EAoCM,UAAA,eAAA,CAAA,EACAsB,EAAA,CAAhBE,GArCU,EAAAxB,EAqCM,UACAsB,cAAAA,CAAAA,EAAAA,EAAA,CAAhBE,KAtCUxB,EAsCM,UAAA,SAAA,CAAA,EACAsB,EAAA,CAAhBE,EAAM,CAAA,EAvCIxB,EAuCM,UAAA,YAAA,CAAA,EAoNnByB,EAAoBzB,CAA0B"}
1
+ {"version":3,"file":"subscription-management.js","sources":["../../src/components/subscription-management/strings.ts","../../src/components/subscription-management/index.ts"],"sourcesContent":["export const strings = {\n en: {\n nonprofitSwapText: ({ brandName = \"\" }) => `Support a new nonprofit with your next ${brandName} recurring order`,\n },\n fr: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Soutenez une nouvelle organisation à but non lucratif avec votre prochaine commande récurrente ${brandName}`,\n },\n de: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Unterstützen Sie eine neue gemeinnützige Organisation mit Ihrer nächsten wiederkehrenden Bestellung bei ${brandName}`,\n },\n es: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Apoye a una nueva organización sin fines de lucro con su próximo pedido recurrente ${brandName}`,\n },\n it: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Sostieni una nuova organizzazione non profit con il tuo prossimo ordine ricorrente ${brandName}`,\n },\n pl: {\n nonprofitSwapText: ({ brandName = \"\" }) =>\n `Wesprzyj nową organizację non-profit przy kolejnym zamówieniu cyklicznym ${brandName}`,\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { TCart } from \"../../shared/cart-contents\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { postFindOrCreateSubscription, postChainEligibleNonprofitsForCart } from \"../../api-sdk/v3/routes\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { BeamNonprofitSelectEvent } from \"../../utils/events\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { strings } from \"./strings\";\nimport \"../redeem-transaction\";\nimport \"../impact-overview\";\n\ninterface RequiredDataPropsWithEmail {\n email: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ninterface RequiredDataPropsWithPartnerUserId {\n partnerUserId: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ntype TRequiredDataProps = RequiredDataPropsWithEmail | RequiredDataPropsWithPartnerUserId;\nexport class BeamSubscriptionManagement extends LitElement {\n static tagName = \"beam-subscription-management\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: TRequiredDataProps[\"apiKey\"];\n\n @property({ type: String })\n public subscriptionId!: TRequiredDataProps[\"subscriptionId\"];\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public email?: RequiredDataPropsWithEmail[\"email\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public partnerUserId?: RequiredDataPropsWithPartnerUserId[\"partnerUserId\"]; // Either email or partnerUserId must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // Based on /findSubscriptionByRemoteId\n @state() private nonprofitId: number | null = null; // From /findSubscriptionByRemoteId response\n @state() private userId: string | null = null; // From findSubscriptionByRemoteId\n @state() private chainName: string | null = null; // From findEligibleNonprofitsForCart\n\n private subscriptionDataController = new AsyncController<typeof this.fetchSubscription>(this, this.fetchSubscription);\n private eligibleNonprofitsDataController = new AsyncController<typeof this.fetchEligibleNonprofits>(\n this,\n this.fetchEligibleNonprofits\n );\n\n async firstUpdated() {\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [\"email\", \"partnerUserId\"],\n \"One of the following properties needs to be specified: email, partnerUserId \"\n );\n }\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n await this.loadWidget();\n }\n\n async loadWidget() {\n // In parallel:\n // (1). Fetch eligible nonprofits [storeId and chainName]\n // (2). Fetch subscription [userId and nonprofitId]\n await Promise.all([this.fetchEligibleNonprofits(), this.fetchSubscription()]);\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n }\n\n async fetchEligibleNonprofits() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const res = await postChainEligibleNonprofitsForCart({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n storeId: this.storeId || undefined,\n postalCode: this.postalCode || undefined,\n countryCode: this.countryCode || undefined,\n widgetName: \"subscription-management\",\n version: \"1.0.0\",\n },\n });\n this.chainName = res.chain.name;\n this.storeId = res.store.id;\n this.eligibleNonprofitsDataController.data = res;\n return res;\n }\n\n async fetchSubscription() {\n enforceConfig<TRequiredDataProps>([\"apiKey\", \"subscriptionId\"], this);\n const result = await postFindOrCreateSubscription({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n remoteSubscriptionId: this.subscriptionId,\n email: this.email,\n partnerUserId: this.partnerUserId,\n },\n });\n\n this.userId = result.beamUserId; // Returned in response regardless of subscription redemption\n this.nonprofitId = result.nonprofit?.id || null;\n return result;\n }\n\n handleSwapNonprofitButtonClick() {\n this.activeWidget = \"redeem-transaction\";\n }\n\n renderSwapNonprofitButton() {\n if (this.activeWidget === \"impact-overview\") {\n return html`<button class=\"swap-nonprofit-button\" @click=\"${this.handleSwapNonprofitButtonClick}\">\n ${strings[this.lang].nonprofitSwapText({ brandName: this.chainName || \"\" })}\n </button>`;\n } else {\n return \"\";\n }\n }\n\n public get cssVariables() {\n const defaults = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"inherit\",\n \"--beam-textColor\": \"inherit\",\n \"--beam-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-borderColor\": \"#d5d5d5\",\n \"--beam-SubscriptionManagement-widgetContainer-borderRadius\": \"4px\",\n \"--beam-SubscriptionManagement-widgetContainer-padding\": \"15px\",\n \"--beam-SubscriptionManagement-widgetContainer-backgroundColor\": \"inherit\",\n \"--beam-SubscriptionManagement-widgetContainer-maxWidth\": \"800px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration\": \"underline\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop\": \"10px\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize\": \"inherit\",\n \"--beam-SubscriptionManagement-swapNonprofitButtonText-color\": \"inherit\",\n };\n\n const remoteConfig = this.eligibleNonprofitsDataController?.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily);\n font-style: var(--beam-fontStyle);\n font-size: var(--beam-fontSize);\n background-color: var(--beam-backgroundColor);\n color: var(--beam-textColor);\n word-break: normal;\n }\n .swap-nonprofit-button {\n margin-top: var(--beam-SubscriptionManagement-swapNonprofitButtonText-marginTop, 10px);\n color: var(--beam-SubscriptionManagement-swapNonprofitButtonText-color, inherit);\n font-size: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontSize, inherit);\n text-decoration: var(--beam-SubscriptionManagement-swapNonprofitButtonText-textDecoration, underline);\n font-family: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontFamily, inherit);\n font-style: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontStyle, inherit);\n font-weight: var(--beam-SubscriptionManagement-swapNonprofitButtonText-fontWeight, inherit);\n line-height: var(--beam-SubscriptionManagement-swapNonprofitButtonText-lineHeight, inherit);\n background: none;\n border: none;\n cursor: pointer;\n }\n .sub-widget-container {\n background-color: var(--beam-SubscriptionManagement-widgetContainer-backgroundColor, inherit);\n border: 1px solid var(--beam-SubscriptionManagement-widgetContainer-borderColor, #d5d5d5);\n border-radius: var(--beam-SubscriptionManagement-widgetContainer-borderRadius, 4px);\n overflow: hidden; /* maintain clean border-radius */\n padding: var(--beam-SubscriptionManagement-widgetContainer-padding, 15px);\n max-width: var(--beam-SubscriptionManagement-widgetContainer-maxWidth, 800px);\n }\n }`,\n ];\n\n render() {\n let content;\n\n if (this.subscriptionDataController.loading || this.eligibleNonprofitsDataController.loading) {\n content = \"\";\n }\n\n if ((this.subscriptionDataController.error || this.eligibleNonprofitsDataController.error) && this.debug) {\n if (this.subscriptionDataController.error !== null) {\n return _errorMessage({ error: this.subscriptionDataController.error });\n } else if (this.eligibleNonprofitsDataController.error !== null) {\n return _errorMessage({ error: this.eligibleNonprofitsDataController.error });\n }\n } else {\n content = \"\";\n }\n\n if (this.activeWidget === \"redeem-transaction\") {\n content = html` <beam-redeem-transaction\n part=\"redeem-transaction\"\n storeId=\"${this.storeId}\"\n subscriptionId=\"${this.subscriptionId}\"\n nonprofitId=${this.nonprofitId}\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof BeamNonprofitSelectEvent)) return; // TS guard\n const { selectedNonprofitId } = event.detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>`;\n } else if (this.activeWidget === \"impact-overview\") {\n content = html`\n <beam-impact-overview\n part=\"impact-overview\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div class=\"sub-widget-container\">${content}</div>\n ${this.renderSwapNonprofitButton()}\n `;\n }\n}\n\ndefineCustomElement(BeamSubscriptionManagement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-subscription-management\": BeamSubscriptionManagement;\n }\n}\n"],"names":["strings","brandName","m","h","e","l","n","t","o","i","a","d","BeamSubscriptionManagement","LitElement","DEFAULT_BASE_URL","AsyncController","MissingConfig","enforceConfig","res","postChainEligibleNonprofitsForCart","result","postFindOrCreateSubscription","html","defaults","remoteConfig","config","_cssVariableMap","content","_errorMessage","event","BeamNonprofitSelectEvent","selectedNonprofitId","cssReset","css","__decorateClass","property","state","defineCustomElement"],"mappings":"q6BAAO,MAAMA,EAAU,CACrB,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAC,EAAY,EAAG,IAAM,0CAA0CA,CAAS,kBAChG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,wGAAkGA,CAAS,EAC/G,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,oHAA2GA,CAAS,EACxH,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,4FAAsFA,CAAS,EACnG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,sFAAsFA,CAAS,EACnG,EACA,GAAI,CACF,kBAAmB,CAAC,CAAE,UAAAA,EAAY,EAAG,IACnC,yFAA4EA,CAAS,EACzF,CACF,ECxBA,IAAAC,EAAA,OAAA,eAAAC,EAAA,OAAA,yBAAAC,EAAA,CAAAC,EAAAC,EAAAC,EAAAC,IAAA,CAAA,QAAAC,EAAAD,EAAA,EAAA,OAAAA,EAAAL,EAAAG,EAAAC,CAAA,EAAAD,EAAAI,EAAAL,EAAA,OAAA,EAAAM,EAAAD,GAAA,EAAAA,KAAAC,EAAAN,EAAAK,CAAA,KAAAD,GAAAD,EAAAG,EAAAL,EAAAC,EAAAE,CAAA,EAAAE,EAAAF,CAAA,IAAAA,GAAA,OAAAD,GAAAC,GAAAP,EAAAI,EAAAC,EAAAE,CAAA,EAAA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2
- export { i as Integrations } from './chunks/index-Tnwxn22c.esm.js';
1
+ export { i as WebComponents } from './chunks/index-Hb-jziQs.esm.js';
2
+ export { i as Integrations } from './chunks/index-Zk634mW7.esm.js';
3
3
  export { i as ReactComponents } from './chunks/index-6t9MtjyS.esm.js';
4
- export { i as Utils } from './chunks/index-iYxrQMxt.esm.js';
4
+ export { i as Utils } from './chunks/index-YwDVLm67.esm.js';
5
5
  import './components/community-impact.js';
6
6
  import 'lit';
7
7
  import 'lit-html';
@@ -14,14 +14,15 @@ import 'lodash';
14
14
  import './components/impact-overview.js';
15
15
  import './components/select-nonprofit.js';
16
16
  import './chunks/promo-pill-label-3bA1z-la.esm.js';
17
- import './chunks/cart-contents-dKdDg09p.esm.js';
18
- import './chunks/openapi-spec-fxMWpEwU.esm.js';
17
+ import './chunks/cart-contents-3-9fB-7m.esm.js';
18
+ import './chunks/openapi-spec--MzXvfCC.esm.js';
19
19
  import './components/redeem-transaction.js';
20
20
  import './components/post-purchase.js';
21
21
  import './components/subscription-management.js';
22
- import './chunks/index-dDBsHD_s.esm.js';
22
+ import './components/product-details-page.js';
23
+ import './chunks/index-b-AHDeDB.esm.js';
23
24
  import './chunks/beam-errors-fXDkG1zo.esm.js';
24
- import './chunks/events-zF9NDtBD.esm.js';
25
+ import './chunks/events-7W7i4aV5.esm.js';
25
26
  import './utils/logger.js';
26
27
  import './utils/network-listeners.js';
27
28
  import './utils/local-storage.js';
@@ -31,12 +32,12 @@ import './utils/remote-session.js';
31
32
  import './utils/memoize-last.js';
32
33
  import 'lodash-es/debounce';
33
34
  import 'lodash-es/isEqual';
34
- import './chunks/index-EjqeU7Mu.esm.js';
35
- import './chunks/order-page-AezeN9KY.esm.js';
36
- import './chunks/update-cart-43LEXveI.esm.js';
35
+ import './chunks/index-SxFKifVJ.esm.js';
36
+ import './chunks/order-page-DPx5SUKM.esm.js';
37
+ import './chunks/update-cart-xaWdPxse.esm.js';
37
38
  import './chunks/index-EGiUuWe-.esm.js';
38
- import './chunks/index-tqTROh5B.esm.js';
39
- import './chunks/index-cRyQ6D5G.esm.js';
39
+ import './chunks/index-HBDtoJlQ.esm.js';
40
+ import './chunks/index-TOzSFOvI.esm.js';
40
41
  import './react/community-impact.js';
41
42
  import '@lit/react';
42
43
  import './react/cumulative-impact.js';
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{i as S}from"./chunks/index-5yFqo0yl.esm.js";import{i as V}from"./chunks/index-IWF7IfQk.esm.js";import{i as Y}from"./chunks/index-o7YiP4gC.esm.js";import{i as _}from"./chunks/index-8yrr7ZZv.esm.js";import"./components/community-impact.esm.js";import"./chunks/lit-HCWbxxT7.esm.js";import"./chunks/progress-bar-9vfd2JYm.esm.js";import"./components/beam-partner-logos.esm.js";import"./chunks/enforce-config-7R9KCF_i.esm.js";import"./chunks/beam-errors-P-Lu07Ce.esm.js";import"./utils/logger.esm.js";import"./chunks/routes-UBDDazXd.esm.js";import"./chunks/localize-jRg7W6Ul.esm.js";import"./chunks/css-card-grid-inRnKSWs.esm.js";import"./components/cumulative-impact.esm.js";import"./chunks/lodash-P8OIs-at.esm.js";import"./chunks/is-all-html-elements-SdSkxirh.esm.js";import"./components/impact-overview.esm.js";import"./chunks/vendor-h5FNKy-G.esm.js";import"./chunks/responsive-Bzkkpj11.esm.js";import"./components/select-nonprofit.esm.js";import"./chunks/promo-pill-label-vCWNyiaj.esm.js";import"./chunks/events-Y8fYvSqM.esm.js";import"./utils/network-listeners.esm.js";import"./utils/local-storage.esm.js";import"./utils/cookies.esm.js";import"./chunks/cart-contents-h60geKWa.esm.js";import"./components/redeem-transaction.esm.js";import"./components/post-purchase.esm.js";import"./components/subscription-management.esm.js";import"./chunks/index-Lw32NXij.esm.js";import"./utils/wait-for-element.esm.js";import"./utils/remote-session.esm.js";import"./utils/memoize-last.esm.js";import"./chunks/index-FsVWk2WD.esm.js";import"./chunks/order-page-E7Kyu1JP.esm.js";import"./chunks/update-cart-6fMyZd34.esm.js";import"./chunks/index-6iInzwnG.esm.js";import"./chunks/index-IKTofhFw.esm.js";import"./chunks/index-UCh8HjVN.esm.js";import"./react/community-impact.esm.js";import"react";import"./react/cumulative-impact.esm.js";import"./react/impact-overview.esm.js";import"./react/select-nonprofit.esm.js";import"./react/redeem-transaction.esm.js";import"./react/post-purchase.esm.js";import"./react/subscription-management.esm.js";export{V as Integrations,Y as ReactComponents,_ as Utils,S as WebComponents};
1
+ import{i as X}from"./chunks/index-V-BsPYtl.esm.js";import{i as Z}from"./chunks/index-TD6ZYob2.esm.js";import{i as $}from"./chunks/index-o7YiP4gC.esm.js";import{i as to}from"./chunks/index-8yrr7ZZv.esm.js";import"./components/community-impact.esm.js";import"./chunks/lit-qtGbjGnK.esm.js";import"./chunks/progress-bar-Sn2QspHy.esm.js";import"./components/beam-partner-logos.esm.js";import"./chunks/localize-F31ae3j6.esm.js";import"./chunks/beam-errors-P-Lu07Ce.esm.js";import"./utils/logger.esm.js";import"./chunks/routes-mFdr3VNw.esm.js";import"./chunks/loading-template-Av0IUyKF.esm.js";import"./chunks/css-card-grid-7tObtoJx.esm.js";import"./components/cumulative-impact.esm.js";import"./chunks/lodash-P8OIs-at.esm.js";import"./chunks/is-all-html-elements-SdSkxirh.esm.js";import"./components/impact-overview.esm.js";import"./chunks/shoelace-components-jVPXTZPS.esm.js";import"./chunks/vendor-jQ8cxMpw.esm.js";import"./chunks/responsive-aWj_7ZN_.esm.js";import"./components/select-nonprofit.esm.js";import"./chunks/promo-pill-label-j0A8qZ0c.esm.js";import"./chunks/events-Y8fYvSqM.esm.js";import"./utils/network-listeners.esm.js";import"./utils/local-storage.esm.js";import"./utils/cookies.esm.js";import"./chunks/cart-contents-h60geKWa.esm.js";import"./components/redeem-transaction.esm.js";import"./components/post-purchase.esm.js";import"./components/subscription-management.esm.js";import"./components/product-details-page.esm.js";import"./utils/makeApiKeyHeader.esm.js";import"./chunks/index-Lw32NXij.esm.js";import"./utils/wait-for-element.esm.js";import"./utils/remote-session.esm.js";import"./utils/memoize-last.esm.js";import"./chunks/index-07spDV_A.esm.js";import"./chunks/order-page-r0Bn2_wR.esm.js";import"./chunks/update-cart--5PpQSrY.esm.js";import"./chunks/index-Q1vx4WtG.esm.js";import"./chunks/index-NF6VKqmo.esm.js";import"./chunks/index-IO0Z_buU.esm.js";import"./react/community-impact.esm.js";import"react";import"./react/cumulative-impact.esm.js";import"./react/impact-overview.esm.js";import"./react/select-nonprofit.esm.js";import"./react/redeem-transaction.esm.js";import"./react/post-purchase.esm.js";import"./react/subscription-management.esm.js";export{Z as Integrations,$ as ReactComponents,to as Utils,X as WebComponents};
2
2
  //# sourceMappingURL=index.esm.js.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{i as S}from"./chunks/index-IzAvjker.esm.js";import{i as V}from"./chunks/index-NU6RpwSa.esm.js";import{i as Y}from"./chunks/index-EHubF2KN.esm.js";import{i as _}from"./chunks/index-phDmC-TS.esm.js";import"./components/community-impact.js";import"./chunks/lit-HCWbxxT7.esm.js";import"./chunks/progress-bar-9vfd2JYm.esm.js";import"./components/beam-partner-logos.js";import"./chunks/enforce-config-iFdf1QkH.esm.js";import"./chunks/beam-errors-P-Lu07Ce.esm.js";import"./utils/logger.js";import"./chunks/routes-t5eRHMRc.esm.js";import"./chunks/localize-ZHtlNltZ.esm.js";import"./chunks/css-card-grid-inRnKSWs.esm.js";import"./components/cumulative-impact.js";import"./chunks/lodash-P8OIs-at.esm.js";import"./chunks/is-all-html-elements-SdSkxirh.esm.js";import"./components/impact-overview.js";import"./chunks/vendor-h5FNKy-G.esm.js";import"./chunks/responsive-Bzkkpj11.esm.js";import"./components/select-nonprofit.js";import"./chunks/promo-pill-label-vCWNyiaj.esm.js";import"./chunks/events-Y8fYvSqM.esm.js";import"./utils/network-listeners.js";import"./utils/local-storage.js";import"./utils/cookies.js";import"./chunks/cart-contents-h60geKWa.esm.js";import"./components/redeem-transaction.js";import"./components/post-purchase.js";import"./components/subscription-management.js";import"./chunks/index-uF-Qtewb.esm.js";import"./utils/wait-for-element.js";import"./utils/remote-session.js";import"./utils/memoize-last.js";import"./chunks/index-QrlkSlnv.esm.js";import"./chunks/order-page-5VQO1Sil.esm.js";import"./chunks/update-cart-WfOplzik.esm.js";import"./chunks/index-l7Ao8g5B.esm.js";import"./chunks/index-MG0WE1Fz.esm.js";import"./chunks/index-_WQFoMIz.esm.js";import"./react/community-impact.js";import"react";import"./react/cumulative-impact.js";import"./react/impact-overview.js";import"./react/select-nonprofit.js";import"./react/redeem-transaction.js";import"./react/post-purchase.js";import"./react/subscription-management.js";export{V as Integrations,Y as ReactComponents,_ as Utils,S as WebComponents};
1
+ import{i as X}from"./chunks/index-cekgAcEE.esm.js";import{i as Z}from"./chunks/index-b9nIxcaS.esm.js";import{i as $}from"./chunks/index-EHubF2KN.esm.js";import{i as to}from"./chunks/index-uF-Qtewb.esm.js";import"./components/community-impact.js";import"./chunks/lit-qtGbjGnK.esm.js";import"./chunks/progress-bar-Sn2QspHy.esm.js";import"./components/beam-partner-logos.js";import"./chunks/localize-fH8KOrMi.esm.js";import"./chunks/beam-errors-P-Lu07Ce.esm.js";import"./utils/logger.js";import"./chunks/routes-eEIGOCLH.esm.js";import"./chunks/loading-template-Av0IUyKF.esm.js";import"./chunks/css-card-grid-7tObtoJx.esm.js";import"./components/cumulative-impact.js";import"./chunks/lodash-P8OIs-at.esm.js";import"./chunks/is-all-html-elements-SdSkxirh.esm.js";import"./components/impact-overview.js";import"./chunks/shoelace-components-yvcqUObE.esm.js";import"./chunks/vendor-jQ8cxMpw.esm.js";import"./chunks/responsive-aWj_7ZN_.esm.js";import"./components/select-nonprofit.js";import"./chunks/promo-pill-label-j0A8qZ0c.esm.js";import"./chunks/events-Y8fYvSqM.esm.js";import"./utils/network-listeners.js";import"./utils/local-storage.js";import"./utils/cookies.js";import"./chunks/cart-contents-h60geKWa.esm.js";import"./components/redeem-transaction.js";import"./components/post-purchase.js";import"./components/subscription-management.js";import"./components/product-details-page.js";import"./utils/makeApiKeyHeader.js";import"./chunks/index-phDmC-TS.esm.js";import"./utils/wait-for-element.js";import"./utils/remote-session.js";import"./utils/memoize-last.js";import"./chunks/index-qFEb98cw.esm.js";import"./chunks/order-page-DTWyo57K.esm.js";import"./chunks/update-cart-TDb6pWxk.esm.js";import"./chunks/index-uCfdsWtt.esm.js";import"./chunks/index-i1kXw_4Z.esm.js";import"./chunks/index-wrvDFuaS.esm.js";import"./react/community-impact.js";import"react";import"./react/cumulative-impact.js";import"./react/impact-overview.js";import"./react/select-nonprofit.js";import"./react/redeem-transaction.js";import"./react/post-purchase.js";import"./react/subscription-management.js";export{Z as Integrations,$ as ReactComponents,to as Utils,X as WebComponents};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{D as u,a as g}from"../chunks/routes-UBDDazXd.esm.js";import{S as y}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{B as h}from"../chunks/events-Y8fYvSqM.esm.js";import{logger as w}from"../utils/logger.esm.js";import{s as f}from"../chunks/index-UCh8HjVN.esm.js";var v=(t,s,a)=>{if(!s.has(t))throw TypeError("Cannot "+a)},c=(t,s,a)=>{if(s.has(t))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(t):s.set(t,a)},i=(t,s,a)=>(v(t,s,"access private method"),a),r,n,o,m;let p,l;const E=new Promise((t,s)=>{p=t,l=s});class U extends EventTarget{constructor(s){super(),c(this,r),c(this,o),this.readyPromise=E,this.plugins={},this.status="pending",i(this,r,n).call(this,s)}async init(s){i(this,r,n).call(this,s);try{await i(this,o,m).call(this,s)}catch(a){const e=new y;throw e.cause=a,this.status="error",this.dispatchEvent(new h({status:"error",error:e})),l(e),w.error(e),this.apiKey&&await f({apiKey:this.apiKey,baseUrl:this.logUrl},{type:"error",code:e.name,metadata:{message:e.message,cause:a?.message}}),a}return this.status="ready",this.dispatchEvent(new h({status:"ready"})),p(!0),this}}r=new WeakSet,n=function(t){this.apiKey=t.apiKey,this.chainId=t.chainId,this.storeId=t.storeId,this.domain=t.domain,this.baseUrl=t.baseUrl||u,this.logUrl=t.logUrl||g},o=new WeakSet,m=async function(t){const s=(t.plugins||[]).map(async a=>(await a.init(t),this.plugins[a.name]=a,a));return Promise.all(s)};const d=new U({}),S=t=>d.init(t),L=()=>d;export{L as getConfig,S as init};
1
+ import{D as u,a as g}from"../chunks/routes-mFdr3VNw.esm.js";import{S as y}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{B as h}from"../chunks/events-Y8fYvSqM.esm.js";import{logger as w}from"../utils/logger.esm.js";import{s as f}from"../chunks/index-IO0Z_buU.esm.js";var v=(t,s,a)=>{if(!s.has(t))throw TypeError("Cannot "+a)},c=(t,s,a)=>{if(s.has(t))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(t):s.set(t,a)},i=(t,s,a)=>(v(t,s,"access private method"),a),r,n,o,m;let p,l;const E=new Promise((t,s)=>{p=t,l=s});class U extends EventTarget{constructor(s){super(),c(this,r),c(this,o),this.readyPromise=E,this.plugins={},this.status="pending",i(this,r,n).call(this,s)}async init(s){i(this,r,n).call(this,s);try{await i(this,o,m).call(this,s)}catch(a){const e=new y;throw e.cause=a,this.status="error",this.dispatchEvent(new h({status:"error",error:e})),l(e),w.error(e),this.apiKey&&await f({apiKey:this.apiKey,baseUrl:this.logUrl},{type:"error",code:e.name,metadata:{message:e.message,cause:a?.message}}),a}return this.status="ready",this.dispatchEvent(new h({status:"ready"})),p(!0),this}}r=new WeakSet,n=function(t){this.apiKey=t.apiKey,this.chainId=t.chainId,this.storeId=t.storeId,this.domain=t.domain,this.baseUrl=t.baseUrl||u,this.logUrl=t.logUrl||g},o=new WeakSet,m=async function(t){const s=(t.plugins||[]).map(async a=>(await a.init(t),this.plugins[a.name]=a,a));return Promise.all(s)};const d=new U({}),S=t=>d.init(t),L=()=>d;export{L as getConfig,S as init};
2
2
  //# sourceMappingURL=beam.esm.js.map
@@ -1,2 +1,2 @@
1
- import{D as u,a as g}from"../chunks/routes-t5eRHMRc.esm.js";import{S as y}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{B as h}from"../chunks/events-Y8fYvSqM.esm.js";import{logger as w}from"../utils/logger.js";import{s as f}from"../chunks/index-_WQFoMIz.esm.js";var v=(t,s,a)=>{if(!s.has(t))throw TypeError("Cannot "+a)},c=(t,s,a)=>{if(s.has(t))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(t):s.set(t,a)},i=(t,s,a)=>(v(t,s,"access private method"),a),r,n,o,m;let p,l;const E=new Promise((t,s)=>{p=t,l=s});class U extends EventTarget{constructor(s){super(),c(this,r),c(this,o),this.readyPromise=E,this.plugins={},this.status="pending",i(this,r,n).call(this,s)}async init(s){i(this,r,n).call(this,s);try{await i(this,o,m).call(this,s)}catch(a){const e=new y;throw e.cause=a,this.status="error",this.dispatchEvent(new h({status:"error",error:e})),l(e),w.error(e),this.apiKey&&await f({apiKey:this.apiKey,baseUrl:this.logUrl},{type:"error",code:e.name,metadata:{message:e.message,cause:a?.message}}),a}return this.status="ready",this.dispatchEvent(new h({status:"ready"})),p(!0),this}}r=new WeakSet,n=function(t){this.apiKey=t.apiKey,this.chainId=t.chainId,this.storeId=t.storeId,this.domain=t.domain,this.baseUrl=t.baseUrl||u,this.logUrl=t.logUrl||g},o=new WeakSet,m=async function(t){const s=(t.plugins||[]).map(async a=>(await a.init(t),this.plugins[a.name]=a,a));return Promise.all(s)};const d=new U({}),S=t=>d.init(t),L=()=>d;export{L as getConfig,S as init};
1
+ import{D as u,a as g}from"../chunks/routes-eEIGOCLH.esm.js";import{S as y}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{B as h}from"../chunks/events-Y8fYvSqM.esm.js";import{logger as w}from"../utils/logger.js";import{s as f}from"../chunks/index-wrvDFuaS.esm.js";var v=(t,s,a)=>{if(!s.has(t))throw TypeError("Cannot "+a)},c=(t,s,a)=>{if(s.has(t))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(t):s.set(t,a)},i=(t,s,a)=>(v(t,s,"access private method"),a),r,n,o,m;let p,l;const E=new Promise((t,s)=>{p=t,l=s});class U extends EventTarget{constructor(s){super(),c(this,r),c(this,o),this.readyPromise=E,this.plugins={},this.status="pending",i(this,r,n).call(this,s)}async init(s){i(this,r,n).call(this,s);try{await i(this,o,m).call(this,s)}catch(a){const e=new y;throw e.cause=a,this.status="error",this.dispatchEvent(new h({status:"error",error:e})),l(e),w.error(e),this.apiKey&&await f({apiKey:this.apiKey,baseUrl:this.logUrl},{type:"error",code:e.name,metadata:{message:e.message,cause:a?.message}}),a}return this.status="ready",this.dispatchEvent(new h({status:"ready"})),p(!0),this}}r=new WeakSet,n=function(t){this.apiKey=t.apiKey,this.chainId=t.chainId,this.storeId=t.storeId,this.domain=t.domain,this.baseUrl=t.baseUrl||u,this.logUrl=t.logUrl||g},o=new WeakSet,m=async function(t){const s=(t.plugins||[]).map(async a=>(await a.init(t),this.plugins[a.name]=a,a));return Promise.all(s)};const d=new U({}),S=t=>d.init(t),L=()=>d;export{L as getConfig,S as init};
2
2
  //# sourceMappingURL=beam.js.map
@@ -1,5 +1,5 @@
1
- export { B as BeamCartAPIConfig, a as BeamCartValues, u as updateCart } from '../chunks/update-cart-43LEXveI.esm.js';
1
+ export { B as BeamCartAPIConfig, a as BeamCartValues, u as updateCart } from '../chunks/update-cart-xaWdPxse.esm.js';
2
2
  import 'lodash';
3
3
  import '../chunks/types-aju0qrRe.esm.js';
4
- import '../chunks/cart-contents-dKdDg09p.esm.js';
5
- import '../chunks/openapi-spec-fxMWpEwU.esm.js';
4
+ import '../chunks/cart-contents-3-9fB-7m.esm.js';
5
+ import '../chunks/openapi-spec--MzXvfCC.esm.js';
@@ -1,2 +1,2 @@
1
- import{x as C}from"../chunks/update-cart-6fMyZd34.esm.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/routes-UBDDazXd.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/network-listeners.esm.js";import"../utils/local-storage.esm.js";import"../utils/cookies.esm.js";import"../utils/remote-session.esm.js";import"../utils/memoize-last.esm.js";import"../chunks/cart-contents-h60geKWa.esm.js";export{C as updateCart};
1
+ import{x as C}from"../chunks/update-cart--5PpQSrY.esm.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/routes-mFdr3VNw.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/network-listeners.esm.js";import"../utils/local-storage.esm.js";import"../utils/cookies.esm.js";import"../utils/remote-session.esm.js";import"../utils/memoize-last.esm.js";import"../chunks/cart-contents-h60geKWa.esm.js";export{C as updateCart};
2
2
  //# sourceMappingURL=cart.esm.js.map
@@ -1,2 +1,2 @@
1
- import{x as C}from"../chunks/update-cart-WfOplzik.esm.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/routes-t5eRHMRc.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/network-listeners.js";import"../utils/local-storage.js";import"../utils/cookies.js";import"../utils/remote-session.js";import"../utils/memoize-last.js";import"../chunks/cart-contents-h60geKWa.esm.js";export{C as updateCart};
1
+ import{x as C}from"../chunks/update-cart-TDb6pWxk.esm.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/routes-eEIGOCLH.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/network-listeners.js";import"../utils/local-storage.js";import"../utils/cookies.js";import"../utils/remote-session.js";import"../utils/memoize-last.js";import"../chunks/cart-contents-h60geKWa.esm.js";export{C as updateCart};
2
2
  //# sourceMappingURL=cart.js.map
@@ -1,12 +1,12 @@
1
- export { i as Utils } from '../chunks/index-dDBsHD_s.esm.js';
2
- export { i as Shopify } from '../chunks/index-EjqeU7Mu.esm.js';
1
+ export { i as Utils } from '../chunks/index-b-AHDeDB.esm.js';
2
+ export { i as Shopify } from '../chunks/index-SxFKifVJ.esm.js';
3
3
  export { i as Session } from '../chunks/index-EGiUuWe-.esm.js';
4
- export { i as Cart } from '../chunks/index-tqTROh5B.esm.js';
5
- export { i as Logs } from '../chunks/index-cRyQ6D5G.esm.js';
4
+ export { i as Cart } from '../chunks/index-HBDtoJlQ.esm.js';
5
+ export { i as Logs } from '../chunks/index-TOzSFOvI.esm.js';
6
6
  import '../chunks/beam-errors-fXDkG1zo.esm.js';
7
- import '../chunks/events-zF9NDtBD.esm.js';
8
- import '../chunks/cart-contents-dKdDg09p.esm.js';
9
- import '../chunks/openapi-spec-fxMWpEwU.esm.js';
7
+ import '../chunks/events-7W7i4aV5.esm.js';
8
+ import '../chunks/cart-contents-3-9fB-7m.esm.js';
9
+ import '../chunks/openapi-spec--MzXvfCC.esm.js';
10
10
  import '../chunks/types-7kSi85Gv.esm.js';
11
11
  import '../utils/logger.js';
12
12
  import '../utils/network-listeners.js';
@@ -17,9 +17,9 @@ import '../utils/remote-session.js';
17
17
  import '../utils/memoize-last.js';
18
18
  import 'lodash-es/debounce';
19
19
  import 'lodash-es/isEqual';
20
- import '../chunks/order-page-AezeN9KY.esm.js';
20
+ import '../chunks/order-page-DPx5SUKM.esm.js';
21
21
  import 'lodash';
22
- import '../chunks/update-cart-43LEXveI.esm.js';
22
+ import '../chunks/update-cart-xaWdPxse.esm.js';
23
23
  import '../chunks/types-aju0qrRe.esm.js';
24
24
  import '../components/post-purchase.js';
25
25
  import 'lit';
@@ -1,2 +1,2 @@
1
- import{i as z}from"../chunks/index-Lw32NXij.esm.js";import{i as B}from"../chunks/index-FsVWk2WD.esm.js";import{i as E}from"../chunks/index-6iInzwnG.esm.js";import{i as G}from"../chunks/index-IKTofhFw.esm.js";import{i as I}from"../chunks/index-UCh8HjVN.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/logger.esm.js";import"../utils/network-listeners.esm.js";import"../utils/local-storage.esm.js";import"../utils/wait-for-element.esm.js";import"../utils/cookies.esm.js";import"../utils/remote-session.esm.js";import"../utils/memoize-last.esm.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/order-page-E7Kyu1JP.esm.js";import"../chunks/cart-contents-h60geKWa.esm.js";import"../chunks/update-cart-6fMyZd34.esm.js";import"../chunks/routes-UBDDazXd.esm.js";import"../components/post-purchase.esm.js";import"../chunks/lit-HCWbxxT7.esm.js";import"../chunks/enforce-config-7R9KCF_i.esm.js";import"../components/redeem-transaction.esm.js";import"../chunks/progress-bar-9vfd2JYm.esm.js";import"../chunks/promo-pill-label-vCWNyiaj.esm.js";import"../chunks/vendor-h5FNKy-G.esm.js";import"../components/beam-partner-logos.esm.js";import"../chunks/localize-jRg7W6Ul.esm.js";import"../chunks/css-card-grid-inRnKSWs.esm.js";import"../components/impact-overview.esm.js";import"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../chunks/responsive-Bzkkpj11.esm.js";export{G as Cart,I as Logs,E as Session,B as Shopify,z as Utils};
1
+ import{i as A}from"../chunks/index-Lw32NXij.esm.js";import{i as D}from"../chunks/index-07spDV_A.esm.js";import{i as F}from"../chunks/index-Q1vx4WtG.esm.js";import{i as H}from"../chunks/index-NF6VKqmo.esm.js";import{i as J}from"../chunks/index-IO0Z_buU.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/logger.esm.js";import"../utils/network-listeners.esm.js";import"../utils/local-storage.esm.js";import"../utils/wait-for-element.esm.js";import"../utils/cookies.esm.js";import"../utils/remote-session.esm.js";import"../utils/memoize-last.esm.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/order-page-r0Bn2_wR.esm.js";import"../chunks/cart-contents-h60geKWa.esm.js";import"../chunks/update-cart--5PpQSrY.esm.js";import"../chunks/routes-mFdr3VNw.esm.js";import"../components/post-purchase.esm.js";import"../chunks/lit-qtGbjGnK.esm.js";import"../chunks/localize-F31ae3j6.esm.js";import"../components/redeem-transaction.esm.js";import"../chunks/progress-bar-Sn2QspHy.esm.js";import"../chunks/promo-pill-label-j0A8qZ0c.esm.js";import"../chunks/vendor-jQ8cxMpw.esm.js";import"../components/beam-partner-logos.esm.js";import"../chunks/loading-template-Av0IUyKF.esm.js";import"../chunks/css-card-grid-7tObtoJx.esm.js";import"../components/impact-overview.esm.js";import"../chunks/shoelace-components-jVPXTZPS.esm.js";import"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../chunks/responsive-aWj_7ZN_.esm.js";export{H as Cart,J as Logs,F as Session,D as Shopify,A as Utils};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1,2 +1,2 @@
1
- import{i as z}from"../chunks/index-uF-Qtewb.esm.js";import{i as B}from"../chunks/index-QrlkSlnv.esm.js";import{i as E}from"../chunks/index-l7Ao8g5B.esm.js";import{i as G}from"../chunks/index-MG0WE1Fz.esm.js";import{i as I}from"../chunks/index-_WQFoMIz.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/logger.js";import"../utils/network-listeners.js";import"../utils/local-storage.js";import"../utils/wait-for-element.js";import"../utils/cookies.js";import"../utils/remote-session.js";import"../utils/memoize-last.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/order-page-5VQO1Sil.esm.js";import"../chunks/cart-contents-h60geKWa.esm.js";import"../chunks/update-cart-WfOplzik.esm.js";import"../chunks/routes-t5eRHMRc.esm.js";import"../components/post-purchase.js";import"../chunks/lit-HCWbxxT7.esm.js";import"../chunks/enforce-config-iFdf1QkH.esm.js";import"../components/redeem-transaction.js";import"../chunks/progress-bar-9vfd2JYm.esm.js";import"../chunks/promo-pill-label-vCWNyiaj.esm.js";import"../chunks/vendor-h5FNKy-G.esm.js";import"../components/beam-partner-logos.js";import"../chunks/localize-ZHtlNltZ.esm.js";import"../chunks/css-card-grid-inRnKSWs.esm.js";import"../components/impact-overview.js";import"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../chunks/responsive-Bzkkpj11.esm.js";export{G as Cart,I as Logs,E as Session,B as Shopify,z as Utils};
1
+ import{i as A}from"../chunks/index-phDmC-TS.esm.js";import{i as D}from"../chunks/index-qFEb98cw.esm.js";import{i as F}from"../chunks/index-uCfdsWtt.esm.js";import{i as H}from"../chunks/index-i1kXw_4Z.esm.js";import{i as J}from"../chunks/index-wrvDFuaS.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../chunks/events-Y8fYvSqM.esm.js";import"../utils/logger.js";import"../utils/network-listeners.js";import"../utils/local-storage.js";import"../utils/wait-for-element.js";import"../utils/cookies.js";import"../utils/remote-session.js";import"../utils/memoize-last.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/order-page-DTWyo57K.esm.js";import"../chunks/cart-contents-h60geKWa.esm.js";import"../chunks/update-cart-TDb6pWxk.esm.js";import"../chunks/routes-eEIGOCLH.esm.js";import"../components/post-purchase.js";import"../chunks/lit-qtGbjGnK.esm.js";import"../chunks/localize-fH8KOrMi.esm.js";import"../components/redeem-transaction.js";import"../chunks/progress-bar-Sn2QspHy.esm.js";import"../chunks/promo-pill-label-j0A8qZ0c.esm.js";import"../chunks/vendor-jQ8cxMpw.esm.js";import"../components/beam-partner-logos.js";import"../chunks/loading-template-Av0IUyKF.esm.js";import"../chunks/css-card-grid-7tObtoJx.esm.js";import"../components/impact-overview.js";import"../chunks/shoelace-components-yvcqUObE.esm.js";import"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../chunks/responsive-aWj_7ZN_.esm.js";export{H as Cart,J as Logs,F as Session,D as Shopify,A as Utils};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import '../chunks/openapi-spec-fxMWpEwU.esm.js';
2
- export { s as sendLog } from '../chunks/index-cRyQ6D5G.esm.js';
1
+ import '../chunks/openapi-spec--MzXvfCC.esm.js';
2
+ export { s as sendLog } from '../chunks/index-TOzSFOvI.esm.js';
@@ -1,2 +1,2 @@
1
- import"../chunks/routes-UBDDazXd.esm.js";import"../utils/logger.esm.js";import{s as i}from"../chunks/index-UCh8HjVN.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";export{i as sendLog};
1
+ import"../chunks/routes-mFdr3VNw.esm.js";import"../utils/logger.esm.js";import{s as i}from"../chunks/index-IO0Z_buU.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";export{i as sendLog};
2
2
  //# sourceMappingURL=logs.esm.js.map
@@ -1,2 +1,2 @@
1
- import"../chunks/routes-t5eRHMRc.esm.js";import"../utils/logger.js";import{s as i}from"../chunks/index-_WQFoMIz.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";export{i as sendLog};
1
+ import"../chunks/routes-eEIGOCLH.esm.js";import"../utils/logger.js";import{s as i}from"../chunks/index-wrvDFuaS.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";export{i as sendLog};
2
2
  //# sourceMappingURL=logs.js.map
@@ -1,2 +1,2 @@
1
- import"../chunks/vendor-h5FNKy-G.esm.js";import"../utils/cookies.esm.js";import"../utils/local-storage.esm.js";import{c as a,e as n}from"../chunks/index-6iInzwnG.esm.js";import"../chunks/lit-HCWbxxT7.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";export{a as createSession,n as endSession};
1
+ import"../chunks/vendor-jQ8cxMpw.esm.js";import"../utils/cookies.esm.js";import"../utils/local-storage.esm.js";import{c as a,e as n}from"../chunks/index-Q1vx4WtG.esm.js";import"../chunks/lit-qtGbjGnK.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";export{a as createSession,n as endSession};
2
2
  //# sourceMappingURL=session.esm.js.map
@@ -1,2 +1,2 @@
1
- import"../chunks/vendor-h5FNKy-G.esm.js";import"../utils/cookies.js";import"../utils/local-storage.js";import{c as a,e as n}from"../chunks/index-l7Ao8g5B.esm.js";import"../chunks/lit-HCWbxxT7.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.js";export{a as createSession,n as endSession};
1
+ import"../chunks/vendor-jQ8cxMpw.esm.js";import"../utils/cookies.js";import"../utils/local-storage.js";import{c as a,e as n}from"../chunks/index-uCfdsWtt.esm.js";import"../chunks/lit-qtGbjGnK.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.js";export{a as createSession,n as endSession};
2
2
  //# sourceMappingURL=session.js.map
@@ -1,9 +1,9 @@
1
- export { T as TBeamOrderPageParams, a as addBeamAttributesToCart, g as getCurrentCart, r as registerCartIntegration, s as showBeamOrderPageWidgets, t as trackCart } from '../chunks/order-page-AezeN9KY.esm.js';
1
+ export { T as TBeamOrderPageParams, a as addBeamAttributesToCart, g as getCurrentCart, r as registerCartIntegration, s as showBeamOrderPageWidgets, t as trackCart } from '../chunks/order-page-DPx5SUKM.esm.js';
2
2
  import 'lodash';
3
- import '../chunks/update-cart-43LEXveI.esm.js';
3
+ import '../chunks/update-cart-xaWdPxse.esm.js';
4
4
  import '../chunks/types-aju0qrRe.esm.js';
5
- import '../chunks/cart-contents-dKdDg09p.esm.js';
6
- import '../chunks/openapi-spec-fxMWpEwU.esm.js';
5
+ import '../chunks/cart-contents-3-9fB-7m.esm.js';
6
+ import '../chunks/openapi-spec--MzXvfCC.esm.js';
7
7
  import '../components/post-purchase.js';
8
8
  import 'lit';
9
9
  import 'lit-html';