@beamimpact/web-sdk 1.58.0 → 1.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{_share-dialog-dependencies-Caoc1gRc.esm.js → _share-dialog-dependencies-C3oAeUgm.esm.js} +2 -2
- package/dist/chunks/{_share-dialog-dependencies-Caoc1gRc.esm.js.map → _share-dialog-dependencies-C3oAeUgm.esm.js.map} +1 -1
- package/dist/chunks/{cart-DKQHSz5X.esm.d.ts → cart-Cm16_NVB.esm.d.ts} +3 -4
- package/dist/chunks/index-B2GUlwwp.esm.js +2 -0
- package/dist/chunks/index-B2GUlwwp.esm.js.map +1 -0
- package/dist/chunks/{index-DGOC8m2r.esm.d.ts → index-BG63SUjk.esm.d.ts} +1 -1
- package/dist/chunks/{index-BxivRkBL.esm.js → index-BhlTVL8_.esm.js} +2 -2
- package/dist/chunks/{index-BxivRkBL.esm.js.map → index-BhlTVL8_.esm.js.map} +1 -1
- package/dist/chunks/{index-M8hQ6GXf.esm.js → index-BlaOItQr.esm.js} +2 -2
- package/dist/chunks/{index-M8hQ6GXf.esm.js.map → index-BlaOItQr.esm.js.map} +1 -1
- package/dist/chunks/{index-Bi9LFICg.esm.d.ts → index-Bn65er6F.esm.d.ts} +1 -1
- package/dist/chunks/{index-BF0X_60j.esm.js → index-BtG64tE0.esm.js} +2 -2
- package/dist/chunks/{index-BF0X_60j.esm.js.map → index-BtG64tE0.esm.js.map} +1 -1
- package/dist/chunks/{index-Yt9xXa7z.esm.js → index-C6QfHWnX.esm.js} +2 -2
- package/dist/chunks/{index-Yt9xXa7z.esm.js.map → index-C6QfHWnX.esm.js.map} +1 -1
- package/dist/chunks/{index-h_-rDiMR.esm.d.ts → index-CSQv0_2I.esm.d.ts} +1 -1
- package/dist/chunks/{index-DtAcPGd4.esm.js → index-DC8IegOb.esm.js} +2 -2
- package/dist/chunks/{index-DtAcPGd4.esm.js.map → index-DC8IegOb.esm.js.map} +1 -1
- package/dist/chunks/index-PWwahCdj.esm.js +2 -0
- package/dist/chunks/index-PWwahCdj.esm.js.map +1 -0
- package/dist/chunks/{index-DQ89VjpD.esm.d.ts → index-_M2mg4n1.esm.d.ts} +1 -1
- package/dist/chunks/{index-E6IoMPQu.esm.js → index-hCVICwBS.esm.js} +2 -2
- package/dist/chunks/{index-E6IoMPQu.esm.js.map → index-hCVICwBS.esm.js.map} +1 -1
- package/dist/chunks/{promo-pill-label-DCBXltdj.esm.js → promo-pill-label-rA01UjBk.esm.js} +2 -2
- package/dist/chunks/{promo-pill-label-DCBXltdj.esm.js.map → promo-pill-label-rA01UjBk.esm.js.map} +1 -1
- package/dist/chunks/{share-button-C1PRjoPw.esm.js → share-button-BxrZs18u.esm.js} +2 -2
- package/dist/chunks/{share-button-C1PRjoPw.esm.js.map → share-button-BxrZs18u.esm.js.map} +1 -1
- package/dist/chunks/{share-button-CNq5lDre.esm.js → share-button-DQT2zQ7w.esm.js} +3 -2
- package/dist/chunks/{share-button-CNq5lDre.esm.js.map → share-button-DQT2zQ7w.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-B5Tr9N3V.esm.d.ts → update-cart-uoS0BDZq.esm.d.ts} +1 -1
- package/dist/chunks/{utils-BPcZ5h8J.esm.d.ts → utils-DfsVjUY-.esm.d.ts} +1 -0
- package/dist/chunks/utils-ly9wMwUO.esm.js.map +1 -1
- package/dist/components/beam-partner-logos.d.ts +1 -1
- package/dist/components/community-impact.d.ts +1 -1
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.d.ts +1 -1
- package/dist/components/cumulative-impact.esm.js +1 -1
- package/dist/components/cumulative-impact.js +1 -1
- package/dist/components/impact-overview.d.ts +1 -1
- package/dist/components/impact-overview.esm.js +1 -1
- package/dist/components/impact-overview.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +1 -1
- package/dist/components/post-purchase.esm.js +1 -1
- package/dist/components/post-purchase.js +1 -1
- package/dist/components/product-details-page.d.ts +1 -1
- package/dist/components/product-details-page.esm.js +1 -1
- package/dist/components/product-details-page.js +1 -1
- package/dist/components/redeem-transaction.d.ts +1 -1
- package/dist/components/redeem-transaction.esm.js +1 -1
- package/dist/components/redeem-transaction.js +1 -1
- package/dist/components/select-nonprofit.d.ts +1 -1
- package/dist/components/select-nonprofit.esm.js +6 -6
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +6 -6
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.d.ts +1 -1
- package/dist/components/select-subscription-nonprofit.esm.js +1 -1
- package/dist/components/select-subscription-nonprofit.js +1 -1
- package/dist/components/shopify.d.ts +4 -4
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.esm.js.map +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/shopify.js.map +1 -1
- package/dist/components/social-share.d.ts +1 -1
- package/dist/components/social-share.esm.js +1 -1
- package/dist/components/social-share.js +1 -1
- package/dist/components/subscriber-select-nonprofit.d.ts +1 -1
- package/dist/components/subscriber-select-nonprofit.esm.js +1 -1
- package/dist/components/subscriber-select-nonprofit.js +1 -1
- package/dist/components/subscription-impact.d.ts +2 -1
- package/dist/components/subscription-impact.esm.js +18 -17
- package/dist/components/subscription-impact.esm.js.map +1 -1
- package/dist/components/subscription-impact.js +18 -17
- package/dist/components/subscription-impact.js.map +1 -1
- package/dist/components/subscription-management.d.ts +3 -1
- package/dist/components/subscription-management.esm.js +19 -17
- package/dist/components/subscription-management.esm.js.map +1 -1
- package/dist/components/subscription-management.js +19 -17
- package/dist/components/subscription-management.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.d.ts +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.d.ts +2 -2
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/logs.d.ts +2 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/promoManager.d.ts +1 -1
- package/dist/integrations/shopify-order.d.ts +1 -1
- package/dist/integrations/shopify-order.esm.js +1 -1
- package/dist/integrations/shopify-order.js +1 -1
- package/dist/integrations/shopify.d.ts +3 -3
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.d.ts +1 -1
- package/dist/integrations/statsig.esm.js +14 -14
- package/dist/integrations/statsig.esm.js.map +1 -1
- package/dist/integrations/statsig.js +14 -14
- package/dist/integrations/statsig.js.map +1 -1
- package/dist/integrations/utils.d.ts +1 -1
- package/dist/react/beam-partner-logos.d.ts +1 -1
- package/dist/react/community-impact.d.ts +1 -1
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.d.ts +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.d.ts +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +1 -1
- package/dist/react/post-purchase.esm.js +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/product-details-page.d.ts +1 -1
- package/dist/react/product-details-page.esm.js +1 -1
- package/dist/react/product-details-page.js +1 -1
- package/dist/react/redeem-transaction.d.ts +1 -1
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/select-nonprofit.d.ts +1 -1
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/select-subscription-nonprofit.d.ts +1 -1
- package/dist/react/select-subscription-nonprofit.esm.js +1 -1
- package/dist/react/select-subscription-nonprofit.js +1 -1
- package/dist/react/shopify.esm.js +1 -1
- package/dist/react/shopify.esm.js.map +1 -1
- package/dist/react/shopify.js +1 -1
- package/dist/react/shopify.js.map +1 -1
- package/dist/react/social-share.d.ts +1 -1
- package/dist/react/social-share.esm.js +1 -1
- package/dist/react/social-share.js +1 -1
- package/dist/react/subscriber-select-nonprofit.d.ts +1 -1
- package/dist/react/subscriber-select-nonprofit.esm.js +1 -1
- package/dist/react/subscriber-select-nonprofit.js +1 -1
- package/dist/react/subscription-impact.d.ts +1 -1
- package/dist/react/subscription-impact.esm.js +1 -1
- package/dist/react/subscription-impact.js +1 -1
- package/dist/react/subscription-management.d.ts +1 -1
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/utils/beam-errors.d.ts +1 -1
- package/dist/utils/cart.d.ts +1 -1
- package/dist/utils/clear-beam-storage.d.ts +1 -1
- package/dist/utils/cookies.d.ts +1 -1
- package/dist/utils/events.d.ts +1 -1
- package/dist/utils/local-storage.d.ts +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/makeApiKeyHeader.d.ts +1 -1
- package/dist/utils/memoize-last.d.ts +1 -1
- package/dist/utils/network-listeners.d.ts +1 -1
- package/dist/utils/promoManager.d.ts +1 -1
- package/dist/utils/remote-session.d.ts +1 -1
- package/dist/utils/wait-for-element.d.ts +1 -1
- package/package.json +3 -3
- package/dist/chunks/index-ADw_ucEx.esm.js +0 -2
- package/dist/chunks/index-ADw_ucEx.esm.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as m,n as s,r as n,a as g,b}from"../chunks/lit-BEag9MFp.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import"../chunks/_share-dialog-dependencies-
|
|
1
|
+
import{i as m,n as s,r as n,a as g,b}from"../chunks/lit-BEag9MFp.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import"../chunks/_share-dialog-dependencies-C3oAeUgm.esm.js";import{u as d,s as r,p}from"../chunks/share-button-BxrZs18u.esm.js";import"./beam-partner-logos.js";import{c as f,d as y,e as u}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{g as w,_ as x}from"../chunks/index-BlaOItQr.esm.js";import{D as I,x as U,W as S}from"../chunks/utils-ly9wMwUO.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";var k=Object.defineProperty,a=(l,t,i,v)=>{for(var o=void 0,c=l.length-1,h;c>=0;c--)(h=l[c])&&(o=h(t,i,o)||o);return o&&k(t,i,o),o};class e extends g{constructor(){super(...arguments),this.baseUrl=I,this.lang="en",this.debug=!1,this.brandName=null,this.shareImageUrl=null,this.isMobile=!1,this.windowResized=!1,this.checkViewport=()=>{this.windowResized=window.innerWidth<=768}}get configLang(){return U[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.checkViewport),this.checkViewport()}disconnectedCallback(){window.removeEventListener("resize",this.checkViewport),super.disconnectedCallback()}async fetchImpactData(){u(["apiKey","storeId","nonprofitId"],this);try{return await w({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{storeId:this.storeId,personalImpactLimit:0,nonprofitId:this.nonprofitId,widgetName:S.community_impact,version:"1.0.0",lang:this.configLang,transactionId:this.transactionId??void 0}})}catch(t){throw this.debug&&console.error("Failed to fetch impact data",t),t}}async updateImpactData(){try{const t=await this.fetchImpactData();if(t&&(this.brandName=t.chain.name,this.shareImageUrl=t.promoAssetUrl||t.personalImpactAssetUrl||t.community[0].share.imageUrl,this.shareImageUrl)){const i=await d(this.shareImageUrl);this.file=i,this.dataUrl=URL.createObjectURL(i)}}catch(t){this.debug&&console.error("Error updating impact data:",t)}}async firstUpdated(){await this.updateImpactData(),this.isMobile=/Mobi|Android/i.test(navigator.userAgent)||"ontouchstart"in window||navigator.maxTouchPoints>0}async openSystemShareSheet(t){if(t)try{const i=await d(t);navigator.share&&this.brandName&&await navigator.share({files:[i],title:r[this.lang].impactShareTitle(),text:r[this.lang].impactShareText({brandName:this.brandName})})}catch(i){this.debug&&console.error("Failed to open share sheet",i)}}async handleClickCopy(){if(this.file)try{this.apiKey&&this.transactionId?p({baseUrl:this.baseUrl,apiKey:this.apiKey||"",requestBody:{eventName:"ExtensibilityCopyImageButtonClick",nonprofitId:this.nonprofitId,storeId:this.storeId,timestamp:Date.now(),transactionId:Number(this.transactionId)}}).catch(()=>null):console.error("Missing data for social share analytics. Skipping send"),await navigator.clipboard.write([new ClipboardItem({"image/png":this.file})])}catch(t){this.debug&&console.error("Failed to copy image to clipboard:",t)}}handleClickDownload(t){this.apiKey&&this.transactionId?p({baseUrl:this.baseUrl,apiKey:this.apiKey||"",requestBody:{eventName:"ExtensibilityDownloadImageButtonClick",nonprofitId:this.nonprofitId,storeId:this.storeId,timestamp:Date.now(),transactionId:Number(this.transactionId)}}).catch(()=>null):console.error("Missing data for social share analytics. Skipping send");const i=t.currentTarget;this.isMobile&&this.shareImageUrl?(t.preventDefault(),this.openSystemShareSheet(this.shareImageUrl)):this.dataUrl&&(i.href=this.dataUrl,i.download=r[this.lang].impactShareTitle())}render(){return!this.brandName||!this.shareImageUrl||!this.dataUrl?x():b`
|
|
2
2
|
<div class="share-container ${this.windowResized||this.isMobile?"mobile":"desktop"}">
|
|
3
3
|
<h2 class="share-title">${r[this.lang].impactShareTitle()}</h2>
|
|
4
4
|
<p class="share-text">${r[this.lang].impactShareText({brandName:this.brandName})}</p>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as lit_html from 'lit-html';
|
|
2
2
|
import * as lit from 'lit';
|
|
3
3
|
import { LitElement, PropertyValues } from 'lit';
|
|
4
|
-
import { b as TNumericId, L as LANGUAGES } from '../chunks/utils-
|
|
4
|
+
import { b as TNumericId, L as LANGUAGES } from '../chunks/utils-DfsVjUY-.esm.js';
|
|
5
5
|
import 'lodash-es/debounce';
|
|
6
6
|
import 'lodash-es/isEqual';
|
|
7
7
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as A,i as E,n as d,r as T,a as L,b as N,k as H,j as U}from"../chunks/lit-BEag9MFp.esm.js";import{d as P,u as h,h as B,j as z,k as _,A as C,e as g,f as W,_ as K,c as D}from"../chunks/index-M8hQ6GXf.esm.js";import{D as O,W as k,y as w,z as R,B as j,x as F}from"../chunks/utils-ly9wMwUO.esm.js";import{c as q,d as G,e as v}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{a as V}from"../chunks/share-button-C1PRjoPw.esm.js";import{c as J}from"../chunks/responsive-aN8P5PqD.esm.js";import{h as o,g as $}from"../chunks/handlebars-3tRO54kz.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const M={long:"dddd, MMMM D, YYYY",short:"MMM D, YYYY",numeric:"MM/DD/YYYY",iso:"YYYY-MM-DD",time:"h:mm A",time24:"HH:mm",datetime:"MMMM D, YYYY h:mm A",month:"MMMM YYYY",monthShort:"MMM YYYY",dayMonth:"MMMM D"},x=(t,e)=>{const r=M[e??"long"]??e??M.long;return $(t).format(r)};o.registerHelper("currentDate",t=>x(new Date,typeof t=="string"?t:void 0)),o.registerHelper("nextMonth",t=>{const e=$().add(1,"month").toDate();return x(e,typeof t=="string"?t:void 0)}),o.registerHelper("dateOffset",(t,e,r)=>{const s=typeof e=="string"?e:void 0,i=(typeof e=="string"?r:e)?.hash?.from,n=i?new Date(i):new Date,p=$(n).add(t,"day").toDate();return s==="relative"?t===-1?"yesterday":t===0?"today":t===1?"tomorrow":t<0?`${Math.abs(t)} days ago`:`${t} days from now`:x(p,s)}),o.registerHelper("formatDate",(t,e)=>{const r=t instanceof Date?t:new Date(t);return isNaN(r.getTime())?"":x(r,typeof e=="string"?e:void 0)}),o.registerHelper("color",(t,e)=>{const r=o.escapeExpression(e),s=o.escapeExpression(t);return new o.SafeString(`<span style="color:${s}">${r}</span>`)}),o.registerHelper("br",()=>new o.SafeString("<br>")),o.registerHelper("bold",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<strong>${e}</strong>`)}),o.registerHelper("italic",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<em>${e}</em>`)}),o.registerHelper("underline",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-decoration:underline">${e}</span>`)}),o.registerHelper("strikethrough",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<s>${e}</s>`)}),o.registerHelper("uppercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:uppercase">${e}</span>`)}),o.registerHelper("lowercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:lowercase">${e}</span>`)}),o.registerHelper("capitalize",t=>{const e=String(t??""),r=e.charAt(0).toUpperCase()+e.slice(1);return new o.SafeString(o.escapeExpression(r))}),o.registerHelper("style",(t,e)=>{const{bold:r,italic:s,underline:i,strikethrough:n,uppercase:p,lowercase:a,color:m,fontSize:f,fontFamily:y}=e.hash;let b=o.escapeExpression(t);r&&(b=`<strong>${b}</strong>`),s&&(b=`<em>${b}</em>`),n&&(b=`<s>${b}</s>`);const u=[];return i&&u.push("text-decoration:underline"),p&&u.push("text-transform:uppercase"),a&&u.push("text-transform:lowercase"),m&&u.push(`color:${o.escapeExpression(m)}`),f&&u.push(`font-size:${o.escapeExpression(f)}`),y&&u.push(`font-family:${o.escapeExpression(y)}`),u.length&&(b=`<span style="${u.join(";")}">${b}</span>`),new o.SafeString(b)});const Q="en",Y=(t,e={},r="")=>{const s=e.lang||Q,i=t||r,n=P(s,i)??i;return o.compile(n)(e)},S=(t,e={},r="")=>A(Y(t,e,r)),I={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},es:{beamAttribution:()=>"Desarrollado por Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},it:{beamAttribution:()=>"Offerto da Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},pl:{beamAttribution:()=>"Wspierane przez Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`}};var X=Object.defineProperty,c=(t,e,r,s)=>{for(var i=void 0,n=t.length-1,p;n>=0;n--)(p=t[n])&&(i=p(e,r,i)||i);return i&&X(e,r,i),i};class l extends L{constructor(){super(...arguments),this.baseUrl=O,this.lang="en",this.debug=!1,this.draftConfig=!1,this.templateData={},this.chain={},this.subscriptionLookup=Promise.resolve(),this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId"],this);const e=await B({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{storeId:this.storeId,widgetName:k.subscriber_select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},version:"1.0.0",lang:this.configLang,options:{config:{draftConfig:this.draftConfig}}}});if(e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),await this.subscriptionLookup,this.selectedNonprofitId!=null&&!e.nonprofits.map(r=>r.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=void 0),this.selectedNonprofitId==null&&this.preselectNonprofitAtIndex!=null){const r=e.nonprofits[this.preselectNonprofitAtIndex-1];r&&(this.selectedNonprofitId=r.nonprofit.id,await this.selectionDataController.exec({selectedNonprofitId:r.nonprofit.id}))}return this.chain={...e?.chain},e},this.fetchSubscription=async()=>{v(["apiKey","subscriptionId"],this);const e=await z({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return e.nonprofit?.id&&this.selectedNonprofitId===void 0&&(this.selectedNonprofitId=e.nonprofit.id),e},this.updateNonprofitForSubscription=async({selectedNonprofitId:e})=>{v(["apiKey","subscriptionId"],this);const r=await _({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e,selectionMethod:R.subscriber_select_nonprofit_widget}});await this.updateComplete;const s=this.getNonprofitById(e);return this.dispatchEvent(new j({selectedNonprofitId:e,nonprofitName:s?.nonprofit?.name??null,source:k.subscriber_select_nonprofit,timestamp:new Date})),r},this.nonprofitListDataController=new C(this,this.getChainNonprofits),this.subscriptionDataController=new C(this,this.fetchSubscription),this.selectionDataController=new C(this,this.updateNonprofitForSubscription),this.makeHandleSelect=(e,r,s)=>async i=>{const n=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let p=null;switch(i.key){case"ArrowUp":case"ArrowLeft":p=r===0?s[s.length-1]:s[r-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":p=r===s.length-1?s[0]:s[r+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(p){n!=null&&(this.selectedNonprofitId=p.nonprofit.id);const a=this.renderRoot.querySelector(`[data-value="${p.nonprofit.id}"]`);a!==null&&(a.tabIndex=0,a.focus());return}}!(i.currentTarget instanceof HTMLElement)||n===e||(this.selectedNonprofitId=e,await this.selectionDataController.exec({selectedNonprofitId:e}))}}get configLang(){return F[this.lang]||"en"}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(r=>r.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),this.nonprofitListDataController.loading=!0}async firstUpdated(){!this.apiKey||!this.email&&!this.partnerUserId||(this.subscriptionLookup=this.subscriptionDataController.exec(),await this.subscriptionLookup)}async updated(e){const r=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const s of r)if(e.has(s)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...V,"--beam-SubscriberSelectNonprofit-title-textAlign":"inherit","--beam-SubscriberSelectNonprofit-description-textAlign":"inherit","--beam-SubscriberSelectNonprofit-maxWidth":"800px","--beam-SubscriberSelectNonprofit-options-marginTop":"0px","--beam-SubscriberSelectNonprofit-options-iconHeight":"20px","--beam-SubscriberSelectNonprofit-options-padding":"6px 4px","--beam-SubscriberSelectNonprofit-options-borderRadius":"4px","--beam-SubscriberSelectNonprofit-options-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-borderWidth":"1px","--beam-SubscriberSelectNonprofit-options--selected-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-backgroundColor":"transparent","--beam-SubscriberSelectNonprofit-options-gap":"8px","--beam-SubscriberSelectNonprofit-options-margin":"14px 0 0 0","--beam-SubscriberSelectNonprofit-width":"100%","--beam-SubscriberSelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SubscriberSelectNonprofit-details-marginTop":"6px","--beam-SubscriberSelectNonprofit-details-borderRadius":"4px","--beam-SubscriberSelectNonprofit-details-borderWidth":"1px","--beam-SubscriberSelectNonprofit-details-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-details-backgroundColor":"inherit","--beam-SubscriberSelectNonprofit-details-padding":"10px",...g("--beam-SubscriberSelectNonprofit-title",{fontSize:"1em",fontWeight:"bold"}),...g("--beam-SubscriberSelectNonprofit-description",{marginTop:"1em",fontSize:".85em"}),"--beam-SubscriberSelectNonprofit-title-block-margin-right":"8px",...g("--beam-SubscriberSelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold",textTransform:"uppercase"}),...g("--beam-SubscriberSelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...g("--beam-SubscriberSelectNonprofit-details-impactDescription",{fontSize:".85em",marginTop:"10px",lineHeight:"normal"}),"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop":"10px",...g("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"})},r=this.nonprofitListDataController?.data?.config?.web?.theme||{},s={...e,...r};return Object.assign(Object.create({toCSS(){return W(this)}}),s)}render(){if(!this.apiKey||!this.email&&!this.partnerUserId)return N``;const{selectedNonprofitId:e}=this,{data:r,loading:s}=this.nonprofitListDataController;if(s&&!r)return K();if(this.nonprofitListDataController.error)return this.debug?D({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return D({error:this.selectionDataController.error});const i=r?.nonprofits||[],n=i.find(a=>a.nonprofit.id===e)||null,p={custom:{...this.templateData},chain:{...this.chain},selectedNonprofit:{...n?.nonprofit},lang:this.configLang};return N`
|
|
1
|
+
import{h as A,i as E,n as d,r as T,a as L,b as N,k as H,j as U}from"../chunks/lit-BEag9MFp.esm.js";import{d as P,u as h,h as B,j as z,k as _,A as C,e as g,f as W,_ as K,c as D}from"../chunks/index-BlaOItQr.esm.js";import{D as O,W as k,y as w,z as R,B as j,x as F}from"../chunks/utils-ly9wMwUO.esm.js";import{c as q,d as G,e as v}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{a as V}from"../chunks/share-button-BxrZs18u.esm.js";import{c as J}from"../chunks/responsive-aN8P5PqD.esm.js";import{h as o,g as $}from"../chunks/handlebars-3tRO54kz.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const M={long:"dddd, MMMM D, YYYY",short:"MMM D, YYYY",numeric:"MM/DD/YYYY",iso:"YYYY-MM-DD",time:"h:mm A",time24:"HH:mm",datetime:"MMMM D, YYYY h:mm A",month:"MMMM YYYY",monthShort:"MMM YYYY",dayMonth:"MMMM D"},x=(t,e)=>{const r=M[e??"long"]??e??M.long;return $(t).format(r)};o.registerHelper("currentDate",t=>x(new Date,typeof t=="string"?t:void 0)),o.registerHelper("nextMonth",t=>{const e=$().add(1,"month").toDate();return x(e,typeof t=="string"?t:void 0)}),o.registerHelper("dateOffset",(t,e,r)=>{const s=typeof e=="string"?e:void 0,i=(typeof e=="string"?r:e)?.hash?.from,n=i?new Date(i):new Date,p=$(n).add(t,"day").toDate();return s==="relative"?t===-1?"yesterday":t===0?"today":t===1?"tomorrow":t<0?`${Math.abs(t)} days ago`:`${t} days from now`:x(p,s)}),o.registerHelper("formatDate",(t,e)=>{const r=t instanceof Date?t:new Date(t);return isNaN(r.getTime())?"":x(r,typeof e=="string"?e:void 0)}),o.registerHelper("color",(t,e)=>{const r=o.escapeExpression(e),s=o.escapeExpression(t);return new o.SafeString(`<span style="color:${s}">${r}</span>`)}),o.registerHelper("br",()=>new o.SafeString("<br>")),o.registerHelper("bold",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<strong>${e}</strong>`)}),o.registerHelper("italic",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<em>${e}</em>`)}),o.registerHelper("underline",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-decoration:underline">${e}</span>`)}),o.registerHelper("strikethrough",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<s>${e}</s>`)}),o.registerHelper("uppercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:uppercase">${e}</span>`)}),o.registerHelper("lowercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:lowercase">${e}</span>`)}),o.registerHelper("capitalize",t=>{const e=String(t??""),r=e.charAt(0).toUpperCase()+e.slice(1);return new o.SafeString(o.escapeExpression(r))}),o.registerHelper("style",(t,e)=>{const{bold:r,italic:s,underline:i,strikethrough:n,uppercase:p,lowercase:a,color:m,fontSize:f,fontFamily:y}=e.hash;let b=o.escapeExpression(t);r&&(b=`<strong>${b}</strong>`),s&&(b=`<em>${b}</em>`),n&&(b=`<s>${b}</s>`);const u=[];return i&&u.push("text-decoration:underline"),p&&u.push("text-transform:uppercase"),a&&u.push("text-transform:lowercase"),m&&u.push(`color:${o.escapeExpression(m)}`),f&&u.push(`font-size:${o.escapeExpression(f)}`),y&&u.push(`font-family:${o.escapeExpression(y)}`),u.length&&(b=`<span style="${u.join(";")}">${b}</span>`),new o.SafeString(b)});const Q="en",Y=(t,e={},r="")=>{const s=e.lang||Q,i=t||r,n=P(s,i)??i;return o.compile(n)(e)},S=(t,e={},r="")=>A(Y(t,e,r)),I={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},es:{beamAttribution:()=>"Desarrollado por Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},it:{beamAttribution:()=>"Offerto da Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},pl:{beamAttribution:()=>"Wspierane przez Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`}};var X=Object.defineProperty,c=(t,e,r,s)=>{for(var i=void 0,n=t.length-1,p;n>=0;n--)(p=t[n])&&(i=p(e,r,i)||i);return i&&X(e,r,i),i};class l extends L{constructor(){super(...arguments),this.baseUrl=O,this.lang="en",this.debug=!1,this.draftConfig=!1,this.templateData={},this.chain={},this.subscriptionLookup=Promise.resolve(),this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId"],this);const e=await B({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{storeId:this.storeId,widgetName:k.subscriber_select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},version:"1.0.0",lang:this.configLang,options:{config:{draftConfig:this.draftConfig}}}});if(e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),await this.subscriptionLookup,this.selectedNonprofitId!=null&&!e.nonprofits.map(r=>r.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=void 0),this.selectedNonprofitId==null&&this.preselectNonprofitAtIndex!=null){const r=e.nonprofits[this.preselectNonprofitAtIndex-1];r&&(this.selectedNonprofitId=r.nonprofit.id,await this.selectionDataController.exec({selectedNonprofitId:r.nonprofit.id}))}return this.chain={...e?.chain},e},this.fetchSubscription=async()=>{v(["apiKey","subscriptionId"],this);const e=await z({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return e.nonprofit?.id&&this.selectedNonprofitId===void 0&&(this.selectedNonprofitId=e.nonprofit.id),e},this.updateNonprofitForSubscription=async({selectedNonprofitId:e})=>{v(["apiKey","subscriptionId"],this);const r=await _({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e,selectionMethod:R.subscriber_select_nonprofit_widget}});await this.updateComplete;const s=this.getNonprofitById(e);return this.dispatchEvent(new j({selectedNonprofitId:e,nonprofitName:s?.nonprofit?.name??null,source:k.subscriber_select_nonprofit,timestamp:new Date})),r},this.nonprofitListDataController=new C(this,this.getChainNonprofits),this.subscriptionDataController=new C(this,this.fetchSubscription),this.selectionDataController=new C(this,this.updateNonprofitForSubscription),this.makeHandleSelect=(e,r,s)=>async i=>{const n=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let p=null;switch(i.key){case"ArrowUp":case"ArrowLeft":p=r===0?s[s.length-1]:s[r-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":p=r===s.length-1?s[0]:s[r+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(p){n!=null&&(this.selectedNonprofitId=p.nonprofit.id);const a=this.renderRoot.querySelector(`[data-value="${p.nonprofit.id}"]`);a!==null&&(a.tabIndex=0,a.focus());return}}!(i.currentTarget instanceof HTMLElement)||n===e||(this.selectedNonprofitId=e,await this.selectionDataController.exec({selectedNonprofitId:e}))}}get configLang(){return F[this.lang]||"en"}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(r=>r.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),this.nonprofitListDataController.loading=!0}async firstUpdated(){!this.apiKey||!this.email&&!this.partnerUserId||(this.subscriptionLookup=this.subscriptionDataController.exec(),await this.subscriptionLookup)}async updated(e){const r=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const s of r)if(e.has(s)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...V,"--beam-SubscriberSelectNonprofit-title-textAlign":"inherit","--beam-SubscriberSelectNonprofit-description-textAlign":"inherit","--beam-SubscriberSelectNonprofit-maxWidth":"800px","--beam-SubscriberSelectNonprofit-options-marginTop":"0px","--beam-SubscriberSelectNonprofit-options-iconHeight":"20px","--beam-SubscriberSelectNonprofit-options-padding":"6px 4px","--beam-SubscriberSelectNonprofit-options-borderRadius":"4px","--beam-SubscriberSelectNonprofit-options-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-borderWidth":"1px","--beam-SubscriberSelectNonprofit-options--selected-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-backgroundColor":"transparent","--beam-SubscriberSelectNonprofit-options-gap":"8px","--beam-SubscriberSelectNonprofit-options-margin":"14px 0 0 0","--beam-SubscriberSelectNonprofit-width":"100%","--beam-SubscriberSelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SubscriberSelectNonprofit-details-marginTop":"6px","--beam-SubscriberSelectNonprofit-details-borderRadius":"4px","--beam-SubscriberSelectNonprofit-details-borderWidth":"1px","--beam-SubscriberSelectNonprofit-details-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-details-backgroundColor":"inherit","--beam-SubscriberSelectNonprofit-details-padding":"10px",...g("--beam-SubscriberSelectNonprofit-title",{fontSize:"1em",fontWeight:"bold"}),...g("--beam-SubscriberSelectNonprofit-description",{marginTop:"1em",fontSize:".85em"}),"--beam-SubscriberSelectNonprofit-title-block-margin-right":"8px",...g("--beam-SubscriberSelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold",textTransform:"uppercase"}),...g("--beam-SubscriberSelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...g("--beam-SubscriberSelectNonprofit-details-impactDescription",{fontSize:".85em",marginTop:"10px",lineHeight:"normal"}),"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop":"10px",...g("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"})},r=this.nonprofitListDataController?.data?.config?.web?.theme||{},s={...e,...r};return Object.assign(Object.create({toCSS(){return W(this)}}),s)}render(){if(!this.apiKey||!this.email&&!this.partnerUserId)return N``;const{selectedNonprofitId:e}=this,{data:r,loading:s}=this.nonprofitListDataController;if(s&&!r)return K();if(this.nonprofitListDataController.error)return this.debug?D({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return D({error:this.selectionDataController.error});const i=r?.nonprofits||[],n=i.find(a=>a.nonprofit.id===e)||null,p={custom:{...this.templateData},chain:{...this.chain},selectedNonprofit:{...n?.nonprofit},lang:this.configLang};return N`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
${this.cssVariables.toCSS()}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as A,i as E,n as d,r as T,a as L,b as N,k as H,j as U}from"../chunks/lit-BEag9MFp.esm.js";import{d as P,u as h,h as B,j as z,k as _,A as C,e as g,f as W,_ as K,c as D}from"../chunks/index-M8hQ6GXf.esm.js";import{D as O,W as k,y as w,z as R,B as j,x as F}from"../chunks/utils-ly9wMwUO.esm.js";import{c as q,d as G,e as v}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{a as V}from"../chunks/share-button-C1PRjoPw.esm.js";import{c as J}from"../chunks/responsive-aN8P5PqD.esm.js";import{h as o,g as $}from"../chunks/handlebars-3tRO54kz.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const M={long:"dddd, MMMM D, YYYY",short:"MMM D, YYYY",numeric:"MM/DD/YYYY",iso:"YYYY-MM-DD",time:"h:mm A",time24:"HH:mm",datetime:"MMMM D, YYYY h:mm A",month:"MMMM YYYY",monthShort:"MMM YYYY",dayMonth:"MMMM D"},x=(t,e)=>{const r=M[e??"long"]??e??M.long;return $(t).format(r)};o.registerHelper("currentDate",t=>x(new Date,typeof t=="string"?t:void 0)),o.registerHelper("nextMonth",t=>{const e=$().add(1,"month").toDate();return x(e,typeof t=="string"?t:void 0)}),o.registerHelper("dateOffset",(t,e,r)=>{const s=typeof e=="string"?e:void 0,i=(typeof e=="string"?r:e)?.hash?.from,n=i?new Date(i):new Date,p=$(n).add(t,"day").toDate();return s==="relative"?t===-1?"yesterday":t===0?"today":t===1?"tomorrow":t<0?`${Math.abs(t)} days ago`:`${t} days from now`:x(p,s)}),o.registerHelper("formatDate",(t,e)=>{const r=t instanceof Date?t:new Date(t);return isNaN(r.getTime())?"":x(r,typeof e=="string"?e:void 0)}),o.registerHelper("color",(t,e)=>{const r=o.escapeExpression(e),s=o.escapeExpression(t);return new o.SafeString(`<span style="color:${s}">${r}</span>`)}),o.registerHelper("br",()=>new o.SafeString("<br>")),o.registerHelper("bold",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<strong>${e}</strong>`)}),o.registerHelper("italic",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<em>${e}</em>`)}),o.registerHelper("underline",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-decoration:underline">${e}</span>`)}),o.registerHelper("strikethrough",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<s>${e}</s>`)}),o.registerHelper("uppercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:uppercase">${e}</span>`)}),o.registerHelper("lowercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:lowercase">${e}</span>`)}),o.registerHelper("capitalize",t=>{const e=String(t??""),r=e.charAt(0).toUpperCase()+e.slice(1);return new o.SafeString(o.escapeExpression(r))}),o.registerHelper("style",(t,e)=>{const{bold:r,italic:s,underline:i,strikethrough:n,uppercase:p,lowercase:a,color:m,fontSize:f,fontFamily:y}=e.hash;let b=o.escapeExpression(t);r&&(b=`<strong>${b}</strong>`),s&&(b=`<em>${b}</em>`),n&&(b=`<s>${b}</s>`);const u=[];return i&&u.push("text-decoration:underline"),p&&u.push("text-transform:uppercase"),a&&u.push("text-transform:lowercase"),m&&u.push(`color:${o.escapeExpression(m)}`),f&&u.push(`font-size:${o.escapeExpression(f)}`),y&&u.push(`font-family:${o.escapeExpression(y)}`),u.length&&(b=`<span style="${u.join(";")}">${b}</span>`),new o.SafeString(b)});const Q="en",Y=(t,e={},r="")=>{const s=e.lang||Q,i=t||r,n=P(s,i)??i;return o.compile(n)(e)},S=(t,e={},r="")=>A(Y(t,e,r)),I={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},es:{beamAttribution:()=>"Desarrollado por Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},it:{beamAttribution:()=>"Offerto da Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},pl:{beamAttribution:()=>"Wspierane przez Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`}};var X=Object.defineProperty,c=(t,e,r,s)=>{for(var i=void 0,n=t.length-1,p;n>=0;n--)(p=t[n])&&(i=p(e,r,i)||i);return i&&X(e,r,i),i};class l extends L{constructor(){super(...arguments),this.baseUrl=O,this.lang="en",this.debug=!1,this.draftConfig=!1,this.templateData={},this.chain={},this.subscriptionLookup=Promise.resolve(),this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId"],this);const e=await B({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{storeId:this.storeId,widgetName:k.subscriber_select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},version:"1.0.0",lang:this.configLang,options:{config:{draftConfig:this.draftConfig}}}});if(e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),await this.subscriptionLookup,this.selectedNonprofitId!=null&&!e.nonprofits.map(r=>r.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=void 0),this.selectedNonprofitId==null&&this.preselectNonprofitAtIndex!=null){const r=e.nonprofits[this.preselectNonprofitAtIndex-1];r&&(this.selectedNonprofitId=r.nonprofit.id,await this.selectionDataController.exec({selectedNonprofitId:r.nonprofit.id}))}return this.chain={...e?.chain},e},this.fetchSubscription=async()=>{v(["apiKey","subscriptionId"],this);const e=await z({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return e.nonprofit?.id&&this.selectedNonprofitId===void 0&&(this.selectedNonprofitId=e.nonprofit.id),e},this.updateNonprofitForSubscription=async({selectedNonprofitId:e})=>{v(["apiKey","subscriptionId"],this);const r=await _({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e,selectionMethod:R.subscriber_select_nonprofit_widget}});await this.updateComplete;const s=this.getNonprofitById(e);return this.dispatchEvent(new j({selectedNonprofitId:e,nonprofitName:s?.nonprofit?.name??null,source:k.subscriber_select_nonprofit,timestamp:new Date})),r},this.nonprofitListDataController=new C(this,this.getChainNonprofits),this.subscriptionDataController=new C(this,this.fetchSubscription),this.selectionDataController=new C(this,this.updateNonprofitForSubscription),this.makeHandleSelect=(e,r,s)=>async i=>{const n=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let p=null;switch(i.key){case"ArrowUp":case"ArrowLeft":p=r===0?s[s.length-1]:s[r-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":p=r===s.length-1?s[0]:s[r+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(p){n!=null&&(this.selectedNonprofitId=p.nonprofit.id);const a=this.renderRoot.querySelector(`[data-value="${p.nonprofit.id}"]`);a!==null&&(a.tabIndex=0,a.focus());return}}!(i.currentTarget instanceof HTMLElement)||n===e||(this.selectedNonprofitId=e,await this.selectionDataController.exec({selectedNonprofitId:e}))}}get configLang(){return F[this.lang]||"en"}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(r=>r.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),this.nonprofitListDataController.loading=!0}async firstUpdated(){!this.apiKey||!this.email&&!this.partnerUserId||(this.subscriptionLookup=this.subscriptionDataController.exec(),await this.subscriptionLookup)}async updated(e){const r=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const s of r)if(e.has(s)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...V,"--beam-SubscriberSelectNonprofit-title-textAlign":"inherit","--beam-SubscriberSelectNonprofit-description-textAlign":"inherit","--beam-SubscriberSelectNonprofit-maxWidth":"800px","--beam-SubscriberSelectNonprofit-options-marginTop":"0px","--beam-SubscriberSelectNonprofit-options-iconHeight":"20px","--beam-SubscriberSelectNonprofit-options-padding":"6px 4px","--beam-SubscriberSelectNonprofit-options-borderRadius":"4px","--beam-SubscriberSelectNonprofit-options-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-borderWidth":"1px","--beam-SubscriberSelectNonprofit-options--selected-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-backgroundColor":"transparent","--beam-SubscriberSelectNonprofit-options-gap":"8px","--beam-SubscriberSelectNonprofit-options-margin":"14px 0 0 0","--beam-SubscriberSelectNonprofit-width":"100%","--beam-SubscriberSelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SubscriberSelectNonprofit-details-marginTop":"6px","--beam-SubscriberSelectNonprofit-details-borderRadius":"4px","--beam-SubscriberSelectNonprofit-details-borderWidth":"1px","--beam-SubscriberSelectNonprofit-details-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-details-backgroundColor":"inherit","--beam-SubscriberSelectNonprofit-details-padding":"10px",...g("--beam-SubscriberSelectNonprofit-title",{fontSize:"1em",fontWeight:"bold"}),...g("--beam-SubscriberSelectNonprofit-description",{marginTop:"1em",fontSize:".85em"}),"--beam-SubscriberSelectNonprofit-title-block-margin-right":"8px",...g("--beam-SubscriberSelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold",textTransform:"uppercase"}),...g("--beam-SubscriberSelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...g("--beam-SubscriberSelectNonprofit-details-impactDescription",{fontSize:".85em",marginTop:"10px",lineHeight:"normal"}),"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop":"10px",...g("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"})},r=this.nonprofitListDataController?.data?.config?.web?.theme||{},s={...e,...r};return Object.assign(Object.create({toCSS(){return W(this)}}),s)}render(){if(!this.apiKey||!this.email&&!this.partnerUserId)return N``;const{selectedNonprofitId:e}=this,{data:r,loading:s}=this.nonprofitListDataController;if(s&&!r)return K();if(this.nonprofitListDataController.error)return this.debug?D({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return D({error:this.selectionDataController.error});const i=r?.nonprofits||[],n=i.find(a=>a.nonprofit.id===e)||null,p={custom:{...this.templateData},chain:{...this.chain},selectedNonprofit:{...n?.nonprofit},lang:this.configLang};return N`
|
|
1
|
+
import{h as A,i as E,n as d,r as T,a as L,b as N,k as H,j as U}from"../chunks/lit-BEag9MFp.esm.js";import{d as P,u as h,h as B,j as z,k as _,A as C,e as g,f as W,_ as K,c as D}from"../chunks/index-BlaOItQr.esm.js";import{D as O,W as k,y as w,z as R,B as j,x as F}from"../chunks/utils-ly9wMwUO.esm.js";import{c as q,d as G,e as v}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{a as V}from"../chunks/share-button-BxrZs18u.esm.js";import{c as J}from"../chunks/responsive-aN8P5PqD.esm.js";import{h as o,g as $}from"../chunks/handlebars-3tRO54kz.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const M={long:"dddd, MMMM D, YYYY",short:"MMM D, YYYY",numeric:"MM/DD/YYYY",iso:"YYYY-MM-DD",time:"h:mm A",time24:"HH:mm",datetime:"MMMM D, YYYY h:mm A",month:"MMMM YYYY",monthShort:"MMM YYYY",dayMonth:"MMMM D"},x=(t,e)=>{const r=M[e??"long"]??e??M.long;return $(t).format(r)};o.registerHelper("currentDate",t=>x(new Date,typeof t=="string"?t:void 0)),o.registerHelper("nextMonth",t=>{const e=$().add(1,"month").toDate();return x(e,typeof t=="string"?t:void 0)}),o.registerHelper("dateOffset",(t,e,r)=>{const s=typeof e=="string"?e:void 0,i=(typeof e=="string"?r:e)?.hash?.from,n=i?new Date(i):new Date,p=$(n).add(t,"day").toDate();return s==="relative"?t===-1?"yesterday":t===0?"today":t===1?"tomorrow":t<0?`${Math.abs(t)} days ago`:`${t} days from now`:x(p,s)}),o.registerHelper("formatDate",(t,e)=>{const r=t instanceof Date?t:new Date(t);return isNaN(r.getTime())?"":x(r,typeof e=="string"?e:void 0)}),o.registerHelper("color",(t,e)=>{const r=o.escapeExpression(e),s=o.escapeExpression(t);return new o.SafeString(`<span style="color:${s}">${r}</span>`)}),o.registerHelper("br",()=>new o.SafeString("<br>")),o.registerHelper("bold",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<strong>${e}</strong>`)}),o.registerHelper("italic",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<em>${e}</em>`)}),o.registerHelper("underline",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-decoration:underline">${e}</span>`)}),o.registerHelper("strikethrough",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<s>${e}</s>`)}),o.registerHelper("uppercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:uppercase">${e}</span>`)}),o.registerHelper("lowercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:lowercase">${e}</span>`)}),o.registerHelper("capitalize",t=>{const e=String(t??""),r=e.charAt(0).toUpperCase()+e.slice(1);return new o.SafeString(o.escapeExpression(r))}),o.registerHelper("style",(t,e)=>{const{bold:r,italic:s,underline:i,strikethrough:n,uppercase:p,lowercase:a,color:m,fontSize:f,fontFamily:y}=e.hash;let b=o.escapeExpression(t);r&&(b=`<strong>${b}</strong>`),s&&(b=`<em>${b}</em>`),n&&(b=`<s>${b}</s>`);const u=[];return i&&u.push("text-decoration:underline"),p&&u.push("text-transform:uppercase"),a&&u.push("text-transform:lowercase"),m&&u.push(`color:${o.escapeExpression(m)}`),f&&u.push(`font-size:${o.escapeExpression(f)}`),y&&u.push(`font-family:${o.escapeExpression(y)}`),u.length&&(b=`<span style="${u.join(";")}">${b}</span>`),new o.SafeString(b)});const Q="en",Y=(t,e={},r="")=>{const s=e.lang||Q,i=t||r,n=P(s,i)??i;return o.compile(n)(e)},S=(t,e={},r="")=>A(Y(t,e,r)),I={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},es:{beamAttribution:()=>"Desarrollado por Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},it:{beamAttribution:()=>"Offerto da Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},pl:{beamAttribution:()=>"Wspierane przez Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`}};var X=Object.defineProperty,c=(t,e,r,s)=>{for(var i=void 0,n=t.length-1,p;n>=0;n--)(p=t[n])&&(i=p(e,r,i)||i);return i&&X(e,r,i),i};class l extends L{constructor(){super(...arguments),this.baseUrl=O,this.lang="en",this.debug=!1,this.draftConfig=!1,this.templateData={},this.chain={},this.subscriptionLookup=Promise.resolve(),this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId"],this);const e=await B({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{storeId:this.storeId,widgetName:k.subscriber_select_nonprofit,...this.postalCode&&{postalCode:this.postalCode},...this.countryCode&&{countryCode:this.countryCode},version:"1.0.0",lang:this.configLang,options:{config:{draftConfig:this.draftConfig}}}});if(e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),await this.subscriptionLookup,this.selectedNonprofitId!=null&&!e.nonprofits.map(r=>r.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=void 0),this.selectedNonprofitId==null&&this.preselectNonprofitAtIndex!=null){const r=e.nonprofits[this.preselectNonprofitAtIndex-1];r&&(this.selectedNonprofitId=r.nonprofit.id,await this.selectionDataController.exec({selectedNonprofitId:r.nonprofit.id}))}return this.chain={...e?.chain},e},this.fetchSubscription=async()=>{v(["apiKey","subscriptionId"],this);const e=await z({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return e.nonprofit?.id&&this.selectedNonprofitId===void 0&&(this.selectedNonprofitId=e.nonprofit.id),e},this.updateNonprofitForSubscription=async({selectedNonprofitId:e})=>{v(["apiKey","subscriptionId"],this);const r=await _({baseUrl:this.baseUrl,headers:w(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e,selectionMethod:R.subscriber_select_nonprofit_widget}});await this.updateComplete;const s=this.getNonprofitById(e);return this.dispatchEvent(new j({selectedNonprofitId:e,nonprofitName:s?.nonprofit?.name??null,source:k.subscriber_select_nonprofit,timestamp:new Date})),r},this.nonprofitListDataController=new C(this,this.getChainNonprofits),this.subscriptionDataController=new C(this,this.fetchSubscription),this.selectionDataController=new C(this,this.updateNonprofitForSubscription),this.makeHandleSelect=(e,r,s)=>async i=>{const n=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let p=null;switch(i.key){case"ArrowUp":case"ArrowLeft":p=r===0?s[s.length-1]:s[r-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":p=r===s.length-1?s[0]:s[r+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(p){n!=null&&(this.selectedNonprofitId=p.nonprofit.id);const a=this.renderRoot.querySelector(`[data-value="${p.nonprofit.id}"]`);a!==null&&(a.tabIndex=0,a.focus());return}}!(i.currentTarget instanceof HTMLElement)||n===e||(this.selectedNonprofitId=e,await this.selectionDataController.exec({selectedNonprofitId:e}))}}get configLang(){return F[this.lang]||"en"}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(r=>r.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),this.nonprofitListDataController.loading=!0}async firstUpdated(){!this.apiKey||!this.email&&!this.partnerUserId||(this.subscriptionLookup=this.subscriptionDataController.exec(),await this.subscriptionLookup)}async updated(e){const r=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const s of r)if(e.has(s)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...V,"--beam-SubscriberSelectNonprofit-title-textAlign":"inherit","--beam-SubscriberSelectNonprofit-description-textAlign":"inherit","--beam-SubscriberSelectNonprofit-maxWidth":"800px","--beam-SubscriberSelectNonprofit-options-marginTop":"0px","--beam-SubscriberSelectNonprofit-options-iconHeight":"20px","--beam-SubscriberSelectNonprofit-options-padding":"6px 4px","--beam-SubscriberSelectNonprofit-options-borderRadius":"4px","--beam-SubscriberSelectNonprofit-options-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-borderWidth":"1px","--beam-SubscriberSelectNonprofit-options--selected-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-backgroundColor":"transparent","--beam-SubscriberSelectNonprofit-options-gap":"8px","--beam-SubscriberSelectNonprofit-options-margin":"14px 0 0 0","--beam-SubscriberSelectNonprofit-width":"100%","--beam-SubscriberSelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SubscriberSelectNonprofit-details-marginTop":"6px","--beam-SubscriberSelectNonprofit-details-borderRadius":"4px","--beam-SubscriberSelectNonprofit-details-borderWidth":"1px","--beam-SubscriberSelectNonprofit-details-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-details-backgroundColor":"inherit","--beam-SubscriberSelectNonprofit-details-padding":"10px",...g("--beam-SubscriberSelectNonprofit-title",{fontSize:"1em",fontWeight:"bold"}),...g("--beam-SubscriberSelectNonprofit-description",{marginTop:"1em",fontSize:".85em"}),"--beam-SubscriberSelectNonprofit-title-block-margin-right":"8px",...g("--beam-SubscriberSelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold",textTransform:"uppercase"}),...g("--beam-SubscriberSelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...g("--beam-SubscriberSelectNonprofit-details-impactDescription",{fontSize:".85em",marginTop:"10px",lineHeight:"normal"}),"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop":"10px",...g("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"})},r=this.nonprofitListDataController?.data?.config?.web?.theme||{},s={...e,...r};return Object.assign(Object.create({toCSS(){return W(this)}}),s)}render(){if(!this.apiKey||!this.email&&!this.partnerUserId)return N``;const{selectedNonprofitId:e}=this,{data:r,loading:s}=this.nonprofitListDataController;if(s&&!r)return K();if(this.nonprofitListDataController.error)return this.debug?D({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return D({error:this.selectionDataController.error});const i=r?.nonprofits||[],n=i.find(a=>a.nonprofit.id===e)||null,p={custom:{...this.templateData},chain:{...this.chain},selectedNonprofit:{...n?.nonprofit},lang:this.configLang};return N`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
${this.cssVariables.toCSS()}
|
|
@@ -2,7 +2,7 @@ import * as lit from 'lit';
|
|
|
2
2
|
import { LitElement, PropertyValues } from 'lit';
|
|
3
3
|
import * as lit_html from 'lit-html';
|
|
4
4
|
import * as lodash from 'lodash';
|
|
5
|
-
import { f as TUrl, b as TNumericId, c as TId, L as LANGUAGES } from '../chunks/utils-
|
|
5
|
+
import { f as TUrl, b as TNumericId, c as TId, L as LANGUAGES } from '../chunks/utils-DfsVjUY-.esm.js';
|
|
6
6
|
import 'lodash-es/debounce';
|
|
7
7
|
import 'lodash-es/isEqual';
|
|
8
8
|
|
|
@@ -21,6 +21,7 @@ declare class BeamSubscriptionImpact extends LitElement {
|
|
|
21
21
|
lang: LANGUAGES;
|
|
22
22
|
debug: boolean;
|
|
23
23
|
draftConfig: boolean;
|
|
24
|
+
showShareButton: boolean;
|
|
24
25
|
private isMobile;
|
|
25
26
|
get configLang(): LANGUAGES;
|
|
26
27
|
getImpactData: () => Promise<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as k,i as $,b as p,n as l,r as _,g as C}from"../chunks/lit-BEag9MFp.esm.js";import{d as z,a as G}from"../chunks/lodash-CrMU6wKg.esm.js";import{a as Y}from"../chunks/share-button-BxrZs18u.esm.js";import{s as S,a as K}from"../chunks/share-button-DQT2zQ7w.esm.js";import"../chunks/_share-dialog-dependencies-C3oAeUgm.esm.js";import"../chunks/vendor-DUOg5fL-.esm.js";import{D as q,y as J,x as Q,l as X}from"../chunks/utils-ly9wMwUO.esm.js";import{u as b,g as Z,A as ee,e as u,f as ie,_ as ae,c as te,d as n}from"../chunks/index-BlaOItQr.esm.js";import{c as ne,a as re,d as oe,e as se}from"../chunks/css-card-grid-tjA36yWj.esm.js";import{c as ce}from"../chunks/responsive-aN8P5PqD.esm.js";var pe=Object.defineProperty,le=(i,e,o,m)=>{for(var t=void 0,a=i.length-1,d;a>=0;a--)(d=i[a])&&(t=d(e,o,t)||t);return t&&pe(e,o,t),t};class A extends k{constructor(){super(...arguments),this.infoText=""}static get styles(){return $`
|
|
2
2
|
sl-badge::part(base) {
|
|
3
3
|
background-color: var(--beam-pillLabel-color-background, #000);
|
|
4
4
|
color: var(--beam-pillLabel-color, #fff);
|
|
@@ -11,7 +11,7 @@ import{a as w,i as $,b as p,n as l,r as _,g as C}from"../chunks/lit-BEag9MFp.esm
|
|
|
11
11
|
text-transform: var(--beam-pillLabel-text-transform, none);
|
|
12
12
|
padding: var(--beam-pillLabel-padding, 3px 4px);
|
|
13
13
|
}
|
|
14
|
-
`}render(){return p`<sl-badge pill aria-label="${this.infoText}">${this.infoText}</sl-badge>`}}le([l({type:String})],A.prototype,"infoText"),customElements.get("beam-info-pill")||customElements.define("beam-info-pill",A);const me={"--beam-pillLabel-color-background":"#0A323C","--beam-pillLabel-color":"#fff","--beam-pillLabel-border":"#0A323C","--beam-pillLabel-border-width":"1px","--beam-pillLabel-font-size":"10px","--beam-pillLabel-font":"inherit","--beam-pillLabel-font-weight":"400","--beam-pillLabel-text-transform":"none","--beam-pillLabel-font-style":"italic","--beam-pillLabel-padding":"3px 4px"},s={en:{title:({causeName:i=""})=>`Your Subscription is Going Towards ${i} With Every Order`,futureTenseTitle:({causeName:i=""})=>`Your Subscription Will Go Towards ${i} With Every Order`,ctaMessagePrefix:()=>"At no extra cost, ",description:({nonprofit:i=""})=>`1% will be donated to ${i} for you, at no extra cost, every order.`,personalImpactTitle:()=>"You're Currently Funding",futureTensePersonalImpactTitle:()=>"You\u2019ll Be Funding",communityImpactTitle:()=>"Together We're Funding",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Learn about ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Learn about ${i} impact${e?"":" \u203A"}`,percentFunded:()=>"funded",progressPillText:()=>"\u{1F389} Impact begins once order is charged"},fr:{title:({causeName:i=""})=>`Votre abonnement contribue \xE0 ${i} \xE0 chaque commande`,futureTenseTitle:({causeName:i=""})=>`Votre abonnement contribuera \xE0 ${i} \xE0 chaque commande`,ctaMessagePrefix:()=>"Sans frais suppl\xE9mentaires, ",description:({nonprofit:i=""})=>`1% de chaque commande sera revers\xE9 \xE0 ${i} pour vous, sans frais suppl\xE9mentaires.`,personalImpactTitle:()=>"Vous financez actuellement",futureTensePersonalImpactTitle:()=>"Vous financerez",communityImpactTitle:()=>"Ensemble, nous finan\xE7ons",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`En savoir plus sur ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`En savoir plus sur l\u2019impact de ${i}${e?"":" \u203A"}`,percentFunded:()=>"financ\xE9",progressPillText:()=>"\u{1F389} L\u2019impact commence une fois la commande d\xE9bit\xE9e"},de:{title:({causeName:i=""})=>`Ihr Abonnement unterst\xFCtzt ${i} mit jeder Bestellung`,futureTenseTitle:({causeName:i=""})=>`Ihr Abonnement wird ${i} mit jeder Bestellung unterst\xFCtzen`,ctaMessagePrefix:()=>"Ohne zus\xE4tzliche Kosten, ",description:({nonprofit:i=""})=>`1% jeder Bestellung wird im Rahmen Ihres Abonnements an ${i} gespendet.`,personalImpactTitle:()=>"Sie unterst\xFCtzen derzeit",futureTensePersonalImpactTitle:()=>"Sie werden unterst\xFCtzen",communityImpactTitle:()=>"Gemeinsam unterst\xFCtzen wir",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Mehr \xFCber ${i} erfahren${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Mehr \xFCber die Wirkung von ${i} erfahren${e?"":" \u203A"}`,percentFunded:()=>"finanziert",progressPillText:()=>"\u{1F389} Wirkung beginnt, sobald die Bestellung abgerechnet wird"},es:{title:({causeName:i=""})=>`Tu suscripci\xF3n est\xE1 apoyando a ${i} con cada pedido`,futureTenseTitle:({causeName:i=""})=>`Tu suscripci\xF3n apoyar\xE1 a ${i} con cada pedido`,ctaMessagePrefix:()=>"Sin coste adicional, ",description:({nonprofit:i=""})=>`El 1% de cada pedido se donar\xE1 a ${i} en tu nombre.`,personalImpactTitle:()=>"Actualmente est\xE1s financiando",futureTensePersonalImpactTitle:()=>"Financiar\xE1s",communityImpactTitle:()=>"Juntos estamos financiando",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Conoce m\xE1s sobre ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Conoce m\xE1s sobre el impacto de ${i}${e?"":" \u203A"}`,percentFunded:()=>"financiado",progressPillText:()=>"\u{1F389} El impacto comienza una vez que se procese el pedido"},it:{title:({causeName:i=""})=>`Il tuo abbonamento sostiene ${i} con ogni ordine`,futureTenseTitle:({causeName:i=""})=>`Il tuo abbonamento sosterr\xE0 ${i} con ogni ordine`,ctaMessagePrefix:()=>"Senza alcun costo aggiuntivo, ",description:({nonprofit:i=""})=>`L'1% di ogni ordine sar\xE0 donato a ${i} per te.`,personalImpactTitle:()=>"Attualmente stai finanziando",futureTensePersonalImpactTitle:()=>"Finanzierai",communityImpactTitle:()=>"Insieme stiamo finanziando",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Scopri di pi\xF9 su ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Scopri di pi\xF9 sull\u2019impatto di ${i}${e?"":" \u203A"}`,percentFunded:()=>"finanziato",progressPillText:()=>"\u{1F389} L\u2019impatto inizia una volta che l\u2019ordine \xE8 stato addebitato"},pl:{title:({causeName:i=""})=>`Twoja subskrypcja wspiera ${i} przy ka\u017Cdym zam\xF3wieniu`,futureTenseTitle:({causeName:i=""})=>`Twoja subskrypcja b\u0119dzie wspiera\u0107 ${i} przy ka\u017Cdym zam\xF3wieniu`,ctaMessagePrefix:()=>"Bez dodatkowych koszt\xF3w, ",description:({nonprofit:i=""})=>`1% z ka\u017Cdego zam\xF3wienia zostanie przekazane na rzecz ${i} w Twoim imieniu.`,personalImpactTitle:()=>"Obecnie wspierasz",futureTensePersonalImpactTitle:()=>"B\u0119dziesz wspiera\u0107",communityImpactTitle:()=>"Razem wspieramy",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Dowiedz si\u0119 wi\u0119cej o ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Dowiedz si\u0119 wi\u0119cej o wp\u0142ywie ${i}${e?"":" \u203A"}`,percentFunded:()=>"sfinansowano",progressPillText:()=>"\u{1F389} Wp\u0142yw rozpoczyna si\u0119 po zrealizowaniu zam\xF3wienia"},ja:{title:({causeName:i=""})=>`Your Subscription is Going Towards ${i} With Every Order`,futureTenseTitle:({causeName:i=""})=>`Your Subscription Will Go Towards ${i} With Every Order`,ctaMessagePrefix:()=>"At no extra cost, ",description:({nonprofit:i=""})=>`1% will be donated to ${i} for you, at no extra cost, every order.`,personalImpactTitle:()=>"You're Currently Funding",futureTensePersonalImpactTitle:()=>"You\u2019ll Be Funding",communityImpactTitle:()=>"Together We're Funding",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Learn about ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Learn about ${i} impact${e?"":" \u203A"}`,percentFunded:()=>"\u652F\u63F4\u6E08\u307F",progressPillText:()=>"\u{1F389} Impact begins once order is charged"}};var de=Object.defineProperty,c=(i,e,r,m)=>{for(var t=void 0,a=i.length-1,d;a>=0;a--)(d=i[a])&&(t=d(e,r,t)||t);return t&&de(e,r,t),t};class o extends w{constructor(){super(...arguments),this.baseUrl=q,this.lang="en",this.debug=!1,this.draftConfig=!1,this.isMobile=window.innerWidth<720,this.getImpactData=async()=>(se(["apiKey","beamUserId","nonprofitId"],this),await Z({baseUrl:this.baseUrl,headers:J(this.apiKey),queryParams:{nonprofitId:this.nonprofitId,beamUserId:this.beamUserId,personalImpactLimit:1,communityImpactLimit:1,storeId:this.storeId,widgetName:"subscription-impact",draftConfig:this.draftConfig,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new ee(this,this.getImpactData),this.evaluateBreakPoints=z(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0}),this.resizeElements=z(()=>{S(this.impactTitleRefs),S(this.impactLinkRefs)},50,{maxWait:50,leading:!0})}get configLang(){return Q[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async updated(e){const r=["baseUrl","storeId","apiKey","beamUserId","lang"];for(const m of r)if(e.has(m)){await this.impactDataController.exec();break}this.resizeElements(),await this.handleFontLoad(this.resizeElements)}disconnectedCallback(){window.removeEventListener("resize",this.resizeElements),document.fonts.removeEventListener("loadingdone",this.resizeElements),super.disconnectedCallback()}async handleFontLoad(e){if(document.fonts.status==="loading")return await document.fonts.ready.catch(r=>X.error(r)),e()}get cssVariables(){const e={...Y,...K,...me,"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"12px","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-subscriptionImpact-impactCards-maxWidth":"900px","--beam-subscriptionImpact-headerContainer-desktop-textAlign":"left","--beam-subscriptionImpact-headerContainer-mobile-textAlign":"center","--beam-subscriptionImpact-descriptionContainer-marginTop":"10px","--beam-subscriptionImpact-cardContainer-marginTop":"15px","--beam-subscriptionImpact-cardContainer-gap":"20px","--beam-subscriptionImpact-card-borderRadius":"8px","--beam-subscriptionImpact-card-background":"#f8fbfb","--beam-subscriptionImpact-card-padding":"24px 28px 24px 24px","--beam-subscriptionImpact-card-marginRight":"0px","--beam-subscriptionImpact-card-marginTop":"10px","--beam-subscriptionImpact-card-gap":"5px","--beam-subscriptionImpact-cardTitle-textAlign":"left","--beam-subscriptionImpact-cardTitle-letterSpacing":"0.36px","--beam-SubscriptionImpact-cardStyle":"'selected_icon'","--beam-SubscriptionImpact-imagePosition":"'inline'","--beam-subscriptionImpact-imageBlock-height":"120px","--beam-subscriptionImpact-imageBlock-borderRadius":"4px","--beam-subscriptionImpact-iconBackground-width":"50px","--beam-subscriptionImpact-iconBackground-height":"50px","--beam-subscriptionImpact-iconBackground-borderRadius":"50%","--beam-subscriptionImpact-iconBackground-background":"#0a323c","--beam-subscriptionImpact-icon-height":"28px","--beam-subscriptionImpact-icon-margin":"auto","--beam-subscriptionImpact-icon-padding":"10px","--beam-subscriptionImpact-icon-borderRadius":"4px","--beam-subscriptionImpact-image-borderRadius":"4px","--beam-subscriptionImpact-image-minHeight":"0","--beam-subscriptionImpact-image-minWidth":"0","--beam-subscriptionImpact-cardDescription-padding":"0px","--beam-subscriptionImpact-card-progressBar-padding":"8px 0px","--beam-subscriptionImpact-card-progressBarLabel-gap":"10px","--beam-subscriptionImpact-card-progressBarLabel-textAlign":"right","--beam-subscriptionImpact-card-progressBarLabel-marginLeft":"8px","--beam-subscriptionImpact-card-linkContainer-textAlign":"left","--beam-subscriptionImpact-card-impactLink-textDecoration":"underline","--beam-subscriptionImpact-footer-textAlign":"center","--beam-subscriptionImpact-footer-marginTop":"10px","--beam-subscriptionImpact-share-button-icon-name":"share-2","--beam-subscriptionImpact-learnAbout-arrow-display":"block",...u("--beam-subscriptionImpact-title",{fontSize:"20px",fontWeight:"bold",lineHeight:"120%",textTransform:"capitalize",fontStyle:"normal",color:"#0a323c"}),...u("--beam-subscriptionImpact-descriptionPrefix",{fontSize:"14px",fontWeight:"800",lineHeight:"138%",fontStyle:"normal",color:"#2f302d",marginTop:"9px"}),...u("--beam-subscriptionImpact-description",{fontSize:"14px",fontWeight:"400",lineHeight:"138%",fontStyle:"normal",color:"#2f302d",marginTop:"9px"}),...u("--beam-subscriptionImpact-cardTitle",{fontSize:"12px",fontWeight:"bold",lineHeight:"120%",fontStyle:"normal",textTransform:"uppercase"}),...u("--beam-subscriptionImpact-cardDescription",{fontSize:"12px",fontWeight:"400",lineHeight:"18.2px",fontStyle:"normal",color:"#454a47"}),...u("--beam-subscriptionImpact-card-progressBarLabel",{fontSize:"10px",color:"#878a92"}),...u("--beam-subscriptionImpact-card-impactLink",{fontSize:"12px",fontWeight:"600",lineHeight:"16px",fontStyle:"normal",color:"#454a47",marginTop:"auto"})},r=this.impactDataController?.data?.config?.web?.theme||{},m={...e,...r};return Object.assign(Object.create({toCSS(){return ie(this)}}),m)}render(){const{data:e,loading:r,error:m}=this.impactDataController;if(r)return ae();if(m||e==null)return this.debug?te({error:m||new Error("No data")}):"";const t=e.community[0],a=e.personal[0],d=e.chain.name,f=n(this.configLang,a?.nonprofit.cause||""),h=a?.nonprofit.name,x=a?.impact?.goalProgressPercentage||0,I=!(a?.impact?.goalProgressPercentage>0||a?.impact?.goalCompletionText?.length>0),y=t?.impact?.goalProgressPercentage||0,P=`${x}% ${n(this.configLang,e?.config?.web?.additionalStrings?.percentFunded||"")||s[this.configLang].percentFunded()}`,F=`${y}% ${n(this.configLang,e?.config?.web?.additionalStrings?.percentFunded||"")||s[this.configLang].percentFunded()}`,E=t?.imageUrl||"",B=a?.imageUrl||"",N=a?.nonprofit.causeIconUrl,W=a?.nonprofit.causeIconSelectedUrl,g=this.cssVariables["--beam-SubscriptionImpact-cardStyle"],T=this.cssVariables["--beam-SubscriptionImpact-imagePosition"],v=g==="'image'",L=g==="'selected_icon'"?W:N,R=v?E:L,U=v?B:L,M=n(this.configLang,e?.config?.web?.dynamicStrings?.ctaTitle||"")||s[this.configLang].title({causeName:f}),D=n(this.configLang,e?.config?.web?.dynamicStrings?.ctaFutureTenseTitle||"")||s[this.configLang].futureTenseTitle({causeName:f}),j=G(e.store.communityPageURL)?e.chain.communityImpactUrl:e.store.communityPageURL,V=a?.nonprofit?.website,H=a?.share?.imageUrl,O=this.cssVariables["--beam-SubscriptionImpact-share-button-icon-name"]||"share-2",k=this.cssVariables["--beam-subscriptionImpact-learnAbout-arrow-display"]==="none";return p`
|
|
14
|
+
`}render(){return p`<sl-badge pill aria-label="${this.infoText}">${this.infoText}</sl-badge>`}}le([l({type:String})],A.prototype,"infoText"),customElements.get("beam-info-pill")||customElements.define("beam-info-pill",A);const me={"--beam-pillLabel-color-background":"#0A323C","--beam-pillLabel-color":"#fff","--beam-pillLabel-border":"#0A323C","--beam-pillLabel-border-width":"1px","--beam-pillLabel-font-size":"10px","--beam-pillLabel-font":"inherit","--beam-pillLabel-font-weight":"400","--beam-pillLabel-text-transform":"none","--beam-pillLabel-font-style":"italic","--beam-pillLabel-padding":"3px 4px"},s={en:{title:({causeName:i=""})=>`Your Subscription is Going Towards ${i} With Every Order`,futureTenseTitle:({causeName:i=""})=>`Your Subscription Will Go Towards ${i} With Every Order`,ctaMessagePrefix:()=>"At no extra cost, ",description:({nonprofit:i=""})=>`1% will be donated to ${i} for you, at no extra cost, every order.`,personalImpactTitle:()=>"You're Currently Funding",futureTensePersonalImpactTitle:()=>"You\u2019ll Be Funding",communityImpactTitle:()=>"Together We're Funding",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Learn about ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Learn about ${i} impact${e?"":" \u203A"}`,percentFunded:()=>"funded",progressPillText:()=>"\u{1F389} Impact begins once order is charged"},fr:{title:({causeName:i=""})=>`Votre abonnement contribue \xE0 ${i} \xE0 chaque commande`,futureTenseTitle:({causeName:i=""})=>`Votre abonnement contribuera \xE0 ${i} \xE0 chaque commande`,ctaMessagePrefix:()=>"Sans frais suppl\xE9mentaires, ",description:({nonprofit:i=""})=>`1% de chaque commande sera revers\xE9 \xE0 ${i} pour vous, sans frais suppl\xE9mentaires.`,personalImpactTitle:()=>"Vous financez actuellement",futureTensePersonalImpactTitle:()=>"Vous financerez",communityImpactTitle:()=>"Ensemble, nous finan\xE7ons",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`En savoir plus sur ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`En savoir plus sur l\u2019impact de ${i}${e?"":" \u203A"}`,percentFunded:()=>"financ\xE9",progressPillText:()=>"\u{1F389} L\u2019impact commence une fois la commande d\xE9bit\xE9e"},de:{title:({causeName:i=""})=>`Ihr Abonnement unterst\xFCtzt ${i} mit jeder Bestellung`,futureTenseTitle:({causeName:i=""})=>`Ihr Abonnement wird ${i} mit jeder Bestellung unterst\xFCtzen`,ctaMessagePrefix:()=>"Ohne zus\xE4tzliche Kosten, ",description:({nonprofit:i=""})=>`1% jeder Bestellung wird im Rahmen Ihres Abonnements an ${i} gespendet.`,personalImpactTitle:()=>"Sie unterst\xFCtzen derzeit",futureTensePersonalImpactTitle:()=>"Sie werden unterst\xFCtzen",communityImpactTitle:()=>"Gemeinsam unterst\xFCtzen wir",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Mehr \xFCber ${i} erfahren${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Mehr \xFCber die Wirkung von ${i} erfahren${e?"":" \u203A"}`,percentFunded:()=>"finanziert",progressPillText:()=>"\u{1F389} Wirkung beginnt, sobald die Bestellung abgerechnet wird"},es:{title:({causeName:i=""})=>`Tu suscripci\xF3n est\xE1 apoyando a ${i} con cada pedido`,futureTenseTitle:({causeName:i=""})=>`Tu suscripci\xF3n apoyar\xE1 a ${i} con cada pedido`,ctaMessagePrefix:()=>"Sin coste adicional, ",description:({nonprofit:i=""})=>`El 1% de cada pedido se donar\xE1 a ${i} en tu nombre.`,personalImpactTitle:()=>"Actualmente est\xE1s financiando",futureTensePersonalImpactTitle:()=>"Financiar\xE1s",communityImpactTitle:()=>"Juntos estamos financiando",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Conoce m\xE1s sobre ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Conoce m\xE1s sobre el impacto de ${i}${e?"":" \u203A"}`,percentFunded:()=>"financiado",progressPillText:()=>"\u{1F389} El impacto comienza una vez que se procese el pedido"},it:{title:({causeName:i=""})=>`Il tuo abbonamento sostiene ${i} con ogni ordine`,futureTenseTitle:({causeName:i=""})=>`Il tuo abbonamento sosterr\xE0 ${i} con ogni ordine`,ctaMessagePrefix:()=>"Senza alcun costo aggiuntivo, ",description:({nonprofit:i=""})=>`L'1% di ogni ordine sar\xE0 donato a ${i} per te.`,personalImpactTitle:()=>"Attualmente stai finanziando",futureTensePersonalImpactTitle:()=>"Finanzierai",communityImpactTitle:()=>"Insieme stiamo finanziando",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Scopri di pi\xF9 su ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Scopri di pi\xF9 sull\u2019impatto di ${i}${e?"":" \u203A"}`,percentFunded:()=>"finanziato",progressPillText:()=>"\u{1F389} L\u2019impatto inizia una volta che l\u2019ordine \xE8 stato addebitato"},pl:{title:({causeName:i=""})=>`Twoja subskrypcja wspiera ${i} przy ka\u017Cdym zam\xF3wieniu`,futureTenseTitle:({causeName:i=""})=>`Twoja subskrypcja b\u0119dzie wspiera\u0107 ${i} przy ka\u017Cdym zam\xF3wieniu`,ctaMessagePrefix:()=>"Bez dodatkowych koszt\xF3w, ",description:({nonprofit:i=""})=>`1% z ka\u017Cdego zam\xF3wienia zostanie przekazane na rzecz ${i} w Twoim imieniu.`,personalImpactTitle:()=>"Obecnie wspierasz",futureTensePersonalImpactTitle:()=>"B\u0119dziesz wspiera\u0107",communityImpactTitle:()=>"Razem wspieramy",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Dowiedz si\u0119 wi\u0119cej o ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Dowiedz si\u0119 wi\u0119cej o wp\u0142ywie ${i}${e?"":" \u203A"}`,percentFunded:()=>"sfinansowano",progressPillText:()=>"\u{1F389} Wp\u0142yw rozpoczyna si\u0119 po zrealizowaniu zam\xF3wienia"},ja:{title:({causeName:i=""})=>`Your Subscription is Going Towards ${i} With Every Order`,futureTenseTitle:({causeName:i=""})=>`Your Subscription Will Go Towards ${i} With Every Order`,ctaMessagePrefix:()=>"At no extra cost, ",description:({nonprofit:i=""})=>`1% will be donated to ${i} for you, at no extra cost, every order.`,personalImpactTitle:()=>"You're Currently Funding",futureTensePersonalImpactTitle:()=>"You\u2019ll Be Funding",communityImpactTitle:()=>"Together We're Funding",personalLinkCopy:({nonprofit:i="",hideArrow:e=!1})=>`Learn about ${i}${e?"":" \u203A"}`,communityLinkCopy:({brandName:i="",hideArrow:e=!1})=>`Learn about ${i} impact${e?"":" \u203A"}`,percentFunded:()=>"\u652F\u63F4\u6E08\u307F",progressPillText:()=>"\u{1F389} Impact begins once order is charged"}};var de=Object.defineProperty,c=(i,e,o,m)=>{for(var t=void 0,a=i.length-1,d;a>=0;a--)(d=i[a])&&(t=d(e,o,t)||t);return t&&de(e,o,t),t};class r extends k{constructor(){super(...arguments),this.baseUrl=q,this.lang="en",this.debug=!1,this.draftConfig=!1,this.showShareButton=!0,this.isMobile=window.innerWidth<720,this.getImpactData=async()=>(se(["apiKey","beamUserId","nonprofitId"],this),await Z({baseUrl:this.baseUrl,headers:J(this.apiKey),queryParams:{nonprofitId:this.nonprofitId,beamUserId:this.beamUserId,personalImpactLimit:1,communityImpactLimit:1,storeId:this.storeId,widgetName:"subscription-impact",draftConfig:this.draftConfig,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new ee(this,this.getImpactData),this.evaluateBreakPoints=z(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0}),this.resizeElements=z(()=>{S(this.impactTitleRefs),S(this.impactLinkRefs)},50,{maxWait:50,leading:!0})}get configLang(){return Q[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async updated(e){const o=["baseUrl","storeId","apiKey","beamUserId","lang"];for(const m of o)if(e.has(m)){await this.impactDataController.exec();break}this.resizeElements(),await this.handleFontLoad(this.resizeElements)}disconnectedCallback(){window.removeEventListener("resize",this.resizeElements),document.fonts.removeEventListener("loadingdone",this.resizeElements),super.disconnectedCallback()}async handleFontLoad(e){if(document.fonts.status==="loading")return await document.fonts.ready.catch(o=>X.error(o)),e()}get cssVariables(){const e={...Y,...K,...me,"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"12px","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-subscriptionImpact-impactCards-maxWidth":"900px","--beam-subscriptionImpact-headerContainer-desktop-textAlign":"left","--beam-subscriptionImpact-headerContainer-mobile-textAlign":"center","--beam-subscriptionImpact-descriptionContainer-marginTop":"10px","--beam-subscriptionImpact-cardContainer-marginTop":"15px","--beam-subscriptionImpact-cardContainer-gap":"20px","--beam-subscriptionImpact-card-borderRadius":"8px","--beam-subscriptionImpact-card-background":"#f8fbfb","--beam-subscriptionImpact-card-padding":"24px 28px 24px 24px","--beam-subscriptionImpact-card-marginRight":"0px","--beam-subscriptionImpact-card-marginTop":"10px","--beam-subscriptionImpact-card-gap":"5px","--beam-subscriptionImpact-cardTitle-textAlign":"left","--beam-subscriptionImpact-cardTitle-letterSpacing":"0.36px","--beam-SubscriptionImpact-cardStyle":"'selected_icon'","--beam-SubscriptionImpact-imagePosition":"'inline'","--beam-subscriptionImpact-imageBlock-height":"120px","--beam-subscriptionImpact-imageBlock-borderRadius":"4px","--beam-subscriptionImpact-iconBackground-width":"50px","--beam-subscriptionImpact-iconBackground-height":"50px","--beam-subscriptionImpact-iconBackground-borderRadius":"50%","--beam-subscriptionImpact-iconBackground-background":"#0a323c","--beam-subscriptionImpact-icon-height":"28px","--beam-subscriptionImpact-icon-margin":"auto","--beam-subscriptionImpact-icon-padding":"10px","--beam-subscriptionImpact-icon-borderRadius":"4px","--beam-subscriptionImpact-image-borderRadius":"4px","--beam-subscriptionImpact-image-minHeight":"0","--beam-subscriptionImpact-image-minWidth":"0","--beam-subscriptionImpact-cardDescription-padding":"0px","--beam-subscriptionImpact-card-progressBar-padding":"8px 0px","--beam-subscriptionImpact-card-progressBarLabel-gap":"10px","--beam-subscriptionImpact-card-progressBarLabel-textAlign":"right","--beam-subscriptionImpact-card-progressBarLabel-marginLeft":"8px","--beam-subscriptionImpact-card-linkContainer-textAlign":"left","--beam-subscriptionImpact-card-impactLink-textDecoration":"underline","--beam-subscriptionImpact-footer-textAlign":"center","--beam-subscriptionImpact-footer-marginTop":"10px","--beam-subscriptionImpact-share-button-icon-name":"share-2","--beam-subscriptionImpact-learnAbout-arrow-display":"block",...u("--beam-subscriptionImpact-title",{fontSize:"20px",fontWeight:"bold",lineHeight:"120%",textTransform:"capitalize",fontStyle:"normal",color:"#0a323c"}),...u("--beam-subscriptionImpact-descriptionPrefix",{fontSize:"14px",fontWeight:"800",lineHeight:"138%",fontStyle:"normal",color:"#2f302d",marginTop:"9px"}),...u("--beam-subscriptionImpact-description",{fontSize:"14px",fontWeight:"400",lineHeight:"138%",fontStyle:"normal",color:"#2f302d",marginTop:"9px"}),...u("--beam-subscriptionImpact-cardTitle",{fontSize:"12px",fontWeight:"bold",lineHeight:"120%",fontStyle:"normal",textTransform:"uppercase"}),...u("--beam-subscriptionImpact-cardDescription",{fontSize:"12px",fontWeight:"400",lineHeight:"18.2px",fontStyle:"normal",color:"#454a47"}),...u("--beam-subscriptionImpact-card-progressBarLabel",{fontSize:"10px",color:"#878a92"}),...u("--beam-subscriptionImpact-card-impactLink",{fontSize:"12px",fontWeight:"600",lineHeight:"16px",fontStyle:"normal",color:"#454a47",marginTop:"auto"})},o=this.impactDataController?.data?.config?.web?.theme||{},m={...e,...o};return Object.assign(Object.create({toCSS(){return ie(this)}}),m)}render(){const{data:e,loading:o,error:m}=this.impactDataController;if(o)return ae();if(m||e==null)return this.debug?te({error:m||new Error("No data")}):"";const t=e.community[0],a=e.personal[0],d=e.chain.name,f=n(this.configLang,a?.nonprofit.cause||""),h=a?.nonprofit.name,x=a?.impact?.goalProgressPercentage||0,I=!(a?.impact?.goalProgressPercentage>0||a?.impact?.goalCompletionText?.length>0),y=t?.impact?.goalProgressPercentage||0,P=`${x}% ${n(this.configLang,e?.config?.web?.additionalStrings?.percentFunded||"")||s[this.configLang].percentFunded()}`,B=`${y}% ${n(this.configLang,e?.config?.web?.additionalStrings?.percentFunded||"")||s[this.configLang].percentFunded()}`,F=t?.imageUrl||"",E=a?.imageUrl||"",N=a?.nonprofit.causeIconUrl,W=a?.nonprofit.causeIconSelectedUrl,g=this.cssVariables["--beam-SubscriptionImpact-cardStyle"],T=this.cssVariables["--beam-SubscriptionImpact-imagePosition"],v=g==="'image'",L=g==="'selected_icon'"?W:N,R=v?F:L,U=v?E:L,M=n(this.configLang,e?.config?.web?.dynamicStrings?.ctaTitle||"")||s[this.configLang].title({causeName:f}),D=n(this.configLang,e?.config?.web?.dynamicStrings?.ctaFutureTenseTitle||"")||s[this.configLang].futureTenseTitle({causeName:f}),j=G(e.store.communityPageURL)?e.chain.communityImpactUrl:e.store.communityPageURL,V=a?.nonprofit?.website,H=a?.share?.imageUrl,O=this.cssVariables["--beam-SubscriptionImpact-share-button-icon-name"]||"share-2",w=this.cssVariables["--beam-subscriptionImpact-learnAbout-arrow-display"]==="none";return p`
|
|
15
15
|
<style>
|
|
16
16
|
:host {
|
|
17
17
|
${this.cssVariables.toCSS()}
|
|
@@ -42,21 +42,22 @@ import{a as w,i as $,b as p,n as l,r as _,g as C}from"../chunks/lit-BEag9MFp.esm
|
|
|
42
42
|
class="card-container cardGrid ${this.isMobile?"card-container-mobile":""}"
|
|
43
43
|
id="beam-subscriptionImpact-card-container"
|
|
44
44
|
>
|
|
45
|
-
${this.renderInlineCard({title:I?n(this.configLang,e?.config?.web?.additionalStrings?.futureTensePersonalImpactTitle||"")||s[this.configLang].futureTensePersonalImpactTitle():n(this.configLang,e?.config?.web?.additionalStrings?.personalImpactTitle||"")||s[this.configLang].personalImpactTitle(),image:U,description:n(this.configLang,a?.impact?.description||""),link:V,linkText:n(this.configLang,e?.config?.web?.dynamicStrings?.personalLinkCopy||"")||s[this.configLang].personalLinkCopy({nonprofit:h,hideArrow:
|
|
46
|
-
${this.renderInlineCard({title:n(this.configLang,e?.config?.web?.additionalStrings?.communityImpactTitle||"")||s[this.configLang].communityImpactTitle(),image:R,description:n(this.configLang,t?.impact?.description||""),link:j,linkText:n(this.configLang,e?.config?.web?.dynamicStrings?.communityLinkCopy||"")||s[this.configLang].communityLinkCopy({brandName:d,hideArrow:
|
|
45
|
+
${this.renderInlineCard({title:I?n(this.configLang,e?.config?.web?.additionalStrings?.futureTensePersonalImpactTitle||"")||s[this.configLang].futureTensePersonalImpactTitle():n(this.configLang,e?.config?.web?.additionalStrings?.personalImpactTitle||"")||s[this.configLang].personalImpactTitle(),image:U,description:n(this.configLang,a?.impact?.description||""),link:V,linkText:n(this.configLang,e?.config?.web?.dynamicStrings?.personalLinkCopy||"")||s[this.configLang].personalLinkCopy({nonprofit:h,hideArrow:w}),progressBarValue:x,progressBarText:P,infoPill:n(this.configLang,e?.config?.web?.additionalStrings?.progressPillText||"")||s[this.configLang].progressPillText(),imageType:g,cardType:"personal",imagePosition:T})}
|
|
46
|
+
${this.renderInlineCard({title:n(this.configLang,e?.config?.web?.additionalStrings?.communityImpactTitle||"")||s[this.configLang].communityImpactTitle(),image:R,description:n(this.configLang,t?.impact?.description||""),link:j,linkText:n(this.configLang,e?.config?.web?.dynamicStrings?.communityLinkCopy||"")||s[this.configLang].communityLinkCopy({brandName:d,hideArrow:w}),progressBarValue:y,progressBarText:B,infoPill:n(this.configLang,e?.config?.web?.additionalStrings?.progressPillText||"")||s[this.configLang].progressPillText(),imageType:g,cardType:"community",imagePosition:T})}
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
${this.showShareButton?p`<div class="footer" part="social-share">
|
|
50
|
+
<beam-share-button
|
|
51
|
+
exportparts="share-button"
|
|
52
|
+
imageUrl="${H}"
|
|
53
|
+
brandName="${d}"
|
|
54
|
+
shareIcon="${O}"
|
|
55
|
+
buttonText="${n(this.configLang,e?.config?.web?.additionalStrings?.shareButtonText||"")}"
|
|
56
|
+
configLang="${this.configLang}"
|
|
57
|
+
></beam-share-button>
|
|
58
|
+
</div>`:""}
|
|
58
59
|
</div>
|
|
59
|
-
`}renderInlineCard(e){const
|
|
60
|
+
`}renderInlineCard(e){const o=e.progressBarValue!==void 0&&e.progressBarValue<=1&&e.cardType==="personal";return p`
|
|
60
61
|
<div class="inline-card ${this.isMobile?"":"inline-card-desktop"}">
|
|
61
62
|
${e.image&&e.imagePosition==="'block'"&&e.imageType==="'image'"?p` <div
|
|
62
63
|
class="image-block-container"
|
|
@@ -88,7 +89,7 @@ import{a as w,i as $,b as p,n as l,r as _,g as C}from"../chunks/lit-BEag9MFp.esm
|
|
|
88
89
|
<div class="impact-container" part="details">
|
|
89
90
|
<p class="card-description">${e.description}</p>
|
|
90
91
|
<div class="card-progress-bar">
|
|
91
|
-
${
|
|
92
|
+
${o?p` <beam-info-pill infoText="${e.infoPill}"></beam-info-pill> `:p`
|
|
92
93
|
<beam-progress-bar value="${e.progressBarValue}" style="flex: 1 0;"> </beam-progress-bar>
|
|
93
94
|
<span class="details-funding-progress-label"> ${e.progressBarText} </span>
|
|
94
95
|
`}
|
|
@@ -99,7 +100,7 @@ import{a as w,i as $,b as p,n as l,r as _,g as C}from"../chunks/lit-BEag9MFp.esm
|
|
|
99
100
|
</div>
|
|
100
101
|
</div>
|
|
101
102
|
</div>
|
|
102
|
-
`}}
|
|
103
|
+
`}}r.tagName="beam-subscription-impact",r.styles=[ne,ce,$`
|
|
103
104
|
:host {
|
|
104
105
|
display: block;
|
|
105
106
|
font-family: var(--beam-fontFamily);
|
|
@@ -279,5 +280,5 @@ import{a as w,i as $,b as p,n as l,r as _,g as C}from"../chunks/lit-BEag9MFp.esm
|
|
|
279
280
|
text-align: var(--beam-subscriptionImpact-footer-textAlign);
|
|
280
281
|
margin-top: var(--beam-subscriptionImpact-footer-marginTop);
|
|
281
282
|
}
|
|
282
|
-
`,re({gap:"var(--beam-subscriptionImpact-cardContainer-gap)",itemMinWidth:"250px",columnCount:"2"})],c([l({type:String,reflect:!0})],
|
|
283
|
+
`,re({gap:"var(--beam-subscriptionImpact-cardContainer-gap)",itemMinWidth:"250px",columnCount:"2"})],c([l({type:String,reflect:!0})],r.prototype,"baseUrl"),c([l({type:String,reflect:!1})],r.prototype,"apiKey"),c([l({type:Number})],r.prototype,"storeId"),c([l({type:String,reflect:!0})],r.prototype,"nonprofitId"),c([l({type:String,reflect:!0})],r.prototype,"beamUserId"),c([l({type:String})],r.prototype,"lang"),c([l({type:Boolean})],r.prototype,"debug"),c([l({type:Boolean})],r.prototype,"draftConfig"),c([l({type:Boolean,converter:i=>`${i}`?.toLowerCase()==="true"})],r.prototype,"showShareButton"),c([_()],r.prototype,"isMobile"),c([C(".card-title")],r.prototype,"impactTitleRefs"),c([C(".impact-link")],r.prototype,"impactLinkRefs"),oe(r);export{r as BeamSubscriptionImpact};
|
|
283
284
|
//# sourceMappingURL=subscription-impact.esm.js.map
|